tuain-ng-forms-lib 15.2.11 → 17.0.0

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