tuain-ng-forms-lib 14.3.20 → 14.4.45

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 (43) hide show
  1. package/esm2020/lib/classes/forms/element.mjs +8 -69
  2. package/esm2020/lib/classes/forms/field.mjs +1 -8
  3. package/esm2020/lib/classes/forms/form.mjs +6 -2
  4. package/esm2020/lib/classes/forms/piece.mjs +115 -0
  5. package/esm2020/lib/classes/forms/section.mjs +25 -28
  6. package/esm2020/lib/classes/forms/subsection.mjs +12 -15
  7. package/esm2020/lib/classes/forms/table/action.mjs +5 -18
  8. package/esm2020/lib/classes/forms/table/column.mjs +4 -14
  9. package/esm2020/lib/classes/forms/table/table.mjs +50 -37
  10. package/esm2020/lib/components/elements/action.component.mjs +26 -13
  11. package/esm2020/lib/components/elements/field.component.mjs +18 -20
  12. package/esm2020/lib/components/elements/layout/element.component.mjs +5 -16
  13. package/esm2020/lib/components/elements/layout/form-header.component.mjs +5 -5
  14. package/esm2020/lib/components/elements/layout/piece.component.mjs +22 -0
  15. package/esm2020/lib/components/elements/layout/section.component.mjs +20 -5
  16. package/esm2020/lib/components/elements/layout/sub-section.component.mjs +20 -7
  17. package/esm2020/lib/components/elements/tables/table-record-action.component.mjs +21 -5
  18. package/esm2020/lib/components/elements/tables/table.component.mjs +67 -47
  19. package/esm2020/lib/components/forms/basic-form.mjs +25 -14
  20. package/fesm2015/tuain-ng-forms-lib.mjs +460 -339
  21. package/fesm2015/tuain-ng-forms-lib.mjs.map +1 -1
  22. package/fesm2020/tuain-ng-forms-lib.mjs +436 -320
  23. package/fesm2020/tuain-ng-forms-lib.mjs.map +1 -1
  24. package/lib/classes/forms/element.d.ts +3 -29
  25. package/lib/classes/forms/field.d.ts +0 -3
  26. package/lib/classes/forms/form.d.ts +3 -0
  27. package/lib/classes/forms/piece.d.ts +43 -0
  28. package/lib/classes/forms/section.d.ts +8 -18
  29. package/lib/classes/forms/subsection.d.ts +7 -12
  30. package/lib/classes/forms/table/action.d.ts +3 -11
  31. package/lib/classes/forms/table/column.d.ts +2 -7
  32. package/lib/classes/forms/table/table.d.ts +1 -3
  33. package/lib/components/elements/action.component.d.ts +4 -8
  34. package/lib/components/elements/field.component.d.ts +4 -9
  35. package/lib/components/elements/layout/element.component.d.ts +3 -8
  36. package/lib/components/elements/layout/form-header.component.d.ts +3 -3
  37. package/lib/components/elements/layout/piece.component.d.ts +10 -0
  38. package/lib/components/elements/layout/section.component.d.ts +4 -3
  39. package/lib/components/elements/layout/sub-section.component.d.ts +4 -4
  40. package/lib/components/elements/tables/table-record-action.component.d.ts +2 -2
  41. package/lib/components/elements/tables/table.component.d.ts +6 -10
  42. package/lib/components/forms/basic-form.d.ts +2 -0
  43. package/package.json +1 -1
@@ -1,22 +1,79 @@
1
1
  import * as i0 from '@angular/core';
2
2
  import { Component, Input, EventEmitter, Output, ChangeDetectionStrategy, NgModule } from '@angular/core';
3
- import { Subject, ReplaySubject } from 'rxjs';
3
+ import { BehaviorSubject, Subject, ReplaySubject } from 'rxjs';
4
4
  import yn from 'yn';
5
5
  import { nanoid } from 'nanoid';
6
6
  import { CommonModule } from '@angular/common';
7
7
  import { RouterModule } from '@angular/router';
8
8
  import { FormsModule } from '@angular/forms';
9
9
 
