tuain-ng-forms-lib 14.0.2 → 14.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 (99) hide show
  1. package/esm2020/lib/classes/forms/action.mjs +35 -0
  2. package/esm2020/lib/classes/forms/element.mjs +76 -0
  3. package/esm2020/lib/classes/forms/field.mjs +321 -0
  4. package/esm2020/lib/classes/forms/form.constants.mjs +26 -0
  5. package/esm2020/lib/classes/forms/form.mjs +422 -0
  6. package/esm2020/lib/classes/forms/section.mjs +132 -0
  7. package/esm2020/lib/classes/forms/subsection.mjs +70 -0
  8. package/esm2020/lib/classes/forms/table/action.mjs +22 -0
  9. package/esm2020/lib/classes/forms/table/column.mjs +61 -0
  10. package/esm2020/lib/classes/forms/table/row-data.mjs +111 -0
  11. package/esm2020/lib/classes/forms/table/table.mjs +372 -0
  12. package/esm2020/lib/components/elements/action.component.mjs +58 -0
  13. package/esm2020/lib/components/elements/field.component.mjs +90 -0
  14. package/esm2020/lib/components/elements/layout/element.component.mjs +31 -0
  15. package/esm2020/lib/components/elements/layout/form-error.component.mjs +20 -0
  16. package/esm2020/lib/components/elements/layout/form-header.component.mjs +30 -0
  17. package/esm2020/lib/components/elements/layout/section.component.mjs +22 -0
  18. package/esm2020/lib/components/elements/layout/sub-section.component.mjs +24 -0
  19. package/esm2020/lib/components/elements/tables/table-record-action.component.mjs +40 -0
  20. package/esm2020/lib/components/elements/tables/table-record-field.component.mjs +25 -0
  21. package/esm2020/lib/components/elements/tables/table.component.mjs +95 -0
  22. package/esm2020/lib/components/forms/basic-form.mjs +1425 -0
  23. package/esm2020/lib/services/event-manager.service.mjs +18 -0
  24. package/esm2020/lib/services/file-manager.service.mjs +6 -0
  25. package/esm2020/lib/services/form-manager.service.mjs +80 -0
  26. package/esm2020/lib/tuain-ng-forms-lib.module.mjs +71 -0
  27. package/esm2020/public-api.mjs +19 -0
  28. package/esm2020/tuain-ng-forms-lib.mjs +5 -0
  29. package/fesm2015/tuain-ng-forms-lib.mjs +3803 -0
  30. package/fesm2015/tuain-ng-forms-lib.mjs.map +1 -0
  31. package/fesm2020/tuain-ng-forms-lib.mjs +3634 -0
  32. package/fesm2020/tuain-ng-forms-lib.mjs.map +1 -0
  33. package/lib/classes/forms/action.d.ts +22 -0
  34. package/lib/classes/forms/element.d.ts +41 -0
  35. package/lib/classes/forms/field.d.ts +109 -0
  36. package/lib/classes/forms/form.constants.d.ts +25 -0
  37. package/lib/classes/forms/form.d.ts +134 -0
  38. package/lib/classes/forms/section.d.ts +39 -0
  39. package/lib/classes/forms/subsection.d.ts +26 -0
  40. package/lib/classes/forms/table/action.d.ts +20 -0
  41. package/lib/classes/forms/table/column.d.ts +33 -0
  42. package/lib/classes/forms/table/row-data.d.ts +14 -0
  43. package/lib/classes/forms/table/table.d.ts +100 -0
  44. package/lib/components/elements/action.component.d.ts +21 -0
  45. package/lib/components/elements/field.component.d.ts +43 -0
  46. package/lib/components/elements/layout/element.component.d.ts +14 -0
  47. package/lib/components/elements/layout/form-error.component.d.ts +8 -0
  48. package/lib/components/elements/layout/form-header.component.d.ts +12 -0
  49. package/lib/components/elements/layout/section.component.d.ts +10 -0
  50. package/lib/components/elements/layout/sub-section.component.d.ts +11 -0
  51. package/lib/components/elements/tables/table-record-action.component.d.ts +15 -0
  52. package/lib/components/elements/tables/table-record-field.component.d.ts +11 -0
  53. package/lib/components/elements/tables/table.component.d.ts +47 -0
  54. package/lib/components/forms/basic-form.d.ts +307 -0
  55. package/lib/services/event-manager.service.d.ts +9 -0
  56. package/lib/services/file-manager.service.d.ts +5 -0
  57. package/lib/services/form-manager.service.d.ts +28 -0
  58. package/lib/tuain-ng-forms-lib.module.d.ts +20 -0
  59. package/package.json +22 -2
  60. package/{src/public-api.ts → public-api.d.ts} +0 -5
  61. package/tuain-ng-forms-lib.d.ts +5 -0
  62. package/.browserslistrc +0 -16
  63. package/.yarn/cache/nanoid-npm-4.0.0-924f5c6312-7d5946df5c.zip +0 -0
  64. package/.yarn/cache/tslib-npm-2.4.0-9cb6dc5030-8c4aa6a3c5.zip +0 -0
  65. package/.yarn/cache/yn-npm-5.0.0-b001dab23c-f0ec7710d3.zip +0 -0
  66. package/.yarn/install-state.gz +0 -0
  67. package/karma.conf.js +0 -44
  68. package/ng-package.json +0 -11
  69. package/src/lib/classes/forms/action.ts +0 -55
  70. package/src/lib/classes/forms/element.ts +0 -98
  71. package/src/lib/classes/forms/field.ts +0 -408
  72. package/src/lib/classes/forms/form.constants.ts +0 -28
  73. package/src/lib/classes/forms/form.ts +0 -495
  74. package/src/lib/classes/forms/section.ts +0 -154
  75. package/src/lib/classes/forms/subsection.ts +0 -91
  76. package/src/lib/classes/forms/table/action.ts +0 -41
  77. package/src/lib/classes/forms/table/column.ts +0 -91
  78. package/src/lib/classes/forms/table/row-data.ts +0 -118
  79. package/src/lib/classes/forms/table/table.ts +0 -438
  80. package/src/lib/components/elements/action.component.ts +0 -53
  81. package/src/lib/components/elements/field.component.ts +0 -118
  82. package/src/lib/components/elements/layout/element.component.ts +0 -28
  83. package/src/lib/components/elements/layout/form-error.component.ts +0 -11
  84. package/src/lib/components/elements/layout/form-header.component.ts +0 -17
  85. package/src/lib/components/elements/layout/section.component.ts +0 -16
  86. package/src/lib/components/elements/layout/sub-section.component.ts +0 -17
  87. package/src/lib/components/elements/tables/table-record-action.component.ts +0 -37
  88. package/src/lib/components/elements/tables/table-record-field.component.ts +0 -19
  89. package/src/lib/components/elements/tables/table.component.ts +0 -102
  90. package/src/lib/components/forms/basic-form.ts +0 -1496
  91. package/src/lib/services/event-manager.service.ts +0 -21
  92. package/src/lib/services/file-manager.service.ts +0 -6
  93. package/src/lib/services/form-manager.service.ts +0 -89
  94. package/src/lib/services/icon-dictionary.service.ts +0 -159
  95. package/src/lib/tuain-ng-forms-lib.module.ts +0 -40
  96. package/src/test.ts +0 -27
  97. package/tsconfig.lib.json +0 -15
  98. package/tsconfig.lib.prod.json +0 -10
  99. package/tsconfig.spec.json +0 -17
