@jvsoft/components 0.0.3 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,12 +1,18 @@
1
1
  import { __decorate } from 'tslib';
2
- import * as i0 from '@angular/core';
3
- import { Input, ViewChild, Optional, Component, inject, Pipe, NgModule, EventEmitter, ContentChildren, ViewChildren, Output, HostListener, Directive, Injectable, ElementRef, HostBinding } from '@angular/core';
2
+ import { trigger, state, transition, style, animate } from '@angular/animations';
3
+ import { TemplatePortal } from '@angular/cdk/portal';
4
4
  import * as i1 from '@angular/common';
5
5
  import { CommonModule, DecimalPipe } from '@angular/common';
6
+ import * as i0 from '@angular/core';
7
+ import { EventEmitter, HostListener, Output, Input, Directive, ViewChild, Optional, Component, inject, Pipe, NgModule, ContentChildren, ViewChildren, Injectable, ElementRef, HostBinding } from '@angular/core';
6
8
  import * as i1$2 from '@angular/forms';
7
- import { ReactiveFormsModule, FormsModule, Validators, FormControl, FormGroup } from '@angular/forms';
9
+ import { Validators, FormControl, FormGroup, ReactiveFormsModule, FormsModule } from '@angular/forms';
10
+ import * as i14 from '@angular/material/badge';
11
+ import { MatBadgeModule } from '@angular/material/badge';
8
12
  import * as i3$1 from '@angular/material/checkbox';
9
13
  import { MatCheckboxModule } from '@angular/material/checkbox';
14
+ import * as i5$1 from '@angular/material/core';
15
+ import { MatRipple, MatRippleModule } from '@angular/material/core';
10
16
  import * as i6 from '@angular/material/divider';
11
17
  import { MatDividerModule } from '@angular/material/divider';
12
18
  import * as i5 from '@angular/material/icon';
@@ -15,28 +21,292 @@ import * as i8 from '@angular/material/menu';
15
21
  import { MatMenuModule } from '@angular/material/menu';
16
22
  import * as i9 from '@angular/material/paginator';
17
23
  import { MatPaginatorModule, MatPaginator, MAT_PAGINATOR_DEFAULT_OPTIONS } from '@angular/material/paginator';
18
- import * as i5$1 from '@angular/material/core';
19
- import { MatRipple, MatRippleModule } from '@angular/material/core';
20
24
  import * as i3 from '@angular/material/sort';
21
25
  import { MatSortModule, MatSort } from '@angular/material/sort';
22
26
  import * as i2 from '@angular/material/table';
23
27
  import { MatColumnDef, MatTable, MatTableModule, MatTableDataSource, MatFooterRow, MatRow } from '@angular/material/table';
24
28
  import * as i4 from '@angular/material/tooltip';
25
29
  import { MatTooltipModule } from '@angular/material/tooltip';
26
- import { Subject, takeUntil, of, fromEvent } from 'rxjs';
27
- import shortHash from 'shorthash2';
28
30
  import { untilDestroyed, UntilDestroy } from '@ngneat/until-destroy';
31
+ import moment from 'moment';
32
+ import { Subject, takeUntil, of, fromEvent } from 'rxjs';
29
33
  import { map, filter, take } from 'rxjs/operators';
30
- import { TemplatePortal } from '@angular/cdk/portal';
31
- import { trigger, state, transition, style, animate } from '@angular/animations';
34
+ import shortHash from 'shorthash2';
32
35
  import * as i1$1 from '@angular/platform-browser';
33
36
  import { DomSanitizer } from '@angular/platform-browser';
34
- import * as i14 from '@angular/material/badge';
35
- import { MatBadgeModule } from '@angular/material/badge';
36
- import moment from 'moment';
37
37
  import * as XLSX from 'xlsx';
38
38
  import * as i2$1 from '@angular/cdk/overlay';
39
39
 
