tuain-ng-forms-lib 14.1.2 → 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 -243
- 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 -357
- package/fesm2015/tuain-ng-forms-lib.mjs.map +1 -1
- package/fesm2020/tuain-ng-forms-lib.mjs +474 -354
- 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 +1 -1
|
@@ -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);
|
|
761
|
+
}
|
|
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);
|
|
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;
|
|
781
|
+
}
|
|
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
|
+
}
|
|
712
810
|
}
|
|
713
|
-
|
|
714
|
-
this.
|
|
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();
|
|
715
814
|
}
|
|
716
815
|
}
|
|
717
|
-
get
|
|
718
|
-
|
|
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,158 +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
|
-
this.notifyEditionFinish();
|
|
905
|
-
}
|
|
906
998
|
}
|
|
907
|
-
|
|
999
|
+
_setValue(newValue, widgetUpdate = true) {
|
|
908
1000
|
var _a;
|
|
909
1001
|
if (typeof newValue === UNDEFINED) {
|
|
910
1002
|
return true;
|
|
@@ -913,12 +1005,12 @@ class FieldDescriptor extends FormElement {
|
|
|
913
1005
|
return true;
|
|
914
1006
|
}
|
|
915
1007
|
let newFinalValue;
|
|
916
|
-
if (this.
|
|
917
|
-
|| this.
|
|
1008
|
+
if (this._fieldType === this._formConfig.fieldTypes.boolean
|
|
1009
|
+
|| this._fieldType === this._formConfig.fieldTypes.check) {
|
|
918
1010
|
newFinalValue = (_a = yn(newValue)) !== null && _a !== void 0 ? _a : false;
|
|
919
1011
|
}
|
|
920
|
-
else if (this.
|
|
921
|
-
|| this.
|
|
1012
|
+
else if (this._fieldType === this._formConfig.fieldTypes.array
|
|
1013
|
+
|| this._fieldType === this._formConfig.fieldTypes.map) {
|
|
922
1014
|
if (newValue === null || newValue === '') {
|
|
923
1015
|
newFinalValue = [];
|
|
924
1016
|
}
|
|
@@ -933,9 +1025,9 @@ class FieldDescriptor extends FormElement {
|
|
|
933
1025
|
newFinalValue = newValue;
|
|
934
1026
|
}
|
|
935
1027
|
if (this._value !== newFinalValue) {
|
|
936
|
-
this.
|
|
1028
|
+
this.hasChanged = true;
|
|
937
1029
|
if (widgetUpdate) {
|
|
938
|
-
this.setAttr(
|
|
1030
|
+
this.setAttr(attrs._value, newFinalValue);
|
|
939
1031
|
}
|
|
940
1032
|
else {
|
|
941
1033
|
this._value = newFinalValue;
|
|
@@ -1583,7 +1675,7 @@ class RecordFormSubSection {
|
|
|
1583
1675
|
return this.subSectionFields;
|
|
1584
1676
|
}
|
|
1585
1677
|
getFieldNames() {
|
|
1586
|
-
return this.subSectionFields.map(field => field.
|
|
1678
|
+
return this.subSectionFields.map(field => field.code);
|
|
1587
1679
|
}
|
|
1588
1680
|
getActions() {
|
|
1589
1681
|
return this.subSectionActions;
|
|
@@ -1800,7 +1892,7 @@ class FormStructureAndData {
|
|
|
1800
1892
|
});
|
|
1801
1893
|
for (const fieldReceived of formFields) {
|
|
1802
1894
|
const fieldToAdd = new FieldDescriptor(fieldReceived, this._formConfig);
|
|
1803
|
-
const fieldCode = fieldToAdd.
|
|
1895
|
+
const fieldCode = fieldToAdd.code;
|
|
1804
1896
|
if (fieldCode) {
|
|
1805
1897
|
this._fieldArray.push(fieldToAdd);
|
|
1806
1898
|
this._fields[fieldCode] = fieldToAdd;
|
|
@@ -1895,13 +1987,13 @@ class FormStructureAndData {
|
|
|
1895
1987
|
get fields() { return this._fields; }
|
|
1896
1988
|
get fieldNames() { return this.getFieldNames(); }
|
|
1897
1989
|
getFields() { return this._fieldArray; }
|
|
1898
|
-
getFieldNames() { return this._fieldArray.map(field => field.
|
|
1990
|
+
getFieldNames() { return this._fieldArray.map(field => field.code); }
|
|
1899
1991
|
getField(code) { var _a; return (code && ((_a = this._fields) === null || _a === void 0 ? void 0 : _a[code])) ? this._fields[code] : null; }
|
|
1900
1992
|
enableField(code) { var _a; (_a = this.getField(code)) === null || _a === void 0 ? void 0 : _a.enable(); }
|
|
1901
1993
|
disableField(code) { var _a; (_a = this.getField(code)) === null || _a === void 0 ? void 0 : _a.disable(); }
|
|
1902
|
-
getFieldValue(code) { var _a; return (_a = this.getField(code)) === null || _a === void 0 ? void 0 : _a.
|
|
1903
|
-
getFieldOptionText(code) { var _a; return (_a = this.getField(code)) === null || _a === void 0 ? void 0 : _a.
|
|
1904
|
-
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; }
|
|
1905
1997
|
setFieldValue(code, value) { var _a; (_a = this.getField(code)) === null || _a === void 0 ? void 0 : _a.setValue(value); }
|
|
1906
1998
|
setFieldError(code, errorCode, message, type = 'error') { var _a; (_a = this.getField(code)) === null || _a === void 0 ? void 0 : _a.setError(errorCode, message, type); }
|
|
1907
1999
|
setFieldIntrinsicErrorMessage(code, message) { var _a; (_a = this.getField(code)) === null || _a === void 0 ? void 0 : _a.setIntrinsicErrorMessage(message); }
|
|
@@ -1910,7 +2002,8 @@ class FormStructureAndData {
|
|
|
1910
2002
|
const codes = this.getFieldSet(null, inputCodes !== null && inputCodes !== void 0 ? inputCodes : null);
|
|
1911
2003
|
for (const code of codes) {
|
|
1912
2004
|
try {
|
|
1913
|
-
(_a = this.getField(code))
|
|
2005
|
+
const field = (_a = this.getField(code)) !== null && _a !== void 0 ? _a : null;
|
|
2006
|
+
field && (field.required = required);
|
|
1914
2007
|
}
|
|
1915
2008
|
catch (e) {
|
|
1916
2009
|
console.log(`Error modificando campo ${code}: ${e}`);
|
|
@@ -1971,28 +2064,28 @@ class FormStructureAndData {
|
|
|
1971
2064
|
return processedFields;
|
|
1972
2065
|
}
|
|
1973
2066
|
enableFields(codes, secCode, subCode) {
|
|
1974
|
-
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);
|
|
1975
2068
|
}
|
|
1976
2069
|
showFields(codes, secCode, subCode) {
|
|
1977
|
-
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);
|
|
1978
2071
|
}
|
|
1979
2072
|
hideFields(codes, secCode, subCode) {
|
|
1980
|
-
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);
|
|
1981
2074
|
}
|
|
1982
2075
|
showLabelFields(codes, secCode, subCode) {
|
|
1983
|
-
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);
|
|
1984
2077
|
}
|
|
1985
2078
|
hideLabelFields(codes, secCode, subCode) {
|
|
1986
|
-
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);
|
|
1987
2080
|
}
|
|
1988
2081
|
disableFields(codes, secCode, subCode) {
|
|
1989
|
-
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);
|
|
1990
2083
|
}
|
|
1991
2084
|
cleanFields(codes, secCode, subCode) {
|
|
1992
|
-
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);
|
|
1993
2086
|
}
|
|
1994
2087
|
tagFieldsWithError(message, codes, secCode, subCode) {
|
|
1995
|
-
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);
|
|
1996
2089
|
}
|
|
1997
2090
|
cleanErrorFields(codes, secCode, subCode) {
|
|
1998
2091
|
return this.tagFieldsWithError('', codes, secCode, subCode);
|
|
@@ -2001,16 +2094,16 @@ class FormStructureAndData {
|
|
|
2001
2094
|
return this.tagFieldsWithError(message, this.getRequiredEmptyFields(codes, secCode, subCode)) > 0;
|
|
2002
2095
|
}
|
|
2003
2096
|
getRequiredFields(codes, secCode, subCode) {
|
|
2004
|
-
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);
|
|
2005
2098
|
}
|
|
2006
2099
|
getRequiredEmptyFields(codes, secCode, subCode) {
|
|
2007
|
-
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);
|
|
2008
2101
|
}
|
|
2009
2102
|
getChangedFields(codes, secCode, subCode) {
|
|
2010
|
-
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);
|
|
2011
2104
|
}
|
|
2012
2105
|
getFieldsWithValidationIssues(codes, secCode, subCode) {
|
|
2013
|
-
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);
|
|
2014
2107
|
}
|
|
2015
2108
|
getFieldsValues(inputCodes, secCode, subCode) {
|
|
2016
2109
|
var _a, _b, _c;
|
|
@@ -2128,14 +2221,14 @@ class FormStructureAndData {
|
|
|
2128
2221
|
fields: [],
|
|
2129
2222
|
tables: [],
|
|
2130
2223
|
};
|
|
2131
|
-
formData.fields = this.getFields().filter(fld => !fld.outputOnly)
|
|
2224
|
+
formData.fields = this.getFields().filter(fld => !(fld === null || fld === void 0 ? void 0 : fld.outputOnly))
|
|
2132
2225
|
.map(fld => {
|
|
2133
2226
|
const fieldPayload = {
|
|
2134
|
-
fieldCode: fld.
|
|
2135
|
-
fieldValue: fld.
|
|
2136
|
-
editable: !fld.disabled,
|
|
2137
|
-
visible: fld.visible,
|
|
2138
|
-
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,
|
|
2139
2232
|
fieldOptions: '',
|
|
2140
2233
|
};
|
|
2141
2234
|
return fieldPayload;
|
|
@@ -2281,6 +2374,7 @@ class BasicFormComponent {
|
|
|
2281
2374
|
this._formRoute = null;
|
|
2282
2375
|
this._definitionObtained = false;
|
|
2283
2376
|
// Eventos de acciones y campos
|
|
2377
|
+
this._formSectionsCanDeactivate = {};
|
|
2284
2378
|
this._formSectionsActivate = {};
|
|
2285
2379
|
this._formSectionsInactivate = {};
|
|
2286
2380
|
this._formActionsStart = {};
|
|
@@ -2581,6 +2675,7 @@ class BasicFormComponent {
|
|
|
2581
2675
|
// Se limpian los manejadores de eventos
|
|
2582
2676
|
this.visible = false;
|
|
2583
2677
|
this.busy = false;
|
|
2678
|
+
this._formSectionsCanDeactivate = {};
|
|
2584
2679
|
this._formSectionsActivate = {};
|
|
2585
2680
|
this._formSectionsInactivate = {};
|
|
2586
2681
|
this._formActionsStart = {};
|
|
@@ -2623,7 +2718,7 @@ class BasicFormComponent {
|
|
|
2623
2718
|
displayActionServerError() { }
|
|
2624
2719
|
displayValidationServerError() { }
|
|
2625
2720
|
displayTableServerError() { }
|
|
2626
|
-
showFieldInfo(
|
|
2721
|
+
showFieldInfo(code, detail) { }
|
|
2627
2722
|
showModalDialog(title, body, options, callback, params) { }
|
|
2628
2723
|
openUploadDialog(title, body, options, callback, params) { }
|
|
2629
2724
|
/**
|
|
@@ -2800,9 +2895,9 @@ class BasicFormComponent {
|
|
|
2800
2895
|
(_f = this._formStructure) === null || _f === void 0 ? void 0 : _f.changeState(initialState || ((_g = this._formStructure) === null || _g === void 0 ? void 0 : _g.defaultState));
|
|
2801
2896
|
const inputFieldNames = Object.keys(this.inputDataFields);
|
|
2802
2897
|
for (let index = 0; index < inputFieldNames.length; index++) {
|
|
2803
|
-
const
|
|
2804
|
-
const fieldValue = this.inputDataFields[
|
|
2805
|
-
this.setFieldValue(
|
|
2898
|
+
const code = inputFieldNames[index];
|
|
2899
|
+
const fieldValue = this.inputDataFields[code];
|
|
2900
|
+
this.setFieldValue(code, fieldValue);
|
|
2806
2901
|
}
|
|
2807
2902
|
const recordResponse = yield this.requestFormAction(formActions.getData);
|
|
2808
2903
|
this.checkErrorRecordReceived(recordResponse);
|
|
@@ -2930,6 +3025,15 @@ class BasicFormComponent {
|
|
|
2930
3025
|
/**
|
|
2931
3026
|
* Manejo de event handlers para acciones sobre el formulario
|
|
2932
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
|
+
}
|
|
2933
3037
|
onSectionActivation(codes, callback, properties = null) {
|
|
2934
3038
|
const sectionSet = (Array.isArray(codes)) ? codes : (codes ? [codes] : []);
|
|
2935
3039
|
sectionSet.forEach((sectionName) => {
|
|
@@ -2966,6 +3070,26 @@ class BasicFormComponent {
|
|
|
2966
3070
|
this._formActionsFinish[actionName].push({ callback, properties });
|
|
2967
3071
|
});
|
|
2968
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
|
+
}
|
|
2969
3093
|
launchSectionActivation(code) {
|
|
2970
3094
|
var _a;
|
|
2971
3095
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -3072,38 +3196,38 @@ class BasicFormComponent {
|
|
|
3072
3196
|
*/
|
|
3073
3197
|
onFieldInput(codes, callback, properties = null) {
|
|
3074
3198
|
const fieldSet = (Array.isArray(codes)) ? codes : (codes ? [codes] : []);
|
|
3075
|
-
fieldSet.forEach((
|
|
3076
|
-
if (!this._fieldInputValidation[
|
|
3077
|
-
this._fieldInputValidation[
|
|
3199
|
+
fieldSet.forEach((code) => {
|
|
3200
|
+
if (!this._fieldInputValidation[code]) {
|
|
3201
|
+
this._fieldInputValidation[code] = [];
|
|
3078
3202
|
}
|
|
3079
|
-
this._fieldInputValidation[
|
|
3203
|
+
this._fieldInputValidation[code].push({ callback, properties });
|
|
3080
3204
|
});
|
|
3081
3205
|
}
|
|
3082
3206
|
onFieldValidationStart(codes, callback, properties = null) {
|
|
3083
3207
|
const fieldSet = (Array.isArray(codes)) ? codes : (codes ? [codes] : []);
|
|
3084
|
-
fieldSet.forEach((
|
|
3085
|
-
if (!this._fieldValidationsStart[
|
|
3086
|
-
this._fieldValidationsStart[
|
|
3208
|
+
fieldSet.forEach((code) => {
|
|
3209
|
+
if (!this._fieldValidationsStart[code]) {
|
|
3210
|
+
this._fieldValidationsStart[code] = [];
|
|
3087
3211
|
}
|
|
3088
|
-
this._fieldValidationsStart[
|
|
3212
|
+
this._fieldValidationsStart[code].push({ callback, properties });
|
|
3089
3213
|
});
|
|
3090
3214
|
}
|
|
3091
3215
|
onFieldValidationFinish(codes, callback, properties = null) {
|
|
3092
3216
|
const fieldSet = (Array.isArray(codes)) ? codes : (codes ? [codes] : []);
|
|
3093
|
-
fieldSet.forEach((
|
|
3094
|
-
if (!this._fieldValidationsFinish[
|
|
3095
|
-
this._fieldValidationsFinish[
|
|
3217
|
+
fieldSet.forEach((code) => {
|
|
3218
|
+
if (!this._fieldValidationsFinish[code]) {
|
|
3219
|
+
this._fieldValidationsFinish[code] = [];
|
|
3096
3220
|
}
|
|
3097
|
-
this._fieldValidationsFinish[
|
|
3221
|
+
this._fieldValidationsFinish[code].push({ callback, properties });
|
|
3098
3222
|
});
|
|
3099
3223
|
}
|
|
3100
|
-
startFieldInputValidation(
|
|
3224
|
+
startFieldInputValidation(code, intrinsicValidation = true) {
|
|
3101
3225
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3102
|
-
const fieldToValidate = this.getField(
|
|
3226
|
+
const fieldToValidate = this.getField(code);
|
|
3103
3227
|
if (!fieldToValidate) {
|
|
3104
3228
|
return false;
|
|
3105
3229
|
}
|
|
3106
|
-
const validationCallbacks = this._fieldInputValidation[
|
|
3230
|
+
const validationCallbacks = this._fieldInputValidation[code];
|
|
3107
3231
|
if (validationCallbacks) {
|
|
3108
3232
|
const clientValidationPromises = [];
|
|
3109
3233
|
for (const validationMethod of validationCallbacks) {
|
|
@@ -3116,13 +3240,13 @@ class BasicFormComponent {
|
|
|
3116
3240
|
return true;
|
|
3117
3241
|
});
|
|
3118
3242
|
}
|
|
3119
|
-
startFieldValidation(
|
|
3243
|
+
startFieldValidation(code, intrinsicValidation = true) {
|
|
3120
3244
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3121
|
-
const fieldToValidate = this.getField(
|
|
3245
|
+
const fieldToValidate = this.getField(code);
|
|
3122
3246
|
if (!fieldToValidate) {
|
|
3123
3247
|
return;
|
|
3124
3248
|
}
|
|
3125
|
-
const validationCallbacks = this._fieldValidationsStart[
|
|
3249
|
+
const validationCallbacks = this._fieldValidationsStart[code];
|
|
3126
3250
|
if (validationCallbacks) {
|
|
3127
3251
|
const clientValidationPromises = [];
|
|
3128
3252
|
for (const validationMethod of validationCallbacks) {
|
|
@@ -3153,10 +3277,9 @@ class BasicFormComponent {
|
|
|
3153
3277
|
if (fieldObj.backend) {
|
|
3154
3278
|
fieldObj.validating = true;
|
|
3155
3279
|
validationResult = yield this
|
|
3156
|
-
.requestFormAction(formActions.validate, fieldObj.
|
|
3280
|
+
.requestFormAction(formActions.validate, fieldObj.code);
|
|
3157
3281
|
serverError = !!this.errorOccured();
|
|
3158
3282
|
}
|
|
3159
|
-
yield this.finishFieldValidation(fieldObj, validationResult, serverError);
|
|
3160
3283
|
if (serverError) {
|
|
3161
3284
|
fieldObj === null || fieldObj === void 0 ? void 0 : fieldObj.setErrorCode(this.errorCode);
|
|
3162
3285
|
fieldObj === null || fieldObj === void 0 ? void 0 : fieldObj.setErrorMessage(this.errorMessage);
|
|
@@ -3165,13 +3288,14 @@ class BasicFormComponent {
|
|
|
3165
3288
|
callback(fieldObj);
|
|
3166
3289
|
}
|
|
3167
3290
|
}
|
|
3291
|
+
yield this.finishFieldValidation(fieldObj, validationResult, serverError);
|
|
3168
3292
|
fieldObj.validating = false;
|
|
3169
3293
|
});
|
|
3170
3294
|
}
|
|
3171
3295
|
finishFieldValidation(fieldObject, validationResult, serverError = false) {
|
|
3172
3296
|
var _a;
|
|
3173
3297
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3174
|
-
const validationCallbacks = this._fieldValidationsFinish[fieldObject.
|
|
3298
|
+
const validationCallbacks = this._fieldValidationsFinish[fieldObject.code];
|
|
3175
3299
|
if (validationCallbacks) {
|
|
3176
3300
|
const clientActionPromises = [];
|
|
3177
3301
|
for (const validationMethod of validationCallbacks) {
|
|
@@ -3185,9 +3309,9 @@ class BasicFormComponent {
|
|
|
3185
3309
|
}
|
|
3186
3310
|
});
|
|
3187
3311
|
}
|
|
3188
|
-
continueFieldValidation(
|
|
3312
|
+
continueFieldValidation(code) {
|
|
3189
3313
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3190
|
-
return this.startServerFieldValidation(
|
|
3314
|
+
return this.startServerFieldValidation(code);
|
|
3191
3315
|
});
|
|
3192
3316
|
}
|
|
3193
3317
|
/**
|
|
@@ -3722,8 +3846,8 @@ class BasicFormComponent {
|
|
|
3722
3846
|
validationError = true;
|
|
3723
3847
|
this.setError(this.formConfig.formStandardErrors.typeWarning, this.formConfig.formStandardErrors.validationTitle, this.formConfig.formStandardErrors.requiredFields);
|
|
3724
3848
|
this.tagFieldsWithError(this.formConfig.formStandardErrors.requiredField, requiredEmptyFields);
|
|
3725
|
-
for (const
|
|
3726
|
-
const requiredEmptyField = this.getField(
|
|
3849
|
+
for (const code of requiredEmptyFields) {
|
|
3850
|
+
const requiredEmptyField = this.getField(code);
|
|
3727
3851
|
requiredEmptyField === null || requiredEmptyField === void 0 ? void 0 : requiredEmptyField.focus();
|
|
3728
3852
|
break;
|
|
3729
3853
|
}
|
|
@@ -3732,8 +3856,8 @@ class BasicFormComponent {
|
|
|
3732
3856
|
if (!validationError && validationIssueFields.length > 0) {
|
|
3733
3857
|
validationError = true;
|
|
3734
3858
|
this.setError(this.formConfig.formStandardErrors.typeWarning, this.formConfig.formStandardErrors.validationTitle, this.formConfig.formStandardErrors.validationFields);
|
|
3735
|
-
for (const
|
|
3736
|
-
const validationIssueField = this.getField(
|
|
3859
|
+
for (const code of validationIssueFields) {
|
|
3860
|
+
const validationIssueField = this.getField(code);
|
|
3737
3861
|
if (validationIssueField) {
|
|
3738
3862
|
validationIssueField.focus();
|
|
3739
3863
|
}
|
|
@@ -3750,8 +3874,8 @@ class BasicFormComponent {
|
|
|
3750
3874
|
if (tableRecord && columnNames) {
|
|
3751
3875
|
for (const columnName of columnNames) {
|
|
3752
3876
|
const columnValue = (_a = tableRecord.getFieldValue(columnName)) !== null && _a !== void 0 ? _a : '';
|
|
3753
|
-
const
|
|
3754
|
-
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);
|
|
3755
3879
|
}
|
|
3756
3880
|
return true;
|
|
3757
3881
|
}
|
|
@@ -3839,9 +3963,9 @@ class BasicFormComponent {
|
|
|
3839
3963
|
return this.onTableGetDataFinish(code, callback, properties);
|
|
3840
3964
|
}
|
|
3841
3965
|
}
|
|
3842
|
-
BasicFormComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
3843
|
-
BasicFormComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "
|
|
3844
|
-
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: [{
|
|
3845
3969
|
type: Component,
|
|
3846
3970
|
args: [{
|
|
3847
3971
|
template: `<ng-content></ng-content>`
|
|
@@ -3863,8 +3987,8 @@ const COMPONENTS = [
|
|
|
3863
3987
|
];
|
|
3864
3988
|
class TuainNgFormsLibModule {
|
|
3865
3989
|
}
|
|
3866
|
-
TuainNgFormsLibModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
3867
|
-
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,
|
|
3868
3992
|
ActionComponent,
|
|
3869
3993
|
FieldComponent,
|
|
3870
3994
|
ElementComponent,
|
|
@@ -3887,12 +4011,10 @@ TuainNgFormsLibModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", v
|
|
|
3887
4011
|
LibTableRecordActionComponent,
|
|
3888
4012
|
LibTableRecordFieldComponent,
|
|
3889
4013
|
LibTableComponent] });
|
|
3890
|
-
TuainNgFormsLibModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "
|
|
3891
|
-
|
|
3892
|
-
|
|
3893
|
-
|
|
3894
|
-
]] });
|
|
3895
|
-
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: [{
|
|
3896
4018
|
type: NgModule,
|
|
3897
4019
|
args: [{
|
|
3898
4020
|
declarations: COMPONENTS,
|