10
- class ActionComponent {
10
+ class PieceComponent {
11
11
  constructor() {
12
+ this.visible = true;
13
+ this.disabled = false;
14
+ }
15
+ defaultProcessAttributeChange(attribute, value) {
16
+ attribute && (this[attribute] = value);
17
+ }
18
+ customProcessAttributeChange(attribute, value) { }
19
+ }
20
+ PieceComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: PieceComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
21
+ 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 });
22
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: PieceComponent, decorators: [{
23
+ type: Component,
24
+ args: [{
25
+ selector: 'lib-piece',
26
+ template: `<ng-content></ng-content>`
27
+ }]
28
+ }] });
29
+
30
+ class ElementComponent extends PieceComponent {
31
+ start() { }
32
+ }
33
+ ElementComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: ElementComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
34
+ ElementComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.6", type: ElementComponent, selector: "lib-element", inputs: { element: "element", form: "form" }, usesInheritance: true, ngImport: i0, template: `<ng-content></ng-content>`, isInline: true });
35
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: ElementComponent, decorators: [{
36
+ type: Component,
37
+ args: [{
38
+ selector: 'lib-element',
39
+ template: `<ng-content></ng-content>`
40
+ }]
41
+ }], propDecorators: { element: [{
42
+ type: Input
43
+ }], form: [{
44
+ type: Input
45
+ }] } });
46
+
47
+ class ActionComponent extends ElementComponent {
48
+ constructor() {
49
+ super(...arguments);
50
+ this.inProgress = false;
51
+ this.action = null;
12
52
  this.style = 'primary';
13
53
  this.showLabel = true;
14
54
  }
15
55
  ngOnInit() {
56
+ if (!this.action) {
57
+ return;
58
+ }
16
59
  this.formConfig = this.action?._formConfig;
60
+ const mapping = Object.entries(this.formConfig?.actionPropagateAttributes);
61
+ for (let index = 0; index < mapping.length; index++) {
62
+ const actionAttr = mapping[index]?.[0];
63
+ const componentAttr = mapping[index]?.[1]?.toString() ?? '';
64
+ if (componentAttr) {
65
+ const value = this.action?.[actionAttr];
66
+ this.defaultProcessAttributeChange(componentAttr, value);
67
+ this.customProcessAttributeChange(componentAttr, value);
68
+ }
69
+ }
70
+ this.action?.attributeChange?.subscribe(event => {
71
+ const { name: componentAttr, value } = event;
72
+ this.defaultProcessAttributeChange(componentAttr, value);
73
+ this.customProcessAttributeChange(componentAttr, value);
74
+ });
17
75
  this.start();
18
76
  }
19
- start() { }
20
77
  activate() {
21
78
  if (this.action?.notifyActivation) {
22
79
  this.action.notifyActivation();
@@ -34,15 +91,9 @@ class ActionComponent {
34
91
  }
35
92
  return false;
36
93
  }
37
- get visible() {
38
- return this.action?.visibleOn(this.state) && this.visibleOnRestriction();
39
- }
40
- get disabled() {
41
- return !(this.action?.enabledOn(this.state));
42
- }
43
94
  }
44
- ActionComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: ActionComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
45
- ActionComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.6", type: ActionComponent, selector: "lib-action", inputs: { action: "action", busy: "busy", relatedField: "relatedField", state: "state", style: "style", showLabel: "showLabel" }, ngImport: i0, template: `<ng-content></ng-content>`, isInline: true });
95
+ ActionComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: ActionComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
96
+ ActionComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.6", type: ActionComponent, selector: "lib-action", inputs: { action: "action", busy: "busy", relatedField: "relatedField", style: "style", showLabel: "showLabel" }, usesInheritance: true, ngImport: i0, template: `<ng-content></ng-content>`, isInline: true });
46
97
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: ActionComponent, decorators: [{
47
98
  type: Component,
48
99
  args: [{
@@ -55,8 +106,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.6", ngImpor
55
106
  type: Input
56
107
  }], relatedField: [{
57
108
  type: Input
58
- }], state: [{
59
- type: Input
60
109
  }], style: [{
61
110
  type: Input
62
111
  }], showLabel: [{
@@ -65,8 +114,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.6", ngImpor
65
114
 
66
115
  const VALUE = 'value';
67
116
  const FOCUS = 'focus';
68
- class FieldComponent {
117
+ class FieldComponent extends ElementComponent {
69
118
  constructor() {
119
+ super(...arguments);
70
120
  // Atributos obtenidos estáticamente
71
121
  this.code = '';
72
122
  this.info = '';
@@ -79,23 +129,25 @@ class FieldComponent {
79
129
  return;
80
130
  }
81
131
  this.formConfig = this.field?._formConfig;
82
- // Inicialización
83
- const mapping = this.formConfig.fieldPropagateAttributes;
132
+ const mapping = Object.entries(this.formConfig?.fieldPropagateAttributes);
84
133
  for (let index = 0; index < mapping.length; index++) {
85
- const attrName = mapping[index].toString();
86
- const attributeValue = this.field?.[attrName];
87
- this.dafaultProcessFieldChange(attrName, attributeValue);
88
- this.processFieldChange(attrName, attributeValue);
134
+ const fieldAttr = mapping[index]?.[0];
135
+ const componentAttr = mapping[index]?.[1]?.toString() ?? '';
136
+ if (componentAttr) {
137
+ const value = this.field?.[fieldAttr];
138
+ this.defaultProcessAttributeChange(componentAttr, value);
139
+ this.customProcessAttributeChange(componentAttr, value);
140
+ }
89
141
  }
90
142
  // Subscripción a cambios en atributos
91
143
  this.field?.attributeChange.subscribe(event => {
92
- const { name: attrName, value } = event;
93
- this.dafaultProcessFieldChange(attrName, value);
94
- this.processFieldChange(attrName, value);
144
+ const { name: componentAttr, value } = event;
145
+ this.defaultProcessAttributeChange(componentAttr, value);
146
+ this.customProcessAttributeChange(componentAttr, value);
95
147
  });
96
148
  this.start();
97
149
  }
98
- dafaultProcessFieldChange(attribute, value) {
150
+ defaultProcessAttributeChange(attribute, value) {
99
151
  if (attribute === VALUE) {
100
152
  this.updateValue();
101
153
  }
@@ -106,14 +158,10 @@ class FieldComponent {
106
158
  this[attribute] = value;
107
159
  }
108
160
  }
109
- get visible() { return this.field?.visibleOn(this.state); }
110
- get disabled() { return !this.field?.enabledOn(this.state); }
111
161
  updateValue() { this.value = this.field?.value; }
112
162
  onInputChange() { setTimeout(() => this.field?.notifyEditionPartial(), 50); }
113
163
  onChangeContent() { setTimeout(() => this.field?.notifyEditionFinish(), 50); }
114
164
  onShowInfo(detail = null) { setTimeout(() => this.field?.notifyEditionDetailRequest(detail), 50); }
115
- processFieldChange(attribute, value) { }
116
- start() { }
117
165
  focus() { }
118
166
  updateObject() { this.field?.setValue(this.value); }
119
167
  inputChanged() {
@@ -129,8 +177,8 @@ class FieldComponent {
129
177
  return (k > 47 && k < 58);
130
178
  }
131
179
  }
132
- FieldComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: FieldComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
133
- FieldComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.6", type: FieldComponent, selector: "lib-field", inputs: { field: "field", state: "state" }, ngImport: i0, template: `<ng-content></ng-content>`, isInline: true });
180
+ FieldComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: FieldComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
181
+ 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 });
134
182
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: FieldComponent, decorators: [{
135
183
  type: Component,
136
184
  args: [{
@@ -139,37 +187,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.6", ngImpor
139
187
  }]
140
188
  }], propDecorators: { field: [{
141
189
  type: Input
142
- }], state: [{
143
- type: Input
144
- }] } });
145
-
146
- class ElementComponent {
147
- ngOnInit() {
148
- this.formConfig = this.element?._formConfig;
149
- this.start();
150
- }
151
- start() { }
152
- get visible() {
153
- return this.element?.visibleOn(this.state);
154
- }
155
- get disabled() {
156
- return !this.element?.enabledOn(this.state);
157
- }
158
- }
159
- ElementComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: ElementComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
160
- ElementComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.6", type: ElementComponent, selector: "lib-element", inputs: { element: "element", form: "form", state: "state" }, ngImport: i0, template: `<ng-content></ng-content>`, isInline: true });
161
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: ElementComponent, decorators: [{
162
- type: Component,
163
- args: [{
164
- selector: 'lib-element',
165
- template: `<ng-content></ng-content>`
166
- }]
167
- }], propDecorators: { element: [{
168
- type: Input
169
- }], form: [{
170
- type: Input
171
- }], state: [{
172
- type: Input
173
190
  }] } });
174
191
 
175
192
  class FormErrorComponent {
@@ -192,7 +209,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.6", ngImpor
192
209
 
193
210
  class FormHeaderComponent {
194
211
  constructor() {
195
- this.goBackAction = false;
212
+ this.canGoBack = false;
196
213
  this.goBackEvent = new EventEmitter();
197
214
  }
198
215
  goBackForm() {
@@ -200,16 +217,16 @@ class FormHeaderComponent {
200
217
  }
201
218
  }
202
219
  FormHeaderComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: FormHeaderComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
203
- FormHeaderComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.6", type: FormHeaderComponent, selector: "lib-form-header", inputs: { formManager: "formManager", goBackAction: "goBackAction", showTitle: "showTitle", headerActions: "headerActions" }, outputs: { goBackEvent: "goBackEvent" }, ngImport: i0, template: `<ng-content></ng-content>`, isInline: true });
220
+ FormHeaderComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.6", type: FormHeaderComponent, selector: "lib-form-header", inputs: { form: "form", canGoBack: "canGoBack", showTitle: "showTitle", headerActions: "headerActions" }, outputs: { goBackEvent: "goBackEvent" }, ngImport: i0, template: `<ng-content></ng-content>`, isInline: true });
204
221
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: FormHeaderComponent, decorators: [{
205
222
  type: Component,
206
223
  args: [{
207
224
  selector: 'lib-form-header',
208
225
  template: `<ng-content></ng-content>`
209
226
  }]
210
- }], propDecorators: { formManager: [{
227
+ }], propDecorators: { form: [{
211
228
  type: Input
212
- }], goBackAction: [{
229
+ }], canGoBack: [{
213
230
  type: Input
214
231
  }], showTitle: [{
215
232
  type: Input
@@ -219,14 +236,28 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.6", ngImpor
219
236
  type: Output
220
237
  }] } });
221
238
 
222
- class SectionComponent {
239
+ class SectionComponent extends PieceComponent {
223
240
  ngOnInit() {
241
+ this.formConfig = this.section?._formConfig;
242
+ const mapping = this.formConfig?.sectionPropagateAttributes;
243
+ for (let index = 0; index < mapping.length; index++) {
244
+ const attrName = mapping[index].toString();
245
+ const attributeValue = this.section?.[attrName];
246
+ this.defaultProcessAttributeChange(attrName, attributeValue);
247
+ this.customProcessAttributeChange(attrName, attributeValue);
248
+ }
249
+ // Subscripción a cambios en atributos
250
+ this.section?.attributeChange.subscribe(event => {
251
+ const { name: attrName, value } = event;
252
+ this.defaultProcessAttributeChange(attrName, value);
253
+ this.customProcessAttributeChange(attrName, value);
254
+ });
224
255
  this.start();
225
256
  }
226
257
  start() { }
227
258
  }
228
- SectionComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: SectionComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
229
- SectionComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.6", type: SectionComponent, selector: "lib-section", inputs: { section: "section", formManager: "formManager" }, ngImport: i0, template: `<ng-content></ng-content>`, isInline: true });
259
+ SectionComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: SectionComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
260
+ SectionComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.6", type: SectionComponent, selector: "lib-section", inputs: { section: "section", form: "form" }, usesInheritance: true, ngImport: i0, template: `<ng-content></ng-content>`, isInline: true });
230
261
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: SectionComponent, decorators: [{
231
262
  type: Component,
232
263
  args: [{
@@ -235,18 +266,32 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.6", ngImpor
235
266
  }]
236
267
  }], propDecorators: { section: [{
237
268
  type: Input
238
- }], formManager: [{
269
+ }], form: [{
239
270
  type: Input
240
271
  }] } });
241
272
 
242
- class SubSectionComponent {
273
+ class SubSectionComponent extends PieceComponent {
243
274
  ngOnInit() {
275
+ this.formConfig = this.subSection?._formConfig;
276
+ const mapping = this.formConfig?.subSectionPropagateAttributes;
277
+ for (let index = 0; index < mapping.length; index++) {
278
+ const attrName = mapping[index].toString();
279
+ const attributeValue = this.subSection?.[attrName];
280
+ this.defaultProcessAttributeChange(attrName, attributeValue);
281
+ this.customProcessAttributeChange(attrName, attributeValue);
282
+ }
283
+ // Subscripción a cambios en atributos
284
+ this.subSection?.attributeChange.subscribe(event => {
285
+ const { name: attrName, value } = event;
286
+ this.defaultProcessAttributeChange(attrName, value);
287
+ this.customProcessAttributeChange(attrName, value);
288
+ });
244
289
  this.start();
245
290
  }
246
291
  start() { }
247
292
  }
248
- SubSectionComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: SubSectionComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
249
- SubSectionComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.6", type: SubSectionComponent, selector: "lib-subsection", inputs: { subSection: "subSection", showHeader: "showHeader", formManager: "formManager" }, ngImport: i0, template: `<ng-content></ng-content>`, isInline: true });
293
+ SubSectionComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: SubSectionComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
294
+ SubSectionComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.6", type: SubSectionComponent, selector: "lib-subsection", inputs: { subSection: "subSection", form: "form" }, usesInheritance: true, ngImport: i0, template: `<ng-content></ng-content>`, isInline: true });
250
295
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: SubSectionComponent, decorators: [{
251
296
  type: Component,
252
297
  args: [{
@@ -255,18 +300,31 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.6", ngImpor
255
300
  }]
256
301
  }], propDecorators: { subSection: [{
257
302
  type: Input
258
- }], showHeader: [{
259
- type: Input
260
- }], formManager: [{
303
+ }], form: [{
261
304
  type: Input
262
305
  }] } });
263
306
 
264
307
  const INLINE_ACTION$1 = 'INLINE';
265
- class LibTableRecordActionComponent {
308
+ class LibTableRecordActionComponent extends PieceComponent {
266
309
  constructor() {
310
+ super(...arguments);
267
311
  this.actionSelected = new EventEmitter();
268
312
  }
269
313
  ngOnInit() {
314
+ this.formConfig = this.action?._formConfig;
315
+ const mapping = this.formConfig?.actionPropagateAttributes;
316
+ for (let index = 0; index < mapping.length; index++) {
317
+ const attrName = mapping[index].toString();
318
+ const attributeValue = this.action?.[attrName];
319
+ this.defaultProcessAttributeChange(attrName, attributeValue);
320
+ this.customProcessAttributeChange(attrName, attributeValue);
321
+ }
322
+ // Subscripción a cambios en atributos
323
+ this.action?.attributeChange.subscribe(event => {
324
+ const { name: attrName, value } = event;
325
+ this.defaultProcessAttributeChange(attrName, value);
326
+ this.customProcessAttributeChange(attrName, value);
327
+ });
270
328
  this.start();
271
329
  }
272
330
  start() { }
@@ -280,8 +338,8 @@ class LibTableRecordActionComponent {
280
338
  }
281
339
  class() { }
282
340
  }
283
- LibTableRecordActionComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: LibTableRecordActionComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
284
- LibTableRecordActionComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.6", type: LibTableRecordActionComponent, selector: "lib-table-record-action", inputs: { recordId: "recordId", recordData: "recordData", action: "action" }, outputs: { actionSelected: "actionSelected" }, ngImport: i0, template: `<ng-content></ng-content>`, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush });
341
+ LibTableRecordActionComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: LibTableRecordActionComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
342
+ 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 });
285
343
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: LibTableRecordActionComponent, decorators: [{
286
344
  type: Component,
287
345
  args: [{
@@ -289,7 +347,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.6", ngImpor
289
347
  template: `<ng-content></ng-content>`,
290
348
  changeDetection: ChangeDetectionStrategy.OnPush
291
349
  }]
292
- }], ctorParameters: function () { return []; }, propDecorators: { recordId: [{
350
+ }], propDecorators: { recordId: [{
293
351
  type: Input
294
352
  }], recordData: [{
295
353
  type: Input
@@ -328,12 +386,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.6", ngImpor
328
386
  }] } });
