sf-crud 12.0.1-beta1

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.
@@ -0,0 +1,733 @@
1
+ import * as i0 from '@angular/core';
2
+ import { Injectable, Component, Input, EventEmitter, Output, NgModule } from '@angular/core';
3
+ import { __awaiter } from 'tslib';
4
+ import * as i1 from '@angular/common/http';
5
+ import { HttpClientModule } from '@angular/common/http';
6
+ import * as i2 from '@angular/router';
7
+ import * as i3 from 'primeng/blockui';
8
+ import { BlockUIModule } from 'primeng/blockui';
9
+ import * as i4 from 'primeng/toolbar';
10
+ import { ToolbarModule } from 'primeng/toolbar';
11
+ import * as i5 from 'primeng/table';
12
+ import { TableModule } from 'primeng/table';
13
+ import * as i7 from '@angular/common';
14
+ import * as i3$1 from 'primeng/api';
15
+ import { MessageService } from 'primeng/api';
16
+ import * as i8 from 'primeng/button';
17
+ import { ButtonModule } from 'primeng/button';
18
+ import * as i9 from 'primeng/ripple';
19
+ import { RippleModule } from 'primeng/ripple';
20
+ import * as i10 from 'primeng/inputtext';
21
+ 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$1 from 'primeng/toast';
26
+ import { ToastModule } from 'primeng/toast';
27
+ import * as i1$1 from 'primeng/dropdown';
28
+ import { DropdownModule } from 'primeng/dropdown';
29
+ import * as i3$2 from '@angular/forms';
30
+ import { FormsModule } from '@angular/forms';
31
+ import { AccordionModule } from 'primeng/accordion';
32
+ import { AvatarModule } from 'primeng/avatar';
33
+ import { AvatarGroupModule } from 'primeng/avatargroup';
34
+ import { BadgeModule } from 'primeng/badge';
35
+ import { BreadcrumbModule } from 'primeng/breadcrumb';
36
+ import { CalendarModule } from 'primeng/calendar';
37
+ import { CardModule } from 'primeng/card';
38
+ import { CarouselModule } from 'primeng/carousel';
39
+ import { CascadeSelectModule } from 'primeng/cascadeselect';
40
+ import { CheckboxModule } from 'primeng/checkbox';
41
+ import { ChipModule } from 'primeng/chip';
42
+ import { ChipsModule } from 'primeng/chips';
43
+ import { CodeHighlighterModule } from 'primeng/codehighlighter';
44
+ import { ConfirmDialogModule } from 'primeng/confirmdialog';
45
+ import { ConfirmPopupModule } from 'primeng/confirmpopup';
46
+ import { ColorPickerModule } from 'primeng/colorpicker';
47
+ import { ContextMenuModule } from 'primeng/contextmenu';
48
+ import { DialogModule } from 'primeng/dialog';
49
+ import { DividerModule } from 'primeng/divider';
50
+ import { FieldsetModule } from 'primeng/fieldset';
51
+ import { FileUploadModule } from 'primeng/fileupload';
52
+ import { GalleriaModule } from 'primeng/galleria';
53
+ import { InplaceModule } from 'primeng/inplace';
54
+ import { InputNumberModule } from 'primeng/inputnumber';
55
+ import { InputMaskModule } from 'primeng/inputmask';
56
+ import { InputSwitchModule } from 'primeng/inputswitch';
57
+ import { InputTextareaModule } from 'primeng/inputtextarea';
58
+ import { KnobModule } from 'primeng/knob';
59
+ import { LightboxModule } from 'primeng/lightbox';
60
+ import { ListboxModule } from 'primeng/listbox';
61
+ import { MegaMenuModule } from 'primeng/megamenu';
62
+ import { MenuModule } from 'primeng/menu';
63
+ import { MenubarModule } from 'primeng/menubar';
64
+ import { MessagesModule } from 'primeng/messages';
65
+ import { MessageModule } from 'primeng/message';
66
+ import { MultiSelectModule } from 'primeng/multiselect';
67
+ import { OrganizationChartModule } from 'primeng/organizationchart';
68
+ import { OverlayPanelModule } from 'primeng/overlaypanel';
69
+ import { PanelModule } from 'primeng/panel';
70
+ import { PanelMenuModule } from 'primeng/panelmenu';
71
+ import { PasswordModule } from 'primeng/password';
72
+ import { ProgressBarModule } from 'primeng/progressbar';
73
+ import { RadioButtonModule } from 'primeng/radiobutton';
74
+ import { RatingModule } from 'primeng/rating';
75
+ import { ScrollPanelModule } from 'primeng/scrollpanel';
76
+ import { ScrollTopModule } from 'primeng/scrolltop';
77
+ import { SelectButtonModule } from 'primeng/selectbutton';
78
+ import { SidebarModule } from 'primeng/sidebar';
79
+ import { SkeletonModule } from 'primeng/skeleton';
80
+ import { SlideMenuModule } from 'primeng/slidemenu';
81
+ import { SliderModule } from 'primeng/slider';
82
+ import { SplitterModule } from 'primeng/splitter';
83
+ import { StepsModule } from 'primeng/steps';
84
+ import { TabMenuModule } from 'primeng/tabmenu';
85
+ import { TabViewModule } from 'primeng/tabview';
86
+ import { TagModule } from 'primeng/tag';
87
+ import { TerminalModule } from 'primeng/terminal';
88
+ import { TieredMenuModule } from 'primeng/tieredmenu';
89
+ import { TimelineModule } from 'primeng/timeline';
90
+ import { ToggleButtonModule } from 'primeng/togglebutton';
91
+ import { TreeModule } from 'primeng/tree';
92
+
93
+ class Shema {
94
+ constructor() {
95
+ this.type = '';
96
+ }
97
+ }
98
+
99
+ class CrudConfig {
100
+ constructor() {
101
+ this.idEntidad = '';
102
+ this.tablero = new ConfigTablero();
103
+ this.esquema = new Shema();
104
+ this.registro = new ConfigRegistro();
105
+ }
106
+ }
107
+ class ConfigTablero {
108
+ constructor() {
109
+ this.columns = [];
110
+ this.endpoint = '';
111
+ this.method = '';
112
+ this.server = '';
113
+ this.key = '';
114
+ this.filters = [];
115
+ }
116
+ }
117
+ class ConfigRegistro {
118
+ constructor() {
119
+ this.operations = [];
120
+ this.btnBack = '';
121
+ }
122
+ }
123
+ class Operations {
124
+ constructor() {
125
+ this.type = '';
126
+ this.server = '';
127
+ this.endpoint = '';
128
+ this.method = '';
129
+ this.validations = new Validations();
130
+ }
131
+ }
132
+ class Validations {
133
+ constructor() {
134
+ this.type = '';
135
+ this.required = [];
136
+ this.server = '';
137
+ this.endpoint = '';
138
+ }
139
+ }
140
+
141
+ class GeneralService {
142
+ constructor(http) {
143
+ var _a;
144
+ this.http = http;
145
+ this.generales = '';
146
+ this.jsonConfig = JSON.parse(sessionStorage.getItem('ConfigJSON') || '{}');
147
+ this.generales = (_a = this.jsonConfig) === null || _a === void 0 ? void 0 : _a.ServidorGenerales;
148
+ }
149
+ getCrudByEntidad(idKatios, idEntidad) {
150
+ return __awaiter(this, void 0, void 0, function* () {
151
+ return this.http.get(`${this.generales}crud/${idKatios}/${idEntidad}`)
152
+ .toPromise()
153
+ .then((res) => res.data)
154
+ .then(data => { return data; });
155
+ });
156
+ }
157
+ genericRequest(method, servidor, endpoint, data) {
158
+ return __awaiter(this, void 0, void 0, function* () {
159
+ switch (method) {
160
+ case 'GET':
161
+ return this.http.get(`${this.jsonConfig[servidor]}${endpoint}`)
162
+ .toPromise();
163
+ case 'POST':
164
+ return this.http.post(`${this.jsonConfig[servidor]}${endpoint}`, data)
165
+ .toPromise();
166
+ case 'PUT':
167
+ return this.http.put(`${this.jsonConfig[servidor]}${endpoint}`, data)
168
+ .toPromise();
169
+ case 'DELETE':
170
+ return this.http.delete(`${this.jsonConfig[servidor]}${endpoint}`, data)
171
+ .toPromise();
172
+ default:
173
+ return;
174
+ }
175
+ });
176
+ }
177
+ }
178
+ GeneralService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: GeneralService, deps: [{ token: i1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
179
+ GeneralService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: GeneralService, providedIn: 'root' });
180
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: GeneralService, decorators: [{
181
+ type: Injectable,
182
+ args: [{
183
+ providedIn: 'root'
184
+ }]
185
+ }], ctorParameters: function () { return [{ type: i1.HttpClient }]; } });
186
+
187
+ class TableroComponent {
188
+ constructor(generalService, router) {
189
+ this.generalService = generalService;
190
+ this.router = router;
191
+ this.opciones = [];
192
+ this.idEntidad = '';
193
+ this.idKatios = '';
194
+ this.crudConfig = new CrudConfig();
195
+ this.enProceso = false;
196
+ this.data = [];
197
+ this.btn = { create: undefined, read: undefined, update: undefined, delete: undefined };
198
+ }
199
+ ngOnInit() {
200
+ this.loadConfigCrud();
201
+ }
202
+ loadConfigCrud() {
203
+ this.enProceso = true;
204
+ this.generalService.getCrudByEntidad(this.idKatios, this.idEntidad)
205
+ .then(res => {
206
+ this.crudConfig = res;
207
+ this.getInfoTablero(this.crudConfig.tablero);
208
+ this.loadOptions();
209
+ })
210
+ .catch(err => {
211
+ console.log(err);
212
+ this.enProceso = false;
213
+ });
214
+ }
215
+ getInfoTablero(configTablero) {
216
+ this.generalService.genericRequest(configTablero.method, configTablero.server, configTablero.endpoint)
217
+ .then((res) => {
218
+ this.data = res.data;
219
+ this.enProceso = false;
220
+ })
221
+ .catch(err => {
222
+ console.log(err);
223
+ this.enProceso = false;
224
+ });
225
+ }
226
+ loadOptions() {
227
+ this.btn.create = this.opciones.find(x => x.label == 'Crear');
228
+ this.btn.read = this.opciones.find(x => x.label == 'Visualizar');
229
+ this.btn.update = this.opciones.find(x => x.label == 'Editar');
230
+ this.btn.delete = this.opciones.find(x => x.label == 'Eliminar');
231
+ }
232
+ redirect(data, accion) {
233
+ var _a, _b;
234
+ switch (accion) {
235
+ case 'create':
236
+ this.router.navigateByUrl(((_b = (_a = this.btn.create) === null || _a === void 0 ? void 0 : _a.valor) === null || _b === void 0 ? void 0 : _b.redirect) || '');
237
+ break;
238
+ case 'read':
239
+ this.router.navigateByUrl(this.btn.read.valor.redirect.replace('$id', data[this.crudConfig.tablero.key]));
240
+ break;
241
+ case 'update':
242
+ this.router.navigateByUrl(this.btn.update.valor.redirect.replace('$id', data[this.crudConfig.tablero.key]));
243
+ break;
244
+ case 'delete':
245
+ this.router.navigateByUrl(this.btn.delete.valor.redirect.replace('$id', data[this.crudConfig.tablero.key]));
246
+ break;
247
+ default:
248
+ break;
249
+ }
250
+ }
251
+ }
252
+ 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 });
253
+ 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\">\n <i class=\"pi pi-cog pi-spin\" style=\"font-size: 50px\"></i>\n</p-blockUI>\n\n<div class=\"card\" *ngIf=\"!enProceso\">\n <p-toolbar styleClass=\"mb-4 gap-2\">\n <ng-template pTemplate=\"left\">\n <button *ngIf=\"btn.create\" pButton pRipple [label]=\"btn.create.label\" [icon]=\"btn.create.icon\"\n class=\"p-button-success mr-2\" (click)=\"redirect(rowData, 'create')\"></button>\n </ng-template>\n </p-toolbar>\n <p-table #dt [columns]=\"crudConfig.tablero.columns\" [value]=\"data\" [rowHover]=\"true\" [rows]=\"10\" [paginator]=\"true\"\n [globalFilterFields]=\"crudConfig.tablero?.filters || []\" [tableStyle]=\"{'min-width': '75rem'}\"\n currentPageReportTemplate=\"Registro {first} al {last} de {totalRecords} {{idEntidad}}\"\n [showCurrentPageReport]=\"true\">\n <ng-template pTemplate=\"caption\">\n <div class=\"flex align-items-center justify-content-between\">\n <h5 class=\"m-0\">{{idEntidad}}</h5>\n <span class=\"p-input-icon-left\">\n <i class=\"pi pi-search\"></i>\n <input pInputText type=\"text\" (input)=\"dt.filterGlobal($event.target.value, 'contains')\"\n placeholder=\"Buscar...\" />\n </span>\n </div>\n </ng-template>\n <ng-template pTemplate=\"header\" let-columns>\n <tr>\n <th *ngFor=\"let col of columns\">\n {{col.label}}\n </th>\n <th>Acci\u00F3n</th>\n </tr>\n </ng-template>\n <ng-template pTemplate=\"body\" let-rowData let-columns=\"columns\">\n <tr>\n <td *ngFor=\"let col of columns\">\n {{rowData[col.col]}}\n </td>\n <th>\n <button *ngIf=\"btn.read\" pButton pRipple [pTooltip]=\"btn.read.label\" [icon]=\"btn.read.icon\"\n class=\"p-button-rounded p-button-info mr-2\" (click)=\"redirect(rowData, 'read')\"></button>\n <button *ngIf=\"btn.update\" pButton pRipple [pTooltip]=\"btn.update.label\" [icon]=\"btn.update.icon\"\n class=\"p-button-rounded p-button-warning mr-2\" (click)=\"redirect(rowData, 'update')\"></button>\n <button *ngIf=\"btn.delete\" pButton pRipple [pTooltip]=\"btn.delete.label\" [icon]=\"btn.delete.icon\"\n class=\"p-button-rounded p-button-danger mr-2\" (click)=\"redirect(rowData, 'delete')\"></button>\n </th>\n </tr>\n </ng-template>\n </p-table>\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: i7.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: i7.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"] }] });
254
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: TableroComponent, decorators: [{
255
+ type: Component,
256
+ args: [{
257
+ selector: 'sf-crudtablero',
258
+ templateUrl: './tablero.component.html'
259
+ }]
260
+ }], ctorParameters: function () { return [{ type: GeneralService }, { type: i2.Router }]; }, propDecorators: { opciones: [{
261
+ type: Input
262
+ }], idEntidad: [{
263
+ type: Input
264
+ }], idKatios: [{
265
+ type: Input
266
+ }] } });
267
+
268
+ class ControlComponent {
269
+ constructor() {
270
+ this.label = '';
271
+ this.setValue = new EventEmitter();
272
+ }
273
+ ngOnInit() {
274
+ }
275
+ sendValue() {
276
+ this.setValue.emit(this.value);
277
+ }
278
+ }
279
+ ControlComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: ControlComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
280
+ 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\">\n <ng-container *ngSwitchCase=\"'string'\">\n <label>{{label}}</label>\n <ng-container *ngIf=\"!control?.enum\">\n <input pInputText type=\"text\" [(ngModel)]=\"value\" (focusout)=\"sendValue()\">\n </ng-container>\n <ng-container *ngIf=\"control?.enum\">\n <p-dropdown [options]=\"control.enum\" [(ngModel)]=\"value\" (onChange)=\"sendValue()\" placeholder=\"Seleccione una opci\u00F3n\"></p-dropdown>\n </ng-container>\n </ng-container>\n</ng-container>\n", components: [{ type: i1$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"] }], directives: [{ type: i7.NgSwitch, selector: "[ngSwitch]", inputs: ["ngSwitch"] }, { type: i7.NgSwitchCase, selector: "[ngSwitchCase]", inputs: ["ngSwitchCase"] }, { type: i7.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i3$2.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: i3$2.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i3$2.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }] });
281
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: ControlComponent, decorators: [{
282
+ type: Component,
283
+ args: [{
284
+ selector: 'sf-control',
285
+ templateUrl: './control.component.html'
286
+ }]
287
+ }], ctorParameters: function () { return []; }, propDecorators: { control: [{
288
+ type: Input
289
+ }], label: [{
290
+ type: Input
291
+ }], value: [{
292
+ type: Input
293
+ }], setValue: [{
294
+ type: Output
295
+ }] } });
296
+
297
+ class RegistroComponent {
298
+ constructor(generalService, router, messageSerice) {
299
+ this.generalService = generalService;
300
+ this.router = router;
301
+ this.messageSerice = messageSerice;
302
+ this.idKatios = '';
303
+ this.idEntidad = '';
304
+ this.trx = '';
305
+ this.id = '';
306
+ this.enProceso = false;
307
+ this.crudConfig = new CrudConfig();
308
+ this.configOperation = new Operations();
309
+ }
310
+ ngOnInit() {
311
+ this.loadConfigCrud();
312
+ this.setLabelSumbit();
313
+ }
314
+ loadConfigCrud() {
315
+ this.enProceso = true;
316
+ this.generalService.getCrudByEntidad(this.idKatios, this.idEntidad)
317
+ .then(res => {
318
+ this.crudConfig = res;
319
+ if (this.trx != 'c')
320
+ this.getInfoRegistro(this.crudConfig.registro);
321
+ else {
322
+ this.data = this.createObject(this.crudConfig.esquema);
323
+ this.enProceso = false;
324
+ }
325
+ this.configOperation = this.crudConfig.registro.operations.find(x => x.type.startsWith(this.trx)) || new Operations();
326
+ })
327
+ .catch(err => {
328
+ console.log(err);
329
+ this.enProceso = false;
330
+ });
331
+ }
332
+ setLabelSumbit() {
333
+ if (this.trx == 'c')
334
+ this.btnSubmit = { label: 'Guardar', icon: 'pi pi-save' };
335
+ else if (this.trx == 'r')
336
+ this.btnSubmit = undefined;
337
+ else if (this.trx == 'u')
338
+ this.btnSubmit = { label: 'Actualizar', icon: 'pi pi-sync' };
339
+ else if (this.trx == 'd')
340
+ this.btnSubmit = { label: 'Eliminar', icon: 'pi pi-trash' };
341
+ }
342
+ getInfoRegistro(configRegistro) {
343
+ let op = configRegistro.operations.find(x => x.type == 'read');
344
+ let endpoint = (op === null || op === void 0 ? void 0 : op.endpoint) || '';
345
+ endpoint = endpoint.replace('@idKatios', this.idKatios);
346
+ endpoint = endpoint.replace('@id', this.id);
347
+ this.generalService.genericRequest((op === null || op === void 0 ? void 0 : op.method) || '', (op === null || op === void 0 ? void 0 : op.server) || '', endpoint)
348
+ .then((res) => {
349
+ this.data = res.data;
350
+ this.enProceso = false;
351
+ })
352
+ .catch(err => {
353
+ console.log(err);
354
+ this.enProceso = false;
355
+ });
356
+ }
357
+ back() {
358
+ this.router.navigateByUrl(this.crudConfig.registro.btnBack);
359
+ }
360
+ getControl(scope) {
361
+ return jsonpath.query(this.crudConfig.esquema, scope)[0];
362
+ }
363
+ getValue(scope) {
364
+ return jsonpath.query(this.data, scope.replace('.properties', ''))[0];
365
+ }
366
+ setValue(value, scope) {
367
+ jsonpath.value(this.data, scope.replace('.properties', ''), value);
368
+ }
369
+ createObject(esquema) {
370
+ let object = {};
371
+ switch (esquema.type) {
372
+ case 'string':
373
+ case 'number':
374
+ return (esquema === null || esquema === void 0 ? void 0 : esquema.default) || null;
375
+ case 'boolean':
376
+ return (esquema === null || esquema === void 0 ? void 0 : esquema.default) || false;
377
+ case 'object':
378
+ for (const key in esquema === null || esquema === void 0 ? void 0 : esquema.properties) {
379
+ Object.defineProperty(object, key, { value: this.createObject(esquema === null || esquema === void 0 ? void 0 : esquema.properties[key]), writable: true, enumerable: true, configurable: true });
380
+ }
381
+ break;
382
+ default:
383
+ break;
384
+ }
385
+ return object;
386
+ }
387
+ submit() {
388
+ if (!this.validateData())
389
+ return;
390
+ this.enProceso = true;
391
+ let endpoint = this.configOperation.endpoint;
392
+ endpoint = endpoint.replace('@idKatios', this.idKatios);
393
+ endpoint = endpoint.replace('@id', this.id);
394
+ this.generalService.genericRequest(this.configOperation.method, this.configOperation.server, endpoint, this.data)
395
+ .then(() => {
396
+ this.messageSerice.add({ severity: 'success', detail: `Proceso exitoso!` });
397
+ setTimeout(() => {
398
+ this.enProceso = false;
399
+ this.back();
400
+ }, 2000);
401
+ })
402
+ .catch(err => {
403
+ var _a;
404
+ 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.'}` });
405
+ this.enProceso = false;
406
+ });
407
+ }
408
+ validateData() {
409
+ if (this.configOperation.validations.type == 'local')
410
+ return this.validateDataLocal();
411
+ return true;
412
+ }
413
+ validateDataLocal() {
414
+ let err = [];
415
+ this.configOperation.validations.required.forEach(x => {
416
+ if (!jsonpath.query(this.data, x.field)[0])
417
+ err.push(x.message);
418
+ });
419
+ if (err.length != 0)
420
+ this.messageSerice.add({ severity: 'warn', detail: err.join('. ') });
421
+ return err.length == 0;
422
+ }
423
+ }
424
+ 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 });
425
+ 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\">\n <i class=\"pi pi-cog pi-spin\" style=\"font-size: 50px\"></i>\n</p-blockUI>\n\n<p-toast></p-toast>\n\n<div class=\"card\" *ngIf=\"!enProceso\">\n <h5 class=\"card-header mb-2\" style=\"display: flex; justify-content: space-between;align-items: center;\">\n <span>{{idEntidad}} {{id != '' ? '-' + id : ''}}</span>\n <button pButton pRipple type=\"button\" icon=\"pi pi-arrow-left\" (click)=\"back()\"></button>\n </h5>\n <div *ngFor=\"let element of crudConfig.uiEsquema.elements\" [class]=\"element?.class\">\n <ng-container [ngSwitch]=\"element.type\">\n <div *ngSwitchCase=\"'Label'\" [style]=\"element?.style\">\n {{element?.label}}\n </div>\n <ng-container *ngSwitchCase=\"'HorizontalLayout'\">\n <div *ngFor=\"let el of element.elements\" [class]=\"el?.class\">\n <ng-container [ngSwitch]=\"el.type\" >\n <sf-control *ngSwitchCase=\"'Control'\" [control]=\"getControl(el.scope)\" [label]=\"el.label\" [value]=\"getValue(el.scope)\" (setValue)=\"setValue($event, el.scope)\"></sf-control>\n </ng-container>\n </div>\n </ng-container>\n <div *ngSwitchCase=\"'Control'\">\n <sf-control *ngSwitchCase=\"'Control'\" [control]=\"getControl(element.scope)\" [label]=\"element.label\"></sf-control>\n </div>\n </ng-container>\n </div>\n <div class=\"card-footer\" *ngIf=\"btnSubmit\">\n <button pButton pRipple type=\"button\" [icon]=\"btnSubmit.icon\" [label]=\"btnSubmit.label\" (click)=\"submit()\"></button>\n </div>\n</div>", components: [{ type: i3.BlockUI, selector: "p-blockUI", inputs: ["autoZIndex", "baseZIndex", "blocked", "target", "styleClass"] }, { type: i5$1.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: i7.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i8.ButtonDirective, selector: "[pButton]", inputs: ["iconPos", "loadingIcon", "label", "icon", "loading"] }, { type: i9.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"] }] });
426
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: RegistroComponent, decorators: [{
427
+ type: Component,
428
+ args: [{
429
+ selector: 'sf-registro',
430
+ templateUrl: './registro.component.html',
431
+ providers: [MessageService]
432
+ }]
433
+ }], ctorParameters: function () { return [{ type: GeneralService }, { type: i2.Router }, { type: i3$1.MessageService }]; }, propDecorators: { idKatios: [{
434
+ type: Input
435
+ }], idEntidad: [{
436
+ type: Input
437
+ }], trx: [{
438
+ type: Input
439
+ }], id: [{
440
+ type: Input
441
+ }] } });
442
+
443
+ class SfCrudComponent {
444
+ constructor() { }
445
+ ngOnInit() {
446
+ }
447
+ }
448
+ SfCrudComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: SfCrudComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
449
+ SfCrudComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.17", type: SfCrudComponent, selector: "lib-sf-crud", ngImport: i0, template: `
450
+ <p>
451
+ sf-crud works!
452
+ </p>
453
+ `, isInline: true });
454
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: SfCrudComponent, decorators: [{
455
+ type: Component,
456
+ args: [{
457
+ selector: 'lib-sf-crud',
458
+ template: `
459
+ <p>
460
+ sf-crud works!
461
+ </p>
462
+ `,
463
+ styles: []
464
+ }]
465
+ }], ctorParameters: function () { return []; } });
466
+
467
+ class SfCrudModule {
468
+ }
469
+ SfCrudModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: SfCrudModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
470
+ SfCrudModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: SfCrudModule, declarations: [SfCrudComponent,
471
+ TableroComponent,
472
+ RegistroComponent,
473
+ ControlComponent], imports: [AccordionModule,
474
+ AvatarGroupModule,
475
+ AvatarModule,
476
+ BadgeModule,
477
+ BlockUIModule,
478
+ BreadcrumbModule,
479
+ ButtonModule,
480
+ CalendarModule,
481
+ CardModule,
482
+ CarouselModule,
483
+ CascadeSelectModule,
484
+ CheckboxModule,
485
+ ChipModule,
486
+ ChipsModule,
487
+ CodeHighlighterModule,
488
+ ColorPickerModule,
489
+ ConfirmDialogModule,
490
+ ConfirmPopupModule,
491
+ ContextMenuModule,
492
+ DialogModule,
493
+ DividerModule,
494
+ DropdownModule,
495
+ FieldsetModule,
496
+ FileUploadModule,
497
+ FormsModule,
498
+ GalleriaModule,
499
+ HttpClientModule,
500
+ InplaceModule,
501
+ InputMaskModule,
502
+ InputNumberModule,
503
+ InputSwitchModule,
504
+ InputTextareaModule,
505
+ InputTextModule,
506
+ KnobModule,
507
+ LightboxModule,
508
+ ListboxModule,
509
+ MegaMenuModule,
510
+ MenubarModule,
511
+ MenuModule,
512
+ MessageModule,
513
+ MessagesModule,
514
+ MultiSelectModule,
515
+ OrganizationChartModule,
516
+ OverlayPanelModule,
517
+ PanelMenuModule,
518
+ PanelModule,
519
+ PasswordModule,
520
+ ProgressBarModule,
521
+ RadioButtonModule,
522
+ RatingModule,
523
+ RippleModule,
524
+ ScrollPanelModule,
525
+ ScrollTopModule,
526
+ SelectButtonModule,
527
+ SidebarModule,
528
+ SkeletonModule,
529
+ SlideMenuModule,
530
+ SliderModule,
531
+ SplitterModule,
532
+ StepsModule,
533
+ TableModule,
534
+ TabMenuModule,
535
+ TabViewModule,
536
+ TagModule,
537
+ TerminalModule,
538
+ TieredMenuModule,
539
+ TimelineModule,
540
+ ToastModule,
541
+ ToggleButtonModule,
542
+ ToolbarModule,
543
+ TooltipModule,
544
+ TreeModule], exports: [SfCrudComponent,
545
+ TableroComponent,
546
+ RegistroComponent] });
547
+ SfCrudModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: SfCrudModule, imports: [[
548
+ AccordionModule,
549
+ AvatarGroupModule,
550
+ AvatarModule,
551
+ BadgeModule,
552
+ BlockUIModule,
553
+ BreadcrumbModule,
554
+ ButtonModule,
555
+ CalendarModule,
556
+ CardModule,
557
+ CarouselModule,
558
+ CascadeSelectModule,
559
+ CheckboxModule,
560
+ ChipModule,
561
+ ChipsModule,
562
+ CodeHighlighterModule,
563
+ ColorPickerModule,
564
+ ConfirmDialogModule,
565
+ ConfirmPopupModule,
566
+ ContextMenuModule,
567
+ DialogModule,
568
+ DividerModule,
569
+ DropdownModule,
570
+ FieldsetModule,
571
+ FileUploadModule,
572
+ FormsModule,
573
+ GalleriaModule,
574
+ HttpClientModule,
575
+ InplaceModule,
576
+ InputMaskModule,
577
+ InputNumberModule,
578
+ InputSwitchModule,
579
+ InputTextareaModule,
580
+ InputTextModule,
581
+ KnobModule,
582
+ LightboxModule,
583
+ ListboxModule,
584
+ MegaMenuModule,
585
+ MenubarModule,
586
+ MenuModule,
587
+ MessageModule,
588
+ MessagesModule,
589
+ MultiSelectModule,
590
+ OrganizationChartModule,
591
+ OverlayPanelModule,
592
+ PanelMenuModule,
593
+ PanelModule,
594
+ PasswordModule,
595
+ ProgressBarModule,
596
+ RadioButtonModule,
597
+ RatingModule,
598
+ RippleModule,
599
+ ScrollPanelModule,
600
+ ScrollTopModule,
601
+ SelectButtonModule,
602
+ SidebarModule,
603
+ SkeletonModule,
604
+ SlideMenuModule,
605
+ SliderModule,
606
+ SplitterModule,
607
+ StepsModule,
608
+ TableModule,
609
+ TabMenuModule,
610
+ TabViewModule,
611
+ TagModule,
612
+ TerminalModule,
613
+ TieredMenuModule,
614
+ TimelineModule,
615
+ ToastModule,
616
+ ToggleButtonModule,
617
+ ToolbarModule,
618
+ TooltipModule,
619
+ TreeModule,
620
+ ]] });
621
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: SfCrudModule, decorators: [{
622
+ type: NgModule,
623
+ args: [{
624
+ declarations: [
625
+ SfCrudComponent,
626
+ TableroComponent,
627
+ RegistroComponent,
628
+ ControlComponent
629
+ ],
630
+ imports: [
631
+ AccordionModule,
632
+ AvatarGroupModule,
633
+ AvatarModule,
634
+ BadgeModule,
635
+ BlockUIModule,
636
+ BreadcrumbModule,
637
+ ButtonModule,
638
+ CalendarModule,
639
+ CardModule,
640
+ CarouselModule,
641
+ CascadeSelectModule,
642
+ CheckboxModule,
643
+ ChipModule,
644
+ ChipsModule,
645
+ CodeHighlighterModule,
646
+ ColorPickerModule,
647
+ ConfirmDialogModule,
648
+ ConfirmPopupModule,
649
+ ContextMenuModule,
650
+ DialogModule,
651
+ DividerModule,
652
+ DropdownModule,
653
+ FieldsetModule,
654
+ FileUploadModule,
655
+ FormsModule,
656
+ GalleriaModule,
657
+ HttpClientModule,
658
+ InplaceModule,
659
+ InputMaskModule,
660
+ InputNumberModule,
661
+ InputSwitchModule,
662
+ InputTextareaModule,
663
+ InputTextModule,
664
+ KnobModule,
665
+ LightboxModule,
666
+ ListboxModule,
667
+ MegaMenuModule,
668
+ MenubarModule,
669
+ MenuModule,
670
+ MessageModule,
671
+ MessagesModule,
672
+ MultiSelectModule,
673
+ OrganizationChartModule,
674
+ OverlayPanelModule,
675
+ PanelMenuModule,
676
+ PanelModule,
677
+ PasswordModule,
678
+ ProgressBarModule,
679
+ RadioButtonModule,
680
+ RatingModule,
681
+ RippleModule,
682
+ ScrollPanelModule,
683
+ ScrollTopModule,
684
+ SelectButtonModule,
685
+ SidebarModule,
686
+ SkeletonModule,
687
+ SlideMenuModule,
688
+ SliderModule,
689
+ SplitterModule,
690
+ StepsModule,
691
+ TableModule,
692
+ TabMenuModule,
693
+ TabViewModule,
694
+ TagModule,
695
+ TerminalModule,
696
+ TieredMenuModule,
697
+ TimelineModule,
698
+ ToastModule,
699
+ ToggleButtonModule,
700
+ ToolbarModule,
701
+ TooltipModule,
702
+ TreeModule,
703
+ ],
704
+ exports: [
705
+ SfCrudComponent,
706
+ TableroComponent,
707
+ RegistroComponent
708
+ ]
709
+ }]
710
+ }] });
711
+
712
+ class SfCrudService {
713
+ constructor() { }
714
+ }
715
+ SfCrudService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: SfCrudService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
716
+ SfCrudService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: SfCrudService, providedIn: 'root' });
717
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: SfCrudService, decorators: [{
718
+ type: Injectable,
719
+ args: [{
720
+ providedIn: 'root'
721
+ }]
722
+ }], ctorParameters: function () { return []; } });
723
+
724
+ /*
725
+ * Public API Surface of sf-crud
726
+ */
727
+
728
+ /**
729
+ * Generated bundle index. Do not edit.
730
+ */
731
+
732
+ export { RegistroComponent, SfCrudComponent, SfCrudModule, SfCrudService, TableroComponent };
733
+ //# sourceMappingURL=sf-crud.js.map