@jcbautistam/custom-table
Version:
Librería de tabla reutilizable con acciones, filtros, exportación y más.
146 lines (145 loc) • 8.14 kB
TypeScript
import { OnInit, OnChanges, SimpleChanges, EventEmitter, AfterViewInit, ElementRef, QueryList, OnDestroy } from '@angular/core';
import { BsDatepickerConfig, BsDaterangepickerConfig } from 'ngx-bootstrap/datepicker';
import { MatPaginator, PageEvent } from '@angular/material/paginator';
import { MatTableDataSource } from '@angular/material/table';
import { MatDialog } from '@angular/material/dialog';
import { Observable } from 'rxjs';
import { HttpParams } from '@angular/common/http';
import { TableAction } from '../../Interfaces/TableAction';
import { ConfiguracionParametros, ParametrosGenerales } from '../../Models/ParametrosGenerales';
import { ExportTableExcelService } from '../../Services/ExportTableExcel.service';
import { LoadingService } from '../../Services/loading.service';
import { ExportNotificationService } from '../../Services/exportNotification.service';
import { ColumnConfig } from '../../Interfaces/ColumnConfig';
import * as i0 from "@angular/core";
export declare class CustomTableComponent implements OnInit, AfterViewInit, OnDestroy, OnChanges {
private excelService;
dialog: MatDialog;
private configParams;
loadingService: LoadingService;
private exportNotificationService;
[x: string]: any;
private destroy$;
private exportSubscription;
isExportInProgress: boolean;
bsConfigGeneral: Partial<BsDatepickerConfig> | undefined;
maxDate: Date;
minDate: Date;
rowSeleccionada: any;
totalRecords: number;
formularioModificado: boolean;
isSelectAll: boolean;
originalData: any[];
dataActives: any[];
filters: {
[key: string]: string | boolean | null;
};
dataSource: MatTableDataSource<any>;
displayedColumns: string[];
styleRow: {
[clave: string]: string;
};
isToggleChecked: boolean;
filterInputs: QueryList<ElementRef>;
paginator: MatPaginator;
matTableWrapper: ElementRef;
get columnKeys(): string[];
data: any[];
dataSelect: any[][];
columnConfigs: any;
withHeader: boolean;
tableConfigs: any;
nombreMenu: string;
nombreTabla: string;
crearRoute: string;
showCreateButton: boolean;
showCreateButtonModal: boolean;
showExportarButton: boolean;
excelFileName: string;
isLoading: boolean;
showCreateButtonDetGral: boolean;
showRefreshButton: boolean;
showAddButton: boolean;
showConfColumnsButton: boolean;
showFilterInactivos: boolean;
actions: TableAction[];
resaltarSeleccion: boolean;
mostrarFiltroGeneralFechas: boolean;
showSelectAll: boolean;
columnsReqMin: number;
isReport: boolean;
fetchDataFunction: (params: HttpParams, extraParam?: any) => Observable<any>;
parametros: ParametrosGenerales;
extraParams: {
[key: string]: any;
};
centerTable: boolean;
tableHeight: string;
showGranTotal: boolean;
widthColumn: string;
onSelectAll: EventEmitter<void>;
cambiarEstatusEvent: EventEmitter<any>;
createEvent: EventEmitter<void>;
refreshEvent: EventEmitter<void>;
AddEvent: EventEmitter<void>;
onCreate: EventEmitter<void>;
enviarItemEvent: EventEmitter<void>;
filtroFechaGeneralEvent: EventEmitter<(Date | undefined)[]>;
changeData: EventEmitter<any>;
filtroFechaReportEvent: EventEmitter<Date | undefined>;
constructor(excelService: ExportTableExcelService, dialog: MatDialog, configParams: ConfiguracionParametros, loadingService: LoadingService, exportNotificationService: ExportNotificationService);
getColumnConfigWithDefault(columnKey: string): ColumnConfig;
shouldBlockRow(element: any): boolean;
predefinedRanges: BsCustomDates[];
bsConfig: Partial<BsDaterangepickerConfig>;
openColumnVisibilityDialog(): void;
updateDisplayedColumns(): void;
onValueChangeDateGeneral(value?: (Date | undefined)[]): void;
onValueChangeDate(value?: (Date | undefined)[], column?: string): void;
ngAfterViewInit(): void;
ngOnInit(): void;
ngOnChanges(changes: SimpleChanges): void;
applyFilter: (event: any, column: string) => void;
columnMatches(row: any): boolean;
applyDateFilter(startDate: Date, endDate: Date, column: string): void;
resetDateFilter(column: string): void;
fechaToString(fecha: Date): string;
applyBooleanFilter(value: boolean | null, column: string): void;
applyFilterActives: (value: boolean) => void;
updateData: () => void;
enviarItem(item: any): void;
refreshTable: () => void;
agregarRegistro(): void;
cambiarEstatus(item: any): void;
exportTable(): void;
onValueChangeDateReport(value?: Date | undefined): void;
create(): void;
get isDataEmpty(): boolean;
shouldHideText(row: any): boolean;
loadData: () => void;
onPageChange(event: PageEvent): void;
onCheckSelectAll(event: any): void;
/** Opciones de tamaño de página transformadas */
transformedPageSizeOptions(options: number[]): number[];
/**
* Verifica si hay overflow horizontal en la tabla y aplica clase correspondiente
*/
private checkForHorizontalOverflow;
private adjustTableHeight;
/**
* Verifica si hay espacio vacío después del último registro y aplica la clase correspondiente
*/
private checkEmptySpace;
/**
* Calcula la altura del contenido de la tabla (filas)
*/
private calculateContentHeight;
ngOnDestroy(): void;
static ɵfac: i0.ɵɵFactoryDeclaration<CustomTableComponent, never>;
static ɵcmp: i0.ɵɵComponentDeclaration<CustomTableComponent, "custom-table", never, { "data": { "alias": "data"; "required": false; }; "dataSelect": { "alias": "dataSelect"; "required": false; }; "columnConfigs": { "alias": "columnConfigs"; "required": false; }; "withHeader": { "alias": "withHeader"; "required": false; }; "tableConfigs": { "alias": "tableConfigs"; "required": false; }; "nombreMenu": { "alias": "nombreMenu"; "required": false; }; "nombreTabla": { "alias": "nombreTabla"; "required": false; }; "crearRoute": { "alias": "crearRoute"; "required": false; }; "showCreateButton": { "alias": "showCreateButton"; "required": false; }; "showCreateButtonModal": { "alias": "showCreateButtonModal"; "required": false; }; "showExportarButton": { "alias": "showExportarButton"; "required": false; }; "excelFileName": { "alias": "excelFileName"; "required": false; }; "showCreateButtonDetGral": { "alias": "showCreateButtonDetGral"; "required": false; }; "showRefreshButton": { "alias": "showRefreshButton"; "required": false; }; "showAddButton": { "alias": "showAddButton"; "required": false; }; "showConfColumnsButton": { "alias": "showConfColumnsButton"; "required": false; }; "showFilterInactivos": { "alias": "showFilterInactivos"; "required": false; }; "actions": { "alias": "actions"; "required": false; }; "resaltarSeleccion": { "alias": "resaltarSeleccion"; "required": false; }; "mostrarFiltroGeneralFechas": { "alias": "mostrarFiltroGeneralFechas"; "required": false; }; "showSelectAll": { "alias": "showSelectAll"; "required": false; }; "columnsReqMin": { "alias": "columnsReqMin"; "required": false; }; "isReport": { "alias": "isReport"; "required": false; }; "fetchDataFunction": { "alias": "fetchDataFunction"; "required": false; }; "parametros": { "alias": "parametros"; "required": false; }; "extraParams": { "alias": "extraParams"; "required": false; }; "centerTable": { "alias": "centerTable"; "required": false; }; "tableHeight": { "alias": "tableHeight"; "required": false; }; "showGranTotal": { "alias": "showGranTotal"; "required": false; }; "widthColumn": { "alias": "widthColumn"; "required": false; }; }, { "onSelectAll": "onSelectAll"; "cambiarEstatusEvent": "cambiarEstatusEvent"; "createEvent": "createEvent"; "refreshEvent": "refreshEvent"; "AddEvent": "AddEvent"; "onCreate": "onCreate"; "enviarItemEvent": "enviarItemEvent"; "filtroFechaGeneralEvent": "filtroFechaGeneralEvent"; "changeData": "changeData"; "filtroFechaReportEvent": "filtroFechaReportEvent"; }, never, never, false, never>;
}
interface BsCustomDates {
label: string;
value: Date[];
}
export {};