40
+ function buscarEnArray(coleccion, idBuscar, dato) {
41
+ if (!Array.isArray(coleccion) || coleccion.length === 0)
42
+ return null; // 🔹 Validación de entrada
43
+ return Array.isArray(idBuscar)
44
+ ? coleccion.find(item => idBuscar.every((campo, idx) => item[campo] === dato[idx])) || null
45
+ : coleccion.find(item => item[idBuscar] === dato) || null;
46
+ }
47
+ function formatearFecha(val, hora = '00:00:00') {
48
+ if (val) {
49
+ if (val.length <= 10) {
50
+ val = val + ' ' + hora;
51
+ }
52
+ return new Date(val);
53
+ }
54
+ return val;
55
+ }
56
+ function esNumero(value) {
57
+ return !isNaN(Number(value));
58
+ }
59
+ function capitalizarTexto(texto) {
60
+ texto = texto.replace(/_/g, ' ');
61
+ texto = texto.replace(/-/g, ' ');
62
+ const textoCortado = texto.split(' ');
63
+ const nText = [];
64
+ textoCortado.forEach(textActual => {
65
+ nText.push(textActual.charAt(0).toUpperCase() + textActual.slice(1));
66
+ });
67
+ return nText.join(' ');
68
+ }
69
+ function getBrowserName() {
70
+ const agent = window.navigator.userAgent.toLowerCase();
71
+ switch (true) {
72
+ case agent.indexOf('edge') > -1:
73
+ return 'edge';
74
+ case agent.indexOf('opr') > -1 && !!window.opr:
75
+ return 'opera';
76
+ case agent.indexOf('chrome') > -1 && !!window.chrome:
77
+ return 'chrome';
78
+ case agent.indexOf('trident') > -1:
79
+ return 'ie';
80
+ case agent.indexOf('firefox') > -1:
81
+ return 'firefox';
82
+ case agent.indexOf('safari') > -1:
83
+ return 'safari';
84
+ default:
85
+ return 'other';
86
+ }
87
+ }
88
+
89
+ class DataModel {
90
+ modelosChk = {}; // Usar any para valores dinámicos
91
+ checkbox;
92
+ constructor() {
93
+ this.checkbox = new ForCheckboxModel(this);
94
+ }
95
+ generarId(row, campoValor, separador = '') {
96
+ if (typeof campoValor == 'string') {
97
+ campoValor = [campoValor];
98
+ }
99
+ return campoValor.map(data => row[data]).join(separador);
100
+ }
101
+ // Agrega controles al objeto modelosChk
102
+ agregarControles(lista, idLista, limpiar = true, campoValor = null, campoValorSeparador = '') {
103
+ if (limpiar) {
104
+ this.modelosChk = {};
105
+ }
106
+ const asignarValor = (dat, idLista, campoValor, key) => {
107
+ if (!key) {
108
+ key = dat[idLista] + (campoValor.includes('.') ? '' : `.${campoValor}`);
109
+ }
110
+ const mat = campoValor.match(/^([in])[A-Z][a-zA-Z]+/);
111
+ if (mat) {
112
+ this.modelosChk[key] = dat[campoValor] * 1;
113
+ }
114
+ else {
115
+ this.modelosChk[key] = dat[campoValor];
116
+ }
117
+ };
118
+ lista.forEach(dat => {
119
+ if (campoValor === null) {
120
+ // Caso 1: Sin campoValor, se asigna false
121
+ this.modelosChk[dat[idLista]] = false;
122
+ }
123
+ else if (typeof campoValor === 'string') {
124
+ // Caso 2: campoValor es un string
125
+ asignarValor(dat, idLista, campoValor, dat[idLista]);
126
+ }
127
+ else if (campoValorSeparador) {
128
+ const idStr = this.generarId(dat, campoValor, campoValorSeparador);
129
+ // Caso 2: campoValor es un string
130
+ asignarValor(dat, idLista, '.', idStr);
131
+ }
132
+ else {
133
+ // Caso 3: campoValor es un array de strings
134
+ campoValor.forEach(data => asignarValor(dat, idLista, data));
135
+ }
136
+ });
137
+ }
138
+ // Establece el estado de un índice
139
+ setState(idx, state) {
140
+ this.modelosChk[idx] = state;
141
+ }
142
+ // Obtiene el estado de un índice
143
+ getState(idx) {
144
+ return this.modelosChk[idx];
145
+ }
146
+ getDataMultiple(idx) {
147
+ const camposMod = Object.keys(this.modelosChk).filter(key => key.split('.')[0] == idx);
148
+ const vRet = {};
149
+ camposMod.forEach(key => {
150
+ vRet[key.split('.')[1]] = this.modelosChk[key];
151
+ });
152
+ return vRet;
153
+ }
154
+ // Genera una lista basada en el estado de los índices
155
+ generarLista(tipoRetorno = null, esCampoNumerico = false) {
156
+ const strLista = [];
157
+ const objLista = {};
158
+ Object.keys(this.modelosChk).forEach(key => {
159
+ if ((esCampoNumerico && esNumero(this.modelosChk[key])) ||
160
+ (this.modelosChk[key])) {
161
+ strLista.push(key);
162
+ objLista[key] = this.modelosChk[key];
163
+ }
164
+ });
165
+ if (tipoRetorno === 'array') {
166
+ return strLista;
167
+ }
168
+ if (tipoRetorno === 'object') {
169
+ return objLista;
170
+ }
171
+ return strLista.join(',');
172
+ }
173
+ generarFormGroupFromModelosChk(tipo) {
174
+ const formGroupObj = {};
175
+ let validadores = [];
176
+ if (tipo == 'number') {
177
+ validadores = [
178
+ Validators.required,
179
+ Validators.min(1)
180
+ ];
181
+ }
182
+ Object.keys(this.modelosChk).forEach(key => {
183
+ formGroupObj[key] = new FormControl(this.modelosChk[key], validadores);
184
+ });
185
+ return new FormGroup(formGroupObj);
186
+ // return this.formBuilder.group(formGroupObj);
187
+ }
188
+ }
189
+ class ForCheckboxModel {
190
+ modeloCheck;
191
+ constructor(modeloCheck) {
192
+ this.modeloCheck = modeloCheck;
193
+ }
194
+ get cantidadActivos() {
195
+ return Object.values(this.modeloCheck.modelosChk).filter(Boolean).length;
196
+ }
197
+ get existenActivados() {
198
+ return this.cantidadActivos > 0;
199
+ }
200
+ get todosActivos() {
201
+ const total = Object.keys(this.modeloCheck.modelosChk).length;
202
+ const activos = this.cantidadActivos;
203
+ return activos > 0 && total === activos;
204
+ }
205
+ get algunosActivos() {
206
+ const total = Object.keys(this.modeloCheck.modelosChk).length;
207
+ const activos = this.cantidadActivos;
208
+ return activos > 0 && total !== activos;
209
+ }
210
+ establecerTodos(activo) {
211
+ Object.keys(this.modeloCheck.modelosChk).forEach(idx => this.modeloCheck.modelosChk[idx] = activo);
212
+ }
213
+ }
214
+
215
+ class MatRowKeyboardSelectionDirective {
216
+ el;
217
+ rows;
218
+ renderedData;
219
+ tabla; // Entrada: Referencia a la tabla
220
+ rowModel; // Entrada: Modelo de fila actual
221
+ seleccionarSiguiente = new EventEmitter(); // Salida: Evento al seleccionar siguiente
222
+ unsubscriber$ = new Subject();
223
+ constructor(el) {
224
+ this.el = el;
225
+ }
226
+ ngOnInit() {
227
+ // Asignar tabindex si no está definido
228
+ if (this.el.nativeElement.tabIndex < 0) {
229
+ this.el.nativeElement.tabIndex = 0;
230
+ }
231
+ // Obtener la fuente de datos de la tabla
232
+ const dataSource = this.tabla.dataSource;
233
+ // Suscribirse a los cambios en los datos
234
+ dataSource.connect().pipe(takeUntil(this.unsubscriber$)).subscribe(data => {
235
+ this.renderedData = data;
236
+ this.rows = Array.from(this.getTableRows());
237
+ });
238
+ }
239
+ ngOnDestroy() {
240
+ // Finalizar la suscripción al destruir la directiva
241
+ this.unsubscriber$.next(null);
242
+ this.unsubscriber$.complete();
243
+ }
244
+ onKeydown(event) {
245
+ var element = event.target;
246
+ if (element.tagName === "INPUT") {
247
+ event.stopPropagation();
248
+ }
249
+ else {
250
+ const currentIndex = this.renderedData.findIndex(row => row === this.rowModel);
251
+ const eRef = event.target;
252
+ this.rows = this.rows.filter(elem => elem.hasAttribute('id'));
253
+ const arrayFilas = Array.from(this.rows);
254
+ const fElem = arrayFilas.filter(elem => elem.id == eRef.id).pop();
255
+ const cElemIdx = arrayFilas.findIndex(elem => elem == fElem);
256
+ let newRow;
257
+ // Controlar las teclas presionadas
258
+ switch (event.key) {
259
+ case 'ArrowDown':
260
+ newRow = this.rows[cElemIdx + 1];
261
+ break;
262
+ case 'ArrowUp':
263
+ newRow = this.rows[cElemIdx - 1];
264
+ break;
265
+ case 'Enter':
266
+ case ' ':
267
+ this.seleccionarSiguiente.next(this.renderedData[currentIndex]);
268
+ event.preventDefault();
269
+ break;
270
+ }
271
+ // Enfocar la nueva fila seleccionada
272
+ if (newRow) {
273
+ newRow.classList.add('estaFocus');
274
+ newRow.focus();
275
+ }
276
+ }
277
+ }
278
+ getTableRows() {
279
+ let el = this.el.nativeElement;
280
+ // Recorrer los elementos padres hasta encontrar la tabla
281
+ while (el && el.parentNode) {
282
+ el = el.parentNode;
283
+ // Verificar si es una tabla de material
284
+ if (el.tagName && el.tagName.toLowerCase() === 'mat-table' || el.hasAttribute('mat-table')) {
285
+ return el.querySelectorAll('mat-row, tr[mat-row]');
286
+ }
287
+ }
288
+ return undefined;
289
+ }
290
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.7", ngImport: i0, type: MatRowKeyboardSelectionDirective, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive });
291
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.1.7", type: MatRowKeyboardSelectionDirective, isStandalone: true, selector: "[matRowKeyboardSelection]", inputs: { tabla: ["matRowKeyboardSelection", "tabla"], rowModel: "rowModel" }, outputs: { seleccionarSiguiente: "seleccionarSiguiente" }, host: { listeners: { "keydown": "onKeydown($event)" } }, ngImport: i0 });
292
+ }
293
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.7", ngImport: i0, type: MatRowKeyboardSelectionDirective, decorators: [{
294
+ type: Directive,
295
+ args: [{
296
+ selector: '[matRowKeyboardSelection]'
297
+ }]
298
+ }], ctorParameters: () => [{ type: i0.ElementRef }], propDecorators: { tabla: [{
299
+ type: Input,
300
+ args: ['matRowKeyboardSelection']
301
+ }], rowModel: [{
302
+ type: Input
303
+ }], seleccionarSiguiente: [{
304
+ type: Output
305
+ }], onKeydown: [{
306
+ type: HostListener,
307
+ args: ['keydown', ['$event']]
308
+ }] } });
309
+
40
310
  class ColumnTypeComponent {
41
311
  table;
42
312
  column;
@@ -378,300 +648,122 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.7", ngImpor
378
648
  ColumnTypeMoneyComponent,
379
649
  ColumnTypeNumberComponent,
380
650
  ColumnTypeDateComponent,
381
- ColumnTypeIconsComponent,
382
- ColumnTypeSinoComponent,
383
- ColumnTypeProgressbarComponent,
384
- ]
385
- }]
386
- }] });
387
-
388
- class TablaMantenimientoColumnDefsComponent {
389
- table;
390
- cdRef;
391
- objThis;
392
- nombreColeccion;
393
- colDetalle;
394
- chkLista; // = new DataModel();
395
- chkListaChange = new EventEmitter();
396
- columnDefLocales;
397
- columnDefEnSubComponentes;
398
- constructor(table, cdRef) {
399
- this.table = table;
400
- this.cdRef = cdRef;
401
- }
402
- ngAfterContentInit() {
403
- if (this.table) {
404
- console.log('ngAfterContentInit');
405
- console.log(this.columnDefEnSubComponentes);
406
- console.log(this.columnDefLocales);
407
- this.cdRef.detectChanges();
408
- this.columnDefEnSubComponentes.forEach(refCol => {
409
- this.table.addColumnDef(refCol);
410
- });
411
- this.columnDefLocales.forEach(refCol => {
412
- this.table.addColumnDef(refCol);
413
- });
414
- }
415
- }
416
- trackByProperty(index, column) {
417
- return column.property;
418
- }
419
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.7", ngImport: i0, type: TablaMantenimientoColumnDefsComponent, deps: [{ token: i2.MatTable, optional: true }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
420
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.1.7", type: TablaMantenimientoColumnDefsComponent, isStandalone: true, selector: "jvs-tabla-mantenimiento-column-defs", inputs: { objThis: "objThis", nombreColeccion: "nombreColeccion", colDetalle: "colDetalle", chkLista: "chkLista" }, outputs: { chkListaChange: "chkListaChange" }, queries: [{ propertyName: "columnDefEnSubComponentes", predicate: MatColumnDef, descendants: true }], viewQueries: [{ propertyName: "columnDefLocales", predicate: MatColumnDef, descendants: true }], ngImport: i0, template: "<ng-content></ng-content>\n\n\n\n<ng-container *ngFor=\"let column of colDetalle; trackBy: trackByProperty\">\n\n <ng-container *ngIf=\"column.type === 'expandir'\" [matColumnDef]=\"column.property\">\n\n <th *matHeaderCellDef class=\"w-4\" mat-header-cell> <span [innerHTML]=\"column.label ?? ''\">{{ column.label }} </span></th>\n <td *matCellDef=\"let row\" class=\"w-4 text-center\" mat-cell>\n <button type=\"button\" class=\"boton-circular text-primary-contrast bg-primary mat-elevation-z2\" matRipple\n *ngIf=\"column.click\"\n (click)=\"column.click(row); row.isExpanded = !row.isExpanded; $event.stopPropagation()\"\n matTooltip=\"Expandir / Contraer\">\n <mat-icon class=\"icon-xs\" [svgIcon]=\"(row.isExpanded ? 'roundExpandLess' : 'roundExpandMore')\"></mat-icon>\n </button>\n <button type=\"button\" class=\"boton-circular text-primary-contrast bg-primary mat-elevation-z2\" matRipple\n *ngIf=\"!column.click\"\n (click)=\"row.isExpanded = !row.isExpanded; $event.stopPropagation()\"\n matTooltip=\"Expandir / Contraer\">\n <mat-icon class=\"icon-xs\" [svgIcon]=\"(row.isExpanded ? 'roundExpandLess' : 'roundExpandMore')\"></mat-icon>\n </button>\n </td>\n <td *matFooterCellDef [ngClass]=\"column.cssFooterClasses\" mat-footer-cell></td>\n\n </ng-container>\n <ng-container *ngIf=\"column.type === 'checkbox'\" [matColumnDef]=\"column.property\">\n\n <th *matHeaderCellDef [ngClass]=\"column.cssClassesTH\" class=\"w-4 text-center\" mat-header-cell>\n <mat-checkbox *ngIf=\"chkLista\"\n (click)=\"$event.stopPropagation()\"\n (change)=\"chkLista.checkbox.establecerTodos($event.checked)\"\n [indeterminate]=\"chkLista.checkbox.algunosActivos\"\n [checked]=\"chkLista.checkbox.todosActivos\"\n ></mat-checkbox>\n </th>\n <td *matCellDef=\"let row\" class=\"w-4 text-center\" mat-cell>\n <mat-checkbox *ngIf=\"chkLista\"\n (click)=\"$event.stopPropagation()\"\n [(ngModel)]=\"chkLista.modelosChk[chkLista.generarId(row, (column.chkField ?? column.property), column.chkFieldSeparador)]\"\n [ngModelOptions]=\"{standalone: true}\"\n ></mat-checkbox>\n\n </td>\n <td *matFooterCellDef [ngClass]=\"column.cssFooterClasses\" mat-footer-cell></td>\n\n </ng-container>\n <ng-container *ngIf=\"column.type === 'estiloEstablecido'\" [matColumnDef]=\"column.property\">\n\n <th *matHeaderCellDef [ngClass]=\"column.cssClassesTH\" class=\"uppercase text-center\" mat-header-cell\n mat-sort-header\n [disabled]=\"column.sort === false\">\n <span [innerHTML]=\"column.label ?? ''\">{{ column.label }} </span>\n <span class=\"text-red-900 font-bold bg-white\">CONFIGURAR ESTILO ESTABLECIDO</span>\n </th>\n <td *matCellDef=\"let row\" [ngClass]=\"column.cssClasses\" mat-cell>\n {{ column.property }}\n <span class=\"text-red-900 font-bold bg-white\">CONFIGURAR ESTILO ESTABLECIDO</span>\n </td>\n <th *matFooterCellDef [ngClass]=\"column.cssFooterClasses\" style=\"height: unset !important;\" mat-footer-cell\n [innerHTML]=\"column.transformarFooter ? column.transformarFooter() : ''\">\n </th>\n\n </ng-container>\n\n <jvs-column-type-text *ngIf=\"column.type == 'text'\" [column]=\"column\"></jvs-column-type-text>\n <jvs-column-type-money *ngIf=\"column.type == 'money'\" [column]=\"column\"></jvs-column-type-money>\n <jvs-column-type-number *ngIf=\"column.type == 'number'\" [column]=\"column\"></jvs-column-type-number>\n <jvs-column-type-date *ngIf=\"column.type == 'date'\" [column]=\"column\"></jvs-column-type-date>\n <jvs-column-type-icons *ngIf=\"column.type == 'icons'\" [column]=\"column\"></jvs-column-type-icons>\n <jvs-column-type-sino *ngIf=\"column.type == 'yes_no'\" [column]=\"column\"></jvs-column-type-sino>\n <jvs-column-type-progressbar *ngIf=\"column.type == 'progress'\" [column]=\"column\"></jvs-column-type-progressbar>\n\n\n\n</ng-container>\n", styles: [""], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "ngmodule", type: MatCheckboxModule }, { kind: "component", type: i3$1.MatCheckbox, selector: "mat-checkbox", inputs: ["aria-label", "aria-labelledby", "aria-describedby", "aria-expanded", "aria-controls", "aria-owns", "id", "required", "labelPosition", "name", "value", "disableRipple", "tabIndex", "color", "disabledInteractive", "checked", "disabled", "indeterminate"], outputs: ["change", "indeterminateChange"], exportAs: ["matCheckbox"] }, { kind: "ngmodule", type: MatIconModule }, { kind: "component", type: i5.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "ngmodule", type: MatRippleModule }, { kind: "directive", type: i5$1.MatRipple, selector: "[mat-ripple], [matRipple]", inputs: ["matRippleColor", "matRippleUnbounded", "matRippleCentered", "matRippleRadius", "matRippleAnimation", "matRippleDisabled", "matRippleTrigger"], exportAs: ["matRipple"] }, { kind: "ngmodule", type: MatSortModule }, { kind: "component", type: i3.MatSortHeader, selector: "[mat-sort-header]", inputs: ["mat-sort-header", "arrowPosition", "start", "disabled", "sortActionDescription", "disableClear"], exportAs: ["matSortHeader"] }, { kind: "ngmodule", type: MatTableModule }, { kind: "directive", type: i2.MatHeaderCellDef, selector: "[matHeaderCellDef]" }, { kind: "directive", type: i2.MatColumnDef, selector: "[matColumnDef]", inputs: ["matColumnDef"] }, { kind: "directive", type: i2.MatCellDef, selector: "[matCellDef]" }, { kind: "directive", type: i2.MatFooterCellDef, selector: "[matFooterCellDef]" }, { kind: "directive", type: i2.MatHeaderCell, selector: "mat-header-cell, th[mat-header-cell]" }, { kind: "directive", type: i2.MatCell, selector: "mat-cell, td[mat-cell]" }, { kind: "directive", type: i2.MatFooterCell, selector: "mat-footer-cell, td[mat-footer-cell]" }, { kind: "ngmodule", type: MatTooltipModule }, { kind: "directive", type: i4.MatTooltip, selector: "[matTooltip]", inputs: ["matTooltipPosition", "matTooltipPositionAtOrigin", "matTooltipDisabled", "matTooltipShowDelay", "matTooltipHideDelay", "matTooltipTouchGestures", "matTooltip", "matTooltipClass"], exportAs: ["matTooltip"] }, { kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i1$2.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i1$2.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "ngmodule", type: ColumnTypeModule }, { kind: "component", type: ColumnTypeTextComponent, selector: "jvs-column-type-text", inputs: ["column"] }, { kind: "component", type: ColumnTypeMoneyComponent, selector: "jvs-column-type-money", inputs: ["column"] }, { kind: "component", type: ColumnTypeNumberComponent, selector: "jvs-column-type-number", inputs: ["column"] }, { kind: "component", type: ColumnTypeDateComponent, selector: "jvs-column-type-date", inputs: ["column"] }, { kind: "component", type: ColumnTypeIconsComponent, selector: "jvs-column-type-icons", inputs: ["column"] }, { kind: "component", type: ColumnTypeSinoComponent, selector: "jvs-column-type-sino", inputs: ["column"] }, { kind: "component", type: ColumnTypeProgressbarComponent, selector: "jvs-column-type-progressbar", inputs: ["column"] }] });
421
- }
422
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.7", ngImport: i0, type: TablaMantenimientoColumnDefsComponent, decorators: [{
423
- type: Component,
424
- args: [{ selector: 'jvs-tabla-mantenimiento-column-defs', standalone: true, imports: [
425
- CommonModule,
426
- MatCheckboxModule,
427
- MatIconModule,
428
- MatRippleModule,
429
- MatSortModule,
430
- MatTableModule,
431
- MatTooltipModule,
432
- ReactiveFormsModule,
433
- FormsModule,
434
- ColumnTypeModule,
435
- ], template: "<ng-content></ng-content>\n\n\n\n<ng-container *ngFor=\"let column of colDetalle; trackBy: trackByProperty\">\n\n <ng-container *ngIf=\"column.type === 'expandir'\" [matColumnDef]=\"column.property\">\n\n <th *matHeaderCellDef class=\"w-4\" mat-header-cell> <span [innerHTML]=\"column.label ?? ''\">{{ column.label }} </span></th>\n <td *matCellDef=\"let row\" class=\"w-4 text-center\" mat-cell>\n <button type=\"button\" class=\"boton-circular text-primary-contrast bg-primary mat-elevation-z2\" matRipple\n *ngIf=\"column.click\"\n (click)=\"column.click(row); row.isExpanded = !row.isExpanded; $event.stopPropagation()\"\n matTooltip=\"Expandir / Contraer\">\n <mat-icon class=\"icon-xs\" [svgIcon]=\"(row.isExpanded ? 'roundExpandLess' : 'roundExpandMore')\"></mat-icon>\n </button>\n <button type=\"button\" class=\"boton-circular text-primary-contrast bg-primary mat-elevation-z2\" matRipple\n *ngIf=\"!column.click\"\n (click)=\"row.isExpanded = !row.isExpanded; $event.stopPropagation()\"\n matTooltip=\"Expandir / Contraer\">\n <mat-icon class=\"icon-xs\" [svgIcon]=\"(row.isExpanded ? 'roundExpandLess' : 'roundExpandMore')\"></mat-icon>\n </button>\n </td>\n <td *matFooterCellDef [ngClass]=\"column.cssFooterClasses\" mat-footer-cell></td>\n\n </ng-container>\n <ng-container *ngIf=\"column.type === 'checkbox'\" [matColumnDef]=\"column.property\">\n\n <th *matHeaderCellDef [ngClass]=\"column.cssClassesTH\" class=\"w-4 text-center\" mat-header-cell>\n <mat-checkbox *ngIf=\"chkLista\"\n (click)=\"$event.stopPropagation()\"\n (change)=\"chkLista.checkbox.establecerTodos($event.checked)\"\n [indeterminate]=\"chkLista.checkbox.algunosActivos\"\n [checked]=\"chkLista.checkbox.todosActivos\"\n ></mat-checkbox>\n </th>\n <td *matCellDef=\"let row\" class=\"w-4 text-center\" mat-cell>\n <mat-checkbox *ngIf=\"chkLista\"\n (click)=\"$event.stopPropagation()\"\n [(ngModel)]=\"chkLista.modelosChk[chkLista.generarId(row, (column.chkField ?? column.property), column.chkFieldSeparador)]\"\n [ngModelOptions]=\"{standalone: true}\"\n ></mat-checkbox>\n\n </td>\n <td *matFooterCellDef [ngClass]=\"column.cssFooterClasses\" mat-footer-cell></td>\n\n </ng-container>\n <ng-container *ngIf=\"column.type === 'estiloEstablecido'\" [matColumnDef]=\"column.property\">\n\n <th *matHeaderCellDef [ngClass]=\"column.cssClassesTH\" class=\"uppercase text-center\" mat-header-cell\n mat-sort-header\n [disabled]=\"column.sort === false\">\n <span [innerHTML]=\"column.label ?? ''\">{{ column.label }} </span>\n <span class=\"text-red-900 font-bold bg-white\">CONFIGURAR ESTILO ESTABLECIDO</span>\n </th>\n <td *matCellDef=\"let row\" [ngClass]=\"column.cssClasses\" mat-cell>\n {{ column.property }}\n <span class=\"text-red-900 font-bold bg-white\">CONFIGURAR ESTILO ESTABLECIDO</span>\n </td>\n <th *matFooterCellDef [ngClass]=\"column.cssFooterClasses\" style=\"height: unset !important;\" mat-footer-cell\n [innerHTML]=\"column.transformarFooter ? column.transformarFooter() : ''\">\n </th>\n\n </ng-container>\n\n <jvs-column-type-text *ngIf=\"column.type == 'text'\" [column]=\"column\"></jvs-column-type-text>\n <jvs-column-type-money *ngIf=\"column.type == 'money'\" [column]=\"column\"></jvs-column-type-money>\n <jvs-column-type-number *ngIf=\"column.type == 'number'\" [column]=\"column\"></jvs-column-type-number>\n <jvs-column-type-date *ngIf=\"column.type == 'date'\" [column]=\"column\"></jvs-column-type-date>\n <jvs-column-type-icons *ngIf=\"column.type == 'icons'\" [column]=\"column\"></jvs-column-type-icons>\n <jvs-column-type-sino *ngIf=\"column.type == 'yes_no'\" [column]=\"column\"></jvs-column-type-sino>\n <jvs-column-type-progressbar *ngIf=\"column.type == 'progress'\" [column]=\"column\"></jvs-column-type-progressbar>\n\n\n\n</ng-container>\n" }]
436
- }], ctorParameters: () => [{ type: i2.MatTable, decorators: [{
437
- type: Optional
438
- }] }, { type: i0.ChangeDetectorRef }], propDecorators: { objThis: [{
439
- type: Input
440
- }], nombreColeccion: [{
441
- type: Input
442
- }], colDetalle: [{
443
- type: Input
444
- }], chkLista: [{
445
- type: Input
446
- }], chkListaChange: [{
447
- type: Output
448
- }], columnDefLocales: [{
449
- type: ViewChildren,
450
- args: [MatColumnDef]
451
- }], columnDefEnSubComponentes: [{
452
- type: ContentChildren,
453
- args: [MatColumnDef, { descendants: true }]
454
- }] } });
455
-
456
- class TablaMantenimientoMenuComponent {
457
- objThis;
458
- nombreColeccion;
459
- item;
460
- derechosActuales;
461
- // @Input() modalPrincipal;
462
- // @Input() botonDisabled = (btn: BotonMantenimiento, item: any) => [];
463
- opcionSelecionada = new EventEmitter();
464
- menu;
465
- subItems;
466
- botonTemplate;
467
- constructor() {
468
- }
469
- ngOnInit() {
470
- }
471
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.7", ngImport: i0, type: TablaMantenimientoMenuComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
472
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.1.7", type: TablaMantenimientoMenuComponent, isStandalone: true, selector: "jvs-tabla-mantenimiento-menu", inputs: { objThis: "objThis", nombreColeccion: "nombreColeccion", item: "item", derechosActuales: "derechosActuales", subItems: "subItems", botonTemplate: "botonTemplate" }, outputs: { opcionSelecionada: "opcionSelecionada" }, viewQueries: [{ propertyName: "menu", first: true, predicate: ["menu"], descendants: true, static: true }], ngImport: i0, template: "<mat-menu #menu=\"matMenu\">\n <div class=\"mat-menu bg-white rounded mat-elevation-z8 shadow botonesContextual w-full\">\n <ng-container *ngFor=\"let btn of subItems\">\n <ng-container *ngTemplateOutlet=\"botonTemplate; context:{btn: btn, item: objThis['seleccionados'][nombreColeccion], barraSuperior: false}\"></ng-container>\n </ng-container>\n </div>\n</mat-menu>\n", styles: [""], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "ngmodule", type: MatMenuModule }, { kind: "component", type: i8.MatMenu, selector: "mat-menu", inputs: ["backdropClass", "aria-label", "aria-labelledby", "aria-describedby", "xPosition", "yPosition", "overlapTrigger", "hasBackdrop", "class", "classList"], outputs: ["closed", "close"], exportAs: ["matMenu"] }] });
473
- }
474
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.7", ngImport: i0, type: TablaMantenimientoMenuComponent, decorators: [{
475
- type: Component,
476
- args: [{ selector: 'jvs-tabla-mantenimiento-menu', standalone: true, imports: [
477
- CommonModule,
478
- MatMenuModule,
479
- ], template: "<mat-menu #menu=\"matMenu\">\n <div class=\"mat-menu bg-white rounded mat-elevation-z8 shadow botonesContextual w-full\">\n <ng-container *ngFor=\"let btn of subItems\">\n <ng-container *ngTemplateOutlet=\"botonTemplate; context:{btn: btn, item: objThis['seleccionados'][nombreColeccion], barraSuperior: false}\"></ng-container>\n </ng-container>\n </div>\n</mat-menu>\n" }]
480
- }], ctorParameters: () => [], propDecorators: { objThis: [{
481
- type: Input
482
- }], nombreColeccion: [{
483
- type: Input
484
- }], item: [{
485
- type: Input
486
- }], derechosActuales: [{
487
- type: Input
488
- }], opcionSelecionada: [{
489
- type: Output
490
- }], menu: [{
491
- type: ViewChild,
492
- args: ['menu', { static: true }]
493
- }], subItems: [{
494
- type: Input,
495
- args: [{ required: true }]
496
- }], botonTemplate: [{
497
- type: Input,
498
- args: [{ required: true }]
499
- }] } });
500
-
501
- function buscarEnArray(coleccion, idBuscar, dato) {
502
- if (!Array.isArray(coleccion) || coleccion.length === 0)
503
- return null; // 🔹 Validación de entrada
504
- return Array.isArray(idBuscar)
505
- ? coleccion.find(item => idBuscar.every((campo, idx) => item[campo] === dato[idx])) || null
506
- : coleccion.find(item => item[idBuscar] === dato) || null;
507
- }
508
- function formatearFecha(val, hora = '00:00:00') {
509
- if (val) {
510
- if (val.length <= 10) {
511
- val = val + ' ' + hora;
512
- }
513
- return new Date(val);
514
- }
515
- return val;
516
- }
517
- function esNumero(value) {
518
- return !isNaN(Number(value));
519
- }
520
- function capitalizarTexto(texto) {
521
- texto = texto.replace(/_/g, ' ');
522
- texto = texto.replace(/-/g, ' ');
523
- const textoCortado = texto.split(' ');
524
- const nText = [];
525
- textoCortado.forEach(textActual => {
526
- nText.push(textActual.charAt(0).toUpperCase() + textActual.slice(1));
527
- });
528
- return nText.join(' ');
529
- }
530
- function getBrowserName() {
531
- const agent = window.navigator.userAgent.toLowerCase();
532
- switch (true) {
533
- case agent.indexOf('edge') > -1:
534
- return 'edge';
535
- case agent.indexOf('opr') > -1 && !!window.opr:
536
- return 'opera';
537
- case agent.indexOf('chrome') > -1 && !!window.chrome:
538
- return 'chrome';
539
- case agent.indexOf('trident') > -1:
540
- return 'ie';
541
- case agent.indexOf('firefox') > -1:
542
- return 'firefox';
543
- case agent.indexOf('safari') > -1:
544
- return 'safari';
545
- default:
546
- return 'other';
547
- }
548
- }
549
-
550
- class DataModel {
551
- modelosChk = {}; // Usar any para valores dinámicos
552
- checkbox;
553
- constructor() {
554
- this.checkbox = new ForCheckboxModel(this);
555
- }
556
- generarId(row, campoValor, separador = '') {
557
- if (typeof campoValor == 'string') {
558
- campoValor = [campoValor];
559
- }
560
- return campoValor.map(data => row[data]).join(separador);
561
- }
562
- // Agrega controles al objeto modelosChk
563
- agregarControles(lista, idLista, limpiar = true, campoValor = null, campoValorSeparador = '') {
564
- if (limpiar) {
565
- this.modelosChk = {};
566
- }
567
- const asignarValor = (dat, idLista, campoValor, key) => {
568
- if (!key) {
569
- key = dat[idLista] + (campoValor.includes('.') ? '' : `.${campoValor}`);
570
- }
571
- const mat = campoValor.match(/^([in])[A-Z][a-zA-Z]+/);
572
- if (mat) {
573
- this.modelosChk[key] = dat[campoValor] * 1;
574
- }
575
- else {
576
- this.modelosChk[key] = dat[campoValor];
577
- }
578
- };
579
- lista.forEach(dat => {
580
- if (campoValor === null) {
581
- // Caso 1: Sin campoValor, se asigna false
582
- this.modelosChk[dat[idLista]] = false;
583
- }
584
- else if (typeof campoValor === 'string') {
585
- // Caso 2: campoValor es un string
586
- asignarValor(dat, idLista, campoValor, dat[idLista]);
587
- }
588
- else if (campoValorSeparador) {
589
- const idStr = this.generarId(dat, campoValor, campoValorSeparador);
590
- // Caso 2: campoValor es un string
591
- asignarValor(dat, idLista, '.', idStr);
592
- }
593
- else {
594
- // Caso 3: campoValor es un array de strings
595
- campoValor.forEach(data => asignarValor(dat, idLista, data));
596
- }
597
- });
598
- }
599
- // Establece el estado de un índice
600
- setState(idx, state) {
601
- this.modelosChk[idx] = state;
602
- }
603
- // Obtiene el estado de un índice
604
- getState(idx) {
605
- return this.modelosChk[idx];
606
- }
607
- getDataMultiple(idx) {
608
- const camposMod = Object.keys(this.modelosChk).filter(key => key.split('.')[0] == idx);
609
- const vRet = {};
610
- camposMod.forEach(key => {
611
- vRet[key.split('.')[1]] = this.modelosChk[key];
612
- });
613
- return vRet;
651
+ ColumnTypeIconsComponent,
652
+ ColumnTypeSinoComponent,
653
+ ColumnTypeProgressbarComponent,
654
+ ]
655
+ }]
656
+ }] });
657
+
658
+ class TablaMantenimientoColumnDefsComponent {
659
+ table;
660
+ cdRef;
661
+ objThis;
662
+ nombreColeccion;
663
+ colDetalle;
664
+ chkLista; // = new DataModel();
665
+ chkListaChange = new EventEmitter();
666
+ columnDefLocales;
667
+ columnDefEnSubComponentes;
668
+ constructor(table, cdRef) {
669
+ this.table = table;
670
+ this.cdRef = cdRef;
614
671
  }
615
- // Genera una lista basada en el estado de los índices
616
- generarLista(tipoRetorno = null, esCampoNumerico = false) {
617
- const strLista = [];
618
- const objLista = {};
619
- Object.keys(this.modelosChk).forEach(key => {
620
- if ((esCampoNumerico && esNumero(this.modelosChk[key])) ||
621
- (this.modelosChk[key])) {
622
- strLista.push(key);
623
- objLista[key] = this.modelosChk[key];
624
- }
625
- });
626
- if (tipoRetorno === 'array') {
627
- return strLista;
628
- }
629
- if (tipoRetorno === 'object') {
630
- return objLista;
672
+ ngAfterContentInit() {
673
+ if (this.table) {
674
+ this.cdRef.detectChanges();
675
+ this.columnDefEnSubComponentes.forEach(refCol => {
676
+ this.table.addColumnDef(refCol);
677
+ });
678
+ this.columnDefLocales.forEach(refCol => {
679
+ this.table.addColumnDef(refCol);
680
+ });
631
681
  }
632
- return strLista.join(',');
633
682
  }
634
- generarFormGroupFromModelosChk(tipo) {
635
- const formGroupObj = {};
636
- let validadores = [];
637
- if (tipo == 'number') {
638
- validadores = [
639
- Validators.required,
640
- Validators.min(1)
641
- ];
642
- }
643
- Object.keys(this.modelosChk).forEach(key => {
644
- formGroupObj[key] = new FormControl(this.modelosChk[key], validadores);
645
- });
646
- return new FormGroup(formGroupObj);
647
- // return this.formBuilder.group(formGroupObj);
683
+ trackByProperty(index, column) {
684
+ return column.property;
648
685
  }
686
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.7", ngImport: i0, type: TablaMantenimientoColumnDefsComponent, deps: [{ token: i2.MatTable, optional: true }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
687
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.1.7", type: TablaMantenimientoColumnDefsComponent, isStandalone: true, selector: "jvs-tabla-mantenimiento-column-defs", inputs: { objThis: "objThis", nombreColeccion: "nombreColeccion", colDetalle: "colDetalle", chkLista: "chkLista" }, outputs: { chkListaChange: "chkListaChange" }, queries: [{ propertyName: "columnDefEnSubComponentes", predicate: MatColumnDef, descendants: true }], viewQueries: [{ propertyName: "columnDefLocales", predicate: MatColumnDef, descendants: true }], ngImport: i0, template: "<ng-content></ng-content>\n\n\n\n<ng-container *ngFor=\"let column of colDetalle; trackBy: trackByProperty\">\n\n <ng-container *ngIf=\"column.type === 'expandir'\" [matColumnDef]=\"column.property\">\n\n <th *matHeaderCellDef class=\"w-4\" mat-header-cell> <span [innerHTML]=\"column.label ?? ''\">{{ column.label }} </span></th>\n <td *matCellDef=\"let row\" class=\"w-4 text-center\" mat-cell>\n <button type=\"button\" class=\"boton-circular text-primary-contrast bg-primary mat-elevation-z2\" matRipple\n *ngIf=\"column.click\"\n (click)=\"column.click(row); row.isExpanded = !row.isExpanded; $event.stopPropagation()\"\n matTooltip=\"Expandir / Contraer\">\n <mat-icon class=\"icon-xs\" [svgIcon]=\"(row.isExpanded ? 'roundExpandLess' : 'roundExpandMore')\"></mat-icon>\n </button>\n <button type=\"button\" class=\"boton-circular text-primary-contrast bg-primary mat-elevation-z2\" matRipple\n *ngIf=\"!column.click\"\n (click)=\"row.isExpanded = !row.isExpanded; $event.stopPropagation()\"\n matTooltip=\"Expandir / Contraer\">\n <mat-icon class=\"icon-xs\" [svgIcon]=\"(row.isExpanded ? 'roundExpandLess' : 'roundExpandMore')\"></mat-icon>\n </button>\n </td>\n <td *matFooterCellDef [ngClass]=\"column.cssFooterClasses\" mat-footer-cell></td>\n\n </ng-container>\n <ng-container *ngIf=\"column.type === 'checkbox'\" [matColumnDef]=\"column.property\">\n\n <th *matHeaderCellDef [ngClass]=\"column.cssClassesTH\" class=\"w-4 text-center\" mat-header-cell>\n <mat-checkbox *ngIf=\"chkLista\"\n (click)=\"$event.stopPropagation()\"\n (change)=\"chkLista.checkbox.establecerTodos($event.checked)\"\n [indeterminate]=\"chkLista.checkbox.algunosActivos\"\n [checked]=\"chkLista.checkbox.todosActivos\"\n ></mat-checkbox>\n </th>\n <td *matCellDef=\"let row\" class=\"w-4 text-center\" mat-cell>\n <mat-checkbox *ngIf=\"chkLista\"\n (click)=\"$event.stopPropagation()\"\n [(ngModel)]=\"chkLista.modelosChk[chkLista.generarId(row, (column.chkField ?? column.property), column.chkFieldSeparador)]\"\n [ngModelOptions]=\"{standalone: true}\"\n ></mat-checkbox>\n\n </td>\n <td *matFooterCellDef [ngClass]=\"column.cssFooterClasses\" mat-footer-cell></td>\n\n </ng-container>\n <ng-container *ngIf=\"column.type === 'estiloEstablecido'\" [matColumnDef]=\"column.property\">\n\n <th *matHeaderCellDef [ngClass]=\"column.cssClassesTH\" class=\"uppercase text-center\" mat-header-cell\n mat-sort-header\n [disabled]=\"column.sort === false\">\n <span [innerHTML]=\"column.label ?? ''\">{{ column.label }} </span>\n <span class=\"text-red-900 font-bold bg-white\">CONFIGURAR ESTILO ESTABLECIDO</span>\n </th>\n <td *matCellDef=\"let row\" [ngClass]=\"column.cssClasses\" mat-cell>\n {{ column.property }}\n <span class=\"text-red-900 font-bold bg-white\">CONFIGURAR ESTILO ESTABLECIDO</span>\n </td>\n <th *matFooterCellDef [ngClass]=\"column.cssFooterClasses\" style=\"height: unset !important;\" mat-footer-cell\n [innerHTML]=\"column.transformarFooter ? column.transformarFooter() : ''\">\n </th>\n\n </ng-container>\n\n <jvs-column-type-text *ngIf=\"column.type == 'text'\" [column]=\"column\"></jvs-column-type-text>\n <jvs-column-type-money *ngIf=\"column.type == 'money'\" [column]=\"column\"></jvs-column-type-money>\n <jvs-column-type-number *ngIf=\"column.type == 'number'\" [column]=\"column\"></jvs-column-type-number>\n <jvs-column-type-date *ngIf=\"column.type == 'date'\" [column]=\"column\"></jvs-column-type-date>\n <jvs-column-type-icons *ngIf=\"column.type == 'icons'\" [column]=\"column\"></jvs-column-type-icons>\n <jvs-column-type-sino *ngIf=\"column.type == 'yes_no'\" [column]=\"column\"></jvs-column-type-sino>\n <jvs-column-type-progressbar *ngIf=\"column.type == 'progress'\" [column]=\"column\"></jvs-column-type-progressbar>\n\n\n\n</ng-container>\n", styles: [""], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "ngmodule", type: MatCheckboxModule }, { kind: "component", type: i3$1.MatCheckbox, selector: "mat-checkbox", inputs: ["aria-label", "aria-labelledby", "aria-describedby", "aria-expanded", "aria-controls", "aria-owns", "id", "required", "labelPosition", "name", "value", "disableRipple", "tabIndex", "color", "disabledInteractive", "checked", "disabled", "indeterminate"], outputs: ["change", "indeterminateChange"], exportAs: ["matCheckbox"] }, { kind: "ngmodule", type: MatIconModule }, { kind: "component", type: i5.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "ngmodule", type: MatRippleModule }, { kind: "directive", type: i5$1.MatRipple, selector: "[mat-ripple], [matRipple]", inputs: ["matRippleColor", "matRippleUnbounded", "matRippleCentered", "matRippleRadius", "matRippleAnimation", "matRippleDisabled", "matRippleTrigger"], exportAs: ["matRipple"] }, { kind: "ngmodule", type: MatSortModule }, { kind: "component", type: i3.MatSortHeader, selector: "[mat-sort-header]", inputs: ["mat-sort-header", "arrowPosition", "start", "disabled", "sortActionDescription", "disableClear"], exportAs: ["matSortHeader"] }, { kind: "ngmodule", type: MatTableModule }, { kind: "directive", type: i2.MatHeaderCellDef, selector: "[matHeaderCellDef]" }, { kind: "directive", type: i2.MatColumnDef, selector: "[matColumnDef]", inputs: ["matColumnDef"] }, { kind: "directive", type: i2.MatCellDef, selector: "[matCellDef]" }, { kind: "directive", type: i2.MatFooterCellDef, selector: "[matFooterCellDef]" }, { kind: "directive", type: i2.MatHeaderCell, selector: "mat-header-cell, th[mat-header-cell]" }, { kind: "directive", type: i2.MatCell, selector: "mat-cell, td[mat-cell]" }, { kind: "directive", type: i2.MatFooterCell, selector: "mat-footer-cell, td[mat-footer-cell]" }, { kind: "ngmodule", type: MatTooltipModule }, { kind: "directive", type: i4.MatTooltip, selector: "[matTooltip]", inputs: ["matTooltipPosition", "matTooltipPositionAtOrigin", "matTooltipDisabled", "matTooltipShowDelay", "matTooltipHideDelay", "matTooltipTouchGestures", "matTooltip", "matTooltipClass"], exportAs: ["matTooltip"] }, { kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i1$2.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i1$2.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "ngmodule", type: ColumnTypeModule }, { kind: "component", type: ColumnTypeTextComponent, selector: "jvs-column-type-text", inputs: ["column"] }, { kind: "component", type: ColumnTypeMoneyComponent, selector: "jvs-column-type-money", inputs: ["column"] }, { kind: "component", type: ColumnTypeNumberComponent, selector: "jvs-column-type-number", inputs: ["column"] }, { kind: "component", type: ColumnTypeDateComponent, selector: "jvs-column-type-date", inputs: ["column"] }, { kind: "component", type: ColumnTypeIconsComponent, selector: "jvs-column-type-icons", inputs: ["column"] }, { kind: "component", type: ColumnTypeSinoComponent, selector: "jvs-column-type-sino", inputs: ["column"] }, { kind: "component", type: ColumnTypeProgressbarComponent, selector: "jvs-column-type-progressbar", inputs: ["column"] }] });
649
688
  }