329
387
 
330
388
  const changeViewAttributes = ['visibleRecords', 'currentPage', 'recordsPerPage'];
331
- class LibTableComponent {
389
+ class LibTableComponent extends ElementComponent {
332
390
  constructor() {
391
+ super(...arguments);
333
392
  this.currentPage = 1;
334
393
  this.globalSearch = false;
335
394
  this.globalFilterString = '';
336
- this.visibleRecords = [];
395
+ // visibleRecords: any[] = [];
337
396
  this.selectedRecords = [];
338
397
  this.totalRecordsNumber = 0;
339
398
  this.allSelected = false;
@@ -341,51 +400,73 @@ class LibTableComponent {
341
400
  this.loaded = false;
342
401
  this.selectable = false;
343
402
  this.hasActions = false;
344
- this.disabled = false;
403
+ this.table = null;
404
+ this.visibleRecords = [];
405
+ this.waiting = false;
345
406
  }
346
407
  ngOnInit() {
347
- if (this.table) {
348
- this.formConfig = this.table?._formConfig;
349
- this.tableFieldStyles = this.formConfig.tableFieldStyles;
350
- this.selectable = this.table.selectable;
351
- this.hasActions = this.table.hasActions();
352
- this.inlineActions = this.table.getActions(this.formConfig.tableActions.inline);
353
- this.globalActions = this.table.getActions(this.formConfig.tableActions.global);
354
- this.selectionActions = this.table.getActions(this.formConfig.tableActions.selection);
355
- // Inicialización de campos mapeados del objeto
356
- const mapping = Object.entries(this.formConfig.componentTableAttrMap);
357
- for (let index = 0; index < mapping.length; index++) {
358
- const [tableAttrRaw, compAttrRaw] = mapping[index];
359
- const tableAttr = tableAttrRaw.toString();
360
- const compAttr = compAttrRaw.toString();
361
- this.syncAttribute(compAttr, this.table[tableAttr]);
362
- }
363
- // Subscripción a cambios en atributos
364
- this.table.attributeChange.subscribe(event => {
365
- const { name: tableAttr, value } = event;
366
- const compAttr = this.formConfig.componentTableAttrMap[tableAttr];
367
- this.syncAttribute(compAttr, value);
368
- });
408
+ if (!this.table) {
409
+ return;
369
410
  }
411
+ this.formConfig = this.table?._formConfig;
412
+ this.tableFieldStyles = this.formConfig?.tableFieldStyles;
413
+ this.selectable = this.table?.selectable;
414
+ this.hasActions = this.table?.hasActions();
415
+ this.inlineActions = this.table?.getActions(this.formConfig?.tableActions.inline);
416
+ this.globalActions = this.table?.getActions(this.formConfig?.tableActions.global);
417
+ this.selectionActions = this.table?.getActions(this.formConfig?.tableActions.selection);
418
+ // Inicialización de campos mapeados del objeto
419
+ const mapping = Object.entries(this.formConfig?.actionPropagateAttributes);
420
+ for (let index = 0; index < mapping.length; index++) {
421
+ const tableAttr = mapping[index]?.[0];
422
+ const componentAttr = mapping[index]?.[1]?.toString() ?? '';
423
+ const attributeValue = this.table?.[tableAttr];
424
+ this.defaultProcessAttributeChange(componentAttr, attributeValue);
425
+ this.customProcessAttributeChange(componentAttr, attributeValue);
426
+ }
427
+ // Subscripción a cambios en atributos
428
+ this.table?.attributeChange.subscribe(event => {
429
+ const { name: attrName, value } = event;
430
+ this.defaultProcessAttributeChange(attrName, value);
431
+ this.customProcessAttributeChange(attrName, value);
432
+ });
433
+ // Suscripción a los cambios de atributos de las columnas
434
+ // this.table.columns.forEach(column => {
435
+ // mapping = this.formConfig?.tableColumnPropagateAttributes;
436
+ // for (let index = 0; index < mapping.length; index++) {
437
+ // const attrName = mapping[index].toString();
438
+ // const attributeValue = column?.[attrName];
439
+ // this.defaultColumnAttributeChange(column, attrName, attributeValue);
440
+ // }
441
+ // column?.attributeChange.subscribe(event => {
442
+ // const { name: attrName, value } = event;
443
+ // this.defaultColumnAttributeChange(column, attrName, value);
444
+ // });
445
+ // });
370
446
  this.start();
371
447
  }
372
- start() { }
448
+ // defaultColumnAttributeChange(column: any, attribute: string, value?: any) {
449
+ // attribute && (column[attribute] = value);
450
+ // }
373
451
  updateTableData() { }
374
- tableGlobalAction(actionCode) { this.table.notifyGlobalAction(actionCode); }
375
- tableSelectionAction(actionCode) { this.table.notifySelectionAction(actionCode); }
376
- tableActionSelected(actionEvent) { this.table.notifyInlineAction(actionEvent); }
377
- tableSelectionToggle(recordId) { this.table.notifyRecordSelection(recordId); }
378
- toggleSelectAll() { return (this.allSelected) ? this.table.unSelectAll() : this.table.selectAll(); }
452
+ tableGlobalAction(actionCode) { this.table?.notifyGlobalAction(actionCode); }
453
+ tableSelectionAction(actionCode) { this.table?.notifySelectionAction(actionCode); }
454
+ tableActionSelected(actionEvent) { this.table?.notifyInlineAction(actionEvent); }
455
+ tableSelectionToggle(recordId) { this.table?.notifyRecordSelection(recordId); }
456
+ toggleSelectAll() { return (this.allSelected) ? this.table?.unSelectAll() : this.table?.selectAll(); }
379
457
  globalFilterCompleted() { this.changePage(1); }
380
- changePage(requestedPage) { this.table.changePage(requestedPage); }
381
- tableColumnSort(columnName, direction = null) { this.table.sort(columnName, direction ?? 'ascend'); }
382
- globalFilterChanged() { this.table.setGlobalFilterString(this.globalFilterString?.trim() ?? '', false); }
383
- syncAttribute(name, value) {
458
+ changePage(requestedPage) { this.table?.changePage(requestedPage); }
459
+ tableColumnSort(columnName, direction = null) { this.table?.sort(columnName, direction ?? 'ascend'); }
460
+ globalFilterChanged() { this.table?.setGlobalFilterString(this.globalFilterString?.trim() ?? '', false); }
461
+ defaultProcessAttributeChange(attribute, value) {
462
+ if (!attribute) {
463
+ return false;
464
+ }
384
465
  try {
385
- if (name === 'visibleRecords') {
466
+ if (attribute === 'visibleRecords') {
386
467
  this.updateTableData();
387
468
  }
388
- this[name] = value;
469
+ this[attribute] = value;
389
470
  return true;
390
471
  }
391
472
  catch {
@@ -394,15 +475,15 @@ class LibTableComponent {
394
475
  }
395
476
  filterHasChanged(column, values) {
396
477
  if (!values || values.length === 0) {
397
- this.table.removeColumnFilter(column.fieldCode);
478
+ this.table?.removeColumnFilter(column.fieldCode);
398
479
  }
399
480
  else {
400
- this.table.addColumnFilter(column.fieldCode, values);
481
+ this.table?.addColumnFilter(column.fieldCode, values);
401
482
  }
402
483
  }
403
484
  }
404
- LibTableComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: LibTableComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
405
- LibTableComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.6", type: LibTableComponent, selector: "lib-table", inputs: { table: "table", tableRecords: "tableRecords", disabled: "disabled", state: "state", waiting: "waiting" }, ngImport: i0, template: `<ng-content></ng-content>`, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush });
485
+ LibTableComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: LibTableComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
486
+ 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 });
406
487
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: LibTableComponent, decorators: [{
407
488
  type: Component,
408
489
  args: [{
@@ -412,11 +493,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.6", ngImpor
412
493
  }]
413
494
  }], propDecorators: { table: [{
414
495
  type: Input
415
- }], tableRecords: [{
416
- type: Input
417
- }], disabled: [{
418
- type: Input
419
- }], state: [{
496
+ }], visibleRecords: [{
420
497
  type: Input
421
498
  }], waiting: [{
422
499
  type: Input
@@ -448,22 +525,30 @@ const operators = {
448
525
  IN: 'IN',
449
526
  };
450
527
 
451
- class FormElement {
452
- constructor(elementDefinition, formConfig) {
528
+ class FormPiece {
529
+ constructor(pieceDefinition, formConfig) {
530
+ this._attributeChange = new BehaviorSubject(null);
531
+ this._formState = '';
453
532
  this._visible = true;
533
+ this._disabled = false;
454
534
  this.visibleStates = null;
455
535
  this.enabledStates = null;
456
- this.elementType = null;
536
+ this.visibleOnState = true;
537
+ this.disabledOnState = false;
538
+ this.customAttributes = {};
457
539
  this._formConfig = formConfig;
458
540
  this._isForced = false;
459
- this.setVisibleStates(elementDefinition.visibleStates);
460
- this.setEnabledStates(elementDefinition.enabledStates);
461
541
  this._visibleForced = false;
462
- this.disabled = elementDefinition?.disabled ?? false;
463
- this.setVisibility(elementDefinition?.visible ?? true);
464
- this.customAttributes = elementDefinition?.customAttributes ?? {};
542
+ this.setVisibleStates(pieceDefinition.visibleStates);
543
+ this.setEnabledStates(pieceDefinition.enabledStates);
544
+ this.enabled = !pieceDefinition?.disabled ?? false;
545
+ this.setVisibility(pieceDefinition?.visible ?? true);
546
+ this.customAttributes = pieceDefinition?.customAttributes ?? {};
547
+ if (pieceDefinition?.customAttributes) {
548
+ Object.keys(pieceDefinition?.customAttributes)
549
+ ?.forEach(attr => this.customAttributes[attr] = pieceDefinition?.customAttributes[attr]);
550
+ }
465
551
  }
466
- ;
467
552
  getCustomAttribute(name) { return this.customAttributes?.[name] ?? null; }
468
553
  setCustomAttribute(name, value) { if (name) {
469
554
  this.customAttributes[name] = value;
@@ -474,9 +559,10 @@ class FormElement {
474
559
  });
475
560
  }
476
561
  matchAttribute(name, value) { return this.customAttributes?.[name] === value; }
477
- isField() { return this.elementType === elementTypes.field; }
478
- isAction() { return this.elementType === elementTypes.action; }
479
- isTable() { return this.elementType === elementTypes.table; }
562
+ get attributeChange() { return this._attributeChange; }
563
+ propagateAttribute(name, value) {
564
+ this._attributeChange.next({ name, value });
565
+ }
480
566
  setVisibleStates(newStates) {
481
567
  const visibleStates = (!Array.isArray(newStates) && typeof newStates === 'string')
482
568
  ? newStates.split(',').map(state => state.trim()).filter(state => state.length > 0)
@@ -491,47 +577,90 @@ class FormElement {
491
577
  }
492
578
  viewOnState(state) { return (this.visibleStates && state) ? this.visibleStates.includes(state) : false; }
493
579
  enabledOnState(state) { return (this.enabledStates && state) ? this.enabledStates.includes(state) : false; }
494
- /**
495
- * @deprecated Utilizar viewOnState
496
- */
497
- supportState(state) { return this.viewOnState(state); }
498
- /**
499
- * @deprecated Utilizar viewOnState
500
- */
501
- supportMode(state) { return this.viewOnState(state); }
502
- get visible() { return (this._isForced) ? this._visibleForced : this._visible; }
580
+ get visible() { return this._visible; }
503
581
  set visible(visible) { this.setVisibility(visible); }
504
582
  visibleOn(state) {
505
583
  return this.visible && this.viewOnState(state);
506
584
  }
507
585
  enabledOn(state) {
508
- return !this.disabled && this.enabledOnState(state);
586
+ return !this._disabled && this.enabledOnState(state);
509
587
  }
510
588
  setVisibility(visible, forced = null) {
511
589
  this._visible = visible && true;
512
- if (forced != null) {
590
+ this.propagateVisible();
591
+ if (forced !== null) {
513
592
  this._isForced = forced;
593
+ this._visibleForced = visible;
594
+ }
595
+ const formerVisibleOnState = this.visibleOnState;
596
+ this.visibleOnState = this.visible && this.viewOnState(this._formState);
597
+ if (formerVisibleOnState !== this.visibleOnState) {
598
+ this.propagateAttribute('visible', this.visibleOnState);
514
599
  }
515
600
  }
516
601
  show(forced = null) {
517
- this._visible = true;
518
- if (forced !== null) {
519
- this._isForced = forced;
520
- this._visibleForced = true;
521
- }
602
+ this.setVisibility(true, forced);
522
603
  }
523
604
  hide(forced = null) {
524
- this._visible = false;
525
- if (forced !== null) {
526
- this._isForced = forced;
527
- this._visibleForced = false;
528
- }
605
+ this.setVisibility(false, forced);
606
+ }
607
+ get disabled() { return this._disabled; }
608
+ get enabled() { return !this._disabled; }
609
+ get editable() { return !this._disabled; }
610
+ set enabled(enabled) {
611
+ this._disabled = !enabled;
612
+ const formerDisableOnState = this.disabledOnState;
613
+ this.disabledOnState = this._disabled || !this.enabledOnState(this._formState);
614
+ if (formerDisableOnState !== this.disabledOnState) {
615
+ this.propagateDisabled();
616
+ }
617
+ }
618
+ enable() { this.enabled = true; }
619
+ disable() { this.enabled = false; }
620
+ subscribeFormStateChange(formChangeSubject) {
621
+ this.formStateChangeCustom(formChangeSubject);
622
+ formChangeSubject.subscribe(event => {
623
+ const { state } = event ?? {};
624
+ if (state) {
625
+ this._formState = state;
626
+ this.visibleOnState = this.visible && this.viewOnState(state);
627
+ this.disabledOnState = this._disabled || !this.enabledOnState(state);
628
+ this.propagateVisible();
629
+ this.propagateDisabled();
630
+ }
631
+ });
632
+ }
633
+ formStateChangeCustom(formChangeSubject) { }
634
+ propagateVisible() {
635
+ this.propagateAttribute('visible', this.visibleOnState);
636
+ }
637
+ propagateDisabled() {
638
+ this.propagateAttribute('disabled', this.disabledOnState);
639
+ }
640
+ }
641
+
642
+ class FormElement extends FormPiece {
643
+ constructor(elementDefinition, formConfig) {
644
+ super(elementDefinition, formConfig);
645
+ this.elementType = null;
646
+ }
647
+ ;
648
+ setAttr(attr, value) {
649
+ const { name: attrName, propagate: name } = attr;
650
+ this[attrName] = value;
651
+ name && this.propagateAttribute(name, value);
529
652
  }
530
- enable() { this.disabled = false; }
531
- disable() { this.disabled = true; }
532
- get enabled() { return !this.disabled; }
533
- get editable() { return !this.disabled; }
534
- set editable(editable) { this.disabled = !editable; }
653
+ isField() { return this.elementType === elementTypes.field; }
654
+ isAction() { return this.elementType === elementTypes.action; }
655
+ isTable() { return this.elementType === elementTypes.table; }
656
+ /**
657
+ * @deprecated Utilizar viewOnState
658
+ */
659
+ supportState(state) { return this.viewOnState(state); }
660
+ /**
661
+ * @deprecated Utilizar viewOnState
662
+ */
663
+ supportMode(state) { return this.viewOnState(state); }
535
664
  }
536
665
 
537
666
  const HEADER = 'HEADER';
@@ -578,7 +707,7 @@ const directChanges = [
578
707
  'maxLength', 'maxValue', 'minLength', 'minValue', 'validateOnServer', 'serverAction', 'visibleLabel',
579
708
  'options',
580
709
  ];
581
- const attrs = {
710
+ const attrs$1 = {
582
711
  _captureType: { name: '_captureType', propagate: 'captureType' },
583
712
  _errorCode: { name: '_errorCode', propagate: 'errorCode' },
584
713
  _errorMessage: { name: '_errorMessage', propagate: 'errorMessage' },
@@ -613,7 +742,6 @@ class FieldDescriptor extends FormElement {
613
742
  this._editionFinish = new Subject();
614
743
  this._editionPartial = new Subject();
615
744
  this._detailRequest = new Subject();
616
- this._attributeChange = new Subject();
617
745
  this._errorType = '';
618
746
  this._errorCode = '';
619
747
  this._errorMessage = '';
@@ -640,7 +768,7 @@ class FieldDescriptor extends FormElement {
640
768
  this._tooltipText = '';
641
769
  this.elementType = elementTypes.field;
642
770
  const fld = (inputFieldReceived) ? inputFieldReceived : {};
643
- this.setAttr(attrs._fieldCode, fld.fieldCode);
771
+ this.setAttr(attrs$1._fieldCode, fld.fieldCode);
644
772
  this.title = fld.fieldTitle ?? this._fieldCode;
645
773
  this.type = fld.fieldTypeCode;
646
774
  this.captureType = fld.captureType ?? DEFAULT_CAPTURE_TYPE;
@@ -680,17 +808,16 @@ class FieldDescriptor extends FormElement {
680
808
  this._setValue(fld.fieldValue ?? this._defaultValue ?? '');
681
809
  }
682
810
  get alignment() { return this._fieldAlignment; }
683
- set alignment(alignment) { this.setAttr(attrs._fieldAlignment, alignment); }
684
- get attributeChange() { return this._attributeChange; }
811
+ set alignment(alignment) { this.setAttr(attrs$1._fieldAlignment, alignment); }
685
812
  get backend() { return this._validateOnServer; }
686
813
  get captureType() { return this._captureType; }
687
- set captureType(captureType) { this.setAttr(attrs._captureType, captureType); }
814
+ set captureType(captureType) { this.setAttr(attrs$1._captureType, captureType); }
688
815
  get code() { return this._fieldCode; }
689
816
  get fieldCode() { return this._fieldCode; }
690
817
  get defaultValue() { return this._defaultValue; }
691
- set defaultValue(defaultValue) { this.setAttr(attrs._defaultValue, defaultValue); }
818
+ set defaultValue(defaultValue) { this.setAttr(attrs$1._defaultValue, defaultValue); }
692
819
  get defaultEditable() { return this._defaultEditable; }
693
- set defaultEditable(editable) { this.setAttr(attrs._defaultEditable, editable); }
820
+ set defaultEditable(editable) { this.setAttr(attrs$1._defaultEditable, editable); }
694
821
  get detailRequest() { return this._detailRequest; }
695
822
  get editionFinish() { return this._editionFinish; }
696
823
  get editionPartial() { return this._editionPartial; }
@@ -725,31 +852,31 @@ class FieldDescriptor extends FormElement {
725
852
  get errorType() { return this._errorType; }
726
853
  get externalValue() { return this._externalValue; }
727
854
  get format() { return this._fieldFormat; }
728
- set format(format) { this.setAttr(attrs._fieldFormat, format); }
855
+ set format(format) { this.setAttr(attrs$1._fieldFormat, format); }
729
856
  get hasChanged() { return this._hasChanged; }
730
- set hasChanged(hasChanged) { this.setAttr(attrs._hasChanged, hasChanged); }
857
+ set hasChanged(hasChanged) { this.setAttr(attrs$1._hasChanged, hasChanged); }
731
858
  get info() { return this._fieldInfo; }
732
- set info(newInfo) { this.setAttr(attrs._fieldInfo, newInfo); }
733
- set intrinsicErrorMessage(message) { this.setAttr(attrs._intrinsicErrorMessage, message); }
859
+ set info(newInfo) { this.setAttr(attrs$1._fieldInfo, newInfo); }
860
+ set intrinsicErrorMessage(message) { this.setAttr(attrs$1._intrinsicErrorMessage, message); }
734
861
  get maxLength() { return (this._maxLength > 0) ? this._maxLength.toString() : ''; }
735
- set maxLength(requiredMaxLength) { this.setAttr(attrs._maxLength, +requiredMaxLength); }
862
+ set maxLength(requiredMaxLength) { this.setAttr(attrs$1._maxLength, +requiredMaxLength); }
736
863
  get maxValue() { return this._maxValue; }
737
864
  set maxValue(inputMaxValue) {
738
865
  let maxValue = inputMaxValue;
739
866
  if (this._fieldType === this._formConfig.fieldTypes.date) {
740
867
  maxValue = new Date(maxValue);
741
868
  }
742
- this.setAttr(attrs._maxValue, maxValue);
869
+ this.setAttr(attrs$1._maxValue, maxValue);
743
870
  }
744
871
  get minLength() { return this._minLength; }
745
- set minLength(requiredMinLength) { this.setAttr(attrs._minLength, +requiredMinLength); }
872
+ set minLength(requiredMinLength) { this.setAttr(attrs$1._minLength, +requiredMinLength); }
746
873
  get minValue() { return this._minValue; }
747
874
  set minValue(inputMinValue) {
748
875
  let minValue = inputMinValue;
749
876
  if (this._fieldType === this._formConfig.fieldTypes.date) {
750
877
  minValue = new Date(minValue);
751
878
  }
752
- this.setAttr(attrs._minValue, minValue);
879
+ this.setAttr(attrs$1._minValue, minValue);
753
880
  }
754
881
  get name() { return this._fieldCode; }
755
882
  get options() {
@@ -773,11 +900,11 @@ class FieldDescriptor extends FormElement {
773
900
  });
774
901
  fieldOptions = (fieldOptions && Array.isArray(fieldOptions)
775
902
  && fieldOptions.length > 0) ? fieldOptions : [];
776
- this.setAttr(attrs._fieldOptions, fieldOptions);
903
+ this.setAttr(attrs$1._fieldOptions, fieldOptions);
777
904
  if (this._value) {
778
905
  if (this._fieldType === this._formConfig.fieldTypes.array && Array.isArray(this._value)) {
779
906
  const fieldValue = this._value?.filter(item => this._fieldOptions?.find(opt => opt.fieldOptionId === item));
780
- this.setAttr(attrs._value, fieldValue);
907
+ this.setAttr(attrs$1._value, fieldValue);
781
908
  }
782
909
  else {
783
910
  const valInOptions = this._fieldOptions?.find(item => item.fieldOptionId === this._value);
@@ -793,28 +920,28 @@ class FieldDescriptor extends FormElement {
793
920
  }
794
921
  get optionText() { return this._fieldOptions?.find(item => item.fieldOptionId === this._value)?.fieldOptionValue ?? null; }
795
922
  get outputOnly() { return this._outputOnly; }
796
- set outputOnly(outputOnly) { this.setAttr(attrs._outputOnly, outputOnly); }
923
+ set outputOnly(outputOnly) { this.setAttr(attrs$1._outputOnly, outputOnly); }
797
924
  get required() { return this._fieldRequired; }
798
- set required(required) { this.setAttr(attrs._fieldRequired, required ?? false); }
925
+ set required(required) { this.setAttr(attrs$1._fieldRequired, required ?? false); }
799
926
  get title() { return this._fieldTitle; }
800
- set title(title) { this.setAttr(attrs._fieldTitle, title?.toString() ?? ''); }
927
+ set title(title) { this.setAttr(attrs$1._fieldTitle, title?.toString() ?? ''); }
801
928
  get tooltip() { return this._tooltipText; }
802
- set tooltip(tooltip) { this.setAttr(attrs._tooltipText, tooltip); }
929
+ set tooltip(tooltip) { this.setAttr(attrs$1._tooltipText, tooltip); }
803
930
  get type() { return this._fieldType; }
804
- set type(fieldType) { this.setAttr(attrs._fieldType, fieldType); }
931
+ set type(fieldType) { this.setAttr(attrs$1._fieldType, fieldType); }
805
932
  get validating() { return this._onValidation; }
806
- set validating(isValidating) { this.setAttr(attrs._onValidation, isValidating); }
933
+ set validating(isValidating) { this.setAttr(attrs$1._onValidation, isValidating); }
807
934
  get value() {
808
935
  return (this._fieldType === this._formConfig.fieldTypes.boolean
809
936
  || this._fieldType === this._formConfig.fieldTypes.check) ? yn(this._value) : this._value;
810
937
  }
811
938
  get validateOnServer() { return this._validateOnServer; }
812
- set validateOnServer(validateOnServer) { this.setAttr(attrs._validateOnServer, validateOnServer); }
939
+ set validateOnServer(validateOnServer) { this.setAttr(attrs$1._validateOnServer, validateOnServer); }
813
940
  get serverAction() { return this._validateOnServer; }
814
941
  set serverAction(validateOnServer) { this.validateOnServer = validateOnServer; }
815
942
  set value(newValue) { this._setValue(newValue); }
816
943
  get visibleLabel() { return this._visibleLabel; }
817
- set visibleLabel(visibleLabel) { this.setAttr(attrs._visibleLabel, visibleLabel); }
944
+ set visibleLabel(visibleLabel) { this.setAttr(attrs$1._visibleLabel, visibleLabel); }
818
945
  /**
819
946
  * @deprecated Use options
820
947
  */
@@ -832,7 +959,7 @@ class FieldDescriptor extends FormElement {
832
959
  */
833
960
  changed(hasChanged = true) { this.hasChanged = hasChanged; }
834
961
  clean() { this._setValue(this._defaultValue || ''); this.resetError(); }
835
- focus() { this.setAttr(attrs._focus, true); }
962
+ focus() { this.setAttr(attrs$1._focus, true); }
836
963
  getErrorCode() { return this.error.code; }
837
964
  setErrorCode(code) { this.setError(code, this._errorMessage); }
838
965
  getErrorMessage() { return this.error.message; }
@@ -940,15 +1067,10 @@ class FieldDescriptor extends FormElement {
940
1067
  const detailEvent = { code: this._fieldCode, detail };
941
1068
  this._detailRequest.next(detailEvent);
942
1069
  }
943
- setAttr(attr, value) {
944
- const { name: attrName, propagate: name } = attr;
945
- this[attrName] = value;
946
- name && this._attributeChange.next({ name, value });
947
- }
948
1070
  setError(code, message, type = DEFAULT_ERROR_TYPE) {
949
- this.setAttr(attrs._errorCode, code ?? NO_ERROR);
950
- this.setAttr(attrs._errorType, (this._errorCode === NO_ERROR) ? '' : type);
951
- this.setAttr(attrs._errorMessage, message ?? '');
1071
+ this.setAttr(attrs$1._errorCode, code ?? NO_ERROR);
1072
+ this.setAttr(attrs$1._errorType, (this._errorCode === NO_ERROR) ? '' : type);
1073
+ this.setAttr(attrs$1._errorMessage, message ?? '');
952
1074
  }
953
1075
  updateFromServer(fld) {
954
1076
  const fieldKeys = Object.keys(fld);
@@ -1003,7 +1125,7 @@ class FieldDescriptor extends FormElement {
1003
1125
  if (this._value !== newFinalValue) {
1004
1126
  this.hasChanged = true;
1005
1127
  if (widgetUpdate) {
1006
- this.setAttr(attrs._value, newFinalValue);
1128
+ this.setAttr(attrs$1._value, newFinalValue);
1007
1129
  }
1008
1130
  else {
1009
1131
  this._value = newFinalValue;
@@ -1013,22 +1135,20 @@ class FieldDescriptor extends FormElement {
1013
1135
  }
1014
1136
  }
1015
1137
 
1016
- class RecordTableColumn {
1138
+ class RecordTableColumn extends FormPiece {
1017
1139
  constructor(recTableColReceived, formConfig) {
1140
+ super(recTableColReceived, formConfig);
1018
1141
  this.fieldCode = '';
1019
1142
  this.fieldTitle = '';
1020
1143
  this.fieldType = '';
1021
1144
  this.fieldAlignment = '';
1022
1145
  this.fieldFormat = '';
1023
- this.visible = true;
1024
1146
  this.sortable = true;
1025
1147
  this.sortDirections = [];
1026
- this.customAttributes = {};
1027
1148
  // Filtros
1028
1149
  this.filterVisible = false;
1029
1150
  this.filterDef = null;
1030
1151
  this.filterSetup = null;
1031
- this._formConfig = formConfig;
1032
1152
  this.filterDef = null;
1033
1153
  if (recTableColReceived) {
1034
1154
  this.fieldCode = recTableColReceived.fieldCode;
@@ -1043,15 +1163,6 @@ class RecordTableColumn {
1043
1163
  this.customAttributes = recTableColReceived?.customAttributes ?? {};
1044
1164
  }
1045
1165
  }
1046
- getCustomAttribute(name) { return this.customAttributes?.[name] ?? null; }
1047
- setCustomAttribute(name, value) { if (name) {
1048
- this.customAttributes[name] = value;
1049
- } }
1050
- setCustomAttributes(attributes) {
1051
- Object.entries(attributes).forEach(([name, value]) => {
1052
- this.setCustomAttribute(name, value);
1053
- });
1054
- }
1055
1166
  hideFilter() {
1056
1167
  this.filterVisible = false;
1057
1168
  }
@@ -1094,8 +1205,9 @@ class RecordTableColumn {
1094
1205
  }
1095
1206
  }
1096
1207
 
1097
- class TableAction {
1098
- constructor(actionDefinition) {
1208
+ class TableAction extends FormPiece {
1209
+ constructor(actionDefinition, formConfig) {
1210
+ super(actionDefinition, formConfig);
1099
1211
  this.actionCode = actionDefinition.actionCode;
1100
1212
  this.actionTitle = actionDefinition.actionTitle;
1101
1213
  this.iconName = actionDefinition.iconName || this.actionCode;
@@ -1103,26 +1215,11 @@ class TableAction {
1103
1215
  this.actionClass = actionDefinition.actionClass || 'INLINE';
1104
1216
  this.newState = actionDefinition.newState;
1105
1217
  this.stateField = actionDefinition.stateField || '';
1106
- this.visibleStates = actionDefinition.visibleStates || [];
1107
- this.enabledStates = actionDefinition.enabledStates || [];
1108
1218
  this.backend = actionDefinition?.serverAction ?? false;
1109
1219
  this.restrictedOnField = actionDefinition.fieldRestrictedCode || '';
1110
1220
  this.restrictedOnValue = actionDefinition.valueRestricted ?? '';
1111
1221
  this.restrictedOnOperator = actionDefinition.operatorRestricted || '';
1112
- this.customAttributes = actionDefinition?.customAttributes ?? {};
1113
- }
1114
- getCustomAttribute(name) { return this.customAttributes?.[name] ?? null; }
1115
- setCustomAttribute(name, value) { if (name) {
1116
- this.customAttributes[name] = value;
1117
- } }
1118
- setCustomAttributes(attributes) {
1119
- Object.entries(attributes).forEach(([name, value]) => {
1120
- this.setCustomAttribute(name, value);
1121
- });
1122
1222
  }
1123
- supportMode(state) { return this.viewOnState(state); }
1124
- viewOnState(state) { return this.visibleStates.includes(state); }
1125
- enabledOnState(state) { return this.enabledStates.includes(state); }
1126
1223
  }
1127
1224
 
1128
1225
  class TableRecordData {
@@ -1237,6 +1334,21 @@ class TableRecordData {
1237
1334
 
1238
1335
  const TABLE_SORT_ASCENDING = 'asc';
1239
1336
  const TABLE_SORT_DESCENDING = 'desc';
1337
+ const attrs = {
1338
+ allSelected: { name: 'allSelected', propagate: 'allSelected' },
1339
+ tableCode: { name: 'tableCode', propagate: 'code' },
1340
+ clientPaging: { name: 'clientPaging', propagate: null },
1341
+ globalSearch: { name: 'globalSearch', propagate: 'globalSearch' },
1342
+ globalFilterString: { name: 'globalFilterString', propagate: null },
1343
+ sorting: { name: 'sorting', propagate: null },
1344
+ recordsPerPage: { name: 'recordsPerPage', propagate: 'recordsPerPage' },
1345
+ layout: { name: 'layout', propagate: 'layout' },
1346
+ columns: { name: 'columns', propagate: 'columns' },
1347
+ selectedRecords: { name: 'selectedRecords', propagate: 'selectedRecords' },
1348
+ currentPage: { name: 'currentPage', propagate: 'currentPage' },
1349
+ totalRecordsNumber: { name: 'totalRecordsNumber', propagate: 'totalRecordsNumber' },
1350
+ visibleRecords: { name: 'visibleRecords', propagate: 'visibleRecords' },
1351
+ };
1240
1352
  class RecordTable extends FormElement {
1241
1353
  constructor(tableReceived, formConfig) {
1242
1354
  super(tableReceived, formConfig);
@@ -1245,7 +1357,6 @@ class RecordTable extends FormElement {
1245
1357
  this._recordSelectionTrigger = new Subject();
1246
1358
  this._selectionActionTrigger = new Subject();
1247
1359
  this._getDataTrigger = new Subject();
1248
- this._attributeChange = new Subject();
1249
1360
  this._tableColumnObj = {};
1250
1361
  this._actionsObj = {};
1251
1362
  // Mecanismos de filtrado nueva versión
@@ -1276,22 +1387,23 @@ class RecordTable extends FormElement {
1276
1387
  this.selectable = tableReceived?.selectable ?? false;
1277
1388
  this.selectionBackend = tableReceived?.selectionBackend ?? false;
1278
1389
  this.sortable = tableReceived?.sortable ?? false;
1279
- this.setAttr('allSelected', false);
1280
- this.setAttr('tableCode', tableReceived.tableCode);
1281
- this.setAttr('clientPaging', tableReceived?.clientPaging ?? true);
1282
- this.setAttr('globalSearch', tableReceived?.simpleFilter ?? false);
1283
- this.setAttr('globalFilterString', '');
1284
- this.setAttr('sorting', { columnName: '', direction: '' });
1285
- this.setAttr('recordsPerPage', formConfig.defaultRecordsPerPage);
1286
- this.setAttr('layout', '');
1390
+ this.setAttr(attrs.allSelected, false);
1391
+ this.setAttr(attrs.tableCode, tableReceived.tableCode);
1392
+ this.setAttr(attrs.clientPaging, tableReceived?.clientPaging ?? true);
1393
+ this.setAttr(attrs.globalSearch, tableReceived?.simpleFilter ?? false);
1394
+ this.setAttr(attrs.globalFilterString, '');
1395
+ this.setAttr(attrs.sorting, { columnName: '', direction: '' });
1396
+ this.setAttr(attrs.recordsPerPage, formConfig.defaultRecordsPerPage);
1397
+ this.setAttr(attrs.layout, '');
1287
1398
  if (tableReceived.fields) {
1288
1399
  const columns = [];
1289
1400
  for (const columnReceived of tableReceived.fields) {
1290
- const columnDefinition = new RecordTableColumn(columnReceived, this._formConfig);
1401
+ const columnEnriched = { ...columnReceived, visibleStates: this.visibleStates };
1402
+ const columnDefinition = new RecordTableColumn(columnEnriched, this._formConfig);
1291
1403
  columns.push(columnDefinition);
1292
1404
  this._tableColumnObj[columnDefinition.fieldCode] = columnDefinition;
1293
1405
  }
1294
- this.setAttr('columns', columns);
1406
+ this.setAttr(attrs.columns, columns);
1295
1407
  }
1296
1408
  if (tableReceived.actions) {
1297
1409
  const tableActions = tableReceived.actions.map(objDef => {
@@ -1308,7 +1420,7 @@ class RecordTable extends FormElement {
1308
1420
  return { ...objDef, visibleStates, enabledStates };
1309
1421
  });
1310
1422
  for (const actionReceived of tableActions) {
1311
- const inlineAction = new TableAction(actionReceived);
1423
+ const inlineAction = new TableAction(actionReceived, this._formConfig);
1312
1424
  this._actions.push(inlineAction);
1313
1425
  this._actionsObj[inlineAction.actionCode] = inlineAction;
1314
1426
  }
@@ -1327,9 +1439,8 @@ class RecordTable extends FormElement {
1327
1439
  get selectionActionTrigger() { return this._selectionActionTrigger; }
1328
1440
  get recordSelectionTrigger() { return this._recordSelectionTrigger; }
1329
1441
  get getDataTrigger() { return this._getDataTrigger; }
1330
- get attributeChange() { return this._attributeChange; }
1331
1442
  getLayout() { return this.layout; }
1332
- setLayout(layout) { this.setAttr('layout', layout); }
1443
+ setLayout(layout) { this.setAttr(attrs.layout, layout); }
1333
1444
  hasActions() { return (this._actions.length > 0); }
1334
1445
  getSelectedRecords() { return this.tableRecords.filter(rec => rec.selected).map(rec => rec.recordId); }
1335
1446
  activateGlobalSearch() { this.globalSearch = true; }
@@ -1337,12 +1448,6 @@ class RecordTable extends FormElement {
1337
1448
  columnDefinition(fieldCode) { return this._tableColumnObj[fieldCode]; }
1338
1449
  putOnWait() { this.waiting = true; }
1339
1450
  freeWaiting() { this.waiting = false; }
1340
- setAttr(name, value) {
1341
- this[name] = value;
1342
- if (this._formConfig.monitoredTableAttributes.includes(name)) {
1343
- this._attributeChange.next({ name, value });
1344
- }
1345
- }
1346
1451
  notifyGlobalAction(actionCode) {
1347
1452
  const tableEvent = {
1348
1453
  tableCode: this.tableCode,
@@ -1407,23 +1512,23 @@ class RecordTable extends FormElement {
1407
1512
  this.updateVisibleRecords();
1408
1513
  }
1409
1514
  selectAll() {
1410
- this.setAttr('allSelected', true);
1515
+ this.setAttr(attrs.allSelected, true);
1411
1516
  this.tableRecords.forEach(record => record.select());
1412
- this.setAttr('selectedRecords', this.getSelectedRecords());
1517
+ this.setAttr(attrs.selectedRecords, this.getSelectedRecords());
1413
1518
  return true;
1414
1519
  }
1415
1520
  unSelectAll() {
1416
- this.setAttr('allSelected', false);
1521
+ this.setAttr(attrs.allSelected, false);
1417
1522
  this.tableRecords.forEach(record => record.unselect());
1418
- this.setAttr('selectedRecords', this.getSelectedRecords());
1523
+ this.setAttr(attrs.selectedRecords, this.getSelectedRecords());
1419
1524
  return true;
1420
1525
  }
1421
1526
  setTableRecords(tableRecords, append) {
1422
1527
  if (!append) {
1423
1528
  this.tableRecords = [];
1424
- this.setAttr('allSelected', false);
1529
+ this.setAttr(attrs.allSelected, false);
1425
1530
  this.tableRecords.forEach(record => record.unselect());
1426
- this.setAttr('selectedRecords', []);
1531
+ this.setAttr(attrs.selectedRecords, []);
1427
1532
  this.tableRecordObj = {};
1428
1533
  }
1429
1534
  const newRecordsObj = { ...this.tableRecordObj };
@@ -1435,7 +1540,7 @@ class RecordTable extends FormElement {
1435
1540
  newRecordsObj[recordIdKey] = recordReceived;
1436
1541
  }
1437
1542
  this.tableRecords = newRecords;
1438
- this.setAttr('selectedRecords', this.getSelectedRecords());
1543
+ this.setAttr(attrs.selectedRecords, this.getSelectedRecords());
1439
1544
  this.tableRecordObj = newRecordsObj;
1440
1545
  this.updateVisibleRecords();
1441
1546
  }
@@ -1444,7 +1549,7 @@ class RecordTable extends FormElement {
1444
1549
  setTableAppend(append) { this._appendPages = append; }
1445
1550
  changePage(requestedPage) {
1446
1551
  if (this.clientPaging) {
1447
- this.setAttr('currentPage', requestedPage);
1552
+ this.setAttr(attrs.currentPage, requestedPage);
1448
1553
  this.updateVisibleRecords();
1449
1554
  }
1450
1555
  else {
@@ -1456,7 +1561,7 @@ class RecordTable extends FormElement {
1456
1561
  let visibleRecords;
1457
1562
  if (this.clientPaging) {
1458
1563
  let filteredRecords = this.getFilteredRecords();
1459
- this.setAttr('totalRecordsNumber', filteredRecords.length);
1564
+ this.setAttr(attrs.totalRecordsNumber, filteredRecords.length);
1460
1565
  const sliceNumber1 = (this.currentPage - 1) * this.recordsPerPage;
1461
1566
  const sliceNumber2 = (this.currentPage - 1) * this.recordsPerPage + this.recordsPerPage;
1462
1567
  visibleRecords = filteredRecords.slice(sliceNumber1, sliceNumber2);
@@ -1469,17 +1574,17 @@ class RecordTable extends FormElement {
1469
1574
  else {
1470
1575
  visibleRecords = this.tableRecords;
1471
1576
  }
1472
- this.setAttr('visibleRecords', visibleRecords);
1577
+ this.setAttr(attrs.visibleRecords, visibleRecords);
1473
1578
  }
1474
1579
  updateFromServer(tableReceived) {
1475
1580
  this.requestedPage = 1;
1476
1581
  this.visible = tableReceived?.visible || true;
1477
1582
  this.totalPages = tableReceived.totalPages || 1;
1478
1583
  this.recordsNumber = tableReceived.recordsNumber;
1479
- this.setAttr('currentPage', +tableReceived?.currentPage || 1);
1480
- this.setAttr('recordsPerPage', +tableReceived.recordsPerPage);
1481
- this.setAttr('totalRecordsNumber', (this.clientPaging) ? tableReceived.tableRecords.length : +tableReceived.totalRecordsNumber);
1482
- this.setAttr('sorting', {
1584
+ this.setAttr(attrs.currentPage, +tableReceived?.currentPage || 1);
1585
+ this.setAttr(attrs.recordsPerPage, +tableReceived.recordsPerPage);
1586
+ this.setAttr(attrs.totalRecordsNumber, (this.clientPaging) ? tableReceived.tableRecords.length : +tableReceived.totalRecordsNumber);
1587
+ this.setAttr(attrs.sorting, {
1483
1588
  columnName: tableReceived.sortingColumn || '',
1484
1589
  direction: tableReceived.sortingDirection || ''
1485
1590
  });
@@ -1528,7 +1633,7 @@ class RecordTable extends FormElement {
1528
1633
  this.changePage(1);
1529
1634
  }
1530
1635
  if (notifyComponent) {
1531
- this.setAttr('globalFilterString', text);
1636
+ this.setAttr(attrs.globalFilterString, text);
1532
1637
  }
1533
1638
  }
1534
1639
  addFilterDefinition(columnName, filterDefinition) {
@@ -1595,7 +1700,7 @@ class RecordTable extends FormElement {
1595
1700
  }
1596
1701
  }
1597
1702
  setRequiredOrder(columnField, direction = null) {
1598
- this.setAttr('sorting', {
1703
+ this.setAttr(attrs.sorting, {
1599
1704
  columnName: columnField,
1600
1705
  direction: (direction === 'ascend') ? TABLE_SORT_ASCENDING : TABLE_SORT_DESCENDING,
1601
1706
  });
@@ -1622,28 +1727,35 @@ class RecordTable extends FormElement {
1622
1727
  }
1623
1728
  return direction === TABLE_SORT_ASCENDING ? result : -result;
1624
1729
  }
1730
+ formStateChangeCustom(formChangeSubject) {
1731
+ this.columns?.forEach(column => {
1732
+ column?.subscribeFormStateChange(formChangeSubject);
1733
+ });
1734
+ }
1625
1735
  }
1626
1736
 
1627
- class RecordFormSubSection {
1628
- constructor(subsectionReceived, formObject) {
1629
- if (!subsectionReceived) {
1630
- return;
1631
- }
1737
+ class RecordFormSubSection extends FormPiece {
1738
+ constructor(subsectionReceived, formObject, formConfig) {
1739
+ super(subsectionReceived, formConfig);
1632
1740
  this._customRender = null;
1633
- this.visible = true;
1741
+ this.subsectionId = null;
1742
+ this.subsectionCode = null;
1743
+ this.subsectionTitle = null;
1634
1744
  this.subSectionElements = [];
1635
1745
  this.subSectionFields = [];
1636
1746
  this.subSectionTables = [];
1637
1747
  this.subSectionActions = [];
1638
1748
  this.elementsArray = {};
1749
+ if (!subsectionReceived) {
1750
+ return;
1751
+ }
1639
1752
  this.subsectionId = (subsectionReceived.subsectionId) ? subsectionReceived.subsectionId.toString() : '';
1640
1753
  this.subsectionCode = (subsectionReceived.subsectionCode) ? subsectionReceived.subsectionCode : '';
1641
1754
  this.subsectionTitle = (subsectionReceived.subsectionTitle) ? subsectionReceived.subsectionTitle : '';
1642
- this.visibleStates = subsectionReceived.visibleStates || [];
1643
1755
  if (subsectionReceived.elements) {
1644
1756
  for (const receivedElement of subsectionReceived.elements) {
1645
1757
  let elementObject = null;
1646
- let arrayToAdd = null;
1758
+ let arrayToAdd = [];
1647
1759
  const { type, code } = receivedElement;
1648
1760
  switch (type) {
1649
1761
  case elementTypes.field:
@@ -1668,8 +1780,6 @@ class RecordFormSubSection {
1668
1780
  }
1669
1781
  }
1670
1782
  }
1671
- show() { this.visible = true; }
1672
- hide() { this.visible = false; }
1673
1783
  get customRender() { return this._customRender; }
1674
1784
  set customRender(customRenderName) { this._customRender = customRenderName; }
1675
1785
  getField(name) {
@@ -1687,26 +1797,24 @@ class RecordFormSubSection {
1687
1797
  getActionNames() {
1688
1798
  return this.subSectionActions.map(action => action.actionCode);
1689
1799
  }
1690
- viewOnState(state) {
1691
- return this.visibleStates.includes(state);
1692
- }
1693
- supportMode(state) { return this.viewOnState(state); }
1694
1800
  }
1695
1801
 
1696
- class RecordFormSection {
1697
- constructor(sectionReceived, formObject) {
1802
+ class RecordFormSection extends FormPiece {
1803
+ constructor(sectionReceived, formObject, formConfig) {
1804
+ super(sectionReceived, formConfig);
1698
1805
  this._activation = new Subject();
1699
1806
  this._inactivation = new Subject();
1700
1807
  this.active = false;
1701
- this.customAttributes = {};
1808
+ this.sectionId = null;
1809
+ this.sectionCode = null;
1810
+ this.sectionTitle = null;
1811
+ this.subSections = [];
1702
1812
  if (!sectionReceived) {
1703
1813
  return;
1704
1814
  }
1705
- this.visible = true;
1706
1815
  this.sectionId = (sectionReceived.sectionId) ? sectionReceived.sectionId.toString() : '';
1707
1816
  this.sectionCode = (sectionReceived.sectionCode) ? sectionReceived.sectionCode : '';
1708
1817
  this.sectionTitle = (sectionReceived.sectionTitle) ? sectionReceived.sectionTitle : '';
1709
- this.visibleStates = sectionReceived.visibleStates || [];
1710
1818
  this.subSections = [];
1711
1819
  this.subSectionsObj = {};
1712
1820
  if (sectionReceived.subsections) {
@@ -1726,7 +1834,7 @@ class RecordFormSection {
1726
1834
  return { ...objDef, visibleStates };
1727
1835
  });
1728
1836
  for (const subsectionReceived of subsections) {
1729
- const subSectionToAdd = new RecordFormSubSection(subsectionReceived, formObject);
1837
+ const subSectionToAdd = new RecordFormSubSection(subsectionReceived, formObject, formConfig);
1730
1838
  const subsectionCode = subSectionToAdd.subsectionCode;
1731
1839
  if (subsectionCode) {
1732
1840
  this.subSections.push(subSectionToAdd);
@@ -1734,36 +1842,22 @@ class RecordFormSection {
1734
1842
  }
1735
1843
  }
1736
1844
  }
1737
- if (sectionReceived?.customAttributes) {
1738
- Object.keys(sectionReceived?.customAttributes)
1739
- ?.forEach(attr => this.customAttributes[attr] = sectionReceived?.customAttributes[attr]);
1740
- }
1741
- }
1742
- getCustomAttribute(name) { return this.customAttributes?.[name] ?? null; }
1743
- setCustomAttribute(name, value) { return name && (this.customAttributes[name] = value); }
1744
- setCustomAttributes(attributes) {
1745
- Object.entries(attributes).forEach(([name, value]) => {
1746
- this.setCustomAttribute(name, value);
1747
- });
1748
1845
  }
1749
- matchAttribute(name, value) { return this.customAttributes?.[name] === value; }
1750
1846
  get code() { return this.sectionCode; }
1751
1847
  get activation() { return this._activation; }
1752
1848
  get inactivation() { return this._inactivation; }
1753
1849
  activate() {
1754
1850
  if (!this.active) {
1755
1851
  this.active = true;
1756
- this._activation.next(this.sectionCode);
1852
+ this.sectionCode && this._activation.next(this.sectionCode);
1757
1853
  }
1758
1854
  }
1759
1855
  inactivate() {
1760
1856
  if (this.active) {
1761
1857
  this.active = false;
1762
- this._inactivation.next(this.sectionCode);
1858
+ this.sectionCode && this._inactivation.next(this.sectionCode);
1763
1859
  }
1764
1860
  }
1765
- show() { this.visible = true; }
1766
- hide() { this.visible = false; }
1767
1861
  get title() { return this.sectionTitle; }
1768
1862
  set title(title) { this.sectionTitle = title; }
1769
1863
  getVisibleSubsections(state) {
@@ -1779,7 +1873,10 @@ class RecordFormSection {
1779
1873
  let fieldsArray = [];
1780
1874
  if (this.subSections && this.subSections.length > 0) {
1781
1875
  for (const subSection of this.subSections) {
1782
- fieldsArray = fieldsArray.concat(subSection.getFields());
1876
+ const subsectionFields = subSection.getFields() ?? [];
1877
+ if (subsectionFields?.length > 0) {
1878
+ fieldsArray = fieldsArray.concat(subsectionFields);
1879
+ }
1783
1880
  }
1784
1881
  }
1785
1882
  return fieldsArray;
@@ -1788,7 +1885,10 @@ class RecordFormSection {
1788
1885
  let actionArray = [];
1789
1886
  if (this.subSections && this.subSections.length > 0) {
1790
1887
  for (const subSection of this.subSections) {
1791
- actionArray = actionArray.concat(subSection.getActions());
1888
+ const subSectionActions = subSection.getActions() ?? [];
1889
+ if (subSectionActions?.length > 0) {
1890
+ actionArray = actionArray.concat(subSectionActions);
1891
+ }
1792
1892
  }
1793
1893
  }
1794
1894
  return actionArray;
@@ -1823,9 +1923,11 @@ class RecordFormSection {
1823
1923
  }
1824
1924
  return null;
1825
1925
  }
1826
- supportState(state) { return this.viewOnState(state); }
1827
- viewOnState(state) { return this.visibleStates.includes(state); }
1828
- supportMode(state) { return this.viewOnState(state); }
1926
+ formStateChangeCustom(formChangeSubject) {
1927
+ this.subSections?.forEach(subsection => {
1928
+ subsection?.subscribeFormStateChange(formChangeSubject);
1929
+ });
1930
+ }
1829
1931
  }
1830
1932
 
1831
1933
  const ACTIVE = 'active';
@@ -1836,6 +1938,7 @@ const DISABLE = 'disable';
1836
1938
  const CLEAN = 'clean';
1837
1939
  class FormStructureAndData {
1838
1940
  constructor(definitionReceived, formConfig) {
1941
+ this._stateChange = new Subject();
1839
1942
  this._name = '';
1840
1943
  this._title = '';
1841
1944
  this._fields = {};
@@ -1940,7 +2043,7 @@ class FormStructureAndData {
1940
2043
  return { ...objDef, visibleStates };
1941
2044
  });
1942
2045
  for (const sectionReceived of formSections) {
1943
- const sectionToAdd = new RecordFormSection(sectionReceived, this);
2046
+ const sectionToAdd = new RecordFormSection(sectionReceived, this, this._formConfig);
1944
2047
  const sectionCode = sectionToAdd.sectionCode;
1945
2048
  if (sectionCode) {
1946
2049
  this._sectionArray.push(sectionToAdd);
@@ -1972,8 +2075,10 @@ class FormStructureAndData {
1972
2075
  this.state = newState;
1973
2076
  }
1974
2077
  }
2078
+ this._stateChange.next({ state: this.state });
1975
2079
  return (this.state === newState);
1976
2080
  }
2081
+ get stateChange() { return this._stateChange; }
1977
2082
  setStateFlow(states, transitions, defaultState) {
1978
2083
  this._stateFlow.states = states;
1979
2084
  this._stateFlow.defaultState = defaultState || this._stateFlow.states[0];
@@ -2405,6 +2510,8 @@ class BasicFormComponent {
2405
2510
  this.cleanStart();
2406
2511
  this.customPreProcessing();
2407
2512
  }
2513
+ get title() { return this.getTitle() ?? ''; }
2514
+ set title(title) { this.setTitle(title); }
2408
2515
  getTitle() { return this._formStructure?.getTitle(); }
2409
2516
  setTitle(title) { return this._formStructure?.setTitle(title); }
2410
2517
  cleanData() { return this._formStructure?.cleanData(); }
@@ -2767,6 +2874,8 @@ class BasicFormComponent {
2767
2874
  const section = formSections[sectionName];
2768
2875
  section.activation.subscribe((code) => this.launchSectionActivation(code));
2769
2876
  section.inactivation.subscribe((code) => this.launchSectionInactivation(code));
2877
+ // Adicionalmente se le pide a la sección se subscriba al cambio de estado del formulario
2878
+ section.subscribeFormStateChange(this._formStructure?.stateChange);
2770
2879
  }
2771
2880
  }
2772
2881
  subscribeFieldsSubjects() {
@@ -2782,6 +2891,8 @@ class BasicFormComponent {
2782
2891
  this.startFieldInputValidation(code, intrinsicValidation);
2783
2892
  });
2784
2893
  field.detailRequest.subscribe(event => this.showFieldInfo(event.code, event.detail));
2894
+ // Adicionalmente se le pide al campo se subscriba al cambio de estado del formulario
2895
+ field.subscribeFormStateChange(this._formStructure?.stateChange);
2785
2896
  });
2786
2897
  }
2787
2898
  }
@@ -2790,6 +2901,8 @@ class BasicFormComponent {
2790
2901
  if (Array.isArray(formActions)) {
2791
2902
  formActions.forEach(action => {
2792
2903
  action.actionActivated.subscribe(code => this.startAction(code));
2904
+ // Adicionalmente se le pide a la acción se subscriba al cambio de estado del formulario
2905
+ action.subscribeFormStateChange(this._formStructure?.stateChange);
2793
2906
  });
2794
2907
  }
2795
2908
  }
@@ -2802,6 +2915,8 @@ class BasicFormComponent {
2802
2915
  table.recordSelectionTrigger.subscribe(event => this.startTableRecordSelection(event));
2803
2916
  table.selectionActionTrigger.subscribe(event => this.startTableSelectionAction(event));
2804
2917
  table.getDataTrigger.subscribe(event => this.startTableGetData(event));
2918
+ // Adicionalmente se le pide a la tabla se subscriba al cambio de estado del formulario
2919
+ table.subscribeFormStateChange(this._formStructure?.stateChange);
2805
2920
  });
2806
2921
  }
2807
2922
  }
@@ -2826,21 +2941,22 @@ class BasicFormComponent {
2826
2941
  if (!this.supportState(initialState)) {
2827
2942
  initialState = this._formStructure?.defaultState ?? null;
2828
2943
  }
2829
- this._formStructure?.changeState(initialState || this._formStructure?.defaultState);
2830
2944
  const inputFieldNames = Object.keys(this.inputDataFields);
2831
2945
  for (let index = 0; index < inputFieldNames.length; index++) {
2832
2946
  const code = inputFieldNames[index];
2833
2947
  const fieldValue = this.inputDataFields[code];
2834
2948
  this.setFieldValue(code, fieldValue);
2835
2949
  }
2836
- const recordResponse = await this.requestFormAction(formActions.getData);
2837
- this.checkErrorRecordReceived(recordResponse);
2838
- this.visible = true;
2839
- this.enabledSections = this._formStructure?.visibleSections ?? [];
2840
2950
  this.subscribeSectionActivation();
2841
2951
  this.subscribeFieldsSubjects();
2842
2952
  this.subscribeActionSubjects();
2843
2953
  this.subscribeTableSubjects();
2954
+ // Se define el estado inicial y se solicita la acción inicial
2955
+ this._formStructure?.changeState(initialState || this._formStructure?.defaultState);
2956
+ const recordResponse = await this.requestFormAction(formActions.getData);
2957
+ this.checkErrorRecordReceived(recordResponse);
2958
+ this.visible = true;
2959
+ this.enabledSections = this._formStructure?.visibleSections ?? [];
2844
2960
  this.start();
2845
2961
  this.customFormStart();
2846
2962
  }
@@ -3459,7 +3575,7 @@ class BasicFormComponent {
3459
3575
  if (action.backend) {
3460
3576
  const actionSubject = {
3461
3577
  tableCode,
3462
- actionType: this.formConfig.tableActions.inline,
3578
+ actionType: this.formConfig?.tableActions.inline,
3463
3579
  actionCode,
3464
3580
  tableRecordId: recordId,
3465
3581
  tableRecordData: recordData
@@ -3538,7 +3654,7 @@ class BasicFormComponent {
3538
3654
  if (tableObject.selectionBackend) {
3539
3655
  const actionSubject = {
3540
3656
  tableCode,
3541
- actionType: this.formConfig.tableActions.rowSelection,
3657
+ actionType: this.formConfig?.tableActions.rowSelection,
3542
3658
  actionCode: null,
3543
3659
  tableRecordId: recordId,
3544
3660
  tableRecordData: recordData
@@ -3616,7 +3732,7 @@ class BasicFormComponent {
3616
3732
  if (action.backend) {
3617
3733
  const actionSubject = {
3618
3734
  tableCode,
3619
- actionType: this.formConfig.tableActions.selection,
3735
+ actionType: this.formConfig?.tableActions.selection,
3620
3736
  actionCode,
3621
3737
  selectedRecords
3622
3738
  };
@@ -3706,7 +3822,7 @@ class BasicFormComponent {
3706
3822
  }
3707
3823
  checkSectionRequiredFields(sectionCode, reqFieldMessage) {
3708
3824
  this.cleanErrorFields(null, sectionCode);
3709
- const requiredFieldMessage = reqFieldMessage ?? this.formConfig.formStandardErrors.requiredField;
3825
+ const requiredFieldMessage = reqFieldMessage ?? this.formConfig?.formStandardErrors.requiredField;
3710
3826
  const numErrors = this.tagFieldsWithError(requiredFieldMessage, this.getRequiredEmptyFields(null, sectionCode));
3711
3827
  return (numErrors === 0);
3712
3828
  }
@@ -3714,15 +3830,15 @@ class BasicFormComponent {
3714
3830
  this.resetError();
3715
3831
  const completeFields = this.checkSectionRequiredFields(sectionCode, reqFieldMessage);
3716
3832
  if (!completeFields) {
3717
- this.setError(this.formConfig.formStandardErrors.typeWarning, this.formConfig.formStandardErrors.validationTitle, this.formConfig.formStandardErrors.requiredFields);
3833
+ this.setError(this.formConfig?.formStandardErrors.typeWarning, this.formConfig?.formStandardErrors.validationTitle, this.formConfig?.formStandardErrors.requiredFields);
3718
3834
  return false;
3719
3835
  }
3720
3836
  let validationError = false;
3721
3837
  const requiredEmptyFields = this.getRequiredEmptyFields(null, sectionCode) ?? [];
3722
3838
  if (requiredEmptyFields?.length > 0) {
3723
3839
  validationError = true;
3724
- this.setError(this.formConfig.formStandardErrors.typeWarning, this.formConfig.formStandardErrors.validationTitle, this.formConfig.formStandardErrors.requiredFields);
3725
- this.tagFieldsWithError(this.formConfig.formStandardErrors.requiredField, requiredEmptyFields);
3840
+ this.setError(this.formConfig?.formStandardErrors.typeWarning, this.formConfig?.formStandardErrors.validationTitle, this.formConfig?.formStandardErrors.requiredFields);
3841
+ this.tagFieldsWithError(this.formConfig?.formStandardErrors.requiredField, requiredEmptyFields);
3726
3842
  for (const code of requiredEmptyFields) {
3727
3843
  const requiredEmptyField = this.getField(code);
3728
3844
  requiredEmptyField?.focus();
@@ -3732,7 +3848,7 @@ class BasicFormComponent {
3732
3848
  const validationIssueFields = this.getFieldsWithValidationIssues(null, sectionCode) ?? [];
3733
3849
  if (!validationError && validationIssueFields.length > 0) {
3734
3850
  validationError = true;
3735
- this.setError(this.formConfig.formStandardErrors.typeWarning, this.formConfig.formStandardErrors.validationTitle, this.formConfig.formStandardErrors.validationFields);
3851
+ this.setError(this.formConfig?.formStandardErrors.typeWarning, this.formConfig?.formStandardErrors.validationTitle, this.formConfig?.formStandardErrors.validationFields);
3736
3852
  for (const code of validationIssueFields) {
3737
3853
  const validationIssueField = this.getField(code);
3738
3854
  if (validationIssueField) {