sf-crud 11.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.
Files changed (52) hide show
  1. package/README.md +24 -0
  2. package/bundles/sf-crud.umd.js +844 -0
  3. package/bundles/sf-crud.umd.js.map +1 -0
  4. package/bundles/sf-crud.umd.min.js +2 -0
  5. package/bundles/sf-crud.umd.min.js.map +1 -0
  6. package/esm2015/lib/components/control/control.component.js +26 -0
  7. package/esm2015/lib/components/control/control.component.ngfactory.js +52 -0
  8. package/esm2015/lib/components/control/control.component.ngsummary.json +1 -0
  9. package/esm2015/lib/components/registro/registro.component.js +152 -0
  10. package/esm2015/lib/components/registro/registro.component.ngfactory.js +46 -0
  11. package/esm2015/lib/components/registro/registro.component.ngsummary.json +1 -0
  12. package/esm2015/lib/components/tablero/tablero.component.js +85 -0
  13. package/esm2015/lib/components/tablero/tablero.component.ngfactory.js +60 -0
  14. package/esm2015/lib/components/tablero/tablero.component.ngsummary.json +1 -0
  15. package/esm2015/lib/sf-crud.component.js +18 -0
  16. package/esm2015/lib/sf-crud.component.ngfactory.js +16 -0
  17. package/esm2015/lib/sf-crud.component.ngsummary.json +1 -0
  18. package/esm2015/lib/sf-crud.module.js +175 -0
  19. package/esm2015/lib/sf-crud.module.ngfactory.js +93 -0
  20. package/esm2015/lib/sf-crud.module.ngsummary.json +1 -0
  21. package/esm2015/lib/sf-crud.service.js +13 -0
  22. package/esm2015/lib/sf-crud.service.ngsummary.json +1 -0
  23. package/esm2015/lib/shared/services/general.service.js +52 -0
  24. package/esm2015/lib/shared/services/general.service.ngsummary.json +1 -0
  25. package/esm2015/lib/shared/services/models/crud-config.model.js +43 -0
  26. package/esm2015/lib/shared/services/models/crud-config.model.ngsummary.json +1 -0
  27. package/esm2015/lib/shared/services/models/shema.model.js +6 -0
  28. package/esm2015/lib/shared/services/models/shema.model.ngsummary.json +1 -0
  29. package/esm2015/public-api.js +9 -0
  30. package/esm2015/public-api.ngsummary.json +1 -0
  31. package/esm2015/sf-crud.js +7 -0
  32. package/esm2015/sf-crud.ngsummary.json +1 -0
  33. package/fesm2015/sf-crud.js +555 -0
  34. package/fesm2015/sf-crud.js.map +1 -0
  35. package/lib/components/control/control.component.d.ts +10 -0
  36. package/lib/components/control/control.component.ngfactory.d.ts +1 -0
  37. package/lib/components/registro/registro.component.d.ts +33 -0
  38. package/lib/components/registro/registro.component.ngfactory.d.ts +1 -0
  39. package/lib/components/tablero/tablero.component.d.ts +26 -0
  40. package/lib/components/tablero/tablero.component.ngfactory.d.ts +1 -0
  41. package/lib/sf-crud.component.d.ts +5 -0
  42. package/lib/sf-crud.component.ngfactory.d.ts +1 -0
  43. package/lib/sf-crud.module.d.ts +2 -0
  44. package/lib/sf-crud.module.ngfactory.d.ts +3 -0
  45. package/lib/sf-crud.service.d.ts +3 -0
  46. package/lib/shared/services/general.service.d.ts +10 -0
  47. package/lib/shared/services/models/crud-config.model.d.ts +36 -0
  48. package/lib/shared/services/models/shema.model.d.ts +6 -0
  49. package/package.json +19 -0
  50. package/public-api.d.ts +5 -0
  51. package/sf-crud.d.ts +6 -0
  52. package/sf-crud.metadata.json +1 -0