650
- class ForCheckboxModel {
651
- modeloCheck;
652
- constructor(modeloCheck) {
653
- this.modeloCheck = modeloCheck;
654
- }
655
- get cantidadActivos() {
656
- return Object.values(this.modeloCheck.modelosChk).filter(Boolean).length;
657
- }
658
- get existenActivados() {
659
- return this.cantidadActivos > 0;
660
- }
661
- get todosActivos() {
662
- const total = Object.keys(this.modeloCheck.modelosChk).length;
663
- const activos = this.cantidadActivos;
664
- return activos > 0 && total === activos;
665
- }
666
- get algunosActivos() {
667
- const total = Object.keys(this.modeloCheck.modelosChk).length;
668
- const activos = this.cantidadActivos;
669
- return activos > 0 && total !== activos;
689
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.7", ngImport: i0, type: TablaMantenimientoColumnDefsComponent, decorators: [{
690
+ type: Component,
691
+ args: [{ selector: 'jvs-tabla-mantenimiento-column-defs', standalone: true, imports: [
692
+ CommonModule,
693
+ MatCheckboxModule,
694
+ MatIconModule,
695
+ MatRippleModule,
696
+ MatSortModule,
697
+ MatTableModule,
698
+ MatTooltipModule,
699
+ ReactiveFormsModule,
700
+ FormsModule,
701
+ ColumnTypeModule,
702
+ ], template: "<ng-content></ng-content>\n\n\n\n<ng-container *ngFor=\"let column of colDetalle; trackBy: trackByProperty\">\n\n <ng-container *ngIf=\"column.type === 'expandir'\" [matColumnDef]=\"column.property\">\n\n <th *matHeaderCellDef class=\"w-4\" mat-header-cell> <span [innerHTML]=\"column.label ?? ''\">{{ column.label }} </span></th>\n <td *matCellDef=\"let row\" class=\"w-4 text-center\" mat-cell>\n <button type=\"button\" class=\"boton-circular text-primary-contrast bg-primary mat-elevation-z2\" matRipple\n *ngIf=\"column.click\"\n (click)=\"column.click(row); row.isExpanded = !row.isExpanded; $event.stopPropagation()\"\n matTooltip=\"Expandir / Contraer\">\n <mat-icon class=\"icon-xs\" [svgIcon]=\"(row.isExpanded ? 'roundExpandLess' : 'roundExpandMore')\"></mat-icon>\n </button>\n <button type=\"button\" class=\"boton-circular text-primary-contrast bg-primary mat-elevation-z2\" matRipple\n *ngIf=\"!column.click\"\n (click)=\"row.isExpanded = !row.isExpanded; $event.stopPropagation()\"\n matTooltip=\"Expandir / Contraer\">\n <mat-icon class=\"icon-xs\" [svgIcon]=\"(row.isExpanded ? 'roundExpandLess' : 'roundExpandMore')\"></mat-icon>\n </button>\n </td>\n <td *matFooterCellDef [ngClass]=\"column.cssFooterClasses\" mat-footer-cell></td>\n\n </ng-container>\n <ng-container *ngIf=\"column.type === 'checkbox'\" [matColumnDef]=\"column.property\">\n\n <th *matHeaderCellDef [ngClass]=\"column.cssClassesTH\" class=\"w-4 text-center\" mat-header-cell>\n <mat-checkbox *ngIf=\"chkLista\"\n (click)=\"$event.stopPropagation()\"\n (change)=\"chkLista.checkbox.establecerTodos($event.checked)\"\n [indeterminate]=\"chkLista.checkbox.algunosActivos\"\n [checked]=\"chkLista.checkbox.todosActivos\"\n ></mat-checkbox>\n </th>\n <td *matCellDef=\"let row\" class=\"w-4 text-center\" mat-cell>\n <mat-checkbox *ngIf=\"chkLista\"\n (click)=\"$event.stopPropagation()\"\n [(ngModel)]=\"chkLista.modelosChk[chkLista.generarId(row, (column.chkField ?? column.property), column.chkFieldSeparador)]\"\n [ngModelOptions]=\"{standalone: true}\"\n ></mat-checkbox>\n\n </td>\n <td *matFooterCellDef [ngClass]=\"column.cssFooterClasses\" mat-footer-cell></td>\n\n </ng-container>\n <ng-container *ngIf=\"column.type === 'estiloEstablecido'\" [matColumnDef]=\"column.property\">\n\n <th *matHeaderCellDef [ngClass]=\"column.cssClassesTH\" class=\"uppercase text-center\" mat-header-cell\n mat-sort-header\n [disabled]=\"column.sort === false\">\n <span [innerHTML]=\"column.label ?? ''\">{{ column.label }} </span>\n <span class=\"text-red-900 font-bold bg-white\">CONFIGURAR ESTILO ESTABLECIDO</span>\n </th>\n <td *matCellDef=\"let row\" [ngClass]=\"column.cssClasses\" mat-cell>\n {{ column.property }}\n <span class=\"text-red-900 font-bold bg-white\">CONFIGURAR ESTILO ESTABLECIDO</span>\n </td>\n <th *matFooterCellDef [ngClass]=\"column.cssFooterClasses\" style=\"height: unset !important;\" mat-footer-cell\n [innerHTML]=\"column.transformarFooter ? column.transformarFooter() : ''\">\n </th>\n\n </ng-container>\n\n <jvs-column-type-text *ngIf=\"column.type == 'text'\" [column]=\"column\"></jvs-column-type-text>\n <jvs-column-type-money *ngIf=\"column.type == 'money'\" [column]=\"column\"></jvs-column-type-money>\n <jvs-column-type-number *ngIf=\"column.type == 'number'\" [column]=\"column\"></jvs-column-type-number>\n <jvs-column-type-date *ngIf=\"column.type == 'date'\" [column]=\"column\"></jvs-column-type-date>\n <jvs-column-type-icons *ngIf=\"column.type == 'icons'\" [column]=\"column\"></jvs-column-type-icons>\n <jvs-column-type-sino *ngIf=\"column.type == 'yes_no'\" [column]=\"column\"></jvs-column-type-sino>\n <jvs-column-type-progressbar *ngIf=\"column.type == 'progress'\" [column]=\"column\"></jvs-column-type-progressbar>\n\n\n\n</ng-container>\n" }]
703
+ }], ctorParameters: () => [{ type: i2.MatTable, decorators: [{
704
+ type: Optional
705
+ }] }, { type: i0.ChangeDetectorRef }], propDecorators: { objThis: [{
706
+ type: Input
707
+ }], nombreColeccion: [{
708
+ type: Input
709
+ }], colDetalle: [{
710
+ type: Input
711
+ }], chkLista: [{
712
+ type: Input
713
+ }], chkListaChange: [{
714
+ type: Output
715
+ }], columnDefLocales: [{
716
+ type: ViewChildren,
717
+ args: [MatColumnDef]
718
+ }], columnDefEnSubComponentes: [{
719
+ type: ContentChildren,
720
+ args: [MatColumnDef, { descendants: true }]
721
+ }] } });
722
+
723
+ class TablaMantenimientoMenuComponent {
724
+ objThis;
725
+ nombreColeccion;
726
+ item;
727
+ derechosActuales;
728
+ // @Input() modalPrincipal;
729
+ // @Input() botonDisabled = (btn: BotonMantenimiento, item: any) => [];
730
+ opcionSelecionada = new EventEmitter();
731
+ menu;
732
+ subItems;
733
+ botonTemplate;
734
+ constructor() {
670
735
  }
671
- establecerTodos(activo) {
672
- Object.keys(this.modeloCheck.modelosChk).forEach(idx => this.modeloCheck.modelosChk[idx] = activo);
736
+ ngOnInit() {
673
737
  }
738
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.7", ngImport: i0, type: TablaMantenimientoMenuComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
739
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.1.7", type: TablaMantenimientoMenuComponent, isStandalone: true, selector: "jvs-tabla-mantenimiento-menu", inputs: { objThis: "objThis", nombreColeccion: "nombreColeccion", item: "item", derechosActuales: "derechosActuales", subItems: "subItems", botonTemplate: "botonTemplate" }, outputs: { opcionSelecionada: "opcionSelecionada" }, viewQueries: [{ propertyName: "menu", first: true, predicate: ["menu"], descendants: true, static: true }], ngImport: i0, template: "<mat-menu #menu=\"matMenu\">\n <div class=\"mat-menu bg-white rounded mat-elevation-z8 shadow botonesContextual w-full\">\n <ng-container *ngFor=\"let btn of subItems\">\n <ng-container *ngTemplateOutlet=\"botonTemplate; context:{btn: btn, item: objThis['seleccionados'][nombreColeccion], barraSuperior: false}\"></ng-container>\n </ng-container>\n </div>\n</mat-menu>\n", styles: [""], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "ngmodule", type: MatMenuModule }, { kind: "component", type: i8.MatMenu, selector: "mat-menu", inputs: ["backdropClass", "aria-label", "aria-labelledby", "aria-describedby", "xPosition", "yPosition", "overlapTrigger", "hasBackdrop", "class", "classList"], outputs: ["closed", "close"], exportAs: ["matMenu"] }] });
674
740
  }
741
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.7", ngImport: i0, type: TablaMantenimientoMenuComponent, decorators: [{
742
+ type: Component,
743
+ args: [{ selector: 'jvs-tabla-mantenimiento-menu', standalone: true, imports: [
744
+ CommonModule,
745
+ MatMenuModule,
746
+ ], template: "<mat-menu #menu=\"matMenu\">\n <div class=\"mat-menu bg-white rounded mat-elevation-z8 shadow botonesContextual w-full\">\n <ng-container *ngFor=\"let btn of subItems\">\n <ng-container *ngTemplateOutlet=\"botonTemplate; context:{btn: btn, item: objThis['seleccionados'][nombreColeccion], barraSuperior: false}\"></ng-container>\n </ng-container>\n </div>\n</mat-menu>\n" }]
747
+ }], ctorParameters: () => [], propDecorators: { objThis: [{
748
+ type: Input
749
+ }], nombreColeccion: [{
750
+ type: Input
751
+ }], item: [{
752
+ type: Input
753
+ }], derechosActuales: [{
754
+ type: Input
755
+ }], opcionSelecionada: [{
756
+ type: Output
757
+ }], menu: [{
758
+ type: ViewChild,
759
+ args: ['menu', { static: true }]
760
+ }], subItems: [{
761
+ type: Input,
762
+ args: [{ required: true }]
763
+ }], botonTemplate: [{
764
+ type: Input,
765
+ args: [{ required: true }]
766
+ }] } });
675
767
 
