sf-crud 12.0.1-beta9 → 12.0.3

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.
Files changed (31) hide show
  1. package/bundles/sf-crud.umd.js +1225 -125
  2. package/bundles/sf-crud.umd.js.map +1 -1
  3. package/esm2015/lib/components/control/control.component.js +114 -12
  4. package/esm2015/lib/components/registro/registro.component.js +309 -43
  5. package/esm2015/lib/components/registro-child/registro-child.component.js +330 -0
  6. package/esm2015/lib/components/registro-detalle/registro-detalle.component.js +232 -0
  7. package/esm2015/lib/components/tablero/tablero.component.js +81 -19
  8. package/esm2015/lib/sf-crud.module.js +24 -13
  9. package/esm2015/lib/sf-crud.service.js +16 -2
  10. package/esm2015/lib/shared/models/crud-config.model.js +51 -0
  11. package/esm2015/lib/shared/models/data-temp-crud.model.js +6 -0
  12. package/esm2015/lib/shared/models/shema.model.js +7 -0
  13. package/esm2015/lib/shared/services/general.service.js +1 -1
  14. package/esm2015/public-api.js +2 -1
  15. package/fesm2015/sf-crud.js +1078 -91
  16. package/fesm2015/sf-crud.js.map +1 -1
  17. package/lib/components/control/control.component.d.ts +16 -3
  18. package/lib/components/registro/registro.component.d.ts +45 -10
  19. package/lib/components/registro-child/registro-child.component.d.ts +47 -0
  20. package/lib/components/registro-detalle/registro-detalle.component.d.ts +36 -0
  21. package/lib/components/tablero/tablero.component.d.ts +17 -4
  22. package/lib/sf-crud.module.d.ts +76 -74
  23. package/lib/sf-crud.service.d.ts +4 -0
  24. package/lib/shared/{services/models → models}/crud-config.model.d.ts +18 -2
  25. package/lib/shared/models/data-temp-crud.model.d.ts +4 -0
  26. package/lib/shared/{services/models → models}/shema.model.d.ts +1 -0
  27. package/lib/shared/services/general.service.d.ts +1 -1
  28. package/package.json +1 -1
  29. package/public-api.d.ts +1 -0
  30. package/esm2015/lib/shared/services/models/crud-config.model.js +0 -43
  31. package/esm2015/lib/shared/services/models/shema.model.js +0 -7
@@ -1,5 +1,7 @@
1
1
  import * as i0 from '@angular/core';
2
- import { Injectable, Component, Input, EventEmitter, Output, NgModule } from '@angular/core';
2
+ import { Injectable, EventEmitter, Component, Input, Output, NgModule } from '@angular/core';
3
+ import * as _ from 'lodash';
4
+ import * as jsonpath from 'jsonpath';
3
5
  import { __awaiter } from 'tslib';
4
6
  import * as i1 from '@angular/common/http';
5
7
  import { HttpClientModule } from '@angular/common/http';
@@ -10,30 +12,41 @@ import * as i4 from 'primeng/toolbar';
10
12
  import { ToolbarModule } from 'primeng/toolbar';
11
13
  import * as i5 from 'primeng/table';
12
14
  import { TableModule } from 'primeng/table';
13
- import * as i6 from '@angular/common';
14
- import * as i3$1 from 'primeng/api';
15
+ import * as i6 from 'primeng/splitbutton';
16
+ import { SplitButtonModule } from 'primeng/splitbutton';
17
+ import * as i7 from '@angular/common';
18
+ import * as i2$1 from 'primeng/api';
15
19
  import { MessageService } from 'primeng/api';
16
- import * as i8 from 'primeng/button';
20
+ import * as i9 from 'primeng/button';
17
21
  import { ButtonModule } from 'primeng/button';
18
- import * as i9 from 'primeng/ripple';
22
+ import * as i10 from 'primeng/ripple';
19
23
  import { RippleModule } from 'primeng/ripple';
20
- import * as i10 from 'primeng/inputtext';
24
+ import * as i11 from 'primeng/inputtext';
21
25
  import { InputTextModule } from 'primeng/inputtext';
22
- import * as i11 from 'primeng/tooltip';
23
- import { TooltipModule } from 'primeng/tooltip';
24
- import * as jsonpath from 'jsonpath';
25
- import * as i5$2 from 'primeng/toast';
26
+ import * as i1$1 from 'primeng/dynamicdialog';
27
+ import { DialogService, DynamicDialogConfig, DynamicDialogRef, DynamicDialogModule } from 'primeng/dynamicdialog';
28
+ import * as moment from 'moment';
29
+ import * as i3$2 from 'primeng/toast';
26
30
  import { ToastModule } from 'primeng/toast';
27
- import * as i2$1 from 'primeng/dropdown';
31
+ import * as i2$2 from 'primeng/inputmask';
32
+ import { InputMaskModule } from 'primeng/inputmask';
33
+ import * as i3$1 from 'primeng/dropdown';
28
34
  import { DropdownModule } from 'primeng/dropdown';
29
- import * as i3$2 from 'primeng/autocomplete';
35
+ import * as i4$1 from 'primeng/autocomplete';
30
36
  import { AutoCompleteModule } from 'primeng/autocomplete';
31
- import * as i4$1 from 'primeng/calendar';
37
+ import * as i5$1 from 'primeng/calendar';
32
38
  import { CalendarModule } from 'primeng/calendar';
33
- import * as i5$1 from 'primeng/inputnumber';
39
+ import * as i6$1 from 'primeng/inputnumber';
34
40
  import { InputNumberModule } from 'primeng/inputnumber';
35
- import * as i7 from '@angular/forms';
41
+ import * as i7$1 from 'primeng/fileupload';
42
+ import { FileUploadModule } from 'primeng/fileupload';
43
+ import * as i8 from 'primeng/inputswitch';
44
+ import { InputSwitchModule } from 'primeng/inputswitch';
45
+ import * as i10$1 from '@angular/forms';
36
46
  import { FormsModule } from '@angular/forms';
47
+ import * as i12 from 'primeng/inputtextarea';
48
+ import { InputTextareaModule } from 'primeng/inputtextarea';
49
+ import Swal from 'sweetalert2';
37
50
  import { AccordionModule } from 'primeng/accordion';
38
51
  import { AvatarGroupModule } from 'primeng/avatargroup';
39
52
  import { AvatarModule } from 'primeng/avatar';
@@ -45,7 +58,6 @@ import { CascadeSelectModule } from 'primeng/cascadeselect';
45
58
  import { CheckboxModule } from 'primeng/checkbox';
46
59
  import { ChipModule } from 'primeng/chip';
47
60
  import { ChipsModule } from 'primeng/chips';
48
- import { CodeHighlighterModule } from 'primeng/codehighlighter';
49
61
  import { ColorPickerModule } from 'primeng/colorpicker';
50
62
  import { ConfirmDialogModule } from 'primeng/confirmdialog';
51
63
  import { ConfirmPopupModule } from 'primeng/confirmpopup';
@@ -53,14 +65,9 @@ import { ContextMenuModule } from 'primeng/contextmenu';
53
65
  import { DialogModule } from 'primeng/dialog';
54
66
  import { DividerModule } from 'primeng/divider';
55
67
  import { FieldsetModule } from 'primeng/fieldset';
56
- import { FileUploadModule } from 'primeng/fileupload';
57
68
  import { GalleriaModule } from 'primeng/galleria';
58
69
  import { InplaceModule } from 'primeng/inplace';
59
- import { InputMaskModule } from 'primeng/inputmask';
60
- import { InputSwitchModule } from 'primeng/inputswitch';
61
- import { InputTextareaModule } from 'primeng/inputtextarea';
62
70
  import { KnobModule } from 'primeng/knob';
63
- import { LightboxModule } from 'primeng/lightbox';
64
71
  import { ListboxModule } from 'primeng/listbox';
65
72
  import { MegaMenuModule } from 'primeng/megamenu';
66
73
  import { MenubarModule } from 'primeng/menubar';
@@ -92,6 +99,7 @@ import { TerminalModule } from 'primeng/terminal';
92
99
  import { TieredMenuModule } from 'primeng/tieredmenu';
93
100
  import { TimelineModule } from 'primeng/timeline';
94
101
  import { ToggleButtonModule } from 'primeng/togglebutton';
102
+ import { TooltipModule } from 'primeng/tooltip';
95
103
  import { TreeModule } from 'primeng/tree';
96
104
 
97
105
  class Shema {
@@ -115,8 +123,8 @@ class ConfigTablero {
115
123
  this.endpoint = '';
116
124
  this.method = '';
117
125
  this.server = '';
118
- this.key = '';
119
126
  this.filters = [];
127
+ this.keys = [];
120
128
  }
121
129
  }
122
130
  class ConfigRegistro {
@@ -141,6 +149,14 @@ class Validations {
141
149
  this.server = '';
142
150
  this.endpoint = '';
143
151
  }
152
+ }
153
+ class RequestChecking {
154
+ constructor(dynamics, statics, swal, redirect) {
155
+ this.dynamics = dynamics;
156
+ this.statics = statics;
157
+ this.swal = swal;
158
+ this.redirect = redirect;
159
+ }
144
160
  }
145
161
 