@@ -0,0 +1,9 @@
1
+ /*
2
+ * Public API Surface of sf-crud
3
+ */
4
+ export * from './lib/components/tablero/tablero.component';
5
+ export * from './lib/components/registro/registro.component';
6
+ export * from './lib/sf-crud.component';
7
+ export * from './lib/sf-crud.module';
8
+ export * from './lib/sf-crud.service';
9
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHVibGljLWFwaS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3Byb2plY3RzL3NmLWNydWQvc3JjL3B1YmxpYy1hcGkudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUE7O0dBRUc7QUFFSCxjQUFjLDRDQUE0QyxDQUFDO0FBQzNELGNBQWMsOENBQThDLENBQUM7QUFDN0QsY0FBYyx5QkFBeUIsQ0FBQztBQUN4QyxjQUFjLHNCQUFzQixDQUFDO0FBQ3JDLGNBQWMsdUJBQXVCLENBQUMiLCJzb3VyY2VzQ29udGVudCI6WyIvKlxyXG4gKiBQdWJsaWMgQVBJIFN1cmZhY2Ugb2Ygc2YtY3J1ZFxyXG4gKi9cclxuXHJcbmV4cG9ydCAqIGZyb20gJy4vbGliL2NvbXBvbmVudHMvdGFibGVyby90YWJsZXJvLmNvbXBvbmVudCc7XHJcbmV4cG9ydCAqIGZyb20gJy4vbGliL2NvbXBvbmVudHMvcmVnaXN0cm8vcmVnaXN0cm8uY29tcG9uZW50JztcclxuZXhwb3J0ICogZnJvbSAnLi9saWIvc2YtY3J1ZC5jb21wb25lbnQnO1xyXG5leHBvcnQgKiBmcm9tICcuL2xpYi9zZi1jcnVkLm1vZHVsZSc7XHJcbmV4cG9ydCAqIGZyb20gJy4vbGliL3NmLWNydWQuc2VydmljZSc7XHJcbiJdfQ==
@@ -0,0 +1 @@
1
+ {"moduleName":null,"summaries":[{"symbol":{"__symbol":0,"members":[]},"metadata":{"__symbol":1,"members":[]}},{"symbol":{"__symbol":2,"members":[]},"metadata":{"__symbol":3,"members":[]}},{"symbol":{"__symbol":4,"members":[]},"metadata":{"__symbol":5,"members":[]}},{"symbol":{"__symbol":6,"members":[]},"metadata":{"__symbol":7,"members":[]}},{"symbol":{"__symbol":8,"members":[]},"metadata":{"__symbol":9,"members":[]}}],"symbols":[{"__symbol":0,"name":"TableroComponent","filePath":"./public-api"},{"__symbol":1,"name":"TableroComponent","filePath":"./lib/components/tablero/tablero.component"},{"__symbol":2,"name":"RegistroComponent","filePath":"./public-api"},{"__symbol":3,"name":"RegistroComponent","filePath":"./lib/components/registro/registro.component"},{"__symbol":4,"name":"SfCrudComponent","filePath":"./public-api"},{"__symbol":5,"name":"SfCrudComponent","filePath":"./lib/sf-crud.component"},{"__symbol":6,"name":"SfCrudModule","filePath":"./public-api"},{"__symbol":7,"name":"SfCrudModule","filePath":"./lib/sf-crud.module"},{"__symbol":8,"name":"SfCrudService","filePath":"./public-api"},{"__symbol":9,"name":"SfCrudService","filePath":"./lib/sf-crud.service"}]}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Generated bundle index. Do not edit.
3
+ */
4
+ export * from './public-api';
5
+ export { ControlComponent as ɵb } from './lib/components/control/control.component';
6
+ export { GeneralService as ɵa } from './lib/shared/services/general.service';
7
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2YtY3J1ZC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3Byb2plY3RzL3NmLWNydWQvc3JjL3NmLWNydWQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUE7O0dBRUc7QUFFSCxjQUFjLGNBQWMsQ0FBQztBQUU3QixPQUFPLEVBQUMsZ0JBQWdCLElBQUksRUFBRSxFQUFDLE1BQU0sNENBQTRDLENBQUM7QUFDbEYsT0FBTyxFQUFDLGNBQWMsSUFBSSxFQUFFLEVBQUMsTUFBTSx1Q0FBdUMsQ0FBQyIsInNvdXJjZXNDb250ZW50IjpbIi8qKlxuICogR2VuZXJhdGVkIGJ1bmRsZSBpbmRleC4gRG8gbm90IGVkaXQuXG4gKi9cblxuZXhwb3J0ICogZnJvbSAnLi9wdWJsaWMtYXBpJztcblxuZXhwb3J0IHtDb250cm9sQ29tcG9uZW50IGFzIMm1Yn0gZnJvbSAnLi9saWIvY29tcG9uZW50cy9jb250cm9sL2NvbnRyb2wuY29tcG9uZW50JztcbmV4cG9ydCB7R2VuZXJhbFNlcnZpY2UgYXMgybVhfSBmcm9tICcuL2xpYi9zaGFyZWQvc2VydmljZXMvZ2VuZXJhbC5zZXJ2aWNlJzsiXX0=
@@ -0,0 +1 @@
1
+ {"moduleName":null,"summaries":[{"symbol":{"__symbol":0,"members":[]},"metadata":{"__symbol":1,"members":[]}},{"symbol":{"__symbol":2,"members":[]},"metadata":{"__symbol":3,"members":[]}},{"symbol":{"__symbol":4,"members":[]},"metadata":{"__symbol":5,"members":[]}},{"symbol":{"__symbol":6,"members":[]},"metadata":{"__symbol":7,"members":[]}},{"symbol":{"__symbol":8,"members":[]},"metadata":{"__symbol":9,"members":[]}},{"symbol":{"__symbol":10,"members":[]},"metadata":{"__symbol":11,"members":[]}},{"symbol":{"__symbol":12,"members":[]},"metadata":{"__symbol":13,"members":[]}}],"symbols":[{"__symbol":0,"name":"TableroComponent","filePath":"./sf-crud"},{"__symbol":1,"name":"TableroComponent","filePath":"./public-api"},{"__symbol":2,"name":"RegistroComponent","filePath":"./sf-crud"},{"__symbol":3,"name":"RegistroComponent","filePath":"./public-api"},{"__symbol":4,"name":"SfCrudComponent","filePath":"./sf-crud"},{"__symbol":5,"name":"SfCrudComponent","filePath":"./public-api"},{"__symbol":6,"name":"SfCrudModule","filePath":"./sf-crud"},{"__symbol":7,"name":"SfCrudModule","filePath":"./public-api"},{"__symbol":8,"name":"SfCrudService","filePath":"./sf-crud"},{"__symbol":9,"name":"SfCrudService","filePath":"./public-api"},{"__symbol":10,"name":"ɵb","filePath":"./sf-crud"},{"__symbol":11,"name":"ControlComponent","filePath":"./lib/components/control/control.component"},{"__symbol":12,"name":"ɵa","filePath":"./sf-crud"},{"__symbol":13,"name":"GeneralService","filePath":"./lib/shared/services/general.service"}]}
@@ -0,0 +1,555 @@
1
+ import { ɵɵdefineInjectable, ɵɵinject, Injectable, Component, Input, EventEmitter, Output, NgModule } from '@angular/core';
2
+ import { Router } from '@angular/router';
3
+ import { __awaiter } from 'tslib';
4
+ import { HttpClient, HttpClientModule } from '@angular/common/http';
5
+ import { query, value } from 'jsonpath';
6
+ import { MessageService } from 'primeng/api';
7
+ import { FormsModule } from '@angular/forms';
8
+ import { AccordionModule } from 'primeng/accordion';
9
+ import { AvatarModule } from 'primeng/avatar';
10
+ import { AvatarGroupModule } from 'primeng/avatargroup';
11
+ import { BadgeModule } from 'primeng/badge';
12
+ import { BlockUIModule } from 'primeng/blockui';
13
+ import { BreadcrumbModule } from 'primeng/breadcrumb';
14
+ import { ButtonModule } from 'primeng/button';
15
+ import { CalendarModule } from 'primeng/calendar';
16
+ import { CardModule } from 'primeng/card';
17
+ import { CarouselModule } from 'primeng/carousel';
18
+ import { CascadeSelectModule } from 'primeng/cascadeselect';
19
+ import { CheckboxModule } from 'primeng/checkbox';
20
+ import { ChipModule } from 'primeng/chip';
21
+ import { ChipsModule } from 'primeng/chips';
22
+ import { CodeHighlighterModule } from 'primeng/codehighlighter';
23
+ import { ConfirmDialogModule } from 'primeng/confirmdialog';
24
+ import { ConfirmPopupModule } from 'primeng/confirmpopup';
25
+ import { ColorPickerModule } from 'primeng/colorpicker';
26
+ import { ContextMenuModule } from 'primeng/contextmenu';
27
+ import { DialogModule } from 'primeng/dialog';
28
+ import { DividerModule } from 'primeng/divider';
29
+ import { DropdownModule } from 'primeng/dropdown';
30
+ import { FieldsetModule } from 'primeng/fieldset';
31
+ import { FileUploadModule } from 'primeng/fileupload';
32
+ import { GalleriaModule } from 'primeng/galleria';
33
+ import { InplaceModule } from 'primeng/inplace';
34
+ import { InputNumberModule } from 'primeng/inputnumber';
35
+ import { InputMaskModule } from 'primeng/inputmask';
36
+ import { InputSwitchModule } from 'primeng/inputswitch';
37
+ import { InputTextModule } from 'primeng/inputtext';
38
+ import { InputTextareaModule } from 'primeng/inputtextarea';
39
+ import { KnobModule } from 'primeng/knob';
40
+ import { LightboxModule } from 'primeng/lightbox';
41
+ import { ListboxModule } from 'primeng/listbox';
42
+ import { MegaMenuModule } from 'primeng/megamenu';
43
+ import { MenuModule } from 'primeng/menu';
44
+ import { MenubarModule } from 'primeng/menubar';
45
+ import { MessagesModule } from 'primeng/messages';
46
+ import { MessageModule } from 'primeng/message';
47
+ import { MultiSelectModule } from 'primeng/multiselect';
48
+ import { OrganizationChartModule } from 'primeng/organizationchart';
49
+ import { OverlayPanelModule } from 'primeng/overlaypanel';
50
+ import { PanelModule } from 'primeng/panel';
51
+ import { PanelMenuModule } from 'primeng/panelmenu';
52
+ import { PasswordModule } from 'primeng/password';
53
+ import { ProgressBarModule } from 'primeng/progressbar';
54
+ import { RadioButtonModule } from 'primeng/radiobutton';
55
+ import { RatingModule } from 'primeng/rating';
56
+ import { RippleModule } from 'primeng/ripple';
57
+ import { ScrollPanelModule } from 'primeng/scrollpanel';
58
+ import { ScrollTopModule } from 'primeng/scrolltop';
59
+ import { SelectButtonModule } from 'primeng/selectbutton';
60
+ import { SidebarModule } from 'primeng/sidebar';
61
+ import { SkeletonModule } from 'primeng/skeleton';
62
+ import { SlideMenuModule } from 'primeng/slidemenu';
63
+ import { SliderModule } from 'primeng/slider';
64
+ import { SplitterModule } from 'primeng/splitter';
65
+ import { StepsModule } from 'primeng/steps';
66
+ import { TableModule } from 'primeng/table';
67
+ import { TabMenuModule } from 'primeng/tabmenu';
68
+ import { TabViewModule } from 'primeng/tabview';
69
+ import { TagModule } from 'primeng/tag';
70
+ import { TerminalModule } from 'primeng/terminal';
71
+ import { TieredMenuModule } from 'primeng/tieredmenu';
72
+ import { TimelineModule } from 'primeng/timeline';
73
+ import { ToastModule } from 'primeng/toast';
74
+ import { ToggleButtonModule } from 'primeng/togglebutton';
75
+ import { ToolbarModule } from 'primeng/toolbar';
76
+ import { TooltipModule } from 'primeng/tooltip';
77
+ import { TreeModule } from 'primeng/tree';
78
+
79
+ class GeneralService {
80
+ constructor(http) {
81
+ var _a;
82
+ this.http = http;
83
+ this.generales = '';
84
+ this.jsonConfig = JSON.parse(sessionStorage.getItem('ConfigJSON') || '{}');
85
+ this.generales = (_a = this.jsonConfig) === null || _a === void 0 ? void 0 : _a.ServidorGenerales;
86
+ }
87
+ getCrudByEntidad(idKatios, idEntidad) {
88
+ return __awaiter(this, void 0, void 0, function* () {
89
+ return this.http.get(`${this.generales}crud/${idKatios}/${idEntidad}`)
90
+ .toPromise()
91
+ .then((res) => res.data)
92
+ .then(data => { return data; });
93
+ });
94
+ }
95
+ genericRequest(method, servidor, endpoint, data) {
96
+ return __awaiter(this, void 0, void 0, function* () {
97
+ switch (method) {
98
+ case 'GET':
99
+ return this.http.get(`${this.jsonConfig[servidor]}${endpoint}`)
100
+ .toPromise();
101
+ case 'POST':
102
+ return this.http.post(`${this.jsonConfig[servidor]}${endpoint}`, data)
103
+ .toPromise();
104
+ case 'PUT':
105
+ return this.http.put(`${this.jsonConfig[servidor]}${endpoint}`, data)
106
+ .toPromise();
107
+ case 'DELETE':
108
+ return this.http.delete(`${this.jsonConfig[servidor]}${endpoint}`, data)
109
+ .toPromise();
110
+ default:
111
+ return;
112
+ }
113
+ });
114
+ }
115
+ }
116
+ GeneralService.ɵprov = ɵɵdefineInjectable({ factory: function GeneralService_Factory() { return new GeneralService(ɵɵinject(HttpClient)); }, token: GeneralService, providedIn: "root" });
117
+ GeneralService.decorators = [
118
+ { type: Injectable, args: [{
119
+ providedIn: 'root'
120
+ },] }
121
+ ];
122
+ GeneralService.ctorParameters = () => [
123
+ { type: HttpClient }
124
+ ];
125
+
126
+ class Shema {
127
+ constructor() {
128
+ this.type = '';
129
+ }
130
+ }
131
+
132
+ class CrudConfig {
133
+ constructor() {
134
+ this.idEntidad = '';
135
+ this.tablero = new ConfigTablero();
136
+ this.esquema = new Shema();
137
+ this.registro = new ConfigRegistro();
138
+ }
139
+ }
140
+ class ConfigTablero {
141
+ constructor() {
142
+ this.columns = [];
143
+ this.endpoint = '';
144
+ this.method = '';
145
+ this.server = '';
146
+ this.key = '';
147
+ this.filters = [];
148
+ }
149
+ }
150
+ class ConfigRegistro {
151
+ constructor() {
152
+ this.operations = [];
153
+ this.btnBack = '';
154
+ }
155
+ }
156
+ class Operations {
157
+ constructor() {
158
+ this.type = '';
159
+ this.server = '';
160
+ this.endpoint = '';
161
+ this.method = '';
162
+ this.validations = new Validations();
163
+ }
164
+ }
165
+ class Validations {
166
+ constructor() {
167
+ this.type = '';
168
+ this.required = [];
169
+ this.server = '';
170
+ this.endpoint = '';
171
+ }
172
+ }
173
+
174
+ class TableroComponent {
175
+ constructor(generalService, router) {
176
+ this.generalService = generalService;
177
+ this.router = router;
178
+ this.opciones = [];
179
+ this.idEntidad = '';
180
+ this.idKatios = '';
181
+ this.crudConfig = new CrudConfig();
182
+ this.enProceso = false;
183
+ this.data = [];
184
+ this.btn = { create: undefined, read: undefined, update: undefined, delete: undefined };
185
+ }
186
+ ngOnInit() {
187
+ this.loadConfigCrud();
188
+ }
189
+ loadConfigCrud() {
190
+ this.enProceso = true;
191
+ this.generalService.getCrudByEntidad(this.idKatios, this.idEntidad)
192
+ .then(res => {
193
+ this.crudConfig = res;
194
+ this.getInfoTablero(this.crudConfig.tablero);
195
+ this.loadOptions();
196
+ })
197
+ .catch(err => {
198
+ console.log(err);
199
+ this.enProceso = false;
200
+ });
201
+ }
202
+ getInfoTablero(configTablero) {
203
+ this.generalService.genericRequest(configTablero.method, configTablero.server, configTablero.endpoint)
204
+ .then((res) => {
205
+ this.data = res.data;
206
+ this.enProceso = false;
207
+ })
208
+ .catch(err => {
209
+ console.log(err);
210
+ this.enProceso = false;
211
+ });
212
+ }
213
+ loadOptions() {
214
+ this.btn.create = this.opciones.find(x => x.label == 'Crear');
215
+ this.btn.read = this.opciones.find(x => x.label == 'Visualizar');
216
+ this.btn.update = this.opciones.find(x => x.label == 'Editar');
217
+ this.btn.delete = this.opciones.find(x => x.label == 'Eliminar');
218
+ }
219
+ redirect(data, accion) {
220
+ var _a, _b;
221
+ switch (accion) {
222
+ case 'create':
223
+ this.router.navigateByUrl(((_b = (_a = this.btn.create) === null || _a === void 0 ? void 0 : _a.valor) === null || _b === void 0 ? void 0 : _b.redirect) || '');
224
+ break;
225
+ case 'read':
226
+ this.router.navigateByUrl(this.btn.read.valor.redirect.replace('$id', data[this.crudConfig.tablero.key]));
227
+ break;
228
+ case 'update':
229
+ this.router.navigateByUrl(this.btn.update.valor.redirect.replace('$id', data[this.crudConfig.tablero.key]));
230
+ break;
231
+ case 'delete':
232
+ this.router.navigateByUrl(this.btn.delete.valor.redirect.replace('$id', data[this.crudConfig.tablero.key]));
233
+ break;
234
+ default:
235
+ break;
236
+ }
237
+ }
238
+ }
239
+ TableroComponent.decorators = [
240
+ { type: Component, args: [{
241
+ selector: 'sf-crudtablero',
242
+ 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(rowData, '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(rowData, 'read')\"></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(rowData, 'update')\"></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(rowData, 'delete')\"></button>\r\n </th>\r\n </tr>\r\n </ng-template>\r\n </p-table>\r\n</div>"
243
+ },] }
244
+ ];
245
+ TableroComponent.ctorParameters = () => [
246
+ { type: GeneralService },
247
+ { type: Router }
248
+ ];
249
+ TableroComponent.propDecorators = {
250
+ opciones: [{ type: Input }],
251
+ idEntidad: [{ type: Input }],
252
+ idKatios: [{ type: Input }]
253
+ };
254
+
255
+ class RegistroComponent {
256
+ constructor(generalService, router, messageSerice) {
257
+ this.generalService = generalService;
258
+ this.router = router;
259
+ this.messageSerice = messageSerice;
260
+ this.idKatios = '';
261
+ this.idEntidad = '';
262
+ this.trx = '';
263
+ this.id = '';
264
+ this.enProceso = false;
265
+ this.crudConfig = new CrudConfig();
266
+ this.configOperation = new Operations();
267
+ }
268
+ ngOnInit() {
269
+ this.loadConfigCrud();
270
+ this.setLabelSumbit();
271
+ }
272
+ loadConfigCrud() {
273
+ this.enProceso = true;
274
+ this.generalService.getCrudByEntidad(this.idKatios, this.idEntidad)
275
+ .then(res => {
276
+ this.crudConfig = res;
277
+ if (this.trx != 'c')
278
+ this.getInfoRegistro(this.crudConfig.registro);
279
+ else {
280
+ this.data = this.createObject(this.crudConfig.esquema);
281
+ this.enProceso = false;
282
+ }
283
+ this.configOperation = this.crudConfig.registro.operations.find(x => x.type.startsWith(this.trx)) || new Operations();
284
+ })
285
+ .catch(err => {
286
+ console.log(err);
287
+ this.enProceso = false;
288
+ });
289
+ }
290
+ setLabelSumbit() {
291
+ if (this.trx == 'c')
292
+ this.btnSubmit = { label: 'Guardar', icon: 'pi pi-save' };
293
+ else if (this.trx == 'r')
294
+ this.btnSubmit = undefined;
295
+ else if (this.trx == 'u')
296
+ this.btnSubmit = { label: 'Actualizar', icon: 'pi pi-sync' };
297
+ else if (this.trx == 'd')
298
+ this.btnSubmit = { label: 'Eliminar', icon: 'pi pi-trash' };
299
+ }
300
+ getInfoRegistro(configRegistro) {
301
+ let op = configRegistro.operations.find(x => x.type == 'read');
302
+ let endpoint = (op === null || op === void 0 ? void 0 : op.endpoint) || '';
303
+ endpoint = endpoint.replace('@idKatios', this.idKatios);
304
+ endpoint = endpoint.replace('@id', this.id);
305
+ this.generalService.genericRequest((op === null || op === void 0 ? void 0 : op.method) || '', (op === null || op === void 0 ? void 0 : op.server) || '', endpoint)
306
+ .then((res) => {
307
+ this.data = res.data;
308
+ this.enProceso = false;
309
+ })
310
+ .catch(err => {
311
+ console.log(err);
312
+ this.enProceso = false;
313
+ });
314
+ }
315
+ back() {
316
+ this.router.navigateByUrl(this.crudConfig.registro.btnBack);
317
+ }
318
+ getControl(scope) {
319
+ return query(this.crudConfig.esquema, scope)[0];
320
+ }
321
+ getValue(scope) {
322
+ return query(this.data, scope.replace('.properties', ''))[0];
323
+ }
324
+ setValue(value$1, scope) {
325
+ value(this.data, scope.replace('.properties', ''), value$1);
326
+ }
327
+ createObject(esquema) {
328
+ let object = {};
329
+ switch (esquema.type) {
330
+ case 'string':
331
+ case 'number':
332
+ return (esquema === null || esquema === void 0 ? void 0 : esquema.default) || null;
333
+ case 'boolean':
334
+ return (esquema === null || esquema === void 0 ? void 0 : esquema.default) || false;
335
+ case 'object':
336
+ for (const key in esquema === null || esquema === void 0 ? void 0 : esquema.properties) {
337
+ Object.defineProperty(object, key, { value: this.createObject(esquema === null || esquema === void 0 ? void 0 : esquema.properties[key]), writable: true, enumerable: true, configurable: true });
338
+ }
339
+ break;
340
+ default:
341
+ break;
342
+ }
343
+ return object;
344
+ }
345
+ submit() {
346
+ if (!this.validateData())
347
+ return;
348
+ this.enProceso = true;
349
+ let endpoint = this.configOperation.endpoint;
350
+ endpoint = endpoint.replace('@idKatios', this.idKatios);
351
+ endpoint = endpoint.replace('@id', this.id);
352
+ this.generalService.genericRequest(this.configOperation.method, this.configOperation.server, endpoint, this.data)
353
+ .then(() => {
354
+ this.messageSerice.add({ severity: 'success', detail: `Proceso exitoso!` });
355
+ setTimeout(() => {
356
+ this.enProceso = false;
357
+ this.back();
358
+ }, 2000);
359
+ })
360
+ .catch(err => {
361
+ var _a;
362
+ 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.'}` });
363
+ this.enProceso = false;
364
+ });
365
+ }
366
+ validateData() {
367
+ if (this.configOperation.validations.type == 'local')
368
+ return this.validateDataLocal();
369
+ return true;
370
+ }
371
+ validateDataLocal() {
372
+ let err = [];
373
+ this.configOperation.validations.required.forEach(x => {
374
+ if (!query(this.data, x.field)[0])
375
+ err.push(x.message);
376
+ });
377
+ if (err.length != 0)
378
+ this.messageSerice.add({ severity: 'warn', detail: err.join('. ') });
379
+ return err.length == 0;
380
+ }
381
+ }
382
+ RegistroComponent.decorators = [
383
+ { type: Component, args: [{
384
+ selector: 'sf-registro',
385
+ 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>",
386
+ providers: [MessageService]
387
+ },] }
388
+ ];
389
+ RegistroComponent.ctorParameters = () => [
390
+ { type: GeneralService },
391
+ { type: Router },
392
+ { type: MessageService }
393
+ ];
394
+ RegistroComponent.propDecorators = {
395
+ idKatios: [{ type: Input }],
396
+ idEntidad: [{ type: Input }],
397
+ trx: [{ type: Input }],
398
+ id: [{ type: Input }]
399
+ };
400
+
401
+ class SfCrudComponent {
402
+ constructor() { }
403
+ ngOnInit() {
404
+ }
405
+ }
406
+ SfCrudComponent.decorators = [
407
+ { type: Component, args: [{
408
+ selector: 'lib-sf-crud',
409
+ template: `
410
+ <p>
411
+ sf-crud works!
412
+ </p>
413
+ `
414
+ },] }
415
+ ];
416
+ SfCrudComponent.ctorParameters = () => [];
417
+
418
+ class ControlComponent {
419
+ constructor() {
420
+ this.label = '';
421
+ this.setValue = new EventEmitter();
422
+ }
423
+ ngOnInit() {
424
+ }
425
+ sendValue() {
426
+ this.setValue.emit(this.value);
427
+ }
428
+ }
429
+ ControlComponent.decorators = [
430
+ { type: Component, args: [{
431
+ selector: 'sf-control',
432
+ template: "<ng-container [ngSwitch]=\"control.type\">\r\n <ng-container *ngSwitchCase=\"'string'\">\r\n <label>{{label}}</label>\r\n <ng-container *ngIf=\"!control?.enum\">\r\n <input pInputText type=\"text\" [(ngModel)]=\"value\" (focusout)=\"sendValue()\">\r\n </ng-container>\r\n <ng-container *ngIf=\"control?.enum\">\r\n <p-dropdown [options]=\"control.enum\" [(ngModel)]=\"value\" (onChange)=\"sendValue()\" placeholder=\"Seleccione una opci\u00F3n\"></p-dropdown>\r\n </ng-container>\r\n </ng-container>\r\n</ng-container>\r\n"
433
+ },] }
434
+ ];
435
+ ControlComponent.ctorParameters = () => [];
436
+ ControlComponent.propDecorators = {
437
+ control: [{ type: Input }],
438
+ label: [{ type: Input }],
439
+ value: [{ type: Input }],
440
+ setValue: [{ type: Output }]
441
+ };
442
+
443
+ class SfCrudModule {
444
+ }
445
+ SfCrudModule.decorators = [
446
+ { type: NgModule, args: [{
447
+ declarations: [
448
+ SfCrudComponent,
449
+ TableroComponent,
450
+ RegistroComponent,
451
+ ControlComponent
452
+ ],
453
+ imports: [
454
+ AccordionModule,
455
+ AvatarGroupModule,
456
+ AvatarModule,
457
+ BadgeModule,
458
+ BlockUIModule,
459
+ BreadcrumbModule,
460
+ ButtonModule,
461
+ CalendarModule,
462
+ CardModule,
463
+ CarouselModule,
464
+ CascadeSelectModule,
465
+ CheckboxModule,
466
+ ChipModule,
467
+ ChipsModule,
468
+ CodeHighlighterModule,
469
+ ColorPickerModule,
470
+ ConfirmDialogModule,
471
+ ConfirmPopupModule,
472
+ ContextMenuModule,
473
+ DialogModule,
474
+ DividerModule,
475
+ DropdownModule,
476
+ FieldsetModule,
477
+ FileUploadModule,
478
+ FormsModule,
479
+ GalleriaModule,
480
+ HttpClientModule,
481
+ InplaceModule,
482
+ InputMaskModule,
483
+ InputNumberModule,
484
+ InputSwitchModule,
485
+ InputTextareaModule,
486
+ InputTextModule,
487
+ KnobModule,
488
+ LightboxModule,
489
+ ListboxModule,
490
+ MegaMenuModule,
491
+ MenubarModule,
492
+ MenuModule,
493
+ MessageModule,
494
+ MessagesModule,
495
+ MultiSelectModule,
496
+ OrganizationChartModule,
497
+ OverlayPanelModule,
498
+ PanelMenuModule,
499
+ PanelModule,
500
+ PasswordModule,
501
+ ProgressBarModule,
502
+ RadioButtonModule,
503
+ RatingModule,
504
+ RippleModule,
505
+ ScrollPanelModule,
506
+ ScrollTopModule,
507
+ SelectButtonModule,
508
+ SidebarModule,
509
+ SkeletonModule,
510
+ SlideMenuModule,
511
+ SliderModule,
512
+ SplitterModule,
513
+ StepsModule,
514
+ TableModule,
515
+ TabMenuModule,
516
+ TabViewModule,
517
+ TagModule,
518
+ TerminalModule,
519
+ TieredMenuModule,
520
+ TimelineModule,
521
+ ToastModule,
522
+ ToggleButtonModule,
523
+ ToolbarModule,
524
+ TooltipModule,
525
+ TreeModule,
526
+ ],
527
+ exports: [
528
+ SfCrudComponent,
529
+ TableroComponent,
530
+ RegistroComponent
531
+ ]
532
+ },] }
533
+ ];
534
+
535
+ class SfCrudService {
536
+ constructor() { }
537
+ }
538
+ SfCrudService.ɵprov = ɵɵdefineInjectable({ factory: function SfCrudService_Factory() { return new SfCrudService(); }, token: SfCrudService, providedIn: "root" });
539
+ SfCrudService.decorators = [
540
+ { type: Injectable, args: [{
541
+ providedIn: 'root'
542
+ },] }
543
+ ];
544
+ SfCrudService.ctorParameters = () => [];
545
+
546
+ /*
547
+ * Public API Surface of sf-crud
548
+ */
549
+
550
+ /**
551
+ * Generated bundle index. Do not edit.
552
+ */
553
+
554
+ export { RegistroComponent, SfCrudComponent, SfCrudModule, SfCrudService, TableroComponent, GeneralService as ɵa, ControlComponent as ɵb };
555
+ //# sourceMappingURL=sf-crud.js.map