tuain-ng-forms-lib 14.1.1 → 14.2.14
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 +9 -3
- package/esm2020/lib/classes/forms/field.mjs +325 -242
- package/esm2020/lib/classes/forms/form.mjs +26 -26
- package/esm2020/lib/classes/forms/subsection.mjs +2 -2
- package/esm2020/lib/components/elements/action.component.mjs +3 -3
- package/esm2020/lib/components/elements/field.component.mjs +20 -15
- package/esm2020/lib/components/elements/layout/element.component.mjs +3 -3
- package/esm2020/lib/components/elements/layout/form-error.component.mjs +3 -3
- package/esm2020/lib/components/elements/layout/form-header.component.mjs +3 -3
- package/esm2020/lib/components/elements/layout/section.component.mjs +3 -3
- package/esm2020/lib/components/elements/layout/sub-section.component.mjs +3 -3
- package/esm2020/lib/components/elements/tables/table-record-action.component.mjs +3 -3
- package/esm2020/lib/components/elements/tables/table-record-field.component.mjs +3 -3
- package/esm2020/lib/components/elements/tables/table.component.mjs +3 -3
- package/esm2020/lib/components/forms/basic-form.mjs +65 -37
- package/esm2020/lib/tuain-ng-forms-lib.module.mjs +7 -9
- package/fesm2015/tuain-ng-forms-lib.mjs +479 -356
- package/fesm2015/tuain-ng-forms-lib.mjs.map +1 -1
- package/fesm2020/tuain-ng-forms-lib.mjs +474 -353
- package/fesm2020/tuain-ng-forms-lib.mjs.map +1 -1
- package/lib/classes/forms/element.d.ts +7 -6
- package/lib/classes/forms/field.d.ts +168 -72
- package/lib/classes/forms/form.d.ts +1 -1
- package/lib/components/elements/action.component.d.ts +1 -1
- package/lib/components/elements/field.component.d.ts +5 -5
- package/lib/components/elements/layout/element.component.d.ts +1 -1
- package/lib/components/elements/layout/form-error.component.d.ts +1 -1
- package/lib/components/elements/layout/form-header.component.d.ts +1 -1
- package/lib/components/elements/layout/section.component.d.ts +1 -1
- package/lib/components/elements/layout/sub-section.component.d.ts +1 -1
- package/lib/components/elements/tables/table-record-action.component.d.ts +1 -1
- package/lib/components/elements/tables/table-record-field.component.d.ts +1 -1
- package/lib/components/elements/tables/table.component.d.ts +1 -1
- package/lib/components/forms/basic-form.d.ts +8 -5
- package/package.json +2 -2
|
@@ -47,9 +47,9 @@ class ActionComponent {
|
|
|
47
47
|
return !((_a = this.action) === null || _a === void 0 ? void 0 : _a.enabledOn(this.state));
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
|
-
ActionComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
51
|
-
ActionComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "
|
|
52
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
50
|
+
ActionComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: ActionComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
51
|
+
ActionComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.6", type: ActionComponent, selector: "lib-action", inputs: { action: "action", busy: "busy", relatedField: "relatedField", state: "state", style: "style", showLabel: "showLabel" }, ngImport: i0, template: `<ng-content></ng-content>`, isInline: true });
|
|
52
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: ActionComponent, decorators: [{
|
|
53
53
|
type: Component,
|
|
54
54
|
args: [{
|
|
55
55
|
selector: 'lib-action',
|
|
@@ -72,26 +72,31 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.1", ngImpor
|
|
|
72
72
|
const VALUE = 'value';
|
|
73
73
|
const FOCUS = 'focus';
|
|
74
74
|
class FieldComponent {
|
|
75
|
+
constructor() {
|
|
76
|
+
// Atributos obtenidos estáticamente
|
|
77
|
+
this.code = '';
|
|
78
|
+
this.info = '';
|
|
79
|
+
this.alignment = '';
|
|
80
|
+
this.tooltip = '';
|
|
81
|
+
this.field = null;
|
|
82
|
+
}
|
|
75
83
|
ngOnInit() {
|
|
76
84
|
var _a, _b;
|
|
77
85
|
if (this.field) {
|
|
78
86
|
this.formConfig = (_a = this.field) === null || _a === void 0 ? void 0 : _a._formConfig;
|
|
79
87
|
// Inicialización
|
|
80
|
-
const mapping =
|
|
88
|
+
const mapping = this.formConfig.fieldPropagateAttributes;
|
|
81
89
|
for (let index = 0; index < mapping.length; index++) {
|
|
82
|
-
const
|
|
83
|
-
const
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
this.dafaultProcessFieldChange(compAttr, attributeValue);
|
|
87
|
-
this.processFieldChange(compAttr, attributeValue);
|
|
90
|
+
const attrName = mapping[index].toString();
|
|
91
|
+
const attributeValue = (_b = this.field) === null || _b === void 0 ? void 0 : _b[attrName];
|
|
92
|
+
this.dafaultProcessFieldChange(attrName, attributeValue);
|
|
93
|
+
this.processFieldChange(attrName, attributeValue);
|
|
88
94
|
}
|
|
89
95
|
// Subscripción a cambios en atributos
|
|
90
96
|
this.field.attributeChange.subscribe(event => {
|
|
91
|
-
const { name:
|
|
92
|
-
|
|
93
|
-
this.
|
|
94
|
-
this.processFieldChange(compAttr, value);
|
|
97
|
+
const { name: attrName, value } = event;
|
|
98
|
+
this.dafaultProcessFieldChange(attrName, value);
|
|
99
|
+
this.processFieldChange(attrName, value);
|
|
95
100
|
});
|
|
96
101
|
}
|
|
97
102
|
this.start();
|
|
@@ -146,9 +151,9 @@ class FieldComponent {
|
|
|
146
151
|
return !((_a = this.field) === null || _a === void 0 ? void 0 : _a.enabledOn(this.state));
|
|
147
152
|
}
|
|
148
153
|
}
|
|
149
|
-
FieldComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
150
|
-
FieldComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "
|
|
151
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
154
|
+
FieldComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: FieldComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
155
|
+
FieldComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.6", type: FieldComponent, selector: "lib-field", inputs: { field: "field", state: "state" }, ngImport: i0, template: `<ng-content></ng-content>`, isInline: true });
|
|
156
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: FieldComponent, decorators: [{
|
|
152
157
|
type: Component,
|
|
153
158
|
args: [{
|
|
154
159
|
selector: 'lib-field',
|
|
@@ -176,9 +181,9 @@ class ElementComponent {
|
|
|
176
181
|
return !((_a = this.element) === null || _a === void 0 ? void 0 : _a.enabledOn(this.state));
|
|
177
182
|
}
|
|
178
183
|
}
|
|
179
|
-
ElementComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
180
|
-
ElementComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "
|
|
181
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
184
|
+
ElementComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: ElementComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
185
|
+
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 });
|
|
186
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: ElementComponent, decorators: [{
|
|
182
187
|
type: Component,
|
|
183
188
|
args: [{
|
|
184
189
|
selector: 'lib-element',
|
|
@@ -194,9 +199,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.1", ngImpor
|
|
|
194
199
|
|
|
195
200
|
class FormErrorComponent {
|
|
196
201
|
}
|
|
197
|
-
FormErrorComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
198
|
-
FormErrorComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "
|
|
199
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
202
|
+
FormErrorComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: FormErrorComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
203
|
+
FormErrorComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.6", type: FormErrorComponent, selector: "lib-form-error", inputs: { errorTitle: "errorTitle", errorMessage: "errorMessage", errorType: "errorType" }, ngImport: i0, template: `<ng-content></ng-content>`, isInline: true });
|
|
204
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: FormErrorComponent, decorators: [{
|
|
200
205
|
type: Component,
|
|
201
206
|
args: [{
|
|
202
207
|
selector: 'lib-form-error',
|
|
@@ -219,9 +224,9 @@ class FormHeaderComponent {
|
|
|
219
224
|
this.goBackEvent.emit();
|
|
220
225
|
}
|
|
221
226
|
}
|
|
222
|
-
FormHeaderComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
223
|
-
FormHeaderComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "
|
|
224
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
227
|
+
FormHeaderComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: FormHeaderComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
228
|
+
FormHeaderComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.6", type: FormHeaderComponent, selector: "lib-form-header", inputs: { formManager: "formManager", goBackAction: "goBackAction", showTitle: "showTitle", headerActions: "headerActions" }, outputs: { goBackEvent: "goBackEvent" }, ngImport: i0, template: `<ng-content></ng-content>`, isInline: true });
|
|
229
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: FormHeaderComponent, decorators: [{
|
|
225
230
|
type: Component,
|
|
226
231
|
args: [{
|
|
227
232
|
selector: 'lib-form-header',
|
|
@@ -245,9 +250,9 @@ class SectionComponent {
|
|
|
245
250
|
}
|
|
246
251
|
start() { }
|
|
247
252
|
}
|
|
248
|
-
SectionComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
249
|
-
SectionComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "
|
|
250
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
253
|
+
SectionComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: SectionComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
254
|
+
SectionComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.6", type: SectionComponent, selector: "lib-section", inputs: { section: "section", formManager: "formManager" }, ngImport: i0, template: `<ng-content></ng-content>`, isInline: true });
|
|
255
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: SectionComponent, decorators: [{
|
|
251
256
|
type: Component,
|
|
252
257
|
args: [{
|
|
253
258
|
selector: 'lib-section',
|
|
@@ -265,9 +270,9 @@ class SubSectionComponent {
|
|
|
265
270
|
}
|
|
266
271
|
start() { }
|
|
267
272
|
}
|
|
268
|
-
SubSectionComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
269
|
-
SubSectionComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "
|
|
270
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
273
|
+
SubSectionComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: SubSectionComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
274
|
+
SubSectionComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.6", type: SubSectionComponent, selector: "lib-subsection", inputs: { subSection: "subSection", showHeader: "showHeader", formManager: "formManager" }, ngImport: i0, template: `<ng-content></ng-content>`, isInline: true });
|
|
275
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: SubSectionComponent, decorators: [{
|
|
271
276
|
type: Component,
|
|
272
277
|
args: [{
|
|
273
278
|
selector: 'lib-subsection',
|
|
@@ -300,9 +305,9 @@ class LibTableRecordActionComponent {
|
|
|
300
305
|
}
|
|
301
306
|
class() { }
|
|
302
307
|
}
|
|
303
|
-
LibTableRecordActionComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
304
|
-
LibTableRecordActionComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "
|
|
305
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
308
|
+
LibTableRecordActionComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: LibTableRecordActionComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
309
|
+
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 });
|
|
310
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: LibTableRecordActionComponent, decorators: [{
|
|
306
311
|
type: Component,
|
|
307
312
|
args: [{
|
|
308
313
|
selector: 'lib-table-record-action',
|
|
@@ -325,9 +330,9 @@ class LibTableRecordFieldComponent {
|
|
|
325
330
|
}
|
|
326
331
|
start() { }
|
|
327
332
|
}
|
|
328
|
-
LibTableRecordFieldComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
329
|
-
LibTableRecordFieldComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "
|
|
330
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
333
|
+
LibTableRecordFieldComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: LibTableRecordFieldComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
334
|
+
LibTableRecordFieldComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.6", type: LibTableRecordFieldComponent, selector: "lib-table-record-field", inputs: { fieldCode: "fieldCode", fieldType: "fieldType", fieldValue: "fieldValue" }, ngImport: i0, template: `<ng-content></ng-content>`, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
335
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: LibTableRecordFieldComponent, decorators: [{
|
|
331
336
|
type: Component,
|
|
332
337
|
args: [{
|
|
333
338
|
selector: 'lib-table-record-field',
|
|
@@ -417,9 +422,9 @@ class LibTableComponent {
|
|
|
417
422
|
}
|
|
418
423
|
}
|
|
419
424
|
}
|
|
420
|
-
LibTableComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
421
|
-
LibTableComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "
|
|
422
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
425
|
+
LibTableComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: LibTableComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
426
|
+
LibTableComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.6", type: LibTableComponent, selector: "lib-table", inputs: { table: "table", tableRecords: "tableRecords", disabled: "disabled", state: "state", waiting: "waiting" }, ngImport: i0, template: `<ng-content></ng-content>`, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
427
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: LibTableComponent, decorators: [{
|
|
423
428
|
type: Component,
|
|
424
429
|
args: [{
|
|
425
430
|
selector: 'lib-table',
|
|
@@ -467,6 +472,10 @@ const operators = {
|
|
|
467
472
|
class FormElement {
|
|
468
473
|
constructor(elementDefinition, formConfig) {
|
|
469
474
|
var _a, _b, _c;
|
|
475
|
+
this._visible = true;
|
|
476
|
+
this.visibleStates = null;
|
|
477
|
+
this.enabledStates = null;
|
|
478
|
+
this.elementType = null;
|
|
470
479
|
this._formConfig = formConfig;
|
|
471
480
|
this._isForced = false;
|
|
472
481
|
this.setVisibleStates(elementDefinition.visibleStates);
|
|
@@ -476,6 +485,7 @@ class FormElement {
|
|
|
476
485
|
this.setVisibility((_b = elementDefinition === null || elementDefinition === void 0 ? void 0 : elementDefinition.visible) !== null && _b !== void 0 ? _b : true);
|
|
477
486
|
this.customAttributes = (_c = elementDefinition === null || elementDefinition === void 0 ? void 0 : elementDefinition.customAttributes) !== null && _c !== void 0 ? _c : {};
|
|
478
487
|
}
|
|
488
|
+
;
|
|
479
489
|
getCustomAttribute(name) { var _a, _b; return (_b = (_a = this.customAttributes) === null || _a === void 0 ? void 0 : _a[name]) !== null && _b !== void 0 ? _b : null; }
|
|
480
490
|
setCustomAttribute(name, value) {
|
|
481
491
|
if (name) {
|
|
@@ -522,14 +532,14 @@ class FormElement {
|
|
|
522
532
|
this._isForced = forced;
|
|
523
533
|
}
|
|
524
534
|
}
|
|
525
|
-
show(forced) {
|
|
535
|
+
show(forced = null) {
|
|
526
536
|
this._visible = true;
|
|
527
537
|
if (forced !== null) {
|
|
528
538
|
this._isForced = forced;
|
|
529
539
|
this._visibleForced = true;
|
|
530
540
|
}
|
|
531
541
|
}
|
|
532
|
-
hide(forced) {
|
|
542
|
+
hide(forced = null) {
|
|
533
543
|
this._visible = false;
|
|
534
544
|
if (forced !== null) {
|
|
535
545
|
this._isForced = forced;
|
|
@@ -540,6 +550,7 @@ class FormElement {
|
|
|
540
550
|
disable() { this.disabled = true; }
|
|
541
551
|
get enabled() { return !this.disabled; }
|
|
542
552
|
get editable() { return !this.disabled; }
|
|
553
|
+
set editable(editable) { this.disabled = !editable; }
|
|
543
554
|
}
|
|
544
555
|
|
|
545
556
|
const HEADER = 'HEADER';
|
|
@@ -581,35 +592,40 @@ const DEFAULT_CAPTURE_TYPE = 'INPUT';
|
|
|
581
592
|
const DEFAULT_ALIGNMENT = 'left';
|
|
582
593
|
const STD_MAX_LENGTH = 50;
|
|
583
594
|
const BIG_MAX_LENGTH = 500;
|
|
584
|
-
const
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
minValue
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
595
|
+
const directChanges = [
|
|
596
|
+
'defaultEditable', 'defaultValue', 'alignment', 'required', 'errorCode', 'errorMessage', 'errorType',
|
|
597
|
+
'tooltip', 'info', 'format', 'intrinsicErrorMessage', 'outputOnly', 'captureType', 'title', 'type',
|
|
598
|
+
'maxLength', 'maxValue', 'minLength', 'minValue', 'validateOnServer', 'serverAction', 'visibleLabel',
|
|
599
|
+
'options',
|
|
600
|
+
];
|
|
601
|
+
const attrs = {
|
|
602
|
+
_captureType: { name: '_captureType', propagate: 'captureType' },
|
|
603
|
+
_errorCode: { name: '_errorCode', propagate: 'errorCode' },
|
|
604
|
+
_errorMessage: { name: '_errorMessage', propagate: 'errorMessage' },
|
|
605
|
+
_errorType: { name: '_errorType', propagate: 'errorType' },
|
|
606
|
+
_defaultValue: { name: '_defaultValue', propagate: 'defaultValue' },
|
|
607
|
+
_defaultEditable: { name: '_defaultEditable', propagate: 'defaultEditable' },
|
|
608
|
+
_fieldAlignment: { name: '_fieldAlignment', propagate: 'alignment' },
|
|
609
|
+
_fieldCode: { name: '_fieldCode', propagate: 'code' },
|
|
610
|
+
_fieldInfo: { name: '_fieldInfo', propagate: 'info' },
|
|
611
|
+
_fieldRequired: { name: '_fieldRequired', propagate: 'required' },
|
|
612
|
+
_fieldTitle: { name: '_fieldTitle', propagate: 'title' },
|
|
613
|
+
_fieldType: { name: '_fieldType', propagate: 'type' },
|
|
614
|
+
_fieldFormat: { name: '_fieldFormat', propagate: 'format' },
|
|
615
|
+
_fieldOptions: { name: '_fieldOptions', propagate: 'options' },
|
|
616
|
+
_focus: { name: '_focus', propagate: 'focus' },
|
|
617
|
+
_hasChanged: { name: '_hasChanged', propagate: 'hasChanged' },
|
|
618
|
+
_intrinsicErrorMessage: { name: '_intrinsicErrorMessage', propagate: null },
|
|
619
|
+
_maxLength: { name: '_maxLength', propagate: 'maxLength' },
|
|
620
|
+
_maxValue: { name: '_maxValue', propagate: 'maxValue' },
|
|
621
|
+
_minLength: { name: '_minLength', propagate: 'minLength' },
|
|
622
|
+
_minValue: { name: '_minValue', propagate: 'minValue' },
|
|
623
|
+
_onValidation: { name: '_onValidation', propagate: 'onValidation' },
|
|
624
|
+
_outputOnly: { name: '_outputOnly', propagate: 'outputOnly' },
|
|
625
|
+
_tooltipText: { name: '_tooltipText', propagate: 'tooltip' },
|
|
626
|
+
_validateOnServer: { name: '_validateOnServer', propagate: 'validateOnServer' },
|
|
627
|
+
_value: { name: '_value', propagate: 'value' },
|
|
628
|
+
_visibleLabel: { name: '_visibleLabel', propagate: 'visibleLabel' },
|
|
613
629
|
};
|
|
614
630
|
class FieldDescriptor extends FormElement {
|
|
615
631
|
constructor(inputFieldReceived, formConfig) {
|
|
@@ -619,48 +635,48 @@ class FieldDescriptor extends FormElement {
|
|
|
619
635
|
this._editionPartial = new Subject();
|
|
620
636
|
this._detailRequest = new Subject();
|
|
621
637
|
this._attributeChange = new Subject();
|
|
622
|
-
this.
|
|
623
|
-
this.
|
|
638
|
+
this._errorType = '';
|
|
639
|
+
this._errorCode = '';
|
|
640
|
+
this._errorMessage = '';
|
|
641
|
+
this._fieldCode = '';
|
|
642
|
+
this._intrinsicErrorMessage = '';
|
|
624
643
|
this._maxLength = 0;
|
|
625
644
|
this._minLength = 0;
|
|
645
|
+
this._focus = false;
|
|
626
646
|
this._onValidation = false;
|
|
627
|
-
this.
|
|
628
|
-
this.
|
|
629
|
-
this.
|
|
630
|
-
this.
|
|
631
|
-
this.
|
|
632
|
-
this.
|
|
633
|
-
this.
|
|
634
|
-
this.
|
|
635
|
-
this.
|
|
636
|
-
this.
|
|
637
|
-
this.
|
|
638
|
-
this.
|
|
639
|
-
this.
|
|
640
|
-
this.
|
|
641
|
-
this.
|
|
642
|
-
this.errorType = '';
|
|
643
|
-
this.errorCode = '';
|
|
644
|
-
this.errorMessage = '';
|
|
645
|
-
this.fieldOptions = null;
|
|
647
|
+
this._validateOnServer = false;
|
|
648
|
+
this._visibleLabel = false;
|
|
649
|
+
this._captureType = '';
|
|
650
|
+
this._defaultValue = '';
|
|
651
|
+
this._defaultEditable = false;
|
|
652
|
+
this._fieldAlignment = '';
|
|
653
|
+
this._fieldInfo = '';
|
|
654
|
+
this._fieldRequired = false;
|
|
655
|
+
this._fieldTitle = '';
|
|
656
|
+
this._fieldType = '';
|
|
657
|
+
this._fieldFormat = null;
|
|
658
|
+
this._fieldOptions = null;
|
|
659
|
+
this._hasChanged = false;
|
|
660
|
+
this._outputOnly = false;
|
|
661
|
+
this._tooltipText = '';
|
|
646
662
|
this.elementType = elementTypes.field;
|
|
647
663
|
const fld = (inputFieldReceived) ? inputFieldReceived : {};
|
|
648
|
-
this.setAttr(
|
|
649
|
-
this.
|
|
650
|
-
this.
|
|
651
|
-
this.
|
|
664
|
+
this.setAttr(attrs._fieldCode, fld.fieldCode);
|
|
665
|
+
this.title = (_a = fld.fieldTitle) !== null && _a !== void 0 ? _a : this._fieldCode;
|
|
666
|
+
this.type = fld.fieldTypeCode;
|
|
667
|
+
this.captureType = (_b = fld.captureType) !== null && _b !== void 0 ? _b : DEFAULT_CAPTURE_TYPE;
|
|
652
668
|
const defaultValue = (_c = fld.defaultValue) !== null && _c !== void 0 ? _c : null;
|
|
653
|
-
if (this.
|
|
654
|
-
this.
|
|
669
|
+
if (this._fieldType === this._formConfig.fieldTypes.boolean) {
|
|
670
|
+
this.defaultValue = defaultValue !== null && defaultValue !== void 0 ? defaultValue : false;
|
|
655
671
|
}
|
|
656
672
|
else {
|
|
657
|
-
this.
|
|
673
|
+
this.defaultValue = defaultValue;
|
|
658
674
|
}
|
|
659
|
-
const defaultTypeAlignment = (this._formConfig.tableFieldStyles[this.
|
|
660
|
-
? this._formConfig.tableFieldStyles[this.
|
|
675
|
+
const defaultTypeAlignment = (this._formConfig.tableFieldStyles[this._fieldType] != null)
|
|
676
|
+
? this._formConfig.tableFieldStyles[this._fieldType]['text-align'] : DEFAULT_ALIGNMENT;
|
|
661
677
|
const fieldAlignment = (fld.alignment != null) ? fld.alignment.toLowerCase() : defaultTypeAlignment;
|
|
662
|
-
this.
|
|
663
|
-
this.
|
|
678
|
+
this.alignment = fieldAlignment;
|
|
679
|
+
this.info = fld.info || '';
|
|
664
680
|
let fieldFormat;
|
|
665
681
|
try {
|
|
666
682
|
fieldFormat = (fld.format) ? new RegExp(fld.format) : null;
|
|
@@ -668,70 +684,256 @@ class FieldDescriptor extends FormElement {
|
|
|
668
684
|
catch (e) {
|
|
669
685
|
fieldFormat = null;
|
|
670
686
|
}
|
|
671
|
-
this.
|
|
672
|
-
this.
|
|
673
|
-
this.
|
|
674
|
-
this.
|
|
675
|
-
this.
|
|
676
|
-
this.
|
|
677
|
-
this.
|
|
678
|
-
|
|
679
|
-
this.
|
|
680
|
-
const intrinsicErrorMessage = (_r = (_m = (_l = (_k = (_j = this._formConfig) === null || _j === void 0 ? void 0 : _j.fieldValidations) === null || _k === void 0 ? void 0 : _k[this.fieldType]) === null || _l === void 0 ? void 0 : _l.message) !== null && _m !== void 0 ? _m : (_q = (_p = (_o = this._formConfig) === null || _o === void 0 ? void 0 : _o.fieldValidations) === null || _p === void 0 ? void 0 : _p.DEFAULT) === null || _q === void 0 ? void 0 : _q.message) !== null && _r !== void 0 ? _r : '';
|
|
681
|
-
this.setAttr(fldAttr.intrinsicErrorMessage, intrinsicErrorMessage);
|
|
687
|
+
this.format = fieldFormat;
|
|
688
|
+
this.validateOnServer = (_d = fld.serverAction) !== null && _d !== void 0 ? _d : false;
|
|
689
|
+
this.tooltip = fld.tooltip || '';
|
|
690
|
+
this.defaultEditable = this.enabled;
|
|
691
|
+
this.required = (_e = fld.required) !== null && _e !== void 0 ? _e : false;
|
|
692
|
+
this.outputOnly = (_f = fld.outputOnly) !== null && _f !== void 0 ? _f : false;
|
|
693
|
+
this.maxLength = (_g = fld.maxLength) !== null && _g !== void 0 ? _g : (this._captureType === 'TEXTAREA' ? BIG_MAX_LENGTH : STD_MAX_LENGTH);
|
|
694
|
+
this.intrinsicErrorMessage = (_q = (_l = (_k = (_j = (_h = this._formConfig) === null || _h === void 0 ? void 0 : _h.fieldValidations) === null || _j === void 0 ? void 0 : _j[this._fieldType]) === null || _k === void 0 ? void 0 : _k.message) !== null && _l !== void 0 ? _l : (_p = (_o = (_m = this._formConfig) === null || _m === void 0 ? void 0 : _m.fieldValidations) === null || _o === void 0 ? void 0 : _o.DEFAULT) === null || _p === void 0 ? void 0 : _p.message) !== null && _q !== void 0 ? _q : '';
|
|
695
|
+
this.setError(fld.errorCode, fld.errorMessage, (_r = fld.errorType) !== null && _r !== void 0 ? _r : DEFAULT_ERROR_TYPE);
|
|
682
696
|
this.setEditable((_s = fld.editable) !== null && _s !== void 0 ? _s : true);
|
|
683
|
-
this.
|
|
697
|
+
this.visibleLabel = (_t = fld.visibleLabel) !== null && _t !== void 0 ? _t : true;
|
|
684
698
|
this.setVisibility(fld.visible);
|
|
685
|
-
this.
|
|
686
|
-
this.
|
|
699
|
+
this.options = fld.fieldOptions;
|
|
700
|
+
this._setValue((_v = (_u = fld.fieldValue) !== null && _u !== void 0 ? _u : this._defaultValue) !== null && _v !== void 0 ? _v : '');
|
|
687
701
|
}
|
|
688
|
-
get
|
|
689
|
-
|
|
702
|
+
get alignment() { return this._fieldAlignment; }
|
|
703
|
+
set alignment(alignment) { this.setAttr(attrs._fieldAlignment, alignment); }
|
|
690
704
|
get attributeChange() { return this._attributeChange; }
|
|
691
|
-
get
|
|
705
|
+
get backend() { return this._validateOnServer; }
|
|
706
|
+
get captureType() { return this._captureType; }
|
|
707
|
+
set captureType(captureType) { this.setAttr(attrs._captureType, captureType); }
|
|
708
|
+
get code() { return this._fieldCode; }
|
|
709
|
+
get fieldCode() { return this._fieldCode; }
|
|
710
|
+
get defaultValue() { return this._defaultValue; }
|
|
711
|
+
set defaultValue(defaultValue) { this.setAttr(attrs._defaultValue, defaultValue); }
|
|
712
|
+
get defaultEditable() { return this._defaultEditable; }
|
|
713
|
+
set defaultEditable(editable) { this.setAttr(attrs._defaultEditable, editable); }
|
|
692
714
|
get detailRequest() { return this._detailRequest; }
|
|
693
|
-
get
|
|
694
|
-
get
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
715
|
+
get editionFinish() { return this._editionFinish; }
|
|
716
|
+
get editionPartial() { return this._editionPartial; }
|
|
717
|
+
get empty() {
|
|
718
|
+
const fieldCurrentValue = this.value;
|
|
719
|
+
if (fieldCurrentValue === undefined || fieldCurrentValue === null) {
|
|
720
|
+
return true;
|
|
721
|
+
}
|
|
722
|
+
if (this._fieldType === this._formConfig.fieldTypes.array
|
|
723
|
+
&& Array.isArray(fieldCurrentValue) && fieldCurrentValue.length === 0) {
|
|
724
|
+
return true;
|
|
725
|
+
}
|
|
726
|
+
;
|
|
727
|
+
if (this._fieldType === this._formConfig.fieldTypes.phone) {
|
|
728
|
+
if (!Array.isArray(fieldCurrentValue)) {
|
|
729
|
+
return true;
|
|
730
|
+
}
|
|
731
|
+
if (fieldCurrentValue.length !== 2 || !fieldCurrentValue[0] || !fieldCurrentValue[1]) {
|
|
732
|
+
return true;
|
|
733
|
+
}
|
|
734
|
+
return false;
|
|
735
|
+
}
|
|
736
|
+
;
|
|
737
|
+
return fieldCurrentValue === '';
|
|
707
738
|
}
|
|
739
|
+
get error() { return { type: this._errorType, code: this._errorCode, message: this._errorMessage }; }
|
|
740
|
+
set error(errorObj) { var _a; this.setError(errorObj.code, errorObj.message, (_a = errorObj.type) !== null && _a !== void 0 ? _a : DEFAULT_ERROR_TYPE); }
|
|
741
|
+
get errorCode() { return this._errorCode; }
|
|
742
|
+
set errorCode(code) { this.setError(code, this._errorMessage); }
|
|
743
|
+
get errorMessage() { return this._errorMessage; }
|
|
744
|
+
set errorMessage(msg) { this.setError(this._errorCode, msg); }
|
|
745
|
+
get errorType() { return this._errorType; }
|
|
746
|
+
get externalValue() { return this._externalValue; }
|
|
747
|
+
get format() { return this._fieldFormat; }
|
|
748
|
+
set format(format) { this.setAttr(attrs._fieldFormat, format); }
|
|
749
|
+
get hasChanged() { return this._hasChanged; }
|
|
750
|
+
set hasChanged(hasChanged) { this.setAttr(attrs._hasChanged, hasChanged); }
|
|
751
|
+
get info() { return this._fieldInfo; }
|
|
752
|
+
set info(newInfo) { this.setAttr(attrs._fieldInfo, newInfo); }
|
|
753
|
+
set intrinsicErrorMessage(message) { this.setAttr(attrs._intrinsicErrorMessage, message); }
|
|
708
754
|
get maxLength() { return (this._maxLength > 0) ? this._maxLength.toString() : ''; }
|
|
709
|
-
set maxLength(requiredMaxLength) {
|
|
710
|
-
|
|
711
|
-
|
|
755
|
+
set maxLength(requiredMaxLength) { this.setAttr(attrs._maxLength, +requiredMaxLength); }
|
|
756
|
+
get maxValue() { return this._maxValue; }
|
|
757
|
+
set maxValue(inputMaxValue) {
|
|
758
|
+
let maxValue = inputMaxValue;
|
|
759
|
+
if (this._fieldType === this._formConfig.fieldTypes.date) {
|
|
760
|
+
maxValue = new Date(maxValue);
|
|
712
761
|
}
|
|
713
|
-
|
|
714
|
-
|
|
762
|
+
this.setAttr(attrs._maxValue, maxValue);
|
|
763
|
+
}
|
|
764
|
+
get minLength() { return this._minLength; }
|
|
765
|
+
set minLength(requiredMinLength) { this.setAttr(attrs._minLength, +requiredMinLength); }
|
|
766
|
+
get minValue() { return this._minValue; }
|
|
767
|
+
set minValue(inputMinValue) {
|
|
768
|
+
let minValue = inputMinValue;
|
|
769
|
+
if (this._fieldType === this._formConfig.fieldTypes.date) {
|
|
770
|
+
minValue = new Date(minValue);
|
|
715
771
|
}
|
|
772
|
+
this.setAttr(attrs._minValue, minValue);
|
|
773
|
+
}
|
|
774
|
+
get name() { return this._fieldCode; }
|
|
775
|
+
get options() {
|
|
776
|
+
var _a, _b;
|
|
777
|
+
return (_b = (_a = this._fieldOptions) === null || _a === void 0 ? void 0 : _a.map(option => {
|
|
778
|
+
const optionCopy = Object.assign({}, option);
|
|
779
|
+
return optionCopy;
|
|
780
|
+
})) !== null && _b !== void 0 ? _b : null;
|
|
716
781
|
}
|
|
717
|
-
|
|
718
|
-
|
|
782
|
+
set options(newOptions) {
|
|
783
|
+
var _a, _b, _c, _d;
|
|
784
|
+
if ((!this._formConfig.captureTypesWithOptions.includes(this._captureType))
|
|
785
|
+
|| typeof newOptions === UNDEFINED || !newOptions
|
|
786
|
+
|| !Array.isArray(newOptions)) {
|
|
787
|
+
return;
|
|
788
|
+
}
|
|
789
|
+
let fieldOptions = newOptions.map((option) => {
|
|
790
|
+
if (option.text !== undefined && option.text !== null
|
|
791
|
+
&& option.value !== undefined && option.value !== null) {
|
|
792
|
+
return { fieldOptionValue: option.text, fieldOptionId: option.value };
|
|
793
|
+
}
|
|
794
|
+
return option;
|
|
795
|
+
});
|
|
796
|
+
fieldOptions = (fieldOptions && Array.isArray(fieldOptions)
|
|
797
|
+
&& fieldOptions.length > 0) ? fieldOptions : [];
|
|
798
|
+
this.setAttr(attrs._fieldOptions, fieldOptions);
|
|
799
|
+
if (this._value) {
|
|
800
|
+
if (this._fieldType === this._formConfig.fieldTypes.array && Array.isArray(this._value)) {
|
|
801
|
+
const fieldValue = (_a = this._value) === null || _a === void 0 ? void 0 : _a.filter(item => { var _a; return (_a = this._fieldOptions) === null || _a === void 0 ? void 0 : _a.find(opt => opt.fieldOptionId === item); });
|
|
802
|
+
this.setAttr(attrs._value, fieldValue);
|
|
803
|
+
}
|
|
804
|
+
else {
|
|
805
|
+
const valInOptions = (_b = this._fieldOptions) === null || _b === void 0 ? void 0 : _b.find(item => item.fieldOptionId === this._value);
|
|
806
|
+
if (!valInOptions) {
|
|
807
|
+
this._setValue('');
|
|
808
|
+
}
|
|
809
|
+
}
|
|
810
|
+
}
|
|
811
|
+
if (this._fieldRequired && ((_c = this._fieldOptions) === null || _c === void 0 ? void 0 : _c.length) === 1) {
|
|
812
|
+
this._setValue((_d = this._fieldOptions) === null || _d === void 0 ? void 0 : _d[0].fieldOptionId);
|
|
813
|
+
this.notifyEditionFinish();
|
|
814
|
+
}
|
|
815
|
+
}
|
|
816
|
+
get optionText() { var _a, _b, _c; return (_c = (_b = (_a = this._fieldOptions) === null || _a === void 0 ? void 0 : _a.find(item => item.fieldOptionId === this._value)) === null || _b === void 0 ? void 0 : _b.fieldOptionValue) !== null && _c !== void 0 ? _c : null; }
|
|
817
|
+
get outputOnly() { return this._outputOnly; }
|
|
818
|
+
set outputOnly(outputOnly) { this.setAttr(attrs._outputOnly, outputOnly); }
|
|
819
|
+
get required() { return this._fieldRequired; }
|
|
820
|
+
set required(required) { this.setAttr(attrs._fieldRequired, required !== null && required !== void 0 ? required : false); }
|
|
821
|
+
get title() { return this._fieldTitle; }
|
|
822
|
+
set title(title) { this.setAttr(attrs._fieldTitle, title.toString()); }
|
|
823
|
+
get tooltip() { return this._tooltipText; }
|
|
824
|
+
set tooltip(tooltip) { this.setAttr(attrs._tooltipText, tooltip); }
|
|
825
|
+
get type() { return this._fieldType; }
|
|
826
|
+
set type(fieldType) { this.setAttr(attrs._fieldType, fieldType); }
|
|
827
|
+
get validating() { return this._onValidation; }
|
|
828
|
+
set validating(isValidating) { this.setAttr(attrs._onValidation, isValidating); }
|
|
829
|
+
get value() {
|
|
830
|
+
return (this._fieldType === this._formConfig.fieldTypes.boolean
|
|
831
|
+
|| this._fieldType === this._formConfig.fieldTypes.check) ? yn(this._value) : this._value;
|
|
832
|
+
}
|
|
833
|
+
get validateOnServer() { return this._validateOnServer; }
|
|
834
|
+
set validateOnServer(validateOnServer) { this.setAttr(attrs._validateOnServer, validateOnServer); }
|
|
835
|
+
get serverAction() { return this._validateOnServer; }
|
|
836
|
+
set serverAction(validateOnServer) { this.validateOnServer = validateOnServer; }
|
|
837
|
+
set value(newValue) { this._setValue(newValue); }
|
|
838
|
+
get visibleLabel() { return this._visibleLabel; }
|
|
839
|
+
set visibleLabel(visibleLabel) { this.setAttr(attrs._visibleLabel, visibleLabel); }
|
|
840
|
+
/**
|
|
841
|
+
* @deprecated Use options
|
|
842
|
+
*/
|
|
843
|
+
get fieldOptions() { return this._fieldOptions; }
|
|
844
|
+
/**
|
|
845
|
+
* @deprecated Use options
|
|
846
|
+
*/
|
|
847
|
+
set fieldOptions(options) { this.options = options; }
|
|
848
|
+
/**
|
|
849
|
+
* @deprecated Use value
|
|
850
|
+
*/
|
|
851
|
+
get fieldValue() { return this.value; }
|
|
852
|
+
/**
|
|
853
|
+
* @deprecated Use hasChanged
|
|
854
|
+
*/
|
|
855
|
+
changed(hasChanged = true) { this.hasChanged = hasChanged; }
|
|
856
|
+
clean() { this._setValue(this._defaultValue || ''); this.resetError(); }
|
|
857
|
+
focus() { this.setAttr(attrs._focus, true); }
|
|
858
|
+
getErrorCode() { return this.error.code; }
|
|
859
|
+
setErrorCode(code) { this.setError(code, this._errorMessage); }
|
|
860
|
+
getErrorMessage() { return this.error.message; }
|
|
861
|
+
setErrorMessage(msg) { this.setError(this._errorCode, msg); }
|
|
862
|
+
getRequired() { return this.required; }
|
|
863
|
+
hasError() { return this._errorCode !== NO_ERROR; }
|
|
864
|
+
hideLabel() { this.visibleLabel = false; }
|
|
865
|
+
resetError() { (this._errorCode !== NO_ERROR) && this.setError(NO_ERROR, null); }
|
|
866
|
+
setEditable(editable = true) { (editable) ? this.enable() : this.disable(); }
|
|
867
|
+
setValue(newValue, widgetUpdate = true) { this._setValue(newValue, widgetUpdate); }
|
|
868
|
+
showLabel() { this.visibleLabel = true; }
|
|
869
|
+
/**
|
|
870
|
+
* @deprecated Use title
|
|
871
|
+
*/
|
|
872
|
+
setLabel(label) { this.title = label; }
|
|
873
|
+
/**
|
|
874
|
+
* @deprecated Use required
|
|
875
|
+
*/
|
|
876
|
+
setRequired(required) { this.required = required; }
|
|
877
|
+
/**
|
|
878
|
+
* @deprecated Use changed
|
|
879
|
+
*/
|
|
880
|
+
setChanged(hasChanged) { this.changed(hasChanged); }
|
|
881
|
+
/**
|
|
882
|
+
* @deprecated Use value
|
|
883
|
+
*/
|
|
884
|
+
getValue() { return this.value; }
|
|
885
|
+
/**
|
|
886
|
+
* @deprecated Use empty
|
|
887
|
+
*/
|
|
888
|
+
isEmpty() { return this.empty; }
|
|
889
|
+
/**
|
|
890
|
+
* @deprecated Use error
|
|
891
|
+
*/
|
|
892
|
+
getError() { return this.error; }
|
|
893
|
+
/**
|
|
894
|
+
* @deprecated Use optionText
|
|
895
|
+
*/
|
|
896
|
+
getOptionText() { return this.optionText; }
|
|
897
|
+
/**
|
|
898
|
+
* @deprecated Use options
|
|
899
|
+
*/
|
|
900
|
+
getFieldOptions() { return this.options; }
|
|
901
|
+
/**
|
|
902
|
+
* @deprecated Use options
|
|
903
|
+
*/
|
|
904
|
+
setFieldOptions(newOptions) { return this.options = newOptions; }
|
|
905
|
+
/**
|
|
906
|
+
* @deprecated Use intrinsicErrorMessage
|
|
907
|
+
*/
|
|
908
|
+
setIntrinsicErrorMessage(message) { this.intrinsicErrorMessage = message; }
|
|
909
|
+
/**
|
|
910
|
+
* @deprecated Use maxValue
|
|
911
|
+
*/
|
|
912
|
+
setMaxValue(inputMaxValue) { this.maxValue = inputMaxValue; }
|
|
913
|
+
/**
|
|
914
|
+
* @deprecated Use minValue
|
|
915
|
+
*/
|
|
916
|
+
setMinValue(inputMinValue) { this.minValue = inputMinValue; }
|
|
917
|
+
/**
|
|
918
|
+
* @deprecated Use showLabel
|
|
919
|
+
*/
|
|
920
|
+
setVisibleLabel(visibleLabel) { this.visibleLabel = visibleLabel; }
|
|
719
921
|
notifyEditionPartial() {
|
|
720
922
|
this.resetError();
|
|
721
|
-
this._editionPartial.next({ code: this.
|
|
923
|
+
this._editionPartial.next({ code: this._fieldCode, intrinsicValidation: true });
|
|
722
924
|
}
|
|
723
925
|
notifyEditionFinish() {
|
|
724
926
|
var _a, _b, _c, _d, _e;
|
|
725
|
-
const fieldValue = this.
|
|
927
|
+
const fieldValue = this.value;
|
|
726
928
|
this.resetError();
|
|
727
|
-
const validationConfig = (_b = (_a = this._formConfig.fieldValidations) === null || _a === void 0 ? void 0 : _a[this.
|
|
929
|
+
const validationConfig = (_b = (_a = this._formConfig.fieldValidations) === null || _a === void 0 ? void 0 : _a[this._fieldType]) !== null && _b !== void 0 ? _b : {};
|
|
728
930
|
const { type, validation } = validationConfig;
|
|
729
931
|
let message = validationConfig === null || validationConfig === void 0 ? void 0 : validationConfig.message;
|
|
730
932
|
let intrinsicValidation = true;
|
|
731
|
-
if (fieldValue && (validation || this.
|
|
933
|
+
if (fieldValue && (validation || this._fieldFormat)) {
|
|
732
934
|
if (type === 'regexp') {
|
|
733
935
|
intrinsicValidation = ((_c = validation === null || validation === void 0 ? void 0 : validation.test(fieldValue)) !== null && _c !== void 0 ? _c : true)
|
|
734
|
-
&& ((_e = (_d = this.
|
|
936
|
+
&& ((_e = (_d = this._fieldFormat) === null || _d === void 0 ? void 0 : _d.test(fieldValue)) !== null && _e !== void 0 ? _e : true);
|
|
735
937
|
}
|
|
736
938
|
else if (type === 'function' && typeof validation === 'function') {
|
|
737
939
|
const { valid, message: customMessage } = validation(fieldValue, this);
|
|
@@ -753,157 +955,48 @@ class FieldDescriptor extends FormElement {
|
|
|
753
955
|
if (intrinsicValidation && fieldValue && typeof fieldValue === 'string'
|
|
754
956
|
&& this._minLength && (fieldValue === null || fieldValue === void 0 ? void 0 : fieldValue.length) < this._minLength) {
|
|
755
957
|
intrinsicValidation = false;
|
|
756
|
-
this.setError('99', `Longitud de ${this.
|
|
757
|
-
}
|
|
758
|
-
this._editionFinish.next({ code: this.fieldCode, intrinsicValidation });
|
|
759
|
-
}
|
|
760
|
-
setAttr(name, value) {
|
|
761
|
-
this[name] = value;
|
|
762
|
-
if (this._formConfig.monitoredFieldAttributes.includes(name)) {
|
|
763
|
-
this._attributeChange.next({ name, value });
|
|
958
|
+
this.setError('99', `Longitud de ${this._fieldTitle} debe ser de al menos ${this._minLength}`);
|
|
764
959
|
}
|
|
960
|
+
this._editionFinish.next({ code: this._fieldCode, intrinsicValidation });
|
|
765
961
|
}
|
|
766
962
|
notifyEditionDetailRequest(detail) {
|
|
767
|
-
const detailEvent = {
|
|
768
|
-
code: this.fieldCode,
|
|
769
|
-
detail,
|
|
770
|
-
};
|
|
963
|
+
const detailEvent = { code: this._fieldCode, detail };
|
|
771
964
|
this._detailRequest.next(detailEvent);
|
|
772
965
|
}
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
changed() { this.setChanged(true); }
|
|
778
|
-
setLabel(label) { this.setAttr(fldAttr.title, label); }
|
|
779
|
-
clean() { this.setValue(this.defaultValue || ''); this.resetError(); }
|
|
780
|
-
get backend() { return this.validateOnServer; }
|
|
781
|
-
setEditable(editable = true) { (editable) ? this.enable() : this.disable(); }
|
|
782
|
-
hasError() { return this.errorCode !== NO_ERROR; }
|
|
783
|
-
resetError() { (this.errorCode !== NO_ERROR) && this.setError(NO_ERROR, null); }
|
|
784
|
-
setError(code, message, type = DEFAULT_ERROR_TYPE) {
|
|
785
|
-
this.setAttr(fldAttr.errorCode, code !== null && code !== void 0 ? code : NO_ERROR);
|
|
786
|
-
this.setAttr(fldAttr.errorType, (this.errorCode === NO_ERROR) ? '' : type);
|
|
787
|
-
this.setAttr(fldAttr.errorMessage, message !== null && message !== void 0 ? message : '');
|
|
788
|
-
}
|
|
789
|
-
getError() { return { type: this.errorType, code: this.errorCode, message: this.errorMessage }; }
|
|
790
|
-
get error() { return this.getError(); }
|
|
791
|
-
set error(errorObj) { var _a; this.setError(errorObj.code, errorObj.message, (_a = errorObj.type) !== null && _a !== void 0 ? _a : DEFAULT_ERROR_TYPE); }
|
|
792
|
-
getErrorCode() { return this.getError().code; }
|
|
793
|
-
setErrorCode(code) { this.setError(code, this.errorMessage); }
|
|
794
|
-
getErrorMessage() { return this.getError().message; }
|
|
795
|
-
setErrorMessage(msg) { this.setError(this.errorCode, msg); }
|
|
796
|
-
get empty() { return this.isEmpty(); }
|
|
797
|
-
isEmpty() {
|
|
798
|
-
const fieldCurrentValue = this.getValue();
|
|
799
|
-
if (fieldCurrentValue === undefined || fieldCurrentValue === null) {
|
|
800
|
-
return true;
|
|
801
|
-
}
|
|
802
|
-
if (this.fieldType === this._formConfig.fieldTypes.array
|
|
803
|
-
&& Array.isArray(fieldCurrentValue) && fieldCurrentValue.length === 0) {
|
|
804
|
-
return true;
|
|
805
|
-
}
|
|
806
|
-
;
|
|
807
|
-
if (this.fieldType === this._formConfig.fieldTypes.phone) {
|
|
808
|
-
if (!Array.isArray(fieldCurrentValue)) {
|
|
809
|
-
return true;
|
|
810
|
-
}
|
|
811
|
-
if (fieldCurrentValue.length !== 2 || !fieldCurrentValue[0] || !fieldCurrentValue[1]) {
|
|
812
|
-
return true;
|
|
813
|
-
}
|
|
814
|
-
return false;
|
|
815
|
-
}
|
|
816
|
-
;
|
|
817
|
-
return fieldCurrentValue === '';
|
|
818
|
-
}
|
|
819
|
-
getValue() {
|
|
820
|
-
if (this.fieldType === this._formConfig.fieldTypes.boolean
|
|
821
|
-
|| this.fieldType === this._formConfig.fieldTypes.check) {
|
|
822
|
-
return yn(this._value);
|
|
823
|
-
}
|
|
824
|
-
return this._value;
|
|
966
|
+
setAttr(attr, value) {
|
|
967
|
+
const { name: attrName, propagate: name } = attr;
|
|
968
|
+
this[attrName] = value;
|
|
969
|
+
name && this._attributeChange.next({ name, value });
|
|
825
970
|
}
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
971
|
+
setError(code, message, type = DEFAULT_ERROR_TYPE) {
|
|
972
|
+
this.setAttr(attrs._errorCode, code !== null && code !== void 0 ? code : NO_ERROR);
|
|
973
|
+
this.setAttr(attrs._errorType, (this._errorCode === NO_ERROR) ? '' : type);
|
|
974
|
+
this.setAttr(attrs._errorMessage, message !== null && message !== void 0 ? message : '');
|
|
829
975
|
}
|
|
830
976
|
updateFromServer(fld) {
|
|
831
|
-
var _a;
|
|
832
977
|
const fieldKeys = Object.keys(fld);
|
|
833
978
|
for (let index = 0; index < fieldKeys.length; index++) {
|
|
834
979
|
const attrName = fieldKeys[index];
|
|
835
980
|
const attrValue = fld[attrName];
|
|
836
|
-
(attrName
|
|
837
|
-
|
|
838
|
-
(attrName === this._formConfig.apiFieldAttrs.required) && this.setAttr(fldAttr.required, (_a = fld.required) !== null && _a !== void 0 ? _a : false);
|
|
839
|
-
(attrName === this._formConfig.apiFieldAttrs.errorCode) && this.setAttr(fldAttr.errorCode, fld.errorCode);
|
|
840
|
-
(attrName === this._formConfig.apiFieldAttrs.errorMessage) && this.setAttr(fldAttr.errorMessage, fld.errorMessage);
|
|
841
|
-
(attrName === this._formConfig.apiFieldAttrs.tooltip) && this.setAttr(fldAttr.tooltipText, fld.tooltip);
|
|
842
|
-
(attrName === this._formConfig.apiFieldAttrs.info) && this.setAttr(fldAttr.info, fld.info);
|
|
843
|
-
(attrName === this._formConfig.apiFieldAttrs.editable) && this.setEditable(fld.editable);
|
|
844
|
-
(attrName === this._formConfig.apiFieldAttrs.title) && this.setLabel(fld.fieldTitle.toString());
|
|
845
|
-
(attrName === this._formConfig.apiFieldAttrs.value) && (this.setValue(fld.fieldValue) && this.setChanged(false));
|
|
846
|
-
(attrName === this._formConfig.apiFieldAttrs.options) && this.setFieldOptions(fld.fieldOptions);
|
|
847
|
-
(attrName === this._formConfig.apiFieldAttrs.captureType) && this.setAttr(fldAttr.captureType, fld.captureType || 'INPUT');
|
|
848
|
-
(attrName === this._formConfig.apiFieldAttrs.type) && this.setAttr(fldAttr.type, fld.fieldTypeCode);
|
|
849
|
-
(attrName === this._formConfig.apiFieldAttrs.maxLength) && this.setAttr(fldAttr.maxLength, fld.maxLength);
|
|
850
|
-
}
|
|
851
|
-
}
|
|
852
|
-
setMinValue(inputMinValue) {
|
|
853
|
-
let minValue = inputMinValue;
|
|
854
|
-
if (this.fieldType === this._formConfig.fieldTypes.date) {
|
|
855
|
-
minValue = new Date(minValue);
|
|
856
|
-
}
|
|
857
|
-
this.setAttr(fldAttr.minValue, minValue);
|
|
858
|
-
}
|
|
859
|
-
setMaxValue(inputMaxValue) {
|
|
860
|
-
let maxValue = inputMaxValue;
|
|
861
|
-
if (this.fieldType === this._formConfig.fieldTypes.date) {
|
|
862
|
-
maxValue = new Date(maxValue);
|
|
863
|
-
}
|
|
864
|
-
this.setAttr(fldAttr.maxValue, maxValue);
|
|
865
|
-
}
|
|
866
|
-
getFieldOptions() {
|
|
867
|
-
return this.fieldOptions.map(option => {
|
|
868
|
-
const optionCopy = Object.assign({}, option);
|
|
869
|
-
return optionCopy;
|
|
870
|
-
});
|
|
871
|
-
}
|
|
872
|
-
setFieldOptions(newOptions) {
|
|
873
|
-
var _a;
|
|
874
|
-
if ((!this._formConfig.captureTypesWithOptions.includes(this.captureType))
|
|
875
|
-
|| typeof newOptions === UNDEFINED || !newOptions
|
|
876
|
-
|| !Array.isArray(newOptions)) {
|
|
877
|
-
return;
|
|
878
|
-
}
|
|
879
|
-
let fieldOptions = newOptions.map(option => {
|
|
880
|
-
if (option.text !== undefined && option.text !== null
|
|
881
|
-
&& option.value !== undefined && option.value !== null) {
|
|
882
|
-
return { fieldOptionValue: option.text, fieldOptionId: option.value };
|
|
883
|
-
}
|
|
884
|
-
return Object.assign({}, option);
|
|
885
|
-
});
|
|
886
|
-
fieldOptions = (fieldOptions && Array.isArray(fieldOptions)
|
|
887
|
-
&& fieldOptions.length > 0) ? fieldOptions : [];
|
|
888
|
-
this.setAttr(fldAttr.options, fieldOptions);
|
|
889
|
-
if (this._value) {
|
|
890
|
-
if (this.fieldType === this._formConfig.fieldTypes.array && Array.isArray(this._value)) {
|
|
891
|
-
const fieldValue = (_a = this._value) === null || _a === void 0 ? void 0 : _a.filter(item => this.fieldOptions.find(opt => opt.fieldOptionId === item));
|
|
892
|
-
this.setAttr(fldAttr.value, fieldValue);
|
|
981
|
+
if (directChanges.includes(attrName)) {
|
|
982
|
+
this[attrName] = attrValue;
|
|
893
983
|
}
|
|
894
984
|
else {
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
985
|
+
(attrName === 'label') && (this.title = attrValue);
|
|
986
|
+
(attrName === 'labelVisible') && (this.visibleLabel = attrValue);
|
|
987
|
+
(attrName === 'editable') && this.setEditable(attrValue);
|
|
988
|
+
(attrName === 'visible') && this.setVisibility(attrValue);
|
|
989
|
+
(attrName === 'value') && (this._setValue(attrValue) && (this.hasChanged = false));
|
|
990
|
+
(attrName === 'fieldValue') && (this._setValue(attrValue) && (this.hasChanged = false));
|
|
991
|
+
(attrName === 'fieldOptions') && (this.options = attrValue);
|
|
992
|
+
(attrName === 'fieldTitle') && (this.title = attrValue);
|
|
993
|
+
(attrName === 'fieldTypeCode') && (this.type = attrValue);
|
|
994
|
+
(attrName === 'fieldType') && (this.type = attrValue);
|
|
995
|
+
(attrName === 'tooltipText') && (this.tooltip = attrValue);
|
|
900
996
|
}
|
|
901
997
|
}
|
|
902
|
-
if (this.fieldRequired && this.fieldOptions.length === 1) {
|
|
903
|
-
this.setValue(this.fieldOptions[0].fieldOptionId);
|
|
904
|
-
}
|
|
905
998
|
}
|
|
906
|
-
|
|
999
|
+
_setValue(newValue, widgetUpdate = true) {
|
|
907
1000
|
var _a;
|
|
908
1001
|
if (typeof newValue === UNDEFINED) {
|
|
909
1002
|
return true;
|
|
@@ -912,12 +1005,12 @@ class FieldDescriptor extends FormElement {
|
|
|
912
1005
|
return true;
|
|
913
1006
|
}
|
|
914
1007
|
let newFinalValue;
|
|
915
|
-
if (this.
|
|
916
|
-
|| this.
|
|
1008
|
+
if (this._fieldType === this._formConfig.fieldTypes.boolean
|
|
1009
|
+
|| this._fieldType === this._formConfig.fieldTypes.check) {
|
|
917
1010
|
newFinalValue = (_a = yn(newValue)) !== null && _a !== void 0 ? _a : false;
|
|
918
1011
|
}
|
|
919
|
-
else if (this.
|
|
920
|
-
|| this.
|
|
1012
|
+
else if (this._fieldType === this._formConfig.fieldTypes.array
|
|
1013
|
+
|| this._fieldType === this._formConfig.fieldTypes.map) {
|
|
921
1014
|
if (newValue === null || newValue === '') {
|
|
922
1015
|
newFinalValue = [];
|
|
923
1016
|
}
|
|
@@ -932,9 +1025,9 @@ class FieldDescriptor extends FormElement {
|
|
|
932
1025
|
newFinalValue = newValue;
|
|
933
1026
|
}
|
|
934
1027
|
if (this._value !== newFinalValue) {
|
|
935
|
-
this.
|
|
1028
|
+
this.hasChanged = true;
|
|
936
1029
|
if (widgetUpdate) {
|
|
937
|
-
this.setAttr(
|
|
1030
|
+
this.setAttr(attrs._value, newFinalValue);
|
|
938
1031
|
}
|
|
939
1032
|
else {
|
|
940
1033
|
this._value = newFinalValue;
|
|
@@ -1582,7 +1675,7 @@ class RecordFormSubSection {
|
|
|
1582
1675
|
return this.subSectionFields;
|
|
1583
1676
|
}
|
|
1584
1677
|
getFieldNames() {
|
|
1585
|
-
return this.subSectionFields.map(field => field.
|
|
1678
|
+
return this.subSectionFields.map(field => field.code);
|
|
1586
1679
|
}
|
|
1587
1680
|
getActions() {
|
|
1588
1681
|
return this.subSectionActions;
|
|
@@ -1799,7 +1892,7 @@ class FormStructureAndData {
|
|
|
1799
1892
|
});
|
|
1800
1893
|
for (const fieldReceived of formFields) {
|
|
1801
1894
|
const fieldToAdd = new FieldDescriptor(fieldReceived, this._formConfig);
|
|
1802
|
-
const fieldCode = fieldToAdd.
|
|
1895
|
+
const fieldCode = fieldToAdd.code;
|
|
1803
1896
|
if (fieldCode) {
|
|
1804
1897
|
this._fieldArray.push(fieldToAdd);
|
|
1805
1898
|
this._fields[fieldCode] = fieldToAdd;
|
|
@@ -1894,13 +1987,13 @@ class FormStructureAndData {
|
|
|
1894
1987
|
get fields() { return this._fields; }
|
|
1895
1988
|
get fieldNames() { return this.getFieldNames(); }
|
|
1896
1989
|
getFields() { return this._fieldArray; }
|
|
1897
|
-
getFieldNames() { return this._fieldArray.map(field => field.
|
|
1990
|
+
getFieldNames() { return this._fieldArray.map(field => field.code); }
|
|
1898
1991
|
getField(code) { var _a; return (code && ((_a = this._fields) === null || _a === void 0 ? void 0 : _a[code])) ? this._fields[code] : null; }
|
|
1899
1992
|
enableField(code) { var _a; (_a = this.getField(code)) === null || _a === void 0 ? void 0 : _a.enable(); }
|
|
1900
1993
|
disableField(code) { var _a; (_a = this.getField(code)) === null || _a === void 0 ? void 0 : _a.disable(); }
|
|
1901
|
-
getFieldValue(code) { var _a; return (_a = this.getField(code)) === null || _a === void 0 ? void 0 : _a.
|
|
1902
|
-
getFieldOptionText(code) { var _a; return (_a = this.getField(code)) === null || _a === void 0 ? void 0 : _a.
|
|
1903
|
-
getFieldOptions(code) { var _a, _b; return (_b = (_a = this.getField(code)) === null || _a === void 0 ? void 0 : _a.
|
|
1994
|
+
getFieldValue(code) { var _a; return (_a = this.getField(code)) === null || _a === void 0 ? void 0 : _a.value; }
|
|
1995
|
+
getFieldOptionText(code) { var _a; return (_a = this.getField(code)) === null || _a === void 0 ? void 0 : _a.optionText; }
|
|
1996
|
+
getFieldOptions(code) { var _a, _b; return (_b = (_a = this.getField(code)) === null || _a === void 0 ? void 0 : _a.options) !== null && _b !== void 0 ? _b : null; }
|
|
1904
1997
|
setFieldValue(code, value) { var _a; (_a = this.getField(code)) === null || _a === void 0 ? void 0 : _a.setValue(value); }
|
|
1905
1998
|
setFieldError(code, errorCode, message, type = 'error') { var _a; (_a = this.getField(code)) === null || _a === void 0 ? void 0 : _a.setError(errorCode, message, type); }
|
|
1906
1999
|
setFieldIntrinsicErrorMessage(code, message) { var _a; (_a = this.getField(code)) === null || _a === void 0 ? void 0 : _a.setIntrinsicErrorMessage(message); }
|
|
@@ -1909,7 +2002,8 @@ class FormStructureAndData {
|
|
|
1909
2002
|
const codes = this.getFieldSet(null, inputCodes !== null && inputCodes !== void 0 ? inputCodes : null);
|
|
1910
2003
|
for (const code of codes) {
|
|
1911
2004
|
try {
|
|
1912
|
-
(_a = this.getField(code))
|
|
2005
|
+
const field = (_a = this.getField(code)) !== null && _a !== void 0 ? _a : null;
|
|
2006
|
+
field && (field.required = required);
|
|
1913
2007
|
}
|
|
1914
2008
|
catch (e) {
|
|
1915
2009
|
console.log(`Error modificando campo ${code}: ${e}`);
|
|
@@ -1970,28 +2064,28 @@ class FormStructureAndData {
|
|
|
1970
2064
|
return processedFields;
|
|
1971
2065
|
}
|
|
1972
2066
|
enableFields(codes, secCode, subCode) {
|
|
1973
|
-
return this.applyOnFields(fld => fld.enable(), codes, secCode, subCode);
|
|
2067
|
+
return this.applyOnFields(fld => fld === null || fld === void 0 ? void 0 : fld.enable(), codes, secCode, subCode);
|
|
1974
2068
|
}
|
|
1975
2069
|
showFields(codes, secCode, subCode) {
|
|
1976
|
-
return this.applyOnFields(fld => fld.show(), codes, secCode, subCode);
|
|
2070
|
+
return this.applyOnFields(fld => fld === null || fld === void 0 ? void 0 : fld.show(), codes, secCode, subCode);
|
|
1977
2071
|
}
|
|
1978
2072
|
hideFields(codes, secCode, subCode) {
|
|
1979
|
-
return this.applyOnFields(fld => fld.hide(), codes, secCode, subCode);
|
|
2073
|
+
return this.applyOnFields(fld => fld === null || fld === void 0 ? void 0 : fld.hide(), codes, secCode, subCode);
|
|
1980
2074
|
}
|
|
1981
2075
|
showLabelFields(codes, secCode, subCode) {
|
|
1982
|
-
return this.applyOnFields(fld => fld.showLablel(), codes, secCode, subCode);
|
|
2076
|
+
return this.applyOnFields(fld => fld === null || fld === void 0 ? void 0 : fld.showLablel(), codes, secCode, subCode);
|
|
1983
2077
|
}
|
|
1984
2078
|
hideLabelFields(codes, secCode, subCode) {
|
|
1985
|
-
return this.applyOnFields(fld => fld.hideLabel(), codes, secCode, subCode);
|
|
2079
|
+
return this.applyOnFields(fld => fld === null || fld === void 0 ? void 0 : fld.hideLabel(), codes, secCode, subCode);
|
|
1986
2080
|
}
|
|
1987
2081
|
disableFields(codes, secCode, subCode) {
|
|
1988
|
-
return this.applyOnFields(fld => fld.disable(), codes, secCode, subCode);
|
|
2082
|
+
return this.applyOnFields(fld => fld === null || fld === void 0 ? void 0 : fld.disable(), codes, secCode, subCode);
|
|
1989
2083
|
}
|
|
1990
2084
|
cleanFields(codes, secCode, subCode) {
|
|
1991
|
-
return this.applyOnFields(fld => fld.clean(), codes, secCode, subCode);
|
|
2085
|
+
return this.applyOnFields(fld => fld === null || fld === void 0 ? void 0 : fld.clean(), codes, secCode, subCode);
|
|
1992
2086
|
}
|
|
1993
2087
|
tagFieldsWithError(message, codes, secCode, subCode) {
|
|
1994
|
-
return this.applyOnFields(fld => fld.setErrorMessage(message), codes, secCode, subCode);
|
|
2088
|
+
return this.applyOnFields(fld => fld === null || fld === void 0 ? void 0 : fld.setErrorMessage(message), codes, secCode, subCode);
|
|
1995
2089
|
}
|
|
1996
2090
|
cleanErrorFields(codes, secCode, subCode) {
|
|
1997
2091
|
return this.tagFieldsWithError('', codes, secCode, subCode);
|
|
@@ -2000,16 +2094,16 @@ class FormStructureAndData {
|
|
|
2000
2094
|
return this.tagFieldsWithError(message, this.getRequiredEmptyFields(codes, secCode, subCode)) > 0;
|
|
2001
2095
|
}
|
|
2002
2096
|
getRequiredFields(codes, secCode, subCode) {
|
|
2003
|
-
return this.getFieldSet(fld => fld.required, codes !== null && codes !== void 0 ? codes : null, secCode, subCode);
|
|
2097
|
+
return this.getFieldSet(fld => fld === null || fld === void 0 ? void 0 : fld.required, codes !== null && codes !== void 0 ? codes : null, secCode, subCode);
|
|
2004
2098
|
}
|
|
2005
2099
|
getRequiredEmptyFields(codes, secCode, subCode) {
|
|
2006
|
-
return this.getFieldSet(fld => fld.required && fld.empty, codes !== null && codes !== void 0 ? codes : null, secCode, subCode);
|
|
2100
|
+
return this.getFieldSet(fld => (fld === null || fld === void 0 ? void 0 : fld.required) && (fld === null || fld === void 0 ? void 0 : fld.empty), codes !== null && codes !== void 0 ? codes : null, secCode, subCode);
|
|
2007
2101
|
}
|
|
2008
2102
|
getChangedFields(codes, secCode, subCode) {
|
|
2009
|
-
return this.getFieldSet(fld => !fld.outputOnly && fld.hasChanged(), codes !== null && codes !== void 0 ? codes : null, secCode, subCode);
|
|
2103
|
+
return this.getFieldSet(fld => !(fld === null || fld === void 0 ? void 0 : fld.outputOnly) && (fld === null || fld === void 0 ? void 0 : fld.hasChanged()), codes !== null && codes !== void 0 ? codes : null, secCode, subCode);
|
|
2010
2104
|
}
|
|
2011
2105
|
getFieldsWithValidationIssues(codes, secCode, subCode) {
|
|
2012
|
-
return this.getFieldSet(fld => fld
|
|
2106
|
+
return this.getFieldSet(fld => fld === null || fld === void 0 ? void 0 : fld.hasError(), codes !== null && codes !== void 0 ? codes : null, secCode, subCode);
|
|
2013
2107
|
}
|
|
2014
2108
|
getFieldsValues(inputCodes, secCode, subCode) {
|
|
2015
2109
|
var _a, _b, _c;
|
|
@@ -2127,14 +2221,14 @@ class FormStructureAndData {
|
|
|
2127
2221
|
fields: [],
|
|
2128
2222
|
tables: [],
|
|
2129
2223
|
};
|
|
2130
|
-
formData.fields = this.getFields().filter(fld => !fld.outputOnly)
|
|
2224
|
+
formData.fields = this.getFields().filter(fld => !(fld === null || fld === void 0 ? void 0 : fld.outputOnly))
|
|
2131
2225
|
.map(fld => {
|
|
2132
2226
|
const fieldPayload = {
|
|
2133
|
-
fieldCode: fld.
|
|
2134
|
-
fieldValue: fld.
|
|
2135
|
-
editable: !fld.disabled,
|
|
2136
|
-
visible: fld.visible,
|
|
2137
|
-
required: fld.required,
|
|
2227
|
+
fieldCode: fld === null || fld === void 0 ? void 0 : fld.code,
|
|
2228
|
+
fieldValue: fld === null || fld === void 0 ? void 0 : fld.value,
|
|
2229
|
+
editable: !(fld === null || fld === void 0 ? void 0 : fld.disabled),
|
|
2230
|
+
visible: fld === null || fld === void 0 ? void 0 : fld.visible,
|
|
2231
|
+
required: fld === null || fld === void 0 ? void 0 : fld.required,
|
|
2138
2232
|
fieldOptions: '',
|
|
2139
2233
|
};
|
|
2140
2234
|
return fieldPayload;
|
|
@@ -2280,6 +2374,7 @@ class BasicFormComponent {
|
|
|
2280
2374
|
this._formRoute = null;
|
|
2281
2375
|
this._definitionObtained = false;
|
|
2282
2376
|
// Eventos de acciones y campos
|
|
2377
|
+
this._formSectionsCanDeactivate = {};
|
|
2283
2378
|
this._formSectionsActivate = {};
|
|
2284
2379
|
this._formSectionsInactivate = {};
|
|
2285
2380
|
this._formActionsStart = {};
|
|
@@ -2580,6 +2675,7 @@ class BasicFormComponent {
|
|
|
2580
2675
|
// Se limpian los manejadores de eventos
|
|
2581
2676
|
this.visible = false;
|
|
2582
2677
|
this.busy = false;
|
|
2678
|
+
this._formSectionsCanDeactivate = {};
|
|
2583
2679
|
this._formSectionsActivate = {};
|
|
2584
2680
|
this._formSectionsInactivate = {};
|
|
2585
2681
|
this._formActionsStart = {};
|
|
@@ -2622,7 +2718,7 @@ class BasicFormComponent {
|
|
|
2622
2718
|
displayActionServerError() { }
|
|
2623
2719
|
displayValidationServerError() { }
|
|
2624
2720
|
displayTableServerError() { }
|
|
2625
|
-
showFieldInfo(
|
|
2721
|
+
showFieldInfo(code, detail) { }
|
|
2626
2722
|
showModalDialog(title, body, options, callback, params) { }
|
|
2627
2723
|
openUploadDialog(title, body, options, callback, params) { }
|
|
2628
2724
|
/**
|
|
@@ -2799,9 +2895,9 @@ class BasicFormComponent {
|
|
|
2799
2895
|
(_f = this._formStructure) === null || _f === void 0 ? void 0 : _f.changeState(initialState || ((_g = this._formStructure) === null || _g === void 0 ? void 0 : _g.defaultState));
|
|
2800
2896
|
const inputFieldNames = Object.keys(this.inputDataFields);
|
|
2801
2897
|
for (let index = 0; index < inputFieldNames.length; index++) {
|
|
2802
|
-
const
|
|
2803
|
-
const fieldValue = this.inputDataFields[
|
|
2804
|
-
this.setFieldValue(
|
|
2898
|
+
const code = inputFieldNames[index];
|
|
2899
|
+
const fieldValue = this.inputDataFields[code];
|
|
2900
|
+
this.setFieldValue(code, fieldValue);
|
|
2805
2901
|
}
|
|
2806
2902
|
const recordResponse = yield this.requestFormAction(formActions.getData);
|
|
2807
2903
|
this.checkErrorRecordReceived(recordResponse);
|
|
@@ -2929,6 +3025,15 @@ class BasicFormComponent {
|
|
|
2929
3025
|
/**
|
|
2930
3026
|
* Manejo de event handlers para acciones sobre el formulario
|
|
2931
3027
|
*/
|
|
3028
|
+
onSectionCanDeactivate(codes, callback, properties = null) {
|
|
3029
|
+
const sectionSet = (Array.isArray(codes)) ? codes : (codes ? [codes] : []);
|
|
3030
|
+
sectionSet.forEach((sectionName) => {
|
|
3031
|
+
if (!this._formSectionsCanDeactivate[sectionName]) {
|
|
3032
|
+
this._formSectionsCanDeactivate[sectionName] = [];
|
|
3033
|
+
}
|
|
3034
|
+
this._formSectionsCanDeactivate[sectionName].push({ callback, properties });
|
|
3035
|
+
});
|
|
3036
|
+
}
|
|
2932
3037
|
onSectionActivation(codes, callback, properties = null) {
|
|
2933
3038
|
const sectionSet = (Array.isArray(codes)) ? codes : (codes ? [codes] : []);
|
|
2934
3039
|
sectionSet.forEach((sectionName) => {
|
|
@@ -2965,6 +3070,26 @@ class BasicFormComponent {
|
|
|
2965
3070
|
this._formActionsFinish[actionName].push({ callback, properties });
|
|
2966
3071
|
});
|
|
2967
3072
|
}
|
|
3073
|
+
verifySectionActivation(code) {
|
|
3074
|
+
var _a;
|
|
3075
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
3076
|
+
const sectionObject = (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.getSection(code);
|
|
3077
|
+
if (!sectionObject) {
|
|
3078
|
+
return false;
|
|
3079
|
+
}
|
|
3080
|
+
const clientSectionMethods = this._formSectionsCanDeactivate[code];
|
|
3081
|
+
if (clientSectionMethods) {
|
|
3082
|
+
for (const clientSectionMethod of clientSectionMethods) {
|
|
3083
|
+
const { callback, properties } = clientSectionMethod;
|
|
3084
|
+
const canActivate = callback(sectionObject);
|
|
3085
|
+
if (canActivate === false) {
|
|
3086
|
+
return false;
|
|
3087
|
+
}
|
|
3088
|
+
}
|
|
3089
|
+
}
|
|
3090
|
+
return true;
|
|
3091
|
+
});
|
|
3092
|
+
}
|
|
2968
3093
|
launchSectionActivation(code) {
|
|
2969
3094
|
var _a;
|
|
2970
3095
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -3071,38 +3196,38 @@ class BasicFormComponent {
|
|
|
3071
3196
|
*/
|
|
3072
3197
|
onFieldInput(codes, callback, properties = null) {
|
|
3073
3198
|
const fieldSet = (Array.isArray(codes)) ? codes : (codes ? [codes] : []);
|
|
3074
|
-
fieldSet.forEach((
|
|
3075
|
-
if (!this._fieldInputValidation[
|
|
3076
|
-
this._fieldInputValidation[
|
|
3199
|
+
fieldSet.forEach((code) => {
|
|
3200
|
+
if (!this._fieldInputValidation[code]) {
|
|
3201
|
+
this._fieldInputValidation[code] = [];
|
|
3077
3202
|
}
|
|
3078
|
-
this._fieldInputValidation[
|
|
3203
|
+
this._fieldInputValidation[code].push({ callback, properties });
|
|
3079
3204
|
});
|
|
3080
3205
|
}
|
|
3081
3206
|
onFieldValidationStart(codes, callback, properties = null) {
|
|
3082
3207
|
const fieldSet = (Array.isArray(codes)) ? codes : (codes ? [codes] : []);
|
|
3083
|
-
fieldSet.forEach((
|
|
3084
|
-
if (!this._fieldValidationsStart[
|
|
3085
|
-
this._fieldValidationsStart[
|
|
3208
|
+
fieldSet.forEach((code) => {
|
|
3209
|
+
if (!this._fieldValidationsStart[code]) {
|
|
3210
|
+
this._fieldValidationsStart[code] = [];
|
|
3086
3211
|
}
|
|
3087
|
-
this._fieldValidationsStart[
|
|
3212
|
+
this._fieldValidationsStart[code].push({ callback, properties });
|
|
3088
3213
|
});
|
|
3089
3214
|
}
|
|
3090
3215
|
onFieldValidationFinish(codes, callback, properties = null) {
|
|
3091
3216
|
const fieldSet = (Array.isArray(codes)) ? codes : (codes ? [codes] : []);
|
|
3092
|
-
fieldSet.forEach((
|
|
3093
|
-
if (!this._fieldValidationsFinish[
|
|
3094
|
-
this._fieldValidationsFinish[
|
|
3217
|
+
fieldSet.forEach((code) => {
|
|
3218
|
+
if (!this._fieldValidationsFinish[code]) {
|
|
3219
|
+
this._fieldValidationsFinish[code] = [];
|
|
3095
3220
|
}
|
|
3096
|
-
this._fieldValidationsFinish[
|
|
3221
|
+
this._fieldValidationsFinish[code].push({ callback, properties });
|
|
3097
3222
|
});
|
|
3098
3223
|
}
|
|
3099
|
-
startFieldInputValidation(
|
|
3224
|
+
startFieldInputValidation(code, intrinsicValidation = true) {
|
|
3100
3225
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3101
|
-
const fieldToValidate = this.getField(
|
|
3226
|
+
const fieldToValidate = this.getField(code);
|
|
3102
3227
|
if (!fieldToValidate) {
|
|
3103
3228
|
return false;
|
|
3104
3229
|
}
|
|
3105
|
-
const validationCallbacks = this._fieldInputValidation[
|
|
3230
|
+
const validationCallbacks = this._fieldInputValidation[code];
|
|
3106
3231
|
if (validationCallbacks) {
|
|
3107
3232
|
const clientValidationPromises = [];
|
|
3108
3233
|
for (const validationMethod of validationCallbacks) {
|
|
@@ -3115,13 +3240,13 @@ class BasicFormComponent {
|
|
|
3115
3240
|
return true;
|
|
3116
3241
|
});
|
|
3117
3242
|
}
|
|
3118
|
-
startFieldValidation(
|
|
3243
|
+
startFieldValidation(code, intrinsicValidation = true) {
|
|
3119
3244
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3120
|
-
const fieldToValidate = this.getField(
|
|
3245
|
+
const fieldToValidate = this.getField(code);
|
|
3121
3246
|
if (!fieldToValidate) {
|
|
3122
3247
|
return;
|
|
3123
3248
|
}
|
|
3124
|
-
const validationCallbacks = this._fieldValidationsStart[
|
|
3249
|
+
const validationCallbacks = this._fieldValidationsStart[code];
|
|
3125
3250
|
if (validationCallbacks) {
|
|
3126
3251
|
const clientValidationPromises = [];
|
|
3127
3252
|
for (const validationMethod of validationCallbacks) {
|
|
@@ -3152,10 +3277,9 @@ class BasicFormComponent {
|
|
|
3152
3277
|
if (fieldObj.backend) {
|
|
3153
3278
|
fieldObj.validating = true;
|
|
3154
3279
|
validationResult = yield this
|
|
3155
|
-
.requestFormAction(formActions.validate, fieldObj.
|
|
3280
|
+
.requestFormAction(formActions.validate, fieldObj.code);
|
|
3156
3281
|
serverError = !!this.errorOccured();
|
|
3157
3282
|
}
|
|
3158
|
-
yield this.finishFieldValidation(fieldObj, validationResult, serverError);
|
|
3159
3283
|
if (serverError) {
|
|
3160
3284
|
fieldObj === null || fieldObj === void 0 ? void 0 : fieldObj.setErrorCode(this.errorCode);
|
|
3161
3285
|
fieldObj === null || fieldObj === void 0 ? void 0 : fieldObj.setErrorMessage(this.errorMessage);
|
|
@@ -3164,13 +3288,14 @@ class BasicFormComponent {
|
|
|
3164
3288
|
callback(fieldObj);
|
|
3165
3289
|
}
|
|
3166
3290
|
}
|
|
3291
|
+
yield this.finishFieldValidation(fieldObj, validationResult, serverError);
|
|
3167
3292
|
fieldObj.validating = false;
|
|
3168
3293
|
});
|
|
3169
3294
|
}
|
|
3170
3295
|
finishFieldValidation(fieldObject, validationResult, serverError = false) {
|
|
3171
3296
|
var _a;
|
|
3172
3297
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3173
|
-
const validationCallbacks = this._fieldValidationsFinish[fieldObject.
|
|
3298
|
+
const validationCallbacks = this._fieldValidationsFinish[fieldObject.code];
|
|
3174
3299
|
if (validationCallbacks) {
|
|
3175
3300
|
const clientActionPromises = [];
|
|
3176
3301
|
for (const validationMethod of validationCallbacks) {
|
|
@@ -3184,9 +3309,9 @@ class BasicFormComponent {
|
|
|
3184
3309
|
}
|
|
3185
3310
|
});
|
|
3186
3311
|
}
|
|
3187
|
-
continueFieldValidation(
|
|
3312
|
+
continueFieldValidation(code) {
|
|
3188
3313
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3189
|
-
return this.startServerFieldValidation(
|
|
3314
|
+
return this.startServerFieldValidation(code);
|
|
3190
3315
|
});
|
|
3191
3316
|
}
|
|
3192
3317
|
/**
|
|
@@ -3721,8 +3846,8 @@ class BasicFormComponent {
|
|
|
3721
3846
|
validationError = true;
|
|
3722
3847
|
this.setError(this.formConfig.formStandardErrors.typeWarning, this.formConfig.formStandardErrors.validationTitle, this.formConfig.formStandardErrors.requiredFields);
|
|
3723
3848
|
this.tagFieldsWithError(this.formConfig.formStandardErrors.requiredField, requiredEmptyFields);
|
|
3724
|
-
for (const
|
|
3725
|
-
const requiredEmptyField = this.getField(
|
|
3849
|
+
for (const code of requiredEmptyFields) {
|
|
3850
|
+
const requiredEmptyField = this.getField(code);
|
|
3726
3851
|
requiredEmptyField === null || requiredEmptyField === void 0 ? void 0 : requiredEmptyField.focus();
|
|
3727
3852
|
break;
|
|
3728
3853
|
}
|
|
@@ -3731,8 +3856,8 @@ class BasicFormComponent {
|
|
|
3731
3856
|
if (!validationError && validationIssueFields.length > 0) {
|
|
3732
3857
|
validationError = true;
|
|
3733
3858
|
this.setError(this.formConfig.formStandardErrors.typeWarning, this.formConfig.formStandardErrors.validationTitle, this.formConfig.formStandardErrors.validationFields);
|
|
3734
|
-
for (const
|
|
3735
|
-
const validationIssueField = this.getField(
|
|
3859
|
+
for (const code of validationIssueFields) {
|
|
3860
|
+
const validationIssueField = this.getField(code);
|
|
3736
3861
|
if (validationIssueField) {
|
|
3737
3862
|
validationIssueField.focus();
|
|
3738
3863
|
}
|
|
@@ -3749,8 +3874,8 @@ class BasicFormComponent {
|
|
|
3749
3874
|
if (tableRecord && columnNames) {
|
|
3750
3875
|
for (const columnName of columnNames) {
|
|
3751
3876
|
const columnValue = (_a = tableRecord.getFieldValue(columnName)) !== null && _a !== void 0 ? _a : '';
|
|
3752
|
-
const
|
|
3753
|
-
this.setFieldValue(
|
|
3877
|
+
const code = (_b = mappingTable === null || mappingTable === void 0 ? void 0 : mappingTable[columnName]) !== null && _b !== void 0 ? _b : columnName;
|
|
3878
|
+
this.setFieldValue(code, columnValue);
|
|
3754
3879
|
}
|
|
3755
3880
|
return true;
|
|
3756
3881
|
}
|
|
@@ -3838,9 +3963,9 @@ class BasicFormComponent {
|
|
|
3838
3963
|
return this.onTableGetDataFinish(code, callback, properties);
|
|
3839
3964
|
}
|
|
3840
3965
|
}
|
|
3841
|
-
BasicFormComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
3842
|
-
BasicFormComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "
|
|
3843
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
3966
|
+
BasicFormComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: BasicFormComponent, deps: [{ token: LibFormManagerService }, { token: LibEventManagerService }, { token: LibFileManagementService }], target: i0.ɵɵFactoryTarget.Component });
|
|
3967
|
+
BasicFormComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.6", type: BasicFormComponent, selector: "ng-component", ngImport: i0, template: `<ng-content></ng-content>`, isInline: true });
|
|
3968
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: BasicFormComponent, decorators: [{
|
|
3844
3969
|
type: Component,
|
|
3845
3970
|
args: [{
|
|
3846
3971
|
template: `<ng-content></ng-content>`
|
|
@@ -3862,8 +3987,8 @@ const COMPONENTS = [
|
|
|
3862
3987
|
];
|
|
3863
3988
|
class TuainNgFormsLibModule {
|
|
3864
3989
|
}
|
|
3865
|
-
TuainNgFormsLibModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
3866
|
-
TuainNgFormsLibModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "
|
|
3990
|
+
TuainNgFormsLibModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: TuainNgFormsLibModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
3991
|
+
TuainNgFormsLibModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "14.2.6", ngImport: i0, type: TuainNgFormsLibModule, declarations: [BasicFormComponent,
|
|
3867
3992
|
ActionComponent,
|
|
3868
3993
|
FieldComponent,
|
|
3869
3994
|
ElementComponent,
|
|
@@ -3886,12 +4011,10 @@ TuainNgFormsLibModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", v
|
|
|
3886
4011
|
LibTableRecordActionComponent,
|
|
3887
4012
|
LibTableRecordFieldComponent,
|
|
3888
4013
|
LibTableComponent] });
|
|
3889
|
-
TuainNgFormsLibModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "
|
|
3890
|
-
|
|
3891
|
-
|
|
3892
|
-
|
|
3893
|
-
]] });
|
|
3894
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.1", ngImport: i0, type: TuainNgFormsLibModule, decorators: [{
|
|
4014
|
+
TuainNgFormsLibModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: TuainNgFormsLibModule, imports: [CommonModule,
|
|
4015
|
+
RouterModule,
|
|
4016
|
+
FormsModule] });
|
|
4017
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: TuainNgFormsLibModule, decorators: [{
|
|
3895
4018
|
type: NgModule,
|
|
3896
4019
|
args: [{
|
|
3897
4020
|
declarations: COMPONENTS,
|