146
162
  class GeneralService {
@@ -196,6 +212,8 @@ class TableroComponent {
196
212
  this.opciones = [];
197
213
  this.idEntidad = '';
198
214
  this.idKatios = '';
215
+ this.onSelectAction = new EventEmitter();
216
+ this.items = [];
199
217
  this.crudConfig = new CrudConfig();
200
218
  this.enProceso = false;
201
219
  this.data = [];
@@ -210,7 +228,6 @@ class TableroComponent {
210
228
  .then(res => {
211
229
  this.crudConfig = res;
212
230
  this.getInfoTablero(this.crudConfig.tablero);
213
- this.loadOptions();
214
231
  })
215
232
  .catch(err => {
216
233
  console.log(err);
@@ -218,9 +235,15 @@ class TableroComponent {
218
235
  });
219
236
  }
220
237
  getInfoTablero(configTablero) {
221
- this.generalService.genericRequest(configTablero.method, configTablero.server, configTablero.endpoint)
238
+ this.generalService.genericRequest(configTablero.method, configTablero.server, this.aplyKeys(configTablero.keys, configTablero.endpoint, this.dataExt))
222
239
  .then((res) => {
223
- this.data = res.data;
240
+ let aux;
241
+ if (!Array.isArray(res))
242
+ aux = res.data;
243
+ else
244
+ aux = res;
245
+ this.generateData(aux);
246
+ this.loadOptions();
224
247
  this.enProceso = false;
225
248
  })
226
249
  .catch(err => {
@@ -228,11 +251,27 @@ class TableroComponent {
228
251
  this.enProceso = false;
229
252
  });
230
253
  }
254
+ generateData(data) {
255
+ data.forEach((item) => {
256
+ let newItem = {};
257
+ this.crudConfig.tablero.columns.forEach(col => {
258
+ newItem[col.col] = this.getValue(col.col, item);
259
+ });
260
+ this.data.push(newItem);
261
+ });
262
+ console.log(this.data);
263
+ }
264
+ getValue(path, item) {
265
+ if (path.includes("."))
266
+ return jsonpath.query(item, path)[0];
267
+ return item[path];
268
+ }
231
269
  loadOptions() {
270
+ this.items = [];
232
271
  this.btn.create = this.opciones.find(x => x.label == 'Crear');
233
- this.btn.read = this.opciones.find(x => x.label == 'Visualizar');
234
- this.btn.update = this.opciones.find(x => x.label == 'Editar');
235
- this.btn.delete = this.opciones.find(x => x.label == 'Eliminar');
272
+ this.opciones.filter((opc) => opc.valor.action).forEach(opc => {
273
+ this.items.push({ label: opc.label, icon: opc.icon, command: () => this.execAction(opc.valor) });
274
+ });
236
275
  }
237
276
  redirect(accion, data) {
238
277
  var _a, _b;
@@ -241,21 +280,52 @@ class TableroComponent {
241
280
  this.router.navigateByUrl(((_b = (_a = this.btn.create) === null || _a === void 0 ? void 0 : _a.valor) === null || _b === void 0 ? void 0 : _b.redirect) || '');
242
281
  break;
243
282
  case 'read':
244
- this.router.navigateByUrl(this.btn.read.valor.redirect.replace('$id', data[this.crudConfig.tablero.key]));
283
+ this.router.navigateByUrl(this.aplyKeys(this.crudConfig.tablero.keys, this.btn.read.valor.redirect, data));
245
284
  break;
246
285
  case 'update':
247
- this.router.navigateByUrl(this.btn.update.valor.redirect.replace('$id', data[this.crudConfig.tablero.key]));
286
+ this.router.navigateByUrl(this.aplyKeys(this.crudConfig.tablero.keys, this.btn.update.valor.redirect, data));
248
287
  break;
249
288
  case 'delete':
250
- this.router.navigateByUrl(this.btn.delete.valor.redirect.replace('$id', data[this.crudConfig.tablero.key]));
289
+ this.router.navigateByUrl(this.aplyKeys(this.crudConfig.tablero.keys, this.btn.delete.valor.redirect, data));
251
290
  break;
252
291
  default:
253
292
  break;
254
293
  }
255
294
  }
295
+ aplyKeys(keys, endpoint, data) {
296
+ keys.forEach(key => {
297
+ var _a, _b, _c, _d;
298
+ switch (key.key) {
299
+ case '@ndoc':
300
+ endpoint = endpoint.replace(key.key, ((_b = (_a = this.user) === null || _a === void 0 ? void 0 : _a.UsuarioSistema) === null || _b === void 0 ? void 0 : _b.NDOC) || '');
301
+ break;
302
+ case '@tdoc':
303
+ endpoint = endpoint.replace(key.key, ((_d = (_c = this.user) === null || _c === void 0 ? void 0 : _c.UsuarioSistema) === null || _d === void 0 ? void 0 : _d.TDOC) || '');
304
+ break;
305
+ case '@idKatios':
306
+ endpoint = endpoint.replace(key.key, this.idKatios);
307
+ break;
308
+ default:
309
+ if (endpoint.includes(key.key) && data)
310
+ endpoint = endpoint.replace(key.key, jsonpath.query(data, (key === null || key === void 0 ? void 0 : key.scope) || '')[0]);
311
+ break;
312
+ }
313
+ });
314
+ return endpoint;
315
+ }
316
+ execAction(params) {
317
+ switch (params.action) {
318
+ case 'redirect':
319
+ this.router.navigateByUrl(this.aplyKeys(this.crudConfig.tablero.keys, params.link, this.itemSelected));
320
+ break;
321
+ default:
322
+ this.onSelectAction.emit({ data: _.cloneDeep(this.itemSelected), params });
323
+ break;
324
+ }
325
+ }
256
326
  }
257
327
  TableroComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: TableroComponent, deps: [{ token: GeneralService }, { token: i2.Router }], target: i0.ɵɵFactoryTarget.Component });
258
- TableroComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.17", type: TableroComponent, selector: "sf-crudtablero", inputs: { opciones: "opciones", idEntidad: "idEntidad", idKatios: "idKatios" }, ngImport: i0, template: "<p-blockUI [blocked]=\"enProceso\">\r\n <i class=\"pi pi-cog pi-spin\" style=\"font-size: 50px\"></i>\r\n</p-blockUI>\r\n\r\n<div class=\"card\" *ngIf=\"!enProceso\">\r\n <p-toolbar styleClass=\"mb-4 gap-2\">\r\n <ng-template pTemplate=\"left\">\r\n <button *ngIf=\"btn.create\" pButton pRipple [label]=\"btn.create.label\" [icon]=\"btn.create.icon\"\r\n class=\"p-button-success mr-2\" (click)=\"redirect('create')\"></button>\r\n </ng-template>\r\n </p-toolbar>\r\n <p-table #dt [columns]=\"crudConfig.tablero.columns\" [value]=\"data\" [rowHover]=\"true\" [rows]=\"10\" [paginator]=\"true\"\r\n [globalFilterFields]=\"crudConfig.tablero?.filters || []\" [tableStyle]=\"{'min-width': '75rem'}\"\r\n currentPageReportTemplate=\"Registro {first} al {last} de {totalRecords} {{idEntidad}}\"\r\n [showCurrentPageReport]=\"true\">\r\n <ng-template pTemplate=\"caption\">\r\n <div class=\"flex align-items-center justify-content-between\">\r\n <h5 class=\"m-0\">{{idEntidad}}</h5>\r\n <span class=\"p-input-icon-left\">\r\n <i class=\"pi pi-search\"></i>\r\n <input pInputText type=\"text\" (input)=\"dt.filterGlobal($event.target.value, 'contains')\"\r\n placeholder=\"Buscar...\" />\r\n </span>\r\n </div>\r\n </ng-template>\r\n <ng-template pTemplate=\"header\" let-columns>\r\n <tr>\r\n <th *ngFor=\"let col of columns\">\r\n {{col.label}}\r\n </th>\r\n <th>Acci\u00F3n</th>\r\n </tr>\r\n </ng-template>\r\n <ng-template pTemplate=\"body\" let-rowData let-columns=\"columns\">\r\n <tr>\r\n <td *ngFor=\"let col of columns\">\r\n {{rowData[col.col]}}\r\n </td>\r\n <th>\r\n <button *ngIf=\"btn.read\" pButton pRipple [pTooltip]=\"btn.read.label\" [icon]=\"btn.read.icon\"\r\n class=\"p-button-rounded p-button-info mr-2\" (click)=\"redirect('read', rowData)\"></button>\r\n <button *ngIf=\"btn.update\" pButton pRipple [pTooltip]=\"btn.update.label\" [icon]=\"btn.update.icon\"\r\n class=\"p-button-rounded p-button-warning mr-2\" (click)=\"redirect('update', rowData)\"></button>\r\n <button *ngIf=\"btn.delete\" pButton pRipple [pTooltip]=\"btn.delete.label\" [icon]=\"btn.delete.icon\"\r\n class=\"p-button-rounded p-button-danger mr-2\" (click)=\"redirect('delete', rowData)\"></button>\r\n </th>\r\n </tr>\r\n </ng-template>\r\n </p-table>\r\n</div>", components: [{ type: i3.BlockUI, selector: "p-blockUI", inputs: ["autoZIndex", "baseZIndex", "blocked", "target", "styleClass"] }, { type: i4.Toolbar, selector: "p-toolbar", inputs: ["style", "styleClass"] }, { type: i5.Table, selector: "p-table", inputs: ["pageLinks", "alwaysShowPaginator", "paginatorPosition", "paginatorDropdownScrollHeight", "currentPageReportTemplate", "showFirstLastIcon", "showPageLinks", "defaultSortOrder", "sortMode", "resetPageOnSort", "contextMenuSelectionMode", "rowTrackBy", "lazy", "lazyLoadOnInit", "compareSelectionBy", "csvSeparator", "exportFilename", "filters", "filterDelay", "expandedRowKeys", "editingRowKeys", "rowExpandMode", "virtualScrollDelay", "virtualRowHeight", "columnResizeMode", "loadingIcon", "showLoader", "showInitialSortBadge", "stateStorage", "editMode", "totalRecords", "value", "columns", "first", "rows", "sortField", "sortOrder", "multiSortMeta", "selection", "contextMenuSelection", "frozenColumns", "frozenValue", "style", "styleClass", "tableStyle", "tableStyleClass", "paginator", "rowsPerPageOptions", "paginatorDropdownAppendTo", "showCurrentPageReport", "showJumpToPageDropdown", "selectionMode", "dataKey", "metaKeySelection", "globalFilterFields", "filterLocale", "scrollable", "scrollHeight", "virtualScroll", "frozenWidth", "responsive", "contextMenu", "resizableColumns", "reorderableColumns", "loading", "rowHover", "customSort", "autoLayout", "exportFunction", "stateKey", "minBufferPx", "maxBufferPx"], outputs: ["selectionChange", "contextMenuSelectionChange", "onRowSelect", "onRowUnselect", "onPage", "onSort", "onFilter", "onLazyLoad", "onRowExpand", "onRowCollapse", "onContextMenuSelect", "onColResize", "onColReorder", "onRowReorder", "onEditInit", "onEditComplete", "onEditCancel", "onHeaderCheckboxToggle", "sortFunction", "firstChange", "rowsChange", "onStateSave", "onStateRestore"] }], directives: [{ type: i6.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i3$1.PrimeTemplate, selector: "[pTemplate]", inputs: ["type", "pTemplate"] }, { type: i8.ButtonDirective, selector: "[pButton]", inputs: ["iconPos", "loadingIcon", "label", "icon", "loading"] }, { type: i9.Ripple, selector: "[pRipple]" }, { type: i10.InputText, selector: "[pInputText]" }, { type: i6.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i11.Tooltip, selector: "[pTooltip]", inputs: ["tooltipPosition", "tooltipEvent", "appendTo", "tooltipZIndex", "escape", "tooltipDisabled", "pTooltip", "positionStyle", "tooltipStyleClass", "showDelay", "hideDelay", "life"] }] });
328
+ TableroComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.17", type: TableroComponent, selector: "sf-crudtablero", inputs: { opciones: "opciones", idEntidad: "idEntidad", idKatios: "idKatios", user: "user", dataExt: "dataExt" }, outputs: { onSelectAction: "onSelectAction" }, ngImport: i0, template: "<p-blockUI [blocked]=\"enProceso\">\r\n <i class=\"pi pi-cog pi-spin\" style=\"font-size: 50px\"></i>\r\n</p-blockUI>\r\n\r\n<div class=\"card\" *ngIf=\"!enProceso\">\r\n <p-toolbar styleClass=\"mb-4 gap-2\">\r\n <ng-template pTemplate=\"left\">\r\n <button *ngIf=\"btn.create\" pButton pRipple [label]=\"btn.create.label\" [icon]=\"btn.create.icon\"\r\n class=\"p-button-success mr-2\" (click)=\"redirect('create')\"></button>\r\n </ng-template>\r\n </p-toolbar>\r\n <p-table #dt [columns]=\"crudConfig.tablero.columns\" [value]=\"data\" [rowHover]=\"true\" [rows]=\"10\" [paginator]=\"true\"\r\n [globalFilterFields]=\"crudConfig.tablero?.filters || []\" [tableStyle]=\"{'min-width': '75rem'}\"\r\n currentPageReportTemplate=\"Registro {first} al {last} de {totalRecords}\" [showCurrentPageReport]=\"true\">\r\n <ng-template pTemplate=\"caption\">\r\n <div class=\"flex align-items-center justify-content-between\">\r\n <h5 class=\"m-0\">{{crudConfig.tablero?.label || idEntidad}}</h5>\r\n <span class=\"p-input-icon-left\">\r\n <i class=\"pi pi-search\"></i>\r\n <input pInputText type=\"text\" (input)=\"dt.filterGlobal($event.target.value, 'contains')\"\r\n placeholder=\"Buscar...\" />\r\n </span>\r\n </div>\r\n </ng-template>\r\n <ng-template pTemplate=\"header\" let-columns>\r\n <tr>\r\n <th *ngFor=\"let col of columns\">\r\n {{col.label}}\r\n </th>\r\n <th>Acci\u00F3n</th>\r\n </tr>\r\n </ng-template>\r\n <ng-template pTemplate=\"body\" let-rowData let-columns=\"columns\">\r\n <tr>\r\n <ng-container *ngFor=\"let col of columns\" [ngSwitch]=\"col.type\">\r\n <td *ngSwitchCase=\"'text'\">{{rowData[col.col]}}</td>\r\n <td *ngSwitchCase=\"'date:yyyy-mm-dd'\">{{rowData[col.col] | date: 'yyyy-MM-dd'}}</td>\r\n <td *ngSwitchCase=\"'currency:USD'\">{{rowData[col.col] | currency: 'USD'}}</td>\r\n </ng-container>\r\n <td>\r\n <p-splitButton icon=\"pi pi-align-justify\" [model]=\"items\" appendTo=\"body\"\r\n (onDropdownClick)=\"itemSelected = rowData\"></p-splitButton>\r\n </td>\r\n </tr>\r\n </ng-template>\r\n </p-table>\r\n</div>", components: [{ type: i3.BlockUI, selector: "p-blockUI", inputs: ["target", "autoZIndex", "baseZIndex", "styleClass", "blocked"] }, { type: i4.Toolbar, selector: "p-toolbar", inputs: ["style", "styleClass"] }, { type: i5.Table, selector: "p-table", inputs: ["frozenColumns", "frozenValue", "style", "styleClass", "tableStyle", "tableStyleClass", "paginator", "pageLinks", "rowsPerPageOptions", "alwaysShowPaginator", "paginatorPosition", "paginatorDropdownAppendTo", "paginatorDropdownScrollHeight", "currentPageReportTemplate", "showCurrentPageReport", "showJumpToPageDropdown", "showFirstLastIcon", "showPageLinks", "defaultSortOrder", "sortMode", "resetPageOnSort", "selectionMode", "contextMenuSelection", "contextMenuSelectionMode", "dataKey", "metaKeySelection", "rowTrackBy", "lazy", "lazyLoadOnInit", "compareSelectionBy", "csvSeparator", "exportFilename", "filters", "globalFilterFields", "filterDelay", "filterLocale", "expandedRowKeys", "editingRowKeys", "rowExpandMode", "scrollable", "scrollDirection", "rowGroupMode", "scrollHeight", "virtualScroll", "virtualScrollDelay", "virtualRowHeight", "frozenWidth", "responsive", "contextMenu", "resizableColumns", "columnResizeMode", "reorderableColumns", "loading", "loadingIcon", "showLoader", "rowHover", "customSort", "showInitialSortBadge", "autoLayout", "exportFunction", "stateKey", "stateStorage", "editMode", "groupRowsBy", "minBufferPx", "maxBufferPx", "responsiveLayout", "breakpoint", "value", "columns", "first", "rows", "totalRecords", "sortField", "sortOrder", "multiSortMeta", "selection"], outputs: ["selectionChange", "contextMenuSelectionChange", "onRowSelect", "onRowUnselect", "onPage", "onSort", "onFilter", "onLazyLoad", "onRowExpand", "onRowCollapse", "onContextMenuSelect", "onColResize", "onColReorder", "onRowReorder", "onEditInit", "onEditComplete", "onEditCancel", "onHeaderCheckboxToggle", "sortFunction", "firstChange", "rowsChange", "onStateSave", "onStateRestore"] }, { type: i6.SplitButton, selector: "p-splitButton", inputs: ["model", "icon", "iconPos", "label", "style", "styleClass", "menuStyle", "menuStyleClass", "disabled", "tabindex", "appendTo", "dir", "showTransitionOptions", "hideTransitionOptions"], outputs: ["onClick", "onDropdownClick"] }], directives: [{ type: i7.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i2$1.PrimeTemplate, selector: "[pTemplate]", inputs: ["type", "pTemplate"] }, { type: i9.ButtonDirective, selector: "[pButton]", inputs: ["iconPos", "loadingIcon", "label", "icon", "loading"] }, { type: i10.Ripple, selector: "[pRipple]" }, { type: i11.InputText, selector: "[pInputText]" }, { type: i7.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i7.NgSwitch, selector: "[ngSwitch]", inputs: ["ngSwitch"] }, { type: i7.NgSwitchCase, selector: "[ngSwitchCase]", inputs: ["ngSwitchCase"] }], pipes: { "date": i7.DatePipe, "currency": i7.CurrencyPipe } });
259
329
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: TableroComponent, decorators: [{
260
330
  type: Component,
261
331
  args: [{
@@ -268,6 +338,12 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImpo
268
338
  type: Input
269
339
  }], idKatios: [{
270
340
  type: Input
341
+ }], user: [{
342
+ type: Input
343
+ }], dataExt: [{
344
+ type: Input
345
+ }], onSelectAction: [{
346
+ type: Output
271
347
  }] } });
272
348
 
273
349
  class ControlComponent {
@@ -276,22 +352,56 @@ class ControlComponent {
276
352
  this.control = new Shema();
277
353
  this.label = '';
278
354
  this.setValue = new EventEmitter();
355
+ this.sendNotification = new EventEmitter();
356
+ this.sendObject = new EventEmitter();
279
357
  this.isLoading = false;
280
358
  this.dataFromService = [];
359
+ this.uploadedFiles = [];
360
+ this.displayAdd = false;
361
+ this.tempValue = {};
281
362
  }
282
363
  ngOnInit() {
283
364
  var _a;
284
365
  if (((_a = this.control) === null || _a === void 0 ? void 0 : _a.config) && this.control.subtype == 'dropdown')
285
366
  this.loadDataFromService();
367
+ if (this.value && this.control.subtype == 'autocomplete')
368
+ this.setDefaultValue();
369
+ if (this.value && this.control.type == 'date')
370
+ this.setDate();
286
371
  }
287
372
  sendValue() {
288
373
  this.setValue.emit(this.value);
289
374
  }
290
- sendValueFromObject() {
291
- this.setValue.emit(this.value[this.control.config.optionValue]);
375
+ sendValueFromObject(event) {
376
+ switch (typeof (this.control.config.optionValue)) {
377
+ case 'object':
378
+ this.control.config.optionValue.forEach((op) => op['value'] = event[op.key]);
379
+ this.setValue.emit(this.control.config.optionValue);
380
+ break;
381
+ default:
382
+ this.setValue.emit(event[this.control.config.optionValue]);
383
+ break;
384
+ }
385
+ }
386
+ validateValue(type) {
387
+ switch (type) {
388
+ case 'email':
389
+ let regex = new RegExp(/([\w\.\-_]+)?\w+@[\w-_]+(\.\w+){1,}/igm);
390
+ if (regex.test(this.value))
391
+ this.sendValue();
392
+ else {
393
+ this.value = null;
394
+ this.sendValue();
395
+ this.sendNotification.emit({ severity: 'warn', detail: 'El correo no es válido' });
396
+ }
397
+ break;
398
+ default:
399
+ break;
400
+ }
292
401
  }
293
402
  loadDataFromService() {
294
403
  this.isLoading = true;
404
+ this.dataFromService = [];
295
405
  this.generalService.genericRequest(this.control.config.method, this.control.config.server, this.control.config.endpoint)
296
406
  .then((res) => {
297
407
  this.dataFromService = res.data;
@@ -306,9 +416,64 @@ class ControlComponent {
306
416
  this.isLoading = false;
307
417
  });
308
418
  }
419
+ onUpload(event) {
420
+ let file = event.files[0];
421
+ let formData = new FormData();
422
+ let path = 'Imagenes/CRUD/temp';
423
+ formData.append('uploadFile', file);
424
+ formData.append('Ruta', `/${path}`);
425
+ this.isLoading = true;
426
+ this.generalService.genericRequest(this.control.config.method, this.control.config.server, this.control.config.endpoint, formData)
427
+ .then(() => {
428
+ this.sendNotification.emit({ severity: 'info', detail: `Archivo cargado correctamente!` });
429
+ this.uploadedFiles.push(file);
430
+ this.isLoading = false;
431
+ this.value = `${this.generalService.jsonConfig.Server}${path}/${file.name}`;
432
+ this.sendValue();
433
+ })
434
+ .catch(err => {
435
+ console.log(err);
436
+ this.isLoading = false;
437
+ this.sendNotification.emit({ severity: 'error', detail: `Error al cargar el archivo!` });
438
+ });
439
+ }
440
+ refresData() {
441
+ var _a, _b;
442
+ if ((_b = (_a = this.control) === null || _a === void 0 ? void 0 : _a.config) === null || _b === void 0 ? void 0 : _b.endpointtemp)
443
+ this.loadDataFromService();
444
+ }
445
+ setDefaultValue() {
446
+ var _a;
447
+ Object.defineProperty(this.tempValue, (_a = this.control.config) === null || _a === void 0 ? void 0 : _a.optionLabel, { value: this.value, writable: true, enumerable: true, configurable: true });
448
+ }
449
+ searchValue(value) {
450
+ let endpoint = this.control.config.endpoint.replace('@id', value);
451
+ this.generalService.genericRequest(this.control.config.method, this.control.config.server, endpoint)
452
+ .then((res) => {
453
+ var _a;
454
+ if (((_a = res === null || res === void 0 ? void 0 : res.data) === null || _a === void 0 ? void 0 : _a.length) > 0) {
455
+ this.sendObject.emit({ data: res.data[0], optionValue: this.control.config.optionValue });
456
+ }
457
+ else {
458
+ this.sendNotification.emit({ severity: 'warn', detail: `Valor no encontrado.` });
459
+ this.sendObject.emit({ data: null, optionValue: this.control.config.optionValue });
460
+ }
461
+ })
462
+ .catch(err => {
463
+ console.log(err);
464
+ this.sendNotification.emit({ severity: 'error', detail: `Error al consumir el servicio.` });
465
+ });
466
+ }
467
+ setDate() {
468
+ let format = this.control.formatMoment;
469
+ if (format && this.value && !(this.value instanceof Date)) {
470
+ this.value = moment(this.value, format).toDate();
471
+ this.sendValue();
472
+ }
473
+ }
309
474
  }
310
475
  ControlComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: ControlComponent, deps: [{ token: GeneralService }], target: i0.ɵɵFactoryTarget.Component });
