tuain-ng-forms-lib 14.4.93 → 14.4.95

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