tuain-ng-forms-lib 14.4.91 → 14.4.93

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