311
- ControlComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.17", type: ControlComponent, selector: "sf-control", inputs: { control: "control", label: "label", value: "value" }, outputs: { setValue: "setValue" }, ngImport: i0, template: "<ng-container [ngSwitch]=\"control.type\">\r\n <label>{{label}}</label>\r\n <ng-container *ngSwitchCase=\"'string'\">\r\n <ng-container [ngSwitch]=\"control.subtype\">\r\n <ng-container *ngSwitchCase=\"'input'\">\r\n <input pInputText type=\"text\" [(ngModel)]=\"value\" (focusout)=\"sendValue()\">\r\n </ng-container>\r\n <ng-container *ngSwitchCase=\"'password'\">\r\n <input pInputText type=\"password\" [(ngModel)]=\"value\" (focusout)=\"sendValue()\">\r\n </ng-container>\r\n <ng-container *ngSwitchCase=\"'email'\">\r\n <input pInputText type=\"email\" [(ngModel)]=\"value\" (focusout)=\"sendValue()\">\r\n </ng-container>\r\n <ng-container *ngSwitchCase=\"'phone'\">\r\n <input pInputText type=\"tel\" [(ngModel)]=\"value\" (focusout)=\"sendValue()\">\r\n </ng-container>\r\n <ng-container *ngSwitchCase=\"'enum'\">\r\n <p-dropdown [options]=\"control.enum\" [(ngModel)]=\"value\" (onChange)=\"sendValue()\"\r\n placeholder=\"Seleccione una opci\u00F3n\"></p-dropdown>\r\n </ng-container>\r\n <ng-container *ngSwitchCase=\"'dropdown'\">\r\n <p-dropdown [lazy]=\"isLoading\" [options]=\"dataFromService\" [(ngModel)]=\"value\" (onChange)=\"sendValue()\"\r\n [optionLabel]=\"control.config.optionLabel\" [optionValue]=\"control.config.optionValue\"\r\n placeholder=\"Seleccione una opci\u00F3n\"></p-dropdown>\r\n </ng-container>\r\n <ng-container *ngSwitchCase=\"'autocomplete'\">\r\n <p-autoComplete [(ngModel)]=\"value\" [showEmptyMessage]=\"true\" [suggestions]=\"dataFromService\"\r\n (completeMethod)=\"loadDataFromControlBusquedaService($event)\" [field]=\"control.field\"\r\n [minLength]=\"1\" (onSelect)=\"sendValueFromObject()\"></p-autoComplete>\r\n </ng-container>\r\n </ng-container>\r\n </ng-container>\r\n <ng-container *ngSwitchCase=\"'date'\">\r\n <ng-container [ngSwitch]=\"control.subtype\">\r\n <ng-container *ngSwitchCase=\"'calendar'\">\r\n <p-calendar [(ngModel)]=\"value\" (onSelect)=\"sendValue()\"\r\n [format]=\"control?.format || 'yy-mm-dd'\"></p-calendar>\r\n </ng-container>\r\n </ng-container>\r\n </ng-container>\r\n <ng-container *ngSwitchCase=\"'numeric'\">\r\n <ng-container [ngSwitch]=\"control.subtype\">\r\n <ng-container *ngSwitchCase=\"'currency'\">\r\n <p-inputNumber [(ngModel)]=\"value\" mode=\"currency\" [minFractionDigits]=\"control?.minFractionDigits || 0\"\r\n (onChange)=\"sendValue()\" [currency]=\"control?.currency || 'USD'\"></p-inputNumber>\r\n </ng-container>\r\n <ng-container *ngSwitchCase=\"'decimal'\">\r\n <p-inputNumber [(ngModel)]=\"value\" mode=\"decimal\" (onChange)=\"sendValue()\"\r\n [minFractionDigits]=\"control?.minFractionDigits || 0\"></p-inputNumber>\r\n </ng-container>\r\n <ng-container *ngSwitchCase=\"'percentage'\">\r\n <p-inputNumber [(ngModel)]=\"value\" suffix=\" %\" (onChange)=\"sendValue()\"\r\n [minFractionDigits]=\"control?.minFractionDigits || 2\"></p-inputNumber>\r\n </ng-container>\r\n </ng-container>\r\n </ng-container>\r\n</ng-container>", components: [{ type: i2$1.Dropdown, selector: "p-dropdown", inputs: ["scrollHeight", "resetFilterOnHide", "dropdownIcon", "optionGroupChildren", "autoDisplayFirst", "emptyFilterMessage", "emptyMessage", "autoZIndex", "baseZIndex", "showTransitionOptions", "hideTransitionOptions", "filterMatchMode", "tooltip", "tooltipPosition", "tooltipPositionStyle", "autofocusFilter", "disabled", "options", "filterValue", "filter", "name", "style", "panelStyle", "styleClass", "panelStyleClass", "readonly", "required", "editable", "appendTo", "tabindex", "placeholder", "filterPlaceholder", "filterLocale", "inputId", "selectId", "dataKey", "filterBy", "autofocus", "optionLabel", "optionValue", "optionDisabled", "optionGroupLabel", "group", "showClear", "virtualScroll", "itemSize", "ariaFilterLabel", "ariaLabelledBy", "maxlength", "tooltipStyleClass"], outputs: ["onChange", "onFilter", "onFocus", "onBlur", "onClick", "onShow", "onHide"] }, { type: i3$2.AutoComplete, selector: "p-autoComplete", inputs: ["minLength", "delay", "type", "autoZIndex", "baseZIndex", "dropdownIcon", "unique", "completeOnFocus", "scrollHeight", "dropdownMode", "showTransitionOptions", "hideTransitionOptions", "autocomplete", "suggestions", "disabled", "style", "panelStyle", "styleClass", "panelStyleClass", "inputStyle", "inputId", "inputStyleClass", "placeholder", "readonly", "virtualScroll", "itemSize", "maxlength", "name", "required", "size", "appendTo", "autoHighlight", "forceSelection", "ariaLabel", "ariaLabelledBy", "group", "field", "dropdown", "showEmptyMessage", "multiple", "tabindex", "dataKey", "emptyMessage", "autofocus", "optionGroupChildren", "optionGroupLabel"], outputs: ["completeMethod", "onSelect", "onUnselect", "onFocus", "onBlur", "onDropdownClick", "onClear", "onKeyUp", "onShow", "onHide"] }, { type: i4$1.Calendar, selector: "p-calendar", inputs: ["dateFormat", "multipleSeparator", "rangeSeparator", "inline", "showOtherMonths", "icon", "shortYearCutoff", "hourFormat", "stepHour", "stepMinute", "stepSecond", "showSeconds", "showOnFocus", "showWeek", "dataType", "selectionMode", "todayButtonStyleClass", "clearButtonStyleClass", "autoZIndex", "baseZIndex", "keepInvalid", "hideOnDateTimeSelect", "numberOfMonths", "view", "timeSeparator", "focusTrap", "firstDayOfWeek", "showTransitionOptions", "hideTransitionOptions", "defaultDate", "minDate", "maxDate", "disabledDates", "disabledDays", "yearRange", "showTime", "locale", "disabled", "style", "styleClass", "inputStyle", "inputId", "name", "inputStyleClass", "placeholder", "ariaLabelledBy", "selectOtherMonths", "showIcon", "appendTo", "readonlyInput", "monthNavigator", "yearNavigator", "timeOnly", "required", "maxDateCount", "showButtonBar", "panelStyleClass", "panelStyle", "touchUI", "tabindex"], outputs: ["onFocus", "onBlur", "onClose", "onSelect", "onInput", "onTodayClick", "onClearClick", "onMonthChange", "onYearChange", "onClickOutside", "onShow"] }, { type: i5$1.InputNumber, selector: "p-inputNumber", inputs: ["showButtons", "format", "buttonLayout", "incrementButtonIcon", "decrementButtonIcon", "step", "locale", "localeMatcher", "mode", "currency", "currencyDisplay", "useGrouping", "minFractionDigits", "maxFractionDigits", "prefix", "suffix", "disabled", "inputId", "styleClass", "style", "placeholder", "size", "maxlength", "tabindex", "title", "ariaLabel", "ariaRequired", "name", "required", "autocomplete", "min", "max", "incrementButtonClass", "decrementButtonClass", "inputStyle", "inputStyleClass"], outputs: ["onInput", "onFocus", "onBlur", "onKeyDown"] }], directives: [{ type: i6.NgSwitch, selector: "[ngSwitch]", inputs: ["ngSwitch"] }, { type: i6.NgSwitchCase, selector: "[ngSwitchCase]", inputs: ["ngSwitchCase"] }, { type: i7.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { type: i10.InputText, selector: "[pInputText]" }, { type: i7.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i7.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }] });
476
+ ControlComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.17", type: ControlComponent, selector: "sf-control", inputs: { control: "control", label: "label", value: "value", appendTo: "appendTo" }, outputs: { setValue: "setValue", sendNotification: "sendNotification", sendObject: "sendObject" }, ngImport: i0, template: "<ng-container [ngSwitch]=\"control.type\" #cc>\r\n <label [for]=\"label\" style=\"width: -webkit-fill-available;\">{{label}}</label>\r\n <ng-container *ngSwitchCase=\"'string'\">\r\n <ng-container [ngSwitch]=\"control.subtype\">\r\n <ng-container *ngSwitchCase=\"'input'\">\r\n <input pInputText type=\"text\" [(ngModel)]=\"value\" (focusout)=\"sendValue()\"\r\n [disabled]=\"control?.disabled || false\">\r\n </ng-container>\r\n <ng-container *ngSwitchCase=\"'textarea'\">\r\n <textarea [rows]=\"control?.rows ? control.rows : 4\" \r\n [(ngModel)]=\"value\" (focusout)=\"sendValue()\" pInputTextarea \r\n [disabled]=\"control?.disabled || false\" [autoResize]=\"control?.autoresize || false\"></textarea>\r\n </ng-container>\r\n <ng-container *ngSwitchCase=\"'password'\">\r\n <input pInputText type=\"password\" [(ngModel)]=\"value\" (focusout)=\"sendValue()\"\r\n [disabled]=\"control?.disabled || false\">\r\n </ng-container>\r\n <ng-container *ngSwitchCase=\"'email'\">\r\n <input pInputText type=\"text\" [(ngModel)]=\"value\" placeholder=\"email@example.com\"\r\n (focusout)=\"validateValue('email')\" [disabled]=\"control?.disabled || false\">\r\n </ng-container>\r\n <ng-container *ngSwitchCase=\"'phone'\">\r\n <p-inputMask mask=\"(999) 999-9999\" [(ngModel)]=\"value\" placeholder=\"(999) 999-9999\"\r\n (focusout)=\"sendValue()\" [disabled]=\"control?.disabled || false\" [unmask]=\"control.unmask || false\"></p-inputMask>\r\n </ng-container>\r\n <ng-container *ngSwitchCase=\"'enum'\">\r\n <p-dropdown [options]=\"control.enum\" [(ngModel)]=\"value\" (onChange)=\"sendValue()\" appendTo=\"body\"\r\n placeholder=\"Seleccione una opci\u00F3n\" [disabled]=\"control?.disabled || false\"></p-dropdown>\r\n </ng-container>\r\n <ng-container *ngSwitchCase=\"'dropdown'\">\r\n <p-dropdown [lazy]=\"isLoading\" [options]=\"dataFromService\" [(ngModel)]=\"value\" (onChange)=\"sendValue()\"\r\n [optionLabel]=\"control.config.optionLabel\"\r\n [optionValue]=\"control?.field || control.config.optionValue\" (onClick)=\"refresData()\"\r\n appendTo=\"body\" placeholder=\"Seleccione una opci\u00F3n\"\r\n [disabled]=\"control?.disabled || false\"></p-dropdown>\r\n </ng-container>\r\n <ng-container *ngSwitchCase=\"'dropdown:replace'\">\r\n <p-dropdown [lazy]=\"isLoading\" [options]=\"dataFromService\"\r\n (onChange)=\"sendValueFromObject($event.value)\" [optionLabel]=\"control.config.optionLabel\"\r\n (onClick)=\"refresData()\" appendTo=\"body\" placeholder=\"Seleccione una opci\u00F3n\"\r\n [disabled]=\"control?.disabled || false\"></p-dropdown>\r\n </ng-container>\r\n <ng-container *ngSwitchCase=\"'autocomplete'\">\r\n <p-autoComplete [showEmptyMessage]=\"true\" [suggestions]=\"dataFromService\" appendTo=\"body\"\r\n (completeMethod)=\"loadDataFromControlBusquedaService($event)\" [field]=\"control.field\"\r\n [minLength]=\"1\" (onSelect)=\"sendValueFromObject($event.value)\" [(ngModel)]=\"tempValue\"\r\n [disabled]=\"control?.disabled || false\"></p-autoComplete>\r\n </ng-container>\r\n <ng-container *ngSwitchCase=\"'input:search'\">\r\n <div class=\"p-inputgroup\">\r\n <input type=\"text\" pInputText [(ngModel)]=\"value\" (focusout)=\"sendValue()\" />\r\n <button type=\"button\" pButton icon=\"pi pi-search\" (click)=\"searchValue(value)\"></button>\r\n </div>\r\n </ng-container>\r\n </ng-container>\r\n </ng-container>\r\n <ng-container *ngSwitchCase=\"'date'\">\r\n <ng-container [ngSwitch]=\"control.subtype\">\r\n <ng-container *ngSwitchCase=\"'calendar'\">\r\n <p-calendar [(ngModel)]=\"value\" (onSelect)=\"sendValue()\" (onBlur)=\"sendValue()\" [monthNavigator]=\"true\"\r\n [yearNavigator]=\"true\" yearRange=\"1900:2035\" [dateFormat]=\"control?.format || 'yy-mm-dd'\"\r\n appendTo=\"body\" [disabled]=\"control?.disabled || false\" [showOnFocus]=\"!control?.hide\"\r\n [placeholder]=\"control?.placeholder || 'aaaa-mm-dd'\" [touchUI]=\"control?.touchUI || false\"\r\n [showIcon]=\"control?.showIcon || false\"></p-calendar>\r\n </ng-container>\r\n </ng-container>\r\n </ng-container>\r\n <ng-container *ngSwitchCase=\"'numeric'\">\r\n <ng-container [ngSwitch]=\"control.subtype\">\r\n <ng-container *ngSwitchCase=\"'currency'\">\r\n <p-inputNumber [(ngModel)]=\"value\" mode=\"currency\" [minFractionDigits]=\"control?.minFractionDigits || 0\"\r\n [min]=\"control?.min || null\" [max]=\"control?.max || null\" (focusout)=\"sendValue()\" [locale]=\"control?.locale || undefined\"\r\n [currency]=\"control?.currency || 'USD'\" [disabled]=\"control?.disabled || false\"></p-inputNumber>\r\n </ng-container>\r\n <ng-container *ngSwitchCase=\"'decimal'\">\r\n <p-inputNumber [(ngModel)]=\"value\" mode=\"decimal\" (focusout)=\"sendValue()\" [min]=\"control?.min || null\"\r\n [max]=\"control?.max || null\" [minFractionDigits]=\"control?.minFractionDigits || 0\" [locale]=\"control?.locale || undefined\"\r\n [disabled]=\"control?.disabled || false\"></p-inputNumber>\r\n </ng-container>\r\n <ng-container *ngSwitchCase=\"'percentage'\">\r\n <p-inputNumber [(ngModel)]=\"value\" suffix=\" %\" (focusout)=\"sendValue()\" [min]=\"control?.min || null\"\r\n [max]=\"control?.max || null\" [minFractionDigits]=\"control?.minFractionDigits || 2\" [locale]=\"control?.locale || undefined\"\r\n [disabled]=\"control?.disabled || false\"></p-inputNumber>\r\n </ng-container>\r\n <ng-container *ngSwitchCase=\"'decimal:search'\">\r\n <div class=\"p-inputgroup\">\r\n <input type=\"number\" pInputText [(ngModel)]=\"value\" (focusout)=\"sendValue()\" />\r\n <button type=\"button\" pButton icon=\"pi pi-search\" (click)=\"searchValue(value)\"></button>\r\n </div>\r\n </ng-container>\r\n </ng-container>\r\n </ng-container>\r\n <ng-container *ngSwitchCase=\"'file'\">\r\n <ng-container [ngSwitch]=\"control.subtype\">\r\n <ng-container *ngSwitchCase=\"'filetmp'\">\r\n <p-fileUpload [accept]=\"control.config.accept\" [customUpload]=\"true\" (uploadHandler)=\"onUpload($event)\"\r\n [maxFileSize]=\"control.config?.maxFileSize || null\" fileLimit=\"1\">\r\n <ng-template pTemplate=\"content\">\r\n <ul *ngIf=\"uploadedFiles.length\">\r\n <li *ngFor=\"let file of uploadedFiles\">{{file.name}} - {{file.size}} bytes</li>\r\n </ul>\r\n </ng-template>\r\n </p-fileUpload>\r\n </ng-container>\r\n </ng-container>\r\n </ng-container>\r\n <ng-container *ngSwitchCase=\"'boolean'\">\r\n <ng-container [ngSwitch]=\"control.subtype\">\r\n <ng-container *ngSwitchCase=\"'switch'\">\r\n <p-inputSwitch [(ngModel)]=\"value\" (onChange)=\"sendValue()\" [id]=\"label\"></p-inputSwitch>\r\n </ng-container>\r\n </ng-container>\r\n </ng-container>\r\n</ng-container>", components: [{ type: i2$2.InputMask, selector: "p-inputMask", inputs: ["type", "slotChar", "autoClear", "style", "inputId", "styleClass", "placeholder", "size", "maxlength", "tabindex", "title", "ariaLabel", "ariaRequired", "disabled", "readonly", "unmask", "name", "required", "characterPattern", "autoFocus", "autocomplete", "mask"], outputs: ["onComplete", "onFocus", "onBlur", "onInput", "onKeydown"] }, { type: i3$1.Dropdown, selector: "p-dropdown", inputs: ["scrollHeight", "filter", "name", "style", "panelStyle", "styleClass", "panelStyleClass", "readonly", "required", "editable", "appendTo", "tabindex", "placeholder", "filterPlaceholder", "filterLocale", "inputId", "selectId", "dataKey", "filterBy", "autofocus", "resetFilterOnHide", "dropdownIcon", "optionLabel", "optionValue", "optionDisabled", "optionGroupLabel", "optionGroupChildren", "autoDisplayFirst", "group", "showClear", "emptyFilterMessage", "emptyMessage", "virtualScroll", "itemSize", "autoZIndex", "baseZIndex", "showTransitionOptions", "hideTransitionOptions", "ariaFilterLabel", "ariaLabelledBy", "filterMatchMode", "maxlength", "tooltip", "tooltipPosition", "tooltipPositionStyle", "tooltipStyleClass", "autofocusFilter", "disabled", "options", "filterValue"], outputs: ["onChange", "onFilter", "onFocus", "onBlur", "onClick", "onShow", "onHide"] }, { type: i4$1.AutoComplete, selector: "p-autoComplete", inputs: ["minLength", "delay", "style", "panelStyle", "styleClass", "panelStyleClass", "inputStyle", "inputId", "inputStyleClass", "placeholder", "readonly", "disabled", "virtualScroll", "itemSize", "maxlength", "name", "required", "size", "appendTo", "autoHighlight", "forceSelection", "type", "autoZIndex", "baseZIndex", "ariaLabel", "ariaLabelledBy", "dropdownIcon", "unique", "group", "completeOnFocus", "field", "scrollHeight", "dropdown", "showEmptyMessage", "dropdownMode", "multiple", "tabindex", "dataKey", "emptyMessage", "showTransitionOptions", "hideTransitionOptions", "autofocus", "autocomplete", "optionGroupChildren", "optionGroupLabel", "suggestions"], outputs: ["completeMethod", "onSelect", "onUnselect", "onFocus", "onBlur", "onDropdownClick", "onClear", "onKeyUp", "onShow", "onHide"] }, { type: i5$1.Calendar, selector: "p-calendar", inputs: ["style", "styleClass", "inputStyle", "inputId", "name", "inputStyleClass", "placeholder", "ariaLabelledBy", "disabled", "dateFormat", "multipleSeparator", "rangeSeparator", "inline", "showOtherMonths", "selectOtherMonths", "showIcon", "icon", "appendTo", "readonlyInput", "shortYearCutoff", "monthNavigator", "yearNavigator", "hourFormat", "timeOnly", "stepHour", "stepMinute", "stepSecond", "showSeconds", "required", "showOnFocus", "showWeek", "dataType", "selectionMode", "maxDateCount", "showButtonBar", "todayButtonStyleClass", "clearButtonStyleClass", "autoZIndex", "baseZIndex", "panelStyleClass", "panelStyle", "keepInvalid", "hideOnDateTimeSelect", "numberOfMonths", "view", "touchUI", "timeSeparator", "focusTrap", "firstDayOfWeek", "showTransitionOptions", "hideTransitionOptions", "tabindex", "defaultDate", "minDate", "maxDate", "disabledDates", "disabledDays", "yearRange", "showTime", "locale"], outputs: ["onFocus", "onBlur", "onClose", "onSelect", "onInput", "onTodayClick", "onClearClick", "onMonthChange", "onYearChange", "onClickOutside", "onShow"] }, { type: i6$1.InputNumber, selector: "p-inputNumber", inputs: ["showButtons", "format", "buttonLayout", "inputId", "styleClass", "style", "placeholder", "size", "maxlength", "tabindex", "title", "ariaLabel", "ariaRequired", "name", "required", "autocomplete", "min", "max", "incrementButtonClass", "decrementButtonClass", "incrementButtonIcon", "decrementButtonIcon", "step", "inputStyle", "inputStyleClass", "locale", "localeMatcher", "mode", "currency", "currencyDisplay", "useGrouping", "minFractionDigits", "maxFractionDigits", "prefix", "suffix", "disabled"], outputs: ["onInput", "onFocus", "onBlur", "onKeyDown"] }, { type: i7$1.FileUpload, selector: "p-fileUpload", inputs: ["name", "url", "method", "multiple", "accept", "disabled", "auto", "withCredentials", "maxFileSize", "invalidFileSizeMessageSummary", "invalidFileSizeMessageDetail", "invalidFileTypeMessageSummary", "invalidFileTypeMessageDetail", "invalidFileLimitMessageDetail", "invalidFileLimitMessageSummary", "style", "styleClass", "previewWidth", "chooseLabel", "uploadLabel", "cancelLabel", "chooseIcon", "uploadIcon", "cancelIcon", "showUploadButton", "showCancelButton", "mode", "headers", "customUpload", "fileLimit", "files"], outputs: ["onBeforeUpload", "onSend", "onUpload", "onError", "onClear", "onRemove", "onSelect", "onProgress", "uploadHandler"] }, { type: i8.InputSwitch, selector: "p-inputSwitch", inputs: ["style", "styleClass", "tabindex", "inputId", "name", "disabled", "readonly", "ariaLabelledBy"], outputs: ["onChange"] }], directives: [{ type: i7.NgSwitch, selector: "[ngSwitch]", inputs: ["ngSwitch"] }, { type: i7.NgSwitchCase, selector: "[ngSwitchCase]", inputs: ["ngSwitchCase"] }, { type: i10$1.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { type: i11.InputText, selector: "[pInputText]" }, { type: i10$1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i10$1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { type: i12.InputTextarea, selector: "[pInputTextarea]", inputs: ["autoResize"], outputs: ["onResize"] }, { type: i9.ButtonDirective, selector: "[pButton]", inputs: ["iconPos", "loadingIcon", "label", "icon", "loading"] }, { type: i10$1.NumberValueAccessor, selector: "input[type=number][formControlName],input[type=number][formControl],input[type=number][ngModel]" }, { type: i2$1.PrimeTemplate, selector: "[pTemplate]", inputs: ["type", "pTemplate"] }, { type: i7.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i7.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }] });
312
477
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: ControlComponent, decorators: [{
313
478
  type: Component,
314
479
  args: [{
@@ -321,45 +486,638 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImpo
321
486
  type: Input
322
487
  }], value: [{
323
488
  type: Input
489
+ }], appendTo: [{
490
+ type: Input
324
491
  }], setValue: [{
325
492
  type: Output
493
+ }], sendNotification: [{
494
+ type: Output
495
+ }], sendObject: [{
496
+ type: Output
326
497
  }] } });
