tuain-ng-forms-lib 17.0.0 → 17.1.1
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/esm2022/lib/classes/forms/action.mjs +66 -40
- package/esm2022/lib/classes/forms/element.mjs +8 -3
- package/esm2022/lib/classes/forms/field.mjs +81 -71
- package/esm2022/lib/classes/forms/section.mjs +51 -39
- package/esm2022/lib/classes/forms/subsection.mjs +45 -27
- package/esm2022/lib/classes/forms/table/table.mjs +124 -82
- package/esm2022/lib/components/elements/action.component.mjs +29 -19
- package/esm2022/lib/components/elements/field.component.mjs +56 -69
- package/esm2022/lib/components/elements/layout/piece.component.mjs +43 -19
- package/esm2022/lib/components/elements/layout/section.component.mjs +21 -13
- package/esm2022/lib/components/elements/layout/sub-section.component.mjs +21 -13
- package/esm2022/lib/components/elements/tables/table-record-action.component.mjs +15 -11
- package/esm2022/lib/components/elements/tables/table.component.mjs +38 -35
- package/fesm2022/tuain-ng-forms-lib.mjs +583 -426
- package/fesm2022/tuain-ng-forms-lib.mjs.map +1 -1
- package/lib/classes/forms/action.d.ts +30 -14
- package/lib/classes/forms/field.d.ts +9 -4
- package/lib/classes/forms/section.d.ts +18 -6
- package/lib/classes/forms/subsection.d.ts +28 -10
- package/lib/classes/forms/table/table.d.ts +63 -21
- package/lib/components/elements/action.component.d.ts +8 -1
- package/lib/components/elements/field.component.d.ts +21 -15
- package/lib/components/elements/layout/piece.component.d.ts +8 -4
- package/lib/components/elements/layout/section.component.d.ts +1 -0
- package/lib/components/elements/layout/sub-section.component.d.ts +1 -0
- package/lib/components/elements/tables/table-record-action.component.d.ts +1 -1
- package/lib/components/elements/tables/table.component.d.ts +12 -5
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { Component, Input, EventEmitter, Output, ChangeDetectionStrategy, NgModule } from '@angular/core';
|
|
2
|
+
import { signal, computed, Component, Input, EventEmitter, Output, ChangeDetectionStrategy, NgModule } from '@angular/core';
|
|
3
3
|
import { BehaviorSubject, Subject, ReplaySubject } from 'rxjs';
|
|
4
4
|
import yn from 'yn';
|
|
5
5
|
import { nanoid } from 'nanoid';
|
|
@@ -7,33 +7,57 @@ import { CommonModule } from '@angular/common';
|
|
|
7
7
|
import { RouterModule } from '@angular/router';
|
|
8
8
|
import { FormsModule } from '@angular/forms';
|
|
9
9
|
|
|
10
|
-
const CUSTOM_ATTRIBUTES = 'customAttributes';
|
|
10
|
+
const CUSTOM_ATTRIBUTES$6 = 'customAttributes';
|
|
11
11
|
class PieceComponent {
|
|
12
12
|
form;
|
|
13
13
|
formConfig;
|
|
14
|
-
visible =
|
|
15
|
-
disabled = false;
|
|
16
|
-
|
|
14
|
+
visible = signal(false);
|
|
15
|
+
disabled = signal(false);
|
|
16
|
+
enabled = computed(() => !this.disabled());
|
|
17
|
+
customAttributes = signal({});
|
|
17
18
|
setForm(form) { this.form = form; }
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
propagatedAttributeChange(attribute, value) { }
|
|
20
|
+
updatePieceAttribute(signaledAttributes, signaledAttribute, value) {
|
|
21
|
+
if (!signaledAttributes.includes(signaledAttribute)) {
|
|
22
|
+
return;
|
|
21
23
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
24
|
+
this[signaledAttribute]?.set(value);
|
|
25
|
+
this.propagatedAttributeChange(signaledAttribute, value);
|
|
26
|
+
}
|
|
27
|
+
updatePieceAttributes(piece, signaledAttributes) {
|
|
28
|
+
if (!piece) {
|
|
29
|
+
return;
|
|
29
30
|
}
|
|
30
|
-
|
|
31
|
-
|
|
31
|
+
// Se recore el conjunto de los atributos propagados desde el piece y se asigna el valor respectivo
|
|
32
|
+
for (let index = 0; index < signaledAttributes.length; index++) {
|
|
33
|
+
const signaledAttribute = signaledAttributes[index];
|
|
34
|
+
try {
|
|
35
|
+
this[signaledAttribute]?.set(piece?.[signaledAttribute]);
|
|
36
|
+
this.propagatedAttributeChange(signaledAttribute, piece?.[signaledAttribute]);
|
|
37
|
+
}
|
|
38
|
+
catch (e) {
|
|
39
|
+
console.log(`Señal ${signaledAttribute} invalida en el componente. ${e}`);
|
|
40
|
+
}
|
|
32
41
|
}
|
|
33
|
-
return true;
|
|
34
42
|
}
|
|
35
|
-
|
|
43
|
+
// Función que las subclases pueden sobrecargar para manejar un comportamiento específico
|
|
36
44
|
customAttributeChange(subAttribute, value) { }
|
|
45
|
+
updateCustomAttribute(attrName, attrValue) {
|
|
46
|
+
this.customAttributes.update(oldCustomAttr => {
|
|
47
|
+
oldCustomAttr[attrName] = attrValue;
|
|
48
|
+
return oldCustomAttr;
|
|
49
|
+
});
|
|
50
|
+
// Ejecución de función personalizada ante un cambio de atributo personalizado
|
|
51
|
+
this.customAttributeChange(attrName, attrValue);
|
|
52
|
+
}
|
|
53
|
+
replaceCustomAttributes(customAttributes) {
|
|
54
|
+
this.customAttributes.set(customAttributes ?? {});
|
|
55
|
+
Object.keys(customAttributes).forEach(attrName => {
|
|
56
|
+
const attrValue = customAttributes[attrName];
|
|
57
|
+
// Ejecución de función personalizada ante un cambio de atributo personalizado
|
|
58
|
+
this.customAttributeChange(attrName, attrValue);
|
|
59
|
+
});
|
|
60
|
+
}
|
|
37
61
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: PieceComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
38
62
|
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.3.12", type: PieceComponent, selector: "lib-piece", ngImport: i0, template: `<ng-content></ng-content>`, isInline: true });
|
|
39
63
|
}
|
|
@@ -63,32 +87,42 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImpo
|
|
|
63
87
|
type: Input
|
|
64
88
|
}] } });
|
|
65
89
|
|
|
90
|
+
const CUSTOM_ATTRIBUTES$5 = 'customAttributes';
|
|
91
|
+
const signaledAttributes$5 = [
|
|
92
|
+
'actionCode', 'actionName', 'iconName', 'inProgress', 'restrictedOnField', 'restrictedOnOperator',
|
|
93
|
+
'restrictedOnValue', 'visible', 'disabled',
|
|
94
|
+
];
|
|
66
95
|
class ActionComponent extends ElementComponent {
|
|
67
|
-
|
|
96
|
+
actionCode = signal(null);
|
|
97
|
+
actionName = signal(null);
|
|
98
|
+
iconName = signal(null);
|
|
99
|
+
inProgress = signal(false);
|
|
100
|
+
restrictedOnField = signal(null);
|
|
101
|
+
restrictedOnOperator = signal(null);
|
|
102
|
+
restrictedOnValue = signal(null);
|
|
68
103
|
action = null;
|
|
104
|
+
updatePropagatedAttributes() {
|
|
105
|
+
this.updatePieceAttributes(this.action, signaledAttributes$5);
|
|
106
|
+
}
|
|
69
107
|
ngOnInit() {
|
|
70
108
|
if (!this.action) {
|
|
71
109
|
return;
|
|
72
110
|
}
|
|
111
|
+
this.action.widget = this;
|
|
73
112
|
this.formConfig = this.action?._formConfig;
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
const
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
this.
|
|
81
|
-
|
|
113
|
+
this.updatePropagatedAttributes();
|
|
114
|
+
this.replaceCustomAttributes(this.action?.customAttributes);
|
|
115
|
+
this.action?.attributeChange.subscribe(event => {
|
|
116
|
+
const { name: attribute, value = null } = event ?? {};
|
|
117
|
+
const attributeParts = attribute?.split('.') ?? [];
|
|
118
|
+
if (signaledAttributes$5.includes(attribute)) {
|
|
119
|
+
this.updatePieceAttribute(signaledAttributes$5, attribute, value);
|
|
120
|
+
}
|
|
121
|
+
else if (attributeParts?.length > 1 && attributeParts?.[0] === CUSTOM_ATTRIBUTES$5) {
|
|
122
|
+
const subAttribute = attributeParts?.[1] ?? null;
|
|
123
|
+
this.updateCustomAttribute(subAttribute, value);
|
|
82
124
|
}
|
|
83
|
-
}
|
|
84
|
-
this.action?.attributeChange?.subscribe(event => {
|
|
85
|
-
const { name: componentAttr, value } = event;
|
|
86
|
-
this.defaultProcessAttributeChange(componentAttr, value);
|
|
87
|
-
this.customProcessAttributeChange(componentAttr, value);
|
|
88
125
|
});
|
|
89
|
-
if (this.action) {
|
|
90
|
-
this.action.widget = this;
|
|
91
|
-
}
|
|
92
126
|
this.start();
|
|
93
127
|
}
|
|
94
128
|
start() {
|
|
@@ -112,85 +146,76 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImpo
|
|
|
112
146
|
type: Input
|
|
113
147
|
}] } });
|
|
114
148
|
|
|
149
|
+
const CUSTOM_ATTRIBUTES$4 = 'customAttributes';
|
|
150
|
+
const signaledAttributes$4 = ['captureType', 'errorCode', 'errorMessage', 'errorType', 'defaultValue',
|
|
151
|
+
'defaultEditable', 'alignment', 'code', 'info', 'required', 'title', 'type', 'format', 'options',
|
|
152
|
+
'hasChanged', 'maxLength', 'maxValue', 'minLength', 'minValue', 'onValidation', 'outputOnly',
|
|
153
|
+
'placeholder', 'tooltip', 'validateOnServer', 'visibleLabel', 'visible', 'disabled', 'value',
|
|
154
|
+
];
|
|
115
155
|
const VALUE = 'value';
|
|
116
156
|
const FOCUS = 'focus';
|
|
117
157
|
class FieldComponent extends ElementComponent {
|
|
118
|
-
// Atributos
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
158
|
+
// Atributos propagados desde el campo
|
|
159
|
+
captureType = signal('');
|
|
160
|
+
errorCode = signal('');
|
|
161
|
+
errorMessage = signal('');
|
|
162
|
+
errorType = signal('');
|
|
163
|
+
defaultValue = signal(null);
|
|
164
|
+
defaultEditable = signal(false);
|
|
165
|
+
alignment = signal('');
|
|
166
|
+
code = signal('');
|
|
167
|
+
info = signal(null);
|
|
168
|
+
required = signal(false);
|
|
169
|
+
title = signal('');
|
|
170
|
+
type = signal('');
|
|
171
|
+
format = signal(null);
|
|
172
|
+
options = signal(null);
|
|
173
|
+
hasChanged = signal(false);
|
|
174
|
+
minLength = signal(0);
|
|
175
|
+
maxLength = signal(0);
|
|
176
|
+
minValue = signal(null);
|
|
177
|
+
maxValue = signal(null);
|
|
178
|
+
onValidation = signal(false);
|
|
179
|
+
outputOnly = signal(false);
|
|
180
|
+
placeholder = signal('');
|
|
181
|
+
tooltip = signal('');
|
|
182
|
+
validateOnServer = signal(false);
|
|
183
|
+
visibleLabel = signal(true);
|
|
184
|
+
value; // Valor del componente relacionado con el campo (pueden diferir en formato y tipo)
|
|
139
185
|
field = null;
|
|
186
|
+
updatePropagatedAttributes() {
|
|
187
|
+
this.updatePieceAttributes(this.field, signaledAttributes$4);
|
|
188
|
+
}
|
|
140
189
|
ngOnInit() {
|
|
141
190
|
if (!this.field) {
|
|
142
191
|
return;
|
|
143
192
|
}
|
|
193
|
+
this.field.widget = this;
|
|
144
194
|
this.formConfig = this.field?._formConfig;
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
const
|
|
149
|
-
const
|
|
150
|
-
if (
|
|
151
|
-
|
|
152
|
-
this.defaultProcessAttributeChange(componentAttr, value);
|
|
153
|
-
this.customProcessAttributeChange(componentAttr, value);
|
|
195
|
+
this.updatePropagatedAttributes();
|
|
196
|
+
this.replaceCustomAttributes(this.field?.customAttributes);
|
|
197
|
+
this.field?.attributeChange.subscribe(event => {
|
|
198
|
+
const { name: attribute, value = null } = event ?? {};
|
|
199
|
+
const attributeParts = attribute?.split('.') ?? [];
|
|
200
|
+
if (attribute === VALUE) {
|
|
201
|
+
this.updateValue();
|
|
154
202
|
}
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
for (let index = 0; index < customAttributesMapping.length; index++) {
|
|
158
|
-
const customAttribute = customAttributesMapping[index];
|
|
159
|
-
if (customAttribute) {
|
|
160
|
-
const value = this.field?.getCustomAttribute(customAttribute);
|
|
161
|
-
const fullName = `customAttributes.${customAttribute}`;
|
|
162
|
-
if (value) {
|
|
163
|
-
this.defaultProcessAttributeChange(fullName, value);
|
|
164
|
-
this.customProcessAttributeChange(fullName, value);
|
|
165
|
-
}
|
|
203
|
+
else if (attribute === FOCUS) {
|
|
204
|
+
this.focus();
|
|
166
205
|
}
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
this.
|
|
173
|
-
this.customProcessAttributeChange(componentAttr, value);
|
|
206
|
+
else if (signaledAttributes$4.includes(attribute)) {
|
|
207
|
+
this.updatePieceAttribute(signaledAttributes$4, attribute, value);
|
|
208
|
+
}
|
|
209
|
+
else if (attributeParts?.length > 1 && attributeParts?.[0] === CUSTOM_ATTRIBUTES$4) {
|
|
210
|
+
const subAttribute = attributeParts?.[1] ?? null;
|
|
211
|
+
this.updateCustomAttribute(subAttribute, value);
|
|
174
212
|
}
|
|
175
213
|
});
|
|
176
|
-
if (this.field) {
|
|
177
|
-
this.field.widget = this;
|
|
178
|
-
}
|
|
179
214
|
this.start();
|
|
180
215
|
}
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
this.updateValue();
|
|
184
|
-
}
|
|
185
|
-
else if (attribute === FOCUS) {
|
|
186
|
-
this.focus();
|
|
187
|
-
}
|
|
188
|
-
else {
|
|
189
|
-
return super.defaultProcessAttributeChange(attribute, value);
|
|
190
|
-
}
|
|
191
|
-
return true;
|
|
216
|
+
updateValue() {
|
|
217
|
+
this.value = this.field?.value;
|
|
192
218
|
}
|
|
193
|
-
updateValue() { this.value = this.field?.value; }
|
|
194
219
|
onInputChange() { setTimeout(() => this.field?.notifyEditionPartial(), 50); }
|
|
195
220
|
onChangeContent() { setTimeout(() => this.field?.notifyEditionFinish(), 50); }
|
|
196
221
|
onShowInfo(detail = null) { setTimeout(() => this.field?.notifyEditionDetailRequest(detail), 50); }
|
|
@@ -204,10 +229,6 @@ class FieldComponent extends ElementComponent {
|
|
|
204
229
|
this.updateObject(false);
|
|
205
230
|
this.onInputChange();
|
|
206
231
|
}
|
|
207
|
-
numberInputValidation(event) {
|
|
208
|
-
const k = event.charCode;
|
|
209
|
-
return (k > 47 && k < 58);
|
|
210
|
-
}
|
|
211
232
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: FieldComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
212
233
|
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.3.12", type: FieldComponent, selector: "lib-field", inputs: { field: "field" }, usesInheritance: true, ngImport: i0, template: `<ng-content></ng-content>`, isInline: true });
|
|
213
234
|
}
|
|
@@ -263,23 +284,31 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImpo
|
|
|
263
284
|
type: Output
|
|
264
285
|
}] } });
|
|
265
286
|
|
|
287
|
+
const CUSTOM_ATTRIBUTES$3 = 'customAttributes';
|
|
288
|
+
const signaledAttributes$3 = [
|
|
289
|
+
'visible', 'disabled',
|
|
290
|
+
];
|
|
266
291
|
class SectionComponent extends PieceComponent {
|
|
267
292
|
section;
|
|
293
|
+
updatePropagatedAttributes() {
|
|
294
|
+
this.updatePieceAttributes(this.section, signaledAttributes$3);
|
|
295
|
+
}
|
|
268
296
|
ngOnInit() {
|
|
297
|
+
if (!this.section) {
|
|
298
|
+
return;
|
|
299
|
+
}
|
|
269
300
|
this.formConfig = this.section?._formConfig;
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
const attrName = mapping[index].toString();
|
|
273
|
-
const attributeValue = this.section?.[attrName];
|
|
274
|
-
this.defaultProcessAttributeChange(attrName, attributeValue);
|
|
275
|
-
this.customProcessAttributeChange(attrName, attributeValue);
|
|
276
|
-
}
|
|
277
|
-
// Subscripción a cambios en atributos
|
|
301
|
+
this.updatePropagatedAttributes();
|
|
302
|
+
this.replaceCustomAttributes(this.section?.customAttributes);
|
|
278
303
|
this.section?.attributeChange.subscribe(event => {
|
|
279
|
-
const { name:
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
this.
|
|
304
|
+
const { name: attribute, value = null } = event ?? {};
|
|
305
|
+
const attributeParts = attribute?.split('.') ?? [];
|
|
306
|
+
if (signaledAttributes$3.includes(attribute)) {
|
|
307
|
+
this.updatePieceAttribute(signaledAttributes$3, attribute, value);
|
|
308
|
+
}
|
|
309
|
+
else if (attributeParts?.length > 1 && attributeParts?.[0] === CUSTOM_ATTRIBUTES$3) {
|
|
310
|
+
const subAttribute = attributeParts?.[1] ?? null;
|
|
311
|
+
this.updateCustomAttribute(subAttribute, value);
|
|
283
312
|
}
|
|
284
313
|
});
|
|
285
314
|
this.start();
|
|
@@ -300,23 +329,31 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImpo
|
|
|
300
329
|
type: Input
|
|
301
330
|
}] } });
|
|
302
331
|
|
|
332
|
+
const CUSTOM_ATTRIBUTES$2 = 'customAttributes';
|
|
333
|
+
const signaledAttributes$2 = [
|
|
334
|
+
'visible', 'disabled',
|
|
335
|
+
];
|
|
303
336
|
class SubSectionComponent extends PieceComponent {
|
|
304
337
|
subSection;
|
|
338
|
+
updatePropagatedAttributes() {
|
|
339
|
+
this.updatePieceAttributes(this.subSection, signaledAttributes$2);
|
|
340
|
+
}
|
|
305
341
|
ngOnInit() {
|
|
342
|
+
if (!this.subSection) {
|
|
343
|
+
return;
|
|
344
|
+
}
|
|
306
345
|
this.formConfig = this.subSection?._formConfig;
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
const attrName = mapping[index].toString();
|
|
310
|
-
const attributeValue = this.subSection?.[attrName];
|
|
311
|
-
this.defaultProcessAttributeChange(attrName, attributeValue);
|
|
312
|
-
this.customProcessAttributeChange(attrName, attributeValue);
|
|
313
|
-
}
|
|
314
|
-
// Subscripción a cambios en atributos
|
|
346
|
+
this.updatePropagatedAttributes();
|
|
347
|
+
this.replaceCustomAttributes(this.subSection?.customAttributes);
|
|
315
348
|
this.subSection?.attributeChange.subscribe(event => {
|
|
316
|
-
const { name:
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
this.
|
|
349
|
+
const { name: attribute, value = null } = event ?? {};
|
|
350
|
+
const attributeParts = attribute?.split('.') ?? [];
|
|
351
|
+
if (signaledAttributes$2.includes(attribute)) {
|
|
352
|
+
this.updatePieceAttribute(signaledAttributes$2, attribute, value);
|
|
353
|
+
}
|
|
354
|
+
else if (attributeParts?.length > 1 && attributeParts?.[0] === CUSTOM_ATTRIBUTES$2) {
|
|
355
|
+
const subAttribute = attributeParts?.[1] ?? null;
|
|
356
|
+
this.updateCustomAttribute(subAttribute, value);
|
|
320
357
|
}
|
|
321
358
|
});
|
|
322
359
|
this.start();
|
|
@@ -338,21 +375,25 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImpo
|
|
|
338
375
|
}] } });
|
|
339
376
|
|
|
340
377
|
const INLINE_ACTION$1 = 'INLINE';
|
|
378
|
+
const CUSTOM_ATTRIBUTES$1 = 'customAttributes';
|
|
379
|
+
const signaledAttributes$1 = [
|
|
380
|
+
'visible', 'disabled',
|
|
381
|
+
];
|
|
341
382
|
class LibTableRecordActionComponent extends PieceComponent {
|
|
342
|
-
isVisible = true;
|
|
343
383
|
recordId;
|
|
344
384
|
recordData;
|
|
345
385
|
action;
|
|
346
386
|
actionSelected = new EventEmitter();
|
|
387
|
+
updatePropagatedAttributes() {
|
|
388
|
+
this.updatePieceAttributes(this.action, signaledAttributes$1);
|
|
389
|
+
}
|
|
347
390
|
ngOnInit() {
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
for (let index = 0; index < mapping.length; index++) {
|
|
351
|
-
const attrName = mapping[index].toString();
|
|
352
|
-
const attributeValue = this.action?.[attrName];
|
|
353
|
-
this.defaultProcessAttributeChange(attrName, attributeValue);
|
|
354
|
-
this.customProcessAttributeChange(attrName, attributeValue);
|
|
391
|
+
if (!this.action) {
|
|
392
|
+
return;
|
|
355
393
|
}
|
|
394
|
+
this.formConfig = this.action?._formConfig;
|
|
395
|
+
this.updatePropagatedAttributes();
|
|
396
|
+
this.replaceCustomAttributes(this.action?.customAttributes);
|
|
356
397
|
this.start();
|
|
357
398
|
}
|
|
358
399
|
start() {
|
|
@@ -364,10 +405,10 @@ class LibTableRecordActionComponent extends PieceComponent {
|
|
|
364
405
|
const restrictionValue = this.action.restrictedOnValue;
|
|
365
406
|
if ((restrictionOper === '==' && relatedFieldValue !== restrictionValue)
|
|
366
407
|
|| (restrictionOper === '!=' && relatedFieldValue === restrictionValue)) {
|
|
367
|
-
this.
|
|
408
|
+
this.visible.set(false);
|
|
368
409
|
}
|
|
369
410
|
else {
|
|
370
|
-
this.
|
|
411
|
+
this.visible.set(true);
|
|
371
412
|
}
|
|
372
413
|
}
|
|
373
414
|
}
|
|
@@ -430,10 +471,25 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImpo
|
|
|
430
471
|
type: Input
|
|
431
472
|
}] } });
|
|
432
473
|
|
|
474
|
+
const CUSTOM_ATTRIBUTES = 'customAttributes';
|
|
475
|
+
const signaledAttributes = [
|
|
476
|
+
'allSelected', 'code', 'globalSearch', 'globalFilterString', 'recordsPerPage', 'layout',
|
|
477
|
+
'columns', 'selectedRecords', 'currentPage', 'totalRecordsNumber', 'visibleRecords',
|
|
478
|
+
'visible', 'disabled',
|
|
479
|
+
];
|
|
433
480
|
class LibTableComponent extends ElementComponent {
|
|
434
481
|
// Atributos sincronizados del objeto
|
|
435
|
-
|
|
436
|
-
|
|
482
|
+
allSelected = signal(null);
|
|
483
|
+
code = signal('');
|
|
484
|
+
globalSearch = signal(null);
|
|
485
|
+
globalFilterString = signal('');
|
|
486
|
+
recordsPerPage = signal(null);
|
|
487
|
+
layout = signal(null);
|
|
488
|
+
columns = signal(null);
|
|
489
|
+
selectedRecords = signal(null);
|
|
490
|
+
currentPage = signal(null);
|
|
491
|
+
totalRecordsNumber = signal(null);
|
|
492
|
+
visibleRecords = signal(null);
|
|
437
493
|
tableFieldStyles;
|
|
438
494
|
loaded = false;
|
|
439
495
|
selectable = false;
|
|
@@ -442,7 +498,6 @@ class LibTableComponent extends ElementComponent {
|
|
|
442
498
|
globalActions;
|
|
443
499
|
selectionActions;
|
|
444
500
|
table = null;
|
|
445
|
-
visibleRecords = [];
|
|
446
501
|
waiting = false;
|
|
447
502
|
ngOnInit() {
|
|
448
503
|
if (!this.table) {
|
|
@@ -451,51 +506,42 @@ class LibTableComponent extends ElementComponent {
|
|
|
451
506
|
this.table.setWidget(this);
|
|
452
507
|
this.formConfig = this.table?._formConfig;
|
|
453
508
|
this.tableFieldStyles = this.formConfig?.tableFieldStyles;
|
|
454
|
-
this.selectable = this.table?.
|
|
509
|
+
this.selectable = this.table?._selectable;
|
|
455
510
|
this.hasActions = this.table?.hasActions();
|
|
456
511
|
this.inlineActions = this.table?.getActions(this.formConfig?.tableActions.inline);
|
|
457
512
|
this.globalActions = this.table?.getActions(this.formConfig?.tableActions.global);
|
|
458
513
|
this.selectionActions = this.table?.getActions(this.formConfig?.tableActions.selection);
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
for (let index = 0; index < mapping.length; index++) {
|
|
462
|
-
const tableAttr = mapping[index]?.[0];
|
|
463
|
-
const componentAttr = mapping[index]?.[1]?.toString() ?? '';
|
|
464
|
-
const attributeValue = this.table?.[tableAttr];
|
|
465
|
-
this.defaultProcessAttributeChange(componentAttr, attributeValue);
|
|
466
|
-
this.customProcessAttributeChange(componentAttr, attributeValue);
|
|
467
|
-
}
|
|
468
|
-
// Subscripción a cambios en atributos
|
|
514
|
+
this.updatePropagatedAttributes();
|
|
515
|
+
this.replaceCustomAttributes(this.table?.customAttributes);
|
|
469
516
|
this.table?.attributeChange.subscribe(event => {
|
|
470
|
-
const { name:
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
this.
|
|
517
|
+
const { name: attribute, value = null } = event ?? {};
|
|
518
|
+
const attributeParts = attribute?.split('.') ?? [];
|
|
519
|
+
if (attribute === 'visibleRecords') {
|
|
520
|
+
this.updateTableData();
|
|
521
|
+
}
|
|
522
|
+
else if (signaledAttributes.includes(attribute)) {
|
|
523
|
+
this.updatePieceAttribute(signaledAttributes, attribute, value);
|
|
524
|
+
}
|
|
525
|
+
else if (attributeParts?.length > 1 && attributeParts?.[0] === CUSTOM_ATTRIBUTES) {
|
|
526
|
+
const subAttribute = attributeParts?.[1] ?? null;
|
|
527
|
+
this.updateCustomAttribute(subAttribute, value);
|
|
474
528
|
}
|
|
475
529
|
});
|
|
476
530
|
this.start();
|
|
477
531
|
}
|
|
532
|
+
updatePropagatedAttributes() {
|
|
533
|
+
this.updatePieceAttributes(this.table, signaledAttributes);
|
|
534
|
+
}
|
|
478
535
|
updateTableData() { }
|
|
479
536
|
tableGlobalAction(actionCode) { this.table?.notifyGlobalAction(actionCode); }
|
|
480
537
|
tableSelectionAction(actionCode) { this.table?.notifySelectionAction(actionCode); }
|
|
481
538
|
tableActionSelected(actionEvent) { this.table?.notifyInlineAction(actionEvent); }
|
|
482
539
|
tableSelectionToggle(recordId) { this.table?.notifyRecordSelection(recordId); }
|
|
483
|
-
toggleSelectAll() { return (this.table?.
|
|
540
|
+
toggleSelectAll() { return (this.table?._allSelected) ? this.table?.unSelectAll() : this.table?.selectAll(); }
|
|
484
541
|
globalFilterCompleted() { this.changePage(1); }
|
|
485
542
|
changePage(requestedPage) { this.table?.changePage(requestedPage); }
|
|
486
543
|
tableColumnSort(columnName, direction = null) { this.table?.sort(columnName, direction ?? 'ascend'); }
|
|
487
544
|
globalFilterChanged() { this.table?.setGlobalFilterString(this.globalFilterString?.trim() ?? '', false); }
|
|
488
|
-
defaultProcessAttributeChange(attribute, value) {
|
|
489
|
-
try {
|
|
490
|
-
if (attribute === 'visibleRecords') {
|
|
491
|
-
this.updateTableData();
|
|
492
|
-
}
|
|
493
|
-
return super.defaultProcessAttributeChange(attribute, value);
|
|
494
|
-
}
|
|
495
|
-
catch {
|
|
496
|
-
return false;
|
|
497
|
-
}
|
|
498
|
-
}
|
|
499
545
|
filterHasChanged(column, values) {
|
|
500
546
|
if (!values || values.length === 0) {
|
|
501
547
|
this.table?.removeColumnFilter(column.fieldCode);
|
|
@@ -505,7 +551,7 @@ class LibTableComponent extends ElementComponent {
|
|
|
505
551
|
}
|
|
506
552
|
}
|
|
507
553
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: LibTableComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
508
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.3.12", type: LibTableComponent, selector: "lib-table", inputs: { table: "table",
|
|
554
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.3.12", type: LibTableComponent, selector: "lib-table", inputs: { table: "table", waiting: "waiting" }, usesInheritance: true, ngImport: i0, template: `<ng-content></ng-content>`, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
509
555
|
}
|
|
510
556
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: LibTableComponent, decorators: [{
|
|
511
557
|
type: Component,
|
|
@@ -516,8 +562,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImpo
|
|
|
516
562
|
}]
|
|
517
563
|
}], propDecorators: { table: [{
|
|
518
564
|
type: Input
|
|
519
|
-
}], visibleRecords: [{
|
|
520
|
-
type: Input
|
|
521
565
|
}], waiting: [{
|
|
522
566
|
type: Input
|
|
523
567
|
}] } });
|
|
@@ -719,8 +763,13 @@ class FormElement extends FormPiecePropagate {
|
|
|
719
763
|
}
|
|
720
764
|
setAttr(attr, value) {
|
|
721
765
|
const { name: attrName, propagate: name } = attr;
|
|
722
|
-
|
|
723
|
-
|
|
766
|
+
try {
|
|
767
|
+
this[attrName] = value;
|
|
768
|
+
name && this.propagateAttribute(name, value);
|
|
769
|
+
}
|
|
770
|
+
catch (e) {
|
|
771
|
+
console.log(`Atributo ${attrName} no presente o valor ${value} inconsistente. ${e}`);
|
|
772
|
+
}
|
|
724
773
|
}
|
|
725
774
|
isField() { return this.elementType === elementTypes.field; }
|
|
726
775
|
isAction() { return this.elementType === elementTypes.action; }
|
|
@@ -728,60 +777,84 @@ class FormElement extends FormPiecePropagate {
|
|
|
728
777
|
}
|
|
729
778
|
|
|
730
779
|
const HEADER = 'HEADER';
|
|
780
|
+
const attrs$2 = {
|
|
781
|
+
actionCode: { name: '_actionCode', propagate: 'actionCode' },
|
|
782
|
+
actionName: { name: '_actionName', propagate: 'actionName' },
|
|
783
|
+
iconName: { name: '_iconName', propagate: 'iconName' },
|
|
784
|
+
inProgress: { name: '_inProgress', propagate: 'inProgress' },
|
|
785
|
+
restrictedOnField: { name: '_restrictedOnField', propagate: 'restrictedOnField' },
|
|
786
|
+
restrictedOnOperator: { name: '_restrictedOnOperator', propagate: 'restrictedOnOperator' },
|
|
787
|
+
restrictedOnValue: { name: '_restrictedOnValue', propagate: 'restrictedOnValue' },
|
|
788
|
+
};
|
|
731
789
|
class FormAction extends FormElement {
|
|
732
790
|
_actionActivated = new Subject();
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
customValidation;
|
|
791
|
+
_actionCode = '';
|
|
792
|
+
_actionName = '';
|
|
793
|
+
_iconName = '';
|
|
794
|
+
_inProgress = false;
|
|
795
|
+
_newState;
|
|
796
|
+
_backend;
|
|
797
|
+
_restrictedOnField = null;
|
|
798
|
+
_restrictedOnOperator = null;
|
|
799
|
+
_restrictedOnValue = null;
|
|
743
800
|
constructor(actionDefinition, formConfig) {
|
|
744
801
|
super(actionDefinition, formConfig);
|
|
745
802
|
this.propagationCustomAttributes = this._formConfig?.propagationCustomAttributes?.actions ?? [];
|
|
746
803
|
this.elementType = elementTypes.action;
|
|
747
|
-
this.actionCode
|
|
748
|
-
this.actionName
|
|
749
|
-
this.iconName
|
|
804
|
+
this.setAttr(attrs$2.actionCode, actionDefinition.actionCode ? actionDefinition.actionCode.toString() : '');
|
|
805
|
+
this.setAttr(attrs$2.actionName, actionDefinition.actionTitle);
|
|
806
|
+
this.setAttr(attrs$2.iconName, actionDefinition.iconName || this._actionCode);
|
|
807
|
+
this.setAttr(attrs$2.restrictedOnField, actionDefinition.fieldRestrictedCode?.toString() ?? null);
|
|
808
|
+
if (this._restrictedOnField) {
|
|
809
|
+
this.setAttr(attrs$2.restrictedOnOperator, actionDefinition.operatorRestricted || '');
|
|
810
|
+
this.setAttr(attrs$2.restrictedOnValue, actionDefinition.valueRestricted ?? '');
|
|
811
|
+
}
|
|
812
|
+
this._backend = actionDefinition?.serverAction ?? false;
|
|
813
|
+
this._newState = actionDefinition?.newState;
|
|
750
814
|
this.setCustomAttribute('location', actionDefinition.position || HEADER);
|
|
751
|
-
this.backend = actionDefinition?.serverAction ?? false;
|
|
752
|
-
this.newState = actionDefinition?.newState;
|
|
753
|
-
this.restrictedOnField = actionDefinition.fieldRestrictedCode?.toString() ?? null;
|
|
754
|
-
if (this.restrictedOnField) {
|
|
755
|
-
this.restrictedOnOperator = actionDefinition.operatorRestricted || '';
|
|
756
|
-
this.restrictedOnValue = actionDefinition.valueRestricted ?? '';
|
|
757
|
-
}
|
|
758
|
-
this.customValidation = () => true;
|
|
759
815
|
}
|
|
816
|
+
get actionCode() { return this._actionCode; }
|
|
817
|
+
get actionName() { return this._actionName; }
|
|
818
|
+
get iconName() { return this._iconName; }
|
|
819
|
+
get inProgress() { return this._inProgress; }
|
|
820
|
+
get newState() { return this._newState; }
|
|
821
|
+
get backend() { return this._backend; }
|
|
822
|
+
get restrictedOnField() { return this._restrictedOnField; }
|
|
823
|
+
get restrictedOnOperator() { return this._restrictedOnOperator; }
|
|
824
|
+
get restrictedOnValue() { return this._restrictedOnValue; }
|
|
825
|
+
set actionCode(actionCode) { this.setAttr(attrs$2.actionCode, actionCode); }
|
|
826
|
+
set actionName(actionName) { this.setAttr(attrs$2.actionName, actionName); }
|
|
827
|
+
set iconName(iconName) { this.setAttr(attrs$2.iconName, iconName); }
|
|
828
|
+
set inProgress(inProgress) { this.setAttr(attrs$2.inProgress, inProgress); }
|
|
829
|
+
set newState(newState) { this._newState, newState; }
|
|
830
|
+
set backend(backend) { this._backend, backend; }
|
|
831
|
+
set restrictedOnField(restrictedOnField) { this.setAttr(attrs$2.restrictedOnField, restrictedOnField); }
|
|
832
|
+
set restrictedOnOperator(restrictedOnOperator) { this.setAttr(attrs$2.restrictedOnOperator, restrictedOnOperator); }
|
|
833
|
+
set restrictedOnValue(restrictedOnValue) { this.setAttr(attrs$2.restrictedOnValue, restrictedOnValue); }
|
|
834
|
+
start() { this.inProgress = true; }
|
|
835
|
+
stop() { this.inProgress = false; }
|
|
760
836
|
connectWithParentForm(form, formChangeSubject) {
|
|
761
837
|
super.connectWithParentForm(form, formChangeSubject);
|
|
762
|
-
if (this.
|
|
763
|
-
const relatedField = this._form.fields?.[this.
|
|
838
|
+
if (this._restrictedOnField) {
|
|
839
|
+
const relatedField = this._form.fields?.[this._restrictedOnField];
|
|
764
840
|
if (relatedField) {
|
|
765
|
-
relatedField.editionFinish.subscribe(event => this.updateRestrictedVisibility());
|
|
766
|
-
relatedField.editionPartial.subscribe(event => this.updateRestrictedVisibility());
|
|
841
|
+
relatedField.editionFinish.subscribe(event => this.updateRestrictedVisibility(event));
|
|
842
|
+
relatedField.editionPartial.subscribe(event => this.updateRestrictedVisibility(event));
|
|
767
843
|
}
|
|
768
844
|
}
|
|
769
845
|
}
|
|
770
|
-
updateRestrictedVisibility() {
|
|
771
|
-
const lastVisible = this._visible;
|
|
846
|
+
updateRestrictedVisibility(event) {
|
|
772
847
|
const newVisible = this._absoluteVisible && this.viewOnState(this._formState);
|
|
773
|
-
|
|
774
|
-
this.setVisibility(newVisible);
|
|
775
|
-
}
|
|
848
|
+
(this._visible !== newVisible) && this.setVisibility(newVisible);
|
|
776
849
|
}
|
|
777
850
|
viewOnState(state) {
|
|
778
851
|
const actionVisible = (this.visibleStates && state) ? this.visibleStates.includes(state) : false;
|
|
779
|
-
if (actionVisible && this._form && this.
|
|
780
|
-
const relatedField = this._form.fields?.[this.
|
|
852
|
+
if (actionVisible && this._form && this._restrictedOnField) {
|
|
853
|
+
const relatedField = this._form.fields?.[this._restrictedOnField];
|
|
781
854
|
if (relatedField) {
|
|
782
855
|
const fieldValue = relatedField.value;
|
|
783
|
-
if ((this.
|
|
784
|
-
|| (this.
|
|
856
|
+
if ((this._restrictedOnOperator === '==' && fieldValue !== this._restrictedOnValue)
|
|
857
|
+
|| (this._restrictedOnOperator === '!=' && fieldValue === this._restrictedOnValue)) {
|
|
785
858
|
return false;
|
|
786
859
|
}
|
|
787
860
|
}
|
|
@@ -789,17 +862,19 @@ class FormAction extends FormElement {
|
|
|
789
862
|
return actionVisible;
|
|
790
863
|
}
|
|
791
864
|
get actionActivated() { return this._actionActivated; }
|
|
792
|
-
|
|
793
|
-
stop() { this.inProgress = false; }
|
|
794
|
-
notifyActivation() { this._actionActivated.next(this.actionCode); }
|
|
865
|
+
notifyActivation() { this._actionActivated.next(this._actionCode); }
|
|
795
866
|
updateFromServer(receivedAction) {
|
|
796
867
|
for (const propertyName in receivedAction) {
|
|
797
868
|
if (propertyName !== 'actionCode' && propertyName !== 'actionId') {
|
|
798
|
-
|
|
869
|
+
try {
|
|
870
|
+
this[propertyName] = receivedAction[propertyName];
|
|
871
|
+
}
|
|
872
|
+
catch (e) {
|
|
873
|
+
console.log(`Error actualizando la propiedad ${propertyName} de la acción ${this.actionCode}. ${e}`);
|
|
874
|
+
}
|
|
799
875
|
}
|
|
800
876
|
}
|
|
801
877
|
}
|
|
802
|
-
setCustomValidation(callback) { this.customValidation = () => callback(); }
|
|
803
878
|
}
|
|
804
879
|
|
|
805
880
|
const UNDEFINED = 'undefined';
|
|
@@ -815,34 +890,34 @@ const directChanges = [
|
|
|
815
890
|
'options', 'placeholder',
|
|
816
891
|
];
|
|
817
892
|
const attrs$1 = {
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
fieldCode: { name: '
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
fieldOptions: { name: '
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
893
|
+
captureType: { name: '_captureType', propagate: 'captureType' },
|
|
894
|
+
errorCode: { name: '_errorCode', propagate: 'errorCode' },
|
|
895
|
+
errorMessage: { name: '_errorMessage', propagate: 'errorMessage' },
|
|
896
|
+
errorType: { name: '_errorType', propagate: 'errorType' },
|
|
897
|
+
defaultValue: { name: '_defaultValue', propagate: 'defaultValue' },
|
|
898
|
+
defaultEditable: { name: '_defaultEditable', propagate: 'defaultEditable' },
|
|
899
|
+
fieldAlignment: { name: '_fieldAlignment', propagate: 'alignment' },
|
|
900
|
+
fieldCode: { name: '_fieldCode', propagate: 'code' },
|
|
901
|
+
fieldInfo: { name: '_fieldInfo', propagate: 'info' },
|
|
902
|
+
fieldRequired: { name: '_fieldRequired', propagate: 'required' },
|
|
903
|
+
fieldTitle: { name: '_fieldTitle', propagate: 'title' },
|
|
904
|
+
fieldType: { name: '_fieldType', propagate: 'type' },
|
|
905
|
+
fieldFormat: { name: '_fieldFormat', propagate: 'format' },
|
|
906
|
+
fieldOptions: { name: '_fieldOptions', propagate: 'options' },
|
|
907
|
+
focus: { name: '_focus', propagate: 'focus' },
|
|
908
|
+
hasChanged: { name: '_hasChanged', propagate: 'hasChanged' },
|
|
909
|
+
intrinsicErrorMessage: { name: '_intrinsicErrorMessage', propagate: null },
|
|
910
|
+
maxLength: { name: '_maxLength', propagate: 'maxLength' },
|
|
911
|
+
maxValue: { name: '_maxValue', propagate: 'maxValue' },
|
|
912
|
+
minLength: { name: '_minLength', propagate: 'minLength' },
|
|
913
|
+
minValue: { name: '_minValue', propagate: 'minValue' },
|
|
914
|
+
onValidation: { name: '_onValidation', propagate: 'onValidation' },
|
|
915
|
+
outputOnly: { name: '_outputOnly', propagate: 'outputOnly' },
|
|
916
|
+
placeholder: { name: '_placeholder', propagate: 'placeholder' },
|
|
917
|
+
tooltipText: { name: '_tooltipText', propagate: 'tooltip' },
|
|
918
|
+
validateOnServer: { name: '_validateOnServer', propagate: 'validateOnServer' },
|
|
919
|
+
value: { name: '_value', propagate: 'value' },
|
|
920
|
+
visibleLabel: { name: '_visibleLabel', propagate: 'visibleLabel' },
|
|
846
921
|
};
|
|
847
922
|
class FieldDescriptor extends FormElement {
|
|
848
923
|
_editionFinish = new Subject();
|
|
@@ -875,15 +950,15 @@ class FieldDescriptor extends FormElement {
|
|
|
875
950
|
_outputOnly = false;
|
|
876
951
|
_tooltipText = '';
|
|
877
952
|
_placeholder = '';
|
|
878
|
-
|
|
879
|
-
|
|
953
|
+
_fieldCode = '';
|
|
954
|
+
_fieldOptions = null;
|
|
880
955
|
constructor(inputFieldReceived, formConfig) {
|
|
881
956
|
super(inputFieldReceived, formConfig);
|
|
882
957
|
this.propagationCustomAttributes = this._formConfig?.propagationCustomAttributes?.fields ?? [];
|
|
883
958
|
this.elementType = elementTypes.field;
|
|
884
959
|
const fld = (inputFieldReceived) ? inputFieldReceived : {};
|
|
885
960
|
this.setAttr(attrs$1.fieldCode, fld.fieldCode);
|
|
886
|
-
this.title = fld.fieldTitle ?? this.
|
|
961
|
+
this.title = fld.fieldTitle ?? this._fieldCode;
|
|
887
962
|
this.placeholder = fld.placeholder ?? this.title;
|
|
888
963
|
this.type = fld.fieldTypeCode;
|
|
889
964
|
this.captureType = fld.captureType ?? DEFAULT_CAPTURE_TYPE;
|
|
@@ -901,7 +976,12 @@ class FieldDescriptor extends FormElement {
|
|
|
901
976
|
this.info = fld.info || '';
|
|
902
977
|
let fieldFormat;
|
|
903
978
|
try {
|
|
904
|
-
|
|
979
|
+
if (fld.format && typeof fld.format === 'string') {
|
|
980
|
+
fieldFormat = new RegExp(fld.format);
|
|
981
|
+
}
|
|
982
|
+
else if (fld.format?.regExp) {
|
|
983
|
+
fieldFormat = new RegExp(fld.format?.regExp);
|
|
984
|
+
}
|
|
905
985
|
}
|
|
906
986
|
catch (e) {
|
|
907
987
|
fieldFormat = null;
|
|
@@ -924,17 +1004,17 @@ class FieldDescriptor extends FormElement {
|
|
|
924
1004
|
this._setValue(fld.fieldValue ?? this._defaultValue ?? '');
|
|
925
1005
|
}
|
|
926
1006
|
get alignment() { return this._fieldAlignment; }
|
|
927
|
-
set alignment(alignment) { this.setAttr(attrs$1.
|
|
1007
|
+
set alignment(alignment) { this.setAttr(attrs$1.fieldAlignment, alignment); }
|
|
928
1008
|
get backend() { return this._validateOnServer; }
|
|
929
1009
|
get captureType() { return this._captureType; }
|
|
930
|
-
set captureType(captureType) { this.setAttr(attrs$1.
|
|
1010
|
+
set captureType(captureType) { this.setAttr(attrs$1.captureType, captureType); }
|
|
931
1011
|
get placeholder() { return this._placeholder; }
|
|
932
|
-
set placeholder(placeholder) { this.setAttr(attrs$1.
|
|
933
|
-
get code() { return this.
|
|
1012
|
+
set placeholder(placeholder) { this.setAttr(attrs$1.placeholder, placeholder); }
|
|
1013
|
+
get code() { return this._fieldCode; }
|
|
934
1014
|
get defaultValue() { return this._defaultValue; }
|
|
935
|
-
set defaultValue(defaultValue) { this.setAttr(attrs$1.
|
|
1015
|
+
set defaultValue(defaultValue) { this.setAttr(attrs$1.defaultValue, defaultValue); }
|
|
936
1016
|
get defaultEditable() { return this._defaultEditable; }
|
|
937
|
-
set defaultEditable(editable) { this.setAttr(attrs$1.
|
|
1017
|
+
set defaultEditable(editable) { this.setAttr(attrs$1.defaultEditable, editable); }
|
|
938
1018
|
get detailRequest() { return this._detailRequest; }
|
|
939
1019
|
get editionFinish() { return this._editionFinish; }
|
|
940
1020
|
get editionPartial() { return this._editionPartial; }
|
|
@@ -979,25 +1059,25 @@ class FieldDescriptor extends FormElement {
|
|
|
979
1059
|
get errorType() { return this._errorType; }
|
|
980
1060
|
get externalValue() { return this._externalValue; }
|
|
981
1061
|
get format() { return this._fieldFormat; }
|
|
982
|
-
set format(format) { this.setAttr(attrs$1.
|
|
1062
|
+
set format(format) { this.setAttr(attrs$1.fieldFormat, format); }
|
|
983
1063
|
get hasChanged() { return this._hasChanged; }
|
|
984
|
-
set hasChanged(hasChanged) { this.setAttr(attrs$1.
|
|
1064
|
+
set hasChanged(hasChanged) { this.setAttr(attrs$1.hasChanged, hasChanged); }
|
|
985
1065
|
get info() { return this._fieldInfo; }
|
|
986
|
-
set info(newInfo) { this.setAttr(attrs$1.
|
|
987
|
-
set intrinsicErrorMessage(message) { this.setAttr(attrs$1.
|
|
1066
|
+
set info(newInfo) { this.setAttr(attrs$1.fieldInfo, newInfo); }
|
|
1067
|
+
set intrinsicErrorMessage(message) { this.setAttr(attrs$1.intrinsicErrorMessage, message); }
|
|
988
1068
|
get maxLength() { return (this._maxLength > 0) ? this._maxLength.toString() : ''; }
|
|
989
|
-
set maxLength(requiredMaxLength) { this.setAttr(attrs$1.
|
|
1069
|
+
set maxLength(requiredMaxLength) { this.setAttr(attrs$1.maxLength, requiredMaxLength ? +requiredMaxLength : null); }
|
|
990
1070
|
get maxValue() { return this._maxValue; }
|
|
991
1071
|
set maxValue(inputMaxValue) {
|
|
992
1072
|
let maxValue = inputMaxValue;
|
|
993
1073
|
if (this._fieldType === this._formConfig.fieldTypes.date) {
|
|
994
1074
|
maxValue = new Date(maxValue);
|
|
995
1075
|
}
|
|
996
|
-
this.setAttr(attrs$1.
|
|
1076
|
+
this.setAttr(attrs$1.maxValue, maxValue);
|
|
997
1077
|
}
|
|
998
1078
|
get minLength() { return this._minLength; }
|
|
999
1079
|
set minLength(requiredMinLength) {
|
|
1000
|
-
this.setAttr(attrs$1.
|
|
1080
|
+
this.setAttr(attrs$1.minLength, requiredMinLength ? +requiredMinLength : null);
|
|
1001
1081
|
}
|
|
1002
1082
|
get minValue() { return this._minValue; }
|
|
1003
1083
|
set minValue(inputMinValue) {
|
|
@@ -1005,11 +1085,11 @@ class FieldDescriptor extends FormElement {
|
|
|
1005
1085
|
if (this._fieldType === this._formConfig.fieldTypes.date) {
|
|
1006
1086
|
minValue = new Date(minValue);
|
|
1007
1087
|
}
|
|
1008
|
-
this.setAttr(attrs$1.
|
|
1088
|
+
this.setAttr(attrs$1.minValue, minValue);
|
|
1009
1089
|
}
|
|
1010
|
-
get name() { return this.
|
|
1090
|
+
get name() { return this._fieldCode; }
|
|
1011
1091
|
get options() {
|
|
1012
|
-
return this.
|
|
1092
|
+
return this._fieldOptions?.map(option => {
|
|
1013
1093
|
const optionCopy = { ...option };
|
|
1014
1094
|
return optionCopy;
|
|
1015
1095
|
}) ?? null;
|
|
@@ -1032,45 +1112,46 @@ class FieldDescriptor extends FormElement {
|
|
|
1032
1112
|
this.setAttr(attrs$1.fieldOptions, fieldOptions);
|
|
1033
1113
|
if (this._value) {
|
|
1034
1114
|
if (this._fieldType === this._formConfig.fieldTypes.array && Array.isArray(this._value)) {
|
|
1035
|
-
const fieldValue = this._value?.filter(item => this.
|
|
1036
|
-
this.setAttr(attrs$1.
|
|
1115
|
+
const fieldValue = this._value?.filter(item => this._fieldOptions?.find(opt => opt.fieldOptionId === item));
|
|
1116
|
+
this.setAttr(attrs$1.value, fieldValue);
|
|
1037
1117
|
}
|
|
1038
1118
|
else {
|
|
1039
|
-
const valInOptions = this.
|
|
1119
|
+
const valInOptions = this._fieldOptions?.find(item => item.fieldOptionId === this._value);
|
|
1040
1120
|
if (!valInOptions) {
|
|
1041
1121
|
this._setValue('');
|
|
1042
1122
|
}
|
|
1043
1123
|
}
|
|
1044
1124
|
}
|
|
1045
|
-
if (this._fieldRequired && this.
|
|
1046
|
-
this._setValue(this.
|
|
1125
|
+
if (this._fieldRequired && this._fieldOptions?.length === 1 && this._value !== this._fieldOptions?.[0].fieldOptionId) {
|
|
1126
|
+
this._setValue(this._fieldOptions?.[0].fieldOptionId);
|
|
1047
1127
|
this.notifyEditionFinish();
|
|
1048
1128
|
}
|
|
1049
1129
|
}
|
|
1050
|
-
get optionText() { return this.
|
|
1130
|
+
get optionText() { return this._fieldOptions?.find(item => item.fieldOptionId === this._value)?.fieldOptionValue ?? null; }
|
|
1051
1131
|
get outputOnly() { return this._outputOnly; }
|
|
1052
|
-
set outputOnly(outputOnly) { this.setAttr(attrs$1.
|
|
1132
|
+
set outputOnly(outputOnly) { this.setAttr(attrs$1.outputOnly, outputOnly); }
|
|
1053
1133
|
get required() { return this._fieldRequired; }
|
|
1054
|
-
set required(required) { this.setAttr(attrs$1.
|
|
1134
|
+
set required(required) { this.setAttr(attrs$1.fieldRequired, required ?? false); }
|
|
1055
1135
|
get title() { return this._fieldTitle; }
|
|
1056
|
-
set title(title) { this.setAttr(attrs$1.
|
|
1136
|
+
set title(title) { this.setAttr(attrs$1.fieldTitle, title?.toString() ?? ''); }
|
|
1057
1137
|
get tooltip() { return this._tooltipText; }
|
|
1058
|
-
set tooltip(tooltip) { this.setAttr(attrs$1.
|
|
1138
|
+
set tooltip(tooltip) { this.setAttr(attrs$1.tooltipText, tooltip); }
|
|
1059
1139
|
get type() { return this._fieldType; }
|
|
1060
|
-
set type(fieldType) { this.setAttr(attrs$1.
|
|
1140
|
+
set type(fieldType) { this.setAttr(attrs$1.fieldType, fieldType); }
|
|
1141
|
+
get onValidation() { return this._onValidation; }
|
|
1061
1142
|
get validating() { return this._onValidation; }
|
|
1062
|
-
set validating(isValidating) { this.setAttr(attrs$1.
|
|
1143
|
+
set validating(isValidating) { this.setAttr(attrs$1.onValidation, isValidating); }
|
|
1063
1144
|
get value() {
|
|
1064
1145
|
return (this._fieldType === this._formConfig.fieldTypes.boolean
|
|
1065
1146
|
|| this._fieldType === this._formConfig.fieldTypes.check) ? yn(this._value) : this._value;
|
|
1066
1147
|
}
|
|
1067
1148
|
get validateOnServer() { return this._validateOnServer; }
|
|
1068
|
-
set validateOnServer(validateOnServer) { this.setAttr(attrs$1.
|
|
1149
|
+
set validateOnServer(validateOnServer) { this.setAttr(attrs$1.validateOnServer, validateOnServer); }
|
|
1069
1150
|
get serverAction() { return this._validateOnServer; }
|
|
1070
1151
|
set serverAction(validateOnServer) { this.validateOnServer = validateOnServer; }
|
|
1071
1152
|
set value(newValue) { this._setValue(newValue); }
|
|
1072
1153
|
get visibleLabel() { return this._visibleLabel; }
|
|
1073
|
-
set visibleLabel(visibleLabel) { this.setAttr(attrs$1.
|
|
1154
|
+
set visibleLabel(visibleLabel) { this.setAttr(attrs$1.visibleLabel, visibleLabel); }
|
|
1074
1155
|
/**
|
|
1075
1156
|
* @deprecated Use value
|
|
1076
1157
|
*/
|
|
@@ -1080,7 +1161,7 @@ class FieldDescriptor extends FormElement {
|
|
|
1080
1161
|
*/
|
|
1081
1162
|
changed(hasChanged = true) { this.hasChanged = hasChanged; }
|
|
1082
1163
|
clean() { this._setValue(this._defaultValue || ''); this.resetError(); }
|
|
1083
|
-
focus() { this.setAttr(attrs$1.
|
|
1164
|
+
focus() { this.setAttr(attrs$1.focus, true); }
|
|
1084
1165
|
getErrorCode() { return this.error.code; }
|
|
1085
1166
|
setErrorCode(code) { this.setError(code, this._errorMessage); }
|
|
1086
1167
|
getErrorMessage() { return this.error.message; }
|
|
@@ -1092,6 +1173,10 @@ class FieldDescriptor extends FormElement {
|
|
|
1092
1173
|
setEditable(editable = true) { (editable) ? this.enable() : this.disable(); }
|
|
1093
1174
|
setValue(newValue, widgetUpdate = true) { this._setValue(newValue, widgetUpdate); }
|
|
1094
1175
|
showLabel() { this.visibleLabel = true; }
|
|
1176
|
+
/**
|
|
1177
|
+
* @deprecated Use code
|
|
1178
|
+
*/
|
|
1179
|
+
get fieldCode() { return this._fieldCode; }
|
|
1095
1180
|
/**
|
|
1096
1181
|
* @deprecated Use title
|
|
1097
1182
|
*/
|
|
@@ -1146,7 +1231,7 @@ class FieldDescriptor extends FormElement {
|
|
|
1146
1231
|
setVisibleLabel(visibleLabel) { this.visibleLabel = visibleLabel; }
|
|
1147
1232
|
notifyEditionPartial() {
|
|
1148
1233
|
this.resetError();
|
|
1149
|
-
this._editionPartial.next({ code: this.
|
|
1234
|
+
this._editionPartial.next({ code: this._fieldCode, intrinsicValidation: true });
|
|
1150
1235
|
}
|
|
1151
1236
|
notifyEditionFinish() {
|
|
1152
1237
|
const fieldValue = this.value;
|
|
@@ -1182,16 +1267,16 @@ class FieldDescriptor extends FormElement {
|
|
|
1182
1267
|
intrinsicValidation = false;
|
|
1183
1268
|
this.setError('99', `Longitud de ${this._fieldTitle} debe ser de al menos ${this._minLength}`);
|
|
1184
1269
|
}
|
|
1185
|
-
this._editionFinish.next({ code: this.
|
|
1270
|
+
this._editionFinish.next({ code: this._fieldCode, intrinsicValidation });
|
|
1186
1271
|
}
|
|
1187
1272
|
notifyEditionDetailRequest(detail) {
|
|
1188
|
-
const detailEvent = { code: this.
|
|
1273
|
+
const detailEvent = { code: this._fieldCode, detail };
|
|
1189
1274
|
this._detailRequest.next(detailEvent);
|
|
1190
1275
|
}
|
|
1191
1276
|
setError(code, message, type = DEFAULT_ERROR_TYPE) {
|
|
1192
|
-
this.setAttr(attrs$1.
|
|
1193
|
-
this.setAttr(attrs$1.
|
|
1194
|
-
this.setAttr(attrs$1.
|
|
1277
|
+
this.setAttr(attrs$1.errorCode, code ?? NO_ERROR);
|
|
1278
|
+
this.setAttr(attrs$1.errorType, (this._errorCode === NO_ERROR) ? '' : type);
|
|
1279
|
+
this.setAttr(attrs$1.errorMessage, message ?? '');
|
|
1195
1280
|
}
|
|
1196
1281
|
updateFromServer(fld) {
|
|
1197
1282
|
const fieldKeys = Object.keys(fld);
|
|
@@ -1246,7 +1331,7 @@ class FieldDescriptor extends FormElement {
|
|
|
1246
1331
|
if (this._value !== newFinalValue) {
|
|
1247
1332
|
this.hasChanged = true;
|
|
1248
1333
|
if (widgetUpdate) {
|
|
1249
|
-
this.setAttr(attrs$1.
|
|
1334
|
+
this.setAttr(attrs$1.value, newFinalValue);
|
|
1250
1335
|
}
|
|
1251
1336
|
else {
|
|
1252
1337
|
this._value = newFinalValue;
|
|
@@ -1514,47 +1599,47 @@ class RecordTable extends FormElement {
|
|
|
1514
1599
|
selectedRecords;
|
|
1515
1600
|
restrictedId;
|
|
1516
1601
|
layout = null;
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1602
|
+
_globalSearch;
|
|
1603
|
+
_tableRecords;
|
|
1604
|
+
_tableRecordObj = {};
|
|
1605
|
+
_visibleRecords = null;
|
|
1606
|
+
_columns;
|
|
1607
|
+
_selectable;
|
|
1608
|
+
_selectionBackend;
|
|
1609
|
+
_selectionField;
|
|
1610
|
+
_allSelected = false;
|
|
1611
|
+
_tableCode = '';
|
|
1612
|
+
_tableTitle;
|
|
1613
|
+
_currentPage;
|
|
1614
|
+
_totalPages;
|
|
1615
|
+
_requestedPage;
|
|
1616
|
+
_recordsPerPage = 10;
|
|
1617
|
+
_totalRecordsNumber = 0;
|
|
1618
|
+
_recordsNumber = 0;
|
|
1619
|
+
_sorting;
|
|
1620
|
+
_waiting;
|
|
1621
|
+
_clientPaging = true;
|
|
1622
|
+
_sortable;
|
|
1538
1623
|
constructor(tableReceived, formConfig) {
|
|
1539
1624
|
super(tableReceived, formConfig);
|
|
1540
1625
|
this.propagationCustomAttributes = this._formConfig?.propagationCustomAttributes?.tables ?? [];
|
|
1541
1626
|
this.elementType = elementTypes.table;
|
|
1542
|
-
this.
|
|
1543
|
-
this.
|
|
1544
|
-
this.
|
|
1545
|
-
this.
|
|
1546
|
-
this.
|
|
1627
|
+
this._waiting = false;
|
|
1628
|
+
this._currentPage = 1;
|
|
1629
|
+
this._totalPages = 1;
|
|
1630
|
+
this._requestedPage = 1;
|
|
1631
|
+
this._columns = [];
|
|
1547
1632
|
this._tableColumnObj = {};
|
|
1548
1633
|
this._actions = [];
|
|
1549
1634
|
this._actionsObj = {};
|
|
1550
|
-
this.
|
|
1551
|
-
this.
|
|
1635
|
+
this._tableRecords = [];
|
|
1636
|
+
this._globalSearch = false;
|
|
1552
1637
|
this.restrictedId = null;
|
|
1553
|
-
this.
|
|
1638
|
+
this._tableTitle = tableReceived.tableTitle;
|
|
1554
1639
|
this._appendPages = tableReceived?.append ?? false;
|
|
1555
|
-
this.
|
|
1556
|
-
this.
|
|
1557
|
-
this.
|
|
1640
|
+
this._selectable = tableReceived?.selectable ?? false;
|
|
1641
|
+
this._selectionBackend = tableReceived?.selectionBackend ?? false;
|
|
1642
|
+
this._sortable = tableReceived?.sortable ?? false;
|
|
1558
1643
|
this.setAttr(attrs.allSelected, false);
|
|
1559
1644
|
this.setAttr(attrs.tableCode, tableReceived.tableCode);
|
|
1560
1645
|
this.setAttr(attrs.clientPaging, tableReceived?.clientPaging ?? true);
|
|
@@ -1597,7 +1682,7 @@ class RecordTable extends FormElement {
|
|
|
1597
1682
|
this._actionsObj[inlineAction.actionCode] = inlineAction;
|
|
1598
1683
|
}
|
|
1599
1684
|
}
|
|
1600
|
-
this.
|
|
1685
|
+
this._selectionField = (this._selectable) ? tableReceived?.selectionField : null;
|
|
1601
1686
|
// Filtros predefinidos en el formulario
|
|
1602
1687
|
if (tableReceived.filters) {
|
|
1603
1688
|
for (let index = 0; index < tableReceived.filters.length; index++) {
|
|
@@ -1611,19 +1696,61 @@ class RecordTable extends FormElement {
|
|
|
1611
1696
|
get selectionActionTrigger() { return this._selectionActionTrigger; }
|
|
1612
1697
|
get recordSelectionTrigger() { return this._recordSelectionTrigger; }
|
|
1613
1698
|
get getDataTrigger() { return this._getDataTrigger; }
|
|
1699
|
+
get globalSearch() { return this._globalSearch; }
|
|
1700
|
+
get tableRecords() { return this._tableRecords; }
|
|
1701
|
+
get tableRecordObj() { return this._tableRecordObj; }
|
|
1702
|
+
get visibleRecords() { return this._visibleRecords; }
|
|
1703
|
+
get columns() { return this._columns; }
|
|
1704
|
+
get selectable() { return this._selectable; }
|
|
1705
|
+
get selectionBackend() { return this._selectionBackend; }
|
|
1706
|
+
get selectionField() { return this._selectionField; }
|
|
1707
|
+
get allSelected() { return this._allSelected; }
|
|
1708
|
+
get tableCode() { return this._tableCode; }
|
|
1709
|
+
get tableTitle() { return this._tableTitle; }
|
|
1710
|
+
get currentPage() { return this._currentPage; }
|
|
1711
|
+
get totalPages() { return this._totalPages; }
|
|
1712
|
+
get requestedPage() { return this._requestedPage; }
|
|
1713
|
+
get recordsPerPage() { return this._recordsPerPage; }
|
|
1714
|
+
get totalRecordsNumber() { return this._totalRecordsNumber; }
|
|
1715
|
+
get recordsNumber() { return this._recordsNumber; }
|
|
1716
|
+
get sorting() { return this._sorting; }
|
|
1717
|
+
get waiting() { return this._waiting; }
|
|
1718
|
+
get clientPaging() { return this._clientPaging; }
|
|
1719
|
+
get sortable() { return this._sortable; }
|
|
1720
|
+
set globalSearch(globalSearch) { this._globalSearch = globalSearch; }
|
|
1721
|
+
set tableRecords(tableRecords) { this._tableRecords = tableRecords; }
|
|
1722
|
+
set tableRecordObj(tableRecordObj) { this._tableRecordObj = tableRecordObj; }
|
|
1723
|
+
set visibleRecords(visibleRecords) { this._visibleRecords = visibleRecords; }
|
|
1724
|
+
set columns(columns) { this._columns = columns; }
|
|
1725
|
+
set selectable(selectable) { this._selectable = selectable; }
|
|
1726
|
+
set selectionBackend(selectionBackend) { this._selectionBackend = selectionBackend; }
|
|
1727
|
+
set selectionField(selectionField) { this._selectionField = selectionField; }
|
|
1728
|
+
set allSelected(allSelected) { this._allSelected = allSelected; }
|
|
1729
|
+
set tableCode(tableCode) { this._tableCode = tableCode; }
|
|
1730
|
+
set tableTitle(tableTitle) { this._tableTitle = tableTitle; }
|
|
1731
|
+
set currentPage(currentPage) { this._currentPage = currentPage; }
|
|
1732
|
+
set totalPages(totalPages) { this._totalPages = totalPages; }
|
|
1733
|
+
set requestedPage(requestedPage) { this._requestedPage = requestedPage; }
|
|
1734
|
+
set recordsPerPage(recordsPerPage) { this._recordsPerPage = recordsPerPage; }
|
|
1735
|
+
set totalRecordsNumber(totalRecordsNumber) { this._totalRecordsNumber = totalRecordsNumber; }
|
|
1736
|
+
set recordsNumber(recordsNumber) { this._recordsNumber = recordsNumber; }
|
|
1737
|
+
set sorting(sorting) { this._sorting = sorting; }
|
|
1738
|
+
set waiting(waiting) { this._waiting = waiting; }
|
|
1739
|
+
set clientPaging(clientPaging) { this._clientPaging = clientPaging; }
|
|
1740
|
+
set sortable(sortable) { this._sortable = sortable; }
|
|
1614
1741
|
getLayout() { return this.layout; }
|
|
1615
1742
|
setLayout(layout) { this.setAttr(attrs.layout, layout); }
|
|
1616
1743
|
hasActions() { return (this._actions.length > 0); }
|
|
1617
|
-
getSelectedRecords() { return this.
|
|
1618
|
-
activateGlobalSearch() { this.
|
|
1619
|
-
inactivateGlobalSearch() { this.
|
|
1744
|
+
getSelectedRecords() { return this._tableRecords.filter(rec => rec.selected).map(rec => rec.recordId); }
|
|
1745
|
+
activateGlobalSearch() { this._globalSearch = true; }
|
|
1746
|
+
inactivateGlobalSearch() { this._globalSearch = false; }
|
|
1620
1747
|
columnDefinition(fieldCode) { return this._tableColumnObj[fieldCode]; }
|
|
1621
|
-
putOnWait() { this.
|
|
1622
|
-
freeWaiting() { this.
|
|
1748
|
+
putOnWait() { this._waiting = true; }
|
|
1749
|
+
freeWaiting() { this._waiting = false; }
|
|
1623
1750
|
setWidget(widget) { this.widget = widget; }
|
|
1624
1751
|
notifyGlobalAction(actionCode) {
|
|
1625
1752
|
const tableEvent = {
|
|
1626
|
-
tableCode: this.
|
|
1753
|
+
tableCode: this._tableCode,
|
|
1627
1754
|
actionCode,
|
|
1628
1755
|
actionDetail: null
|
|
1629
1756
|
};
|
|
@@ -1631,7 +1758,7 @@ class RecordTable extends FormElement {
|
|
|
1631
1758
|
}
|
|
1632
1759
|
notifyInlineAction(tableActionEvent) {
|
|
1633
1760
|
const tableEvent = {
|
|
1634
|
-
tableCode: this.
|
|
1761
|
+
tableCode: this._tableCode,
|
|
1635
1762
|
actionCode: tableActionEvent.actionCode,
|
|
1636
1763
|
actionDetail: {
|
|
1637
1764
|
recordId: tableActionEvent.recordId,
|
|
@@ -1646,9 +1773,9 @@ class RecordTable extends FormElement {
|
|
|
1646
1773
|
return;
|
|
1647
1774
|
}
|
|
1648
1775
|
record.toggleSelect();
|
|
1649
|
-
this.
|
|
1776
|
+
this._requestedPage = this._currentPage ?? 1;
|
|
1650
1777
|
const tableEvent = {
|
|
1651
|
-
tableCode: this.
|
|
1778
|
+
tableCode: this._tableCode,
|
|
1652
1779
|
actionCode: null,
|
|
1653
1780
|
actionDetail: {
|
|
1654
1781
|
recordId: record.recordId,
|
|
@@ -1659,7 +1786,7 @@ class RecordTable extends FormElement {
|
|
|
1659
1786
|
}
|
|
1660
1787
|
notifySelectionAction(actionCode) {
|
|
1661
1788
|
const tableEvent = {
|
|
1662
|
-
tableCode: this.
|
|
1789
|
+
tableCode: this._tableCode,
|
|
1663
1790
|
actionCode,
|
|
1664
1791
|
actionDetail: {
|
|
1665
1792
|
selectedRecords: this.selectedRecords
|
|
@@ -1669,9 +1796,9 @@ class RecordTable extends FormElement {
|
|
|
1669
1796
|
}
|
|
1670
1797
|
notifyGetDataAction(requestedPage = null) {
|
|
1671
1798
|
this.updateVisibleRecords();
|
|
1672
|
-
this.
|
|
1799
|
+
this._requestedPage = requestedPage || this._currentPage || 1;
|
|
1673
1800
|
const tableEvent = {
|
|
1674
|
-
tableCode: this.
|
|
1801
|
+
tableCode: this._tableCode,
|
|
1675
1802
|
actionCode: null,
|
|
1676
1803
|
actionDetail: null,
|
|
1677
1804
|
};
|
|
@@ -1679,49 +1806,49 @@ class RecordTable extends FormElement {
|
|
|
1679
1806
|
return null;
|
|
1680
1807
|
}
|
|
1681
1808
|
clean() {
|
|
1682
|
-
this.
|
|
1809
|
+
this._tableRecords = [];
|
|
1683
1810
|
this.unSelectAll();
|
|
1684
|
-
this.
|
|
1811
|
+
this._tableRecordObj = {};
|
|
1685
1812
|
this.updateVisibleRecords();
|
|
1686
1813
|
}
|
|
1687
1814
|
selectAll() {
|
|
1688
1815
|
this.setAttr(attrs.allSelected, true);
|
|
1689
|
-
this.
|
|
1816
|
+
this._tableRecords.forEach(record => record.select());
|
|
1690
1817
|
this.setAttr(attrs.selectedRecords, this.getSelectedRecords());
|
|
1691
1818
|
return true;
|
|
1692
1819
|
}
|
|
1693
1820
|
unSelectAll() {
|
|
1694
1821
|
this.setAttr(attrs.allSelected, false);
|
|
1695
|
-
this.
|
|
1822
|
+
this._tableRecords.forEach(record => record.unselect());
|
|
1696
1823
|
this.setAttr(attrs.selectedRecords, this.getSelectedRecords());
|
|
1697
1824
|
return true;
|
|
1698
1825
|
}
|
|
1699
1826
|
setTableRecords(tableRecords, append) {
|
|
1700
1827
|
if (!append) {
|
|
1701
|
-
this.
|
|
1828
|
+
this._tableRecords = [];
|
|
1702
1829
|
this.setAttr(attrs.allSelected, false);
|
|
1703
|
-
this.
|
|
1830
|
+
this._tableRecords.forEach(record => record.unselect());
|
|
1704
1831
|
this.setAttr(attrs.selectedRecords, []);
|
|
1705
|
-
this.
|
|
1832
|
+
this._tableRecordObj = {};
|
|
1706
1833
|
}
|
|
1707
|
-
const newRecordsObj = { ...this.
|
|
1708
|
-
const newRecords = [...this.
|
|
1834
|
+
const newRecordsObj = { ...this._tableRecordObj };
|
|
1835
|
+
const newRecords = [...this._tableRecords];
|
|
1709
1836
|
for (const tableRecord of tableRecords) {
|
|
1710
|
-
const recordReceived = new TableRecordData(tableRecord, this.
|
|
1837
|
+
const recordReceived = new TableRecordData(tableRecord, this._columns, this._selectionField);
|
|
1711
1838
|
const recordIdKey = recordReceived.recordIdKey;
|
|
1712
1839
|
newRecords.push(recordReceived);
|
|
1713
1840
|
newRecordsObj[recordIdKey] = recordReceived;
|
|
1714
1841
|
}
|
|
1715
|
-
this.
|
|
1842
|
+
this._tableRecords = newRecords;
|
|
1716
1843
|
this.setAttr(attrs.selectedRecords, this.getSelectedRecords());
|
|
1717
|
-
this.
|
|
1844
|
+
this._tableRecordObj = newRecordsObj;
|
|
1718
1845
|
this.updateVisibleRecords();
|
|
1719
1846
|
}
|
|
1720
1847
|
appendRecords(records) { this.setTableRecords(records, true); }
|
|
1721
1848
|
replaceRecords(records) { this.setTableRecords(records, false); }
|
|
1722
1849
|
setTableAppend(append) { this._appendPages = append; }
|
|
1723
1850
|
changePage(requestedPage) {
|
|
1724
|
-
if (this.
|
|
1851
|
+
if (this._clientPaging) {
|
|
1725
1852
|
this.setAttr(attrs.currentPage, requestedPage);
|
|
1726
1853
|
this.updateVisibleRecords();
|
|
1727
1854
|
}
|
|
@@ -1731,25 +1858,25 @@ class RecordTable extends FormElement {
|
|
|
1731
1858
|
}
|
|
1732
1859
|
updateVisibleRecords() {
|
|
1733
1860
|
let visibleRecords;
|
|
1734
|
-
if (this.
|
|
1861
|
+
if (this._clientPaging) {
|
|
1735
1862
|
let filteredRecords = this.getFilteredRecords();
|
|
1736
1863
|
this.setAttr(attrs.totalRecordsNumber, filteredRecords.length);
|
|
1737
|
-
const sliceNumber1 = (this.
|
|
1738
|
-
const sliceNumber2 = (this.
|
|
1864
|
+
const sliceNumber1 = (this._currentPage - 1) * this._recordsPerPage;
|
|
1865
|
+
const sliceNumber2 = (this._currentPage - 1) * this._recordsPerPage + this._recordsPerPage;
|
|
1739
1866
|
visibleRecords = filteredRecords.slice(sliceNumber1, sliceNumber2);
|
|
1740
|
-
const recordsLastPage = this.
|
|
1741
|
-
const totalPages = Math.trunc(this.
|
|
1742
|
-
if (this.
|
|
1743
|
-
this.
|
|
1867
|
+
const recordsLastPage = this._totalRecordsNumber % this._recordsPerPage;
|
|
1868
|
+
const totalPages = Math.trunc(this._totalRecordsNumber / this._recordsPerPage + (recordsLastPage ? 1 : 0));
|
|
1869
|
+
if (this._currentPage > totalPages) {
|
|
1870
|
+
this._currentPage = totalPages || 1;
|
|
1744
1871
|
}
|
|
1745
1872
|
}
|
|
1746
1873
|
else {
|
|
1747
|
-
visibleRecords = this.
|
|
1874
|
+
visibleRecords = this._tableRecords;
|
|
1748
1875
|
}
|
|
1749
1876
|
this.setAttr(attrs.visibleRecords, visibleRecords);
|
|
1750
1877
|
}
|
|
1751
1878
|
updateFromServer(tableReceived) {
|
|
1752
|
-
this.
|
|
1879
|
+
this._requestedPage = 1;
|
|
1753
1880
|
const { visible = true, totalPages = 1, recordsNumber, currentPage = 1, recordsPerPage, totalRecordsNumber, sortingColumn, sortingDirection, tableRecords, actions, fields, } = tableReceived;
|
|
1754
1881
|
this.visible = visible;
|
|
1755
1882
|
if (actions) {
|
|
@@ -1797,11 +1924,11 @@ class RecordTable extends FormElement {
|
|
|
1797
1924
|
});
|
|
1798
1925
|
}
|
|
1799
1926
|
if (tableRecords) {
|
|
1800
|
-
this.
|
|
1801
|
-
this.
|
|
1927
|
+
this._totalPages = totalPages;
|
|
1928
|
+
this._recordsNumber = recordsNumber;
|
|
1802
1929
|
this.setAttr(attrs.currentPage, +currentPage);
|
|
1803
1930
|
this.setAttr(attrs.recordsPerPage, +recordsPerPage);
|
|
1804
|
-
this.setAttr(attrs.totalRecordsNumber, (this.
|
|
1931
|
+
this.setAttr(attrs.totalRecordsNumber, (this._clientPaging) ? tableRecords.length : +totalRecordsNumber);
|
|
1805
1932
|
this.setAttr(attrs.sorting, {
|
|
1806
1933
|
columnName: sortingColumn || '',
|
|
1807
1934
|
direction: sortingDirection || ''
|
|
@@ -1813,13 +1940,13 @@ class RecordTable extends FormElement {
|
|
|
1813
1940
|
this.appendRecords(tableRecords);
|
|
1814
1941
|
}
|
|
1815
1942
|
}
|
|
1816
|
-
this.
|
|
1943
|
+
this._waiting = false;
|
|
1817
1944
|
this.updateVisibleRecords();
|
|
1818
1945
|
}
|
|
1819
1946
|
getTableRecord(recordId) {
|
|
1820
1947
|
const recordIdKey = (typeof recordId === 'object') ? JSON.stringify(recordId) : recordId;
|
|
1821
|
-
return (this.
|
|
1822
|
-
? this.
|
|
1948
|
+
return (this._tableRecordObj && recordId && this._tableRecordObj[recordId])
|
|
1949
|
+
? this._tableRecordObj[recordId] : null;
|
|
1823
1950
|
}
|
|
1824
1951
|
getAction(actionCode) {
|
|
1825
1952
|
return (this._actionsObj && actionCode && this._actionsObj[actionCode])
|
|
@@ -1848,7 +1975,7 @@ class RecordTable extends FormElement {
|
|
|
1848
1975
|
}
|
|
1849
1976
|
setGlobalFilterString(text, notifyComponent = true) {
|
|
1850
1977
|
this.globalFilterStrings = text.split(' ').filter(t => t && t.trim().length > 0).map(t => t.trim()) ?? [];
|
|
1851
|
-
if (this.
|
|
1978
|
+
if (this._clientPaging) {
|
|
1852
1979
|
this.changePage(1);
|
|
1853
1980
|
}
|
|
1854
1981
|
if (notifyComponent) {
|
|
@@ -1860,14 +1987,14 @@ class RecordTable extends FormElement {
|
|
|
1860
1987
|
tableColumn && tableColumn.addFilterDefinition(filterDefinition);
|
|
1861
1988
|
}
|
|
1862
1989
|
getFilteredRecords() {
|
|
1863
|
-
let filteredRecords = this.
|
|
1990
|
+
let filteredRecords = this._tableRecords;
|
|
1864
1991
|
if (this.restrictedId) {
|
|
1865
1992
|
filteredRecords = filteredRecords.filter(record => record.recordId === this.restrictedId);
|
|
1866
1993
|
}
|
|
1867
1994
|
if (this.globalFilterStrings.length > 0) {
|
|
1868
1995
|
filteredRecords = filteredRecords.filter(record => record.hasPattern(this.globalFilterStrings, this._tableColumnObj));
|
|
1869
1996
|
}
|
|
1870
|
-
const columnFilters = this.
|
|
1997
|
+
const columnFilters = this._columns.filter(column => column.filter).map(column => column.filter);
|
|
1871
1998
|
if (columnFilters.length > 0) {
|
|
1872
1999
|
filteredRecords = filteredRecords.filter(record => record.hasCondition(columnFilters));
|
|
1873
2000
|
}
|
|
@@ -1896,7 +2023,7 @@ class RecordTable extends FormElement {
|
|
|
1896
2023
|
simpleFilterWords: this.globalFilterStrings,
|
|
1897
2024
|
advancedFilter: [],
|
|
1898
2025
|
};
|
|
1899
|
-
const columnFilters = this.
|
|
2026
|
+
const columnFilters = this._columns.filter(column => column.filter).map(column => column.filter);
|
|
1900
2027
|
for (let index = 0; index < columnFilters.length; index++) {
|
|
1901
2028
|
const columnFilter = columnFilters[index];
|
|
1902
2029
|
compactFilter.advancedFilter.push({
|
|
@@ -1911,7 +2038,7 @@ class RecordTable extends FormElement {
|
|
|
1911
2038
|
// Ordenamiento de registros local
|
|
1912
2039
|
sort(columnName, direction) {
|
|
1913
2040
|
this.setRequiredOrder(columnName, direction);
|
|
1914
|
-
if (this.
|
|
2041
|
+
if (this._clientPaging) {
|
|
1915
2042
|
this.localSortData();
|
|
1916
2043
|
}
|
|
1917
2044
|
else {
|
|
@@ -1925,10 +2052,10 @@ class RecordTable extends FormElement {
|
|
|
1925
2052
|
});
|
|
1926
2053
|
}
|
|
1927
2054
|
localSortData() {
|
|
1928
|
-
if (!this.
|
|
2055
|
+
if (!this._sorting.columnName || !this._sorting.direction) {
|
|
1929
2056
|
return;
|
|
1930
2057
|
}
|
|
1931
|
-
this.
|
|
2058
|
+
this._tableRecords.sort((a, b) => this.recordCompare(a, b, this._sorting.columnName, this._sorting.direction));
|
|
1932
2059
|
//this.unSelectAll();
|
|
1933
2060
|
this.updateVisibleRecords();
|
|
1934
2061
|
}
|
|
@@ -1947,7 +2074,7 @@ class RecordTable extends FormElement {
|
|
|
1947
2074
|
return direction === TABLE_SORT_ASCENDING ? result : -result;
|
|
1948
2075
|
}
|
|
1949
2076
|
formStateChangeCustomSubscribe(form, formChangeSubject) {
|
|
1950
|
-
this.
|
|
2077
|
+
this._columns?.forEach(column => {
|
|
1951
2078
|
column?.connectWithParentForm(form, formChangeSubject);
|
|
1952
2079
|
});
|
|
1953
2080
|
this._actions?.forEach(action => {
|
|
@@ -1958,24 +2085,24 @@ class RecordTable extends FormElement {
|
|
|
1958
2085
|
|
|
1959
2086
|
class RecordFormSubSection extends FormPiecePropagate {
|
|
1960
2087
|
_customRender = null;
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
2088
|
+
_subsectionId = null;
|
|
2089
|
+
_subsectionCode = null;
|
|
2090
|
+
_subsectionTitle = null;
|
|
2091
|
+
_subSectionElements = [];
|
|
2092
|
+
_subSectionFields = [];
|
|
2093
|
+
_subSectionTables = [];
|
|
2094
|
+
_subSectionActions = [];
|
|
2095
|
+
_elementsArray = {};
|
|
2096
|
+
_active = false;
|
|
1970
2097
|
constructor(subsectionReceived, formObject, formConfig) {
|
|
1971
2098
|
super(subsectionReceived, formConfig);
|
|
1972
2099
|
this.propagationCustomAttributes = this._formConfig?.propagationCustomAttributes?.subsections ?? [];
|
|
1973
2100
|
if (!subsectionReceived) {
|
|
1974
2101
|
return;
|
|
1975
2102
|
}
|
|
1976
|
-
this.
|
|
1977
|
-
this.
|
|
1978
|
-
this.
|
|
2103
|
+
this._subsectionId = (subsectionReceived.subsectionId) ? subsectionReceived.subsectionId.toString() : '';
|
|
2104
|
+
this._subsectionCode = (subsectionReceived.subsectionCode) ? subsectionReceived.subsectionCode : '';
|
|
2105
|
+
this._subsectionTitle = (subsectionReceived.subsectionTitle) ? subsectionReceived.subsectionTitle : '';
|
|
1979
2106
|
if (subsectionReceived.elements) {
|
|
1980
2107
|
for (const receivedElement of subsectionReceived.elements) {
|
|
1981
2108
|
let elementObject = null;
|
|
@@ -1984,52 +2111,70 @@ class RecordFormSubSection extends FormPiecePropagate {
|
|
|
1984
2111
|
switch (type) {
|
|
1985
2112
|
case elementTypes.field:
|
|
1986
2113
|
elementObject = formObject.getField(code);
|
|
1987
|
-
arrayToAdd = this.
|
|
2114
|
+
arrayToAdd = this._subSectionFields;
|
|
1988
2115
|
break;
|
|
1989
2116
|
case elementTypes.table:
|
|
1990
2117
|
elementObject = formObject.getTable(code);
|
|
1991
|
-
arrayToAdd = this.
|
|
2118
|
+
arrayToAdd = this._subSectionTables;
|
|
1992
2119
|
break;
|
|
1993
2120
|
case elementTypes.action:
|
|
1994
2121
|
elementObject = formObject.getAction(code);
|
|
1995
|
-
arrayToAdd = this.
|
|
2122
|
+
arrayToAdd = this._subSectionActions;
|
|
1996
2123
|
break;
|
|
1997
2124
|
}
|
|
1998
2125
|
if (elementObject) {
|
|
1999
2126
|
elementObject.elementType = type;
|
|
2000
2127
|
arrayToAdd.push(elementObject);
|
|
2001
|
-
this.
|
|
2002
|
-
this.
|
|
2128
|
+
this._subSectionElements.push(elementObject);
|
|
2129
|
+
this._elementsArray[code] = elementObject;
|
|
2003
2130
|
}
|
|
2004
2131
|
}
|
|
2005
2132
|
}
|
|
2006
2133
|
}
|
|
2007
2134
|
get customRender() { return this._customRender; }
|
|
2008
2135
|
set customRender(customRenderName) { this._customRender = customRenderName; }
|
|
2136
|
+
get subsectionId() { return this._subsectionId; }
|
|
2137
|
+
get subsectionCode() { return this._subsectionCode; }
|
|
2138
|
+
get subsectionTitle() { return this._subsectionTitle; }
|
|
2139
|
+
get subSectionElements() { return this._subSectionElements; }
|
|
2140
|
+
get subSectionFields() { return this._subSectionFields; }
|
|
2141
|
+
get subSectionTables() { return this._subSectionTables; }
|
|
2142
|
+
get subSectionActions() { return this._subSectionActions; }
|
|
2143
|
+
get elementsArray() { return this._elementsArray; }
|
|
2144
|
+
get active() { return this._active; }
|
|
2145
|
+
set subsectionId(subsectionId) { this._subsectionId = subsectionId; }
|
|
2146
|
+
set subsectionCode(subsectionCode) { this._subsectionCode = subsectionCode; }
|
|
2147
|
+
set subsectionTitle(subsectionTitle) { this._subsectionTitle = subsectionTitle; }
|
|
2148
|
+
set subSectionElements(subSectionElements) { this._subSectionElements = subSectionElements; }
|
|
2149
|
+
set subSectionFields(subSectionFields) { this._subSectionFields = subSectionFields; }
|
|
2150
|
+
set subSectionTables(subSectionTables) { this._subSectionTables = subSectionTables; }
|
|
2151
|
+
set subSectionActions(subSectionActions) { this._subSectionActions = subSectionActions; }
|
|
2152
|
+
set elementsArray(elementsArray) { this._elementsArray = elementsArray; }
|
|
2153
|
+
set active(active) { this._active = active; }
|
|
2009
2154
|
getField(name) {
|
|
2010
|
-
return this.
|
|
2155
|
+
return this._subSectionFields.find(fld => fld.name === name);
|
|
2011
2156
|
}
|
|
2012
2157
|
getFields() {
|
|
2013
|
-
return this.
|
|
2158
|
+
return this._subSectionFields;
|
|
2014
2159
|
}
|
|
2015
2160
|
getFieldNames() {
|
|
2016
|
-
return this.
|
|
2161
|
+
return this._subSectionFields.map(field => field.code);
|
|
2017
2162
|
}
|
|
2018
2163
|
getActions() {
|
|
2019
|
-
return this.
|
|
2164
|
+
return this._subSectionActions;
|
|
2020
2165
|
}
|
|
2021
2166
|
getActionNames() {
|
|
2022
|
-
return this.
|
|
2167
|
+
return this._subSectionActions.map(action => action.actionCode);
|
|
2023
2168
|
}
|
|
2024
2169
|
activate() {
|
|
2025
|
-
if (!this.
|
|
2026
|
-
this.
|
|
2170
|
+
if (!this._active) {
|
|
2171
|
+
this._active = true;
|
|
2027
2172
|
// this.subsectionCode && this._activation.next(this.subsectionCode);
|
|
2028
2173
|
}
|
|
2029
2174
|
}
|
|
2030
2175
|
inactivate() {
|
|
2031
|
-
if (this.
|
|
2032
|
-
this.
|
|
2176
|
+
if (this._active) {
|
|
2177
|
+
this._active = false;
|
|
2033
2178
|
// this.subsectionCode && this._inactivation.next(this.subsectionCode);
|
|
2034
2179
|
}
|
|
2035
2180
|
}
|
|
@@ -2039,12 +2184,12 @@ const ACTIVE$1 = 'active';
|
|
|
2039
2184
|
class RecordFormSection extends FormPiecePropagate {
|
|
2040
2185
|
_activation = new Subject();
|
|
2041
2186
|
_inactivation = new Subject();
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2187
|
+
_active = false;
|
|
2188
|
+
_sectionId = null;
|
|
2189
|
+
_sectionCode = null;
|
|
2190
|
+
_sectionTitle = null;
|
|
2191
|
+
_subSections = [];
|
|
2192
|
+
_subSectionsObj;
|
|
2048
2193
|
_exclusiveSubSectionsByAttr = {};
|
|
2049
2194
|
constructor(sectionReceived, formObject, formConfig) {
|
|
2050
2195
|
super(sectionReceived, formConfig);
|
|
@@ -2052,11 +2197,11 @@ class RecordFormSection extends FormPiecePropagate {
|
|
|
2052
2197
|
if (!sectionReceived) {
|
|
2053
2198
|
return;
|
|
2054
2199
|
}
|
|
2055
|
-
this.
|
|
2056
|
-
this.
|
|
2057
|
-
this.
|
|
2058
|
-
this.
|
|
2059
|
-
this.
|
|
2200
|
+
this._sectionId = (sectionReceived.sectionId) ? sectionReceived.sectionId.toString() : '';
|
|
2201
|
+
this._sectionCode = (sectionReceived.sectionCode) ? sectionReceived.sectionCode : '';
|
|
2202
|
+
this._sectionTitle = (sectionReceived.sectionTitle) ? sectionReceived.sectionTitle : '';
|
|
2203
|
+
this._subSections = [];
|
|
2204
|
+
this._subSectionsObj = {};
|
|
2060
2205
|
if (sectionReceived.subsections) {
|
|
2061
2206
|
const subsections = sectionReceived.subsections.map(subSecDef => {
|
|
2062
2207
|
const visibleStates = subSecDef.visibleStates ?? [];
|
|
@@ -2069,42 +2214,54 @@ class RecordFormSection extends FormPiecePropagate {
|
|
|
2069
2214
|
const subSectionToAdd = new RecordFormSubSection(subsectionReceived, formObject, formConfig);
|
|
2070
2215
|
const subsectionCode = subSectionToAdd.subsectionCode;
|
|
2071
2216
|
if (subsectionCode) {
|
|
2072
|
-
this.
|
|
2073
|
-
this.
|
|
2217
|
+
this._subSections.push(subSectionToAdd);
|
|
2218
|
+
this._subSectionsObj[subsectionCode] = subSectionToAdd;
|
|
2074
2219
|
}
|
|
2075
2220
|
}
|
|
2076
2221
|
}
|
|
2077
2222
|
}
|
|
2078
|
-
get code() { return this.
|
|
2223
|
+
get code() { return this._sectionCode; }
|
|
2079
2224
|
get activation() { return this._activation; }
|
|
2080
2225
|
get inactivation() { return this._inactivation; }
|
|
2226
|
+
get active() { return this._active; }
|
|
2227
|
+
get sectionId() { return this._sectionId; }
|
|
2228
|
+
get sectionCode() { return this._sectionCode; }
|
|
2229
|
+
get sectionTitle() { return this._sectionTitle; }
|
|
2230
|
+
get subSections() { return this._subSections; }
|
|
2231
|
+
get subSectionsObj() { return this._subSectionsObj; }
|
|
2232
|
+
set active(active) { this._active = active; }
|
|
2233
|
+
set sectionId(sectionId) { this._sectionId = sectionId; }
|
|
2234
|
+
set sectionCode(sectionCode) { this._sectionCode = sectionCode; }
|
|
2235
|
+
set sectionTitle(sectionTitle) { this._sectionTitle = sectionTitle; }
|
|
2236
|
+
set subSections(subSections) { this._subSections = subSections; }
|
|
2237
|
+
set subSectionsObj(subSectionsObj) { this._subSectionsObj = subSectionsObj; }
|
|
2081
2238
|
activate() {
|
|
2082
|
-
if (!this.
|
|
2083
|
-
this.
|
|
2084
|
-
this.
|
|
2239
|
+
if (!this._active) {
|
|
2240
|
+
this._active = true;
|
|
2241
|
+
this._sectionCode && this._activation.next(this._sectionCode);
|
|
2085
2242
|
}
|
|
2086
2243
|
}
|
|
2087
2244
|
inactivate() {
|
|
2088
|
-
if (this.
|
|
2089
|
-
this.
|
|
2090
|
-
this.
|
|
2245
|
+
if (this._active) {
|
|
2246
|
+
this._active = false;
|
|
2247
|
+
this._sectionCode && this._inactivation.next(this._sectionCode);
|
|
2091
2248
|
}
|
|
2092
2249
|
}
|
|
2093
|
-
get title() { return this.
|
|
2094
|
-
set title(title) { this.
|
|
2250
|
+
get title() { return this._sectionTitle; }
|
|
2251
|
+
set title(title) { this._sectionTitle = title; }
|
|
2095
2252
|
getVisibleSubsections(state) {
|
|
2096
|
-
return this.
|
|
2253
|
+
return this._subSections.filter(subSection => subSection.visible);
|
|
2097
2254
|
}
|
|
2098
2255
|
getSubsection(subSectionCode) {
|
|
2099
|
-
return (this.
|
|
2100
|
-
? this.
|
|
2256
|
+
return (this._subSectionsObj && this._subSectionsObj[subSectionCode])
|
|
2257
|
+
? this._subSectionsObj[subSectionCode] : null;
|
|
2101
2258
|
}
|
|
2102
2259
|
activateSubSection(subSectionCode) {
|
|
2103
2260
|
if (subSectionCode === this._exclusiveSubSectionsByAttr[ACTIVE$1]) {
|
|
2104
2261
|
return;
|
|
2105
2262
|
}
|
|
2106
|
-
const subSection = (this.
|
|
2107
|
-
? this.
|
|
2263
|
+
const subSection = (this._subSectionsObj && this._subSectionsObj[subSectionCode])
|
|
2264
|
+
? this._subSectionsObj[subSectionCode] : null;
|
|
2108
2265
|
if (subSection) {
|
|
2109
2266
|
subSection?.activate();
|
|
2110
2267
|
this._exclusiveSubSectionsByAttr[ACTIVE$1] = subSectionCode;
|
|
@@ -2112,8 +2269,8 @@ class RecordFormSection extends FormPiecePropagate {
|
|
|
2112
2269
|
}
|
|
2113
2270
|
getFields() {
|
|
2114
2271
|
let fieldsArray = [];
|
|
2115
|
-
if (this.
|
|
2116
|
-
for (const subSection of this.
|
|
2272
|
+
if (this._subSections && this._subSections.length > 0) {
|
|
2273
|
+
for (const subSection of this._subSections) {
|
|
2117
2274
|
const subsectionFields = subSection.getFields() ?? [];
|
|
2118
2275
|
if (subsectionFields?.length > 0) {
|
|
2119
2276
|
fieldsArray = fieldsArray.concat(subsectionFields);
|
|
@@ -2124,8 +2281,8 @@ class RecordFormSection extends FormPiecePropagate {
|
|
|
2124
2281
|
}
|
|
2125
2282
|
getActions() {
|
|
2126
2283
|
let actionArray = [];
|
|
2127
|
-
if (this.
|
|
2128
|
-
for (const subSection of this.
|
|
2284
|
+
if (this._subSections && this._subSections.length > 0) {
|
|
2285
|
+
for (const subSection of this._subSections) {
|
|
2129
2286
|
const subSectionActions = subSection.getActions() ?? [];
|
|
2130
2287
|
if (subSectionActions?.length > 0) {
|
|
2131
2288
|
actionArray = actionArray.concat(subSectionActions);
|
|
@@ -2136,8 +2293,8 @@ class RecordFormSection extends FormPiecePropagate {
|
|
|
2136
2293
|
}
|
|
2137
2294
|
getActionNames() {
|
|
2138
2295
|
let actionArray = [];
|
|
2139
|
-
if (this.
|
|
2140
|
-
for (const subSection of this.
|
|
2296
|
+
if (this._subSections && this._subSections.length > 0) {
|
|
2297
|
+
for (const subSection of this._subSections) {
|
|
2141
2298
|
actionArray = actionArray.concat(subSection.getActionNames());
|
|
2142
2299
|
}
|
|
2143
2300
|
}
|
|
@@ -2145,8 +2302,8 @@ class RecordFormSection extends FormPiecePropagate {
|
|
|
2145
2302
|
}
|
|
2146
2303
|
getFieldNames() {
|
|
2147
2304
|
let fieldsArray = [];
|
|
2148
|
-
if (this.
|
|
2149
|
-
for (const subSection of this.
|
|
2305
|
+
if (this._subSections && this._subSections.length > 0) {
|
|
2306
|
+
for (const subSection of this._subSections) {
|
|
2150
2307
|
fieldsArray = fieldsArray.concat(subSection.getFieldNames());
|
|
2151
2308
|
}
|
|
2152
2309
|
}
|
|
@@ -2154,8 +2311,8 @@ class RecordFormSection extends FormPiecePropagate {
|
|
|
2154
2311
|
}
|
|
2155
2312
|
getField(name) {
|
|
2156
2313
|
let field = null;
|
|
2157
|
-
if (this.
|
|
2158
|
-
for (const subSection of this.
|
|
2314
|
+
if (this._subSections && this._subSections.length > 0) {
|
|
2315
|
+
for (const subSection of this._subSections) {
|
|
2159
2316
|
field = subSection.getField(name);
|
|
2160
2317
|
if (field) {
|
|
2161
2318
|
return field;
|
|
@@ -2165,7 +2322,7 @@ class RecordFormSection extends FormPiecePropagate {
|
|
|
2165
2322
|
return null;
|
|
2166
2323
|
}
|
|
2167
2324
|
formStateChangeCustomSubscribe(form, formChangeSubject) {
|
|
2168
|
-
this.
|
|
2325
|
+
this._subSections?.forEach(subsection => {
|
|
2169
2326
|
subsection?.connectWithParentForm(form, formChangeSubject);
|
|
2170
2327
|
});
|
|
2171
2328
|
}
|