@@ -0,0 +1,3634 @@
1
+ import * as i0 from '@angular/core';
2
+ import { Component, Input, EventEmitter, Output, ChangeDetectionStrategy, NgModule } from '@angular/core';
3
+ import { Subject, ReplaySubject } from 'rxjs';
4
+ import yn from 'yn';
5
+ import { nanoid } from 'nanoid';
6
+ import { CommonModule } from '@angular/common';
7
+ import { RouterModule } from '@angular/router';
8
+ import { FormsModule } from '@angular/forms';
9
+
10
+ class ActionComponent {
11
+ constructor() {
12
+ this.style = 'primary';
13
+ this.showLabel = true;
14
+ }
15
+ ngOnInit() {
16
+ this.formConfig = this.action?._formConfig;
17
+ this.start();
18
+ }
19
+ start() { }
20
+ activate() {
21
+ if (this.action?.notifyActivation) {
22
+ this.action.notifyActivation();
23
+ }
24
+ }
25
+ visibleOnRestriction() {
26
+ if (!this.action?.restrictedOnField) {
27
+ return true;
28
+ }
29
+ if ((this.action?.restrictedOnOperator === '=='
30
+ && this.relatedField === this.action?.restrictedOnValue)
31
+ || (this.action?.restrictedOnOperator === '!='
32
+ && this.relatedField !== this.action?.restrictedOnValue)) {
33
+ return true;
34
+ }
35
+ return false;
36
+ }
37
+ get visible() {
38
+ return this.action?.visibleOn(this.state) && this.visibleOnRestriction();
39
+ }
40
+ get disabled() {
41
+ return !(this.action?.enabledOn(this.state));
42
+ }
43
+ }
44
+ ActionComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: ActionComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
45
+ ActionComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.6", type: ActionComponent, selector: "lib-action", inputs: { action: "action", busy: "busy", relatedField: "relatedField", state: "state", style: "style", showLabel: "showLabel" }, ngImport: i0, template: `<ng-content></ng-content>`, isInline: true });
46
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: ActionComponent, decorators: [{
47
+ type: Component,
48
+ args: [{
49
+ selector: 'lib-action',
50
+ template: `<ng-content></ng-content>`
51
+ }]
52
+ }], propDecorators: { action: [{
53
+ type: Input
54
+ }], busy: [{
55
+ type: Input
56
+ }], relatedField: [{
57
+ type: Input
58
+ }], state: [{
59
+ type: Input
60
+ }], style: [{
61
+ type: Input
62
+ }], showLabel: [{
63
+ type: Input
64
+ }] } });
65
+
66
+ const VALUE = 'value';
67
+ const FOCUS = 'focus';
68
+ class FieldComponent {
69
+ ngOnInit() {
70
+ if (this.field) {
71
+ this.formConfig = this.field?._formConfig;
72
+ // Inicialización
73
+ const mapping = Object.entries(this.formConfig.componentFieldAttrMap);
74
+ for (let index = 0; index < mapping.length; index++) {
75
+ const [fieldAttr1, compAttr1] = mapping[index];
76
+ const compAttr = compAttr1.toString();
77
+ const fieldAttr = fieldAttr1.toString();
78
+ const attributeValue = this.field?.[fieldAttr];
79
+ this.dafaultProcessFieldChange(compAttr, attributeValue);
80
+ this.processFieldChange(compAttr, attributeValue);
81
+ }
82
+ // Subscripción a cambios en atributos
83
+ this.field.attributeChange.subscribe(event => {
84
+ const { name: fieldAttr, value } = event;
85
+ const compAttr = this.formConfig.componentFieldAttrMap[fieldAttr];
86
+ this.dafaultProcessFieldChange(compAttr, value);
87
+ this.processFieldChange(compAttr, value);
88
+ });
89
+ }
90
+ this.start();
91
+ }
92
+ dafaultProcessFieldChange(attribute, value) {
93
+ if (attribute === VALUE) {
94
+ this.updateValue();
95
+ }
96
+ else if (attribute === FOCUS) {
97
+ this.focus();
98
+ }
99
+ else {
100
+ this[attribute] = value;
101
+ }
102
+ }
103
+ processFieldChange(attribute, value) { }
104
+ start() { }
105
+ focus() { }
106
+ updateObject() {
107
+ this.field.setValue(this.value);
108
+ }
109
+ inputChanged() {
110
+ this.field.setValue(this.value);
111
+ this.onChangeContent();
112
+ }
113
+ inputTyped() {
114
+ this.field.setValue(this.value);
115
+ this.onInputChange();
116
+ }
117
+ updateValue() {
118
+ this.value = this.field.getValue();
119
+ }
120
+ onInputChange() {
121
+ setTimeout(() => this.field.notifyEditionPartial(), 50);
122
+ }
123
+ onChangeContent() {
124
+ setTimeout(() => this.field.notifyEditionFinish(), 50);
125
+ }
126
+ onShowInfo(detail = null) {
127
+ setTimeout(() => this.field.notifyEditionDetailRequest(detail), 50);
128
+ }
129
+ numberInputValidation(event) {
130
+ const k = event.charCode;
131
+ return (k > 47 && k < 58);
132
+ }
133
+ get visible() {
134
+ return this.field?.visibleOn(this.state);
135
+ }
136
+ get disabled() {
137
+ return !this.field?.enabledOn(this.state);
138
+ }
139
+ }
140
+ FieldComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: FieldComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
141
+ FieldComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.6", type: FieldComponent, selector: "lib-field", inputs: { field: "field", state: "state" }, ngImport: i0, template: `<ng-content></ng-content>`, isInline: true });
142
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: FieldComponent, decorators: [{
143
+ type: Component,
144
+ args: [{
145
+ selector: 'lib-field',
146
+ template: `<ng-content></ng-content>`
147
+ }]
148
+ }], propDecorators: { field: [{
149
+ type: Input
150
+ }], state: [{
151
+ type: Input
152
+ }] } });
153
+
154
+ class ElementComponent {
155
+ ngOnInit() {
156
+ this.formConfig = this.element?._formConfig;
157
+ this.start();
158
+ }
159
+ start() { }
160
+ get visible() {
161
+ return this.element?.visibleOn(this.state);
162
+ }
163
+ get disabled() {
164
+ return !this.element?.enabledOn(this.state);
165
+ }
166
+ }
167
+ ElementComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: ElementComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
168
+ ElementComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.6", type: ElementComponent, selector: "lib-element", inputs: { element: "element", form: "form", state: "state" }, ngImport: i0, template: `<ng-content></ng-content>`, isInline: true });
169
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: ElementComponent, decorators: [{
170
+ type: Component,
171
+ args: [{
172
+ selector: 'lib-element',
173
+ template: `<ng-content></ng-content>`
174
+ }]
175
+ }], propDecorators: { element: [{
176
+ type: Input
177
+ }], form: [{
178
+ type: Input
179
+ }], state: [{
180
+ type: Input
181
+ }] } });
182
+
183
+ class FormErrorComponent {
184
+ }
185
+ FormErrorComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: FormErrorComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
186
+ FormErrorComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.6", type: FormErrorComponent, selector: "lib-form-error", inputs: { errorTitle: "errorTitle", errorMessage: "errorMessage", errorType: "errorType" }, ngImport: i0, template: `<ng-content></ng-content>`, isInline: true });
187
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: FormErrorComponent, decorators: [{
188
+ type: Component,
189
+ args: [{
190
+ selector: 'lib-form-error',
191
+ template: `<ng-content></ng-content>`
192
+ }]
193
+ }], propDecorators: { errorTitle: [{
194
+ type: Input
195
+ }], errorMessage: [{
196
+ type: Input
197
+ }], errorType: [{
198
+ type: Input
199
+ }] } });
200
+
201
+ class FormHeaderComponent {
202
+ constructor() {
203
+ this.goBackEvent = new EventEmitter();
204
+ }
205
+ goBackForm() {
206
+ this.goBackEvent.emit();
207
+ }
208
+ }
209
+ FormHeaderComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: FormHeaderComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
210
+ FormHeaderComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.6", type: FormHeaderComponent, selector: "lib-form-header", inputs: { formManager: "formManager", goBackAction: "goBackAction", showTitle: "showTitle", headerActions: "headerActions" }, outputs: { goBackEvent: "goBackEvent" }, ngImport: i0, template: `<ng-content></ng-content>`, isInline: true });
211
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: FormHeaderComponent, decorators: [{
212
+ type: Component,
213
+ args: [{
214
+ selector: 'lib-form-header',
215
+ template: `<ng-content></ng-content>`
216
+ }]
217
+ }], propDecorators: { formManager: [{
218
+ type: Input
219
+ }], goBackAction: [{
220
+ type: Input
221
+ }], showTitle: [{
222
+ type: Input
223
+ }], headerActions: [{
224
+ type: Input
225
+ }], goBackEvent: [{
226
+ type: Output
227
+ }] } });
228
+
229
+ class SectionComponent {
230
+ ngOnInit() {
231
+ this.start();
232
+ }
233
+ start() { }
234
+ }
235
+ SectionComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: SectionComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
236
+ SectionComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.6", type: SectionComponent, selector: "lib-section", inputs: { section: "section", formManager: "formManager" }, ngImport: i0, template: `<ng-content></ng-content>`, isInline: true });
237
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: SectionComponent, decorators: [{
238
+ type: Component,
239
+ args: [{
240
+ selector: 'lib-section',
241
+ template: `<ng-content></ng-content>`
242
+ }]
243
+ }], propDecorators: { section: [{
244
+ type: Input
245
+ }], formManager: [{
246
+ type: Input
247
+ }] } });
248
+
249
+ class SubSectionComponent {
250
+ ngOnInit() {
251
+ this.start();
252
+ }
253
+ start() { }
254
+ }
255
+ SubSectionComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: SubSectionComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
256
+ SubSectionComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.6", type: SubSectionComponent, selector: "lib-subsection", inputs: { subSection: "subSection", showHeader: "showHeader", formManager: "formManager" }, ngImport: i0, template: `<ng-content></ng-content>`, isInline: true });
257
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: SubSectionComponent, decorators: [{
258
+ type: Component,
259
+ args: [{
260
+ selector: 'lib-subsection',
261
+ template: `<ng-content></ng-content>`
262
+ }]
263
+ }], propDecorators: { subSection: [{
264
+ type: Input
265
+ }], showHeader: [{
266
+ type: Input
267
+ }], formManager: [{
268
+ type: Input
269
+ }] } });
270
+
271
+ const INLINE_ACTION$1 = 'INLINE';
272
+ class LibTableRecordActionComponent {
273
+ constructor() {
274
+ this.actionSelected = new EventEmitter();
275
+ }
276
+ ngOnInit() {
277
+ this.start();
278
+ }
279
+ start() { }
280
+ onActivate() {
281
+ const tableEvent = {
282
+ actionCode: this.action.actionCode,
283
+ recordId: this.recordId,
284
+ recordData: this.recordData,
285
+ };
286
+ this.actionSelected.emit(tableEvent);
287
+ }
288
+ class() { }
289
+ }
290
+ LibTableRecordActionComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: LibTableRecordActionComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
291
+ LibTableRecordActionComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.6", type: LibTableRecordActionComponent, selector: "lib-table-record-action", inputs: { recordId: "recordId", recordData: "recordData", action: "action" }, outputs: { actionSelected: "actionSelected" }, ngImport: i0, template: `<ng-content></ng-content>`, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush });
292
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: LibTableRecordActionComponent, decorators: [{
293
+ type: Component,
294
+ args: [{
295
+ selector: 'lib-table-record-action',
296
+ template: `<ng-content></ng-content>`,
297
+ changeDetection: ChangeDetectionStrategy.OnPush
298
+ }]
299
+ }], ctorParameters: function () { return []; }, propDecorators: { recordId: [{
300
+ type: Input
301
+ }], recordData: [{
302
+ type: Input
303
+ }], action: [{
304
+ type: Input
305
+ }], actionSelected: [{
306
+ type: Output
307
+ }] } });
308
+
309
+ class LibTableRecordFieldComponent {
310
+ ngOnInit() {
311
+ this.start();
312
+ }
313
+ start() { }
314
+ }
315
+ LibTableRecordFieldComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: LibTableRecordFieldComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
316
+ LibTableRecordFieldComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.6", type: LibTableRecordFieldComponent, selector: "lib-table-record-field", inputs: { fieldCode: "fieldCode", fieldType: "fieldType", fieldValue: "fieldValue" }, ngImport: i0, template: `<ng-content></ng-content>`, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush });
317
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: LibTableRecordFieldComponent, decorators: [{
318
+ type: Component,
319
+ args: [{
320
+ selector: 'lib-table-record-field',
321
+ template: `<ng-content></ng-content>`,
322
+ changeDetection: ChangeDetectionStrategy.OnPush
323
+ }]
324
+ }], propDecorators: { fieldCode: [{
325
+ type: Input
326
+ }], fieldType: [{
327
+ type: Input
328
+ }], fieldValue: [{
329
+ type: Input
330
+ }] } });
331
+
332
+ const changeViewAttributes = ['visibleRecords', 'currentPage', 'recordsPerPage'];
333
+ class LibTableComponent {
334
+ constructor() {
335
+ this.globalFilterString = '';
336
+ this.currentPage = 1;
337
+ this.globalSearch = false;
338
+ this.selectedRecords = [];
339
+ this.totalRecordsNumber = 0;
340
+ this.allSelected = false;
341
+ this.loaded = false;
342
+ this.selectable = false;
343
+ this.hasActions = false;
344
+ this.disabled = false;
345
+ }
346
+ ngOnInit() {
347
+ if (this.table) {
348
+ this.formConfig = this.table?._formConfig;
349
+ this.tableFieldStyles = this.formConfig.tableFieldStyles;
350
+ this.selectable = this.table.selectable;
351
+ this.hasActions = this.table.hasActions();
352
+ this.inlineActions = this.table.getActions(this.formConfig.tableActions.inline);
353
+ this.globalActions = this.table.getActions(this.formConfig.tableActions.global);
354
+ this.selectionActions = this.table.getActions(this.formConfig.tableActions.selection);
355
+ // Inicialización de campos mapeados del objeto
356
+ const mapping = Object.entries(this.formConfig.componentTableAttrMap);
357
+ for (let index = 0; index < mapping.length; index++) {
358
+ const [tableAttrRaw, compAttrRaw] = mapping[index];
359
+ const tableAttr = tableAttrRaw.toString();
360
+ const compAttr = compAttrRaw.toString();
361
+ this.syncAttribute(compAttr, this.table[tableAttr]);
362
+ }
363
+ // Subscripción a cambios en atributos
364
+ this.table.attributeChange.subscribe(event => {
365
+ const { name: tableAttr, value } = event;
366
+ const compAttr = this.formConfig.componentTableAttrMap[tableAttr];
367
+ this.syncAttribute(compAttr, value);
368
+ });
369
+ }
370
+ this.start();
371
+ }
372
+ start() { }
373
+ updateTableData() { }
374
+ tableGlobalAction(actionCode) { this.table.notifyGlobalAction(actionCode); }
375
+ tableSelectionAction(actionCode) { this.table.notifySelectionAction(actionCode); }
376
+ tableActionSelected(actionEvent) { this.table.notifyInlineAction(actionEvent); }
377
+ tableSelectionToggle(recordId) { this.table.notifyRecordSelection(recordId); }
378
+ toggleSelectAll() { return (this.allSelected) ? this.table.unSelectAll() : this.table.selectAll(); }
379
+ globalFilterCompleted() { this.changePage(1); }
380
+ changePage(requestedPage) { this.table.changePage(requestedPage); }
381
+ tableColumnSort(columnName, direction = null) { this.table.sort(columnName, direction ?? 'ascend'); }
382
+ globalFilterChanged() { this.table.setGlobalFilterString(this.globalFilterString?.trim() ?? ''); }
383
+ syncAttribute(name, value) {
384
+ try {
385
+ if (name === 'visibleRecords') {
386
+ this.updateTableData();
387
+ }
388
+ this[name] = value;
389
+ return true;
390
+ }
391
+ catch {
392
+ return false;
393
+ }
394
+ }
395
+ filterHasChanged(column, values) {
396
+ if (!values || values.length === 0) {
397
+ this.table.removeColumnFilter(column.fieldCode);
398
+ }
399
+ else {
400
+ this.table.addColumnFilter(column.fieldCode, values);
401
+ }
402
+ }
403
+ }
404
+ LibTableComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: LibTableComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
405
+ LibTableComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.6", type: LibTableComponent, selector: "lib-table", inputs: { table: "table", tableRecords: "tableRecords", disabled: "disabled", state: "state", waiting: "waiting" }, ngImport: i0, template: `<ng-content></ng-content>`, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush });
406
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: LibTableComponent, decorators: [{
407
+ type: Component,
408
+ args: [{
409
+ selector: 'lib-table',
410
+ template: `<ng-content></ng-content>`,
411
+ changeDetection: ChangeDetectionStrategy.OnPush
412
+ }]
413
+ }], propDecorators: { table: [{
414
+ type: Input
415
+ }], tableRecords: [{
416
+ type: Input
417
+ }], disabled: [{
418
+ type: Input
419
+ }], state: [{
420
+ type: Input
421
+ }], waiting: [{
422
+ type: Input
423
+ }] } });
424
+
425
+ const NO_ERROR = '00';
426
+ const HEADER$1 = 'HEADER';
427
+ const elementTypes = {
428
+ action: 'ACTION',
429
+ field: 'FIELD',
430
+ table: 'TABLE',
431
+ };
432
+ const formActions = {
433
+ tableAction: 'TABLEACTION',
434
+ getData: 'GETDATA',
435
+ getTableData: 'GETTABLEDATA',
436
+ validate: 'VALIDATE',
437
+ };
438
+ const operators = {
439
+ G: 'G',
440
+ L: 'L',
441
+ GE: 'GE',
442
+ LE: 'LE',
443
+ EQ: 'EQ',
444
+ NEQ: 'NEQ',
445
+ HAS: 'HAS',
446
+ NOTHAS: 'NOTHAS',
447
+ BETWEEN: 'BETWEEN',
448
+ IN: 'IN',
449
+ };
450
+
451
+ class FormElement {
452
+ constructor(elementDefinition, formConfig) {
453
+ this._formConfig = formConfig;
454
+ this._isForced = false;
455
+ this.setVisibleStates(elementDefinition.visibleStates);
456
+ this.setEnabledStates(elementDefinition.enabledStates);
457
+ this._visibleForced = false;
458
+ this.disabled = elementDefinition?.disabled ?? false;
459
+ this.setVisibility(elementDefinition?.visible ?? true);
460
+ this.customAttributes = elementDefinition?.customAttributes ?? {};
461
+ }
462
+ getCustomAttribute(name) { return this.customAttributes?.[name] ?? null; }
463
+ setCustomAttribute(name, value) { if (name) {
464
+ this.customAttributes[name] = value;
465
+ } }
466
+ matchAttribute(name, value) { return this.customAttributes?.[name] === value; }
467
+ isField() { return this.elementType === elementTypes.field; }
468
+ isAction() { return this.elementType === elementTypes.action; }
469
+ isTable() { return this.elementType === elementTypes.table; }
470
+ setVisibleStates(newStates) {
471
+ const visibleStates = (!Array.isArray(newStates) && typeof newStates === 'string')
472
+ ? newStates.split(',').map(state => state.trim()).filter(state => state.length > 0)
473
+ : newStates;
474
+ this.visibleStates = (Array.isArray(visibleStates)) ? visibleStates : [];
475
+ }
476
+ setEnabledStates(newStates) {
477
+ const enabledStates = (!Array.isArray(newStates) && typeof newStates === 'string')
478
+ ? newStates.split(',').map(state => state.trim()).filter(state => state.length > 0)
479
+ : newStates;
480
+ this.enabledStates = (Array.isArray(enabledStates)) ? enabledStates : [];
481
+ }
482
+ viewOnState(state) { return (this.visibleStates && state) ? this.visibleStates.includes(state) : false; }
483
+ enabledOnState(state) { return (this.enabledStates && state) ? this.enabledStates.includes(state) : false; }
484
+ /**
485
+ * @deprecated Utilizar viewOnState
486
+ */
487
+ supportState(state) { return this.viewOnState(state); }
488
+ /**
489
+ * @deprecated Utilizar viewOnState
490
+ */
491
+ supportMode(state) { return this.viewOnState(state); }
492
+ get visible() { return (this._isForced) ? this._visibleForced : this._visible; }
493
+ set visible(visible) { this.setVisibility(visible); }
494
+ visibleOn(state) {
495
+ return this.visible && this.viewOnState(state);
496
+ }
497
+ enabledOn(state) {
498
+ return !this.disabled && this.enabledOnState(state);
499
+ }
500
+ setVisibility(visible, forced = null) {
501
+ this._visible = visible && true;
502
+ if (forced != null) {
503
+ this._isForced = forced;
504
+ }
505
+ }
506
+ show(forced) {
507
+ this._visible = true;
508
+ if (forced !== null) {
509
+ this._isForced = forced;
510
+ this._visibleForced = true;
511
+ }
512
+ }
513
+ hide(forced) {
514
+ this._visible = false;
515
+ if (forced !== null) {
516
+ this._isForced = forced;
517
+ this._visibleForced = false;
518
+ }
519
+ }
520
+ enable() { this.disabled = false; }
521
+ disable() { this.disabled = true; }
522
+ get enabled() { return !this.disabled; }
523
+ get editable() { return !this.disabled; }
524
+ }
525
+
526
+ const HEADER = 'HEADER';
527
+ class FormAction extends FormElement {
528
+ constructor(actionDefinition, formConfig) {
529
+ super(actionDefinition, formConfig);
530
+ this._actionActivated = new Subject();
531
+ this.inProgress = false;
532
+ this.elementType = elementTypes.action;
533
+ this.actionCode = actionDefinition.actionCode ? actionDefinition.actionCode.toString() : '';
534
+ this.actionName = actionDefinition.actionTitle;
535
+ this.iconName = actionDefinition.iconName || this.actionCode;
536
+ this.setCustomAttribute('location', actionDefinition.position || HEADER);
537
+ this.backend = actionDefinition?.serverAction ?? false;
538
+ this.newState = actionDefinition?.newState;
539
+ this.restrictedOnField = actionDefinition.fieldRestrictedCode ? actionDefinition.fieldRestrictedCode.toString() : '';
540
+ this.restrictedOnOperator = actionDefinition.operatorRestricted || '';
541
+ this.restrictedOnValue = actionDefinition.valueRestricted ?? '';
542
+ this.customValidation = () => true;
543
+ }
544
+ get actionActivated() { return this._actionActivated; }
545
+ start() { this.inProgress = true; }
546
+ stop() { this.inProgress = false; }
547
+ notifyActivation() { this._actionActivated.next(this.actionCode); }
548
+ updateFromServer(receivedAction) {
549
+ for (const propertyName in receivedAction) {
550
+ if (propertyName !== 'actionCode' && propertyName !== 'actionId') {
551
+ this[propertyName] = receivedAction[propertyName];
552
+ }
553
+ }
554
+ }
555
+ setCustomValidation(callback) { this.customValidation = () => callback(); }
556
+ }
557
+
558
+ const UNDEFINED = 'undefined';
559
+ const DEFAULT_ERROR_TYPE = 'error';
560
+ const DEFAULT_CAPTURE_TYPE = 'INPUT';
561
+ const DEFAULT_ALIGNMENT = 'left';
562
+ const STD_MAX_LENGTH = 50;
563
+ const BIG_MAX_LENGTH = 500;
564
+ const fldAttr = {
565
+ validateOnServer: 'validateOnServer',
566
+ value: '_value',
567
+ minValue: '_minValue',
568
+ maxValue: '_maxValue',
569
+ maxLength: '_maxLength',
570
+ onValidation: '_onValidation',
571
+ focus: 'focus',
572
+ intrinsicErrorMessage: '_intrinsicErrorMessage',
573
+ code: 'fieldCode',
574
+ info: 'fieldInfo',
575
+ defaultValue: 'defaultValue',
576
+ defaultEditable: 'defaultEditable',
577
+ visibleLabel: 'visibleLabel',
578
+ required: 'fieldRequired',
579
+ hasChanged: 'hasChanged',
580
+ outputOnly: 'outputOnly',
581
+ captureType: 'captureType',
582
+ title: 'fieldTitle',
583
+ type: 'fieldType',
584
+ alignment: 'fieldAlignment',
585
+ format: 'fieldFormat',
586
+ externalValue: 'externalValue',
587
+ tooltipText: 'tooltipText',
588
+ errorType: 'errorType',
589
+ errorCode: 'errorCode',
590
+ errorMessage: 'errorMessage',
591
+ options: 'fieldOptions',
592
+ };
593
+ class FieldDescriptor extends FormElement {
594
+ constructor(inputFieldReceived, formConfig) {
595
+ super(inputFieldReceived, formConfig);
596
+ this._editionFinish = new Subject();
597
+ this._editionPartial = new Subject();
598
+ this._detailRequest = new Subject();
599
+ this._attributeChange = new Subject();
600
+ this.elementType = elementTypes.field;
601
+ const fld = (inputFieldReceived) ? inputFieldReceived : {};
602
+ this.setAttr(fldAttr.code, fld.fieldCode);
603
+ this.setAttr(fldAttr.title, fld.fieldTitle ?? this.fieldCode);
604
+ this.setAttr(fldAttr.type, fld.fieldTypeCode);
605
+ this.setAttr(fldAttr.captureType, fld.captureType ?? DEFAULT_CAPTURE_TYPE);
606
+ const defaultValue = fld.defaultValue ?? null;
607
+ if (this.fieldType === this._formConfig.fieldTypes.boolean) {
608
+ this.setAttr(fldAttr.defaultValue, defaultValue ?? false);
609
+ }
610
+ else {
611
+ this.setAttr(fldAttr.defaultValue, defaultValue);
612
+ }
613
+ const defaultTypeAlignment = (this._formConfig.tableFieldStyles[this.fieldType] != null)
614
+ ? this._formConfig.tableFieldStyles[this.fieldType]['text-align'] : DEFAULT_ALIGNMENT;
615
+ const fieldAlignment = (fld.alignment != null) ? fld.alignment.toLowerCase() : defaultTypeAlignment;
616
+ this.setAttr(fldAttr.alignment, fieldAlignment);
617
+ this.setAttr(fldAttr.info, fld.info || '');
618
+ let fieldFormat;
619
+ try {
620
+ fieldFormat = (fld.format) ? new RegExp(fld.format) : null;
621
+ }
622
+ catch (e) {
623
+ fieldFormat = null;
624
+ }
625
+ this.setAttr(fldAttr.format, fieldFormat);
626
+ this.setAttr(fldAttr.validateOnServer, fld.serverAction ?? false);
627
+ this.setAttr(fldAttr.tooltipText, fld.tooltip || '');
628
+ this.setAttr(fldAttr.defaultEditable, this.enabled);
629
+ this.setAttr(fldAttr.required, fld.required ?? false);
630
+ this.setError(fld.errorCode, fld.errorMessage, fld.errorType ?? DEFAULT_ERROR_TYPE);
631
+ this.setAttr(fldAttr.outputOnly, fld.outputOnly ?? false);
632
+ const maxLength = fld.maxLength ?? (this.captureType === 'TEXTAREA' ? BIG_MAX_LENGTH : STD_MAX_LENGTH);
633
+ this.setAttr(fldAttr.maxLength, maxLength);
634
+ this.setAttr(fldAttr.intrinsicErrorMessage, this._formConfig.fieldTypeErrMsg[this.fieldType] ?? this._formConfig.fieldTypeErrMsg.DEFAULT);
635
+ this.setEditable(fld.editable ?? true);
636
+ this.setVisibleLabel(fld.visibleLabel ?? true);
637
+ this.setVisibility(fld.visible);
638
+ this.setFieldOptions(fld.fieldOptions);
639
+ this.setValue(fld.fieldValue ?? this.defaultValue ?? '');
640
+ }
641
+ get name() { return this.fieldCode; }
642
+ get editionFinish() { return this._editionFinish; }
643
+ get attributeChange() { return this._attributeChange; }
644
+ get editionPartial() { return this._editionPartial; }
645
+ get detailRequest() { return this._detailRequest; }
646
+ get info() { return this.fieldInfo; }
647
+ get validating() { return this._onValidation; }
648
+ set validating(isValidating) { this.setAttr(fldAttr.onValidation, isValidating); }
649
+ focus() { this.setAttr(fldAttr.focus, true); }
650
+ setIntrinsicErrorMessage(message) { this.setAttr(fldAttr.intrinsicErrorMessage, message); }
651
+ set intrinsicErrorMessage(message) { this.setIntrinsicErrorMessage(message); }
652
+ get fieldValue() { return this.getValue(); }
653
+ getRequired() { return this.required; }
654
+ setRequired(required) { this.required = required; }
655
+ get required() { return this.fieldRequired; }
656
+ set required(required) { this.setAttr(fldAttr.required, required ?? false); }
657
+ get maxLength() { return (this._maxLength > 0) ? this._maxLength.toString() : ''; }
658
+ set maxLength(requiredMaxLength) {
659
+ if (typeof requiredMaxLength === 'string') {
660
+ this.setAttr(fldAttr.maxLength, parseInt(requiredMaxLength, 10));
661
+ }
662
+ else if (typeof requiredMaxLength === 'number') {
663
+ this.setAttr(fldAttr.maxLength, requiredMaxLength);
664
+ }
665
+ }
666
+ get value() { return this.getValue(); }
667
+ set value(newValue) { this.setValue(newValue); }
668
+ notifyEditionPartial() {
669
+ this._editionPartial.next({ code: this.fieldCode, intrinsicValidation: true });
670
+ }
671
+ notifyEditionFinish() {
672
+ let intrinsicValidation = true;
673
+ const fieldDefaultFormat = this._formConfig.fieldTypesPatterns?.[this.fieldType] ?? null;
674
+ const fieldValue = this.getValue();
675
+ if (fieldValue && (fieldDefaultFormat || this.fieldFormat)) {
676
+ intrinsicValidation = (fieldDefaultFormat?.test(fieldValue) ?? true)
677
+ && (this.fieldFormat?.test(fieldValue) ?? true);
678
+ if (!intrinsicValidation) {
679
+ this.setError('99', this._intrinsicErrorMessage);
680
+ }
681
+ }
682
+ if (intrinsicValidation && fieldValue && this._minValue && fieldValue < this._minValue) {
683
+ intrinsicValidation = false;
684
+ this.setError('99', 'Campo con valor inferior al mínimo');
685
+ }
686
+ if (intrinsicValidation && fieldValue && this._maxValue && fieldValue > this._maxValue) {
687
+ intrinsicValidation = false;
688
+ this.setError('99', 'Campo con valor superior al máximo');
689
+ }
690
+ this._editionFinish.next({ code: this.fieldCode, intrinsicValidation });
691
+ }
692
+ setAttr(name, value) {
693
+ this[name] = value;
694
+ if (this._formConfig.monitoredFieldAttributes.includes(name)) {
695
+ this._attributeChange.next({ name, value });
696
+ }
697
+ }
698
+ notifyEditionDetailRequest(detail) {
699
+ const detailEvent = {
700
+ code: this.fieldCode,
701
+ detail,
702
+ };
703
+ this._detailRequest.next(detailEvent);
704
+ }
705
+ setVisibleLabel(visibleLabel) { this.setAttr(fldAttr.visibleLabel, visibleLabel); }
706
+ showLabel() { this.setVisibleLabel(true); }
707
+ hideLabel() { this.setVisibleLabel(false); }
708
+ setChanged(hasChanged) { this.setAttr(fldAttr.hasChanged, hasChanged); }
709
+ changed() { this.setChanged(true); }
710
+ setLabel(label) { this.setAttr(fldAttr.title, label); }
711
+ clean() { this.setValue(this.defaultValue || ''); this.resetError(); }
712
+ get backend() { return this.validateOnServer; }
713
+ setEditable(editable = true) { (editable) ? this.enable() : this.disable(); }
714
+ hasError() { return this.errorCode !== NO_ERROR; }
715
+ resetError() { (this.errorCode !== NO_ERROR) && this.setError(NO_ERROR, null); }
716
+ setError(code, message, type = DEFAULT_ERROR_TYPE) {
717
+ this.setAttr(fldAttr.errorCode, code ?? NO_ERROR);
718
+ this.setAttr(fldAttr.errorType, (this.errorCode === NO_ERROR) ? '' : type);
719
+ this.setAttr(fldAttr.errorMessage, message ?? '');
720
+ }
721
+ getError() { return { type: this.errorType, code: this.errorCode, message: this.errorMessage }; }
722
+ get error() { return this.getError(); }
723
+ set error(errorObj) { this.setError(errorObj.code, errorObj.message, errorObj.type ?? DEFAULT_ERROR_TYPE); }
724
+ getErrorCode() { return this.getError().code; }
725
+ setErrorCode(code) { this.setError(code, this.errorMessage); }
726
+ getErrorMessage() { return this.getError().message; }
727
+ setErrorMessage(msg) { this.setError(this.errorCode, msg); }
728
+ get empty() { return this.isEmpty(); }
729
+ isEmpty() {
730
+ const fieldCurrentValue = this.getValue();
731
+ if (fieldCurrentValue === undefined || fieldCurrentValue === null) {
732
+ return true;
733
+ }
734
+ if (this.fieldType === this._formConfig.fieldTypes.array
735
+ && Array.isArray(fieldCurrentValue) && fieldCurrentValue.length === 0) {
736
+ return true;
737
+ }
738
+ ;
739
+ if (this.fieldType === this._formConfig.fieldTypes.phone) {
740
+ if (!Array.isArray(fieldCurrentValue)) {
741
+ return true;
742
+ }
743
+ if (fieldCurrentValue.length !== 2 || !fieldCurrentValue[0] || !fieldCurrentValue[1]) {
744
+ return true;
745
+ }
746
+ return false;
747
+ }
748
+ ;
749
+ return fieldCurrentValue === '';
750
+ }
751
+ getValue() {
752
+ if (this.fieldType === this._formConfig.fieldTypes.boolean
753
+ || this.fieldType === this._formConfig.fieldTypes.check) {
754
+ return yn(this._value);
755
+ }
756
+ return this._value;
757
+ }
758
+ getOptionText() {
759
+ return this.fieldOptions?.find(item => item.fieldOptionId === this._value)?.fieldOptionValue ?? null;
760
+ }
761
+ updateFromServer(fld) {
762
+ const fieldKeys = Object.keys(fld);
763
+ for (let index = 0; index < fieldKeys.length; index++) {
764
+ const attrName = fieldKeys[index];
765
+ const attrValue = fld[attrName];
766
+ (attrName === this._formConfig.apiFieldAttrs.visible) && this.setVisibility(attrValue);
767
+ (attrName === this._formConfig.apiFieldAttrs.labelVisible) && this.setVisibleLabel(fld.visibleLabel);
768
+ (attrName === this._formConfig.apiFieldAttrs.required) && this.setAttr(fldAttr.required, fld.required ?? false);
769
+ (attrName === this._formConfig.apiFieldAttrs.errorCode) && this.setAttr(fldAttr.errorCode, fld.errorCode);
770
+ (attrName === this._formConfig.apiFieldAttrs.errorMessage) && this.setAttr(fldAttr.errorMessage, fld.errorMessage);
771
+ (attrName === this._formConfig.apiFieldAttrs.tooltip) && this.setAttr(fldAttr.tooltipText, fld.tooltip);
772
+ (attrName === this._formConfig.apiFieldAttrs.info) && this.setAttr(fldAttr.info, fld.info);
773
+ (attrName === this._formConfig.apiFieldAttrs.editable) && this.setEditable(fld.editable);
774
+ (attrName === this._formConfig.apiFieldAttrs.title) && this.setLabel(fld.fieldTitle.toString());
775
+ (attrName === this._formConfig.apiFieldAttrs.value) && (this.setValue(fld.fieldValue) && this.setChanged(false));
776
+ (attrName === this._formConfig.apiFieldAttrs.options) && this.setFieldOptions(fld.fieldOptions);
777
+ (attrName === this._formConfig.apiFieldAttrs.captureType) && this.setAttr(fldAttr.captureType, fld.captureType || 'INPUT');
778
+ (attrName === this._formConfig.apiFieldAttrs.type) && this.setAttr(fldAttr.type, fld.fieldTypeCode);
779
+ (attrName === this._formConfig.apiFieldAttrs.maxLength) && this.setAttr(fldAttr.maxLength, fld.maxLength);
780
+ }
781
+ }
782
+ setMinValue(inputMinValue) {
783
+ let minValue = inputMinValue;
784
+ if (this.fieldType === this._formConfig.fieldTypes.date) {
785
+ minValue = new Date(minValue);
786
+ }
787
+ this.setAttr(fldAttr.minValue, minValue);
788
+ }
789
+ setMaxValue(inputMaxValue) {
790
+ let maxValue = inputMaxValue;
791
+ if (this.fieldType === this._formConfig.fieldTypes.date) {
792
+ maxValue = new Date(maxValue);
793
+ }
794
+ this.setAttr(fldAttr.maxValue, maxValue);
795
+ }
796
+ getFieldOptions() {
797
+ return this.fieldOptions.map(option => {
798
+ const optionCopy = { ...option };
799
+ return optionCopy;
800
+ });
801
+ }
802
+ setFieldOptions(newOptions) {
803
+ if ((!this._formConfig.captureTypesWithOptions.includes(this.captureType))
804
+ || typeof newOptions === UNDEFINED || !newOptions
805
+ || !Array.isArray(newOptions)) {
806
+ return;
807
+ }
808
+ let fieldOptions = newOptions.map(option => {
809
+ if (option.text !== undefined && option.text !== null
810
+ && option.value !== undefined && option.value !== null) {
811
+ return { fieldOptionValue: option.text, fieldOptionId: option.value };
812
+ }
813
+ return { ...option };
814
+ });
815
+ fieldOptions = (fieldOptions && Array.isArray(fieldOptions)
816
+ && fieldOptions.length > 0) ? fieldOptions : [];
817
+ this.setAttr(fldAttr.options, fieldOptions);
818
+ if (this._value) {
819
+ if (this.fieldType === this._formConfig.fieldTypes.array && Array.isArray(this._value)) {
820
+ const fieldValue = this._value?.filter(item => this.fieldOptions.find(opt => opt.fieldOptionId === item));
821
+ this.setAttr(fldAttr.value, fieldValue);
822
+ }
823
+ else {
824
+ const valInOptions = this.fieldOptions
825
+ .find(item => item.fieldOptionId === this._value);
826
+ if (!valInOptions) {
827
+ this.setValue('');
828
+ }
829
+ }
830
+ }
831
+ if (this.fieldRequired && this.fieldOptions.length === 1) {
832
+ this.setValue(this.fieldOptions[0].fieldOptionId);
833
+ }
834
+ }
835
+ setValue(newValue, widgetUpdate = true) {
836
+ if (typeof newValue === UNDEFINED) {
837
+ return true;
838
+ }
839
+ if (newValue === null && this.required) {
840
+ return true;
841
+ }
842
+ let newFinalValue;
843
+ if (this.fieldType === this._formConfig.fieldTypes.boolean
844
+ || this.fieldType === this._formConfig.fieldTypes.check) {
845
+ newFinalValue = yn(newValue) ?? false;
846
+ }
847
+ else if (this.fieldType === this._formConfig.fieldTypes.array
848
+ || this.fieldType === this._formConfig.fieldTypes.map) {
849
+ if (newValue === null || newValue === '') {
850
+ newFinalValue = [];
851
+ }
852
+ else if (Array.isArray(newValue)) {
853
+ newFinalValue = newValue;
854
+ }
855
+ else {
856
+ newFinalValue = newValue.toString().split(',');
857
+ }
858
+ }
859
+ else {
860
+ newFinalValue = newValue;
861
+ }
862
+ if (this._value !== newFinalValue) {
863
+ this.setChanged(true);
864
+ if (widgetUpdate) {
865
+ this.setAttr(fldAttr.value, newFinalValue);
866
+ }
867
+ else {
868
+ this._value = newFinalValue;
869
+ }
870
+ }
871
+ return true;
872
+ }
873
+ }
874
+
875
+ class RecordTableColumn {
876
+ constructor(recTableColReceived, formConfig) {
877
+ // Filtros
878
+ this.filterVisible = false;
879
+ this._formConfig = formConfig;
880
+ this.filterDef = null;
881
+ if (recTableColReceived) {
882
+ this.fieldCode = recTableColReceived.fieldCode;
883
+ this.fieldTitle = recTableColReceived.fieldTitle;
884
+ this.fieldType = recTableColReceived.fieldTypeCode || this._formConfig.fieldTypes.text;
885
+ const defaultTypeAlignment = (this._formConfig.tableFieldStyles[this.fieldType] != null) ? this._formConfig.tableFieldStyles[this.fieldType]['text-align'] : 'left';
886
+ this.fieldAlignment = (recTableColReceived.alignment != null) ? recTableColReceived.alignment.toLowerCase() : defaultTypeAlignment;
887
+ this.visible = recTableColReceived?.visible ?? true;
888
+ this.sortable = recTableColReceived?.sortable ?? false;
889
+ this.sortDirections = (this.sortable) ? ['ascend', 'descend'] : [null];
890
+ this.fieldFormat = recTableColReceived.format || '';
891
+ this.customAttributes = recTableColReceived?.customAttributes ?? {};
892
+ }
893
+ }
894
+ hideFilter() {
895
+ this.filterVisible = false;
896
+ }
897
+ addFilterDefinition(filterDefinition) {
898
+ this.filterDef = {
899
+ operators: filterDefinition.operators,
900
+ options: filterDefinition.options ?? null,
901
+ };
902
+ }
903
+ get filterDefinition() {
904
+ return this.filterDef;
905
+ }
906
+ addFilter(columnValues, operator) {
907
+ this.filterSetup = {
908
+ fieldCode: this.fieldCode,
909
+ operator: operator ?? this.filterDef.operators[0],
910
+ values: columnValues,
911
+ };
912
+ }
913
+ get filter() {
914
+ return this.filterSetup;
915
+ }
916
+ removeFilter() {
917
+ this.filterSetup = null;
918
+ }
919
+ get options() {
920
+ if (this.filterDef?.operators?.length === 1 && this.filterDef?.operators[0] === 'IN') {
921
+ return this.filterDef?.options;
922
+ }
923
+ return null;
924
+ }
925
+ serSortDirections(ascend, descend) {
926
+ this.sortDirections = [];
927
+ if (ascend) {
928
+ this.sortDirections.unshift('ascend');
929
+ }
930
+ if (descend) {
931
+ this.sortDirections.unshift('descend');
932
+ }
933
+ }
934
+ }
935
+
936
+ class TableAction {
937
+ constructor(actionDefinition) {
938
+ this.actionCode = actionDefinition.actionCode;
939
+ this.actionTitle = actionDefinition.actionTitle;
940
+ this.iconName = actionDefinition.iconName || this.actionCode;
941
+ this.actionType = actionDefinition.actionType || 'STANDARD';
942
+ this.actionClass = actionDefinition.actionClass || 'INLINE';
943
+ this.newState = actionDefinition.newState;
944
+ this.stateField = actionDefinition.stateField || '';
945
+ this.visibleStates = actionDefinition.visibleStates || [];
946
+ this.enabledStates = actionDefinition.enabledStates || [];
947
+ this.backend = actionDefinition?.serverAction ?? false;
948
+ this.restrictedOnField = actionDefinition.fieldRestrictedCode || '';
949
+ this.restrictedOnValue = actionDefinition.valueRestricted ?? '';
950
+ this.restrictedOnOperator = actionDefinition.operatorRestricted || '';
951
+ this.customAttributes = actionDefinition?.customAttributes ?? {};
952
+ }
953
+ supportMode(state) { return this.viewOnState(state); }
954
+ viewOnState(state) { return this.visibleStates.includes(state); }
955
+ enabledOnState(state) { return this.enabledStates.includes(state); }
956
+ }
957
+
958
+ class TableRecordData {
959
+ constructor(recordReceived, recordDefinition, selectionFieldName = null) {
960
+ this.recordData = {};
961
+ const { tableRecordId, recordData } = recordReceived;
962
+ this.recordId = tableRecordId;
963
+ this.selected = false;
964
+ this.recordData = {};
965
+ if (!recordDefinition || recordDefinition.length === 0 || !recordData || recordData.length === 0) {
966
+ return;
967
+ }
968
+ const fieldNames = recordDefinition.map(column => column.fieldCode);
969
+ if (Array.isArray(recordData)) {
970
+ const rawRecordData = recordData.filter(fieldData => fieldData.fieldCode && fieldNames.includes(fieldData.fieldCode));
971
+ rawRecordData.forEach(fieldData => {
972
+ const { fieldCode, fieldValue } = fieldData;
973
+ const fieldDef = recordDefinition.find(column => column.fieldCode === fieldCode);
974
+ this.recordData[fieldCode] = fieldValue ?? '';
975
+ if (fieldCode === selectionFieldName) {
976
+ this.selected = fieldValue;
977
+ }
978
+ });
979
+ }
980
+ else {
981
+ const fields = Object.keys(recordData);
982
+ fields.forEach(fieldCode => {
983
+ const fieldValue = recordData[fieldCode];
984
+ const fieldDef = recordDefinition.find(column => column.fieldCode === fieldCode);
985
+ this.recordData[fieldCode] = fieldValue ?? '';
986
+ });
987
+ }
988
+ }
989
+ toggleSelect() { this.selected = !this.selected; }
990
+ select() { this.selected = true; }
991
+ unselect() { this.selected = false; }
992
+ get recordIdKey() {
993
+ return (typeof this.recordId === 'object')
994
+ ? JSON.stringify(this.recordId) : this.recordId;
995
+ }
996
+ getFieldValue(fieldCode) {
997
+ return (fieldCode && this.recordData) ? this.recordData[fieldCode] : null;
998
+ }
999
+ hasPattern(words, columnObj) {
1000
+ if (!words || words.length === 0) {
1001
+ return true;
1002
+ }
1003
+ for (const fieldCode in this.recordData) {
1004
+ const columnDef = columnObj?.[fieldCode];
1005
+ if (columnDef && columnDef?.visible && this.recordData.hasOwnProperty(fieldCode)) {
1006
+ for (const word of words) {
1007
+ const term = word.toUpperCase();
1008
+ let fieldValue;
1009
+ if (columnDef.fieldType.toUpperCase().includes('DATE')) {
1010
+ fieldValue = this.recordData[fieldCode].substring(0, 16);
1011
+ }
1012
+ else {
1013
+ fieldValue = this.recordData[fieldCode];
1014
+ }
1015
+ if (fieldValue.toString().toUpperCase().includes(term)) {
1016
+ return true;
1017
+ }
1018
+ }
1019
+ }
1020
+ }
1021
+ return false;
1022
+ }
1023
+ hasCondition(columnFilters) {
1024
+ if (!columnFilters || columnFilters.length === 0) {
1025
+ return true;
1026
+ }
1027
+ for (const condition of columnFilters) {
1028
+ const { fieldCode, operator, values } = condition;
1029
+ if (this.recordData.hasOwnProperty(fieldCode)) {
1030
+ const fieldValue = this.recordData[fieldCode];
1031
+ const stringValue = fieldValue.toString().toUpperCase();
1032
+ if (operator === operators.G && fieldValue <= values[0]) {
1033
+ return false;
1034
+ }
1035
+ if (operator === operators.L && fieldValue >= values[0]) {
1036
+ return false;
1037
+ }
1038
+ if (operator === operators.GE && fieldValue < values[0]) {
1039
+ return false;
1040
+ }
1041
+ if (operator === operators.LE && fieldValue > values[0]) {
1042
+ return false;
1043
+ }
1044
+ if (operator === operators.IN && !values.includes(fieldValue)) {
1045
+ return false;
1046
+ }
1047
+ if (operator === operators.EQ) {
1048
+ return fieldValue === values[0];
1049
+ }
1050
+ if (operator === operators.NEQ && fieldValue === values[0]) {
1051
+ return false;
1052
+ }
1053
+ if (operator === operators.HAS && !stringValue.includes(values[0].toString().toUpperCase())) {
1054
+ return false;
1055
+ }
1056
+ if (operator === operators.NOTHAS && stringValue.includes(values[0].toString().toUpperCase())) {
1057
+ return false;
1058
+ }
1059
+ if (operator === operators.BETWEEN && (fieldValue < values[0] || fieldValue > values[1])) {
1060
+ return false;
1061
+ }
1062
+ }
1063
+ }
1064
+ return true;
1065
+ }
1066
+ }
1067
+
1068
+ const TABLE_SORT_ASCENDING = 'asc';
1069
+ const TABLE_SORT_DESCENDING = 'desc';
1070
+ class RecordTable extends FormElement {
1071
+ constructor(tableReceived, formConfig) {
1072
+ super(tableReceived, formConfig);
1073
+ this._inlineActionTrigger = new Subject();
1074
+ this._globalActionTrigger = new Subject();
1075
+ this._recordSelectionTrigger = new Subject();
1076
+ this._selectionActionTrigger = new Subject();
1077
+ this._getDataTrigger = new Subject();
1078
+ this._attributeChange = new Subject();
1079
+ this._tableColumnObj = {};
1080
+ this._actionsObj = {};
1081
+ // Mecanismos de filtrado nueva versión
1082
+ this.globalFilterStrings = [];
1083
+ this.tableRecordObj = {};
1084
+ this.allSelected = false;
1085
+ this.elementType = elementTypes.table;
1086
+ this.waiting = false;
1087
+ this.currentPage = 1;
1088
+ this.totalPages = 1;
1089
+ this.requestedPage = 1;
1090
+ this.columns = [];
1091
+ this._tableColumnObj = {};
1092
+ this._actions = [];
1093
+ this._actionsObj = {};
1094
+ this.tableRecords = [];
1095
+ this.globalSearch = false;
1096
+ this.restrictedId = null;
1097
+ this.tableTitle = tableReceived.tableTitle;
1098
+ this._appendPages = tableReceived?.append ?? false;
1099
+ this.selectable = tableReceived?.selectable ?? false;
1100
+ this.selectionBackend = tableReceived?.selectionBackend ?? false;
1101
+ this.sortable = tableReceived?.sortable ?? false;
1102
+ this.setAttr('allSelected', false);
1103
+ this.setAttr('tableCode', tableReceived.tableCode);
1104
+ this.setAttr('clientPaging', tableReceived?.clientPaging ?? true);
1105
+ this.setAttr('globalSearch', tableReceived?.simpleFilter ?? false);
1106
+ this.setAttr('sorting', { columnName: '', direction: '' });
1107
+ this.setAttr('recordsPerPage', formConfig.defaultRecordsPerPage);
1108
+ this.setAttr('layout', '');
1109
+ if (tableReceived.fields) {
1110
+ const columns = [];
1111
+ for (const columnReceived of tableReceived.fields) {
1112
+ const columnDefinition = new RecordTableColumn(columnReceived, this._formConfig);
1113
+ columns.push(columnDefinition);
1114
+ this._tableColumnObj[columnDefinition.fieldCode] = columnDefinition;
1115
+ }
1116
+ this.setAttr('columns', columns);
1117
+ }
1118
+ if (tableReceived.actions) {
1119
+ const tableActions = tableReceived.actions.map(objDef => {
1120
+ let visibleStates = objDef.visibleStates;
1121
+ let enabledStates = objDef.enabledStates;
1122
+ if (!visibleStates) {
1123
+ visibleStates = (objDef.actionModes || '').split(',')
1124
+ .map(state => state.trim())
1125
+ .filter(state => state.length > 0);
1126
+ enabledStates = (objDef.actionModes || '').split(',')
1127
+ .map(state => state.trim())
1128
+ .filter(state => state.length > 0);
1129
+ }
1130
+ return { ...objDef, visibleStates, enabledStates };
1131
+ });
1132
+ for (const actionReceived of tableActions) {
1133
+ const inlineAction = new TableAction(actionReceived);
1134
+ this._actions.push(inlineAction);
1135
+ this._actionsObj[inlineAction.actionCode] = inlineAction;
1136
+ }
1137
+ }
1138
+ this.selectionField = (this.selectable) ? tableReceived?.selectionField : null;
1139
+ // Filtros predefinidos en el formulario
1140
+ if (tableReceived.filters) {
1141
+ for (let index = 0; index < tableReceived.filters.length; index++) {
1142
+ this.addFilterDefinition(tableReceived.filters[index].fieldCode, tableReceived.filters[index]);
1143
+ }
1144
+ }
1145
+ }
1146
+ get columnNames() { return Object.keys(this._tableColumnObj); }
1147
+ get inlineActionTrigger() { return this._inlineActionTrigger; }
1148
+ get globalActionTrigger() { return this._globalActionTrigger; }
1149
+ get selectionActionTrigger() { return this._selectionActionTrigger; }
1150
+ get recordSelectionTrigger() { return this._recordSelectionTrigger; }
1151
+ get getDataTrigger() { return this._getDataTrigger; }
1152
+ get attributeChange() { return this._attributeChange; }
1153
+ getLayout() { return this.layout; }
1154
+ setLayout(layout) { this.setAttr('layout', layout); }
1155
+ hasActions() { return (this._actions.length > 0); }
1156
+ getSelectedRecords() { return this.tableRecords.filter(rec => rec.selected).map(rec => rec.recordId); }
1157
+ activateGlobalSearch() { this.globalSearch = true; }
1158
+ inactivateGlobalSearch() { this.globalSearch = false; }
1159
+ columnDefinition(fieldCode) { return this._tableColumnObj[fieldCode]; }
1160
+ putOnWait() { this.waiting = true; }
1161
+ freeWaiting() { this.waiting = false; }
1162
+ setAttr(name, value) {
1163
+ this[name] = value;
1164
+ if (this._formConfig.monitoredTableAttributes.includes(name)) {
1165
+ this._attributeChange.next({ name, value });
1166
+ }
1167
+ }
1168
+ notifyGlobalAction(actionCode) {
1169
+ const tableEvent = {
1170
+ tableCode: this.tableCode,
1171
+ actionCode,
1172
+ actionDetail: null
1173
+ };
1174
+ this._globalActionTrigger.next(tableEvent);
1175
+ }
1176
+ notifyInlineAction(tableActionEvent) {
1177
+ const tableEvent = {
1178
+ tableCode: this.tableCode,
1179
+ actionCode: tableActionEvent.actionCode,
1180
+ actionDetail: {
1181
+ recordId: tableActionEvent.recordId,
1182
+ recordData: tableActionEvent.recordData
1183
+ }
1184
+ };
1185
+ this._inlineActionTrigger.next(tableEvent);
1186
+ }
1187
+ notifyRecordSelection(recordId) {
1188
+ const record = this.getTableRecord(recordId);
1189
+ if (!record) {
1190
+ return;
1191
+ }
1192
+ record.toggleSelect();
1193
+ const tableEvent = {
1194
+ tableCode: this.tableCode,
1195
+ actionCode: null,
1196
+ actionDetail: {
1197
+ recordId: record.recordId,
1198
+ recordData: record.recordData
1199
+ }
1200
+ };
1201
+ this.recordSelectionTrigger.next(tableEvent);
1202
+ }
1203
+ notifySelectionAction(actionCode) {
1204
+ const tableEvent = {
1205
+ tableCode: this.tableCode,
1206
+ actionCode,
1207
+ actionDetail: {
1208
+ selectedRecords: this.selectedRecords
1209
+ }
1210
+ };
1211
+ this._selectionActionTrigger.next(tableEvent);
1212
+ }
1213
+ notifyGetDataAction(requestedPage = null) {
1214
+ this.updateVisibleRecords();
1215
+ this.requestedPage = requestedPage || this.currentPage;
1216
+ const tableEvent = {
1217
+ tableCode: this.tableCode,
1218
+ actionCode: null,
1219
+ actionDetail: null,
1220
+ };
1221
+ this._getDataTrigger.next(tableEvent);
1222
+ return null;
1223
+ }
1224
+ clean() {
1225
+ this.tableRecords = [];
1226
+ this.unSelectAll();
1227
+ this.tableRecordObj = {};
1228
+ this.updateVisibleRecords();
1229
+ }
1230
+ selectAll() {
1231
+ this.setAttr('allSelected', true);
1232
+ this.tableRecords.forEach(record => record.select());
1233
+ this.setAttr('selectedRecords', this.getSelectedRecords());
1234
+ return true;
1235
+ }
1236
+ unSelectAll() {
1237
+ this.setAttr('allSelected', false);
1238
+ this.tableRecords.forEach(record => record.unselect());
1239
+ this.setAttr('selectedRecords', this.getSelectedRecords());
1240
+ return true;
1241
+ }
1242
+ setTableRecords(tableRecords, append) {
1243
+ if (!append) {
1244
+ this.clean();
1245
+ }
1246
+ const newRecordsObj = { ...this.tableRecordObj };
1247
+ const newRecords = [...this.tableRecords];
1248
+ for (const tableRecord of tableRecords) {
1249
+ const recordReceived = new TableRecordData(tableRecord, this.columns, this.selectionField);
1250
+ const recordIdKey = recordReceived.recordIdKey;
1251
+ newRecords.push(recordReceived);
1252
+ newRecordsObj[recordIdKey] = recordReceived;
1253
+ }
1254
+ this.tableRecords = newRecords;
1255
+ this.setAttr('selectedRecords', this.getSelectedRecords());
1256
+ this.tableRecordObj = newRecordsObj;
1257
+ this.updateVisibleRecords();
1258
+ }
1259
+ appendRecords(records) { this.setTableRecords(records, true); }
1260
+ replaceRecords(records) { this.setTableRecords(records, false); }
1261
+ changePage(requestedPage) {
1262
+ if (this.clientPaging) {
1263
+ this.setAttr('currentPage', requestedPage);
1264
+ this.updateVisibleRecords();
1265
+ }
1266
+ else {
1267
+ this.notifyGetDataAction(requestedPage);
1268
+ }
1269
+ }
1270
+ updateVisibleRecords() {
1271
+ // updateView const changeViewAttributes = ['currentPage', 'recordsPerPage', 'sorting'];
1272
+ let visibleRecords;
1273
+ if (this.clientPaging) {
1274
+ let filteredRecords = this.getFilteredRecords();
1275
+ this.setAttr('totalRecordsNumber', filteredRecords.length);
1276
+ visibleRecords = filteredRecords.slice((this.currentPage - 1) * this.recordsPerPage, (this.currentPage - 1) * this.recordsPerPage + this.recordsPerPage);
1277
+ }
1278
+ else {
1279
+ visibleRecords = this.tableRecords;
1280
+ }
1281
+ this.setAttr('visibleRecords', visibleRecords);
1282
+ }
1283
+ updateFromServer(tableReceived) {
1284
+ this.requestedPage = 1;
1285
+ this.clean();
1286
+ this.visible = tableReceived?.visible || true;
1287
+ this.totalPages = tableReceived.totalPages || 1;
1288
+ this.recordsNumber = tableReceived.recordsNumber;
1289
+ this.setAttr('currentPage', +tableReceived?.currentPage ?? 1);
1290
+ this.setAttr('recordsPerPage', +tableReceived.recordsPerPage);
1291
+ this.setAttr('totalRecordsNumber', (this.clientPaging) ? tableReceived.tableRecords.length : +tableReceived.totalRecordsNumber);
1292
+ this.setAttr('sorting', {
1293
+ columnName: tableReceived.sortingColumn || '',
1294
+ direction: tableReceived.sortingDirection || ''
1295
+ });
1296
+ this.waiting = false;
1297
+ if (this._appendPages) {
1298
+ this.replaceRecords(tableReceived.tableRecords);
1299
+ }
1300
+ else {
1301
+ this.appendRecords(tableReceived.tableRecords);
1302
+ }
1303
+ this.updateVisibleRecords();
1304
+ }
1305
+ getTableRecord(recordId) {
1306
+ const recordIdKey = (typeof recordId === 'object') ? JSON.stringify(recordId) : recordId;
1307
+ return (this.tableRecordObj && recordId && this.tableRecordObj[recordId])
1308
+ ? this.tableRecordObj[recordId] : null;
1309
+ }
1310
+ getAction(actionCode) {
1311
+ return (this._actionsObj && actionCode && this._actionsObj[actionCode])
1312
+ ? this._actionsObj[actionCode] : null;
1313
+ }
1314
+ getActions(actionClass = this._formConfig.tableActions.inline, actionTypes = null) {
1315
+ return this._actions.filter(actionDef => {
1316
+ const typeIncluded = (actionTypes) ? actionTypes.includes(actionDef.actionType) : true;
1317
+ return actionDef.actionClass === actionClass && typeIncluded;
1318
+ });
1319
+ }
1320
+ // Filtros
1321
+ setFilterById(id) {
1322
+ if (this.restrictedId === id) {
1323
+ return;
1324
+ }
1325
+ this.restrictedId = id;
1326
+ this.updateVisibleRecords();
1327
+ }
1328
+ cleanIdFilter() {
1329
+ if (this.restrictedId === null) {
1330
+ return;
1331
+ }
1332
+ this.restrictedId = null;
1333
+ this.updateVisibleRecords();
1334
+ }
1335
+ setGlobalFilterString(text) {
1336
+ this.globalFilterStrings = text.split(' ').filter(t => t && t.trim().length > 0).map(t => t.trim()) ?? [];
1337
+ if (this.clientPaging) {
1338
+ this.changePage(1);
1339
+ }
1340
+ }
1341
+ addFilterDefinition(columnName, filterDefinition) {
1342
+ const tableColumn = this.columnDefinition(columnName);
1343
+ tableColumn && tableColumn.addFilterDefinition(filterDefinition);
1344
+ }
1345
+ getFilteredRecords() {
1346
+ let filteredRecords = this.tableRecords;
1347
+ if (this.restrictedId) {
1348
+ filteredRecords = filteredRecords.filter(record => record.recordId === this.restrictedId);
1349
+ }
1350
+ if (this.globalFilterStrings.length > 0) {
1351
+ filteredRecords = filteredRecords.filter(record => record.hasPattern(this.globalFilterStrings, this._tableColumnObj));
1352
+ }
1353
+ const columnFilters = this.columns.filter(column => column.filter).map(column => column.filter);
1354
+ if (columnFilters.length > 0) {
1355
+ filteredRecords = filteredRecords.filter(record => record.hasCondition(columnFilters));
1356
+ }
1357
+ return filteredRecords;
1358
+ }
1359
+ getColumnFilter(columnName) {
1360
+ const tableColumn = this.columnDefinition(columnName);
1361
+ return tableColumn?.filter ?? null;
1362
+ }
1363
+ addColumnFilter(columnName, columnValues, operator = null) {
1364
+ const tableColumn = this.columnDefinition(columnName);
1365
+ const columnFilterDefinition = tableColumn?.filterDefinition ?? null;
1366
+ if (!columnFilterDefinition) {
1367
+ return null;
1368
+ }
1369
+ tableColumn && tableColumn.addFilter(columnValues, operator);
1370
+ this.updateVisibleRecords();
1371
+ }
1372
+ removeColumnFilter(columnName) {
1373
+ const tableColumn = this.columnDefinition(columnName);
1374
+ tableColumn && tableColumn.removeFilter();
1375
+ this.updateVisibleRecords();
1376
+ }
1377
+ get currentFilter() {
1378
+ const compactFilter = {
1379
+ simpleFilterWords: this.globalFilterStrings,
1380
+ advancedFilter: [],
1381
+ };
1382
+ const columnFilters = this.columns.filter(column => column.filter).map(column => column.filter);
1383
+ for (let index = 0; index < columnFilters.length; index++) {
1384
+ const columnFilter = columnFilters[index];
1385
+ compactFilter.advancedFilter.push({
1386
+ fieldCode: columnFilter.fieldCode,
1387
+ operator: columnFilter.operator,
1388
+ fieldValue1: columnFilter.values[0],
1389
+ fieldValue2: columnFilter.values[1],
1390
+ });
1391
+ }
1392
+ return compactFilter;
1393
+ }
1394
+ // Ordenamiento de registros local
1395
+ sort(columnName, direction) {
1396
+ this.setRequiredOrder(columnName, direction);
1397
+ if (this.clientPaging) {
1398
+ this.localSortData();
1399
+ }
1400
+ else {
1401
+ this.notifyGetDataAction();
1402
+ }
1403
+ }
1404
+ setRequiredOrder(columnField, direction = null) {
1405
+ this.setAttr('sorting', {
1406
+ columnName: columnField,
1407
+ direction: (direction === 'ascend') ? TABLE_SORT_ASCENDING : TABLE_SORT_DESCENDING,
1408
+ });
1409
+ }
1410
+ localSortData() {
1411
+ if (!this.sorting.columnName || !this.sorting.direction) {
1412
+ return;
1413
+ }
1414
+ this.tableRecords.sort((a, b) => this.recordCompare(a, b, this.sorting.columnName, this.sorting.direction));
1415
+ //this.unSelectAll();
1416
+ this.updateVisibleRecords();
1417
+ }
1418
+ recordCompare(recordA, recordB, columnCompare, direction) {
1419
+ const recordAValue = recordA.getFieldValue(columnCompare);
1420
+ const recordBValue = recordB.getFieldValue(columnCompare);
1421
+ const recordAColumn = isNaN(recordAValue) ? recordAValue.toLocaleLowerCase() : recordAValue;
1422
+ const recordBColumn = isNaN(recordBValue) ? recordBValue.toLocaleLowerCase() : recordBValue;
1423
+ let result = 0;
1424
+ if (recordAColumn < recordBColumn) {
1425
+ result = -1;
1426
+ }
1427
+ else if (recordAColumn > recordBColumn) {
1428
+ result = 1;
1429
+ }
1430
+ return direction === TABLE_SORT_ASCENDING ? result : -result;
1431
+ }
1432
+ }
1433
+
1434
+ class RecordFormSubSection {
1435
+ constructor(subsectionReceived, formObject) {
1436
+ if (!subsectionReceived) {
1437
+ return;
1438
+ }
1439
+ this._customRender = null;
1440
+ this.visible = true;
1441
+ this.subSectionElements = [];
1442
+ this.subSectionFields = [];
1443
+ this.subSectionTables = [];
1444
+ this.subSectionActions = [];
1445
+ this.elementsArray = {};
1446
+ this.subsectionId = (subsectionReceived.subsectionId) ? subsectionReceived.subsectionId.toString() : '';
1447
+ this.subsectionCode = (subsectionReceived.subsectionCode) ? subsectionReceived.subsectionCode : '';
1448
+ this.subsectionTitle = (subsectionReceived.subsectionTitle) ? subsectionReceived.subsectionTitle : '';
1449
+ this.visibleStates = subsectionReceived.visibleStates || [];
1450
+ if (subsectionReceived.elements) {
1451
+ for (const receivedElement of subsectionReceived.elements) {
1452
+ let elementObject = null;
1453
+ let arrayToAdd = null;
1454
+ const { type, code } = receivedElement;
1455
+ switch (type) {
1456
+ case elementTypes.field:
1457
+ elementObject = formObject.getField(code);
1458
+ arrayToAdd = this.subSectionFields;
1459
+ break;
1460
+ case elementTypes.table:
1461
+ elementObject = formObject.getTable(code);
1462
+ arrayToAdd = this.subSectionTables;
1463
+ break;
1464
+ case elementTypes.action:
1465
+ elementObject = formObject.getAction(code);
1466
+ arrayToAdd = this.subSectionActions;
1467
+ break;
1468
+ }
1469
+ if (elementObject) {
1470
+ elementObject.elementType = type;
1471
+ arrayToAdd.push(elementObject);
1472
+ this.subSectionElements.push(elementObject);
1473
+ this.elementsArray[code] = elementObject;
1474
+ }
1475
+ }
1476
+ }
1477
+ }
1478
+ show() { this.visible = true; }
1479
+ hide() { this.visible = false; }
1480
+ get customRender() { return this._customRender; }
1481
+ set customRender(customRenderName) { this._customRender = customRenderName; }
1482
+ getField(name) {
1483
+ return this.subSectionFields.find(fld => fld.name === name);
1484
+ }
1485
+ getFields() {
1486
+ return this.subSectionFields;
1487
+ }
1488
+ getFieldNames() {
1489
+ return this.subSectionFields.map(field => field.fieldCode);
1490
+ }
1491
+ getActions() {
1492
+ return this.subSectionActions;
1493
+ }
1494
+ getActionNames() {
1495
+ return this.subSectionActions.map(action => action.actionCode);
1496
+ }
1497
+ viewOnState(state) {
1498
+ return this.visibleStates.includes(state);
1499
+ }
1500
+ supportMode(state) { return this.viewOnState(state); }
1501
+ }
1502
+
1503
+ class RecordFormSection {
1504
+ constructor(sectionReceived, formObject) {
1505
+ this._activation = new Subject();
1506
+ this._inactivation = new Subject();
1507
+ this.active = false;
1508
+ this.customAttributes = {};
1509
+ if (!sectionReceived) {
1510
+ return;
1511
+ }
1512
+ this.visible = true;
1513
+ this.sectionId = (sectionReceived.sectionId) ? sectionReceived.sectionId.toString() : '';
1514
+ this.sectionCode = (sectionReceived.sectionCode) ? sectionReceived.sectionCode : '';
1515
+ this.sectionTitle = (sectionReceived.sectionTitle) ? sectionReceived.sectionTitle : '';
1516
+ this.visibleStates = sectionReceived.visibleStates || [];
1517
+ this.subSections = [];
1518
+ this.subSectionsObj = {};
1519
+ if (sectionReceived.subsections) {
1520
+ const subsections = sectionReceived.subsections.map(objDef => {
1521
+ let visibleStates = objDef.visibleStates;
1522
+ if (!visibleStates) {
1523
+ visibleStates = (objDef.subsectionModes || '').split(',')
1524
+ .map(state => state.trim())
1525
+ .filter(state => state.length > 0);
1526
+ }
1527
+ if (!visibleStates || visibleStates.length === 0) {
1528
+ visibleStates = this.visibleStates;
1529
+ }
1530
+ if (objDef.elements && Array.isArray(objDef.elements)) {
1531
+ objDef.elements = objDef.elements.map(elm => ({ code: elm.elementCode, type: elm.elementTypeName }));
1532
+ }
1533
+ return { ...objDef, visibleStates };
1534
+ });
1535
+ for (const subsectionReceived of subsections) {
1536
+ const subSectionToAdd = new RecordFormSubSection(subsectionReceived, formObject);
1537
+ const subsectionCode = subSectionToAdd.subsectionCode;
1538
+ if (subsectionCode) {
1539
+ this.subSections.push(subSectionToAdd);
1540
+ this.subSectionsObj[subsectionCode] = subSectionToAdd;
1541
+ }
1542
+ }
1543
+ }
1544
+ if (sectionReceived?.customAttributes) {
1545
+ Object.keys(sectionReceived?.customAttributes)
1546
+ ?.forEach(attr => this.customAttributes[attr] = sectionReceived?.customAttributes[attr]);
1547
+ }
1548
+ }
1549
+ getCustomAttribute(name) { return this.customAttributes?.[name] ?? null; }
1550
+ setCustomAttribute(name, value) { return name && (this.customAttributes[name] = value); }
1551
+ matchAttribute(name, value) { return this.customAttributes?.[name] === value; }
1552
+ get code() { return this.sectionCode; }
1553
+ get activation() { return this._activation; }
1554
+ get inactivation() { return this._inactivation; }
1555
+ activate() {
1556
+ if (!this.active) {
1557
+ this.active = true;
1558
+ this._activation.next(this.sectionCode);
1559
+ }
1560
+ }
1561
+ inactivate() {
1562
+ if (this.active) {
1563
+ this.active = false;
1564
+ this._inactivation.next(this.sectionCode);
1565
+ }
1566
+ }
1567
+ show() { this.visible = true; }
1568
+ hide() { this.visible = false; }
1569
+ get title() { return this.sectionTitle; }
1570
+ set title(title) { this.sectionTitle = title; }
1571
+ getVisibleSubsections(state) {
1572
+ return this.subSections.filter(subSection => {
1573
+ return subSection.visible && subSection.viewOnState(state);
1574
+ });
1575
+ }
1576
+ getSubsection(subSectionCode) {
1577
+ return (this.subSectionsObj && this.subSectionsObj[subSectionCode])
1578
+ ? this.subSectionsObj[subSectionCode] : null;
1579
+ }
1580
+ getFields() {
1581
+ let fieldsArray = [];
1582
+ if (this.subSections && this.subSections.length > 0) {
1583
+ for (const subSection of this.subSections) {
1584
+ fieldsArray = fieldsArray.concat(subSection.getFields());
1585
+ }
1586
+ }
1587
+ return fieldsArray;
1588
+ }
1589
+ getActions() {
1590
+ let actionArray = [];
1591
+ if (this.subSections && this.subSections.length > 0) {
1592
+ for (const subSection of this.subSections) {
1593
+ actionArray = actionArray.concat(subSection.getActions());
1594
+ }
1595
+ }
1596
+ return actionArray;
1597
+ }
1598
+ getActionNames() {
1599
+ let actionArray = [];
1600
+ if (this.subSections && this.subSections.length > 0) {
1601
+ for (const subSection of this.subSections) {
1602
+ actionArray = actionArray.concat(subSection.getActionNames());
1603
+ }
1604
+ }
1605
+ return actionArray;
1606
+ }
1607
+ getFieldNames() {
1608
+ let fieldsArray = [];
1609
+ if (this.subSections && this.subSections.length > 0) {
1610
+ for (const subSection of this.subSections) {
1611
+ fieldsArray = fieldsArray.concat(subSection.getFieldNames());
1612
+ }
1613
+ }
1614
+ return fieldsArray;
1615
+ }
1616
+ getField(name) {
1617
+ let field = null;
1618
+ if (this.subSections && this.subSections.length > 0) {
1619
+ for (const subSection of this.subSections) {
1620
+ field = subSection.getField(name);
1621
+ if (field) {
1622
+ return field;
1623
+ }
1624
+ }
1625
+ }
1626
+ return null;
1627
+ }
1628
+ supportState(state) { return this.viewOnState(state); }
1629
+ viewOnState(state) { return this.visibleStates.includes(state); }
1630
+ supportMode(state) { return this.viewOnState(state); }
1631
+ }
1632
+
1633
+ const ACTIVE = 'active';
1634
+ const SHOW = 'show';
1635
+ const HIDE = 'hide';
1636
+ const ENABLE = 'enable';
1637
+ const DISABLE = 'disable';
1638
+ const CLEAN = 'clean';
1639
+ class FormStructureAndData {
1640
+ constructor(definitionReceived, formConfig) {
1641
+ this._name = '';
1642
+ this._title = '';
1643
+ this._fields = {};
1644
+ this._actions = {};
1645
+ this._tables = {};
1646
+ this._sections = {};
1647
+ this._immutableData = {};
1648
+ this._extraInfo = {};
1649
+ this._exclusiveSectionsByAttr = {};
1650
+ this._formConfig = formConfig;
1651
+ this.state = '';
1652
+ this._actionArray = [];
1653
+ this._fieldArray = [];
1654
+ this._tableArray = [];
1655
+ this._sectionArray = [];
1656
+ this._stateFlow = {
1657
+ defaultState: '',
1658
+ states: [],
1659
+ transitions: [],
1660
+ };
1661
+ if (!definitionReceived) {
1662
+ return;
1663
+ }
1664
+ this._name = (definitionReceived.form && definitionReceived.form.formCode)
1665
+ ? definitionReceived.form.formCode : this._name;
1666
+ this._title = (definitionReceived.form && definitionReceived.form.formTitle)
1667
+ ? definitionReceived.form.formTitle : '';
1668
+ this.setStateFlow(definitionReceived?.states, definitionReceived?.transitions, definitionReceived?.defaultState);
1669
+ this.immutableData = definitionReceived.immutableData;
1670
+ this.extraInfo = definitionReceived.extraInfo;
1671
+ if (definitionReceived.actions) {
1672
+ const formActions = definitionReceived.actions.map(objDef => {
1673
+ let visibleStates = objDef.visibleStates;
1674
+ let enabledStates = objDef.enabledStates;
1675
+ if (!visibleStates) {
1676
+ visibleStates = (objDef.actionModes || '').split(',')
1677
+ .map(state => state.trim())
1678
+ .filter(state => state.length > 0) || [];
1679
+ enabledStates = [...visibleStates];
1680
+ }
1681
+ return { ...objDef, visibleStates, enabledStates };
1682
+ });
1683
+ for (const actionReceived of formActions) {
1684
+ const globalAction = new FormAction(actionReceived, this._formConfig);
1685
+ const globalActionCode = globalAction.actionCode;
1686
+ if (globalActionCode) {
1687
+ this._actionArray.push(globalAction);
1688
+ this._actions[globalActionCode] = globalAction;
1689
+ }
1690
+ }
1691
+ }
1692
+ if (definitionReceived.fields) {
1693
+ const formFields = definitionReceived.fields.map(objDef => {
1694
+ let visibleStates = objDef.visibleStates;
1695
+ let enabledStates = objDef.enabledStates || objDef.editableStates;
1696
+ if (!visibleStates) {
1697
+ visibleStates = (objDef.fieldModes || '').split(',')
1698
+ .map(state => state.trim())
1699
+ .filter(state => state.length > 0) || [];
1700
+ enabledStates = [...visibleStates];
1701
+ }
1702
+ return { ...objDef, visibleStates, enabledStates };
1703
+ });
1704
+ for (const fieldReceived of formFields) {
1705
+ const fieldToAdd = new FieldDescriptor(fieldReceived, this._formConfig);
1706
+ const fieldCode = fieldToAdd.fieldCode;
1707
+ if (fieldCode) {
1708
+ this._fieldArray.push(fieldToAdd);
1709
+ this._fields[fieldCode] = fieldToAdd;
1710
+ }
1711
+ }
1712
+ }
1713
+ if (definitionReceived.tables) {
1714
+ const tables = definitionReceived.tables.map(objDef => {
1715
+ let visibleStates = objDef.visibleStates;
1716
+ let enabledStates = objDef.enabledStates || objDef.editableStates;
1717
+ if (!visibleStates) {
1718
+ visibleStates = (objDef.tableModes || '').split(',')
1719
+ .map(state => state.trim())
1720
+ .filter(state => state.length > 0) || [];
1721
+ enabledStates = [...visibleStates];
1722
+ }
1723
+ if (!visibleStates || visibleStates.length === 0) {
1724
+ visibleStates = this._formConfig.defaultStateFlow.states;
1725
+ }
1726
+ return { ...objDef, visibleStates, enabledStates };
1727
+ });
1728
+ for (const tableReceived of tables) {
1729
+ const tableToAdd = new RecordTable(tableReceived, this._formConfig);
1730
+ const tableCode = tableToAdd.tableCode;
1731
+ if (tableCode) {
1732
+ this._tableArray.push(tableToAdd);
1733
+ this._tables[tableCode] = tableToAdd;
1734
+ }
1735
+ }
1736
+ }
1737
+ if (definitionReceived.sections) {
1738
+ const formSections = definitionReceived.sections.map(objDef => {
1739
+ let visibleStates = objDef.visibleStates;
1740
+ if (!visibleStates) {
1741
+ visibleStates = (objDef.sectionModes || '').split(',')
1742
+ .map(state => state.trim())
1743
+ .filter(state => state.length > 0) || [];
1744
+ }
1745
+ return { ...objDef, visibleStates };
1746
+ });
1747
+ for (const sectionReceived of formSections) {
1748
+ const sectionToAdd = new RecordFormSection(sectionReceived, this);
1749
+ const sectionCode = sectionToAdd.sectionCode;
1750
+ if (sectionCode) {
1751
+ this._sectionArray.push(sectionToAdd);
1752
+ this._sections[sectionCode] = sectionToAdd;
1753
+ }
1754
+ }
1755
+ }
1756
+ }
1757
+ getTitle() { return this._title; }
1758
+ setTitle(title) { this._title = title; }
1759
+ get name() { return this._name; }
1760
+ set name(name) { this._name = name; }
1761
+ // Estados
1762
+ get defaultState() { return this._stateFlow.defaultState; }
1763
+ supportState(state) { return this._stateFlow.states?.includes(state); }
1764
+ supportMode(state) { return this.supportState(state); }
1765
+ get states() { return this._stateFlow.states; }
1766
+ getCurrentState() { return this.state; }
1767
+ changeState(newState) {
1768
+ if (!newState || !this.supportState(newState)) {
1769
+ return false;
1770
+ }
1771
+ if (!this.state) {
1772
+ this.state = newState;
1773
+ }
1774
+ else {
1775
+ const transitionToChange = this._stateFlow.transitions.find(trns => trns.source === this.state && trns.destination === newState);
1776
+ if (transitionToChange) {
1777
+ this.state = newState;
1778
+ }
1779
+ }
1780
+ return (this.state === newState);
1781
+ }
1782
+ setStateFlow(states, transitions, defaultState) {
1783
+ if (!states || !transitions) {
1784
+ this._stateFlow = JSON.parse(JSON.stringify(this._formConfig.defaultStateFlow));
1785
+ return;
1786
+ }
1787
+ this._stateFlow.states = states;
1788
+ this._stateFlow.defaultState = defaultState || this._stateFlow.states[0];
1789
+ this._stateFlow.transitions = transitions.map(transition => {
1790
+ const name = transition.name;
1791
+ const source = (this._stateFlow.states.includes(transition.source)) ? transition.source : '';
1792
+ const destination = (this._stateFlow.states.includes(transition.destination)) ? transition.destination : '';
1793
+ return { name, source, destination };
1794
+ }).filter(item => item.name && item.source && item.destination);
1795
+ }
1796
+ // immutable Data
1797
+ getImmutableElement(name) { return this._immutableData?.[name]?.value ?? null; }
1798
+ set immutableData(immutableData) { Object.assign(this._immutableData, immutableData); }
1799
+ get immutableData() { return JSON.parse(JSON.stringify(this._immutableData)); }
1800
+ // extra Info
1801
+ getExtraInfo(name) { return this._extraInfo?.[name]?.value ?? null; }
1802
+ set extraInfo(extraInfo) { Object.assign(this._extraInfo, extraInfo); }
1803
+ get extraInfo() { return JSON.parse(JSON.stringify(this._extraInfo)); }
1804
+ // Fields
1805
+ get fields() { return this._fields; }
1806
+ get fieldNames() { return this.getFieldNames(); }
1807
+ getFields() { return this._fieldArray; }
1808
+ getFieldNames() { return this._fieldArray.map(field => field.fieldCode); }
1809
+ getField(code) { return (code && this._fields?.[code]) ? this._fields[code] : null; }
1810
+ enableField(code) { this.getField(code)?.enable(); }
1811
+ disableField(code) { this.getField(code)?.disable(); }
1812
+ getFieldValue(code) { return this.getField(code)?.getValue(); }
1813
+ getFieldOptionText(code) { return this.getField(code)?.getOptionText(); }
1814
+ getFieldOptions(code) { return this.getField(code)?.getFieldOptions() ?? null; }
1815
+ setFieldValue(code, value) { this.getField(code)?.setValue(value); }
1816
+ setFieldError(code, errorCode, message, type = 'error') { this.getField(code)?.setError(errorCode, message, type); }
1817
+ setFieldIntrinsicErrorMessage(code, message) { this.getField(code)?.setIntrinsicErrorMessage(message); }
1818
+ setFieldRequired(code, required) { this.getField(code)?.setRequired(required); }
1819
+ setFieldErrorMessage(code, message) { this.getField(code)?.setErrorMessage(message); }
1820
+ setFieldOptions(code, optionsArray, idAttribute, nameAttribute) {
1821
+ const field = this.getField(code);
1822
+ if (field && optionsArray?.length > 0) {
1823
+ const fieldOptions = optionsArray.map(item => ({
1824
+ fieldOptionId: item[idAttribute],
1825
+ fieldOptionValue: item[nameAttribute]
1826
+ }));
1827
+ field.setFieldOptions(fieldOptions);
1828
+ }
1829
+ }
1830
+ getFieldSet(filter, inputCodes, secCode, subCode) {
1831
+ let codes = [];
1832
+ if (typeof inputCodes === 'string' && inputCodes) {
1833
+ codes = [inputCodes];
1834
+ }
1835
+ else if (Array.isArray(inputCodes) && inputCodes.length > 0) {
1836
+ codes = inputCodes ?? [];
1837
+ }
1838
+ else if (secCode && !subCode) {
1839
+ codes = this.getSection(secCode)?.getFieldNames() ?? [];
1840
+ }
1841
+ else if (secCode && subCode) {
1842
+ codes = this.getSubSection(secCode, subCode)?.getFieldNames() ?? [];
1843
+ }
1844
+ else {
1845
+ codes = this.getFieldNames() ?? [];
1846
+ }
1847
+ return (filter) ? codes.filter(fld => filter(this.getField(fld))) : codes;
1848
+ }
1849
+ applyOnFields(processFunc, inputCodes, secCode, subCode) {
1850
+ if (!processFunc) {
1851
+ return 0;
1852
+ }
1853
+ const codes = this.getFieldSet(null, inputCodes ?? null, secCode, subCode);
1854
+ let processedFields = 0;
1855
+ for (const code of codes) {
1856
+ const field = this.getField(code);
1857
+ if (field) {
1858
+ try {
1859
+ processFunc(field);
1860
+ processedFields += 1;
1861
+ }
1862
+ catch (e) {
1863
+ console.log(`Error procesando funcion en campo ${field}: ${e}`);
1864
+ }
1865
+ }
1866
+ }
1867
+ return processedFields;
1868
+ }
1869
+ enableFields(codes, secCode, subCode) {
1870
+ return this.applyOnFields(fld => fld.enable(), codes, secCode, subCode);
1871
+ }
1872
+ showFields(codes, secCode, subCode) {
1873
+ return this.applyOnFields(fld => fld.show(), codes, secCode, subCode);
1874
+ }
1875
+ hideFields(codes, secCode, subCode) {
1876
+ return this.applyOnFields(fld => fld.hide(), codes, secCode, subCode);
1877
+ }
1878
+ showLabelFields(codes, secCode, subCode) {
1879
+ return this.applyOnFields(fld => fld.showLablel(), codes, secCode, subCode);
1880
+ }
1881
+ hideLabelFields(codes, secCode, subCode) {
1882
+ return this.applyOnFields(fld => fld.hideLabel(), codes, secCode, subCode);
1883
+ }
1884
+ disableFields(codes, secCode, subCode) {
1885
+ return this.applyOnFields(fld => fld.disable(), codes, secCode, subCode);
1886
+ }
1887
+ cleanFields(codes, secCode, subCode) {
1888
+ return this.applyOnFields(fld => fld.clean(), codes, secCode, subCode);
1889
+ }
1890
+ tagFieldsWithError(message, codes, secCode, subCode) {
1891
+ return this.applyOnFields(fld => fld.setErrorMessage(message), codes, secCode, subCode);
1892
+ }
1893
+ cleanErrorFields(codes, secCode, subCode) {
1894
+ return this.tagFieldsWithError('', codes, secCode, subCode);
1895
+ }
1896
+ tagEmptyRequiredFields(message, codes = null, secCode, subCode) {
1897
+ return this.tagFieldsWithError(message, this.getRequiredEmptyFields(codes, secCode, subCode)) > 0;
1898
+ }
1899
+ getRequiredFields(codes, secCode, subCode) {
1900
+ return this.getFieldSet(fld => fld.required, codes ?? null, secCode, subCode);
1901
+ }
1902
+ getRequiredEmptyFields(codes, secCode, subCode) {
1903
+ return this.getFieldSet(fld => fld.required && fld.empty, codes ?? null, secCode, subCode);
1904
+ }
1905
+ getChangedFields(codes, secCode, subCode) {
1906
+ return this.getFieldSet(fld => !fld.outputOnly && fld.hasChanged(), codes ?? null, secCode, subCode);
1907
+ }
1908
+ getFieldsWithValidationIssues(codes, secCode, subCode) {
1909
+ return this.getFieldSet(fld => fld.errorCode !== NO_ERROR, codes ?? null, secCode, subCode);
1910
+ }
1911
+ getFieldsValues(inputCodes, secCode, subCode) {
1912
+ const codes = this.getFieldSet(null, inputCodes ?? null, secCode, subCode);
1913
+ const resultObject = {};
1914
+ for (let index = 0; index < codes.length; index++) {
1915
+ const code = codes[index];
1916
+ if (code) {
1917
+ resultObject[code] = this._fields?.[code]?.getValue() ?? null;
1918
+ }
1919
+ }
1920
+ return resultObject;
1921
+ }
1922
+ // Acciones
1923
+ get actions() { return this._actions; }
1924
+ getActionsByAttribute(name, value) { return this._actionArray.filter(actionItem => actionItem.matchAttribute(name, value)); }
1925
+ getActions() { return this._actionArray; }
1926
+ getAction(code) { return (code && this._actions?.[code]) ? this._actions[code] : null; }
1927
+ showActions(codes) { return this.execOnActions(codes, SHOW); }
1928
+ hideActions(codes) { return this.execOnActions(codes, HIDE); }
1929
+ enableActions(codes) { return this.execOnActions(codes, ENABLE); }
1930
+ disableActions(codes) { return this.execOnActions(codes, DISABLE); }
1931
+ execOnActions(codes, functionName) {
1932
+ const actionCodes = (Array.isArray(codes)) ? codes : (codes ? [codes] : []);
1933
+ if (!functionName || actionCodes.length === 0) {
1934
+ return;
1935
+ }
1936
+ actionCodes.forEach(code => {
1937
+ const action = this.getAction(code);
1938
+ action?.[functionName]?.();
1939
+ });
1940
+ }
1941
+ // Tablas
1942
+ get tables() { return this.tables; }
1943
+ getTables() { return this._tableArray; }
1944
+ getTable(code) { return (code && this._tables?.[code]) ? this._tables[code] : null; }
1945
+ getTableRecord(code, id) { return this.getTable(code)?.getTableRecord(id); }
1946
+ enableTables(codes) { return this.execOnTables(codes, ENABLE); }
1947
+ disableTables(codes) { return this.execOnTables(codes, DISABLE); }
1948
+ showTables(codes) { return this.execOnTables(codes, SHOW); }
1949
+ hideTables(codes) { return this.execOnTables(codes, HIDE); }
1950
+ cleanTables(codes) { return this.execOnTables(codes, CLEAN); }
1951
+ execOnTables(codes, functionName) {
1952
+ const tableCodes = (Array.isArray(codes)) ? codes : (codes ? [codes] : []);
1953
+ if (!functionName || tableCodes.length === 0) {
1954
+ return;
1955
+ }
1956
+ tableCodes.forEach(code => {
1957
+ const table = this.getTable(code);
1958
+ table?.[functionName]?.();
1959
+ });
1960
+ }
1961
+ // Secciones
1962
+ get sections() { return this._sections; }
1963
+ getSections() { return this._sectionArray; }
1964
+ getSectionsByAttribute(name, value) { return this._sectionArray.filter(item => item.matchAttribute(name, value)); }
1965
+ get sectionTitles() { return this._sectionArray.map(formSection => formSection.sectionTitle); }
1966
+ get visibleSections() { return this._sectionArray.filter(sec => sec.visible); }
1967
+ getSection(code) { return (code && this._sections?.[code]) ? this._sections[code] : null; }
1968
+ showSections(codes) { this.execOnSections(codes, SHOW); }
1969
+ hideSections(codes) { this.execOnSections(codes, HIDE); }
1970
+ activeSection() { return this._exclusiveSectionsByAttr[ACTIVE]; }
1971
+ getSubSection(code, subCode) { return this.getSection(code)?.getSubsection(subCode) ?? null; }
1972
+ showSubSections(code, subCodes) { return this.execOnSubSections(code, subCodes, SHOW); }
1973
+ hideSubSections(code, subCodes) { return this.execOnSubSections(code, subCodes, HIDE); }
1974
+ getSectionActions(code) { return this.getSection(code)?.getActions() ?? null; }
1975
+ getSectionActionNames(code) { return this.getSection(code)?.getActionNames() ?? null; }
1976
+ activateSection(code) {
1977
+ if (code === this._exclusiveSectionsByAttr[ACTIVE]) {
1978
+ return;
1979
+ }
1980
+ this.getSection(this.activeSection())?.inactivate();
1981
+ this.getSection(code)?.activate();
1982
+ this._exclusiveSectionsByAttr[ACTIVE] = code;
1983
+ }
1984
+ execOnSections(codes, functionName) {
1985
+ const sectionCodes = (Array.isArray(codes)) ? codes : (codes ? [codes] : []);
1986
+ if (!functionName || sectionCodes.length === 0) {
1987
+ return;
1988
+ }
1989
+ sectionCodes.forEach(code => {
1990
+ const section = this.getSection(code);
1991
+ section?.[functionName]?.();
1992
+ });
1993
+ }
1994
+ execOnSubSections(code, subNames, functionName) {
1995
+ const subCodes = (Array.isArray(subNames)) ? subNames : (subNames ? [subNames] : []);
1996
+ const section = this.getSection(code);
1997
+ if (!functionName || !section || subCodes.length === 0) {
1998
+ return;
1999
+ }
2000
+ for (const subCode of subCodes) {
2001
+ const subSection = this.getSubSection(code, subCode);
2002
+ subSection?.[functionName]?.();
2003
+ }
2004
+ }
2005
+ /**
2006
+ * Métodos propios de gestión del formulario
2007
+ */
2008
+ cleanData() {
2009
+ for (const field of this._fieldArray) {
2010
+ field.setValue(field.defaultValue);
2011
+ }
2012
+ for (const table of this._tableArray) {
2013
+ table.clean();
2014
+ }
2015
+ }
2016
+ getPayload() {
2017
+ const formData = {
2018
+ fields: [],
2019
+ tables: [],
2020
+ };
2021
+ formData.fields = this.getFields().filter(fld => !fld.outputOnly)
2022
+ .map(fld => {
2023
+ const fieldPayload = {
2024
+ fieldCode: fld.fieldCode,
2025
+ fieldValue: fld.getValue(),
2026
+ editable: !fld.disabled,
2027
+ visible: fld.visible,
2028
+ required: fld.required,
2029
+ fieldOptions: '',
2030
+ };
2031
+ return fieldPayload;
2032
+ });
2033
+ formData.tables = this.getTables().map(tbl => {
2034
+ const tablePayload = {
2035
+ tableCode: tbl.tableCode,
2036
+ visible: tbl.visible,
2037
+ currentPage: tbl.currentPage,
2038
+ requestedPage: tbl.requestedPage,
2039
+ recordsPerPage: tbl.recordsPerPage,
2040
+ currentFilter: tbl.currentFilter,
2041
+ sortingColumn: tbl.sorting.columnName,
2042
+ sortingDirection: tbl.sorting.direction,
2043
+ };
2044
+ return tablePayload;
2045
+ });
2046
+ return formData;
2047
+ }
2048
+ }
2049
+
2050
+ class LibFormManagerService {
2051
+ constructor() {
2052
+ this.cleanStack();
2053
+ }
2054
+ // Métodos virtuales para las aplicaciones
2055
+ getFormDefinition(formCode) { }
2056
+ execServerAction(actionDetail) { }
2057
+ goToForm(formCode, token, subject) { }
2058
+ loadStack() { }
2059
+ saveStack() { }
2060
+ cleanStack() { this.pageStack = []; }
2061
+ resetPageStack() { this.cleanStack(); }
2062
+ findFormInStack(token) {
2063
+ const index = this.pageStack.findIndex(item => item?.token === token);
2064
+ const data = (index >= 0) ? this.pageStack[index] : null;
2065
+ return { index, data };
2066
+ }
2067
+ replaceItem(token, formInfo) {
2068
+ if (!token || !formInfo) {
2069
+ return;
2070
+ }
2071
+ const { index, data: storedForm } = this.findFormInStack(token);
2072
+ let updatedForm = null;
2073
+ if (index >= 0) {
2074
+ updatedForm = { ...storedForm };
2075
+ updatedForm.subject = formInfo?.subject ?? storedForm.subject;
2076
+ updatedForm.state = formInfo?.state ?? storedForm.state;
2077
+ updatedForm.fields = storedForm?.fields ?? {};
2078
+ updatedForm.extra = storedForm?.extra ?? {};
2079
+ if (formInfo.fields) {
2080
+ Object.assign(updatedForm.fields, formInfo.fields);
2081
+ }
2082
+ if (formInfo.extra) {
2083
+ Object.assign(updatedForm.extra, formInfo.extra);
2084
+ }
2085
+ this.pageStack[index] = updatedForm;
2086
+ this.saveStack();
2087
+ }
2088
+ }
2089
+ stack(origin, target) {
2090
+ const token = nanoid(6);
2091
+ this.replaceItem(target.originToken, origin);
2092
+ this.pageStack.push({ token, ...target });
2093
+ this.saveStack();
2094
+ return token;
2095
+ }
2096
+ unstack(token = null) {
2097
+ let index = (token) ? this.findFormInStack(token).index : this.pageStack.length - 2;
2098
+ let formInfo = null;
2099
+ if (index >= 0) {
2100
+ formInfo = this.pageStack[index];
2101
+ this.pageStack.splice(index + 1);
2102
+ this.saveStack();
2103
+ }
2104
+ return formInfo;
2105
+ }
2106
+ getFormInfo(token) {
2107
+ const { data } = this.findFormInStack(token);
2108
+ return {
2109
+ token: data?.token,
2110
+ subject: data?.subject,
2111
+ state: data?.state,
2112
+ originToken: data?.originToken,
2113
+ fields: data?.fields ?? {},
2114
+ extra: data?.extra ?? {}
2115
+ };
2116
+ }
2117
+ openForm(origin, target) {
2118
+ (!origin) && this.cleanStack();
2119
+ target.originToken = origin?.token ?? null;
2120
+ const token = this.stack(origin, target);
2121
+ this.goToForm(target.name, token, target.subject);
2122
+ }
2123
+ backTo(targetToken = null) {
2124
+ const formInfo = this.unstack(targetToken);
2125
+ formInfo && formInfo.name && this.goToForm(formInfo.name, formInfo.token, formInfo.subject);
2126
+ }
2127
+ }
2128
+
2129
+ class LibEventManagerService {
2130
+ constructor(eventNames) {
2131
+ this.eventSubjects = {};
2132
+ eventNames.forEach((name) => { this.addEventName(name); });
2133
+ }
2134
+ addEventName(name) {
2135
+ if (!this.eventSubjects[name]) {
2136
+ const newEventSubject = new ReplaySubject(1);
2137
+ this.eventSubjects[name] = newEventSubject;
2138
+ }
2139
+ }
2140
+ getEventNames() { return Object.keys(this.eventSubjects); }
2141
+ getSubject(eventClassName) { return eventClassName ? this.eventSubjects[eventClassName] : null; }
2142
+ subscribe(eventClassName, callback) { this.getSubject(eventClassName).subscribe(callback); }
2143
+ next(eventClassName, data) { this.getSubject(eventClassName).next(data); }
2144
+ }
2145
+
2146
+ class LibFileManagementService {
2147
+ openFile(fileBase64Data, fileName, fileType) { }
2148
+ saveFileFromURL(fileUrl, fullFileName = null) { }
2149
+ saveFile(fileBase64Data, fileName, fileType) { }
2150
+ }
2151
+
2152
+ const PAYLOAD_VERSION = 'TUAINEXCHANGE_1.0';
2153
+ const INLINE_ACTION = 'INLINE';
2154
+ const GLOBAL_ACTION = 'GLOBAL';
2155
+ const GET_DATA_ACTION = 'GETDATA';
2156
+ const SUBJECT = 'subject';
2157
+ const TOKEN = 'token';
2158
+ class BasicFormComponent {
2159
+ constructor(formManagerService, _eventManager, fileMgmtServices) {
2160
+ this.formManagerService = formManagerService;
2161
+ this._eventManager = _eventManager;
2162
+ this.fileMgmtServices = fileMgmtServices;
2163
+ this._formStructure = null;
2164
+ this._controlToken = null;
2165
+ this._originToken = null;
2166
+ this._formRoute = null;
2167
+ this._definitionObtained = false;
2168
+ // Eventos de acciones y campos
2169
+ this._formSectionsActivate = {};
2170
+ this._formSectionsInactivate = {};
2171
+ this._formActionsStart = {};
2172
+ this._formActionsFinish = {};
2173
+ this._fieldInputValidation = {};
2174
+ this._fieldValidationsStart = {};
2175
+ this._fieldValidationsFinish = {};
2176
+ // Callback de acciones de tablas
2177
+ this._tableSelectionsStart = {};
2178
+ this._tableSelectionsFinish = {};
2179
+ this._tableActionsStart = {};
2180
+ this._tableActionsFinish = {};
2181
+ this._tableGetDataStart = {};
2182
+ this._tableGetDataFinish = {};
2183
+ this._actionServerError = [];
2184
+ this._fieldServerError = [];
2185
+ this._tableServerError = [];
2186
+ this.inputDataFields = {};
2187
+ this.extraData = {};
2188
+ this.enabledSections = [];
2189
+ this.name = null;
2190
+ this.formSubject = null;
2191
+ this._errorType = '';
2192
+ this.errorCode = '';
2193
+ this.errorFullCode = '';
2194
+ this.errorName = '';
2195
+ this.errorMessage = '';
2196
+ this.errorDetail = '';
2197
+ this.visible = false;
2198
+ this.busy = false;
2199
+ this._eventEmiter = this._eventManager;
2200
+ this.cleanStart();
2201
+ this.customPreProcessing();
2202
+ }
2203
+ getTitle() { return this._formStructure?.getTitle(); }
2204
+ setTitle(title) { return this._formStructure?.setTitle(title); }
2205
+ cleanData() { return this._formStructure?.cleanData(); }
2206
+ getCurrentState() { return this._formStructure?.getCurrentState(); }
2207
+ supportState(state) { return this._formStructure?.supportState(state ?? '') ?? false; }
2208
+ changeState(state) { return this._formStructure?.changeState(state) ?? false; }
2209
+ getStates() { return this._formStructure?.states; }
2210
+ getImmutableElement(name) { return this._formStructure?.getImmutableElement(name); }
2211
+ getExtraInfo(name) { return this._formStructure?.getExtraInfo(name); }
2212
+ getFields() { return this._formStructure?.getFields() ?? null; }
2213
+ getFieldNames() { return this._formStructure?.getFieldNames() ?? null; }
2214
+ getField(code) { return this._formStructure?.getField(code) ?? null; }
2215
+ enableField(code) { return this._formStructure?.enableField(code); }
2216
+ disableField(code) { return this._formStructure?.disableField(code); }
2217
+ getFieldValue(code) { return this._formStructure?.getFieldValue(code) ?? null; }
2218
+ getFieldOptionText(code) { return this._formStructure?.getFieldOptionText(code); }
2219
+ getFieldsValues(codes) { return this._formStructure?.getFieldsValues(codes) ?? null; }
2220
+ getFieldOptions(code) { return this._formStructure?.getFieldOptions(code) ?? null; }
2221
+ setFieldValue(code, value) { return this._formStructure?.setFieldValue(code, value); }
2222
+ setFieldRequired(code, required) { return this._formStructure?.setFieldRequired(code, required); }
2223
+ setFieldErrorMessage(code, errorMessage) { return this._formStructure?.setFieldErrorMessage(code, errorMessage); }
2224
+ setFieldError(code, errorCode, message, type) { return this._formStructure?.setFieldError(code, errorCode, message, type); }
2225
+ setFieldIntrinsicErrorMessage(code, message) {
2226
+ return this._formStructure?.setFieldIntrinsicErrorMessage(code, message);
2227
+ }
2228
+ setFieldOptions(code, optionsArray, idAttribute, nameAttribute) {
2229
+ return this._formStructure?.setFieldOptions(code, optionsArray, idAttribute, nameAttribute);
2230
+ }
2231
+ getFieldSet(filterFunc, codes, secCode, subCode) {
2232
+ return this._formStructure?.getFieldSet(filterFunc, codes ?? null, secCode ?? null, subCode ?? null);
2233
+ }
2234
+ applyOnFields(processFunc, codes, secCode, subCode) {
2235
+ return this._formStructure?.applyOnFields(processFunc, codes, secCode, subCode);
2236
+ }
2237
+ applyProcessToAllFields(processFunc) {
2238
+ return this._formStructure?.applyOnFields(processFunc);
2239
+ }
2240
+ cleanFields(codes, secCode, subCode) {
2241
+ return this._formStructure?.cleanFields(codes, secCode, subCode);
2242
+ }
2243
+ getRequiredFields(codes, secCode, subCode) {
2244
+ return this._formStructure?.getRequiredFields(codes, secCode, subCode);
2245
+ }
2246
+ getRequiredEmptyFields(codes, secCode, subCode) {
2247
+ return this._formStructure?.getRequiredEmptyFields(codes, secCode, subCode) ?? null;
2248
+ }
2249
+ getChangedFields(codes, secCode, subCode) {
2250
+ return this._formStructure?.getChangedFields(codes, secCode, subCode);
2251
+ }
2252
+ getFieldsWithValidationIssues(codes, secCode, subCode) {
2253
+ return this._formStructure?.getFieldsWithValidationIssues(codes, secCode, subCode);
2254
+ }
2255
+ tagFieldsWithError(errorMessage, codes, secCode, subCode) {
2256
+ return this._formStructure?.tagFieldsWithError(errorMessage, codes, secCode, subCode);
2257
+ }
2258
+ cleanErrorFields(codes, secCode, subCode) {
2259
+ return this._formStructure?.cleanErrorFields(codes, secCode, subCode);
2260
+ }
2261
+ showLabelFields(codes, secCode, subCode) {
2262
+ return this._formStructure?.showLabelFields(codes, secCode, subCode);
2263
+ }
2264
+ hideLabelFields(codes, secCode, subCode) {
2265
+ return this._formStructure?.hideLabelFields(codes, secCode, subCode);
2266
+ }
2267
+ enableFields(codes, secCode, subCode) {
2268
+ return this._formStructure?.enableFields(codes, secCode, subCode);
2269
+ }
2270
+ disableFields(codes, secCode, subCode) {
2271
+ return this._formStructure?.disableFields(codes, secCode, subCode);
2272
+ }
2273
+ /**
2274
+ * @deprecated Use enableFields
2275
+ */
2276
+ enableEditFields(codes, secCode, subCode) {
2277
+ return this.enableFields(codes, secCode, subCode);
2278
+ }
2279
+ /**
2280
+ * @deprecated Use disableFields
2281
+ */
2282
+ disableEditFields(codes, secCode, subCode) {
2283
+ return this.disableFields(codes, secCode, subCode);
2284
+ }
2285
+ showFields(codes, secCode, subCode) {
2286
+ return this._formStructure?.showFields(codes, secCode, subCode);
2287
+ }
2288
+ hideFields(codes, secCode, subCode) {
2289
+ return this._formStructure?.hideFields(codes, secCode, subCode);
2290
+ }
2291
+ getActionsByAttribute(name, value) {
2292
+ return this._formStructure?.getActionsByAttribute(name, value);
2293
+ }
2294
+ getHeaderActions() {
2295
+ return this._formStructure?.getActionsByAttribute('location', HEADER$1);
2296
+ }
2297
+ getAction(actionCode) {
2298
+ return this._formStructure?.getAction(actionCode) ?? null;
2299
+ }
2300
+ showActions(actionArray) {
2301
+ return this._formStructure?.showActions(actionArray);
2302
+ }
2303
+ hideActions(actionArray) {
2304
+ return this._formStructure?.hideActions(actionArray);
2305
+ }
2306
+ enableActions(actionArray) {
2307
+ return this._formStructure?.enableActions(actionArray);
2308
+ }
2309
+ disableActions(actionArray) {
2310
+ return this._formStructure?.disableActions(actionArray);
2311
+ }
2312
+ showAction(code) {
2313
+ return this._formStructure?.showActions(code);
2314
+ }
2315
+ hideAction(code) {
2316
+ return this._formStructure?.hideActions(code);
2317
+ }
2318
+ enableAction(code) {
2319
+ return this._formStructure?.enableActions(code);
2320
+ }
2321
+ disableAction(code) {
2322
+ return this._formStructure?.disableActions(code);
2323
+ }
2324
+ getSections() {
2325
+ return this._formStructure?.getSections() ?? null;
2326
+ }
2327
+ activateSection(code) {
2328
+ return this._formStructure?.activateSection(code);
2329
+ }
2330
+ getSectionsTitles() {
2331
+ return this._formStructure?.getSections().map(sec => sec.title) ?? null;
2332
+ }
2333
+ getSection(code) {
2334
+ return this._formStructure?.getSection(code) ?? null;
2335
+ }
2336
+ showSection(code) {
2337
+ return this._formStructure?.showSections(code);
2338
+ }
2339
+ hideSection(code) {
2340
+ return this._formStructure?.hideSections(code);
2341
+ }
2342
+ showSections(codes) {
2343
+ return this._formStructure?.showSections(codes);
2344
+ }
2345
+ hideSections(codes) {
2346
+ return this._formStructure?.hideSections(codes);
2347
+ }
2348
+ getSubSection(code, subCode) {
2349
+ return this._formStructure?.getSubSection(code, subCode) ?? null;
2350
+ }
2351
+ showSubSection(code, subCode) {
2352
+ return this._formStructure?.showSubSections(code, subCode);
2353
+ }
2354
+ hideSubSection(code, subCode) {
2355
+ return this._formStructure?.hideSubSections(code, subCode);
2356
+ }
2357
+ showSubSections(code, subCodes) {
2358
+ return this._formStructure?.showSubSections(code, subCodes);
2359
+ }
2360
+ hideSubSections(code, subCodes) {
2361
+ return this._formStructure?.hideSubSections(code, subCodes);
2362
+ }
2363
+ getSectionActions(code) {
2364
+ return this._formStructure?.getSectionActions(code) ?? null;
2365
+ }
2366
+ getSectionActionNames(code) {
2367
+ return this._formStructure?.getSectionActionNames(code) ?? null;
2368
+ }
2369
+ getTables() {
2370
+ return this._formStructure?.getTables();
2371
+ }
2372
+ showTables(codes) {
2373
+ return this._formStructure?.showTables(codes);
2374
+ }
2375
+ hideTables(codes) {
2376
+ return this._formStructure?.hideTables(codes);
2377
+ }
2378
+ cleanTables(codes) {
2379
+ return this._formStructure?.cleanTables(codes);
2380
+ }
2381
+ getTable(code) {
2382
+ return this._formStructure?.getTable(code) ?? null;
2383
+ }
2384
+ showTable(code) {
2385
+ return this._formStructure?.showTables(code);
2386
+ }
2387
+ hideTable(code) {
2388
+ return this._formStructure?.hideTables(code);
2389
+ }
2390
+ cleanTable(code) {
2391
+ return this._formStructure?.getTable(code)?.clean();
2392
+ }
2393
+ getTableRecord(code, recordId) {
2394
+ return this._formStructure?.getTableRecord(code, recordId);
2395
+ }
2396
+ setConfig(formConfig) {
2397
+ this.formConfig = formConfig;
2398
+ }
2399
+ cleanStart() {
2400
+ this._errorType = '';
2401
+ this.errorCode = '';
2402
+ this.errorFullCode = '';
2403
+ this.errorName = '';
2404
+ this.errorMessage = '';
2405
+ this.errorDetail = '';
2406
+ this._formStructure = null;
2407
+ this.fields = null;
2408
+ this.actions = null;
2409
+ this.sections = null;
2410
+ this._controlToken = null;
2411
+ this.inputDataFields = {};
2412
+ this._definitionObtained = false;
2413
+ // Se limpian los manejadores de eventos
2414
+ this.visible = false;
2415
+ this.busy = false;
2416
+ this._formSectionsActivate = {};
2417
+ this._formSectionsInactivate = {};
2418
+ this._formActionsStart = {};
2419
+ this._formActionsFinish = {};
2420
+ this._fieldInputValidation = {};
2421
+ this._fieldValidationsStart = {};
2422
+ this._fieldValidationsFinish = {};
2423
+ this._tableSelectionsStart = {};
2424
+ this._tableSelectionsFinish = {};
2425
+ this._tableActionsStart = {};
2426
+ this._tableActionsFinish = {};
2427
+ this._tableGetDataStart = {};
2428
+ this._tableGetDataFinish = {};
2429
+ this._actionServerError = [];
2430
+ this._fieldServerError = [];
2431
+ this._tableServerError = [];
2432
+ this.onActionServerError(() => this.displayActionServerError());
2433
+ this.onValidationServerError(() => this.displayValidationServerError());
2434
+ this.onTableServerError(() => this.displayTableServerError());
2435
+ }
2436
+ get formVisible() { return this.visible; }
2437
+ get formManager() { return this; }
2438
+ get formCode() { return this.name ?? ''; }
2439
+ set formCode(name) { this.name = name; }
2440
+ get inServerProcess() { return this.busy; }
2441
+ get form() { return this._formStructure; }
2442
+ get state() { return this._formStructure?.state ?? null; }
2443
+ get currentState() { return this._formStructure?.state ?? ''; }
2444
+ set currentState(state) { this?._formStructure?.changeState(state); }
2445
+ get immutableData() { return this._formStructure?.immutableData; }
2446
+ get extraInfo() { return this._formStructure?.extraInfo; }
2447
+ get visibleSections() { return this._formStructure?.visibleSections ?? null; }
2448
+ get formRoute() { return this._formRoute ?? ''; }
2449
+ set formRoute(route) { this._formRoute = route; }
2450
+ get subject() { return this.formSubject ?? ''; }
2451
+ // Métodos virtuales
2452
+ customPreProcessing() { }
2453
+ customFormStart() { }
2454
+ displayActionServerError() { }
2455
+ displayValidationServerError() { }
2456
+ displayTableServerError() { }
2457
+ showFieldInfo(fieldCode, detail) { }
2458
+ showModalDialog(title, body, options, callback, params) { }
2459
+ openUploadDialog(title, body, options, callback, params) { }
2460
+ /**
2461
+ * @deprecated Use supportState
2462
+ */
2463
+ supportMode(state) { return this.supportState(state); }
2464
+ /**
2465
+ * @deprecated Use getField
2466
+ */
2467
+ getFieldObject(code) { return this.getField(code); }
2468
+ /**
2469
+ * @deprecated Use getAction
2470
+ */
2471
+ getActionObject(code) { return this.getAction(code); }
2472
+ /**
2473
+ * @deprecated Use getTable
2474
+ */
2475
+ getTableObject(code) { return this.getTable(code); }
2476
+ /**
2477
+ * @deprecated Use getSection
2478
+ */
2479
+ getSectionObject(code) { return this.getSection(code); }
2480
+ /**
2481
+ * @deprecated Use changeState
2482
+ */
2483
+ changeFormMode(state) { return this.changeState(state); }
2484
+ /**
2485
+ * @deprecated Use subject
2486
+ */
2487
+ getFormSubject() { return this.subject; }
2488
+ /**
2489
+ * @deprecated Use subject
2490
+ */
2491
+ getSubject() { return this.formSubject ?? ''; }
2492
+ /**
2493
+ * @deprecated Use subject
2494
+ */
2495
+ getformSubject() { return this.formSubject ?? ''; }
2496
+ numSections() { return this._formStructure?.sections.length; }
2497
+ subscribeAppEvent(eventName, callback) {
2498
+ this._eventEmiter.subscribe(eventName, callback);
2499
+ }
2500
+ openForm(name, data = null, backData = null, cleanStack = false) {
2501
+ let origin = null;
2502
+ if (!cleanStack) {
2503
+ origin = { ...backData, name: this.name, url: this._formRoute, token: this._controlToken };
2504
+ origin.subject = origin?.subject ?? this.formSubject;
2505
+ origin.state = origin?.state ?? this.state;
2506
+ origin.fields = origin?.fields ?? {};
2507
+ origin.extra = origin?.extra ?? {};
2508
+ }
2509
+ const target = { ...data, name };
2510
+ target.subject = target?.subject ?? null;
2511
+ target.state = target?.state ?? null;
2512
+ target.fields = target?.fields ?? {};
2513
+ target.extra = target?.extra ?? {};
2514
+ this.formManagerService.openForm(origin, target);
2515
+ }
2516
+ canGoBack() { return this._originToken !== null; }
2517
+ goBack() { return this.formManagerService.backTo(); }
2518
+ goBackForm() { return this.goBack(); }
2519
+ getOriginDetail() { return this.formManagerService?.getFormInfo(this._originToken ?? ''); }
2520
+ setError(errorType, errorMessage, errorDetail) {
2521
+ this._errorType = errorType || '';
2522
+ this.errorMessage = errorMessage || '';
2523
+ this.errorDetail = errorDetail || '';
2524
+ }
2525
+ resetError() {
2526
+ this.errorCode = NO_ERROR;
2527
+ this.errorFullCode = '';
2528
+ this.errorName = '';
2529
+ this.errorMessage = '';
2530
+ this.errorDetail = '';
2531
+ }
2532
+ getErrorType() { return this._errorType; }
2533
+ getErrorMessage() { return this.errorMessage; }
2534
+ getErrorDetail() { return this.errorDetail; }
2535
+ getErrorName() { return this.errorName; }
2536
+ getErrorFullCode() { return this.errorFullCode; }
2537
+ getErrorCode() { return this.errorCode; }
2538
+ getFormParameter(name) {
2539
+ return (name) ? (this.extraData?.[name] ?? null) : null;
2540
+ }
2541
+ preocessInputParams(params) {
2542
+ this._controlToken = params?.[TOKEN] ?? null;
2543
+ this.formSubject = params?.[SUBJECT] ?? null;
2544
+ const tokenInfo = (this._controlToken) ? this.formManagerService.getFormInfo(this._controlToken) : {};
2545
+ const { token, subject, state, fields, extra, originToken } = tokenInfo;
2546
+ if (token && this._controlToken === token) {
2547
+ this.formSubject = this.formSubject ?? subject ?? null;
2548
+ this.inputDataFields = fields;
2549
+ this.extraData = extra;
2550
+ this._originToken = originToken;
2551
+ return state;
2552
+ }
2553
+ return null;
2554
+ }
2555
+ subscribeSectionActivation() {
2556
+ const formSections = this._formStructure?.sections;
2557
+ const sectionNames = Object.keys(formSections);
2558
+ for (let index = 0; index < sectionNames.length; index++) {
2559
+ const sectionName = sectionNames[index];
2560
+ const section = formSections[sectionName];
2561
+ section.activation.subscribe((code) => this.launchSectionActivation(code));
2562
+ section.inactivation.subscribe((code) => this.launchSectionInactivation(code));
2563
+ }
2564
+ }
2565
+ subscribeFieldsSubjects() {
2566
+ const formFields = this._formStructure?.getFields();
2567
+ if (Array.isArray(formFields)) {
2568
+ formFields.forEach(field => {
2569
+ field.editionFinish.subscribe(event => {
2570
+ const { code, intrinsicValidation } = event;
2571
+ this.startFieldValidation(code, intrinsicValidation);
2572
+ });
2573
+ field.editionPartial.subscribe(event => {
2574
+ const { code, intrinsicValidation } = event;
2575
+ this.startFieldInputValidation(code, intrinsicValidation);
2576
+ });
2577
+ field.detailRequest.subscribe(event => this.showFieldInfo(event.code, event.detail));
2578
+ });
2579
+ }
2580
+ }
2581
+ subscribeActionSubjects() {
2582
+ const formActions = this._formStructure?.getActions();
2583
+ if (Array.isArray(formActions)) {
2584
+ formActions.forEach(action => {
2585
+ action.actionActivated.subscribe(code => this.startAction(code));
2586
+ });
2587
+ }
2588
+ }
2589
+ subscribeTableSubjects() {
2590
+ const formTables = this._formStructure?.getTables();
2591
+ if (Array.isArray(formTables)) {
2592
+ formTables.forEach(table => {
2593
+ table.inlineActionTrigger.subscribe(event => this.startTableAction(event));
2594
+ table.globalActionTrigger.subscribe(event => this.startTableGlobalAction(event));
2595
+ table.recordSelectionTrigger.subscribe(event => this.startTableRecordSelection(event));
2596
+ table.selectionActionTrigger.subscribe(event => this.startTableSelectionAction(event));
2597
+ table.getDataTrigger.subscribe(event => this.startTableGetData(event));
2598
+ });
2599
+ }
2600
+ }
2601
+ async formInit(params) {
2602
+ let initialState = this.preocessInputParams(params);
2603
+ if (!this.name) {
2604
+ return;
2605
+ }
2606
+ if (!this._definitionObtained) {
2607
+ this.busy = true;
2608
+ const formDefinition = await this.formManagerService.getFormDefinition(this.name);
2609
+ this.busy = false;
2610
+ this._formStructure = new FormStructureAndData(formDefinition, this.formConfig);
2611
+ this.fields = this._formStructure?.fields;
2612
+ this.actions = this._formStructure?.actions;
2613
+ this.sections = this._formStructure?.sections;
2614
+ this._definitionObtained = true;
2615
+ }
2616
+ else {
2617
+ this.cleanData();
2618
+ }
2619
+ if (!this.supportState(initialState)) {
2620
+ initialState = this._formStructure?.defaultState ?? null;
2621
+ }
2622
+ this._formStructure?.changeState(initialState || this._formStructure?.defaultState);
2623
+ const inputFieldNames = Object.keys(this.inputDataFields);
2624
+ for (let index = 0; index < inputFieldNames.length; index++) {
2625
+ const fieldCode = inputFieldNames[index];
2626
+ const fieldValue = this.inputDataFields[fieldCode];
2627
+ this.setFieldValue(fieldCode, fieldValue);
2628
+ }
2629
+ const recordResponse = await this.requestFormAction(formActions.getData);
2630
+ this.checkErrorRecordReceived(recordResponse);
2631
+ this.visible = true;
2632
+ this.enabledSections = this._formStructure?.visibleSections ?? [];
2633
+ this.subscribeSectionActivation();
2634
+ this.subscribeFieldsSubjects();
2635
+ this.subscribeActionSubjects();
2636
+ this.subscribeTableSubjects();
2637
+ this.customFormStart();
2638
+ }
2639
+ checkErrorRecordReceived(recordResponse) {
2640
+ const { error } = recordResponse;
2641
+ if (!error) {
2642
+ return false;
2643
+ }
2644
+ this.errorCode = recordResponse.errorCode;
2645
+ this.errorFullCode = recordResponse.errorFullCode;
2646
+ this.errorName = recordResponse.errorName;
2647
+ this.errorMessage = recordResponse.errorMessage;
2648
+ this.errorDetail = recordResponse.errorDetail;
2649
+ return true;
2650
+ }
2651
+ errorOccured() {
2652
+ return (this.errorCode !== NO_ERROR);
2653
+ }
2654
+ /**
2655
+ * Soporte manejo de eventos de formulario
2656
+ */
2657
+ async requestFormAction(actionCode, actionSubject = {}) {
2658
+ const actionDetail = {
2659
+ formCode: this.name,
2660
+ formSubject: this.formSubject,
2661
+ currentMode: this._formStructure?.state,
2662
+ actionCode,
2663
+ actionSubject,
2664
+ version: PAYLOAD_VERSION,
2665
+ formData: this._formStructure?.getPayload(),
2666
+ immutableData: this._formStructure?.immutableData,
2667
+ };
2668
+ this.errorCode = NO_ERROR;
2669
+ this.errorFullCode = '';
2670
+ this.errorName = '';
2671
+ this.errorMessage = '';
2672
+ this.errorDetail = '';
2673
+ this.busy = true;
2674
+ const formActionResponse = await this.formManagerService.execServerAction(actionDetail);
2675
+ this.busy = false;
2676
+ if (formActionResponse.hasError()) {
2677
+ const error = formActionResponse.error;
2678
+ this.errorCode = error.errorCode;
2679
+ this.errorFullCode = error.errorFullCode;
2680
+ this.errorName = error.errorName;
2681
+ this.errorMessage = error.errorMessage;
2682
+ this.errorDetail = error.errorDetail;
2683
+ }
2684
+ const formResponseData = formActionResponse.getData();
2685
+ this.updateFormWithServerData(formResponseData);
2686
+ return formResponseData;
2687
+ }
2688
+ updateFormWithServerData(formContent) {
2689
+ const { currentMode, formSubject, actions, fields, recordTables, returnedFile, immutableData, extraInfo, } = formContent;
2690
+ currentMode && this.changeState(currentMode);
2691
+ if (formSubject) {
2692
+ this.formSubject = formSubject;
2693
+ }
2694
+ if (actions && actions.length > 0) {
2695
+ for (const changedAction of actions) {
2696
+ const actionObject = this.getAction(changedAction.actionCode);
2697
+ if (actionObject) {
2698
+ actionObject.updateFromServer(changedAction);
2699
+ }
2700
+ }
2701
+ }
2702
+ if (fields && fields.length > 0) {
2703
+ for (const changedField of fields) {
2704
+ const fieldObject = this.getField(changedField.fieldCode);
2705
+ if (fieldObject) {
2706
+ fieldObject.updateFromServer(changedField);
2707
+ }
2708
+ }
2709
+ }
2710
+ if (recordTables && recordTables.length > 0) {
2711
+ for (const changedTable of recordTables) {
2712
+ const tableObject = this.getTable(changedTable.tableCode);
2713
+ if (tableObject) {
2714
+ tableObject.updateFromServer(changedTable);
2715
+ }
2716
+ }
2717
+ }
2718
+ if (returnedFile && returnedFile.file) {
2719
+ this.fileMgmtServices.saveFile(returnedFile.file, returnedFile.name, returnedFile.type);
2720
+ }
2721
+ if (this._formStructure) {
2722
+ this._formStructure.immutableData = immutableData;
2723
+ this._formStructure.extraInfo = extraInfo;
2724
+ }
2725
+ }
2726
+ /**
2727
+ * Manejo de event handlers para errores Server del formulario
2728
+ */
2729
+ cleanActionServerError() {
2730
+ this._actionServerError = [];
2731
+ }
2732
+ cleanFieldServerError() {
2733
+ this._fieldServerError = [];
2734
+ }
2735
+ cleanTableServerError() {
2736
+ this._tableServerError = [];
2737
+ }
2738
+ onActionServerError(callback, properties = null) {
2739
+ this._actionServerError.push({ callback, properties });
2740
+ }
2741
+ onValidationServerError(callback, properties = null) {
2742
+ this._fieldServerError.push({ callback, properties });
2743
+ }
2744
+ onTableServerError(callback, properties = null) {
2745
+ this._tableServerError.push({ callback, properties });
2746
+ }
2747
+ /**
2748
+ * Manejo de event handlers para acciones sobre el formulario
2749
+ */
2750
+ onSectionActivation(codes, callback, properties = null) {
2751
+ const sectionSet = (Array.isArray(codes)) ? codes : (codes ? [codes] : []);
2752
+ sectionSet.forEach((sectionName) => {
2753
+ if (!this._formSectionsActivate[sectionName]) {
2754
+ this._formSectionsActivate[sectionName] = [];
2755
+ }
2756
+ this._formSectionsActivate[sectionName].push({ callback, properties });
2757
+ });
2758
+ }
2759
+ onSectionInactivation(codes, callback, properties = null) {
2760
+ const sectionSet = (Array.isArray(codes)) ? codes : (codes ? [codes] : []);
2761
+ sectionSet.forEach((sectionName) => {
2762
+ if (!this._formSectionsInactivate[sectionName]) {
2763
+ this._formSectionsInactivate[sectionName] = [];
2764
+ }
2765
+ this._formSectionsInactivate[sectionName].push({ callback, properties });
2766
+ });
2767
+ }
2768
+ onActionStart(codes, callback, properties = null) {
2769
+ const actionSet = (Array.isArray(codes)) ? codes : (codes ? [codes] : []);
2770
+ actionSet.forEach((actionName) => {
2771
+ if (!this._formActionsStart[actionName]) {
2772
+ this._formActionsStart[actionName] = [];
2773
+ }
2774
+ this._formActionsStart[actionName].push({ callback, properties });
2775
+ });
2776
+ }
2777
+ onActionFinish(codes, callback, properties = null) {
2778
+ const actionSet = (Array.isArray(codes)) ? codes : (codes ? [codes] : []);
2779
+ actionSet.forEach((actionName) => {
2780
+ if (!this._formActionsFinish[actionName]) {
2781
+ this._formActionsFinish[actionName] = [];
2782
+ }
2783
+ this._formActionsFinish[actionName].push({ callback, properties });
2784
+ });
2785
+ }
2786
+ async launchSectionActivation(code) {
2787
+ const sectionObject = this._formStructure?.getSection(code);
2788
+ if (!sectionObject) {
2789
+ return;
2790
+ }
2791
+ const clientSectionMethods = this._formSectionsActivate[code];
2792
+ if (clientSectionMethods) {
2793
+ for (const clientSectionMethod of clientSectionMethods) {
2794
+ const { callback, properties } = clientSectionMethod;
2795
+ callback(sectionObject);
2796
+ }
2797
+ }
2798
+ }
2799
+ async launchSectionInactivation(code) {
2800
+ const sectionObject = this._formStructure?.getSection(code);
2801
+ if (!sectionObject) {
2802
+ return;
2803
+ }
2804
+ const clientSectionMethods = this._formSectionsInactivate[code];
2805
+ if (clientSectionMethods) {
2806
+ for (const clientSectionMethod of clientSectionMethods) {
2807
+ const { callback, properties } = clientSectionMethod;
2808
+ callback(sectionObject);
2809
+ }
2810
+ }
2811
+ }
2812
+ async startAction(code) {
2813
+ const actionObject = this.getAction(code);
2814
+ if (!actionObject) {
2815
+ return;
2816
+ }
2817
+ this.resetError();
2818
+ actionObject.start();
2819
+ const clientActionMethods = this._formActionsStart[code];
2820
+ if (clientActionMethods) {
2821
+ const clientActionPromises = [];
2822
+ for (const clientActionMethod of clientActionMethods) {
2823
+ const { callback, properties } = clientActionMethod;
2824
+ const continueActionPromise = callback(actionObject);
2825
+ clientActionPromises.push(continueActionPromise);
2826
+ }
2827
+ const clientActionResults = await Promise.all(clientActionPromises);
2828
+ const continueAction = clientActionResults.reduce((total, curr) => (total && (curr !== false)), true);
2829
+ if (!continueAction) {
2830
+ actionObject.stop();
2831
+ return;
2832
+ }
2833
+ }
2834
+ this.startServerAction(actionObject);
2835
+ }
2836
+ async startServerAction(actionInput) {
2837
+ const action = (typeof actionInput === 'string')
2838
+ ? this.getAction(actionInput) : actionInput;
2839
+ let serverError = false;
2840
+ let actionResult = null;
2841
+ if (action.backend) {
2842
+ actionResult = await this.requestFormAction(action.actionCode);
2843
+ serverError = !!this.errorOccured();
2844
+ }
2845
+ await this.finishAction(action, actionResult, serverError);
2846
+ if (!serverError) {
2847
+ action.newState && this.changeState(action.newState);
2848
+ }
2849
+ else {
2850
+ for (let index = 0; index < this._actionServerError.length; index++) {
2851
+ const { callback, properties } = this._actionServerError[index];
2852
+ callback(action);
2853
+ }
2854
+ }
2855
+ action.stop();
2856
+ }
2857
+ async finishAction(action, actionResult, serverError = false) {
2858
+ const finishActionMethods = this._formActionsFinish[action.actionCode];
2859
+ if (finishActionMethods) {
2860
+ const clientActionPromises = [];
2861
+ for (const clientActionMethod of finishActionMethods) {
2862
+ const { callback, properties } = clientActionMethod;
2863
+ const continueOnError = properties?.continueOnError ?? false;
2864
+ if (!serverError || continueOnError) {
2865
+ clientActionPromises.push(callback(action, actionResult));
2866
+ }
2867
+ }
2868
+ await Promise.all(clientActionPromises);
2869
+ }
2870
+ }
2871
+ completeGlobalAction(action) {
2872
+ return this.startServerAction(action);
2873
+ }
2874
+ /**
2875
+ * Manejadores de eventos para validaciones sobre campos
2876
+ */
2877
+ onFieldInput(codes, callback, properties = null) {
2878
+ const fieldSet = (Array.isArray(codes)) ? codes : (codes ? [codes] : []);
2879
+ fieldSet.forEach((fieldCode) => {
2880
+ if (!this._fieldInputValidation[fieldCode]) {
2881
+ this._fieldInputValidation[fieldCode] = [];
2882
+ }
2883
+ this._fieldInputValidation[fieldCode].push({ callback, properties });
2884
+ });
2885
+ }
2886
+ onFieldValidationStart(codes, callback, properties = null) {
2887
+ const fieldSet = (Array.isArray(codes)) ? codes : (codes ? [codes] : []);
2888
+ fieldSet.forEach((fieldCode) => {
2889
+ if (!this._fieldValidationsStart[fieldCode]) {
2890
+ this._fieldValidationsStart[fieldCode] = [];
2891
+ }
2892
+ this._fieldValidationsStart[fieldCode].push({ callback, properties });
2893
+ });
2894
+ }
2895
+ onFieldValidationFinish(codes, callback, properties = null) {
2896
+ const fieldSet = (Array.isArray(codes)) ? codes : (codes ? [codes] : []);
2897
+ fieldSet.forEach((fieldCode) => {
2898
+ if (!this._fieldValidationsFinish[fieldCode]) {
2899
+ this._fieldValidationsFinish[fieldCode] = [];
2900
+ }
2901
+ this._fieldValidationsFinish[fieldCode].push({ callback, properties });
2902
+ });
2903
+ }
2904
+ async startFieldInputValidation(fieldCode, intrinsicValidation = true) {
2905
+ const fieldToValidate = this.getField(fieldCode);
2906
+ if (!fieldToValidate) {
2907
+ return false;
2908
+ }
2909
+ fieldToValidate.resetError();
2910
+ const validationCallbacks = this._fieldInputValidation[fieldCode];
2911
+ if (validationCallbacks) {
2912
+ const clientValidationPromises = [];
2913
+ for (const validationMethod of validationCallbacks) {
2914
+ const { callback, properties } = validationMethod;
2915
+ const continueValidationPromise = callback(fieldToValidate);
2916
+ clientValidationPromises.push(continueValidationPromise);
2917
+ }
2918
+ await Promise.all(clientValidationPromises);
2919
+ }
2920
+ return true;
2921
+ }
2922
+ async startFieldValidation(fieldCode, intrinsicValidation = true) {
2923
+ const fieldToValidate = this.getField(fieldCode);
2924
+ if (!fieldToValidate) {
2925
+ return;
2926
+ }
2927
+ fieldToValidate.resetError();
2928
+ const validationCallbacks = this._fieldValidationsStart[fieldCode];
2929
+ if (validationCallbacks) {
2930
+ const clientValidationPromises = [];
2931
+ for (const validationMethod of validationCallbacks) {
2932
+ const { callback, properties } = validationMethod;
2933
+ const clientValidationPromise = callback(fieldToValidate);
2934
+ clientValidationPromises.push(clientValidationPromise);
2935
+ }
2936
+ const clientValidationResults = await Promise.all(clientValidationPromises);
2937
+ const continueValidation = clientValidationResults.reduce((total, curr) => (total && (curr !== false)), true);
2938
+ if (!continueValidation) {
2939
+ return;
2940
+ }
2941
+ }
2942
+ if (intrinsicValidation) {
2943
+ this.startServerFieldValidation(fieldToValidate);
2944
+ }
2945
+ }
2946
+ async startServerFieldValidation(inputField) {
2947
+ const fieldObj = (typeof inputField === 'string')
2948
+ ? this.getField(inputField) : inputField;
2949
+ let serverError = false;
2950
+ let validationResult = true;
2951
+ if (!fieldObj) {
2952
+ return;
2953
+ }
2954
+ if (fieldObj.backend) {
2955
+ fieldObj.validating = true;
2956
+ validationResult = await this
2957
+ .requestFormAction(formActions.validate, fieldObj.fieldCode);
2958
+ serverError = !!this.errorOccured();
2959
+ }
2960
+ await this.finishFieldValidation(fieldObj, validationResult, serverError);
2961
+ if (serverError) {
2962
+ fieldObj?.setErrorCode(this.errorCode);
2963
+ fieldObj?.setErrorMessage(this.errorMessage);
2964
+ for (let index = 0; index < this._fieldServerError.length; index++) {
2965
+ const { callback, properties } = this._fieldServerError[index];
2966
+ callback(fieldObj);
2967
+ }
2968
+ }
2969
+ fieldObj.validating = false;
2970
+ }
2971
+ async finishFieldValidation(fieldObject, validationResult, serverError = false) {
2972
+ const validationCallbacks = this._fieldValidationsFinish[fieldObject.fieldCode];
2973
+ if (validationCallbacks) {
2974
+ const clientActionPromises = [];
2975
+ for (const validationMethod of validationCallbacks) {
2976
+ const { callback, properties } = validationMethod;
2977
+ const continueOnError = properties?.continueOnError ?? false;
2978
+ if (!serverError || continueOnError) {
2979
+ clientActionPromises.push(callback(fieldObject, validationResult));
2980
+ }
2981
+ }
2982
+ await Promise.all(clientActionPromises);
2983
+ }
2984
+ }
2985
+ async continueFieldValidation(fieldCode) {
2986
+ return this.startServerFieldValidation(fieldCode);
2987
+ }
2988
+ /**
2989
+ * Manejadores de eventos para acciones sobre Tablas
2990
+ */
2991
+ onTableActionStart(code, actionCode, callback, properties = null) {
2992
+ const tableObject = this.getTable(code);
2993
+ if (!tableObject) {
2994
+ return;
2995
+ }
2996
+ const inlineActionObject = tableObject.getAction(actionCode);
2997
+ if (!inlineActionObject) {
2998
+ return;
2999
+ }
3000
+ let tableEventHandlers;
3001
+ if (this._tableActionsStart[code]) {
3002
+ tableEventHandlers = this._tableActionsStart[code];
3003
+ }
3004
+ else {
3005
+ tableEventHandlers = {};
3006
+ this._tableActionsStart[code] = tableEventHandlers;
3007
+ }
3008
+ if (!tableEventHandlers[actionCode]) {
3009
+ tableEventHandlers[actionCode] = [];
3010
+ }
3011
+ tableEventHandlers[actionCode].push({ callback, properties });
3012
+ }
3013
+ onTableActionFinish(code, actionCode, callback, properties = null) {
3014
+ const tableObject = this.getTable(code);
3015
+ if (!tableObject) {
3016
+ return;
3017
+ }
3018
+ const inlineActionObject = tableObject.getAction(actionCode);
3019
+ if (!inlineActionObject) {
3020
+ return;
3021
+ }
3022
+ let tableEventHandlers;
3023
+ if (this._tableActionsFinish[code]) {
3024
+ tableEventHandlers = this._tableActionsFinish[code];
3025
+ }
3026
+ else {
3027
+ tableEventHandlers = {};
3028
+ this._tableActionsFinish[code] = tableEventHandlers;
3029
+ }
3030
+ if (!tableEventHandlers[actionCode]) {
3031
+ tableEventHandlers[actionCode] = [];
3032
+ }
3033
+ tableEventHandlers[actionCode].push({ callback, properties });
3034
+ }
3035
+ onTableSelectionStart(code, callback, properties = null) {
3036
+ const tableObject = this.getTable(code);
3037
+ if (!tableObject) {
3038
+ return;
3039
+ }
3040
+ let tableEventHandlers;
3041
+ if (this._tableSelectionsStart[code]) {
3042
+ tableEventHandlers = this._tableSelectionsStart[code];
3043
+ }
3044
+ else {
3045
+ tableEventHandlers = [];
3046
+ this._tableSelectionsStart[code] = tableEventHandlers;
3047
+ }
3048
+ tableEventHandlers.push({ callback, properties });
3049
+ }
3050
+ onTableSelectionFinish(code, callback, properties = null) {
3051
+ const tableObject = this.getTable(code);
3052
+ if (!tableObject) {
3053
+ return;
3054
+ }
3055
+ let tableEventHandlers;
3056
+ if (this._tableSelectionsFinish[code]) {
3057
+ tableEventHandlers = this._tableSelectionsFinish[code];
3058
+ }
3059
+ else {
3060
+ tableEventHandlers = [];
3061
+ this._tableSelectionsFinish[code] = tableEventHandlers;
3062
+ }
3063
+ tableEventHandlers.push({ callback, properties });
3064
+ }
3065
+ onTableGetDataStart(code, callback, properties = null) {
3066
+ const tableObject = this.getTable(code);
3067
+ if (!tableObject) {
3068
+ return;
3069
+ }
3070
+ let tableEventHandlers;
3071
+ if (this._tableGetDataStart[code]) {
3072
+ tableEventHandlers = this._tableGetDataStart[code];
3073
+ }
3074
+ else {
3075
+ tableEventHandlers = [];
3076
+ this._tableGetDataStart[code] = tableEventHandlers;
3077
+ }
3078
+ tableEventHandlers.push({ callback, properties });
3079
+ }
3080
+ onTableGetDataFinish(code, callback, properties = null) {
3081
+ const tableObject = this.getTable(code);
3082
+ if (!tableObject) {
3083
+ return;
3084
+ }
3085
+ let tableEventHandlers;
3086
+ if (this._tableGetDataFinish[code]) {
3087
+ tableEventHandlers = this._tableGetDataFinish[code];
3088
+ }
3089
+ else {
3090
+ tableEventHandlers = {};
3091
+ this._tableGetDataFinish[code] = tableEventHandlers;
3092
+ }
3093
+ tableEventHandlers[GET_DATA_ACTION] = { callback, properties };
3094
+ }
3095
+ async startTableGlobalAction(tableActionEvent) {
3096
+ const { tableCode, actionCode } = tableActionEvent;
3097
+ const tableObject = this.getTable(tableCode);
3098
+ if (!tableObject || !actionCode) {
3099
+ return;
3100
+ }
3101
+ this.resetError();
3102
+ const action = tableObject.getAction(actionCode);
3103
+ if (!action) {
3104
+ return;
3105
+ }
3106
+ const tableActionDetail = {
3107
+ tableObject,
3108
+ action,
3109
+ tableCode,
3110
+ actionCode,
3111
+ };
3112
+ const tableEventHandlers = this._tableActionsStart[tableCode];
3113
+ const tableActionMethods = (tableEventHandlers) ? tableEventHandlers[actionCode] : null;
3114
+ if (tableActionMethods) {
3115
+ const clientActionPromises = [];
3116
+ for (const tableActionMethod of tableActionMethods) {
3117
+ const { callback, properties } = tableActionMethod;
3118
+ const clientActionPromise = callback(tableActionDetail);
3119
+ clientActionPromises.push(clientActionPromise);
3120
+ }
3121
+ const clientActionResults = await Promise.all(clientActionPromises);
3122
+ const continueAction = clientActionResults.reduce((total, curr) => (total && (curr !== false)), true);
3123
+ if (!continueAction) {
3124
+ return;
3125
+ }
3126
+ }
3127
+ this.startTableServerGlobalAction(tableActionDetail);
3128
+ }
3129
+ async startTableServerGlobalAction(tableActionDetail) {
3130
+ const { tableObject, action, tableCode, actionCode } = tableActionDetail;
3131
+ if (!tableObject || !action) {
3132
+ return;
3133
+ }
3134
+ tableObject.putOnWait();
3135
+ let serverError = false;
3136
+ let actionResult = null;
3137
+ if (action.backend) {
3138
+ const actionSubject = {
3139
+ tableCode,
3140
+ actionType: GLOBAL_ACTION,
3141
+ actionCode
3142
+ };
3143
+ actionResult = await this
3144
+ .requestFormAction(formActions.tableAction, actionSubject);
3145
+ serverError = !!this.errorOccured();
3146
+ }
3147
+ await this.finishTableGlobalAction(tableActionDetail, actionResult, serverError);
3148
+ if (!serverError) {
3149
+ action.newState && this.changeState(action.newState);
3150
+ }
3151
+ else {
3152
+ for (let index = 0; index < this._tableServerError.length; index++) {
3153
+ const { callback, properties } = this._tableServerError[index];
3154
+ callback(tableObject);
3155
+ }
3156
+ }
3157
+ tableObject.freeWaiting();
3158
+ }
3159
+ async finishTableGlobalAction(tableActionDetail, actionResult, serverError = false) {
3160
+ const { tableCode, actionCode } = tableActionDetail;
3161
+ const tableEventHandlers = this._tableActionsFinish[tableCode];
3162
+ const tableActionMethods = (tableEventHandlers) ? tableEventHandlers[actionCode] : null;
3163
+ if (tableActionMethods) {
3164
+ const clientActionPromises = [];
3165
+ for (const tableActionMethod of tableActionMethods) {
3166
+ const { callback, properties } = tableActionMethod;
3167
+ const continueOnError = properties?.continueOnError ?? false;
3168
+ if (!serverError || continueOnError) {
3169
+ clientActionPromises.push(callback(tableActionDetail, actionResult));
3170
+ }
3171
+ }
3172
+ await Promise.all(clientActionPromises);
3173
+ }
3174
+ }
3175
+ async startTableAction(tableActionEvent) {
3176
+ const { tableCode, actionCode, actionDetail } = tableActionEvent;
3177
+ const tableObject = this.getTable(tableCode);
3178
+ if (!tableObject || !actionCode) {
3179
+ return;
3180
+ }
3181
+ this.resetError();
3182
+ const { recordId, recordData } = actionDetail;
3183
+ const action = tableObject.getAction(actionCode);
3184
+ if (!action) {
3185
+ return;
3186
+ }
3187
+ const tableActionDetail = {
3188
+ tableObject,
3189
+ action,
3190
+ tableCode,
3191
+ actionCode,
3192
+ recordId,
3193
+ recordData
3194
+ };
3195
+ const tableEventHandlers = this._tableActionsStart[tableCode];
3196
+ const tableActionMethods = (tableEventHandlers) ? tableEventHandlers[actionCode] : null;
3197
+ if (tableActionMethods) {
3198
+ const clientActionPromises = [];
3199
+ for (const tableActionMethod of tableActionMethods) {
3200
+ const { callback, properties } = tableActionMethod;
3201
+ const clientActionPromise = callback(tableActionDetail);
3202
+ clientActionPromises.push(clientActionPromise);
3203
+ }
3204
+ const clientActionResults = await Promise.all(clientActionPromises);
3205
+ const continueAction = clientActionResults.reduce((total, curr) => (total && (curr !== false)), true);
3206
+ if (!continueAction) {
3207
+ return;
3208
+ }
3209
+ }
3210
+ this.startTableServerAction(tableActionDetail);
3211
+ }
3212
+ async startTableServerAction(tableActionDetail) {
3213
+ const { tableObject, action, tableCode, actionCode, recordId, recordData } = tableActionDetail;
3214
+ if (!tableObject || !action) {
3215
+ return;
3216
+ }
3217
+ tableObject.putOnWait();
3218
+ let serverError = false;
3219
+ let actionResult = null;
3220
+ if (action.backend) {
3221
+ const actionSubject = {
3222
+ tableCode,
3223
+ actionType: this.formConfig.tableActions.inline,
3224
+ actionCode,
3225
+ tableRecordId: recordId,
3226
+ tableRecordData: recordData
3227
+ };
3228
+ actionResult = await this
3229
+ .requestFormAction(formActions.tableAction, actionSubject);
3230
+ serverError = !!this.errorOccured();
3231
+ }
3232
+ await this.finishTableAction(tableActionDetail, actionResult, serverError);
3233
+ if (!serverError) {
3234
+ action.newState && this.changeState(action.newState);
3235
+ }
3236
+ else {
3237
+ this.displayTableServerError();
3238
+ }
3239
+ tableObject.freeWaiting();
3240
+ }
3241
+ completeInlineAction(tableAction) {
3242
+ return this.startTableServerAction(tableAction);
3243
+ }
3244
+ async finishTableAction(tableActionDetail, actionResult, serverError = false) {
3245
+ const { tableCode, actionCode } = tableActionDetail;
3246
+ const tableEventHandlers = this._tableActionsFinish[tableCode];
3247
+ const tableActionMethods = (tableEventHandlers) ? tableEventHandlers[actionCode] : null;
3248
+ if (tableActionMethods) {
3249
+ const clientActionPromises = [];
3250
+ for (const tableActionMethod of tableActionMethods) {
3251
+ const { callback, properties } = tableActionMethod;
3252
+ const continueOnError = properties?.continueOnError ?? false;
3253
+ if (!serverError || continueOnError) {
3254
+ clientActionPromises.push(callback(tableActionDetail, actionResult));
3255
+ }
3256
+ }
3257
+ await Promise.all(clientActionPromises);
3258
+ }
3259
+ }
3260
+ async startTableRecordSelection(tableActionEvent) {
3261
+ const { tableCode, actionDetail } = tableActionEvent;
3262
+ const tableObject = this.getTable(tableCode);
3263
+ if (!tableObject) {
3264
+ return;
3265
+ }
3266
+ this.resetError();
3267
+ const { recordId, recordData } = actionDetail;
3268
+ const tableSelectionDetail = {
3269
+ tableObject,
3270
+ tableCode,
3271
+ recordId,
3272
+ recordData
3273
+ };
3274
+ const tableEventHandlers = this._tableSelectionsStart[tableCode];
3275
+ if (tableEventHandlers) {
3276
+ const clientActionPromises = [];
3277
+ for (const tableSelectionMethod of tableEventHandlers) {
3278
+ const { callback, properties } = tableSelectionMethod;
3279
+ const clientActionPromise = callback(tableSelectionDetail);
3280
+ clientActionPromises.push(clientActionPromise);
3281
+ }
3282
+ const clientActionResults = await Promise.all(clientActionPromises);
3283
+ const continueAction = clientActionResults.reduce((total, curr) => (total && (curr !== false)), true);
3284
+ if (!continueAction) {
3285
+ return;
3286
+ }
3287
+ }
3288
+ this.startTableServerRecordSelection(tableSelectionDetail);
3289
+ }
3290
+ async startTableServerRecordSelection(tableSelectionDetail) {
3291
+ const { tableObject, tableCode, recordId, recordData } = tableSelectionDetail;
3292
+ if (!tableObject) {
3293
+ return;
3294
+ }
3295
+ tableObject.putOnWait();
3296
+ let serverError = false;
3297
+ let actionResult = null;
3298
+ if (tableObject.selectionBackend) {
3299
+ const actionSubject = {
3300
+ tableCode,
3301
+ actionType: this.formConfig.tableActions.rowSelection,
3302
+ actionCode: null,
3303
+ tableRecordId: recordId,
3304
+ tableRecordData: recordData
3305
+ };
3306
+ actionResult = await this
3307
+ .requestFormAction(formActions.tableAction, actionSubject);
3308
+ serverError = !!this.errorOccured();
3309
+ }
3310
+ await this.finishTableRecordSelection(tableSelectionDetail, actionResult, serverError);
3311
+ if (serverError) {
3312
+ this.displayTableServerError();
3313
+ }
3314
+ tableObject.freeWaiting();
3315
+ }
3316
+ async finishTableRecordSelection(tableSelectionDetail, actionResult, serverError = false) {
3317
+ const { tableCode } = tableSelectionDetail;
3318
+ const tableEventHandlers = this._tableSelectionsFinish[tableCode];
3319
+ if (tableEventHandlers) {
3320
+ const clientActionPromises = [];
3321
+ for (const tableSelectionMethod of tableEventHandlers) {
3322
+ const { callback, properties } = tableSelectionMethod;
3323
+ const continueOnError = properties?.continueOnError ?? false;
3324
+ if (!serverError || continueOnError) {
3325
+ clientActionPromises.push(callback(tableSelectionDetail, actionResult));
3326
+ }
3327
+ }
3328
+ await Promise.all(clientActionPromises);
3329
+ }
3330
+ }
3331
+ async startTableSelectionAction(tableActionEvent) {
3332
+ const { tableCode, actionCode, actionDetail } = tableActionEvent;
3333
+ const tableObject = this.getTable(tableCode);
3334
+ if (!tableObject || !actionCode) {
3335
+ return;
3336
+ }
3337
+ this.resetError();
3338
+ const { selectedRecords } = actionDetail;
3339
+ const action = tableObject.getAction(actionCode);
3340
+ if (!action) {
3341
+ return;
3342
+ }
3343
+ const tableActionDetail = {
3344
+ tableObject,
3345
+ action,
3346
+ tableCode,
3347
+ actionCode,
3348
+ selectedRecords
3349
+ };
3350
+ const tableEventHandlers = this._tableActionsStart[tableCode];
3351
+ const tableActionMethods = (tableEventHandlers) ? tableEventHandlers[actionCode] : null;
3352
+ if (tableActionMethods) {
3353
+ const clientActionPromises = [];
3354
+ for (const tableActionMethod of tableActionMethods) {
3355
+ const { callback, properties } = tableActionMethod;
3356
+ const clientActionPromise = callback(tableActionDetail);
3357
+ clientActionPromises.push(clientActionPromise);
3358
+ }
3359
+ const clientActionResults = await Promise.all(clientActionPromises);
3360
+ const continueAction = clientActionResults.reduce((total, curr) => (total && (curr !== false)), true);
3361
+ if (!continueAction) {
3362
+ return;
3363
+ }
3364
+ }
3365
+ this.startTableServerSelectionAction(tableActionDetail);
3366
+ }
3367
+ async startTableServerSelectionAction(tableActionDetail) {
3368
+ const { tableObject, action, tableCode, actionCode, selectedRecords } = tableActionDetail;
3369
+ if (!tableObject || !action) {
3370
+ return;
3371
+ }
3372
+ tableObject.putOnWait();
3373
+ let serverError = false;
3374
+ let actionResult = null;
3375
+ if (action.backend) {
3376
+ const actionSubject = {
3377
+ tableCode,
3378
+ actionType: this.formConfig.tableActions.selection,
3379
+ actionCode,
3380
+ selectedRecords
3381
+ };
3382
+ actionResult = await this
3383
+ .requestFormAction(formActions.tableAction, actionSubject);
3384
+ serverError = !!this.errorOccured();
3385
+ }
3386
+ await this.finishTableSelectionAction(tableActionDetail, actionResult, serverError);
3387
+ if (!serverError) {
3388
+ action.newState && this.changeState(action.newState);
3389
+ }
3390
+ else {
3391
+ this.displayTableServerError();
3392
+ }
3393
+ tableObject.freeWaiting();
3394
+ }
3395
+ async finishTableSelectionAction(tableActionDetail, actionResult, serverError = false) {
3396
+ const { tableCode, actionCode } = tableActionDetail;
3397
+ const tableEventHandlers = this._tableActionsFinish[tableCode];
3398
+ const tableActionMethods = (tableEventHandlers) ? tableEventHandlers[actionCode] : null;
3399
+ if (tableActionMethods) {
3400
+ const clientActionPromises = [];
3401
+ for (const tableActionMethod of tableActionMethods) {
3402
+ const { callback, properties } = tableActionMethod;
3403
+ const continueOnError = properties?.continueOnError ?? false;
3404
+ if (!serverError || continueOnError) {
3405
+ clientActionPromises.push(callback(tableActionDetail, actionResult));
3406
+ }
3407
+ }
3408
+ await Promise.all(clientActionPromises);
3409
+ }
3410
+ }
3411
+ async startTableGetData(tableActionEvent) {
3412
+ const { tableCode } = tableActionEvent;
3413
+ const tableObject = this.getTable(tableCode);
3414
+ const tableActionDetail = {
3415
+ tableObject,
3416
+ tableCode
3417
+ };
3418
+ this.resetError();
3419
+ const tableEventHandlers = this._tableGetDataStart[tableCode];
3420
+ if (tableEventHandlers) {
3421
+ const clientActionPromises = [];
3422
+ for (const tableActionMethod of tableEventHandlers) {
3423
+ const { callback, properties } = tableActionMethod;
3424
+ const clientActionPromise = callback(tableActionDetail);
3425
+ clientActionPromises.push(clientActionPromise);
3426
+ }
3427
+ const clientActionResults = await Promise.all(clientActionPromises);
3428
+ const continueAction = clientActionResults.reduce((total, curr) => (total && (curr !== false)), true);
3429
+ if (!continueAction) {
3430
+ return;
3431
+ }
3432
+ }
3433
+ this.startTableServerGetData(tableActionDetail);
3434
+ }
3435
+ async startTableServerGetData(tableActionDetail) {
3436
+ const { tableObject, tableCode } = tableActionDetail;
3437
+ tableObject.putOnWait();
3438
+ let serverError = false;
3439
+ const actionSubject = { tableCode };
3440
+ const actionResult = await this
3441
+ .requestFormAction(formActions.getTableData, actionSubject);
3442
+ serverError = !!this.errorOccured();
3443
+ await this.finishTableGetData(tableActionDetail, actionResult, serverError);
3444
+ if (serverError) {
3445
+ this.displayTableServerError();
3446
+ }
3447
+ tableObject.freeWaiting();
3448
+ }
3449
+ async finishTableGetData(tableActionDetail, actionResult, serverError = false) {
3450
+ const { tableCode, tableActionCode } = tableActionDetail;
3451
+ const tableEventHandlers = this._tableActionsFinish[tableCode];
3452
+ const tableActionMethods = (tableEventHandlers) ? tableEventHandlers[tableActionCode] : null;
3453
+ if (tableActionMethods) {
3454
+ const clientActionPromises = [];
3455
+ for (const tableActionMethod of tableActionMethods) {
3456
+ const { callback, properties } = tableActionMethod;
3457
+ const continueOnError = properties?.continueOnError ?? false;
3458
+ if (!serverError || continueOnError) {
3459
+ clientActionPromises.push(callback(tableActionDetail, actionResult));
3460
+ }
3461
+ }
3462
+ await Promise.all(clientActionPromises);
3463
+ }
3464
+ }
3465
+ checkSectionRequiredFields(sectionCode, reqFieldMessage) {
3466
+ this.cleanErrorFields(null, sectionCode);
3467
+ const requiredFieldMessage = reqFieldMessage ?? this.formConfig.formStandardErrors.requiredField;
3468
+ const numErrors = this.tagFieldsWithError(requiredFieldMessage, this.getRequiredEmptyFields(null, sectionCode));
3469
+ return (numErrors === 0);
3470
+ }
3471
+ validateSectionConsistency(sectionCode, reqFieldMessage) {
3472
+ this.resetError();
3473
+ const completeFields = this.checkSectionRequiredFields(sectionCode, reqFieldMessage);
3474
+ if (!completeFields) {
3475
+ this.setError(this.formConfig.formStandardErrors.typeWarning, this.formConfig.formStandardErrors.validationTitle, this.formConfig.formStandardErrors.requiredFields);
3476
+ return false;
3477
+ }
3478
+ let validationError = false;
3479
+ const requiredEmptyFields = this.getRequiredEmptyFields(null, sectionCode) ?? [];
3480
+ if (requiredEmptyFields?.length > 0) {
3481
+ validationError = true;
3482
+ this.setError(this.formConfig.formStandardErrors.typeWarning, this.formConfig.formStandardErrors.validationTitle, this.formConfig.formStandardErrors.requiredFields);
3483
+ this.tagFieldsWithError(this.formConfig.formStandardErrors.requiredField, requiredEmptyFields);
3484
+ for (const fieldCode of requiredEmptyFields) {
3485
+ const requiredEmptyField = this.getField(fieldCode);
3486
+ requiredEmptyField?.focus();
3487
+ break;
3488
+ }
3489
+ }
3490
+ const validationIssueFields = this.getFieldsWithValidationIssues(null, sectionCode) ?? [];
3491
+ if (!validationError && validationIssueFields.length > 0) {
3492
+ validationError = true;
3493
+ this.setError(this.formConfig.formStandardErrors.typeWarning, this.formConfig.formStandardErrors.validationTitle, this.formConfig.formStandardErrors.validationFields);
3494
+ for (const fieldCode of validationIssueFields) {
3495
+ const validationIssueField = this.getField(fieldCode);
3496
+ if (validationIssueField) {
3497
+ validationIssueField.focus();
3498
+ }
3499
+ break;
3500
+ }
3501
+ }
3502
+ return validationError;
3503
+ }
3504
+ copyTableRecordToFields(tableObj, mappingTable = null) {
3505
+ const tableObject = this.getTable(tableObj.tableCode);
3506
+ const tableRecord = tableObject?.getTableRecord(tableObj.recordId);
3507
+ const columnNames = tableObject?.columnNames;
3508
+ if (tableRecord && columnNames) {
3509
+ for (const columnName of columnNames) {
3510
+ const columnValue = tableRecord.getFieldValue(columnName) ?? '';
3511
+ const fieldCode = mappingTable?.[columnName] ?? columnName;
3512
+ this.setFieldValue(fieldCode, columnValue);
3513
+ }
3514
+ return true;
3515
+ }
3516
+ return false;
3517
+ }
3518
+ /**
3519
+ * Métodos Legacy de compatibilidad hacia atrás
3520
+ */
3521
+ addSectionActivation(codes, callback, properties = null) {
3522
+ return this.onSectionActivation(codes, callback, properties);
3523
+ }
3524
+ addSectionInactivation(codes, callback, properties = null) {
3525
+ return this.onSectionInactivation(codes, callback, properties);
3526
+ }
3527
+ addActionMethodStart(codes, callback, properties = null) {
3528
+ return this.onActionStart(codes, callback, properties);
3529
+ }
3530
+ addActionMethodFinish(codes, callback, properties = null) {
3531
+ return this.onActionFinish(codes, callback, properties);
3532
+ }
3533
+ addFieldInputValidation(codes, callback, properties = null) {
3534
+ return this.onFieldInput(codes, callback, properties);
3535
+ }
3536
+ addFieldValidationStart(codes, callback, properties = null) {
3537
+ return this.onFieldValidationStart(codes, callback, properties);
3538
+ }
3539
+ addFieldValidationFinish(codes, callback, properties = null) {
3540
+ return this.onFieldValidationFinish(codes, callback, properties);
3541
+ }
3542
+ addTableActionStart(code, actionCode, callback, properties = null) {
3543
+ return this.onTableActionStart(code, actionCode, callback, properties);
3544
+ }
3545
+ addTableActionFinish(code, actionCode, callback, properties = null) {
3546
+ return this.onTableActionFinish(code, actionCode, callback, properties);
3547
+ }
3548
+ addTableSelectionStart(code, callback, properties = null) {
3549
+ return this.onTableSelectionStart(code, callback, properties);
3550
+ }
3551
+ addTableSelectionFinish(code, callback, properties = null) {
3552
+ return this.onTableSelectionFinish(code, callback, properties);
3553
+ }
3554
+ addTableGetDataStart(code, callback, properties = null) {
3555
+ return this.onTableGetDataStart(code, callback, properties);
3556
+ }
3557
+ addTableGetDataFinish(code, callback, properties = null) {
3558
+ return this.onTableGetDataFinish(code, callback, properties);
3559
+ }
3560
+ }
3561
+ BasicFormComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: BasicFormComponent, deps: [{ token: LibFormManagerService }, { token: LibEventManagerService }, { token: LibFileManagementService }], target: i0.ɵɵFactoryTarget.Component });
3562
+ BasicFormComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.6", type: BasicFormComponent, selector: "ng-component", ngImport: i0, template: `<ng-content></ng-content>`, isInline: true });
3563
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: BasicFormComponent, decorators: [{
3564
+ type: Component,
3565
+ args: [{
3566
+ template: `<ng-content></ng-content>`
3567
+ }]
3568
+ }], ctorParameters: function () { return [{ type: LibFormManagerService }, { type: LibEventManagerService }, { type: LibFileManagementService }]; } });
3569
+
3570
+ const COMPONENTS = [
3571
+ BasicFormComponent,
3572
+ ActionComponent,
3573
+ FieldComponent,
3574
+ ElementComponent,
3575
+ FormErrorComponent,
3576
+ FormHeaderComponent,
3577
+ SectionComponent,
3578
+ SubSectionComponent,
3579
+ LibTableRecordActionComponent,
3580
+ LibTableRecordFieldComponent,
3581
+ LibTableComponent
3582
+ ];
3583
+ class TuainNgFormsLibModule {
3584
+ }
3585
+ TuainNgFormsLibModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: TuainNgFormsLibModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
3586
+ TuainNgFormsLibModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "14.2.6", ngImport: i0, type: TuainNgFormsLibModule, declarations: [BasicFormComponent,
3587
+ ActionComponent,
3588
+ FieldComponent,
3589
+ ElementComponent,
3590
+ FormErrorComponent,
3591
+ FormHeaderComponent,
3592
+ SectionComponent,
3593
+ SubSectionComponent,
3594
+ LibTableRecordActionComponent,
3595
+ LibTableRecordFieldComponent,
3596
+ LibTableComponent], imports: [CommonModule,
3597
+ RouterModule,
3598
+ FormsModule], exports: [BasicFormComponent,
3599
+ ActionComponent,
3600
+ FieldComponent,
3601
+ ElementComponent,
3602
+ FormErrorComponent,
3603
+ FormHeaderComponent,
3604
+ SectionComponent,
3605
+ SubSectionComponent,
3606
+ LibTableRecordActionComponent,
3607
+ LibTableRecordFieldComponent,
3608
+ LibTableComponent] });
3609
+ TuainNgFormsLibModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: TuainNgFormsLibModule, imports: [CommonModule,
3610
+ RouterModule,
3611
+ FormsModule] });
3612
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: TuainNgFormsLibModule, decorators: [{
3613
+ type: NgModule,
3614
+ args: [{
3615
+ declarations: COMPONENTS,
3616
+ imports: [
3617
+ CommonModule,
3618
+ RouterModule,
3619
+ FormsModule,
3620
+ ],
3621
+ exports: COMPONENTS
3622
+ }]
3623
+ }] });
3624
+
3625
+ /*
3626
+ * Public API Surface of tuain-ng-forms-lib
3627
+ */
3628
+
3629
+ /**
3630
+ * Generated bundle index. Do not edit.
3631
+ */
3632
+
3633
+ export { ActionComponent, BasicFormComponent, ElementComponent, FieldComponent, FormErrorComponent, FormHeaderComponent, LibEventManagerService, LibFileManagementService, LibFormManagerService, LibTableComponent, LibTableRecordActionComponent, LibTableRecordFieldComponent, SectionComponent, SubSectionComponent, TuainNgFormsLibModule };
3634
+ //# sourceMappingURL=tuain-ng-forms-lib.mjs.map