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