tuain-ng-forms-lib 14.3.20 → 14.4.90
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.
- package/esm2020/lib/classes/forms/element.mjs +8 -69
- package/esm2020/lib/classes/forms/field.mjs +5 -12
- package/esm2020/lib/classes/forms/form.mjs +11 -7
- package/esm2020/lib/classes/forms/piece-propagate.mjs +30 -0
- package/esm2020/lib/classes/forms/piece.mjs +95 -0
- package/esm2020/lib/classes/forms/section.mjs +44 -44
- package/esm2020/lib/classes/forms/subsection.mjs +24 -14
- package/esm2020/lib/classes/forms/table/action.mjs +5 -18
- package/esm2020/lib/classes/forms/table/column.mjs +8 -15
- package/esm2020/lib/classes/forms/table/row-data.mjs +14 -9
- package/esm2020/lib/classes/forms/table/table.mjs +62 -42
- package/esm2020/lib/components/elements/action.component.mjs +26 -13
- package/esm2020/lib/components/elements/field.component.mjs +20 -22
- package/esm2020/lib/components/elements/layout/element.component.mjs +5 -16
- package/esm2020/lib/components/elements/layout/form-header.component.mjs +5 -5
- package/esm2020/lib/components/elements/layout/piece.component.mjs +22 -0
- package/esm2020/lib/components/elements/layout/section.component.mjs +20 -5
- package/esm2020/lib/components/elements/layout/sub-section.component.mjs +20 -7
- package/esm2020/lib/components/elements/tables/table-record-action.component.mjs +21 -5
- package/esm2020/lib/components/elements/tables/table.component.mjs +50 -54
- package/esm2020/lib/components/forms/basic-form.mjs +26 -15
- package/fesm2015/tuain-ng-forms-lib.mjs +533 -398
- package/fesm2015/tuain-ng-forms-lib.mjs.map +1 -1
- package/fesm2020/tuain-ng-forms-lib.mjs +500 -368
- package/fesm2020/tuain-ng-forms-lib.mjs.map +1 -1
- package/lib/classes/forms/element.d.ts +3 -29
- package/lib/classes/forms/field.d.ts +0 -3
- package/lib/classes/forms/form.d.ts +3 -0
- package/lib/classes/forms/piece-propagate.d.ts +11 -0
- package/lib/classes/forms/piece.d.ts +41 -0
- package/lib/classes/forms/section.d.ts +10 -18
- package/lib/classes/forms/subsection.d.ts +10 -12
- package/lib/classes/forms/table/action.d.ts +3 -11
- package/lib/classes/forms/table/column.d.ts +4 -7
- package/lib/classes/forms/table/row-data.d.ts +1 -1
- package/lib/classes/forms/table/table.d.ts +3 -4
- package/lib/components/elements/action.component.d.ts +4 -8
- package/lib/components/elements/field.component.d.ts +5 -10
- package/lib/components/elements/layout/element.component.d.ts +3 -8
- package/lib/components/elements/layout/form-header.component.d.ts +3 -3
- package/lib/components/elements/layout/piece.component.d.ts +10 -0
- package/lib/components/elements/layout/section.component.d.ts +4 -3
- package/lib/components/elements/layout/sub-section.component.d.ts +4 -4
- package/lib/components/elements/tables/table-record-action.component.d.ts +2 -2
- package/lib/components/elements/tables/table.component.d.ts +6 -18
- package/lib/components/forms/basic-form.d.ts +2 -0
- 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
|
|
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:
|
|
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",
|
|
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
|
-
|
|
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
|
|
86
|
-
const
|
|
87
|
-
|
|
88
|
-
|
|
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:
|
|
93
|
-
this.
|
|
94
|
-
this.
|
|
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
|
-
|
|
150
|
+
defaultProcessAttributeChange(attribute, value) {
|
|
99
151
|
if (attribute === VALUE) {
|
|
100
152
|
this.updateValue();
|
|
101
153
|
}
|
|
@@ -106,22 +158,18 @@ 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
|
-
updateObject() { this.field?.setValue(this.value); }
|
|
166
|
+
updateObject(widgetUpdate = true) { this.field?.setValue(this.value, widgetUpdate); }
|
|
119
167
|
inputChanged() {
|
|
120
168
|
this.field?.setValue(this.value);
|
|
121
169
|
this.onChangeContent();
|
|
122
170
|
}
|
|
123
171
|
inputTyped() {
|
|
124
|
-
this.
|
|
172
|
+
this.updateObject(false);
|
|
125
173
|
this.onInputChange();
|
|
126
174
|
}
|
|
127
175
|
numberInputValidation(event) {
|
|
@@ -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:
|
|
133
|
-
FieldComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.6", type: FieldComponent, selector: "lib-field", inputs: { field: "field",
|
|
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.
|
|
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: {
|
|
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: {
|
|
227
|
+
}], propDecorators: { form: [{
|
|
211
228
|
type: Input
|
|
212
|
-
}],
|
|
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:
|
|
229
|
-
SectionComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.6", type: SectionComponent, selector: "lib-section", inputs: { section: "section",
|
|
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
|
-
}],
|
|
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:
|
|
249
|
-
SubSectionComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.6", type: SubSectionComponent, selector: "lib-subsection", inputs: { subSection: "subSection",
|
|
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
|
-
}],
|
|
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:
|
|
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
|
-
}],
|
|
350
|
+
}], propDecorators: { recordId: [{
|
|
293
351
|
type: Input
|
|
294
352
|
}], recordData: [{
|
|
295
353
|
type: Input
|
|
@@ -327,65 +385,64 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.6", ngImpor
|
|
|
327
385
|
type: Input
|
|
328
386
|
}] } });
|
|
329
387
|
|
|
330
|
-
|
|
331
|
-
class LibTableComponent {
|
|
388
|
+
class LibTableComponent extends ElementComponent {
|
|
332
389
|
constructor() {
|
|
333
|
-
|
|
334
|
-
this.globalSearch = false;
|
|
390
|
+
super(...arguments);
|
|
335
391
|
this.globalFilterString = '';
|
|
336
|
-
this.visibleRecords = [];
|
|
337
|
-
this.selectedRecords = [];
|
|
338
|
-
this.totalRecordsNumber = 0;
|
|
339
|
-
this.allSelected = false;
|
|
340
|
-
this.layout = '';
|
|
341
392
|
this.loaded = false;
|
|
342
393
|
this.selectable = false;
|
|
343
394
|
this.hasActions = false;
|
|
344
|
-
this.
|
|
395
|
+
this.table = null;
|
|
396
|
+
this.visibleRecords = [];
|
|
397
|
+
this.waiting = false;
|
|
345
398
|
}
|
|
346
399
|
ngOnInit() {
|
|
347
|
-
if (this.table) {
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
this.
|
|
365
|
-
const { name: tableAttr, value } = event;
|
|
366
|
-
const compAttr = this.formConfig.componentTableAttrMap[tableAttr];
|
|
367
|
-
this.syncAttribute(compAttr, value);
|
|
368
|
-
});
|
|
400
|
+
if (!this.table) {
|
|
401
|
+
return;
|
|
402
|
+
}
|
|
403
|
+
this.formConfig = this.table?._formConfig;
|
|
404
|
+
this.tableFieldStyles = this.formConfig?.tableFieldStyles;
|
|
405
|
+
this.selectable = this.table?.selectable;
|
|
406
|
+
this.hasActions = this.table?.hasActions();
|
|
407
|
+
this.inlineActions = this.table?.getActions(this.formConfig?.tableActions.inline);
|
|
408
|
+
this.globalActions = this.table?.getActions(this.formConfig?.tableActions.global);
|
|
409
|
+
this.selectionActions = this.table?.getActions(this.formConfig?.tableActions.selection);
|
|
410
|
+
// Inicialización de campos mapeados del objeto
|
|
411
|
+
const mapping = Object.entries(this.formConfig?.tablePropagationAttributes);
|
|
412
|
+
for (let index = 0; index < mapping.length; index++) {
|
|
413
|
+
const tableAttr = mapping[index]?.[0];
|
|
414
|
+
const componentAttr = mapping[index]?.[1]?.toString() ?? '';
|
|
415
|
+
const attributeValue = this.table?.[tableAttr];
|
|
416
|
+
this.defaultProcessAttributeChange(componentAttr, attributeValue);
|
|
417
|
+
this.customProcessAttributeChange(componentAttr, attributeValue);
|
|
369
418
|
}
|
|
419
|
+
// Subscripción a cambios en atributos
|
|
420
|
+
this.table?.attributeChange.subscribe(event => {
|
|
421
|
+
const { name: attrName, value } = event;
|
|
422
|
+
this.defaultProcessAttributeChange(attrName, value);
|
|
423
|
+
this.customProcessAttributeChange(attrName, value);
|
|
424
|
+
});
|
|
370
425
|
this.start();
|
|
371
426
|
}
|
|
372
|
-
start() { }
|
|
373
427
|
updateTableData() { }
|
|
374
|
-
tableGlobalAction(actionCode) { this.table
|
|
375
|
-
tableSelectionAction(actionCode) { this.table
|
|
376
|
-
tableActionSelected(actionEvent) { this.table
|
|
377
|
-
tableSelectionToggle(recordId) { this.table
|
|
378
|
-
toggleSelectAll() { return (this.allSelected) ? this.table
|
|
428
|
+
tableGlobalAction(actionCode) { this.table?.notifyGlobalAction(actionCode); }
|
|
429
|
+
tableSelectionAction(actionCode) { this.table?.notifySelectionAction(actionCode); }
|
|
430
|
+
tableActionSelected(actionEvent) { this.table?.notifyInlineAction(actionEvent); }
|
|
431
|
+
tableSelectionToggle(recordId) { this.table?.notifyRecordSelection(recordId); }
|
|
432
|
+
toggleSelectAll() { return (this.table?.allSelected) ? this.table?.unSelectAll() : this.table?.selectAll(); }
|
|
379
433
|
globalFilterCompleted() { this.changePage(1); }
|
|
380
|
-
changePage(requestedPage) { this.table
|
|
381
|
-
tableColumnSort(columnName, direction = null) { this.table
|
|
382
|
-
globalFilterChanged() { this.table
|
|
383
|
-
|
|
434
|
+
changePage(requestedPage) { this.table?.changePage(requestedPage); }
|
|
435
|
+
tableColumnSort(columnName, direction = null) { this.table?.sort(columnName, direction ?? 'ascend'); }
|
|
436
|
+
globalFilterChanged() { this.table?.setGlobalFilterString(this.globalFilterString?.trim() ?? '', false); }
|
|
437
|
+
defaultProcessAttributeChange(attribute, value) {
|
|
438
|
+
if (!attribute) {
|
|
439
|
+
return false;
|
|
440
|
+
}
|
|
384
441
|
try {
|
|
385
|
-
if (
|
|
442
|
+
if (attribute === 'visibleRecords') {
|
|
386
443
|
this.updateTableData();
|
|
387
444
|
}
|
|
388
|
-
this[
|
|
445
|
+
this[attribute] = value;
|
|
389
446
|
return true;
|
|
390
447
|
}
|
|
391
448
|
catch {
|
|
@@ -394,15 +451,15 @@ class LibTableComponent {
|
|
|
394
451
|
}
|
|
395
452
|
filterHasChanged(column, values) {
|
|
396
453
|
if (!values || values.length === 0) {
|
|
397
|
-
this.table
|
|
454
|
+
this.table?.removeColumnFilter(column.fieldCode);
|
|
398
455
|
}
|
|
399
456
|
else {
|
|
400
|
-
this.table
|
|
457
|
+
this.table?.addColumnFilter(column.fieldCode, values);
|
|
401
458
|
}
|
|
402
459
|
}
|
|
403
460
|
}
|
|
404
|
-
LibTableComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: LibTableComponent, deps:
|
|
405
|
-
LibTableComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.6", type: LibTableComponent, selector: "lib-table", inputs: { table: "table",
|
|
461
|
+
LibTableComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: LibTableComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
462
|
+
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
463
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: LibTableComponent, decorators: [{
|
|
407
464
|
type: Component,
|
|
408
465
|
args: [{
|
|
@@ -412,11 +469,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.6", ngImpor
|
|
|
412
469
|
}]
|
|
413
470
|
}], propDecorators: { table: [{
|
|
414
471
|
type: Input
|
|
415
|
-
}],
|
|
416
|
-
type: Input
|
|
417
|
-
}], disabled: [{
|
|
418
|
-
type: Input
|
|
419
|
-
}], state: [{
|
|
472
|
+
}], visibleRecords: [{
|
|
420
473
|
type: Input
|
|
421
474
|
}], waiting: [{
|
|
422
475
|
type: Input
|
|
@@ -448,22 +501,29 @@ const operators = {
|
|
|
448
501
|
IN: 'IN',
|
|
449
502
|
};
|
|
450
503
|
|
|
451
|
-
class
|
|
452
|
-
constructor(
|
|
453
|
-
this.
|
|
504
|
+
class FormPiece {
|
|
505
|
+
constructor(pieceDefinition, formConfig) {
|
|
506
|
+
this._formState = '';
|
|
507
|
+
this._absoluteVisible = true;
|
|
508
|
+
this._absoluteDisabled = false;
|
|
454
509
|
this.visibleStates = null;
|
|
455
510
|
this.enabledStates = null;
|
|
456
|
-
this.
|
|
511
|
+
this._visible = true;
|
|
512
|
+
this._disabled = false;
|
|
513
|
+
this.customAttributes = {};
|
|
457
514
|
this._formConfig = formConfig;
|
|
458
515
|
this._isForced = false;
|
|
459
|
-
this.setVisibleStates(elementDefinition.visibleStates);
|
|
460
|
-
this.setEnabledStates(elementDefinition.enabledStates);
|
|
461
516
|
this._visibleForced = false;
|
|
462
|
-
this.
|
|
463
|
-
this.
|
|
464
|
-
this.
|
|
517
|
+
this.setVisibleStates(pieceDefinition.visibleStates);
|
|
518
|
+
this.setEnabledStates(pieceDefinition.enabledStates);
|
|
519
|
+
this.enabled = !pieceDefinition?.disabled ?? false;
|
|
520
|
+
this.setVisibility(pieceDefinition?.visible ?? true);
|
|
521
|
+
this.customAttributes = pieceDefinition?.customAttributes ?? {};
|
|
522
|
+
if (pieceDefinition?.customAttributes) {
|
|
523
|
+
Object.keys(pieceDefinition?.customAttributes)
|
|
524
|
+
?.forEach(attr => this.customAttributes[attr] = pieceDefinition?.customAttributes[attr]);
|
|
525
|
+
}
|
|
465
526
|
}
|
|
466
|
-
;
|
|
467
527
|
getCustomAttribute(name) { return this.customAttributes?.[name] ?? null; }
|
|
468
528
|
setCustomAttribute(name, value) { if (name) {
|
|
469
529
|
this.customAttributes[name] = value;
|
|
@@ -474,9 +534,6 @@ class FormElement {
|
|
|
474
534
|
});
|
|
475
535
|
}
|
|
476
536
|
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; }
|
|
480
537
|
setVisibleStates(newStates) {
|
|
481
538
|
const visibleStates = (!Array.isArray(newStates) && typeof newStates === 'string')
|
|
482
539
|
? newStates.split(',').map(state => state.trim()).filter(state => state.length > 0)
|
|
@@ -491,47 +548,104 @@ class FormElement {
|
|
|
491
548
|
}
|
|
492
549
|
viewOnState(state) { return (this.visibleStates && state) ? this.visibleStates.includes(state) : false; }
|
|
493
550
|
enabledOnState(state) { return (this.enabledStates && state) ? this.enabledStates.includes(state) : false; }
|
|
494
|
-
|
|
495
|
-
|
|
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; }
|
|
551
|
+
get absoluteVisible() { return this._absoluteVisible; }
|
|
552
|
+
get absoluteDisabled() { return this._absoluteDisabled; }
|
|
553
|
+
get visible() { return this._visible; }
|
|
503
554
|
set visible(visible) { this.setVisibility(visible); }
|
|
504
555
|
visibleOn(state) {
|
|
505
|
-
return this.
|
|
556
|
+
return this._absoluteVisible && this.viewOnState(state);
|
|
506
557
|
}
|
|
507
558
|
enabledOn(state) {
|
|
508
|
-
return !this.
|
|
559
|
+
return !this._absoluteDisabled && this.enabledOnState(state);
|
|
509
560
|
}
|
|
510
561
|
setVisibility(visible, forced = null) {
|
|
511
|
-
this.
|
|
512
|
-
if (forced
|
|
562
|
+
this._absoluteVisible = !!visible;
|
|
563
|
+
if (forced !== null) {
|
|
513
564
|
this._isForced = forced;
|
|
565
|
+
this._visibleForced = visible;
|
|
514
566
|
}
|
|
567
|
+
this._visible = this._absoluteVisible && this.viewOnState(this._formState);
|
|
515
568
|
}
|
|
516
569
|
show(forced = null) {
|
|
517
|
-
this.
|
|
518
|
-
if (forced !== null) {
|
|
519
|
-
this._isForced = forced;
|
|
520
|
-
this._visibleForced = true;
|
|
521
|
-
}
|
|
570
|
+
this.setVisibility(true, forced);
|
|
522
571
|
}
|
|
523
572
|
hide(forced = null) {
|
|
524
|
-
this.
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
573
|
+
this.setVisibility(false, forced);
|
|
574
|
+
}
|
|
575
|
+
get enabled() { return !this._disabled; }
|
|
576
|
+
set enabled(enabled) {
|
|
577
|
+
this._absoluteDisabled = !enabled;
|
|
578
|
+
this._disabled = this._absoluteDisabled || !this.enabledOnState(this._formState);
|
|
579
|
+
}
|
|
580
|
+
get editable() { return !this._disabled; }
|
|
581
|
+
get disabled() { return this._disabled; }
|
|
582
|
+
set disabled(disabled) { this.enabled = !disabled; }
|
|
583
|
+
enable() { this.enabled = true; }
|
|
584
|
+
disable() { this.enabled = false; }
|
|
585
|
+
formStateChangeCustomSubscribe(formChangeSubject) { }
|
|
586
|
+
formStateChange(state) {
|
|
587
|
+
if (state) {
|
|
588
|
+
this._formState = state;
|
|
589
|
+
this._visible = this._absoluteVisible && this.viewOnState(state);
|
|
590
|
+
this._disabled = this._absoluteDisabled || !this.enabledOnState(state);
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
subscribeFormStateChange(formChangeSubject) {
|
|
594
|
+
this.formStateChangeCustomSubscribe(formChangeSubject);
|
|
595
|
+
formChangeSubject.subscribe(event => this.formStateChange(event?.state));
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
const VISIBLE = 'visible';
|
|
600
|
+
const DISABLED = 'disabled';
|
|
601
|
+
class FormPiecePropagate extends FormPiece {
|
|
602
|
+
constructor(pieceDefinition, formConfig) {
|
|
603
|
+
super(pieceDefinition, formConfig);
|
|
604
|
+
this._attributeChange = new BehaviorSubject(null);
|
|
605
|
+
}
|
|
606
|
+
get attributeChange() { return this._attributeChange; }
|
|
607
|
+
propagateAttribute(name, value) {
|
|
608
|
+
this._attributeChange?.next({ name, value });
|
|
609
|
+
}
|
|
610
|
+
setVisibility(visible, forced = null) {
|
|
611
|
+
super.setVisibility(visible, forced);
|
|
612
|
+
this.propagateAttribute(VISIBLE, this._visible);
|
|
613
|
+
}
|
|
614
|
+
set enabled(enabled) {
|
|
615
|
+
super.enabled = enabled;
|
|
616
|
+
this.propagateAttribute(DISABLED, this._disabled);
|
|
617
|
+
}
|
|
618
|
+
formStateChange(state) {
|
|
619
|
+
super.formStateChange(state);
|
|
620
|
+
if (state) {
|
|
621
|
+
this.propagateAttribute(VISIBLE, this._visible);
|
|
622
|
+
this.propagateAttribute(DISABLED, this._disabled);
|
|
528
623
|
}
|
|
529
624
|
}
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
class FormElement extends FormPiecePropagate {
|
|
628
|
+
constructor(elementDefinition, formConfig) {
|
|
629
|
+
super(elementDefinition, formConfig);
|
|
630
|
+
this.elementType = null;
|
|
631
|
+
}
|
|
632
|
+
;
|
|
633
|
+
setAttr(attr, value) {
|
|
634
|
+
const { name: attrName, propagate: name } = attr;
|
|
635
|
+
this[attrName] = value;
|
|
636
|
+
name && this.propagateAttribute(name, value);
|
|
637
|
+
}
|
|
638
|
+
isField() { return this.elementType === elementTypes.field; }
|
|
639
|
+
isAction() { return this.elementType === elementTypes.action; }
|
|
640
|
+
isTable() { return this.elementType === elementTypes.table; }
|
|
641
|
+
/**
|
|
642
|
+
* @deprecated Utilizar viewOnState
|
|
643
|
+
*/
|
|
644
|
+
supportState(state) { return this.viewOnState(state); }
|
|
645
|
+
/**
|
|
646
|
+
* @deprecated Utilizar viewOnState
|
|
647
|
+
*/
|
|
648
|
+
supportMode(state) { return this.viewOnState(state); }
|
|
535
649
|
}
|
|
536
650
|
|
|
537
651
|
const HEADER = 'HEADER';
|
|
@@ -578,7 +692,7 @@ const directChanges = [
|
|
|
578
692
|
'maxLength', 'maxValue', 'minLength', 'minValue', 'validateOnServer', 'serverAction', 'visibleLabel',
|
|
579
693
|
'options',
|
|
580
694
|
];
|
|
581
|
-
const attrs = {
|
|
695
|
+
const attrs$1 = {
|
|
582
696
|
_captureType: { name: '_captureType', propagate: 'captureType' },
|
|
583
697
|
_errorCode: { name: '_errorCode', propagate: 'errorCode' },
|
|
584
698
|
_errorMessage: { name: '_errorMessage', propagate: 'errorMessage' },
|
|
@@ -613,7 +727,6 @@ class FieldDescriptor extends FormElement {
|
|
|
613
727
|
this._editionFinish = new Subject();
|
|
614
728
|
this._editionPartial = new Subject();
|
|
615
729
|
this._detailRequest = new Subject();
|
|
616
|
-
this._attributeChange = new Subject();
|
|
617
730
|
this._errorType = '';
|
|
618
731
|
this._errorCode = '';
|
|
619
732
|
this._errorMessage = '';
|
|
@@ -640,7 +753,7 @@ class FieldDescriptor extends FormElement {
|
|
|
640
753
|
this._tooltipText = '';
|
|
641
754
|
this.elementType = elementTypes.field;
|
|
642
755
|
const fld = (inputFieldReceived) ? inputFieldReceived : {};
|
|
643
|
-
this.setAttr(attrs._fieldCode, fld.fieldCode);
|
|
756
|
+
this.setAttr(attrs$1._fieldCode, fld.fieldCode);
|
|
644
757
|
this.title = fld.fieldTitle ?? this._fieldCode;
|
|
645
758
|
this.type = fld.fieldTypeCode;
|
|
646
759
|
this.captureType = fld.captureType ?? DEFAULT_CAPTURE_TYPE;
|
|
@@ -669,7 +782,7 @@ class FieldDescriptor extends FormElement {
|
|
|
669
782
|
this.defaultEditable = this.enabled;
|
|
670
783
|
this.required = fld.required ?? false;
|
|
671
784
|
this.outputOnly = fld.outputOnly ?? false;
|
|
672
|
-
this.maxLength = fld.maxLength
|
|
785
|
+
this.maxLength = fld.maxLength || (this._captureType === 'TEXTAREA' ? BIG_MAX_LENGTH : STD_MAX_LENGTH);
|
|
673
786
|
this.intrinsicErrorMessage = this._formConfig?.fieldValidations?.[this._fieldType]?.message
|
|
674
787
|
?? this._formConfig?.fieldValidations?.DEFAULT?.message ?? '';
|
|
675
788
|
this.setError(fld.errorCode, fld.errorMessage, fld.errorType ?? DEFAULT_ERROR_TYPE);
|
|
@@ -680,17 +793,16 @@ class FieldDescriptor extends FormElement {
|
|
|
680
793
|
this._setValue(fld.fieldValue ?? this._defaultValue ?? '');
|
|
681
794
|
}
|
|
682
795
|
get alignment() { return this._fieldAlignment; }
|
|
683
|
-
set alignment(alignment) { this.setAttr(attrs._fieldAlignment, alignment); }
|
|
684
|
-
get attributeChange() { return this._attributeChange; }
|
|
796
|
+
set alignment(alignment) { this.setAttr(attrs$1._fieldAlignment, alignment); }
|
|
685
797
|
get backend() { return this._validateOnServer; }
|
|
686
798
|
get captureType() { return this._captureType; }
|
|
687
|
-
set captureType(captureType) { this.setAttr(attrs._captureType, captureType); }
|
|
799
|
+
set captureType(captureType) { this.setAttr(attrs$1._captureType, captureType); }
|
|
688
800
|
get code() { return this._fieldCode; }
|
|
689
801
|
get fieldCode() { return this._fieldCode; }
|
|
690
802
|
get defaultValue() { return this._defaultValue; }
|
|
691
|
-
set defaultValue(defaultValue) { this.setAttr(attrs._defaultValue, defaultValue); }
|
|
803
|
+
set defaultValue(defaultValue) { this.setAttr(attrs$1._defaultValue, defaultValue); }
|
|
692
804
|
get defaultEditable() { return this._defaultEditable; }
|
|
693
|
-
set defaultEditable(editable) { this.setAttr(attrs._defaultEditable, editable); }
|
|
805
|
+
set defaultEditable(editable) { this.setAttr(attrs$1._defaultEditable, editable); }
|
|
694
806
|
get detailRequest() { return this._detailRequest; }
|
|
695
807
|
get editionFinish() { return this._editionFinish; }
|
|
696
808
|
get editionPartial() { return this._editionPartial; }
|
|
@@ -725,31 +837,31 @@ class FieldDescriptor extends FormElement {
|
|
|
725
837
|
get errorType() { return this._errorType; }
|
|
726
838
|
get externalValue() { return this._externalValue; }
|
|
727
839
|
get format() { return this._fieldFormat; }
|
|
728
|
-
set format(format) { this.setAttr(attrs._fieldFormat, format); }
|
|
840
|
+
set format(format) { this.setAttr(attrs$1._fieldFormat, format); }
|
|
729
841
|
get hasChanged() { return this._hasChanged; }
|
|
730
|
-
set hasChanged(hasChanged) { this.setAttr(attrs._hasChanged, hasChanged); }
|
|
842
|
+
set hasChanged(hasChanged) { this.setAttr(attrs$1._hasChanged, hasChanged); }
|
|
731
843
|
get info() { return this._fieldInfo; }
|
|
732
|
-
set info(newInfo) { this.setAttr(attrs._fieldInfo, newInfo); }
|
|
733
|
-
set intrinsicErrorMessage(message) { this.setAttr(attrs._intrinsicErrorMessage, message); }
|
|
844
|
+
set info(newInfo) { this.setAttr(attrs$1._fieldInfo, newInfo); }
|
|
845
|
+
set intrinsicErrorMessage(message) { this.setAttr(attrs$1._intrinsicErrorMessage, message); }
|
|
734
846
|
get maxLength() { return (this._maxLength > 0) ? this._maxLength.toString() : ''; }
|
|
735
|
-
set maxLength(requiredMaxLength) { this.setAttr(attrs._maxLength, +requiredMaxLength); }
|
|
847
|
+
set maxLength(requiredMaxLength) { this.setAttr(attrs$1._maxLength, requiredMaxLength ? +requiredMaxLength : null); }
|
|
736
848
|
get maxValue() { return this._maxValue; }
|
|
737
849
|
set maxValue(inputMaxValue) {
|
|
738
850
|
let maxValue = inputMaxValue;
|
|
739
851
|
if (this._fieldType === this._formConfig.fieldTypes.date) {
|
|
740
852
|
maxValue = new Date(maxValue);
|
|
741
853
|
}
|
|
742
|
-
this.setAttr(attrs._maxValue, maxValue);
|
|
854
|
+
this.setAttr(attrs$1._maxValue, maxValue);
|
|
743
855
|
}
|
|
744
856
|
get minLength() { return this._minLength; }
|
|
745
|
-
set minLength(requiredMinLength) { this.setAttr(attrs._minLength, +requiredMinLength); }
|
|
857
|
+
set minLength(requiredMinLength) { this.setAttr(attrs$1._minLength, requiredMinLength ? +requiredMinLength : null); }
|
|
746
858
|
get minValue() { return this._minValue; }
|
|
747
859
|
set minValue(inputMinValue) {
|
|
748
860
|
let minValue = inputMinValue;
|
|
749
861
|
if (this._fieldType === this._formConfig.fieldTypes.date) {
|
|
750
862
|
minValue = new Date(minValue);
|
|
751
863
|
}
|
|
752
|
-
this.setAttr(attrs._minValue, minValue);
|
|
864
|
+
this.setAttr(attrs$1._minValue, minValue);
|
|
753
865
|
}
|
|
754
866
|
get name() { return this._fieldCode; }
|
|
755
867
|
get options() {
|
|
@@ -773,11 +885,11 @@ class FieldDescriptor extends FormElement {
|
|
|
773
885
|
});
|
|
774
886
|
fieldOptions = (fieldOptions && Array.isArray(fieldOptions)
|
|
775
887
|
&& fieldOptions.length > 0) ? fieldOptions : [];
|
|
776
|
-
this.setAttr(attrs._fieldOptions, fieldOptions);
|
|
888
|
+
this.setAttr(attrs$1._fieldOptions, fieldOptions);
|
|
777
889
|
if (this._value) {
|
|
778
890
|
if (this._fieldType === this._formConfig.fieldTypes.array && Array.isArray(this._value)) {
|
|
779
891
|
const fieldValue = this._value?.filter(item => this._fieldOptions?.find(opt => opt.fieldOptionId === item));
|
|
780
|
-
this.setAttr(attrs._value, fieldValue);
|
|
892
|
+
this.setAttr(attrs$1._value, fieldValue);
|
|
781
893
|
}
|
|
782
894
|
else {
|
|
783
895
|
const valInOptions = this._fieldOptions?.find(item => item.fieldOptionId === this._value);
|
|
@@ -786,35 +898,35 @@ class FieldDescriptor extends FormElement {
|
|
|
786
898
|
}
|
|
787
899
|
}
|
|
788
900
|
}
|
|
789
|
-
if (this._fieldRequired && this._fieldOptions?.length === 1) {
|
|
901
|
+
if (this._fieldRequired && this._fieldOptions?.length === 1 && this._value !== this._fieldOptions?.[0].fieldOptionId) {
|
|
790
902
|
this._setValue(this._fieldOptions?.[0].fieldOptionId);
|
|
791
903
|
this.notifyEditionFinish();
|
|
792
904
|
}
|
|
793
905
|
}
|
|
794
906
|
get optionText() { return this._fieldOptions?.find(item => item.fieldOptionId === this._value)?.fieldOptionValue ?? null; }
|
|
795
907
|
get outputOnly() { return this._outputOnly; }
|
|
796
|
-
set outputOnly(outputOnly) { this.setAttr(attrs._outputOnly, outputOnly); }
|
|
908
|
+
set outputOnly(outputOnly) { this.setAttr(attrs$1._outputOnly, outputOnly); }
|
|
797
909
|
get required() { return this._fieldRequired; }
|
|
798
|
-
set required(required) { this.setAttr(attrs._fieldRequired, required ?? false); }
|
|
910
|
+
set required(required) { this.setAttr(attrs$1._fieldRequired, required ?? false); }
|
|
799
911
|
get title() { return this._fieldTitle; }
|
|
800
|
-
set title(title) { this.setAttr(attrs._fieldTitle, title?.toString() ?? ''); }
|
|
912
|
+
set title(title) { this.setAttr(attrs$1._fieldTitle, title?.toString() ?? ''); }
|
|
801
913
|
get tooltip() { return this._tooltipText; }
|
|
802
|
-
set tooltip(tooltip) { this.setAttr(attrs._tooltipText, tooltip); }
|
|
914
|
+
set tooltip(tooltip) { this.setAttr(attrs$1._tooltipText, tooltip); }
|
|
803
915
|
get type() { return this._fieldType; }
|
|
804
|
-
set type(fieldType) { this.setAttr(attrs._fieldType, fieldType); }
|
|
916
|
+
set type(fieldType) { this.setAttr(attrs$1._fieldType, fieldType); }
|
|
805
917
|
get validating() { return this._onValidation; }
|
|
806
|
-
set validating(isValidating) { this.setAttr(attrs._onValidation, isValidating); }
|
|
918
|
+
set validating(isValidating) { this.setAttr(attrs$1._onValidation, isValidating); }
|
|
807
919
|
get value() {
|
|
808
920
|
return (this._fieldType === this._formConfig.fieldTypes.boolean
|
|
809
921
|
|| this._fieldType === this._formConfig.fieldTypes.check) ? yn(this._value) : this._value;
|
|
810
922
|
}
|
|
811
923
|
get validateOnServer() { return this._validateOnServer; }
|
|
812
|
-
set validateOnServer(validateOnServer) { this.setAttr(attrs._validateOnServer, validateOnServer); }
|
|
924
|
+
set validateOnServer(validateOnServer) { this.setAttr(attrs$1._validateOnServer, validateOnServer); }
|
|
813
925
|
get serverAction() { return this._validateOnServer; }
|
|
814
926
|
set serverAction(validateOnServer) { this.validateOnServer = validateOnServer; }
|
|
815
927
|
set value(newValue) { this._setValue(newValue); }
|
|
816
928
|
get visibleLabel() { return this._visibleLabel; }
|
|
817
|
-
set visibleLabel(visibleLabel) { this.setAttr(attrs._visibleLabel, visibleLabel); }
|
|
929
|
+
set visibleLabel(visibleLabel) { this.setAttr(attrs$1._visibleLabel, visibleLabel); }
|
|
818
930
|
/**
|
|
819
931
|
* @deprecated Use options
|
|
820
932
|
*/
|
|
@@ -832,7 +944,7 @@ class FieldDescriptor extends FormElement {
|
|
|
832
944
|
*/
|
|
833
945
|
changed(hasChanged = true) { this.hasChanged = hasChanged; }
|
|
834
946
|
clean() { this._setValue(this._defaultValue || ''); this.resetError(); }
|
|
835
|
-
focus() { this.setAttr(attrs._focus, true); }
|
|
947
|
+
focus() { this.setAttr(attrs$1._focus, true); }
|
|
836
948
|
getErrorCode() { return this.error.code; }
|
|
837
949
|
setErrorCode(code) { this.setError(code, this._errorMessage); }
|
|
838
950
|
getErrorMessage() { return this.error.message; }
|
|
@@ -940,15 +1052,10 @@ class FieldDescriptor extends FormElement {
|
|
|
940
1052
|
const detailEvent = { code: this._fieldCode, detail };
|
|
941
1053
|
this._detailRequest.next(detailEvent);
|
|
942
1054
|
}
|
|
943
|
-
setAttr(attr, value) {
|
|
944
|
-
const { name: attrName, propagate: name } = attr;
|
|
945
|
-
this[attrName] = value;
|
|
946
|
-
name && this._attributeChange.next({ name, value });
|
|
947
|
-
}
|
|
948
1055
|
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 ?? '');
|
|
1056
|
+
this.setAttr(attrs$1._errorCode, code ?? NO_ERROR);
|
|
1057
|
+
this.setAttr(attrs$1._errorType, (this._errorCode === NO_ERROR) ? '' : type);
|
|
1058
|
+
this.setAttr(attrs$1._errorMessage, message ?? '');
|
|
952
1059
|
}
|
|
953
1060
|
updateFromServer(fld) {
|
|
954
1061
|
const fieldKeys = Object.keys(fld);
|
|
@@ -1003,7 +1110,7 @@ class FieldDescriptor extends FormElement {
|
|
|
1003
1110
|
if (this._value !== newFinalValue) {
|
|
1004
1111
|
this.hasChanged = true;
|
|
1005
1112
|
if (widgetUpdate) {
|
|
1006
|
-
this.setAttr(attrs._value, newFinalValue);
|
|
1113
|
+
this.setAttr(attrs$1._value, newFinalValue);
|
|
1007
1114
|
}
|
|
1008
1115
|
else {
|
|
1009
1116
|
this._value = newFinalValue;
|
|
@@ -1013,22 +1120,21 @@ class FieldDescriptor extends FormElement {
|
|
|
1013
1120
|
}
|
|
1014
1121
|
}
|
|
1015
1122
|
|
|
1016
|
-
class RecordTableColumn {
|
|
1123
|
+
class RecordTableColumn extends FormPiece {
|
|
1017
1124
|
constructor(recTableColReceived, formConfig) {
|
|
1125
|
+
super(recTableColReceived, formConfig);
|
|
1018
1126
|
this.fieldCode = '';
|
|
1019
1127
|
this.fieldTitle = '';
|
|
1020
1128
|
this.fieldType = '';
|
|
1021
1129
|
this.fieldAlignment = '';
|
|
1022
1130
|
this.fieldFormat = '';
|
|
1023
|
-
this.visible = true;
|
|
1024
1131
|
this.sortable = true;
|
|
1132
|
+
this.searchable = true;
|
|
1025
1133
|
this.sortDirections = [];
|
|
1026
|
-
this.customAttributes = {};
|
|
1027
1134
|
// Filtros
|
|
1028
1135
|
this.filterVisible = false;
|
|
1029
1136
|
this.filterDef = null;
|
|
1030
1137
|
this.filterSetup = null;
|
|
1031
|
-
this._formConfig = formConfig;
|
|
1032
1138
|
this.filterDef = null;
|
|
1033
1139
|
if (recTableColReceived) {
|
|
1034
1140
|
this.fieldCode = recTableColReceived.fieldCode;
|
|
@@ -1036,22 +1142,15 @@ class RecordTableColumn {
|
|
|
1036
1142
|
this.fieldType = recTableColReceived.fieldTypeCode || this._formConfig.fieldTypes.text;
|
|
1037
1143
|
const defaultTypeAlignment = (this._formConfig.tableFieldStyles[this.fieldType] != null) ? this._formConfig.tableFieldStyles[this.fieldType]['text-align'] : 'left';
|
|
1038
1144
|
this.fieldAlignment = (recTableColReceived.alignment != null) ? recTableColReceived.alignment.toLowerCase() : defaultTypeAlignment;
|
|
1039
|
-
this.
|
|
1145
|
+
this._absoluteVisible = recTableColReceived?.visible ?? true;
|
|
1040
1146
|
this.sortable = recTableColReceived?.sortable ?? false;
|
|
1147
|
+
this.searchable = recTableColReceived?.searchable ?? true;
|
|
1041
1148
|
this.sortDirections = (this.sortable) ? ['ascend', 'descend'] : [];
|
|
1042
1149
|
this.fieldFormat = recTableColReceived.format || '';
|
|
1043
1150
|
this.customAttributes = recTableColReceived?.customAttributes ?? {};
|
|
1044
1151
|
}
|
|
1045
1152
|
}
|
|
1046
|
-
|
|
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
|
-
}
|
|
1153
|
+
setSearchable(searchable = true) { this.searchable = searchable; }
|
|
1055
1154
|
hideFilter() {
|
|
1056
1155
|
this.filterVisible = false;
|
|
1057
1156
|
}
|
|
@@ -1094,8 +1193,9 @@ class RecordTableColumn {
|
|
|
1094
1193
|
}
|
|
1095
1194
|
}
|
|
1096
1195
|
|
|
1097
|
-
class TableAction {
|
|
1098
|
-
constructor(actionDefinition) {
|
|
1196
|
+
class TableAction extends FormPiece {
|
|
1197
|
+
constructor(actionDefinition, formConfig) {
|
|
1198
|
+
super(actionDefinition, formConfig);
|
|
1099
1199
|
this.actionCode = actionDefinition.actionCode;
|
|
1100
1200
|
this.actionTitle = actionDefinition.actionTitle;
|
|
1101
1201
|
this.iconName = actionDefinition.iconName || this.actionCode;
|
|
@@ -1103,35 +1203,20 @@ class TableAction {
|
|
|
1103
1203
|
this.actionClass = actionDefinition.actionClass || 'INLINE';
|
|
1104
1204
|
this.newState = actionDefinition.newState;
|
|
1105
1205
|
this.stateField = actionDefinition.stateField || '';
|
|
1106
|
-
this.visibleStates = actionDefinition.visibleStates || [];
|
|
1107
|
-
this.enabledStates = actionDefinition.enabledStates || [];
|
|
1108
1206
|
this.backend = actionDefinition?.serverAction ?? false;
|
|
1109
1207
|
this.restrictedOnField = actionDefinition.fieldRestrictedCode || '';
|
|
1110
1208
|
this.restrictedOnValue = actionDefinition.valueRestricted ?? '';
|
|
1111
1209
|
this.restrictedOnOperator = actionDefinition.operatorRestricted || '';
|
|
1112
|
-
this.customAttributes = actionDefinition?.customAttributes ?? {};
|
|
1113
1210
|
}
|
|
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
|
-
}
|
|
1123
|
-
supportMode(state) { return this.viewOnState(state); }
|
|
1124
|
-
viewOnState(state) { return this.visibleStates.includes(state); }
|
|
1125
|
-
enabledOnState(state) { return this.enabledStates.includes(state); }
|
|
1126
1211
|
}
|
|
1127
1212
|
|
|
1128
1213
|
class TableRecordData {
|
|
1129
1214
|
constructor(recordReceived, recordDefinition, selectionFieldName = null) {
|
|
1215
|
+
this.recordId = null;
|
|
1216
|
+
this.selected = false;
|
|
1130
1217
|
this.recordData = {};
|
|
1131
1218
|
const { tableRecordId, recordData } = recordReceived;
|
|
1132
1219
|
this.recordId = tableRecordId;
|
|
1133
|
-
this.selected = false;
|
|
1134
|
-
this.recordData = {};
|
|
1135
1220
|
if (!recordDefinition || recordDefinition.length === 0 || !recordData || recordData.length === 0) {
|
|
1136
1221
|
return;
|
|
1137
1222
|
}
|
|
@@ -1170,10 +1255,11 @@ class TableRecordData {
|
|
|
1170
1255
|
if (!words || words.length === 0) {
|
|
1171
1256
|
return true;
|
|
1172
1257
|
}
|
|
1173
|
-
for (const
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1258
|
+
for (const word of words) {
|
|
1259
|
+
let wordIsPresent = false;
|
|
1260
|
+
for (const fieldCode in this.recordData) {
|
|
1261
|
+
const columnDef = columnObj?.[fieldCode];
|
|
1262
|
+
if (columnDef?.searchable && this.recordData.hasOwnProperty(fieldCode)) {
|
|
1177
1263
|
const term = word.toUpperCase();
|
|
1178
1264
|
let fieldValue;
|
|
1179
1265
|
if (columnDef.fieldType.toUpperCase().includes('DATE')) {
|
|
@@ -1183,12 +1269,16 @@ class TableRecordData {
|
|
|
1183
1269
|
fieldValue = this.recordData[fieldCode];
|
|
1184
1270
|
}
|
|
1185
1271
|
if (fieldValue.toString().toUpperCase().includes(term)) {
|
|
1186
|
-
|
|
1272
|
+
wordIsPresent = true;
|
|
1273
|
+
break;
|
|
1187
1274
|
}
|
|
1188
1275
|
}
|
|
1189
1276
|
}
|
|
1277
|
+
if (!wordIsPresent) {
|
|
1278
|
+
return false;
|
|
1279
|
+
}
|
|
1190
1280
|
}
|
|
1191
|
-
return
|
|
1281
|
+
return true;
|
|
1192
1282
|
}
|
|
1193
1283
|
hasCondition(columnFilters) {
|
|
1194
1284
|
if (!columnFilters || columnFilters.length === 0) {
|
|
@@ -1237,6 +1327,21 @@ class TableRecordData {
|
|
|
1237
1327
|
|
|
1238
1328
|
const TABLE_SORT_ASCENDING = 'asc';
|
|
1239
1329
|
const TABLE_SORT_DESCENDING = 'desc';
|
|
1330
|
+
const attrs = {
|
|
1331
|
+
allSelected: { name: 'allSelected', propagate: 'allSelected' },
|
|
1332
|
+
tableCode: { name: 'tableCode', propagate: 'code' },
|
|
1333
|
+
clientPaging: { name: 'clientPaging', propagate: null },
|
|
1334
|
+
globalSearch: { name: 'globalSearch', propagate: 'globalSearch' },
|
|
1335
|
+
globalFilterString: { name: 'globalFilterString', propagate: 'globalFilterString' },
|
|
1336
|
+
sorting: { name: 'sorting', propagate: null },
|
|
1337
|
+
recordsPerPage: { name: 'recordsPerPage', propagate: 'recordsPerPage' },
|
|
1338
|
+
layout: { name: 'layout', propagate: 'layout' },
|
|
1339
|
+
columns: { name: 'columns', propagate: 'columns' },
|
|
1340
|
+
selectedRecords: { name: 'selectedRecords', propagate: 'selectedRecords' },
|
|
1341
|
+
currentPage: { name: 'currentPage', propagate: 'currentPage' },
|
|
1342
|
+
totalRecordsNumber: { name: 'totalRecordsNumber', propagate: 'totalRecordsNumber' },
|
|
1343
|
+
visibleRecords: { name: 'visibleRecords', propagate: 'visibleRecords' },
|
|
1344
|
+
};
|
|
1240
1345
|
class RecordTable extends FormElement {
|
|
1241
1346
|
constructor(tableReceived, formConfig) {
|
|
1242
1347
|
super(tableReceived, formConfig);
|
|
@@ -1245,10 +1350,10 @@ class RecordTable extends FormElement {
|
|
|
1245
1350
|
this._recordSelectionTrigger = new Subject();
|
|
1246
1351
|
this._selectionActionTrigger = new Subject();
|
|
1247
1352
|
this._getDataTrigger = new Subject();
|
|
1248
|
-
this._attributeChange = new Subject();
|
|
1249
1353
|
this._tableColumnObj = {};
|
|
1250
1354
|
this._actionsObj = {};
|
|
1251
1355
|
// Mecanismos de filtrado nueva versión
|
|
1356
|
+
this.globalFilterString = '';
|
|
1252
1357
|
this.globalFilterStrings = [];
|
|
1253
1358
|
this.layout = null;
|
|
1254
1359
|
this.tableRecordObj = {};
|
|
@@ -1276,22 +1381,27 @@ class RecordTable extends FormElement {
|
|
|
1276
1381
|
this.selectable = tableReceived?.selectable ?? false;
|
|
1277
1382
|
this.selectionBackend = tableReceived?.selectionBackend ?? false;
|
|
1278
1383
|
this.sortable = tableReceived?.sortable ?? false;
|
|
1279
|
-
this.setAttr(
|
|
1280
|
-
this.setAttr(
|
|
1281
|
-
this.setAttr(
|
|
1282
|
-
this.setAttr(
|
|
1283
|
-
this.setAttr(
|
|
1284
|
-
this.setAttr(
|
|
1285
|
-
this.setAttr(
|
|
1286
|
-
this.setAttr(
|
|
1384
|
+
this.setAttr(attrs.allSelected, false);
|
|
1385
|
+
this.setAttr(attrs.tableCode, tableReceived.tableCode);
|
|
1386
|
+
this.setAttr(attrs.clientPaging, tableReceived?.clientPaging ?? true);
|
|
1387
|
+
this.setAttr(attrs.globalSearch, tableReceived?.simpleFilter ?? false);
|
|
1388
|
+
this.setAttr(attrs.globalFilterString, '');
|
|
1389
|
+
this.setAttr(attrs.sorting, { columnName: '', direction: '' });
|
|
1390
|
+
this.setAttr(attrs.recordsPerPage, formConfig.defaultRecordsPerPage);
|
|
1391
|
+
this.setAttr(attrs.layout, '');
|
|
1287
1392
|
if (tableReceived.fields) {
|
|
1288
1393
|
const columns = [];
|
|
1289
1394
|
for (const columnReceived of tableReceived.fields) {
|
|
1290
|
-
const
|
|
1395
|
+
const columnEnriched = {
|
|
1396
|
+
...columnReceived,
|
|
1397
|
+
visibleStates: this.visibleStates,
|
|
1398
|
+
enabledStates: this.enabledStates
|
|
1399
|
+
};
|
|
1400
|
+
const columnDefinition = new RecordTableColumn(columnEnriched, this._formConfig);
|
|
1291
1401
|
columns.push(columnDefinition);
|
|
1292
1402
|
this._tableColumnObj[columnDefinition.fieldCode] = columnDefinition;
|
|
1293
1403
|
}
|
|
1294
|
-
this.setAttr(
|
|
1404
|
+
this.setAttr(attrs.columns, columns);
|
|
1295
1405
|
}
|
|
1296
1406
|
if (tableReceived.actions) {
|
|
1297
1407
|
const tableActions = tableReceived.actions.map(objDef => {
|
|
@@ -1308,7 +1418,7 @@ class RecordTable extends FormElement {
|
|
|
1308
1418
|
return { ...objDef, visibleStates, enabledStates };
|
|
1309
1419
|
});
|
|
1310
1420
|
for (const actionReceived of tableActions) {
|
|
1311
|
-
const inlineAction = new TableAction(actionReceived);
|
|
1421
|
+
const inlineAction = new TableAction(actionReceived, this._formConfig);
|
|
1312
1422
|
this._actions.push(inlineAction);
|
|
1313
1423
|
this._actionsObj[inlineAction.actionCode] = inlineAction;
|
|
1314
1424
|
}
|
|
@@ -1327,9 +1437,8 @@ class RecordTable extends FormElement {
|
|
|
1327
1437
|
get selectionActionTrigger() { return this._selectionActionTrigger; }
|
|
1328
1438
|
get recordSelectionTrigger() { return this._recordSelectionTrigger; }
|
|
1329
1439
|
get getDataTrigger() { return this._getDataTrigger; }
|
|
1330
|
-
get attributeChange() { return this._attributeChange; }
|
|
1331
1440
|
getLayout() { return this.layout; }
|
|
1332
|
-
setLayout(layout) { this.setAttr(
|
|
1441
|
+
setLayout(layout) { this.setAttr(attrs.layout, layout); }
|
|
1333
1442
|
hasActions() { return (this._actions.length > 0); }
|
|
1334
1443
|
getSelectedRecords() { return this.tableRecords.filter(rec => rec.selected).map(rec => rec.recordId); }
|
|
1335
1444
|
activateGlobalSearch() { this.globalSearch = true; }
|
|
@@ -1337,12 +1446,6 @@ class RecordTable extends FormElement {
|
|
|
1337
1446
|
columnDefinition(fieldCode) { return this._tableColumnObj[fieldCode]; }
|
|
1338
1447
|
putOnWait() { this.waiting = true; }
|
|
1339
1448
|
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
1449
|
notifyGlobalAction(actionCode) {
|
|
1347
1450
|
const tableEvent = {
|
|
1348
1451
|
tableCode: this.tableCode,
|
|
@@ -1407,23 +1510,23 @@ class RecordTable extends FormElement {
|
|
|
1407
1510
|
this.updateVisibleRecords();
|
|
1408
1511
|
}
|
|
1409
1512
|
selectAll() {
|
|
1410
|
-
this.setAttr(
|
|
1513
|
+
this.setAttr(attrs.allSelected, true);
|
|
1411
1514
|
this.tableRecords.forEach(record => record.select());
|
|
1412
|
-
this.setAttr(
|
|
1515
|
+
this.setAttr(attrs.selectedRecords, this.getSelectedRecords());
|
|
1413
1516
|
return true;
|
|
1414
1517
|
}
|
|
1415
1518
|
unSelectAll() {
|
|
1416
|
-
this.setAttr(
|
|
1519
|
+
this.setAttr(attrs.allSelected, false);
|
|
1417
1520
|
this.tableRecords.forEach(record => record.unselect());
|
|
1418
|
-
this.setAttr(
|
|
1521
|
+
this.setAttr(attrs.selectedRecords, this.getSelectedRecords());
|
|
1419
1522
|
return true;
|
|
1420
1523
|
}
|
|
1421
1524
|
setTableRecords(tableRecords, append) {
|
|
1422
1525
|
if (!append) {
|
|
1423
1526
|
this.tableRecords = [];
|
|
1424
|
-
this.setAttr(
|
|
1527
|
+
this.setAttr(attrs.allSelected, false);
|
|
1425
1528
|
this.tableRecords.forEach(record => record.unselect());
|
|
1426
|
-
this.setAttr(
|
|
1529
|
+
this.setAttr(attrs.selectedRecords, []);
|
|
1427
1530
|
this.tableRecordObj = {};
|
|
1428
1531
|
}
|
|
1429
1532
|
const newRecordsObj = { ...this.tableRecordObj };
|
|
@@ -1435,7 +1538,7 @@ class RecordTable extends FormElement {
|
|
|
1435
1538
|
newRecordsObj[recordIdKey] = recordReceived;
|
|
1436
1539
|
}
|
|
1437
1540
|
this.tableRecords = newRecords;
|
|
1438
|
-
this.setAttr(
|
|
1541
|
+
this.setAttr(attrs.selectedRecords, this.getSelectedRecords());
|
|
1439
1542
|
this.tableRecordObj = newRecordsObj;
|
|
1440
1543
|
this.updateVisibleRecords();
|
|
1441
1544
|
}
|
|
@@ -1444,7 +1547,7 @@ class RecordTable extends FormElement {
|
|
|
1444
1547
|
setTableAppend(append) { this._appendPages = append; }
|
|
1445
1548
|
changePage(requestedPage) {
|
|
1446
1549
|
if (this.clientPaging) {
|
|
1447
|
-
this.setAttr(
|
|
1550
|
+
this.setAttr(attrs.currentPage, requestedPage);
|
|
1448
1551
|
this.updateVisibleRecords();
|
|
1449
1552
|
}
|
|
1450
1553
|
else {
|
|
@@ -1452,11 +1555,10 @@ class RecordTable extends FormElement {
|
|
|
1452
1555
|
}
|
|
1453
1556
|
}
|
|
1454
1557
|
updateVisibleRecords() {
|
|
1455
|
-
// updateView const changeViewAttributes = ['currentPage', 'recordsPerPage', 'sorting'];
|
|
1456
1558
|
let visibleRecords;
|
|
1457
1559
|
if (this.clientPaging) {
|
|
1458
1560
|
let filteredRecords = this.getFilteredRecords();
|
|
1459
|
-
this.setAttr(
|
|
1561
|
+
this.setAttr(attrs.totalRecordsNumber, filteredRecords.length);
|
|
1460
1562
|
const sliceNumber1 = (this.currentPage - 1) * this.recordsPerPage;
|
|
1461
1563
|
const sliceNumber2 = (this.currentPage - 1) * this.recordsPerPage + this.recordsPerPage;
|
|
1462
1564
|
visibleRecords = filteredRecords.slice(sliceNumber1, sliceNumber2);
|
|
@@ -1469,17 +1571,17 @@ class RecordTable extends FormElement {
|
|
|
1469
1571
|
else {
|
|
1470
1572
|
visibleRecords = this.tableRecords;
|
|
1471
1573
|
}
|
|
1472
|
-
this.setAttr(
|
|
1574
|
+
this.setAttr(attrs.visibleRecords, visibleRecords);
|
|
1473
1575
|
}
|
|
1474
1576
|
updateFromServer(tableReceived) {
|
|
1475
1577
|
this.requestedPage = 1;
|
|
1476
1578
|
this.visible = tableReceived?.visible || true;
|
|
1477
1579
|
this.totalPages = tableReceived.totalPages || 1;
|
|
1478
1580
|
this.recordsNumber = tableReceived.recordsNumber;
|
|
1479
|
-
this.setAttr(
|
|
1480
|
-
this.setAttr(
|
|
1481
|
-
this.setAttr(
|
|
1482
|
-
this.setAttr(
|
|
1581
|
+
this.setAttr(attrs.currentPage, +tableReceived?.currentPage || 1);
|
|
1582
|
+
this.setAttr(attrs.recordsPerPage, +tableReceived.recordsPerPage);
|
|
1583
|
+
this.setAttr(attrs.totalRecordsNumber, (this.clientPaging) ? tableReceived.tableRecords.length : +tableReceived.totalRecordsNumber);
|
|
1584
|
+
this.setAttr(attrs.sorting, {
|
|
1483
1585
|
columnName: tableReceived.sortingColumn || '',
|
|
1484
1586
|
direction: tableReceived.sortingDirection || ''
|
|
1485
1587
|
});
|
|
@@ -1528,7 +1630,7 @@ class RecordTable extends FormElement {
|
|
|
1528
1630
|
this.changePage(1);
|
|
1529
1631
|
}
|
|
1530
1632
|
if (notifyComponent) {
|
|
1531
|
-
this.setAttr(
|
|
1633
|
+
this.setAttr(attrs.globalFilterString, text.trim());
|
|
1532
1634
|
}
|
|
1533
1635
|
}
|
|
1534
1636
|
addFilterDefinition(columnName, filterDefinition) {
|
|
@@ -1576,10 +1678,10 @@ class RecordTable extends FormElement {
|
|
|
1576
1678
|
for (let index = 0; index < columnFilters.length; index++) {
|
|
1577
1679
|
const columnFilter = columnFilters[index];
|
|
1578
1680
|
compactFilter.advancedFilter.push({
|
|
1579
|
-
fieldCode: columnFilter
|
|
1580
|
-
operator: columnFilter
|
|
1581
|
-
fieldValue1: columnFilter
|
|
1582
|
-
fieldValue2: columnFilter
|
|
1681
|
+
fieldCode: columnFilter?.fieldCode,
|
|
1682
|
+
operator: columnFilter?.operator,
|
|
1683
|
+
fieldValue1: columnFilter?.values[0],
|
|
1684
|
+
fieldValue2: columnFilter?.values[1],
|
|
1583
1685
|
});
|
|
1584
1686
|
}
|
|
1585
1687
|
return compactFilter;
|
|
@@ -1595,7 +1697,7 @@ class RecordTable extends FormElement {
|
|
|
1595
1697
|
}
|
|
1596
1698
|
}
|
|
1597
1699
|
setRequiredOrder(columnField, direction = null) {
|
|
1598
|
-
this.setAttr(
|
|
1700
|
+
this.setAttr(attrs.sorting, {
|
|
1599
1701
|
columnName: columnField,
|
|
1600
1702
|
direction: (direction === 'ascend') ? TABLE_SORT_ASCENDING : TABLE_SORT_DESCENDING,
|
|
1601
1703
|
});
|
|
@@ -1622,28 +1724,39 @@ class RecordTable extends FormElement {
|
|
|
1622
1724
|
}
|
|
1623
1725
|
return direction === TABLE_SORT_ASCENDING ? result : -result;
|
|
1624
1726
|
}
|
|
1727
|
+
formStateChangeCustomSubscribe(formChangeSubject) {
|
|
1728
|
+
this.columns?.forEach(column => {
|
|
1729
|
+
column?.subscribeFormStateChange(formChangeSubject);
|
|
1730
|
+
});
|
|
1731
|
+
this._actions?.forEach(action => {
|
|
1732
|
+
action?.subscribeFormStateChange(formChangeSubject);
|
|
1733
|
+
});
|
|
1734
|
+
}
|
|
1625
1735
|
}
|
|
1626
1736
|
|
|
1627
|
-
class RecordFormSubSection {
|
|
1628
|
-
constructor(subsectionReceived, formObject) {
|
|
1629
|
-
|
|
1630
|
-
return;
|
|
1631
|
-
}
|
|
1737
|
+
class RecordFormSubSection extends FormPiecePropagate {
|
|
1738
|
+
constructor(subsectionReceived, formObject, formConfig) {
|
|
1739
|
+
super(subsectionReceived, formConfig);
|
|
1632
1740
|
this._customRender = null;
|
|
1633
|
-
this.
|
|
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
|
+
this.active = false;
|
|
1750
|
+
if (!subsectionReceived) {
|
|
1751
|
+
return;
|
|
1752
|
+
}
|
|
1639
1753
|
this.subsectionId = (subsectionReceived.subsectionId) ? subsectionReceived.subsectionId.toString() : '';
|
|
1640
1754
|
this.subsectionCode = (subsectionReceived.subsectionCode) ? subsectionReceived.subsectionCode : '';
|
|
1641
1755
|
this.subsectionTitle = (subsectionReceived.subsectionTitle) ? subsectionReceived.subsectionTitle : '';
|
|
1642
|
-
this.visibleStates = subsectionReceived.visibleStates || [];
|
|
1643
1756
|
if (subsectionReceived.elements) {
|
|
1644
1757
|
for (const receivedElement of subsectionReceived.elements) {
|
|
1645
1758
|
let elementObject = null;
|
|
1646
|
-
let arrayToAdd =
|
|
1759
|
+
let arrayToAdd = [];
|
|
1647
1760
|
const { type, code } = receivedElement;
|
|
1648
1761
|
switch (type) {
|
|
1649
1762
|
case elementTypes.field:
|
|
@@ -1668,8 +1781,6 @@ class RecordFormSubSection {
|
|
|
1668
1781
|
}
|
|
1669
1782
|
}
|
|
1670
1783
|
}
|
|
1671
|
-
show() { this.visible = true; }
|
|
1672
|
-
hide() { this.visible = false; }
|
|
1673
1784
|
get customRender() { return this._customRender; }
|
|
1674
1785
|
set customRender(customRenderName) { this._customRender = customRenderName; }
|
|
1675
1786
|
getField(name) {
|
|
@@ -1687,46 +1798,50 @@ class RecordFormSubSection {
|
|
|
1687
1798
|
getActionNames() {
|
|
1688
1799
|
return this.subSectionActions.map(action => action.actionCode);
|
|
1689
1800
|
}
|
|
1690
|
-
|
|
1691
|
-
|
|
1801
|
+
activate() {
|
|
1802
|
+
if (!this.active) {
|
|
1803
|
+
this.active = true;
|
|
1804
|
+
// this.subsectionCode && this._activation.next(this.subsectionCode);
|
|
1805
|
+
}
|
|
1806
|
+
}
|
|
1807
|
+
inactivate() {
|
|
1808
|
+
if (this.active) {
|
|
1809
|
+
this.active = false;
|
|
1810
|
+
// this.subsectionCode && this._inactivation.next(this.subsectionCode);
|
|
1811
|
+
}
|
|
1692
1812
|
}
|
|
1693
|
-
supportMode(state) { return this.viewOnState(state); }
|
|
1694
1813
|
}
|
|
1695
1814
|
|
|
1696
|
-
|
|
1697
|
-
|
|
1815
|
+
const ACTIVE$1 = 'active';
|
|
1816
|
+
class RecordFormSection extends FormPiecePropagate {
|
|
1817
|
+
constructor(sectionReceived, formObject, formConfig) {
|
|
1818
|
+
super(sectionReceived, formConfig);
|
|
1698
1819
|
this._activation = new Subject();
|
|
1699
1820
|
this._inactivation = new Subject();
|
|
1700
1821
|
this.active = false;
|
|
1701
|
-
this.
|
|
1822
|
+
this.sectionId = null;
|
|
1823
|
+
this.sectionCode = null;
|
|
1824
|
+
this.sectionTitle = null;
|
|
1825
|
+
this.subSections = [];
|
|
1826
|
+
this._exclusiveSubSectionsByAttr = {};
|
|
1702
1827
|
if (!sectionReceived) {
|
|
1703
1828
|
return;
|
|
1704
1829
|
}
|
|
1705
|
-
this.visible = true;
|
|
1706
1830
|
this.sectionId = (sectionReceived.sectionId) ? sectionReceived.sectionId.toString() : '';
|
|
1707
1831
|
this.sectionCode = (sectionReceived.sectionCode) ? sectionReceived.sectionCode : '';
|
|
1708
1832
|
this.sectionTitle = (sectionReceived.sectionTitle) ? sectionReceived.sectionTitle : '';
|
|
1709
|
-
this.visibleStates = sectionReceived.visibleStates || [];
|
|
1710
1833
|
this.subSections = [];
|
|
1711
1834
|
this.subSectionsObj = {};
|
|
1712
1835
|
if (sectionReceived.subsections) {
|
|
1713
|
-
const subsections = sectionReceived.subsections.map(
|
|
1714
|
-
|
|
1715
|
-
if (
|
|
1716
|
-
|
|
1717
|
-
.map(state => state.trim())
|
|
1718
|
-
.filter(state => state.length > 0);
|
|
1719
|
-
}
|
|
1720
|
-
if (!visibleStates || visibleStates.length === 0) {
|
|
1721
|
-
visibleStates = this.visibleStates;
|
|
1722
|
-
}
|
|
1723
|
-
if (objDef.elements && Array.isArray(objDef.elements)) {
|
|
1724
|
-
objDef.elements = objDef.elements.map(elm => ({ code: elm.elementCode, type: elm.elementTypeName }));
|
|
1836
|
+
const subsections = sectionReceived.subsections.map(subSecDef => {
|
|
1837
|
+
const visibleStates = subSecDef.visibleStates ?? [];
|
|
1838
|
+
if (subSecDef.elements && Array.isArray(subSecDef.elements)) {
|
|
1839
|
+
subSecDef.elements = subSecDef.elements.map(elm => ({ code: elm.elementCode, type: elm.elementTypeName }));
|
|
1725
1840
|
}
|
|
1726
|
-
return { ...
|
|
1841
|
+
return { ...subSecDef, visibleStates };
|
|
1727
1842
|
});
|
|
1728
1843
|
for (const subsectionReceived of subsections) {
|
|
1729
|
-
const subSectionToAdd = new RecordFormSubSection(subsectionReceived, formObject);
|
|
1844
|
+
const subSectionToAdd = new RecordFormSubSection(subsectionReceived, formObject, formConfig);
|
|
1730
1845
|
const subsectionCode = subSectionToAdd.subsectionCode;
|
|
1731
1846
|
if (subsectionCode) {
|
|
1732
1847
|
this.subSections.push(subSectionToAdd);
|
|
@@ -1734,52 +1849,50 @@ class RecordFormSection {
|
|
|
1734
1849
|
}
|
|
1735
1850
|
}
|
|
1736
1851
|
}
|
|
1737
|
-
if (sectionReceived?.customAttributes) {
|
|
1738
|
-
Object.keys(sectionReceived?.customAttributes)
|
|
1739
|
-
?.forEach(attr => this.customAttributes[attr] = sectionReceived?.customAttributes[attr]);
|
|
1740
|
-
}
|
|
1741
1852
|
}
|
|
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
|
-
}
|
|
1749
|
-
matchAttribute(name, value) { return this.customAttributes?.[name] === value; }
|
|
1750
1853
|
get code() { return this.sectionCode; }
|
|
1751
1854
|
get activation() { return this._activation; }
|
|
1752
1855
|
get inactivation() { return this._inactivation; }
|
|
1753
1856
|
activate() {
|
|
1754
1857
|
if (!this.active) {
|
|
1755
1858
|
this.active = true;
|
|
1756
|
-
this._activation.next(this.sectionCode);
|
|
1859
|
+
this.sectionCode && this._activation.next(this.sectionCode);
|
|
1757
1860
|
}
|
|
1758
1861
|
}
|
|
1759
1862
|
inactivate() {
|
|
1760
1863
|
if (this.active) {
|
|
1761
1864
|
this.active = false;
|
|
1762
|
-
this._inactivation.next(this.sectionCode);
|
|
1865
|
+
this.sectionCode && this._inactivation.next(this.sectionCode);
|
|
1763
1866
|
}
|
|
1764
1867
|
}
|
|
1765
|
-
show() { this.visible = true; }
|
|
1766
|
-
hide() { this.visible = false; }
|
|
1767
1868
|
get title() { return this.sectionTitle; }
|
|
1768
1869
|
set title(title) { this.sectionTitle = title; }
|
|
1769
1870
|
getVisibleSubsections(state) {
|
|
1770
|
-
return this.subSections.filter(subSection =>
|
|
1771
|
-
return subSection.visible && subSection.viewOnState(state);
|
|
1772
|
-
});
|
|
1871
|
+
return this.subSections.filter(subSection => subSection.visible);
|
|
1773
1872
|
}
|
|
1774
1873
|
getSubsection(subSectionCode) {
|
|
1775
1874
|
return (this.subSectionsObj && this.subSectionsObj[subSectionCode])
|
|
1776
1875
|
? this.subSectionsObj[subSectionCode] : null;
|
|
1777
1876
|
}
|
|
1877
|
+
activateSubSection(subSectionCode) {
|
|
1878
|
+
if (subSectionCode === this._exclusiveSubSectionsByAttr[ACTIVE$1]) {
|
|
1879
|
+
return;
|
|
1880
|
+
}
|
|
1881
|
+
const subSection = (this.subSectionsObj && this.subSectionsObj[subSectionCode])
|
|
1882
|
+
? this.subSectionsObj[subSectionCode] : null;
|
|
1883
|
+
if (subSection) {
|
|
1884
|
+
subSection?.activate();
|
|
1885
|
+
this._exclusiveSubSectionsByAttr[ACTIVE$1] = subSectionCode;
|
|
1886
|
+
}
|
|
1887
|
+
}
|
|
1778
1888
|
getFields() {
|
|
1779
1889
|
let fieldsArray = [];
|
|
1780
1890
|
if (this.subSections && this.subSections.length > 0) {
|
|
1781
1891
|
for (const subSection of this.subSections) {
|
|
1782
|
-
|
|
1892
|
+
const subsectionFields = subSection.getFields() ?? [];
|
|
1893
|
+
if (subsectionFields?.length > 0) {
|
|
1894
|
+
fieldsArray = fieldsArray.concat(subsectionFields);
|
|
1895
|
+
}
|
|
1783
1896
|
}
|
|
1784
1897
|
}
|
|
1785
1898
|
return fieldsArray;
|
|
@@ -1788,7 +1901,10 @@ class RecordFormSection {
|
|
|
1788
1901
|
let actionArray = [];
|
|
1789
1902
|
if (this.subSections && this.subSections.length > 0) {
|
|
1790
1903
|
for (const subSection of this.subSections) {
|
|
1791
|
-
|
|
1904
|
+
const subSectionActions = subSection.getActions() ?? [];
|
|
1905
|
+
if (subSectionActions?.length > 0) {
|
|
1906
|
+
actionArray = actionArray.concat(subSectionActions);
|
|
1907
|
+
}
|
|
1792
1908
|
}
|
|
1793
1909
|
}
|
|
1794
1910
|
return actionArray;
|
|
@@ -1823,9 +1939,11 @@ class RecordFormSection {
|
|
|
1823
1939
|
}
|
|
1824
1940
|
return null;
|
|
1825
1941
|
}
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1942
|
+
formStateChangeCustomSubscribe(formChangeSubject) {
|
|
1943
|
+
this.subSections?.forEach(subsection => {
|
|
1944
|
+
subsection?.subscribeFormStateChange(formChangeSubject);
|
|
1945
|
+
});
|
|
1946
|
+
}
|
|
1829
1947
|
}
|
|
1830
1948
|
|
|
1831
1949
|
const ACTIVE = 'active';
|
|
@@ -1836,6 +1954,7 @@ const DISABLE = 'disable';
|
|
|
1836
1954
|
const CLEAN = 'clean';
|
|
1837
1955
|
class FormStructureAndData {
|
|
1838
1956
|
constructor(definitionReceived, formConfig) {
|
|
1957
|
+
this._stateChange = new Subject();
|
|
1839
1958
|
this._name = '';
|
|
1840
1959
|
this._title = '';
|
|
1841
1960
|
this._fields = {};
|
|
@@ -1890,7 +2009,7 @@ class FormStructureAndData {
|
|
|
1890
2009
|
if (definitionReceived.fields) {
|
|
1891
2010
|
const formFields = definitionReceived.fields.map(objDef => {
|
|
1892
2011
|
let visibleStates = objDef.visibleStates;
|
|
1893
|
-
let enabledStates = objDef.enabledStates
|
|
2012
|
+
let enabledStates = objDef.enabledStates ?? objDef.editableStates;
|
|
1894
2013
|
if (!visibleStates) {
|
|
1895
2014
|
visibleStates = (objDef.fieldModes || '').split(',')
|
|
1896
2015
|
.map(state => state.trim())
|
|
@@ -1940,7 +2059,7 @@ class FormStructureAndData {
|
|
|
1940
2059
|
return { ...objDef, visibleStates };
|
|
1941
2060
|
});
|
|
1942
2061
|
for (const sectionReceived of formSections) {
|
|
1943
|
-
const sectionToAdd = new RecordFormSection(sectionReceived, this);
|
|
2062
|
+
const sectionToAdd = new RecordFormSection(sectionReceived, this, this._formConfig);
|
|
1944
2063
|
const sectionCode = sectionToAdd.sectionCode;
|
|
1945
2064
|
if (sectionCode) {
|
|
1946
2065
|
this._sectionArray.push(sectionToAdd);
|
|
@@ -1972,8 +2091,10 @@ class FormStructureAndData {
|
|
|
1972
2091
|
this.state = newState;
|
|
1973
2092
|
}
|
|
1974
2093
|
}
|
|
2094
|
+
this._stateChange.next({ state: this.state });
|
|
1975
2095
|
return (this.state === newState);
|
|
1976
2096
|
}
|
|
2097
|
+
get stateChange() { return this._stateChange; }
|
|
1977
2098
|
setStateFlow(states, transitions, defaultState) {
|
|
1978
2099
|
this._stateFlow.states = states;
|
|
1979
2100
|
this._stateFlow.defaultState = defaultState || this._stateFlow.states[0];
|
|
@@ -2167,7 +2288,7 @@ class FormStructureAndData {
|
|
|
2167
2288
|
getSections() { return this._sectionArray; }
|
|
2168
2289
|
getSectionsByAttribute(name, value) { return this._sectionArray.filter(item => item.matchAttribute(name, value)); }
|
|
2169
2290
|
get sectionTitles() { return this._sectionArray.map(formSection => formSection.sectionTitle); }
|
|
2170
|
-
get visibleSections() { return this._sectionArray.filter(sec => sec.
|
|
2291
|
+
get visibleSections() { return this._sectionArray.filter(sec => sec.absoluteVisible); }
|
|
2171
2292
|
getSection(code) { return (code && this._sections?.[code]) ? this._sections[code] : null; }
|
|
2172
2293
|
showSections(codes) { this.execOnSections(codes, SHOW); }
|
|
2173
2294
|
hideSections(codes) { this.execOnSections(codes, HIDE); }
|
|
@@ -2227,8 +2348,8 @@ class FormStructureAndData {
|
|
|
2227
2348
|
const fieldPayload = {
|
|
2228
2349
|
fieldCode: fld?.code,
|
|
2229
2350
|
fieldValue: fld?.value,
|
|
2230
|
-
editable: !fld?.
|
|
2231
|
-
visible: fld?.
|
|
2351
|
+
editable: !fld?.absoluteDisabled,
|
|
2352
|
+
visible: fld?.absoluteVisible,
|
|
2232
2353
|
required: fld?.required,
|
|
2233
2354
|
fieldOptions: '',
|
|
2234
2355
|
};
|
|
@@ -2237,7 +2358,7 @@ class FormStructureAndData {
|
|
|
2237
2358
|
formData.tables = this.getTables().map(tbl => {
|
|
2238
2359
|
const tablePayload = {
|
|
2239
2360
|
tableCode: tbl.tableCode,
|
|
2240
|
-
visible: tbl.
|
|
2361
|
+
visible: tbl.absoluteVisible,
|
|
2241
2362
|
currentPage: tbl.currentPage,
|
|
2242
2363
|
requestedPage: tbl.requestedPage,
|
|
2243
2364
|
recordsPerPage: tbl.recordsPerPage,
|
|
@@ -2405,6 +2526,8 @@ class BasicFormComponent {
|
|
|
2405
2526
|
this.cleanStart();
|
|
2406
2527
|
this.customPreProcessing();
|
|
2407
2528
|
}
|
|
2529
|
+
get title() { return this.getTitle() ?? ''; }
|
|
2530
|
+
set title(title) { this.setTitle(title); }
|
|
2408
2531
|
getTitle() { return this._formStructure?.getTitle(); }
|
|
2409
2532
|
setTitle(title) { return this._formStructure?.setTitle(title); }
|
|
2410
2533
|
cleanData() { return this._formStructure?.cleanData(); }
|
|
@@ -2767,6 +2890,8 @@ class BasicFormComponent {
|
|
|
2767
2890
|
const section = formSections[sectionName];
|
|
2768
2891
|
section.activation.subscribe((code) => this.launchSectionActivation(code));
|
|
2769
2892
|
section.inactivation.subscribe((code) => this.launchSectionInactivation(code));
|
|
2893
|
+
// Adicionalmente se le pide a la sección se subscriba al cambio de estado del formulario
|
|
2894
|
+
section.subscribeFormStateChange(this._formStructure?.stateChange);
|
|
2770
2895
|
}
|
|
2771
2896
|
}
|
|
2772
2897
|
subscribeFieldsSubjects() {
|
|
@@ -2782,6 +2907,8 @@ class BasicFormComponent {
|
|
|
2782
2907
|
this.startFieldInputValidation(code, intrinsicValidation);
|
|
2783
2908
|
});
|
|
2784
2909
|
field.detailRequest.subscribe(event => this.showFieldInfo(event.code, event.detail));
|
|
2910
|
+
// Adicionalmente se le pide al campo se subscriba al cambio de estado del formulario
|
|
2911
|
+
field.subscribeFormStateChange(this._formStructure?.stateChange);
|
|
2785
2912
|
});
|
|
2786
2913
|
}
|
|
2787
2914
|
}
|
|
@@ -2790,6 +2917,8 @@ class BasicFormComponent {
|
|
|
2790
2917
|
if (Array.isArray(formActions)) {
|
|
2791
2918
|
formActions.forEach(action => {
|
|
2792
2919
|
action.actionActivated.subscribe(code => this.startAction(code));
|
|
2920
|
+
// Adicionalmente se le pide a la acción se subscriba al cambio de estado del formulario
|
|
2921
|
+
action.subscribeFormStateChange(this._formStructure?.stateChange);
|
|
2793
2922
|
});
|
|
2794
2923
|
}
|
|
2795
2924
|
}
|
|
@@ -2802,6 +2931,8 @@ class BasicFormComponent {
|
|
|
2802
2931
|
table.recordSelectionTrigger.subscribe(event => this.startTableRecordSelection(event));
|
|
2803
2932
|
table.selectionActionTrigger.subscribe(event => this.startTableSelectionAction(event));
|
|
2804
2933
|
table.getDataTrigger.subscribe(event => this.startTableGetData(event));
|
|
2934
|
+
// Adicionalmente se le pide a la tabla se subscriba al cambio de estado del formulario
|
|
2935
|
+
table.subscribeFormStateChange(this._formStructure?.stateChange);
|
|
2805
2936
|
});
|
|
2806
2937
|
}
|
|
2807
2938
|
}
|
|
@@ -2826,21 +2957,22 @@ class BasicFormComponent {
|
|
|
2826
2957
|
if (!this.supportState(initialState)) {
|
|
2827
2958
|
initialState = this._formStructure?.defaultState ?? null;
|
|
2828
2959
|
}
|
|
2829
|
-
this._formStructure?.changeState(initialState || this._formStructure?.defaultState);
|
|
2830
2960
|
const inputFieldNames = Object.keys(this.inputDataFields);
|
|
2831
2961
|
for (let index = 0; index < inputFieldNames.length; index++) {
|
|
2832
2962
|
const code = inputFieldNames[index];
|
|
2833
2963
|
const fieldValue = this.inputDataFields[code];
|
|
2834
2964
|
this.setFieldValue(code, fieldValue);
|
|
2835
2965
|
}
|
|
2836
|
-
const recordResponse = await this.requestFormAction(formActions.getData);
|
|
2837
|
-
this.checkErrorRecordReceived(recordResponse);
|
|
2838
|
-
this.visible = true;
|
|
2839
|
-
this.enabledSections = this._formStructure?.visibleSections ?? [];
|
|
2840
2966
|
this.subscribeSectionActivation();
|
|
2841
2967
|
this.subscribeFieldsSubjects();
|
|
2842
2968
|
this.subscribeActionSubjects();
|
|
2843
2969
|
this.subscribeTableSubjects();
|
|
2970
|
+
// Se define el estado inicial y se solicita la acción inicial
|
|
2971
|
+
this._formStructure?.changeState(initialState || this._formStructure?.defaultState);
|
|
2972
|
+
const recordResponse = await this.requestFormAction(formActions.getData);
|
|
2973
|
+
this.checkErrorRecordReceived(recordResponse);
|
|
2974
|
+
this.visible = true;
|
|
2975
|
+
this.enabledSections = this._formStructure?.visibleSections ?? [];
|
|
2844
2976
|
this.start();
|
|
2845
2977
|
this.customFormStart();
|
|
2846
2978
|
}
|
|
@@ -3098,7 +3230,7 @@ class BasicFormComponent {
|
|
|
3098
3230
|
for (const clientActionMethod of finishActionMethods) {
|
|
3099
3231
|
const { callback, properties } = clientActionMethod;
|
|
3100
3232
|
const continueOnError = properties?.continueOnError ?? false;
|
|
3101
|
-
if (!serverError || continueOnError) {
|
|
3233
|
+
if (callback && (!serverError || continueOnError)) {
|
|
3102
3234
|
clientActionPromises.push(callback(action, actionResult));
|
|
3103
3235
|
}
|
|
3104
3236
|
}
|
|
@@ -3459,7 +3591,7 @@ class BasicFormComponent {
|
|
|
3459
3591
|
if (action.backend) {
|
|
3460
3592
|
const actionSubject = {
|
|
3461
3593
|
tableCode,
|
|
3462
|
-
actionType: this.formConfig
|
|
3594
|
+
actionType: this.formConfig?.tableActions.inline,
|
|
3463
3595
|
actionCode,
|
|
3464
3596
|
tableRecordId: recordId,
|
|
3465
3597
|
tableRecordData: recordData
|
|
@@ -3538,7 +3670,7 @@ class BasicFormComponent {
|
|
|
3538
3670
|
if (tableObject.selectionBackend) {
|
|
3539
3671
|
const actionSubject = {
|
|
3540
3672
|
tableCode,
|
|
3541
|
-
actionType: this.formConfig
|
|
3673
|
+
actionType: this.formConfig?.tableActions.rowSelection,
|
|
3542
3674
|
actionCode: null,
|
|
3543
3675
|
tableRecordId: recordId,
|
|
3544
3676
|
tableRecordData: recordData
|
|
@@ -3616,7 +3748,7 @@ class BasicFormComponent {
|
|
|
3616
3748
|
if (action.backend) {
|
|
3617
3749
|
const actionSubject = {
|
|
3618
3750
|
tableCode,
|
|
3619
|
-
actionType: this.formConfig
|
|
3751
|
+
actionType: this.formConfig?.tableActions.selection,
|
|
3620
3752
|
actionCode,
|
|
3621
3753
|
selectedRecords
|
|
3622
3754
|
};
|
|
@@ -3706,7 +3838,7 @@ class BasicFormComponent {
|
|
|
3706
3838
|
}
|
|
3707
3839
|
checkSectionRequiredFields(sectionCode, reqFieldMessage) {
|
|
3708
3840
|
this.cleanErrorFields(null, sectionCode);
|
|
3709
|
-
const requiredFieldMessage = reqFieldMessage ?? this.formConfig
|
|
3841
|
+
const requiredFieldMessage = reqFieldMessage ?? this.formConfig?.formStandardErrors.requiredField;
|
|
3710
3842
|
const numErrors = this.tagFieldsWithError(requiredFieldMessage, this.getRequiredEmptyFields(null, sectionCode));
|
|
3711
3843
|
return (numErrors === 0);
|
|
3712
3844
|
}
|
|
@@ -3714,15 +3846,15 @@ class BasicFormComponent {
|
|
|
3714
3846
|
this.resetError();
|
|
3715
3847
|
const completeFields = this.checkSectionRequiredFields(sectionCode, reqFieldMessage);
|
|
3716
3848
|
if (!completeFields) {
|
|
3717
|
-
this.setError(this.formConfig
|
|
3849
|
+
this.setError(this.formConfig?.formStandardErrors.typeWarning, this.formConfig?.formStandardErrors.validationTitle, this.formConfig?.formStandardErrors.requiredFields);
|
|
3718
3850
|
return false;
|
|
3719
3851
|
}
|
|
3720
3852
|
let validationError = false;
|
|
3721
3853
|
const requiredEmptyFields = this.getRequiredEmptyFields(null, sectionCode) ?? [];
|
|
3722
3854
|
if (requiredEmptyFields?.length > 0) {
|
|
3723
3855
|
validationError = true;
|
|
3724
|
-
this.setError(this.formConfig
|
|
3725
|
-
this.tagFieldsWithError(this.formConfig
|
|
3856
|
+
this.setError(this.formConfig?.formStandardErrors.typeWarning, this.formConfig?.formStandardErrors.validationTitle, this.formConfig?.formStandardErrors.requiredFields);
|
|
3857
|
+
this.tagFieldsWithError(this.formConfig?.formStandardErrors.requiredField, requiredEmptyFields);
|
|
3726
3858
|
for (const code of requiredEmptyFields) {
|
|
3727
3859
|
const requiredEmptyField = this.getField(code);
|
|
3728
3860
|
requiredEmptyField?.focus();
|
|
@@ -3732,7 +3864,7 @@ class BasicFormComponent {
|
|
|
3732
3864
|
const validationIssueFields = this.getFieldsWithValidationIssues(null, sectionCode) ?? [];
|
|
3733
3865
|
if (!validationError && validationIssueFields.length > 0) {
|
|
3734
3866
|
validationError = true;
|
|
3735
|
-
this.setError(this.formConfig
|
|
3867
|
+
this.setError(this.formConfig?.formStandardErrors.typeWarning, this.formConfig?.formStandardErrors.validationTitle, this.formConfig?.formStandardErrors.validationFields);
|
|
3736
3868
|
for (const code of validationIssueFields) {
|
|
3737
3869
|
const validationIssueField = this.getField(code);
|
|
3738
3870
|
if (validationIssueField) {
|