676
768
  const getFileName = (name) => {
677
769
  const timeSpan = new Date().toISOString();
@@ -716,101 +808,6 @@ class TableUtil {
716
808
  }
717
809
  }
718
810
 
719
- class MatRowKeyboardSelectionDirective {
720
- el;
721
- rows;
722
- renderedData;
723
- tabla; // Entrada: Referencia a la tabla
724
- rowModel; // Entrada: Modelo de fila actual
725
- seleccionarSiguiente = new EventEmitter(); // Salida: Evento al seleccionar siguiente
726
- unsubscriber$ = new Subject();
727
- constructor(el) {
728
- this.el = el;
729
- }
730
- ngOnInit() {
731
- // Asignar tabindex si no está definido
732
- if (this.el.nativeElement.tabIndex < 0) {
733
- this.el.nativeElement.tabIndex = 0;
734
- }
735
- // Obtener la fuente de datos de la tabla
736
- const dataSource = this.tabla.dataSource;
737
- // Suscribirse a los cambios en los datos
738
- dataSource.connect().pipe(takeUntil(this.unsubscriber$)).subscribe(data => {
739
- this.renderedData = data;
740
- this.rows = Array.from(this.getTableRows());
741
- });
742
- }
743
- ngOnDestroy() {
744
- // Finalizar la suscripción al destruir la directiva
745
- this.unsubscriber$.next(null);
746
- this.unsubscriber$.complete();
747
- }
748
- onKeydown(event) {
749
- var element = event.target;
750
- if (element.tagName === "INPUT") {
751
- event.stopPropagation();
752
- }
753
- else {
754
- const currentIndex = this.renderedData.findIndex(row => row === this.rowModel);
755
- const eRef = event.target;
756
- this.rows = this.rows.filter(elem => elem.hasAttribute('id'));
757
- const arrayFilas = Array.from(this.rows);
758
- const fElem = arrayFilas.filter(elem => elem.id == eRef.id).pop();
759
- const cElemIdx = arrayFilas.findIndex(elem => elem == fElem);
760
- let newRow;
761
- // Controlar las teclas presionadas
762
- switch (event.key) {
763
- case 'ArrowDown':
764
- newRow = this.rows[cElemIdx + 1];
765
- break;
766
- case 'ArrowUp':
767
- newRow = this.rows[cElemIdx - 1];
768
- break;
769
- case 'Enter':
770
- case ' ':
771
- this.seleccionarSiguiente.next(this.renderedData[currentIndex]);
772
- event.preventDefault();
773
- break;
774
- }
775
- // Enfocar la nueva fila seleccionada
776
- if (newRow) {
777
- newRow.classList.add('estaFocus');
778
- newRow.focus();
779
- }
780
- }
781
- }
782
- getTableRows() {
783
- let el = this.el.nativeElement;
784
- // Recorrer los elementos padres hasta encontrar la tabla
785
- while (el && el.parentNode) {
786
- el = el.parentNode;
787
- // Verificar si es una tabla de material
788
- if (el.tagName && el.tagName.toLowerCase() === 'mat-table' || el.hasAttribute('mat-table')) {
789
- return el.querySelectorAll('mat-row, tr[mat-row]');
790
- }
791
- }
792
- return undefined;
793
- }
794
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.7", ngImport: i0, type: MatRowKeyboardSelectionDirective, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive });
795
- static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.1.7", type: MatRowKeyboardSelectionDirective, isStandalone: true, selector: "[matRowKeyboardSelection]", inputs: { tabla: ["matRowKeyboardSelection", "tabla"], rowModel: "rowModel" }, outputs: { seleccionarSiguiente: "seleccionarSiguiente" }, host: { listeners: { "keydown": "onKeydown($event)" } }, ngImport: i0 });
796
- }
797
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.7", ngImport: i0, type: MatRowKeyboardSelectionDirective, decorators: [{
798
- type: Directive,
799
- args: [{
800
- selector: '[matRowKeyboardSelection]'
801
- }]
802
- }], ctorParameters: () => [{ type: i0.ElementRef }], propDecorators: { tabla: [{
803
- type: Input,
804
- args: ['matRowKeyboardSelection']
805
- }], rowModel: [{
806
- type: Input
807
- }], seleccionarSiguiente: [{
808
- type: Output
809
- }], onKeydown: [{
810
- type: HostListener,
811
- args: ['keydown', ['$event']]
812
- }] } });
813
-
814
811
  class TablaMantenimientoService {
815
812
  get templateBotonesComunes() {
816
813
  return [