327
498
 
499
+ class RegistroDetalleComponent {
500
+ constructor(ref, config, messageService) {
501
+ this.ref = ref;
502
+ this.config = config;
503
+ this.messageService = messageService;
504
+ this.esquema = new Shema();
505
+ }
506
+ ngOnInit() {
507
+ var _a;
508
+ this.uiEsquema = this.config.data.uiEsquema[0];
509
+ this.esquema = this.config.data.esquema;
510
+ this.data = (_a = this.config.data) === null || _a === void 0 ? void 0 : _a.data;
511
+ if (!this.data) {
512
+ this.data = this.createObject(this.esquema);
513
+ jsonpath.value(this.data, '$..id', this.config.data.id);
514
+ }
515
+ }
516
+ getControl(scope) {
517
+ return jsonpath.query(this.esquema, scope)[0];
518
+ }
519
+ getValue(scope) {
520
+ return jsonpath.query(this.data, scope.replace('.properties', ''))[0];
521
+ }
522
+ setValue(value, scope) {
523
+ switch (typeof (value)) {
524
+ case 'object':
525
+ if (Array.isArray(value))
526
+ value.forEach((val) => jsonpath.value(this.data, val.scope.replace('.properties', ''), val.value));
527
+ else
528
+ jsonpath.value(this.data, scope.replace('.properties', ''), value);
529
+ break;
530
+ default:
531
+ jsonpath.value(this.data, scope.replace('.properties', ''), value);
532
+ break;
533
+ }
534
+ this.applyValuesOnEvent('onChange', this.esquema, scope.replace('$..properties.', ''));
535
+ }
536
+ createObject(esquema) {
537
+ let object = {};
538
+ const resultArray = [];
539
+ switch (esquema.type) {
540
+ case 'numeric':
541
+ return (esquema === null || esquema === void 0 ? void 0 : esquema.default) || 0;
542
+ case 'string':
543
+ case 'date':
544
+ return (esquema === null || esquema === void 0 ? void 0 : esquema.default) ? this.setDefaultValue(esquema.default) : null;
545
+ case 'boolean':
546
+ return (esquema === null || esquema === void 0 ? void 0 : esquema.default) || false;
547
+ case 'file':
548
+ return null;
549
+ case 'array':
550
+ case 'object':
551
+ for (const key in esquema === null || esquema === void 0 ? void 0 : esquema.properties) {
552
+ Object.defineProperty(object, key, { value: this.createObject(esquema === null || esquema === void 0 ? void 0 : esquema.properties[key]), writable: true, enumerable: true, configurable: true });
553
+ }
554
+ break;
555
+ default:
556
+ break;
557
+ }
558
+ return object;
559
+ }
560
+ setDefaultValue(value) {
561
+ let data = null;
562
+ let uactivo;
563
+ switch (value) {
564
+ case '@uactivo':
565
+ uactivo = JSON.parse(localStorage.getItem('oSessionTFM') || '{}');
566
+ if (!uactivo)
567
+ console.log('Validar configuracion de sesion');
568
+ else
569
+ data = `${uactivo.UsuarioSistema.TDOC}-${uactivo.UsuarioSistema.NDOC}`;
570
+ break;
571
+ case '@tdocactivo':
572
+ uactivo = JSON.parse(sessionStorage.getItem('usrSesion') || '{}');
573
+ if (!uactivo)
574
+ console.log('Validar configuracion de sesion');
575
+ else
576
+ data = uactivo.UsuarioSistema.TDOC;
577
+ break;
578
+ case '@ndocactivo':
579
+ uactivo = JSON.parse(sessionStorage.getItem('usrSesion') || '{}');
580
+ if (!uactivo)
581
+ console.log('Validar configuracion de sesion');
582
+ else
583
+ data = uactivo.UsuarioSistema.NDOC;
584
+ break;
585
+ case '@hoy':
586
+ data = new Date();
587
+ break;
588
+ default:
589
+ data = value;
590
+ break;
591
+ }
592
+ return data;
593
+ }
594
+ submit() {
595
+ this.applyValuesOnEvent('onSubmit', this.esquema);
596
+ if (!this.validateData())
597
+ return;
598
+ this.ref.close(this.data);
599
+ }
600
+ cancel() {
601
+ this.applyValuesOnEvent('onCancel', this.esquema);
602
+ this.ref.close();
603
+ }
604
+ validateData() {
605
+ if (this.esquema.validations.type == 'local')
606
+ return this.validateDataLocal();
607
+ return true;
608
+ }
609
+ validateDataLocal() {
610
+ let err = [];
611
+ this.esquema.validations.required.forEach((x) => {
612
+ if (!jsonpath.query(this.data, x.field)[0])
613
+ err.push(x.message);
614
+ });
615
+ if (err.length != 0)
616
+ this.messageService.add({ severity: 'warn', detail: err.join('. ') });
617
+ return err.length == 0;
618
+ }
619
+ applyValuesOnEvent(event, esquema, scope) {
620
+ if (scope) {
621
+ if (esquema.properties[scope][event]) {
622
+ esquema.properties[scope][event].forEach((value) => {
623
+ this.setValueEvent(this.data, value);
624
+ });
625
+ }
626
+ }
627
+ else {
628
+ for (const key in esquema.properties) {
629
+ if (esquema.properties[key][event]) {
630
+ esquema.properties[key][event].forEach((value) => {
631
+ this.setValueEvent(this.data, value);
632
+ });
633
+ }
634
+ }
635
+ }
636
+ }
637
+ setValueEvent(data, params) {
638
+ var _a;
639
+ let value;
640
+ let date = moment(new Date());
641
+ switch (params.op) {
642
+ case 'sum':
643
+ value = jsonpath.query(data, params === null || params === void 0 ? void 0 : params.scope[0]).reduce((acc, cur) => acc += (params === null || params === void 0 ? void 0 : params.key) ? cur[params.key] : cur, 0);
644
+ break;
645
+ case 'concat':
646
+ let array = [];
647
+ (_a = params === null || params === void 0 ? void 0 : params.key) === null || _a === void 0 ? void 0 : _a.reduce((acc, cur) => {
648
+ array.push(jsonpath.query(data, cur)[0]);
649
+ }, []);
650
+ if (params === null || params === void 0 ? void 0 : params.separator)
651
+ jsonpath.value(data, params.scope[0], array.join((params === null || params === void 0 ? void 0 : params.separator) || ' '));
652
+ break;
653
+ case 'enable':
654
+ jsonpath.value(this.esquema, params.scope[0], false);
655
+ break;
656
+ case 'disabled':
657
+ jsonpath.value(this.esquema, params.scope[0], true);
658
+ break;
659
+ case 'replace:endpoint':
660
+ jsonpath.value(this.esquema, params.scope[0], jsonpath.query(this.esquema, params.scope[1])[0].replace(params.scope[2], jsonpath.query(data, `$..${params.key}`)));
661
+ break;
662
+ case 'setNull':
663
+ jsonpath.value(this.data, `$.${params.key}`, null);
664
+ break;
665
+ case 'datediff:years':
666
+ jsonpath.value(this.data, params.scope[0], date.diff(moment(jsonpath.query(this.data, params.scope[1])[0]), 'years'));
667
+ break;
668
+ case 'datediff:months':
669
+ jsonpath.value(this.data, params.scope[0], date.diff(moment(jsonpath.query(this.data, params.scope[1])[0]), 'months'));
670
+ break;
671
+ case 'datediff:weeks':
672
+ jsonpath.value(this.data, params.scope[0], date.diff(moment(jsonpath.query(this.data, params.scope[1])[0]), 'weeks'));
673
+ break;
674
+ case 'datediff:days':
675
+ jsonpath.value(this.data, params.scope[0], date.diff(moment(jsonpath.query(this.data, params.scope[1])[0]), 'days'));
676
+ break;
677
+ default:
678
+ break;
679
+ }
680
+ return value;
681
+ }
682
+ sendNotification(message) {
683
+ this.messageService.add(message);
684
+ }
685
+ applyValuesFromObject(event) {
686
+ if (event.data)
687
+ event.optionValue.forEach((value) => jsonpath.value(this.data, value.scope.replace('.properties', ''), this.aplyFormatValue(value.scope, event.data[value.key])));
688
+ else
689
+ event.optionValue.forEach((value) => jsonpath.value(this.data, value.scope.replace('.properties', ''), null));
690
+ }
691
+ aplyFormatValue(scope, value) {
692
+ let control = jsonpath.query(this.esquema, scope)[0];
693
+ let resp;
694
+ switch (control.type) {
695
+ case 'date':
696
+ resp = new Date(`${value}`);
697
+ break;
698
+ case 'numeric':
699
+ resp = +value;
700
+ break;
701
+ default:
702
+ resp = value;
703
+ break;
704
+ }
705
+ return resp;
706
+ }
707
+ }
708
+ RegistroDetalleComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: RegistroDetalleComponent, deps: [{ token: i1$1.DynamicDialogRef }, { token: i1$1.DynamicDialogConfig }, { token: i2$1.MessageService }], target: i0.ɵɵFactoryTarget.Component });
709
+ RegistroDetalleComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.17", type: RegistroDetalleComponent, selector: "lib-registro-detalle", ngImport: i0, template: "<p-toast></p-toast>\r\n<div *ngFor=\"let element of uiEsquema.elements\" [class]=\"element?.class\" #a>\r\n <ng-container [ngSwitch]=\"element.type\">\r\n <div *ngSwitchCase=\"'Label'\" [style]=\"element?.style\">\r\n {{element?.label}}\r\n </div>\r\n <ng-container *ngSwitchCase=\"'HorizontalLayout'\">\r\n <div *ngFor=\"let el of element.elements\" [class]=\"el?.class\">\r\n <ng-container [ngSwitch]=\"el.type\">\r\n <sf-control *ngSwitchCase=\"'Control'\" [control]=\"getControl(el.scope)\" [label]=\"el.label\"\r\n [value]=\"getValue(el.scope)\" (setValue)=\"setValue($event, el.scope)\"\r\n (sendNotification)=\"sendNotification($event)\" (sendObject)=\"applyValuesFromObject($event)\"></sf-control>\r\n </ng-container>\r\n </div>\r\n </ng-container>\r\n <ng-container *ngSwitchCase=\"'VerticalLayout'\">\r\n <div *ngFor=\"let el of element.elements\" [class]=\"el?.class\">\r\n <ng-container [ngSwitch]=\"el.type\">\r\n <sf-control *ngSwitchCase=\"'Control'\" [control]=\"getControl(el.scope)\" [label]=\"el.label\"\r\n [value]=\"getValue(el.scope)\" (setValue)=\"setValue($event, el.scope)\"\r\n (sendNotification)=\"sendNotification($event)\" (sendObject)=\"applyValuesFromObject($event)\"></sf-control>\r\n </ng-container>\r\n </div>\r\n </ng-container>\r\n <ng-container *ngSwitchCase=\"'Control'\">\r\n <sf-control [control]=\"getControl(element.scope)\" [label]=\"element.label\"></sf-control>\r\n </ng-container>\r\n </ng-container>\r\n</div>\r\n<div class=\"card-footer mt-2\">\r\n <button pButton pRipple type=\"button\" label=\"Guardar\" (click)=\"submit()\" class=\"mr-2\"></button>\r\n <button pButton pRipple type=\"button\" label=\"Cancelar\" (click)=\"cancel()\" class=\"p-button-danger\"></button>\r\n</div>", styles: [""], components: [{ type: i3$2.Toast, selector: "p-toast", inputs: ["key", "autoZIndex", "baseZIndex", "style", "styleClass", "position", "preventOpenDuplicates", "preventDuplicates", "showTransformOptions", "hideTransformOptions", "showTransitionOptions", "hideTransitionOptions", "breakpoints"], outputs: ["onClose"] }, { type: ControlComponent, selector: "sf-control", inputs: ["control", "label", "value", "appendTo"], outputs: ["setValue", "sendNotification", "sendObject"] }], directives: [{ type: i7.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i7.NgSwitch, selector: "[ngSwitch]", inputs: ["ngSwitch"] }, { type: i7.NgSwitchCase, selector: "[ngSwitchCase]", inputs: ["ngSwitchCase"] }, { type: i9.ButtonDirective, selector: "[pButton]", inputs: ["iconPos", "loadingIcon", "label", "icon", "loading"] }, { type: i10.Ripple, selector: "[pRipple]" }] });
710
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: RegistroDetalleComponent, decorators: [{
711
+ type: Component,
712
+ args: [{
713
+ selector: 'lib-registro-detalle',
714
+ templateUrl: './registro-detalle.component.html',
715
+ styleUrls: ['./registro-detalle.component.css']
716
+ }]
717
+ }], ctorParameters: function () { return [{ type: i1$1.DynamicDialogRef }, { type: i1$1.DynamicDialogConfig }, { type: i2$1.MessageService }]; } });
718
+
719
+ class RegistroChildComponent {
720
+ constructor(ref, config, messageService, dialogService) {
721
+ this.ref = ref;
722
+ this.config = config;
723
+ this.messageService = messageService;
724
+ this.dialogService = dialogService;
725
+ this.esquema = new Shema();
726
+ this.trx = 'c';
727
+ this.controlsLoaded = false;
728
+ }
729
+ ngOnInit() {
730
+ var _a;
731
+ this.uiEsquema = this.config.data.uiEsquema[0];
732
+ this.esquema = this.config.data.esquema;
733
+ this.data = (_a = this.config.data) === null || _a === void 0 ? void 0 : _a.data;
734
+ if (!this.data) {
735
+ this.data = this.createObject(this.esquema);
736
+ jsonpath.value(this.data, '$..id', this.config.data.id);
737
+ }
738
+ this.buildControls();
739
+ }
740
+ buildControls() {
741
+ this.controlsLoaded = false;
742
+ this.controls = [];
743
+ this.values = [];
744
+ this.uiEsquema.elements.forEach((layout, i) => {
745
+ var _a;
746
+ this.controls.push([]);
747
+ this.values.push([]);
748
+ (_a = layout.elements) === null || _a === void 0 ? void 0 : _a.forEach((element) => {
749
+ if (!element.scope)
750
+ console.log("CONFIGURAR BIEN " + element);
751
+ this.controls[i].push(this.getControl(element.scope));
752
+ this.values[i].push(this.getValue(element.scope));
753
+ });
754
+ });
755
+ this.controlsLoaded = true;
756
+ }
757
+ getControl(scope) {
758
+ return jsonpath.query(this.esquema, scope)[0];
759
+ }
760
+ getValue(scope) {
761
+ return jsonpath.query(this.data, scope.replace('.properties', ''))[0];
762
+ }
763
+ setValue(value, scope, i, j) {
764
+ switch (typeof (value)) {
765
+ case 'object':
766
+ if (Array.isArray(value))
767
+ value.forEach((val) => jsonpath.value(this.data, val.scope.replace('.properties', ''), val.value));
768
+ else {
769
+ this.values[i][j] = value;
770
+ jsonpath.value(this.data, scope.replace('.properties', ''), value);
771
+ }
772
+ break;
773
+ default:
774
+ this.values[i][j] = value;
775
+ jsonpath.value(this.data, scope.replace('.properties', ''), value);
776
+ break;
777
+ }
778
+ this.applyValuesOnEvent('onChange', this.esquema, scope.replace('$..properties.', ''));
779
+ }
780
+ createObject(esquema) {
781
+ let object = {};
782
+ const resultArray = [];
783
+ switch (esquema.type) {
784
+ case 'numeric':
785
+ return (esquema === null || esquema === void 0 ? void 0 : esquema.default) || 0;
786
+ case 'string':
787
+ case 'date':
788
+ return (esquema === null || esquema === void 0 ? void 0 : esquema.default) ? this.setDefaultValue(esquema.default) : null;
789
+ case 'boolean':
790
+ return (esquema === null || esquema === void 0 ? void 0 : esquema.default) || false;
791
+ case 'file':
792
+ return null;
793
+ case 'array':
794
+ case 'object':
795
+ for (const key in esquema === null || esquema === void 0 ? void 0 : esquema.properties) {
796
+ Object.defineProperty(object, key, { value: this.createObjectChild(esquema === null || esquema === void 0 ? void 0 : esquema.properties[key]), writable: true, enumerable: true, configurable: true });
797
+ }
798
+ break;
799
+ default:
800
+ break;
801
+ }
802
+ return object;
803
+ }
804
+ createObjectChild(esquema) {
805
+ let object = {};
806
+ const resultArray = [];
807
+ switch (esquema.type) {
808
+ case 'numeric':
809
+ return (esquema === null || esquema === void 0 ? void 0 : esquema.default) || 0;
810
+ case 'string':
811
+ case 'date':
812
+ return (esquema === null || esquema === void 0 ? void 0 : esquema.default) ? this.setDefaultValue(esquema.default) : null;
813
+ case 'boolean':
814
+ return (esquema === null || esquema === void 0 ? void 0 : esquema.default) || false;
815
+ case 'file':
816
+ return null;
817
+ case 'array':
818
+ return [];
819
+ case 'object':
820
+ for (const key in esquema === null || esquema === void 0 ? void 0 : esquema.properties) {
821
+ Object.defineProperty(object, key, { value: this.createObject(esquema === null || esquema === void 0 ? void 0 : esquema.properties[key]), writable: true, enumerable: true, configurable: true });
822
+ }
823
+ break;
824
+ default:
825
+ break;
826
+ }
827
+ return object;
828
+ }
829
+ setDefaultValue(value) {
830
+ let data = null;
831
+ let uactivo;
832
+ switch (value) {
833
+ case '@uactivo':
834
+ uactivo = JSON.parse(localStorage.getItem('oSessionTFM') || '{}');
835
+ if (!uactivo)
836
+ console.log('Validar configuracion de sesion');
837
+ else
838
+ data = `${uactivo.UsuarioSistema.TDOC}-${uactivo.UsuarioSistema.NDOC}`;
839
+ break;
840
+ case '@tdocactivo':
841
+ uactivo = JSON.parse(sessionStorage.getItem('usrSesion') || '{}');
842
+ if (!uactivo)
843
+ console.log('Validar configuracion de sesion');
844
+ else
845
+ data = uactivo.UsuarioSistema.TDOC;
846
+ break;
847
+ case '@ndocactivo':
848
+ uactivo = JSON.parse(sessionStorage.getItem('usrSesion') || '{}');
849
+ if (!uactivo)
850
+ console.log('Validar configuracion de sesion');
851
+ else
852
+ data = uactivo.UsuarioSistema.NDOC;
853
+ break;
854
+ case '@hoy':
855
+ data = new Date();
856
+ break;
857
+ default:
858
+ data = value;
859
+ break;
860
+ }
861
+ return data;
862
+ }
863
+ submit() {
864
+ this.applyValuesOnEvent('onSubmit', this.esquema);
865
+ if (!this.validateData())
866
+ return;
867
+ this.ref.close(this.data);
868
+ }
869
+ cancel() {
870
+ this.applyValuesOnEvent('onCancel', this.esquema);
871
+ this.ref.close();
872
+ }
873
+ validateData() {
874
+ if (this.esquema.validations.type == 'local')
875
+ return this.validateDataLocal();
876
+ return true;
877
+ }
878
+ validateDataLocal() {
879
+ let err = [];
880
+ this.esquema.validations.required.forEach((x) => {
881
+ if (!jsonpath.query(this.data, x.field)[0])
882
+ err.push(x.message);
883
+ });
884
+ if (err.length != 0)
885
+ this.messageService.add({ severity: 'warn', detail: err.join('. ') });
886
+ return err.length == 0;
887
+ }
888
+ applyValuesOnEvent(event, esquema, scope) {
889
+ if (scope) {
890
+ if (esquema.properties[scope][event]) {
891
+ esquema.properties[scope][event].forEach((value) => {
892
+ this.setValueEvent(this.data, value);
893
+ });
894
+ }
895
+ }
896
+ else {
897
+ for (const key in esquema.properties) {
898
+ if (esquema.properties[key][event]) {
899
+ esquema.properties[key][event].forEach((value) => {
900
+ this.setValueEvent(this.data, value);
901
+ });
902
+ }
903
+ }
904
+ }
905
+ }
906
+ setValueEvent(data, params) {
907
+ var _a;
908
+ let value;
909
+ let date = moment(new Date());
910
+ switch (params.op) {
911
+ case 'sum':
912
+ value = jsonpath.query(data, params === null || params === void 0 ? void 0 : params.scope[0]).reduce((acc, cur) => acc += (params === null || params === void 0 ? void 0 : params.key) ? cur[params.key] : cur, 0);
913
+ break;
914
+ case 'concat':
915
+ let array = [];
916
+ (_a = params === null || params === void 0 ? void 0 : params.key) === null || _a === void 0 ? void 0 : _a.reduce((acc, cur) => {
917
+ array.push(jsonpath.query(data, cur)[0]);
918
+ }, []);
919
+ if (params === null || params === void 0 ? void 0 : params.separator)
920
+ jsonpath.value(data, params.scope[0], array.join((params === null || params === void 0 ? void 0 : params.separator) || ' '));
921
+ break;
922
+ case 'enable':
923
+ jsonpath.value(this.esquema, params.scope[0], false);
924
+ break;
925
+ case 'disabled':
926
+ jsonpath.value(this.esquema, params.scope[0], true);
927
+ break;
928
+ case 'replace:endpoint':
929
+ jsonpath.value(this.esquema, params.scope[0], jsonpath.query(this.esquema, params.scope[1])[0].replace(params.scope[2], jsonpath.query(data, `$..${params.key}`)));
930
+ break;
931
+ case 'setNull':
932
+ jsonpath.value(this.data, `$.${params.key}`, null);
933
+ break;
934
+ case 'datediff:years':
935
+ jsonpath.value(this.data, params.scope[0], date.diff(moment(jsonpath.query(this.data, params.scope[1])[0]), 'years'));
936
+ break;
937
+ case 'datediff:months':
938
+ jsonpath.value(this.data, params.scope[0], date.diff(moment(jsonpath.query(this.data, params.scope[1])[0]), 'months'));
939
+ break;
940
+ case 'datediff:weeks':
941
+ jsonpath.value(this.data, params.scope[0], date.diff(moment(jsonpath.query(this.data, params.scope[1])[0]), 'weeks'));
942
+ break;
943
+ case 'datediff:days':
944
+ jsonpath.value(this.data, params.scope[0], date.diff(moment(jsonpath.query(this.data, params.scope[1])[0]), 'days'));
945
+ break;
946
+ default:
947
+ break;
948
+ }
949
+ return value;
950
+ }
951
+ sendNotification(message) {
952
+ this.messageService.add(message);
953
+ }
954
+ addObjectArray(element) {
955
+ this.dialogRef = this.dialogService.open(RegistroDetalleComponent, {
956
+ header: element.label ? element.label : 'Detalle',
957
+ width: '70%',
958
+ modal: true,
959
+ closable: false,
960
+ data: {
961
+ uiEsquema: Object.assign({}, element.elements),
962
+ esquema: this.getControl(element.scope),
963
+ id: this.getValue(element.scope).length + 1
964
+ }
965
+ });
966
+ this.dialogRef.onClose.subscribe((data) => {
967
+ if (data)
968
+ this.data[element.scope.replace('$..properties.', '')].push(data);
969
+ this.applyValuesOnEvent('onChange', this.esquema, element.scope.replace('$..properties.', ''));
970
+ });
971
+ }
972
+ editRow(element, data, index) {
973
+ this.dialogRef = this.dialogService.open(RegistroDetalleComponent, {
974
+ header: element.label ? element.label : 'Detalle',
975
+ width: '70%',
976
+ modal: true,
977
+ closable: false,
978
+ data: {
979
+ uiEsquema: Object.assign({}, element.elements),
980
+ esquema: this.getControl(element.scope),
981
+ data: Object.assign({}, data)
982
+ }
983
+ });
984
+ this.dialogRef.onClose.subscribe((data) => {
985
+ if (data)
986
+ this.data[element.scope.replace('$..properties.', '')][index] = data;
987
+ this.applyValuesOnEvent('onChange', this.esquema, element.scope.replace('$..properties.', ''));
988
+ });
989
+ }
990
+ deleteRow(element, index) {
991
+ this.data[element.scope.replace('$..properties.', '')].splice(index, 1);
992
+ index = 1;
993
+ this.data[element.scope.replace('$..properties.', '')].forEach((el) => {
994
+ el.id = index;
995
+ index++;
996
+ });
997
+ this.applyValuesOnEvent('onChange', this.esquema, element.scope.replace('$..properties.', ''));
998
+ }
999
+ applyValuesFromObject(event) {
1000
+ if (event.data)
1001
+ event.optionValue.forEach((value) => jsonpath.value(this.data, value.scope.replace('.properties', ''), this.aplyFormatValue(value.scope, event.data[value.key])));
1002
+ else
1003
+ event.optionValue.forEach((value) => jsonpath.value(this.data, value.scope.replace('.properties', ''), null));
1004
+ }
1005
+ aplyFormatValue(scope, value) {
1006
+ let control = jsonpath.query(this.esquema, scope)[0];
1007
+ let resp;
1008
+ switch (control.type) {
1009
+ case 'date':
1010
+ resp = new Date(`${value}`);
1011
+ break;
1012
+ case 'numeric':
1013
+ resp = +value;
1014
+ break;
1015
+ default:
1016
+ resp = value;
1017
+ break;
1018
+ }
1019
+ return resp;
1020
+ }
1021
+ }
1022
+ RegistroChildComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: RegistroChildComponent, deps: [{ token: i1$1.DynamicDialogRef }, { token: i1$1.DynamicDialogConfig }, { token: i2$1.MessageService }, { token: i1$1.DialogService }], target: i0.ɵɵFactoryTarget.Component });
1023
+ RegistroChildComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.17", type: RegistroChildComponent, selector: "lib-registro-child", providers: [MessageService, DialogService], ngImport: i0, template: "<p-toast></p-toast>\r\n<div *ngIf=\"controlsLoaded\">\r\n<div *ngFor=\"let element of uiEsquema.elements; let i = index\" [class]=\"element?.class\" #a>\r\n <ng-container [ngSwitch]=\"element.type\">\r\n <div *ngSwitchCase=\"'Label'\" [style]=\"element?.style\">\r\n {{element?.label}}\r\n </div>\r\n <ng-container *ngSwitchCase=\"'HorizontalLayout'\">\r\n <div *ngFor=\"let el of element.elements; let j =index\" [class]=\"el?.class\">\r\n <ng-container [ngSwitch]=\"el.type\">\r\n <sf-control *ngSwitchCase=\"'Control'\" [control]=\"controls[i][j]\" [label]=\"el.label\" [value]=\"values[i][j]\"\r\n (setValue)=\"setValue($event, el.scope, i, j)\" (sendNotification)=\"sendNotification($event)\"\r\n (sendObject)=\"applyValuesFromObject($event)\"></sf-control>\r\n </ng-container>\r\n </div>\r\n </ng-container>\r\n <ng-container *ngSwitchCase=\"'VerticalLayout'\">\r\n <div *ngFor=\"let el of element.elements; let k =index\" [class]=\"el?.class\">\r\n <ng-container [ngSwitch]=\"el.type\">\r\n <sf-control *ngSwitchCase=\"'Control'\" [control]=\"controls[i][k]\" [label]=\"el.label\"\r\n [value]=\"values[i][k]\" (setValue)=\"setValue($event, el.scope, i, k)\"\r\n (sendNotification)=\"sendNotification($event)\"\r\n (sendObject)=\"applyValuesFromObject($event)\"></sf-control>\r\n <ng-container *ngSwitchCase=\"'Table'\">\r\n <p-table [value]=\"getValue(el.scope)\" [columns]=\"getControl(el.scope).config.columns\">\r\n <ng-template pTemplate=\"caption\">\r\n <div class=\"flex align-items-center justify-content-between\">\r\n <button pButton pRipple icon=\"pi pi-plus\" (click)=\"addObjectArray(el)\"\r\n class=\"p-button-success\"></button>\r\n </div>\r\n </ng-template>\r\n <ng-template pTemplate=\"header\" let-columns>\r\n <tr>\r\n <th *ngFor=\"let col of columns\">\r\n {{col.label}}\r\n </th>\r\n <ng-container *ngIf=\"trx == 'c' || trx == 'u'\">\r\n <th></th>\r\n </ng-container>\r\n </tr>\r\n </ng-template>\r\n <ng-template pTemplate=\"body\" let-rowData let-columns=\"columns\" let-rowIndex=\"rowIndex\">\r\n <tr>\r\n <ng-container *ngFor=\"let col of columns\" [ngSwitch]=\"col.type\">\r\n <ng-container *ngSwitchCase=\"'text'\">\r\n <td>{{rowData[col.col]}}</td>\r\n </ng-container>\r\n <ng-container *ngSwitchCase=\"'currency:USD'\">\r\n <td>{{rowData[col.col] | currency: 'USD'}}</td>\r\n </ng-container>\r\n <ng-container *ngSwitchCase=\"'date:yyyy-mm-dd'\">\r\n <td>{{rowData[col.col] | date: 'yyyy-mm-dd'}}</td>\r\n </ng-container>\r\n <ng-container *ngSwitchCase=\"'date:dd/mm/yyyy'\">\r\n <td>{{rowData[col.col] | date: 'dd/MM/yyyy'}}</td>\r\n </ng-container>\r\n <ng-container *ngSwitchCase=\"'boolean'\">\r\n <td>\r\n <i *ngIf=\"rowData[col.col]\" class=\"pi pi-check\"></i>\r\n <i *ngIf=\"!rowData[col.col]\" class=\"pi pi-times\"></i>\r\n </td>\r\n </ng-container>\r\n </ng-container>\r\n <ng-container *ngIf=\"trx == 'c' || trx == 'u'\">\r\n <td>\r\n <button pButton pRipple type=\"button\"\r\n (click)=\"editRow(el, rowData, rowIndex)\" icon=\"pi pi-pencil\"\r\n class=\"p-button-rounded p-button-info mr-1\"></button>\r\n <button pButton pRipple type=\"button\" (click)=\"deleteRow(el, rowIndex)\"\r\n icon=\"pi pi-trash\" class=\"p-button-rounded p-button-danger\"></button>\r\n </td>\r\n </ng-container>\r\n </tr>\r\n </ng-template>\r\n </p-table>\r\n </ng-container>\r\n </ng-container>\r\n </div>\r\n </ng-container>\r\n <ng-container *ngSwitchCase=\"'Control'\">\r\n <sf-control [control]=\"getControl(element.scope)\" [label]=\"element.label\"></sf-control>\r\n </ng-container>\r\n </ng-container>\r\n</div>\r\n<div class=\"card-footer mt-2\">\r\n <button pButton pRipple type=\"button\" label=\"Guardar\" (click)=\"submit()\" class=\"mr-2\"></button>\r\n <button pButton pRipple type=\"button\" label=\"Cancelar\" (click)=\"cancel()\" class=\"p-button-danger\"></button>\r\n</div>\r\n</div>\r\n", components: [{ type: i3$2.Toast, selector: "p-toast", inputs: ["key", "autoZIndex", "baseZIndex", "style", "styleClass", "position", "preventOpenDuplicates", "preventDuplicates", "showTransformOptions", "hideTransformOptions", "showTransitionOptions", "hideTransitionOptions", "breakpoints"], outputs: ["onClose"] }, { type: ControlComponent, selector: "sf-control", inputs: ["control", "label", "value", "appendTo"], outputs: ["setValue", "sendNotification", "sendObject"] }, { type: i5.Table, selector: "p-table", inputs: ["frozenColumns", "frozenValue", "style", "styleClass", "tableStyle", "tableStyleClass", "paginator", "pageLinks", "rowsPerPageOptions", "alwaysShowPaginator", "paginatorPosition", "paginatorDropdownAppendTo", "paginatorDropdownScrollHeight", "currentPageReportTemplate", "showCurrentPageReport", "showJumpToPageDropdown", "showFirstLastIcon", "showPageLinks", "defaultSortOrder", "sortMode", "resetPageOnSort", "selectionMode", "contextMenuSelection", "contextMenuSelectionMode", "dataKey", "metaKeySelection", "rowTrackBy", "lazy", "lazyLoadOnInit", "compareSelectionBy", "csvSeparator", "exportFilename", "filters", "globalFilterFields", "filterDelay", "filterLocale", "expandedRowKeys", "editingRowKeys", "rowExpandMode", "scrollable", "scrollDirection", "rowGroupMode", "scrollHeight", "virtualScroll", "virtualScrollDelay", "virtualRowHeight", "frozenWidth", "responsive", "contextMenu", "resizableColumns", "columnResizeMode", "reorderableColumns", "loading", "loadingIcon", "showLoader", "rowHover", "customSort", "showInitialSortBadge", "autoLayout", "exportFunction", "stateKey", "stateStorage", "editMode", "groupRowsBy", "minBufferPx", "maxBufferPx", "responsiveLayout", "breakpoint", "value", "columns", "first", "rows", "totalRecords", "sortField", "sortOrder", "multiSortMeta", "selection"], outputs: ["selectionChange", "contextMenuSelectionChange", "onRowSelect", "onRowUnselect", "onPage", "onSort", "onFilter", "onLazyLoad", "onRowExpand", "onRowCollapse", "onContextMenuSelect", "onColResize", "onColReorder", "onRowReorder", "onEditInit", "onEditComplete", "onEditCancel", "onHeaderCheckboxToggle", "sortFunction", "firstChange", "rowsChange", "onStateSave", "onStateRestore"] }], directives: [{ type: i7.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i7.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i7.NgSwitch, selector: "[ngSwitch]", inputs: ["ngSwitch"] }, { type: i7.NgSwitchCase, selector: "[ngSwitchCase]", inputs: ["ngSwitchCase"] }, { type: i2$1.PrimeTemplate, selector: "[pTemplate]", inputs: ["type", "pTemplate"] }, { type: i9.ButtonDirective, selector: "[pButton]", inputs: ["iconPos", "loadingIcon", "label", "icon", "loading"] }, { type: i10.Ripple, selector: "[pRipple]" }], pipes: { "currency": i7.CurrencyPipe, "date": i7.DatePipe } });
1024
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: RegistroChildComponent, decorators: [{
1025
+ type: Component,
1026
+ args: [{
1027
+ selector: 'lib-registro-child',
1028
+ templateUrl: './registro-child.component.html',
1029
+ providers: [MessageService, DialogService]
1030
+ }]
1031
+ }], ctorParameters: function () { return [{ type: i1$1.DynamicDialogRef }, { type: i1$1.DynamicDialogConfig }, { type: i2$1.MessageService }, { type: i1$1.DialogService }]; } });
1032
+
1033
+ class SfCrudService {
1034
+ constructor() {
1035
+ this._dataTemp = [];
1036
+ }
1037
+ saveDataTemp(scope, value) {
1038
+ this._dataTemp.push({ scope, value });
1039
+ sessionStorage.setItem('dataTemp', JSON.stringify(this._dataTemp));
1040
+ }
1041
+ getDataTemp() {
1042
+ let dataTemp = sessionStorage.getItem('dataTemp');
1043
+ sessionStorage.removeItem('dataTemp');
1044
+ return dataTemp ? JSON.parse(dataTemp) : [];
1045
+ }
1046
+ cleanDataTemp() {
1047
+ sessionStorage.removeItem('dataTemp');
1048
+ }
1049
+ }
1050
+ SfCrudService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: SfCrudService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
1051
+ SfCrudService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: SfCrudService, providedIn: 'root' });
1052
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: SfCrudService, decorators: [{
1053
+ type: Injectable,
1054
+ args: [{
1055
+ providedIn: 'root'
1056
+ }]
1057
+ }], ctorParameters: function () { return []; } });
1058
+
328
1059
  class RegistroComponent {
329
- constructor(generalService, router, messageSerice) {
1060
+ constructor(generalService, router, messageSerice, dialogService, sfCrudService) {
330
1061
  this.generalService = generalService;
331
1062
  this.router = router;
332
1063
  this.messageSerice = messageSerice;
1064
+ this.dialogService = dialogService;
1065
+ this.sfCrudService = sfCrudService;
333
1066
  this.idKatios = '';
334
1067
  this.idEntidad = '';
335
1068
  this.trx = '';
336
1069
  this.id = '';
337
- this.enProceso = false;
1070
+ this.sendData = new EventEmitter();
1071
+ this.onSubmit = new EventEmitter();
1072
+ this.dataTemp = [];
338
1073
  this.crudConfig = new CrudConfig();
1074
+ this.enProceso = false;
339
1075
  this.configOperation = new Operations();
1076
+ this.isLocal = false;
1077
+ this.controlsLoaded = false;
1078
+ this.dataTemp = this.sfCrudService.getDataTemp();
340
1079
  }
341
1080
  ngOnInit() {
342
1081
  this.loadConfigCrud();
343
- this.setLabelSumbit();
344
1082
  }
345
1083
  loadConfigCrud() {
346
1084
  this.enProceso = true;
347
1085
  this.generalService.getCrudByEntidad(this.idKatios, this.idEntidad)
348
1086
  .then(res => {
1087
+ this.setDataTemp(res.esquema, this.dataTemp);
349
1088
  this.crudConfig = res;
350
- if (this.trx != 'c')
351
- this.getInfoRegistro(this.crudConfig.registro);
352
- else {
1089
+ if (this.trx == 'c') {
353
1090
  this.data = this.createObject(this.crudConfig.esquema);
1091
+ this.setLabelSumbit();
354
1092
  this.enProceso = false;
1093
+ this.configOperation = this.crudConfig.registro.operations.find(x => x.type.startsWith(this.trx)) || new Operations();
1094
+ this.buildControls();
355
1095
  }
356
- this.configOperation = this.crudConfig.registro.operations.find(x => x.type.startsWith(this.trx)) || new Operations();
1096
+ else
1097
+ this.getInfoRegistro(this.crudConfig.registro);
357
1098
  })
358
1099
  .catch(err => {
359
1100
  console.log(err);
360
1101
  this.enProceso = false;
361
1102
  });
362
1103
  }
1104
+ buildControls() {
1105
+ this.controlsLoaded = false;
1106
+ this.controls = [];
1107
+ this.values = [];
1108
+ this.crudConfig.uiEsquema.elements.forEach((layout, i) => {
1109
+ var _a;
1110
+ this.controls.push([]);
1111
+ this.values.push([]);
1112
+ (_a = layout.elements) === null || _a === void 0 ? void 0 : _a.forEach((element) => {
1113
+ if (!element.scope)
1114
+ console.log("CONFIGURAR BIEN " + element);
1115
+ this.controls[i].push(this.getControl(element.scope));
1116
+ this.values[i].push(this.getValue(element.scope));
1117
+ });
1118
+ });
1119
+ this.controlsLoaded = true;
1120
+ }
363
1121
  setLabelSumbit() {
364
1122
  if (this.trx == 'c')
365
1123
  this.btnSubmit = { label: 'Guardar', icon: 'pi pi-save' };
@@ -374,11 +1132,26 @@ class RegistroComponent {
374
1132
  let op = configRegistro.operations.find(x => x.type == 'read');
375
1133
  let endpoint = (op === null || op === void 0 ? void 0 : op.endpoint) || '';
376
1134
  endpoint = endpoint.replace('@idKatios', this.idKatios);
1135
+ endpoint = endpoint.replace('@ndocactivo', this.user.UsuarioSistema.NDOC);
377
1136
  endpoint = endpoint.replace('@id', this.id);
378
1137
  this.generalService.genericRequest((op === null || op === void 0 ? void 0 : op.method) || '', (op === null || op === void 0 ? void 0 : op.server) || '', endpoint)
379
1138
  .then((res) => {
380
- this.data = res.data;
1139
+ if (res === null || res === void 0 ? void 0 : res.data) {
1140
+ if (Array.isArray(res.data))
1141
+ this.data = res.data[0];
1142
+ else
1143
+ this.data = res.data;
1144
+ this.trx = 'u';
1145
+ }
1146
+ else {
1147
+ this.trx = 'c';
1148
+ this.data = this.createObject(this.crudConfig.esquema);
1149
+ console.log(this.data);
1150
+ }
1151
+ this.buildControls();
381
1152
  this.enProceso = false;
1153
+ this.configOperation = this.crudConfig.registro.operations.find(x => x.type.startsWith(this.trx)) || new Operations();
1154
+ this.setLabelSumbit();
382
1155
  })
383
1156
  .catch(err => {
384
1157
  console.log(err);
@@ -394,11 +1167,25 @@ class RegistroComponent {
394
1167
  getValue(scope) {
395
1168
  return jsonpath.query(this.data, scope.replace('.properties', ''))[0];
396
1169
  }
397
- setValue(value, scope) {
398
- jsonpath.value(this.data, scope.replace('.properties', ''), value);
1170
+ setValue(value, scope, i, j) {
1171
+ switch (typeof (value)) {
1172
+ case 'object':
1173
+ if (Array.isArray(value))
1174
+ value.forEach((val) => jsonpath.value(this.data, val.scope.replace('.properties', ''), val.value));
1175
+ else {
1176
+ jsonpath.value(this.data, scope.replace('.properties', ''), value);
1177
+ this.values[i][j] = value;
1178
+ }
1179
+ break;
1180
+ default:
1181
+ this.values[i][j] = value;
1182
+ jsonpath.value(this.data, scope.replace('.properties', ''), value);
1183
+ break;
1184
+ }
1185
+ this.applyValuesOnEvent('onChange', this.crudConfig.esquema);
399
1186
  }
400
1187
  createObject(esquema) {
401
- let object = {};
1188
+ const object = {};
402
1189
  switch (esquema.type) {
403
1190
  case 'numeric':
404
1191
  return (esquema === null || esquema === void 0 ? void 0 : esquema.default) || 0;
@@ -409,48 +1196,106 @@ class RegistroComponent {
409
1196
  return (esquema === null || esquema === void 0 ? void 0 : esquema.default) || false;
410
1197
  case 'array':
411
1198
  return [];
1199
+ case 'file':
1200
+ return null;
412
1201
  case 'object':
413
- for (const key in esquema === null || esquema === void 0 ? void 0 : esquema.properties) {
414
- Object.defineProperty(object, key, { value: this.createObject(esquema === null || esquema === void 0 ? void 0 : esquema.properties[key]), writable: true, enumerable: true, configurable: true });
415
- }
416
- break;
1202
+ Object.getOwnPropertyNames(esquema === null || esquema === void 0 ? void 0 : esquema.properties).forEach(key => {
1203
+ let aux = esquema === null || esquema === void 0 ? void 0 : esquema.properties[key];
1204
+ if (aux)
1205
+ object[key] = this.createObject(aux);
1206
+ });
1207
+ return object;
417
1208
  default:
418
- break;
1209
+ return null;
419
1210
  }
420
- return object;
421
1211
  }
422
1212
  submit() {
1213
+ console.log(this.data);
423
1214
  if (!this.validateData())
424
1215
  return;
1216
+ this.applyValuesOnEvent('onSubmit', this.crudConfig.esquema);
425
1217
  this.enProceso = true;
426
1218
  let endpoint = this.configOperation.endpoint;
427
1219
  endpoint = endpoint.replace('@idKatios', this.idKatios);
428
1220
  endpoint = endpoint.replace('@id', this.id);
429
1221
  this.generalService.genericRequest(this.configOperation.method, this.configOperation.server, endpoint, this.data)
430
- .then(() => {
431
- this.messageSerice.add({ severity: 'success', detail: `Proceso exitoso!` });
1222
+ .then((res) => {
1223
+ this.generateMessage({ severity: 'success', detail: `Proceso exitoso!` }, res, this.configOperation.answerChecking);
1224
+ this.enProceso = false;
432
1225
  setTimeout(() => {
433
- this.enProceso = false;
434
- this.back();
1226
+ var _a, _b;
1227
+ if ((_a = this.configOperation) === null || _a === void 0 ? void 0 : _a.redirect)
1228
+ this.router.navigate([(_b = this.configOperation) === null || _b === void 0 ? void 0 : _b.redirect]);
1229
+ else
1230
+ this.onSubmit.emit(this.data);
435
1231
  }, 2000);
436
1232
  })
437
1233
  .catch(err => {
438
- var _a;
439
- this.messageSerice.add({ severity: 'warn', detail: `${((_a = err === null || err === void 0 ? void 0 : err.error) === null || _a === void 0 ? void 0 : _a.message) || 'Error no controlado, por favor comunicarse con del admin.'}` });
1234
+ const operation = this.crudConfig.registro.operations.find(op => op.type.startsWith(this.trx));
1235
+ this.generateMessage({ severity: "error", detail: "Por favor comunicarse con el admin", summary: "Error no controlado" }, err.error, operation.errorChecking);
440
1236
  this.enProceso = false;
441
1237
  });
442
1238
  }
1239
+ /**
1240
+ * Generates message using answerchecking
1241
+ * @param currentMsg Default message: Message
1242
+ * @param rta Resquest's response
1243
+ * @param answerChecking
1244
+ */
1245
+ generateMessage(currentMsg, rta, requestChecking) {
1246
+ if (requestChecking) {
1247
+ if (requestChecking.statics)
1248
+ Object.assign(currentMsg, requestChecking.statics);
1249
+ //mapear los dinamicos
1250
+ if (requestChecking.dynamics) {
1251
+ const dynamics = requestChecking.dynamics;
1252
+ try {
1253
+ if (dynamics && typeof (rta) == "string")
1254
+ rta = JSON.parse(rta);
1255
+ if (dynamics) {
1256
+ for (const property in dynamics) {
1257
+ currentMsg[property] = jsonpath.query(rta, dynamics[property])[0];
1258
+ }
1259
+ }
1260
+ }
1261
+ catch (error) { //es una respuesta sin JSON
1262
+ if (dynamics)
1263
+ currentMsg.detail = rta;
1264
+ }
1265
+ }
1266
+ }
1267
+ if ((requestChecking === null || requestChecking === void 0 ? void 0 : requestChecking.redirect) || (requestChecking === null || requestChecking === void 0 ? void 0 : requestChecking.swal))
1268
+ Swal.fire(currentMsg.summary, currentMsg.detail, currentMsg.severity).then((res) => {
1269
+ if (res.isConfirmed && requestChecking.redirect)
1270
+ window.location.href = requestChecking.redirect;
1271
+ });
1272
+ else
1273
+ this.messageSerice.add(currentMsg);
1274
+ }
443
1275
  validateData() {
444
1276
  if (this.configOperation.validations.type == 'local')
445
1277
  return this.validateDataLocal();
446
1278
  return true;
447
1279
  }
448
1280
  validateDataLocal() {
1281
+ var _a, _b, _c, _d;
449
1282
  let err = [];
450
- this.configOperation.validations.required.forEach(x => {
1283
+ (_b = (_a = this.configOperation.validations) === null || _a === void 0 ? void 0 : _a.required) === null || _b === void 0 ? void 0 : _b.forEach(x => {
451
1284
  if (!jsonpath.query(this.data, x.field)[0])
452
1285
  err.push(x.message);
453
1286
  });
1287
+ (_d = (_c = this.configOperation.validations) === null || _c === void 0 ? void 0 : _c.operations) === null || _d === void 0 ? void 0 : _d.forEach((op) => {
1288
+ switch (op.action) {
1289
+ case 'sumArray':
1290
+ let var1 = jsonpath.query(this.data, op.scope[0]).reduce((acc, cur) => acc += cur[op.key], 0);
1291
+ let var2 = jsonpath.query(this.data, op.scope[1]).reduce((acc, cur) => acc += cur[op.key], 0);
1292
+ if (var1 != var2)
1293
+ err.push(op.message);
1294
+ break;
1295
+ default:
1296
+ break;
1297
+ }
1298
+ });
454
1299
  if (err.length != 0)
455
1300
  this.messageSerice.add({ severity: 'warn', detail: err.join('. ') });
456
1301
  return err.length == 0;
@@ -459,11 +1304,13 @@ class RegistroComponent {
459
1304
  let data = null;
460
1305
  switch (value) {
461
1306
  case '@uactivo':
462
- let uactivo = JSON.parse(localStorage.getItem('oSessionTFM') || '{}');
463
- if (!uactivo)
464
- console.log('Validar configuracion de sesion');
465
- else
466
- data = `${uactivo.UsuarioSistema.TDOC}-${uactivo.UsuarioSistema.NDOC}`;
1307
+ data = `${this.user.UsuarioSistema.TDOC}-${this.user.UsuarioSistema.NDOC}`;
1308
+ break;
1309
+ case '@tdocactivo':
1310
+ data = this.user.UsuarioSistema.TDOC;
1311
+ break;
1312
+ case '@ndocactivo':
1313
+ data = this.user.UsuarioSistema.NDOC;
467
1314
  break;
468
1315
  case '@hoy':
469
1316
  data = new Date();
@@ -474,17 +1321,154 @@ class RegistroComponent {
474
1321
  }
475
1322
  return data;
476
1323
  }
1324
+ sendNotification(message) {
1325
+ this.messageSerice.add(message);
1326
+ }
1327
+ addObjectArray(element) {
1328
+ this.dialogRef = this.dialogService.open(RegistroChildComponent, {
1329
+ header: element.label ? element.label : 'Detalle',
1330
+ width: '70%',
1331
+ modal: true,
1332
+ closable: false,
1333
+ data: {
1334
+ uiEsquema: Object.assign({}, element.elements),
1335
+ esquema: this.getControl(element.scope),
1336
+ id: this.getValue(element.scope).length + 1
1337
+ }
1338
+ });
1339
+ this.dialogRef.onClose.subscribe((data) => {
1340
+ if (data)
1341
+ this.data[element.scope.replace('$..properties.', '')].push(data);
1342
+ this.applyValuesOnEvent('onChange', this.crudConfig.esquema, element.scope.replace('$..properties.', ''));
1343
+ });
1344
+ }
1345
+ editRow(element, data, index) {
1346
+ this.dialogRef = this.dialogService.open(RegistroChildComponent, {
1347
+ header: element.label ? element.label : 'Detalle',
1348
+ width: '70%',
1349
+ modal: true,
1350
+ closable: false,
1351
+ data: {
1352
+ uiEsquema: Object.assign({}, element.elements),
1353
+ esquema: this.getControl(element.scope),
1354
+ data: Object.assign({}, data)
1355
+ }
1356
+ });
1357
+ this.dialogRef.onClose.subscribe((data) => {
1358
+ if (data)
1359
+ this.data[element.scope.replace('$..properties.', '')][index] = data;
1360
+ this.applyValuesOnEvent('onChange', this.crudConfig.esquema, element.scope.replace('$..properties.', ''));
1361
+ });
1362
+ }
1363
+ deleteRow(element, index) {
1364
+ this.data[element.scope.replace('$..properties.', '')].splice(index, 1);
1365
+ index = 1;
1366
+ this.data[element.scope.replace('$..properties.', '')].forEach((el) => {
1367
+ el.id = index;
1368
+ index++;
1369
+ });
1370
+ this.applyValuesOnEvent('onChange', this.crudConfig.esquema, element.scope.replace('$..properties.', ''));
1371
+ }
1372
+ applyValuesOnEvent(event, esquema, key) {
1373
+ if (key) {
1374
+ if (esquema.properties[key][event]) {
1375
+ esquema.properties[key][event].forEach((value) => {
1376
+ this.setValueEvent(this.data, value);
1377
+ });
1378
+ }
1379
+ }
1380
+ else {
1381
+ for (const key in esquema.properties) {
1382
+ if (esquema.properties[key][event]) {
1383
+ esquema.properties[key][event].forEach((value) => {
1384
+ this.setValueEvent(this.data, value);
1385
+ });
1386
+ }
1387
+ }
1388
+ }
1389
+ }
1390
+ setValueEvent(data, params) {
1391
+ var _a;
1392
+ let date = moment(new Date());
1393
+ switch (params.op) {
1394
+ case 'sum':
1395
+ jsonpath.value(data, params.scope[1], jsonpath.query(data, params.scope[0]).reduce((acc, cur) => acc += (params === null || params === void 0 ? void 0 : params.key) ? cur[params.key] : cur, 0));
1396
+ break;
1397
+ case 'concat':
1398
+ let array = [];
1399
+ (_a = params === null || params === void 0 ? void 0 : params.key) === null || _a === void 0 ? void 0 : _a.reduce((acc, cur) => {
1400
+ array.push(jsonpath.query(data, cur)[0]);
1401
+ }, []);
1402
+ if (params === null || params === void 0 ? void 0 : params.separator)
1403
+ jsonpath.value(data, params.scope[0], array.join((params === null || params === void 0 ? void 0 : params.separator) || ' '));
1404
+ break;
1405
+ case 'enable':
1406
+ jsonpath.value(this.crudConfig.esquema, params.scope[0], false);
1407
+ break;
1408
+ case 'disabled':
1409
+ jsonpath.value(this.crudConfig.esquema, params.scope[0], true);
1410
+ break;
1411
+ case 'replace:endpoint':
1412
+ jsonpath.value(this.crudConfig.esquema, params.scope[0], this.crudConfig.esquema.config.endpointtemp.replace(params.scope[1], jsonpath.query(data, `$..${params.key}`)));
1413
+ break;
1414
+ case 'setNull':
1415
+ jsonpath.value(this.data, `$.${params.key}`, null);
1416
+ break;
1417
+ case 'datediff:years':
1418
+ jsonpath.value(this.data, params.scope[0], date.diff(moment(jsonpath.query(this.data, params.scope[1])[0]), 'years'));
1419
+ break;
1420
+ case 'datediff:months':
1421
+ jsonpath.value(this.data, params.scope[0], date.diff(moment(jsonpath.query(this.data, params.scope[1])[0]), 'months'));
1422
+ break;
1423
+ case 'datediff:weeks':
1424
+ jsonpath.value(this.data, params.scope[0], date.diff(moment(jsonpath.query(this.data, params.scope[1])[0]), 'weeks'));
1425
+ break;
1426
+ case 'datediff:days':
1427
+ jsonpath.value(this.data, params.scope[0], date.diff(moment(jsonpath.query(this.data, params.scope[1])[0]), 'days'));
1428
+ break;
1429
+ default:
1430
+ break;
1431
+ }
1432
+ }
1433
+ setDataTemp(esquema, dataTemp) {
1434
+ dataTemp.forEach(data => {
1435
+ jsonpath.value(esquema, data.scope, data.value);
1436
+ });
1437
+ }
1438
+ applyValuesFromObject(event) {
1439
+ if (event.data)
1440
+ event.optionValue.forEach((value) => jsonpath.value(this.data, value.scope.replace('.properties', ''), this.aplyFormatValue(value.scope, event.data[value.key])));
1441
+ else
1442
+ event.optionValue.forEach((value) => jsonpath.value(this.data, value.scope.replace('.properties', ''), null));
1443
+ }
1444
+ aplyFormatValue(scope, value) {
1445
+ let control = jsonpath.query(this.crudConfig.esquema, scope)[0];
1446
+ let resp;
1447
+ switch (control.type) {
1448
+ case 'date':
1449
+ resp = new Date(`${value}`);
1450
+ break;
1451
+ case 'numeric':
1452
+ resp = +value;
1453
+ break;
1454
+ default:
1455
+ resp = value;
1456
+ break;
1457
+ }
1458
+ return resp;
1459
+ }
477
1460
  }
478
- RegistroComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: RegistroComponent, deps: [{ token: GeneralService }, { token: i2.Router }, { token: i3$1.MessageService }], target: i0.ɵɵFactoryTarget.Component });
479
- RegistroComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.17", type: RegistroComponent, selector: "sf-registro", inputs: { idKatios: "idKatios", idEntidad: "idEntidad", trx: "trx", id: "id" }, providers: [MessageService], ngImport: i0, template: "<p-blockUI [blocked]=\"enProceso\">\r\n <i class=\"pi pi-cog pi-spin\" style=\"font-size: 50px\"></i>\r\n</p-blockUI>\r\n\r\n<p-toast></p-toast>\r\n\r\n<div class=\"card\" *ngIf=\"!enProceso\">\r\n <h5 class=\"card-header mb-2\" style=\"display: flex; justify-content: space-between;align-items: center;\">\r\n <span>{{idEntidad}} {{id != '' ? '-' + id : ''}}</span>\r\n <button pButton pRipple type=\"button\" icon=\"pi pi-arrow-left\" (click)=\"back()\"></button>\r\n </h5>\r\n <div *ngFor=\"let element of crudConfig.uiEsquema.elements\" [class]=\"element?.class\">\r\n <ng-container [ngSwitch]=\"element.type\">\r\n <div *ngSwitchCase=\"'Label'\" [style]=\"element?.style\">\r\n {{element?.label}}\r\n </div>\r\n <ng-container *ngSwitchCase=\"'HorizontalLayout'\">\r\n <div *ngFor=\"let el of element.elements\" [class]=\"el?.class\">\r\n <ng-container [ngSwitch]=\"el.type\" >\r\n <sf-control *ngSwitchCase=\"'Control'\" [control]=\"getControl(el.scope)\" [label]=\"el.label\" [value]=\"getValue(el.scope)\" (setValue)=\"setValue($event, el.scope)\"></sf-control>\r\n </ng-container>\r\n </div>\r\n </ng-container>\r\n <div *ngSwitchCase=\"'Control'\">\r\n <sf-control *ngSwitchCase=\"'Control'\" [control]=\"getControl(element.scope)\" [label]=\"element.label\"></sf-control>\r\n </div>\r\n </ng-container>\r\n </div>\r\n <div class=\"card-footer\" *ngIf=\"btnSubmit\">\r\n <button pButton pRipple type=\"button\" [icon]=\"btnSubmit.icon\" [label]=\"btnSubmit.label\" (click)=\"submit()\"></button>\r\n </div>\r\n</div>", components: [{ type: i3.BlockUI, selector: "p-blockUI", inputs: ["autoZIndex", "baseZIndex", "blocked", "target", "styleClass"] }, { type: i5$2.Toast, selector: "p-toast", inputs: ["autoZIndex", "baseZIndex", "position", "preventOpenDuplicates", "preventDuplicates", "showTransformOptions", "hideTransformOptions", "showTransitionOptions", "hideTransitionOptions", "key", "style", "styleClass", "breakpoints"], outputs: ["onClose"] }, { type: ControlComponent, selector: "sf-control", inputs: ["control", "label", "value"], outputs: ["setValue"] }], directives: [{ type: i6.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i8.ButtonDirective, selector: "[pButton]", inputs: ["iconPos", "loadingIcon", "label", "icon", "loading"] }, { type: i9.Ripple, selector: "[pRipple]" }, { type: i6.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i6.NgSwitch, selector: "[ngSwitch]", inputs: ["ngSwitch"] }, { type: i6.NgSwitchCase, selector: "[ngSwitchCase]", inputs: ["ngSwitchCase"] }] });
1461
+ RegistroComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: RegistroComponent, deps: [{ token: GeneralService }, { token: i2.Router }, { token: i2$1.MessageService }, { token: i1$1.DialogService }, { token: SfCrudService }], target: i0.ɵɵFactoryTarget.Component });
1462
+ RegistroComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.17", type: RegistroComponent, selector: "sf-registro", inputs: { idKatios: "idKatios", idEntidad: "idEntidad", trx: "trx", id: "id", user: "user" }, outputs: { sendData: "sendData", onSubmit: "onSubmit" }, providers: [MessageService, DialogService, DynamicDialogConfig, DynamicDialogRef], ngImport: i0, template: "<p-blockUI [blocked]=\"enProceso\">\r\n <i class=\"pi pi-cog pi-spin\" style=\"font-size: 50px\"></i>\r\n</p-blockUI>\r\n\r\n<p-toast></p-toast>\r\n\r\n<div class=\"card\" *ngIf=\"!enProceso && controlsLoaded\">\r\n <h5 class=\"card-header mb-2\" style=\"display: flex; justify-content: space-between;align-items: center;\">\r\n <span>{{crudConfig.registro?.label || idEntidad}} {{id != '' ? '-' + id : ''}}</span>\r\n <button *ngIf=\"crudConfig.registro?.canBack\" pButton pRipple type=\"button\" icon=\"pi pi-arrow-left\" (click)=\"back()\"></button>\r\n </h5>\r\n <div *ngFor=\"let element of crudConfig.uiEsquema.elements; let i = index\" [class]=\"element?.class\">\r\n <ng-container [ngSwitch]=\"element.type\">\r\n <div *ngSwitchCase=\"'Label'\" [style]=\"element?.style\">\r\n {{element?.label}}\r\n </div>\r\n <ng-container *ngSwitchCase=\"'HorizontalLayout'\">\r\n <div *ngFor=\"let el of element.elements;let j = index\" [class]=\"el?.class\">\r\n <ng-container [ngSwitch]=\"el.type\">\r\n <sf-control *ngSwitchCase=\"'Control'\" [control]=\"controls[i][j]\" [label]=\"el.label\"\r\n [value]=\"values[i][j]\" (setValue)=\"setValue($event, el.scope, i, j)\"\r\n (sendNotification)=\"sendNotification($event)\" (sendObject)=\"applyValuesFromObject($event)\"></sf-control>\r\n </ng-container>\r\n </div>\r\n </ng-container>\r\n <ng-container *ngSwitchCase=\"'VerticalLayout'\">\r\n <div *ngFor=\"let el of element.elements;let j = index\" [class]=\"el?.class\">\r\n <ng-container [ngSwitch]=\"el.type\">\r\n <sf-control *ngSwitchCase=\"'Control'\" [control]=\"controls[i][j]\" [label]=\"el.label\"\r\n [value]=\"values[i][j]\" (setValue)=\"setValue($event, el.scope, i, j)\"\r\n (sendNotification)=\"sendNotification($event)\" (sendObject)=\"applyValuesFromObject($event)\"></sf-control>\r\n <ng-container *ngSwitchCase=\"'Table'\">\r\n <p-table [value]=\"getValue(el.scope)\" [columns]=\"getControl(el.scope).config.columns\">\r\n <ng-template pTemplate=\"caption\">\r\n <div class=\"flex align-items-center justify-content-between\">\r\n <button pButton pRipple icon=\"pi pi-plus\" (click)=\"addObjectArray(el)\"\r\n class=\"p-button-success\"></button>\r\n </div>\r\n </ng-template>\r\n <ng-template pTemplate=\"header\" let-columns>\r\n <tr>\r\n <th *ngFor=\"let col of columns\">\r\n {{col.label}}\r\n </th>\r\n <ng-container *ngIf=\"trx == 'c' || trx == 'u'\">\r\n <th></th>\r\n </ng-container>\r\n </tr>\r\n </ng-template>\r\n <ng-template pTemplate=\"body\" let-rowData let-columns=\"columns\" let-rowIndex=\"rowIndex\">\r\n <tr>\r\n <ng-container *ngFor=\"let col of columns\" [ngSwitch]=\"col.type\">\r\n <ng-container *ngSwitchCase=\"'text'\">\r\n <td>{{rowData[col.col]}}</td>\r\n </ng-container>\r\n <ng-container *ngSwitchCase=\"'currency:USD'\">\r\n <td>{{rowData[col.col] | currency: 'USD'}}</td>\r\n </ng-container>\r\n <ng-container *ngSwitchCase=\"'date:yyyy-mm-dd'\">\r\n <td>{{rowData[col.col] | date: 'yyyy-mm-dd'}}</td>\r\n </ng-container>\r\n <ng-container *ngSwitchCase=\"'date:dd/mm/yyyy'\">\r\n <td>{{rowData[col.col] | date: 'dd/MM/yyyy'}}</td>\r\n </ng-container>\r\n <ng-container *ngSwitchCase=\"'boolean'\">\r\n <td>\r\n <i *ngIf=\"rowData[col.col]\" class=\"pi pi-check\"></i>\r\n <i *ngIf=\"!rowData[col.col]\" class=\"pi pi-times\"></i>\r\n </td>\r\n </ng-container>\r\n </ng-container>\r\n <ng-container *ngIf=\"trx == 'c' || trx == 'u'\">\r\n <td>\r\n <button pButton pRipple type=\"button\" (click)=\"editRow(el, rowData, rowIndex)\" icon=\"pi pi-pencil\" class=\"p-button-rounded p-button-info mr-1\"></button>\r\n <button pButton pRipple type=\"button\" (click)=\"deleteRow(el, rowIndex)\" icon=\"pi pi-trash\" class=\"p-button-rounded p-button-danger\"></button>\r\n </td>\r\n </ng-container>\r\n </tr>\r\n </ng-template>\r\n </p-table>\r\n </ng-container>\r\n </ng-container>\r\n </div>\r\n </ng-container>\r\n <ng-container *ngSwitchCase=\"'Control'\">\r\n <sf-control [control]=\"getControl(element.scope)\" [label]=\"element.label\"></sf-control>\r\n </ng-container>\r\n </ng-container>\r\n </div>\r\n <div class=\"card-footer mt-2\" *ngIf=\"btnSubmit\">\r\n <button pButton pRipple type=\"button\" [icon]=\"btnSubmit.icon\" [label]=\"btnSubmit.label\"\r\n (click)=\"submit()\"></button>\r\n </div>\r\n</div>\r\n", components: [{ type: i3.BlockUI, selector: "p-blockUI", inputs: ["target", "autoZIndex", "baseZIndex", "styleClass", "blocked"] }, { type: i3$2.Toast, selector: "p-toast", inputs: ["key", "autoZIndex", "baseZIndex", "style", "styleClass", "position", "preventOpenDuplicates", "preventDuplicates", "showTransformOptions", "hideTransformOptions", "showTransitionOptions", "hideTransitionOptions", "breakpoints"], outputs: ["onClose"] }, { type: ControlComponent, selector: "sf-control", inputs: ["control", "label", "value", "appendTo"], outputs: ["setValue", "sendNotification", "sendObject"] }, { type: i5.Table, selector: "p-table", inputs: ["frozenColumns", "frozenValue", "style", "styleClass", "tableStyle", "tableStyleClass", "paginator", "pageLinks", "rowsPerPageOptions", "alwaysShowPaginator", "paginatorPosition", "paginatorDropdownAppendTo", "paginatorDropdownScrollHeight", "currentPageReportTemplate", "showCurrentPageReport", "showJumpToPageDropdown", "showFirstLastIcon", "showPageLinks", "defaultSortOrder", "sortMode", "resetPageOnSort", "selectionMode", "contextMenuSelection", "contextMenuSelectionMode", "dataKey", "metaKeySelection", "rowTrackBy", "lazy", "lazyLoadOnInit", "compareSelectionBy", "csvSeparator", "exportFilename", "filters", "globalFilterFields", "filterDelay", "filterLocale", "expandedRowKeys", "editingRowKeys", "rowExpandMode", "scrollable", "scrollDirection", "rowGroupMode", "scrollHeight", "virtualScroll", "virtualScrollDelay", "virtualRowHeight", "frozenWidth", "responsive", "contextMenu", "resizableColumns", "columnResizeMode", "reorderableColumns", "loading", "loadingIcon", "showLoader", "rowHover", "customSort", "showInitialSortBadge", "autoLayout", "exportFunction", "stateKey", "stateStorage", "editMode", "groupRowsBy", "minBufferPx", "maxBufferPx", "responsiveLayout", "breakpoint", "value", "columns", "first", "rows", "totalRecords", "sortField", "sortOrder", "multiSortMeta", "selection"], outputs: ["selectionChange", "contextMenuSelectionChange", "onRowSelect", "onRowUnselect", "onPage", "onSort", "onFilter", "onLazyLoad", "onRowExpand", "onRowCollapse", "onContextMenuSelect", "onColResize", "onColReorder", "onRowReorder", "onEditInit", "onEditComplete", "onEditCancel", "onHeaderCheckboxToggle", "sortFunction", "firstChange", "rowsChange", "onStateSave", "onStateRestore"] }], directives: [{ type: i7.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i9.ButtonDirective, selector: "[pButton]", inputs: ["iconPos", "loadingIcon", "label", "icon", "loading"] }, { type: i10.Ripple, selector: "[pRipple]" }, { type: i7.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i7.NgSwitch, selector: "[ngSwitch]", inputs: ["ngSwitch"] }, { type: i7.NgSwitchCase, selector: "[ngSwitchCase]", inputs: ["ngSwitchCase"] }, { type: i2$1.PrimeTemplate, selector: "[pTemplate]", inputs: ["type", "pTemplate"] }], pipes: { "currency": i7.CurrencyPipe, "date": i7.DatePipe } });
480
1463
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: RegistroComponent, decorators: [{
481
1464
  type: Component,
482
1465
  args: [{
483
1466
  selector: 'sf-registro',
484
1467
  templateUrl: './registro.component.html',
485
- providers: [MessageService]
1468
+ providers: [MessageService, DialogService, DynamicDialogConfig, DynamicDialogRef],
1469
+ entryComponents: [RegistroComponent]
486
1470
  }]
487
- }], ctorParameters: function () { return [{ type: GeneralService }, { type: i2.Router }, { type: i3$1.MessageService }]; }, propDecorators: { idKatios: [{
1471
+ }], ctorParameters: function () { return [{ type: GeneralService }, { type: i2.Router }, { type: i2$1.MessageService }, { type: i1$1.DialogService }, { type: SfCrudService }]; }, propDecorators: { idKatios: [{
488
1472
  type: Input
489
1473
  }], idEntidad: [{
490
1474
  type: Input
@@ -492,6 +1476,12 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImpo
492
1476
  type: Input
493
1477
  }], id: [{
494
1478
  type: Input
1479
+ }], user: [{
1480
+ type: Input
1481
+ }], sendData: [{
1482
+ type: Output
1483
+ }], onSubmit: [{
1484
+ type: Output
495
1485
  }] } });
496
1486
 
497
1487
  class SfCrudComponent {
@@ -524,7 +1514,9 @@ SfCrudModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "1
524
1514
  SfCrudModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: SfCrudModule, declarations: [SfCrudComponent,
525
1515
  TableroComponent,
526
1516
  RegistroComponent,
527
- ControlComponent], imports: [AccordionModule,
1517
+ ControlComponent,
1518
+ RegistroChildComponent,
1519
+ RegistroDetalleComponent], imports: [AccordionModule,
528
1520
  AutoCompleteModule,
529
1521
  AvatarGroupModule,
530
1522
  AvatarModule,
@@ -539,7 +1531,6 @@ SfCrudModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "
539
1531
  CheckboxModule,
540
1532
  ChipModule,
541
1533
  ChipsModule,
542
- CodeHighlighterModule,
543
1534
  ColorPickerModule,
544
1535
  ConfirmDialogModule,
545
1536
  ConfirmPopupModule,
@@ -547,6 +1538,7 @@ SfCrudModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "
547
1538
  DialogModule,
548
1539
  DividerModule,
549
1540
  DropdownModule,
1541
+ DynamicDialogModule,
550
1542
  FieldsetModule,
551
1543
  FileUploadModule,
552
1544
  FormsModule,
@@ -559,7 +1551,6 @@ SfCrudModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "
559
1551
  InputTextareaModule,
560
1552
  InputTextModule,
561
1553
  KnobModule,
562
- LightboxModule,
563
1554
  ListboxModule,
564
1555
  MegaMenuModule,
565
1556
  MenubarModule,
@@ -583,6 +1574,7 @@ SfCrudModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "
583
1574
  SkeletonModule,
584
1575
  SlideMenuModule,
585
1576
  SliderModule,
1577
+ SplitButtonModule,
586
1578
  SplitterModule,
587
1579
  StepsModule,
588
1580
  TableModule,
@@ -598,7 +1590,8 @@ SfCrudModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "
598
1590
  TooltipModule,
599
1591
  TreeModule], exports: [SfCrudComponent,
600
1592
  TableroComponent,
601
- RegistroComponent] });
1593
+ RegistroComponent,
1594
+ ControlComponent] });
602
1595
  SfCrudModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: SfCrudModule, imports: [[
603
1596
  AccordionModule,
604
1597
  AutoCompleteModule,
@@ -615,7 +1608,6 @@ SfCrudModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "
615
1608
  CheckboxModule,
616
1609
  ChipModule,
617
1610
  ChipsModule,
618
- CodeHighlighterModule,
619
1611
  ColorPickerModule,
620
1612
  ConfirmDialogModule,
621
1613
  ConfirmPopupModule,
@@ -623,6 +1615,7 @@ SfCrudModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "
623
1615
  DialogModule,
624
1616
  DividerModule,
625
1617
  DropdownModule,
1618
+ DynamicDialogModule,
626
1619
  FieldsetModule,
627
1620
  FileUploadModule,
628
1621
  FormsModule,
@@ -635,7 +1628,6 @@ SfCrudModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "
635
1628
  InputTextareaModule,
636
1629
  InputTextModule,
637
1630
  KnobModule,
638
- LightboxModule,
639
1631
  ListboxModule,
640
1632
  MegaMenuModule,
641
1633
  MenubarModule,
@@ -659,6 +1651,7 @@ SfCrudModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "
659
1651
  SkeletonModule,
660
1652
  SlideMenuModule,
661
1653
  SliderModule,
1654
+ SplitButtonModule,
662
1655
  SplitterModule,
663
1656
  StepsModule,
664
1657
  TableModule,
@@ -681,7 +1674,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImpo
681
1674
  SfCrudComponent,
682
1675
  TableroComponent,
683
1676
  RegistroComponent,
684
- ControlComponent
1677
+ ControlComponent,
1678
+ RegistroChildComponent,
1679
+ RegistroDetalleComponent
685
1680
  ],
686
1681
  imports: [
687
1682
  AccordionModule,
@@ -699,7 +1694,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImpo
699
1694
  CheckboxModule,
700
1695
  ChipModule,
701
1696
  ChipsModule,
702
- CodeHighlighterModule,
703
1697
  ColorPickerModule,
704
1698
  ConfirmDialogModule,
705
1699
  ConfirmPopupModule,
@@ -707,6 +1701,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImpo
707
1701
  DialogModule,
708
1702
  DividerModule,
709
1703
  DropdownModule,
1704
+ DynamicDialogModule,
710
1705
  FieldsetModule,
711
1706
  FileUploadModule,
712
1707
  FormsModule,
@@ -719,7 +1714,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImpo
719
1714
  InputTextareaModule,
720
1715
  InputTextModule,
721
1716
  KnobModule,
722
- LightboxModule,
723
1717
  ListboxModule,
724
1718
  MegaMenuModule,
725
1719
  MenubarModule,
@@ -743,6 +1737,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImpo
743
1737
  SkeletonModule,
744
1738
  SlideMenuModule,
745
1739
  SliderModule,
1740
+ SplitButtonModule,
746
1741
  SplitterModule,
747
1742
  StepsModule,
748
1743
  TableModule,
@@ -761,23 +1756,15 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImpo
761
1756
  exports: [
762
1757
  SfCrudComponent,
763
1758
  TableroComponent,
764
- RegistroComponent
1759
+ RegistroComponent,
1760
+ ControlComponent
1761
+ ],
1762
+ entryComponents: [
1763
+ RegistroChildComponent
765
1764
  ]
766
1765
  }]
767
1766
  }] });
768
1767
 
769
- class SfCrudService {
770
- constructor() { }
771
- }
772
- SfCrudService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: SfCrudService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
773
- SfCrudService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: SfCrudService, providedIn: 'root' });
774
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: SfCrudService, decorators: [{
775
- type: Injectable,
776
- args: [{
777
- providedIn: 'root'
778
- }]
779
- }], ctorParameters: function () { return []; } });
780
-
781
1768
  /*
782
1769
  * Public API Surface of sf-crud
783
1770
  */
@@ -786,5 +1773,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImpo
786
1773
  * Generated bundle index. Do not edit.
787
1774
  */
788
1775
 
789
- export { RegistroComponent, SfCrudComponent, SfCrudModule, SfCrudService, TableroComponent };
1776
+ export { ControlComponent, RegistroComponent, SfCrudComponent, SfCrudModule, SfCrudService, TableroComponent };
790
1777
  //# sourceMappingURL=sf-crud.js.map