tuain-ng-forms-lib 0.12.23 → 12.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundles/tuain-ng-forms-lib.umd.js +624 -662
- package/bundles/tuain-ng-forms-lib.umd.js.map +1 -1
- package/esm2015/lib/classes/forms/action.js +5 -5
- package/esm2015/lib/classes/forms/element.js +7 -6
- package/esm2015/lib/classes/forms/field.js +149 -166
- package/esm2015/lib/classes/forms/form.constants.js +11 -82
- package/esm2015/lib/classes/forms/form.js +8 -8
- package/esm2015/lib/classes/forms/subsection.js +6 -6
- package/esm2015/lib/classes/forms/table/column.js +5 -5
- package/esm2015/lib/classes/forms/table/row-data.js +6 -4
- package/esm2015/lib/classes/forms/table/table.js +15 -13
- package/esm2015/lib/components/elements/action.component.js +3 -1
- package/esm2015/lib/components/elements/field.component.js +45 -7
- package/esm2015/lib/components/elements/layout/element.component.js +3 -6
- package/esm2015/lib/components/elements/layout/form-error.component.js +1 -1
- package/esm2015/lib/components/elements/tables/table.component.js +7 -7
- package/esm2015/lib/components/forms/basic-form.js +89 -85
- package/esm2015/lib/services/form-manager.service.js +60 -54
- package/fesm2015/tuain-ng-forms-lib.js +410 -440
- package/fesm2015/tuain-ng-forms-lib.js.map +1 -1
- package/lib/classes/forms/action.d.ts +1 -1
- package/lib/classes/forms/element.d.ts +3 -2
- package/lib/classes/forms/field.d.ts +19 -13
- package/lib/classes/forms/form.constants.d.ts +10 -74
- package/lib/classes/forms/form.d.ts +2 -1
- package/lib/classes/forms/table/column.d.ts +2 -1
- package/lib/classes/forms/table/table.d.ts +1 -1
- package/lib/components/elements/action.component.d.ts +1 -0
- package/lib/components/elements/field.component.d.ts +17 -2
- package/lib/components/elements/layout/element.component.d.ts +1 -2
- package/lib/components/elements/layout/form-error.component.d.ts +0 -1
- package/lib/components/elements/tables/table.component.d.ts +1 -0
- package/lib/components/forms/basic-form.d.ts +23 -4
- package/lib/services/form-manager.service.d.ts +22 -15
- package/package.json +1 -1
- package/tuain-ng-forms-lib.metadata.json +1 -1
|
@@ -12,6 +12,8 @@ class ActionComponent {
|
|
|
12
12
|
this.showLabel = true;
|
|
13
13
|
}
|
|
14
14
|
ngOnInit() {
|
|
15
|
+
var _a;
|
|
16
|
+
this.formConfig = (_a = this.actionObject) === null || _a === void 0 ? void 0 : _a._formConfig;
|
|
15
17
|
this.start();
|
|
16
18
|
}
|
|
17
19
|
start() { }
|
|
@@ -49,106 +51,52 @@ ActionComponent.propDecorators = {
|
|
|
49
51
|
showLabel: [{ type: Input }]
|
|
50
52
|
};
|
|
51
53
|
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
FORMERROR_TYPE_WARNING: 'WARNING',
|
|
66
|
-
FORMERROR_REQUIRED_FIELDS: 'Todos los campos requeridos deben ser diligenciados',
|
|
67
|
-
FORMERROR_VALIDATION_TITLE: 'Advertencia',
|
|
68
|
-
FORMERROR_VALIDATION_FIELDS: 'Existen campos con problemas de validación',
|
|
69
|
-
// Valores para los controles de navegació
|
|
70
|
-
FORMNAVIGATION_FIRST: 'first',
|
|
71
|
-
FORMNAVIGATION_PREVGROUP: 'prevgroup',
|
|
72
|
-
FORMNAVIGATION_NEXTGROUP: 'nextgroup',
|
|
73
|
-
FORMNAVIGATION_LAST: 'last',
|
|
74
|
-
FIELDTYPE_ARRAY: 'ARRAY',
|
|
75
|
-
FIELDTYPE_CHECK: 'CHECK',
|
|
76
|
-
FIELDTYPE_DATE: 'DATE',
|
|
77
|
-
FIELDTYPE_MAP: 'MAP',
|
|
78
|
-
FIELDTYPE_CURRENCY: 'CURRENCY',
|
|
79
|
-
FIELDTYPE_SELECT: 'SELECT',
|
|
80
|
-
FIELDTYPE_TEXT: 'TEXT',
|
|
81
|
-
FIELD_REQUIRED_MESSAGE: 'Campo requerido',
|
|
82
|
-
FORMTABLEACTION_SORT: 'SORT',
|
|
83
|
-
FORMTABLEACTION_REFRESH: 'REFRESH',
|
|
84
|
-
FORMTABLEACTION_NAVIGATE: 'NAVIGATE',
|
|
85
|
-
FORMTABLEACTION_INLINE: 'INLINE',
|
|
86
|
-
FORMTABLEACTION_GLOBAL: 'GLOBAL',
|
|
87
|
-
FORMTABLEACTION_ROWSELECTION: 'ROWSELECTION',
|
|
88
|
-
FORMTABLEACTION_SELECTION: 'SELECTION',
|
|
89
|
-
TABLE_SORT_ASCENDING: 'asc',
|
|
90
|
-
TABLE_SORT_DESCENDING: 'desc',
|
|
91
|
-
SERVICE_ERRORCODE_NOERROR: '00',
|
|
92
|
-
};
|
|
93
|
-
const operators = {
|
|
94
|
-
G: '>',
|
|
95
|
-
L: '<',
|
|
96
|
-
GE: '>=',
|
|
97
|
-
LE: '<=',
|
|
98
|
-
EQ: '==',
|
|
99
|
-
NOT_EQ: '!=',
|
|
100
|
-
CONTENT: 'Contiene',
|
|
101
|
-
NOT_CONTENT: 'No Contiene',
|
|
102
|
-
BETWEEN: 'Entre',
|
|
103
|
-
};
|
|
104
|
-
const tableFieldStyles = {
|
|
105
|
-
TEXT: {
|
|
106
|
-
'text-align': 'left'
|
|
107
|
-
},
|
|
108
|
-
TITLE: {
|
|
109
|
-
'text-align': 'left'
|
|
110
|
-
},
|
|
111
|
-
LABEL: {
|
|
112
|
-
'text-align': 'left'
|
|
113
|
-
},
|
|
114
|
-
MESSAGE: {
|
|
115
|
-
'text-align': 'left'
|
|
116
|
-
},
|
|
117
|
-
NUMBER: {
|
|
118
|
-
'text-align': 'right'
|
|
119
|
-
},
|
|
120
|
-
DATE: {
|
|
121
|
-
'text-align': 'right'
|
|
122
|
-
},
|
|
123
|
-
CHECK: {
|
|
124
|
-
'text-align': 'center'
|
|
125
|
-
},
|
|
126
|
-
ARRAY: {
|
|
127
|
-
'text-align': 'left'
|
|
128
|
-
},
|
|
129
|
-
SELECT: {
|
|
130
|
-
'text-align': 'left'
|
|
131
|
-
}
|
|
132
|
-
};
|
|
133
|
-
const DEFAULT_STATE_FLOW = {
|
|
134
|
-
defaultState: 'CREATE',
|
|
135
|
-
states: ['CREATE', 'EDIT', 'VIEW'],
|
|
136
|
-
transitions: [
|
|
137
|
-
{ name: 'VIEW1', origin: 'CREATE', destination: 'VIEW' },
|
|
138
|
-
{ name: 'VIEW2', origin: 'EDIT', destination: 'VIEW' },
|
|
139
|
-
{ name: 'EDIT1', origin: 'CREATE', destination: 'EDIT' },
|
|
140
|
-
{ name: 'EDIT2', origin: 'VIEW', destination: 'EDIT' },
|
|
141
|
-
{ name: 'CREATE1', origin: 'EDIT', destination: 'CREATE' },
|
|
142
|
-
{ name: 'CREATE2', origin: 'VIEW', destination: 'CREATE' },
|
|
143
|
-
]
|
|
54
|
+
const MONITORED_ATTRIBUTES = {
|
|
55
|
+
_maxLength: 'maxLength',
|
|
56
|
+
_onValidation: 'onValidation',
|
|
57
|
+
_fieldValue: 'value',
|
|
58
|
+
captureType: 'captureType',
|
|
59
|
+
fieldTitle: 'title',
|
|
60
|
+
fieldType: 'type',
|
|
61
|
+
errorMessage: 'errorMessage',
|
|
62
|
+
errorType: 'errorType',
|
|
63
|
+
errorCode: 'errorCode',
|
|
64
|
+
visibleLabel: 'visibleLabel',
|
|
65
|
+
fieldRequired: 'required',
|
|
66
|
+
fieldOptions: 'options',
|
|
144
67
|
};
|
|
145
|
-
|
|
146
68
|
class FieldComponent {
|
|
147
|
-
constructor() {
|
|
148
|
-
this.componentConstants = Object.assign({}, componentConstants);
|
|
149
|
-
}
|
|
150
69
|
ngOnInit() {
|
|
151
|
-
|
|
70
|
+
var _a;
|
|
71
|
+
if (this.fieldObject) {
|
|
72
|
+
this.formConfig = (_a = this.fieldObject) === null || _a === void 0 ? void 0 : _a._formConfig;
|
|
73
|
+
// Atributos estáticos
|
|
74
|
+
this.code = this.fieldObject.fieldCode;
|
|
75
|
+
this.fieldInfo = this.fieldObject.fieldInfo;
|
|
76
|
+
this.fieldAlignment = this.fieldObject.fieldAlignment;
|
|
77
|
+
this.tooltipText = this.fieldObject.tooltipText;
|
|
78
|
+
// Cargue inicial
|
|
79
|
+
this.maxLength = this.fieldObject._maxLength;
|
|
80
|
+
this.onValidation = this.fieldObject._onValidation;
|
|
81
|
+
this.value = this.fieldObject._fieldValue;
|
|
82
|
+
this.captureType = this.fieldObject.captureType;
|
|
83
|
+
this.title = this.fieldObject.fieldTitle;
|
|
84
|
+
this.type = this.fieldObject.fieldType;
|
|
85
|
+
this.errorMessage = this.fieldObject.errorMessage;
|
|
86
|
+
this.errorType = this.fieldObject.errorType;
|
|
87
|
+
this.errorCode = this.fieldObject.errorCode;
|
|
88
|
+
this.visibleLabel = this.fieldObject.visibleLabel;
|
|
89
|
+
this.required = this.fieldObject.fieldRequired;
|
|
90
|
+
this.options = this.fieldObject.fieldOptions;
|
|
91
|
+
this.fieldObject.widget = this;
|
|
92
|
+
// Atributos dinámicos
|
|
93
|
+
this.fieldObject.attributeChange.subscribe(event => {
|
|
94
|
+
const { name, value } = event;
|
|
95
|
+
if (this[MONITORED_ATTRIBUTES[name]]) {
|
|
96
|
+
this[MONITORED_ATTRIBUTES[name]] = value;
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
}
|
|
152
100
|
this.start();
|
|
153
101
|
}
|
|
154
102
|
start() { }
|
|
@@ -173,17 +121,15 @@ FieldComponent.decorators = [
|
|
|
173
121
|
template: `<ng-content></ng-content>`
|
|
174
122
|
},] }
|
|
175
123
|
];
|
|
176
|
-
FieldComponent.ctorParameters = () => [];
|
|
177
124
|
FieldComponent.propDecorators = {
|
|
178
125
|
fieldObject: [{ type: Input }],
|
|
179
126
|
disabled: [{ type: Input }]
|
|
180
127
|
};
|
|
181
128
|
|
|
182
129
|
class ElementComponent {
|
|
183
|
-
constructor() {
|
|
184
|
-
this.componentConstants = Object.assign({}, componentConstants);
|
|
185
|
-
}
|
|
186
130
|
ngOnInit() {
|
|
131
|
+
var _a;
|
|
132
|
+
this.formConfig = (_a = this.formElement) === null || _a === void 0 ? void 0 : _a._formConfig;
|
|
187
133
|
this.start();
|
|
188
134
|
}
|
|
189
135
|
start() { }
|
|
@@ -204,7 +150,6 @@ ElementComponent.decorators = [
|
|
|
204
150
|
template: `<ng-content></ng-content>`
|
|
205
151
|
},] }
|
|
206
152
|
];
|
|
207
|
-
ElementComponent.ctorParameters = () => [];
|
|
208
153
|
ElementComponent.propDecorators = {
|
|
209
154
|
formElement: [{ type: Input }],
|
|
210
155
|
formManager: [{ type: Input }]
|
|
@@ -300,9 +245,33 @@ class Filter {
|
|
|
300
245
|
}
|
|
301
246
|
}
|
|
302
247
|
|
|
248
|
+
const elementTypes = {
|
|
249
|
+
action: 'ACTION',
|
|
250
|
+
field: 'FIELD',
|
|
251
|
+
table: 'TABLE',
|
|
252
|
+
};
|
|
253
|
+
const formActions = {
|
|
254
|
+
tableAction: 'TABLEACTION',
|
|
255
|
+
getData: 'GETDATA',
|
|
256
|
+
getTableData: 'GETTABLEDATA',
|
|
257
|
+
validate: 'VALIDATE',
|
|
258
|
+
};
|
|
259
|
+
const operators = {
|
|
260
|
+
G: '>',
|
|
261
|
+
L: '<',
|
|
262
|
+
GE: '>=',
|
|
263
|
+
LE: '<=',
|
|
264
|
+
EQ: '==',
|
|
265
|
+
NOT_EQ: '!=',
|
|
266
|
+
CONTENT: 'Contiene',
|
|
267
|
+
NOT_CONTENT: 'No Contiene',
|
|
268
|
+
BETWEEN: 'Entre',
|
|
269
|
+
};
|
|
270
|
+
|
|
303
271
|
class FormElement {
|
|
304
|
-
constructor(elementDefinition) {
|
|
272
|
+
constructor(elementDefinition, formConfig) {
|
|
305
273
|
var _a, _b;
|
|
274
|
+
this._formConfig = formConfig;
|
|
306
275
|
this._isForced = false;
|
|
307
276
|
this.setVisibleStates(elementDefinition.visibleStates);
|
|
308
277
|
this.setEnabledStates(elementDefinition.enabledStates);
|
|
@@ -311,9 +280,9 @@ class FormElement {
|
|
|
311
280
|
this.setVisibility((_b = elementDefinition === null || elementDefinition === void 0 ? void 0 : elementDefinition.visible) !== null && _b !== void 0 ? _b : true);
|
|
312
281
|
this.widget = null;
|
|
313
282
|
}
|
|
314
|
-
isField() { return this.
|
|
315
|
-
isAction() { return this.
|
|
316
|
-
isTable() { return this.
|
|
283
|
+
isField() { return this.elementType === elementTypes.field; }
|
|
284
|
+
isAction() { return this.elementType === elementTypes.action; }
|
|
285
|
+
isTable() { return this.elementType === elementTypes.table; }
|
|
317
286
|
setVisibleStates(newStates) {
|
|
318
287
|
const visibleStates = (!Array.isArray(newStates) && typeof newStates === 'string')
|
|
319
288
|
? newStates.split(',').map(state => state.trim()).filter(state => state.length > 0)
|
|
@@ -359,13 +328,14 @@ class FormElement {
|
|
|
359
328
|
}
|
|
360
329
|
|
|
361
330
|
class RecordTableColumn {
|
|
362
|
-
constructor(recTableColReceived) {
|
|
331
|
+
constructor(recTableColReceived, formConfig) {
|
|
363
332
|
var _a, _b, _c;
|
|
333
|
+
this._formConfig = formConfig;
|
|
364
334
|
if (recTableColReceived) {
|
|
365
335
|
this.fieldCode = recTableColReceived.fieldCode;
|
|
366
336
|
this.fieldTitle = recTableColReceived.fieldTitle;
|
|
367
|
-
this.fieldType = recTableColReceived.fieldTypeCode ||
|
|
368
|
-
const defaultTypeAlignment = (tableFieldStyles[this.fieldType] != null) ? tableFieldStyles[this.fieldType]['text-align'] : 'left';
|
|
337
|
+
this.fieldType = recTableColReceived.fieldTypeCode || this._formConfig.fieldTypes.text;
|
|
338
|
+
const defaultTypeAlignment = (this._formConfig.tableFieldStyles[this.fieldType] != null) ? this._formConfig.tableFieldStyles[this.fieldType]['text-align'] : 'left';
|
|
369
339
|
this.fieldAlignment = (recTableColReceived.alignment != null) ? recTableColReceived.alignment.toLowerCase() : defaultTypeAlignment;
|
|
370
340
|
this.visible = (_a = recTableColReceived === null || recTableColReceived === void 0 ? void 0 : recTableColReceived.visible) !== null && _a !== void 0 ? _a : true;
|
|
371
341
|
this.sortable = (_b = recTableColReceived === null || recTableColReceived === void 0 ? void 0 : recTableColReceived.sortable) !== null && _b !== void 0 ? _b : false;
|
|
@@ -452,6 +422,8 @@ function formatCurrency(inputValue) {
|
|
|
452
422
|
return outputValue;
|
|
453
423
|
}
|
|
454
424
|
|
|
425
|
+
const DATE_TYPE = 'DATE';
|
|
426
|
+
const CURRENCY_TYPE = 'CURRENCY';
|
|
455
427
|
class TableRecordData {
|
|
456
428
|
constructor(recordReceived, recordDefinition, selectionFieldName = null) {
|
|
457
429
|
this.recordData = {};
|
|
@@ -486,10 +458,10 @@ class TableRecordData {
|
|
|
486
458
|
}
|
|
487
459
|
}
|
|
488
460
|
formatFieldValue(fieldType, fieldValue) {
|
|
489
|
-
if (fieldType ===
|
|
461
|
+
if (fieldType === CURRENCY_TYPE) {
|
|
490
462
|
return formatCurrency(fieldValue);
|
|
491
463
|
}
|
|
492
|
-
else if (fieldType ===
|
|
464
|
+
else if (fieldType === DATE_TYPE && fieldValue) {
|
|
493
465
|
return new Date(fieldValue).toISOString().split('T')[0];
|
|
494
466
|
}
|
|
495
467
|
return fieldValue || '';
|
|
@@ -573,6 +545,8 @@ class TableRecordData {
|
|
|
573
545
|
}
|
|
574
546
|
}
|
|
575
547
|
|
|
548
|
+
const TABLE_SORT_ASCENDING = 'asc';
|
|
549
|
+
const TABLE_SORT_DESCENDING = 'desc';
|
|
576
550
|
const TABLE_FILTER_TYPES = {
|
|
577
551
|
simpleFilterChange: 'SIMPLE_CHANGE',
|
|
578
552
|
simpleFilterFinish: 'SIMPLE_FINISH',
|
|
@@ -580,9 +554,9 @@ const TABLE_FILTER_TYPES = {
|
|
|
580
554
|
complexFilterRemove: 'COMPLEX_REMOVE',
|
|
581
555
|
};
|
|
582
556
|
class RecordTable extends FormElement {
|
|
583
|
-
constructor(tableReceived) {
|
|
557
|
+
constructor(tableReceived, formConfig) {
|
|
584
558
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
585
|
-
super(tableReceived);
|
|
559
|
+
super(tableReceived, formConfig);
|
|
586
560
|
this._inlineActionTrigger = new Subject();
|
|
587
561
|
this._globalActionTrigger = new Subject();
|
|
588
562
|
this._recordSelectionTrigger = new Subject();
|
|
@@ -592,7 +566,7 @@ class RecordTable extends FormElement {
|
|
|
592
566
|
this._tableColumnObj = {};
|
|
593
567
|
this._actionsObj = {};
|
|
594
568
|
this.allSelected = false;
|
|
595
|
-
this.
|
|
569
|
+
this.elementType = elementTypes.table;
|
|
596
570
|
this.waiting = false;
|
|
597
571
|
this.complexFilter = false;
|
|
598
572
|
this.currentPage = 1;
|
|
@@ -615,10 +589,10 @@ class RecordTable extends FormElement {
|
|
|
615
589
|
this.customAttributes = (_f = tableReceived === null || tableReceived === void 0 ? void 0 : tableReceived.customAttributes) !== null && _f !== void 0 ? _f : {};
|
|
616
590
|
this.sortable = (_g = tableReceived === null || tableReceived === void 0 ? void 0 : tableReceived.sortable) !== null && _g !== void 0 ? _g : false;
|
|
617
591
|
this.sorting = { columnName: '', direction: '' };
|
|
618
|
-
this.recordsPerPage =
|
|
592
|
+
this.recordsPerPage = formConfig.defaultRecordsPerPage;
|
|
619
593
|
if (tableReceived.fields) {
|
|
620
594
|
for (const columnReceived of tableReceived.fields) {
|
|
621
|
-
const columnDefinition = new RecordTableColumn(columnReceived);
|
|
595
|
+
const columnDefinition = new RecordTableColumn(columnReceived, this._formConfig);
|
|
622
596
|
this.columns.push(columnDefinition);
|
|
623
597
|
this._tableColumnObj[columnDefinition.fieldCode] = columnDefinition;
|
|
624
598
|
}
|
|
@@ -795,7 +769,7 @@ class RecordTable extends FormElement {
|
|
|
795
769
|
return (this._actionsObj && actionCode && this._actionsObj[actionCode])
|
|
796
770
|
? this._actionsObj[actionCode] : null;
|
|
797
771
|
}
|
|
798
|
-
getActions(actionClass =
|
|
772
|
+
getActions(actionClass = this._formConfig.tableActions.inline, actionTypes = null) {
|
|
799
773
|
return this._actions.filter(actionDef => {
|
|
800
774
|
const typeIncluded = (actionTypes) ? actionTypes.includes(actionDef.actionType) : true;
|
|
801
775
|
return actionDef.actionClass === actionClass && typeIncluded;
|
|
@@ -856,14 +830,14 @@ class RecordTable extends FormElement {
|
|
|
856
830
|
setRequiredOrder(columnField) {
|
|
857
831
|
if (columnField !== this.sorting.columnName) {
|
|
858
832
|
this.sorting.columnName = columnField;
|
|
859
|
-
this.sorting.direction =
|
|
833
|
+
this.sorting.direction = TABLE_SORT_ASCENDING;
|
|
860
834
|
}
|
|
861
835
|
else {
|
|
862
|
-
if (this.sorting.direction ===
|
|
863
|
-
this.sorting.direction =
|
|
836
|
+
if (this.sorting.direction === TABLE_SORT_ASCENDING) {
|
|
837
|
+
this.sorting.direction = TABLE_SORT_DESCENDING;
|
|
864
838
|
}
|
|
865
839
|
else {
|
|
866
|
-
this.sorting.direction =
|
|
840
|
+
this.sorting.direction = TABLE_SORT_ASCENDING;
|
|
867
841
|
}
|
|
868
842
|
}
|
|
869
843
|
}
|
|
@@ -884,7 +858,7 @@ class RecordTable extends FormElement {
|
|
|
884
858
|
else if (recordAColumn > recordBColumn) {
|
|
885
859
|
result = 1;
|
|
886
860
|
}
|
|
887
|
-
return direction ===
|
|
861
|
+
return direction === TABLE_SORT_ASCENDING ? result : -result;
|
|
888
862
|
}
|
|
889
863
|
}
|
|
890
864
|
|
|
@@ -1040,13 +1014,15 @@ class LibTableComponent {
|
|
|
1040
1014
|
this.hasActions = false;
|
|
1041
1015
|
}
|
|
1042
1016
|
ngOnInit() {
|
|
1043
|
-
|
|
1017
|
+
var _a;
|
|
1018
|
+
this.formConfig = (_a = this.tableObject) === null || _a === void 0 ? void 0 : _a._formConfig;
|
|
1019
|
+
this.tableFieldStyles = this.formConfig.tableFieldStyles;
|
|
1044
1020
|
this.selectable = this.tableObject.selectable;
|
|
1045
1021
|
this.hasActions = this.tableObject.hasActions;
|
|
1046
1022
|
this.tableObject.widget = this;
|
|
1047
|
-
this.inlineActions = this.tableObject.getActions(
|
|
1048
|
-
this.globalActions = this.tableObject.getActions(
|
|
1049
|
-
this.selectionActions = this.tableObject.getActions(
|
|
1023
|
+
this.inlineActions = this.tableObject.getActions(this.formConfig.tableActions.inline);
|
|
1024
|
+
this.globalActions = this.tableObject.getActions(this.formConfig.tableActions.global);
|
|
1025
|
+
this.selectionActions = this.tableObject.getActions(this.formConfig.tableActions.selection);
|
|
1050
1026
|
this.start();
|
|
1051
1027
|
}
|
|
1052
1028
|
start() { }
|
|
@@ -1156,21 +1132,21 @@ class RecordFormSubSection {
|
|
|
1156
1132
|
let arrayToAdd = null;
|
|
1157
1133
|
const { type, code } = receivedElement;
|
|
1158
1134
|
switch (type) {
|
|
1159
|
-
case
|
|
1135
|
+
case elementTypes.field:
|
|
1160
1136
|
elementObject = formObject.getFieldObject(code);
|
|
1161
1137
|
arrayToAdd = this.subSectionFields;
|
|
1162
1138
|
break;
|
|
1163
|
-
case
|
|
1139
|
+
case elementTypes.table:
|
|
1164
1140
|
elementObject = formObject.getTableObject(code);
|
|
1165
1141
|
arrayToAdd = this.subSectionTables;
|
|
1166
1142
|
break;
|
|
1167
|
-
case
|
|
1143
|
+
case elementTypes.action:
|
|
1168
1144
|
elementObject = formObject.getActionObject(code);
|
|
1169
1145
|
arrayToAdd = this.subSectionActions;
|
|
1170
1146
|
break;
|
|
1171
1147
|
}
|
|
1172
1148
|
if (elementObject) {
|
|
1173
|
-
elementObject.
|
|
1149
|
+
elementObject.elementType = type;
|
|
1174
1150
|
arrayToAdd.push(elementObject);
|
|
1175
1151
|
this.subSectionElements.push(elementObject);
|
|
1176
1152
|
this.elementsArray[code] = elementObject;
|
|
@@ -1302,12 +1278,12 @@ class RecordFormSection {
|
|
|
1302
1278
|
|
|
1303
1279
|
const HEADER$1 = 'HEADER';
|
|
1304
1280
|
class FormAction extends FormElement {
|
|
1305
|
-
constructor(actionDefinition) {
|
|
1281
|
+
constructor(actionDefinition, formConfig) {
|
|
1306
1282
|
var _a, _b;
|
|
1307
|
-
super(actionDefinition);
|
|
1283
|
+
super(actionDefinition, formConfig);
|
|
1308
1284
|
this._actionActivated = new Subject();
|
|
1309
1285
|
this.inProgress = false;
|
|
1310
|
-
this.
|
|
1286
|
+
this.elementType = elementTypes.action;
|
|
1311
1287
|
this.actionCode = actionDefinition.actionCode ? actionDefinition.actionCode.toString() : '';
|
|
1312
1288
|
this.actionName = actionDefinition.actionTitle;
|
|
1313
1289
|
this.iconName = actionDefinition.iconName || this.actionCode;
|
|
@@ -1335,109 +1311,103 @@ class FormAction extends FormElement {
|
|
|
1335
1311
|
}
|
|
1336
1312
|
|
|
1337
1313
|
const UNDEFINED = 'undefined';
|
|
1338
|
-
const
|
|
1339
|
-
const
|
|
1340
|
-
const
|
|
1341
|
-
const FIELD_CAPTURE_TYPE = 'captureType';
|
|
1342
|
-
const FIELD_TYPE = 'fieldTypeCode';
|
|
1343
|
-
const FIELD_MAX_LENGTH = 'maxLength';
|
|
1344
|
-
const FIELD_VISIBLE = 'visible';
|
|
1345
|
-
const FIELD_LABEL_VISIBLE = 'visibleLabel';
|
|
1346
|
-
const FIELD_REQUIRED = 'required';
|
|
1347
|
-
const FIELD_ERR_CODE = 'errorCode';
|
|
1348
|
-
const FIELD_ERR_MSG = 'errorMessage';
|
|
1349
|
-
const FIELD_TOOLTIP = 'tooltipText';
|
|
1350
|
-
const FIELD_INFO = 'info';
|
|
1351
|
-
const FIELD_EDITABLE = 'editable';
|
|
1352
|
-
const FIELD_TYPES = {
|
|
1353
|
-
array: 'ARRAY',
|
|
1354
|
-
check: 'CHECK',
|
|
1355
|
-
date: 'DATE',
|
|
1356
|
-
daterange: 'DATERANGE',
|
|
1357
|
-
time: 'TIME',
|
|
1358
|
-
timerange: 'TIMERANGE',
|
|
1359
|
-
map: 'MAP',
|
|
1360
|
-
number: 'NUMBER',
|
|
1361
|
-
decimal: 'DECIMAL',
|
|
1362
|
-
currency: 'CURRENCY',
|
|
1363
|
-
select: 'SELECT',
|
|
1364
|
-
typeahead: 'TYPEAHEAD',
|
|
1365
|
-
text: 'TEXT',
|
|
1366
|
-
password: 'PASSWORD',
|
|
1367
|
-
label: 'LABEL',
|
|
1368
|
-
html: 'HTML',
|
|
1369
|
-
title: 'TITLE',
|
|
1370
|
-
message: 'MESSAGE',
|
|
1371
|
-
link: 'LINK',
|
|
1372
|
-
warning: 'WARNING',
|
|
1373
|
-
avatar: 'AVATAR',
|
|
1374
|
-
email: 'EMAIL',
|
|
1375
|
-
phone: 'PHONE',
|
|
1376
|
-
};
|
|
1377
|
-
const FIELD_TYPES_FORMATS = {
|
|
1378
|
-
EMAIL: new RegExp('^\\w+([\\.-]?\\w+)@\\w+([\\.-]?\\w+)(\\.\\w{2,3})+$'),
|
|
1379
|
-
};
|
|
1314
|
+
const DEFAULT_ERROR_TYPE = 'error';
|
|
1315
|
+
const DEFAULT_CAPTURE_TYPE = 'INPUT';
|
|
1316
|
+
const DEFAULT_ALIGNMENT = 'left';
|
|
1380
1317
|
const STD_MAX_LENGTH = 50;
|
|
1381
1318
|
const BIG_MAX_LENGTH = 500;
|
|
1319
|
+
const fldAttr = {
|
|
1320
|
+
validateOnServer: 'validateOnServer',
|
|
1321
|
+
value: '_fieldValue',
|
|
1322
|
+
minValue: '_minValue',
|
|
1323
|
+
maxValue: '_maxValue',
|
|
1324
|
+
maxLength: '_maxLength',
|
|
1325
|
+
onValidation: '_onValidation',
|
|
1326
|
+
intrinsicErrorMessage: '_intrinsicErrorMessage',
|
|
1327
|
+
code: 'fieldCode',
|
|
1328
|
+
info: 'fieldInfo',
|
|
1329
|
+
defaultValue: 'defaultValue',
|
|
1330
|
+
defaultEditable: 'defaultEditable',
|
|
1331
|
+
customAttributes: 'customAttributes',
|
|
1332
|
+
visibleLabel: 'visibleLabel',
|
|
1333
|
+
required: 'fieldRequired',
|
|
1334
|
+
hasChanged: 'hasChanged',
|
|
1335
|
+
outputOnly: 'outputOnly',
|
|
1336
|
+
captureType: 'captureType',
|
|
1337
|
+
title: 'fieldTitle',
|
|
1338
|
+
type: 'fieldType',
|
|
1339
|
+
alignment: 'fieldAlignment',
|
|
1340
|
+
format: 'fieldFormat',
|
|
1341
|
+
externalValue: 'externalValue',
|
|
1342
|
+
tooltipText: 'tooltipText',
|
|
1343
|
+
errorType: 'errorType',
|
|
1344
|
+
errorCode: 'errorCode',
|
|
1345
|
+
errorMessage: 'errorMessage',
|
|
1346
|
+
options: 'fieldOptions',
|
|
1347
|
+
};
|
|
1382
1348
|
class FieldDescriptor extends FormElement {
|
|
1383
|
-
constructor(inputFieldReceived) {
|
|
1384
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
1385
|
-
super(inputFieldReceived);
|
|
1349
|
+
constructor(inputFieldReceived, formConfig) {
|
|
1350
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
1351
|
+
super(inputFieldReceived, formConfig);
|
|
1386
1352
|
this._editionFinish = new Subject();
|
|
1387
1353
|
this._editionPartial = new Subject();
|
|
1388
1354
|
this._detailRequest = new Subject();
|
|
1389
|
-
this.
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
this.
|
|
1393
|
-
this.
|
|
1394
|
-
this.captureType =
|
|
1395
|
-
this.
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
this.
|
|
1401
|
-
|
|
1355
|
+
this._attributeChange = new Subject();
|
|
1356
|
+
this.elementType = elementTypes.field;
|
|
1357
|
+
const fld = (inputFieldReceived) ? inputFieldReceived : {};
|
|
1358
|
+
this.setAttr(fldAttr.code, fld.fieldCode);
|
|
1359
|
+
this.setAttr(fldAttr.title, (_a = fld.fieldTitle) !== null && _a !== void 0 ? _a : this.fieldCode);
|
|
1360
|
+
this.setAttr(fldAttr.captureType, (_b = fld.captureType) !== null && _b !== void 0 ? _b : DEFAULT_CAPTURE_TYPE);
|
|
1361
|
+
this.setAttr(fldAttr.defaultValue, (_c = fld.defaultValue) !== null && _c !== void 0 ? _c : null);
|
|
1362
|
+
const defaultTypeAlignment = (this._formConfig.tableFieldStyles[this.fieldType] != null)
|
|
1363
|
+
? this._formConfig.tableFieldStyles[this.fieldType]['text-align'] : DEFAULT_ALIGNMENT;
|
|
1364
|
+
const fieldAlignment = (fld.alignment != null) ? fld.alignment.toLowerCase() : defaultTypeAlignment;
|
|
1365
|
+
this.setAttr(fldAttr.alignment, fieldAlignment);
|
|
1366
|
+
this.setAttr(fldAttr.info, fld.info || '');
|
|
1367
|
+
let fieldFormat;
|
|
1402
1368
|
try {
|
|
1403
|
-
|
|
1369
|
+
fieldFormat = (fld.format) ? new RegExp(fld.format) : null;
|
|
1404
1370
|
}
|
|
1405
1371
|
catch (e) {
|
|
1406
|
-
|
|
1407
|
-
}
|
|
1408
|
-
this.
|
|
1409
|
-
this.
|
|
1410
|
-
this.
|
|
1411
|
-
this.
|
|
1412
|
-
this.
|
|
1413
|
-
this.
|
|
1414
|
-
this.
|
|
1415
|
-
this.
|
|
1416
|
-
|
|
1417
|
-
this.
|
|
1418
|
-
this.
|
|
1419
|
-
this.
|
|
1420
|
-
|
|
1421
|
-
|
|
1372
|
+
fieldFormat = null;
|
|
1373
|
+
}
|
|
1374
|
+
this.setAttr(fldAttr.format, fieldFormat);
|
|
1375
|
+
this.setAttr(fldAttr.validateOnServer, (_d = fld.serverAction) !== null && _d !== void 0 ? _d : false);
|
|
1376
|
+
this.setAttr(fldAttr.customAttributes, (_e = fld.customAttributes) !== null && _e !== void 0 ? _e : {});
|
|
1377
|
+
this.setAttr(fldAttr.tooltipText, fld.tooltip || '');
|
|
1378
|
+
this.setAttr(fldAttr.defaultEditable, this.enabled);
|
|
1379
|
+
this.setAttr(fldAttr.required, (_f = fld.required) !== null && _f !== void 0 ? _f : false);
|
|
1380
|
+
this.setError(fld.errorCode, fld.errorMessage, (_g = fld.errorType) !== null && _g !== void 0 ? _g : DEFAULT_ERROR_TYPE);
|
|
1381
|
+
this.setAttr(fldAttr.outputOnly, (_h = fld.outputOnly) !== null && _h !== void 0 ? _h : false);
|
|
1382
|
+
const maxLength = (_j = fld.maxLength) !== null && _j !== void 0 ? _j : (this.captureType === 'TEXTAREA' ? BIG_MAX_LENGTH : STD_MAX_LENGTH);
|
|
1383
|
+
this.setAttr(fldAttr.maxLength, maxLength);
|
|
1384
|
+
this.setAttr(fldAttr.intrinsicErrorMessage, (_k = this._formConfig.fieldTypeErrMsg[this.fieldType]) !== null && _k !== void 0 ? _k : this._formConfig.fieldTypeErrMsg.DEFAULT);
|
|
1385
|
+
this.setFieldType(fld.fieldTypeCode);
|
|
1386
|
+
this.setEditable((_l = fld.editable) !== null && _l !== void 0 ? _l : true);
|
|
1387
|
+
this.setVisibleLabel((_m = fld.visibleLabel) !== null && _m !== void 0 ? _m : true);
|
|
1388
|
+
this.setVisibility(fld.visible);
|
|
1389
|
+
this.setFieldOptions(fld.fieldOptions);
|
|
1390
|
+
this.setValue(fld.fieldValue || this.defaultValue || '');
|
|
1422
1391
|
}
|
|
1423
1392
|
get name() { return this.fieldCode; }
|
|
1424
1393
|
get editionFinish() { return this._editionFinish; }
|
|
1394
|
+
get attributeChange() { return this._attributeChange; }
|
|
1425
1395
|
get editionPartial() { return this._editionPartial; }
|
|
1426
1396
|
get detailRequest() { return this._detailRequest; }
|
|
1427
1397
|
get validating() { return this._onValidation; }
|
|
1428
|
-
set validating(isValidating) { this.
|
|
1429
|
-
setIntrinsicErrorMessage(message) { this.
|
|
1398
|
+
set validating(isValidating) { this.setAttr(fldAttr.onValidation, isValidating); }
|
|
1399
|
+
setIntrinsicErrorMessage(message) { this.setAttr(fldAttr.intrinsicErrorMessage, message); }
|
|
1430
1400
|
set intrinsicErrorMessage(message) { this.setIntrinsicErrorMessage(message); }
|
|
1431
1401
|
get fieldValue() { return this.getValue(); }
|
|
1432
1402
|
get required() { return this.fieldRequired; }
|
|
1433
|
-
set required(required) { this.
|
|
1403
|
+
set required(required) { this.setAttr(fldAttr.required, required !== null && required !== void 0 ? required : false); }
|
|
1434
1404
|
get maxLength() { return (this._maxLength > 0) ? this._maxLength.toString() : ''; }
|
|
1435
1405
|
set maxLength(requiredMaxLength) {
|
|
1436
1406
|
if (typeof requiredMaxLength === 'string') {
|
|
1437
|
-
this.
|
|
1407
|
+
this.setAttr(fldAttr.maxLength, parseInt(requiredMaxLength, 10));
|
|
1438
1408
|
}
|
|
1439
1409
|
else if (typeof requiredMaxLength === 'number') {
|
|
1440
|
-
this.
|
|
1410
|
+
this.setAttr(fldAttr.maxLength, requiredMaxLength);
|
|
1441
1411
|
}
|
|
1442
1412
|
}
|
|
1443
1413
|
get value() { return this.getValue(); }
|
|
@@ -1447,39 +1417,48 @@ class FieldDescriptor extends FormElement {
|
|
|
1447
1417
|
this._editionPartial.next({ code: this.fieldCode, intrinsicValidation });
|
|
1448
1418
|
}
|
|
1449
1419
|
notifyEditionFinish() {
|
|
1450
|
-
var _a, _b, _c, _d;
|
|
1420
|
+
var _a, _b, _c, _d, _e;
|
|
1451
1421
|
let intrinsicValidation = true;
|
|
1452
|
-
const fieldDefaultFormat = (_a =
|
|
1422
|
+
const fieldDefaultFormat = (_b = (_a = this._formConfig.fieldTypesPatterns) === null || _a === void 0 ? void 0 : _a[this.fieldType]) !== null && _b !== void 0 ? _b : null;
|
|
1453
1423
|
const fieldValue = this.getValue();
|
|
1454
1424
|
if (fieldValue && (fieldDefaultFormat || this.fieldFormat)) {
|
|
1455
|
-
intrinsicValidation = ((
|
|
1456
|
-
&& ((
|
|
1425
|
+
intrinsicValidation = ((_c = fieldDefaultFormat === null || fieldDefaultFormat === void 0 ? void 0 : fieldDefaultFormat.test(fieldValue)) !== null && _c !== void 0 ? _c : true)
|
|
1426
|
+
&& ((_e = (_d = this.fieldFormat) === null || _d === void 0 ? void 0 : _d.test(fieldValue)) !== null && _e !== void 0 ? _e : true);
|
|
1457
1427
|
if (!intrinsicValidation) {
|
|
1458
1428
|
this.setError('99', this._intrinsicErrorMessage);
|
|
1459
1429
|
}
|
|
1460
1430
|
}
|
|
1461
1431
|
this._editionFinish.next({ code: this.fieldCode, intrinsicValidation });
|
|
1462
1432
|
}
|
|
1433
|
+
setAttr(name, value) {
|
|
1434
|
+
this[name] = value;
|
|
1435
|
+
if (this._formConfig.monitoredFieldAttributes.includes(name)) {
|
|
1436
|
+
this._attributeChange.next({ name, value });
|
|
1437
|
+
}
|
|
1438
|
+
}
|
|
1463
1439
|
notifyEditionDetailRequest() {
|
|
1464
1440
|
this._detailRequest.next(this.fieldCode);
|
|
1465
1441
|
}
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1442
|
+
getCustomAttribute(name) { var _a, _b; return (_b = (_a = this.customAttributes) === null || _a === void 0 ? void 0 : _a[name]) !== null && _b !== void 0 ? _b : null; }
|
|
1443
|
+
setVisibleLabel(visibleLabel) { this.setAttr(fldAttr.visibleLabel, visibleLabel); }
|
|
1444
|
+
showLabel() { this.setVisibleLabel(true); }
|
|
1445
|
+
hideLabel() { this.setVisibleLabel(false); }
|
|
1446
|
+
setChanged(hasChanged) { this.setAttr(fldAttr.hasChanged, hasChanged); }
|
|
1447
|
+
changed() { this.setChanged(true); }
|
|
1469
1448
|
getRawValue() { return this._fieldValue; }
|
|
1470
|
-
setLabel(label) { this.
|
|
1449
|
+
setLabel(label) { this.setAttr(fldAttr.title, label); }
|
|
1471
1450
|
clean() { this.setValue(this.defaultValue || ''); }
|
|
1472
1451
|
get backend() { return this.validateOnServer; }
|
|
1473
|
-
setVisibleLabel(visibleLabel) { this.visibleLabel = visibleLabel; }
|
|
1474
1452
|
setEditable(editable = true) { (editable) ? this.enable() : this.disable(); }
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
this.errorCode
|
|
1478
|
-
this.
|
|
1453
|
+
hasError() { return this.errorCode !== '00'; }
|
|
1454
|
+
setError(code, message, type = DEFAULT_ERROR_TYPE) {
|
|
1455
|
+
this.setAttr(fldAttr.errorCode, code !== null && code !== void 0 ? code : '00');
|
|
1456
|
+
this.setAttr(fldAttr.errorType, (this.errorCode === '00') ? '' : type);
|
|
1457
|
+
this.setAttr(fldAttr.errorMessage, message !== null && message !== void 0 ? message : '');
|
|
1479
1458
|
}
|
|
1480
1459
|
getError() { return { type: this.errorType, code: this.errorCode, message: this.errorMessage }; }
|
|
1481
1460
|
get error() { return this.getError(); }
|
|
1482
|
-
set error(errorObj) { this.setError(errorObj.code, errorObj.message, errorObj.type); }
|
|
1461
|
+
set error(errorObj) { var _a; this.setError(errorObj.code, errorObj.message, (_a = errorObj.type) !== null && _a !== void 0 ? _a : DEFAULT_ERROR_TYPE); }
|
|
1483
1462
|
getErrorCode() { return this.getError().code; }
|
|
1484
1463
|
setErrorCode(code) { this.setError(code, this.errorMessage); }
|
|
1485
1464
|
getErrorMessage() { return this.getError().message; }
|
|
@@ -1489,7 +1468,7 @@ class FieldDescriptor extends FormElement {
|
|
|
1489
1468
|
if (fieldCurrentValue === undefined || fieldCurrentValue === null) {
|
|
1490
1469
|
return true;
|
|
1491
1470
|
}
|
|
1492
|
-
if ((this.fieldType ===
|
|
1471
|
+
if ((this.fieldType === this._formConfig.fieldTypes.array || this.fieldType === this._formConfig.fieldTypes.phone)
|
|
1493
1472
|
&& Array.isArray(fieldCurrentValue) && fieldCurrentValue.length === 0) {
|
|
1494
1473
|
return true;
|
|
1495
1474
|
}
|
|
@@ -1497,12 +1476,15 @@ class FieldDescriptor extends FormElement {
|
|
|
1497
1476
|
return fieldCurrentValue === '';
|
|
1498
1477
|
}
|
|
1499
1478
|
getValue() {
|
|
1500
|
-
var _a;
|
|
1479
|
+
var _a, _b;
|
|
1501
1480
|
switch (this.fieldType) {
|
|
1502
|
-
case
|
|
1481
|
+
case this._formConfig.fieldTypes.boolean:
|
|
1503
1482
|
return (_a = this._fieldValue) !== null && _a !== void 0 ? _a : false;
|
|
1504
1483
|
break;
|
|
1505
|
-
case
|
|
1484
|
+
case this._formConfig.fieldTypes.check:
|
|
1485
|
+
return (_b = this._fieldValue) !== null && _b !== void 0 ? _b : false;
|
|
1486
|
+
break;
|
|
1487
|
+
case this._formConfig.fieldTypes.currency:
|
|
1506
1488
|
return this._fieldValue.replace(',', '');
|
|
1507
1489
|
break;
|
|
1508
1490
|
default:
|
|
@@ -1512,68 +1494,39 @@ class FieldDescriptor extends FormElement {
|
|
|
1512
1494
|
}
|
|
1513
1495
|
updateFromServer(fld) {
|
|
1514
1496
|
var _a;
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
this.
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
this.
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
(this.
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
(this.
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
(this.
|
|
1532
|
-
|
|
1533
|
-
if (FIELD_INFO in fld) {
|
|
1534
|
-
(this.fieldInfo = fld.info);
|
|
1535
|
-
}
|
|
1536
|
-
if (FIELD_EDITABLE in fld) {
|
|
1537
|
-
this.setEditable(fld.editable);
|
|
1538
|
-
}
|
|
1539
|
-
if (FIELD_TITLE in fld) {
|
|
1540
|
-
this.setLabel(fld.fieldTitle.toString());
|
|
1541
|
-
}
|
|
1542
|
-
if (FIELD_VALUE in fld) {
|
|
1543
|
-
this.hasChanged = false;
|
|
1544
|
-
this.setValue(fld.fieldValue);
|
|
1545
|
-
}
|
|
1546
|
-
if (FIELD_OPTIONS in fld) {
|
|
1547
|
-
this.setFieldOptions(fld.fieldOptions);
|
|
1548
|
-
}
|
|
1549
|
-
if (FIELD_CAPTURE_TYPE in fld) {
|
|
1550
|
-
this.captureType = fld.captureType || 'INPUT';
|
|
1551
|
-
}
|
|
1552
|
-
if (FIELD_TYPE in fld) {
|
|
1553
|
-
this.setFieldType(fld.fieldTypeCode);
|
|
1554
|
-
}
|
|
1555
|
-
if (FIELD_MAX_LENGTH in fld) {
|
|
1556
|
-
this.maxLength = fld.maxLength;
|
|
1497
|
+
const fieldKeys = Object.keys(fld);
|
|
1498
|
+
for (let index = 0; index < fieldKeys.length; index++) {
|
|
1499
|
+
const attrName = fieldKeys[index];
|
|
1500
|
+
const attrValue = fld[attrName];
|
|
1501
|
+
(attrName === this._formConfig.apifieldattrs.visible) && this.setVisibility(attrValue);
|
|
1502
|
+
(attrName === this._formConfig.apifieldattrs.labelVisible) && this.setVisibleLabel(fld.visibleLabel);
|
|
1503
|
+
(attrName === this._formConfig.apifieldattrs.required) && this.setAttr(fldAttr.required, (_a = fld.required) !== null && _a !== void 0 ? _a : false);
|
|
1504
|
+
(attrName === this._formConfig.apifieldattrs.errorCode) && this.setAttr(fldAttr.errorCode, fld.errorCode);
|
|
1505
|
+
(attrName === this._formConfig.apifieldattrs.errorMessage) && this.setAttr(fldAttr.errorMessage, fld.errorMessage);
|
|
1506
|
+
(attrName === this._formConfig.apifieldattrs.tooltip) && this.setAttr(fldAttr.tooltipText, fld.tooltip);
|
|
1507
|
+
(attrName === this._formConfig.apifieldattrs.info) && this.setAttr(fldAttr.info, fld.info);
|
|
1508
|
+
(attrName === this._formConfig.apifieldattrs.editable) && this.setEditable(fld.editable);
|
|
1509
|
+
(attrName === this._formConfig.apifieldattrs.title) && this.setLabel(fld.fieldTitle.toString());
|
|
1510
|
+
(attrName === this._formConfig.apifieldattrs.value) && (this.setValue(fld._fieldValue) && this.setChanged(false));
|
|
1511
|
+
(attrName === this._formConfig.apifieldattrs.options) && this.setFieldOptions(fld.fieldOptions);
|
|
1512
|
+
(attrName === this._formConfig.apifieldattrs.captureType) && this.setAttr(fldAttr.captureType, fld.captureType || 'INPUT');
|
|
1513
|
+
(attrName === this._formConfig.apifieldattrs.type) && this.setFieldType(fld.fieldTypeCode);
|
|
1514
|
+
(attrName === this._formConfig.apifieldattrs.maxLength) && this.setAttr(fldAttr.maxLength, fld.maxLength);
|
|
1557
1515
|
}
|
|
1558
1516
|
}
|
|
1559
1517
|
setFieldType(inputFieldType) {
|
|
1560
|
-
this.
|
|
1561
|
-
/**
|
|
1562
|
-
* Se elimina la validación de que sea un tipo conocido
|
|
1563
|
-
* this.fieldType = (inputFieldType && FIELDTYPES.includes(inputFieldType))
|
|
1564
|
-
* ? inputFieldType : componentConstants.FIELDTYPE_TEXT;
|
|
1565
|
-
*/
|
|
1518
|
+
this.setAttr(fldAttr.type, inputFieldType);
|
|
1566
1519
|
}
|
|
1567
1520
|
format() {
|
|
1568
|
-
if (this.fieldType ===
|
|
1569
|
-
this.
|
|
1521
|
+
if (this.fieldType === this._formConfig.fieldTypes.currency) {
|
|
1522
|
+
this.setAttr(fldAttr.value, formatCurrency(this._fieldValue));
|
|
1570
1523
|
}
|
|
1571
1524
|
}
|
|
1572
1525
|
setMinValue(minValue) {
|
|
1573
1526
|
var _a, _b, _c;
|
|
1574
|
-
if (this.fieldType ===
|
|
1527
|
+
if (this.fieldType === this._formConfig.fieldTypes.date
|
|
1575
1528
|
&& ((_a = this.widget) === null || _a === void 0 ? void 0 : _a.setMinValue)) {
|
|
1576
|
-
this.
|
|
1529
|
+
this.setAttr(fldAttr.minValue, minValue);
|
|
1577
1530
|
if (!minValue) {
|
|
1578
1531
|
(_b = this.widget) === null || _b === void 0 ? void 0 : _b.setMinValue(false);
|
|
1579
1532
|
}
|
|
@@ -1585,9 +1538,9 @@ class FieldDescriptor extends FormElement {
|
|
|
1585
1538
|
}
|
|
1586
1539
|
setMaxValue(maxValue) {
|
|
1587
1540
|
var _a, _b, _c;
|
|
1588
|
-
if (this.fieldType ===
|
|
1541
|
+
if (this.fieldType === this._formConfig.fieldTypes.date
|
|
1589
1542
|
&& ((_a = this.widget) === null || _a === void 0 ? void 0 : _a.setMaxValue)) {
|
|
1590
|
-
this.
|
|
1543
|
+
this.setAttr(fldAttr.maxValue, maxValue);
|
|
1591
1544
|
if (!maxValue) {
|
|
1592
1545
|
(_b = this.widget) === null || _b === void 0 ? void 0 : _b.setMaxValue(false);
|
|
1593
1546
|
}
|
|
@@ -1607,21 +1560,23 @@ class FieldDescriptor extends FormElement {
|
|
|
1607
1560
|
|| !Array.isArray(newOptions)) {
|
|
1608
1561
|
return;
|
|
1609
1562
|
}
|
|
1610
|
-
|
|
1563
|
+
let fieldOptions = newOptions.map(option => {
|
|
1611
1564
|
if (option.text !== undefined && option.text !== null
|
|
1612
1565
|
&& option.value !== undefined && option.value !== null) {
|
|
1613
1566
|
return { fieldOptionValue: option.text, fieldOptionId: option.value };
|
|
1614
1567
|
}
|
|
1615
1568
|
return Object.assign({}, option);
|
|
1616
1569
|
});
|
|
1617
|
-
|
|
1570
|
+
fieldOptions = (fieldOptions && Array.isArray(fieldOptions)
|
|
1618
1571
|
&& fieldOptions.length > 0) ? fieldOptions : [];
|
|
1619
|
-
|
|
1572
|
+
this.setAttr(fldAttr.options, fieldOptions);
|
|
1573
|
+
if (this.fieldType === this._formConfig.fieldTypes.array && this.widget) {
|
|
1620
1574
|
return (_a = this.widget) === null || _a === void 0 ? void 0 : _a.refereshContent();
|
|
1621
1575
|
}
|
|
1622
1576
|
if (this._fieldValue) {
|
|
1623
|
-
if (this.fieldType ===
|
|
1624
|
-
|
|
1577
|
+
if (this.fieldType === this._formConfig.fieldTypes.array && Array.isArray(this._fieldValue)) {
|
|
1578
|
+
const fieldValue = (_b = this._fieldValue) === null || _b === void 0 ? void 0 : _b.filter(item => this.fieldOptions.find(opt => opt.fieldOptionId === item));
|
|
1579
|
+
this.setAttr(fldAttr.value, fieldValue);
|
|
1625
1580
|
}
|
|
1626
1581
|
else {
|
|
1627
1582
|
const valInOptions = this.fieldOptions
|
|
@@ -1641,17 +1596,20 @@ class FieldDescriptor extends FormElement {
|
|
|
1641
1596
|
setValue(newValue, widgetUpdate = true) {
|
|
1642
1597
|
var _a;
|
|
1643
1598
|
if (typeof newValue === UNDEFINED || newValue === null) {
|
|
1644
|
-
return;
|
|
1599
|
+
return true;
|
|
1645
1600
|
}
|
|
1646
1601
|
let newFinalValue;
|
|
1647
1602
|
switch (this.fieldType) {
|
|
1648
1603
|
case 'BOOLEAN':
|
|
1649
1604
|
newFinalValue = !!newValue;
|
|
1650
1605
|
break;
|
|
1651
|
-
case
|
|
1606
|
+
case this._formConfig.fieldTypes.boolean:
|
|
1652
1607
|
newFinalValue = !!newValue;
|
|
1653
1608
|
break;
|
|
1654
|
-
case
|
|
1609
|
+
case this._formConfig.fieldTypes.check:
|
|
1610
|
+
newFinalValue = !!newValue;
|
|
1611
|
+
break;
|
|
1612
|
+
case this._formConfig.fieldTypes.array:
|
|
1655
1613
|
if (newValue === null || newValue === '') {
|
|
1656
1614
|
newFinalValue = [];
|
|
1657
1615
|
}
|
|
@@ -1665,7 +1623,7 @@ class FieldDescriptor extends FormElement {
|
|
|
1665
1623
|
newFinalValue = newValue;
|
|
1666
1624
|
}
|
|
1667
1625
|
break;
|
|
1668
|
-
case
|
|
1626
|
+
case this._formConfig.fieldTypes.map:
|
|
1669
1627
|
newFinalValue = newValue;
|
|
1670
1628
|
if (newFinalValue && this.widget && widgetUpdate) {
|
|
1671
1629
|
const latitude = parseFloat(newFinalValue[0]);
|
|
@@ -1673,7 +1631,7 @@ class FieldDescriptor extends FormElement {
|
|
|
1673
1631
|
(_a = this.widget) === null || _a === void 0 ? void 0 : _a.setLocation(latitude, longitude);
|
|
1674
1632
|
}
|
|
1675
1633
|
break;
|
|
1676
|
-
case
|
|
1634
|
+
case this._formConfig.fieldTypes.currency:
|
|
1677
1635
|
newFinalValue = formatCurrency(this._fieldValue);
|
|
1678
1636
|
break;
|
|
1679
1637
|
default:
|
|
@@ -1681,22 +1639,24 @@ class FieldDescriptor extends FormElement {
|
|
|
1681
1639
|
break;
|
|
1682
1640
|
}
|
|
1683
1641
|
if (this._fieldValue !== newFinalValue) {
|
|
1684
|
-
this.
|
|
1685
|
-
this.
|
|
1642
|
+
this.setChanged(true);
|
|
1643
|
+
this.setAttr(fldAttr.value, newFinalValue);
|
|
1686
1644
|
}
|
|
1645
|
+
return true;
|
|
1687
1646
|
}
|
|
1688
1647
|
}
|
|
1689
1648
|
|
|
1690
1649
|
const HEADER = 'HEADER';
|
|
1691
1650
|
const NO_ERROR = '00';
|
|
1692
1651
|
class FormStructureAndData {
|
|
1693
|
-
constructor(definitionReceived) {
|
|
1652
|
+
constructor(definitionReceived, formConfig) {
|
|
1694
1653
|
this._fieldsObj = {};
|
|
1695
1654
|
this._actionsObj = {};
|
|
1696
1655
|
this._tableObj = {};
|
|
1697
1656
|
this._sectionsObj = {};
|
|
1698
1657
|
this._immutableData = {};
|
|
1699
1658
|
this._extraInfo = {};
|
|
1659
|
+
this._formConfig = formConfig;
|
|
1700
1660
|
this.state = '';
|
|
1701
1661
|
this._actions = [];
|
|
1702
1662
|
this._fields = [];
|
|
@@ -1730,7 +1690,7 @@ class FormStructureAndData {
|
|
|
1730
1690
|
return Object.assign(Object.assign({}, objDef), { visibleStates, enabledStates });
|
|
1731
1691
|
});
|
|
1732
1692
|
for (const actionReceived of formActions) {
|
|
1733
|
-
const globalAction = new FormAction(actionReceived);
|
|
1693
|
+
const globalAction = new FormAction(actionReceived, this._formConfig);
|
|
1734
1694
|
const globalActionCode = globalAction.actionCode;
|
|
1735
1695
|
if (globalActionCode) {
|
|
1736
1696
|
this._actions.push(globalAction);
|
|
@@ -1751,7 +1711,7 @@ class FormStructureAndData {
|
|
|
1751
1711
|
return Object.assign(Object.assign({}, objDef), { visibleStates, enabledStates });
|
|
1752
1712
|
});
|
|
1753
1713
|
for (const fieldReceived of formFields) {
|
|
1754
|
-
const fieldToAdd = new FieldDescriptor(fieldReceived);
|
|
1714
|
+
const fieldToAdd = new FieldDescriptor(fieldReceived, this._formConfig);
|
|
1755
1715
|
const fieldCode = fieldToAdd.fieldCode;
|
|
1756
1716
|
if (fieldCode) {
|
|
1757
1717
|
this._fields.push(fieldToAdd);
|
|
@@ -1770,12 +1730,12 @@ class FormStructureAndData {
|
|
|
1770
1730
|
enabledStates = [...visibleStates];
|
|
1771
1731
|
}
|
|
1772
1732
|
if (!visibleStates || visibleStates.length === 0) {
|
|
1773
|
-
visibleStates =
|
|
1733
|
+
visibleStates = this._formConfig.defaultStateFlow.states;
|
|
1774
1734
|
}
|
|
1775
1735
|
return Object.assign(Object.assign({}, objDef), { visibleStates, enabledStates });
|
|
1776
1736
|
});
|
|
1777
1737
|
for (const tableReceived of tables) {
|
|
1778
|
-
const tableToAdd = new RecordTable(tableReceived);
|
|
1738
|
+
const tableToAdd = new RecordTable(tableReceived, this._formConfig);
|
|
1779
1739
|
const tableCode = tableToAdd.tableCode;
|
|
1780
1740
|
if (tableCode) {
|
|
1781
1741
|
this._tables.push(tableToAdd);
|
|
@@ -1827,7 +1787,7 @@ class FormStructureAndData {
|
|
|
1827
1787
|
}
|
|
1828
1788
|
setStateFlow(states, transitions, defaultState) {
|
|
1829
1789
|
if (!states || !transitions) {
|
|
1830
|
-
this._stateFlow = JSON.parse(JSON.stringify(
|
|
1790
|
+
this._stateFlow = JSON.parse(JSON.stringify(this._formConfig.defaultStateFlow));
|
|
1831
1791
|
return;
|
|
1832
1792
|
}
|
|
1833
1793
|
this._stateFlow.states = states;
|
|
@@ -2256,71 +2216,77 @@ class LibFormManagerService {
|
|
|
2256
2216
|
constructor() {
|
|
2257
2217
|
this.cleanStack();
|
|
2258
2218
|
}
|
|
2259
|
-
|
|
2260
|
-
* Métodos virtuales de manejo de formularios
|
|
2261
|
-
*/
|
|
2219
|
+
// Métodos virtuales para las aplicaciones
|
|
2262
2220
|
getFormDefinition(formCode) { }
|
|
2221
|
+
getFormRoute(formCode) { }
|
|
2222
|
+
getRouteForm(path) { }
|
|
2263
2223
|
execServerAction(actionDetail) { }
|
|
2264
|
-
|
|
2265
|
-
/**
|
|
2266
|
-
* Manejo del stack de navegación con atributos estados y parámetros
|
|
2267
|
-
*/
|
|
2268
|
-
resetPageStack() { this.cleanStack(); }
|
|
2269
|
-
cleanStack() {
|
|
2270
|
-
this.pageStack = [];
|
|
2271
|
-
}
|
|
2224
|
+
goToForm(formCode, token, subject) { }
|
|
2272
2225
|
loadStack() { }
|
|
2273
2226
|
saveStack() { }
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
this.
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
|
|
2227
|
+
cleanStack() { this.pageStack = []; }
|
|
2228
|
+
resetPageStack() { this.cleanStack(); }
|
|
2229
|
+
findFormInStack(token) {
|
|
2230
|
+
const index = this.pageStack.findIndex(item => (item === null || item === void 0 ? void 0 : item.token) === token);
|
|
2231
|
+
const data = (index >= 0) ? this.pageStack[index] : null;
|
|
2232
|
+
return { index, data };
|
|
2233
|
+
}
|
|
2234
|
+
replaceItem(token, formInfo) {
|
|
2235
|
+
var _a, _b;
|
|
2236
|
+
if (!token || !formInfo) {
|
|
2237
|
+
return;
|
|
2238
|
+
}
|
|
2239
|
+
const { index, data: storedForm } = this.findFormInStack(token);
|
|
2240
|
+
let updatedForm = null;
|
|
2241
|
+
if (index >= 0) {
|
|
2242
|
+
updatedForm = Object.assign({}, storedForm);
|
|
2243
|
+
updatedForm.subject = (_a = formInfo === null || formInfo === void 0 ? void 0 : formInfo.subject) !== null && _a !== void 0 ? _a : storedForm.subject;
|
|
2244
|
+
updatedForm.state = (_b = formInfo === null || formInfo === void 0 ? void 0 : formInfo.state) !== null && _b !== void 0 ? _b : storedForm.state;
|
|
2245
|
+
Object.assign(updatedForm.fields, formInfo.fields);
|
|
2246
|
+
Object.assign(updatedForm.extra, formInfo.extra);
|
|
2247
|
+
this.pageStack[index] = updatedForm;
|
|
2286
2248
|
this.saveStack();
|
|
2287
|
-
return formData;
|
|
2288
2249
|
}
|
|
2289
2250
|
}
|
|
2290
|
-
|
|
2291
|
-
const
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
|
|
2251
|
+
stack(origin, target) {
|
|
2252
|
+
const token = nanoid(6);
|
|
2253
|
+
this.replaceItem(target.originToken, origin);
|
|
2254
|
+
this.pageStack.push(Object.assign({ token }, target));
|
|
2255
|
+
this.saveStack();
|
|
2256
|
+
return token;
|
|
2257
|
+
}
|
|
2258
|
+
unstack(token = null) {
|
|
2259
|
+
let index = (token) ? this.findFormInStack(token).index : this.pageStack.length - 2;
|
|
2260
|
+
let formInfo = null;
|
|
2261
|
+
if (index >= 0) {
|
|
2262
|
+
formInfo = this.pageStack[index];
|
|
2263
|
+
this.pageStack.splice(index + 1);
|
|
2264
|
+
this.saveStack();
|
|
2295
2265
|
}
|
|
2296
|
-
return
|
|
2266
|
+
return formInfo;
|
|
2297
2267
|
}
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
|
|
2268
|
+
getFormInfo(token) {
|
|
2269
|
+
var _a, _b;
|
|
2270
|
+
const { data } = this.findFormInStack(token);
|
|
2271
|
+
return {
|
|
2272
|
+
token: data === null || data === void 0 ? void 0 : data.token,
|
|
2273
|
+
subject: data === null || data === void 0 ? void 0 : data.subject,
|
|
2274
|
+
state: data === null || data === void 0 ? void 0 : data.state,
|
|
2275
|
+
originToken: data === null || data === void 0 ? void 0 : data.originToken,
|
|
2276
|
+
fields: (_a = data === null || data === void 0 ? void 0 : data.fields) !== null && _a !== void 0 ? _a : {},
|
|
2277
|
+
extra: (_b = data === null || data === void 0 ? void 0 : data.extra) !== null && _b !== void 0 ? _b : {}
|
|
2278
|
+
};
|
|
2305
2279
|
}
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
const
|
|
2311
|
-
|
|
2312
|
-
const navigationArray = [url, ...params, newToken];
|
|
2313
|
-
this.goToRoute(navigationArray);
|
|
2280
|
+
openForm(origin, target) {
|
|
2281
|
+
var _a;
|
|
2282
|
+
(!origin) && this.cleanStack();
|
|
2283
|
+
target.originToken = (_a = origin === null || origin === void 0 ? void 0 : origin.token) !== null && _a !== void 0 ? _a : null;
|
|
2284
|
+
const token = this.stack(origin, target);
|
|
2285
|
+
this.goToForm(target.name, token, target.subject);
|
|
2314
2286
|
}
|
|
2315
|
-
|
|
2316
|
-
const
|
|
2317
|
-
|
|
2318
|
-
return;
|
|
2319
|
-
}
|
|
2320
|
-
const { origin: { url, params, token } } = prevForm;
|
|
2321
|
-
const navigationArray = [url, ...params];
|
|
2322
|
-
token && navigationArray.push(token);
|
|
2323
|
-
this.goToRoute(navigationArray);
|
|
2287
|
+
backTo(targetToken = null) {
|
|
2288
|
+
const formInfo = this.unstack(targetToken);
|
|
2289
|
+
formInfo && formInfo.name && this.goToForm(formInfo.name, formInfo.token, formInfo.subject);
|
|
2324
2290
|
}
|
|
2325
2291
|
}
|
|
2326
2292
|
|
|
@@ -2351,11 +2317,8 @@ const PAYLOAD_VERSION = 'TUAINEXCHANGE_1.0';
|
|
|
2351
2317
|
const INLINE_ACTION = 'INLINE';
|
|
2352
2318
|
const GLOBAL_ACTION = 'GLOBAL';
|
|
2353
2319
|
const GET_DATA_ACTION = 'GETDATA';
|
|
2354
|
-
const
|
|
2355
|
-
const
|
|
2356
|
-
const ORIGIN_PARAM = 'origin';
|
|
2357
|
-
const STATE_PARAM = 'mode';
|
|
2358
|
-
const REQUIRED_FIELD_MESSAGE = 'Campo requerido';
|
|
2320
|
+
const SUBJECT = 'subject';
|
|
2321
|
+
const TOKEN = 'token';
|
|
2359
2322
|
class BasicFormComponent {
|
|
2360
2323
|
constructor(formManagerService, _eventManager, fileMgmtServices) {
|
|
2361
2324
|
this.formManagerService = formManagerService;
|
|
@@ -2365,10 +2328,9 @@ class BasicFormComponent {
|
|
|
2365
2328
|
this.errorMessage = '';
|
|
2366
2329
|
this.errorDetail = '';
|
|
2367
2330
|
this.formStructure = null;
|
|
2368
|
-
this.
|
|
2369
|
-
this.inputDataFields =
|
|
2370
|
-
this.extraData =
|
|
2371
|
-
this.componentConstants = componentConstants;
|
|
2331
|
+
this.controlToken = null;
|
|
2332
|
+
this.inputDataFields = {};
|
|
2333
|
+
this.extraData = {};
|
|
2372
2334
|
this.definitionObtained = false;
|
|
2373
2335
|
this.formVisible = false;
|
|
2374
2336
|
this.inServerProcess = false;
|
|
@@ -2390,14 +2352,17 @@ class BasicFormComponent {
|
|
|
2390
2352
|
this.cleanStart();
|
|
2391
2353
|
this.customPreProcessing();
|
|
2392
2354
|
}
|
|
2355
|
+
setConfig(formConfig) {
|
|
2356
|
+
this.formConfig = formConfig;
|
|
2357
|
+
}
|
|
2393
2358
|
cleanStart() {
|
|
2394
2359
|
this._errorType = '';
|
|
2395
2360
|
this.errorCode = '';
|
|
2396
2361
|
this.errorMessage = '';
|
|
2397
2362
|
this.errorDetail = '';
|
|
2398
2363
|
this.formStructure = null;
|
|
2399
|
-
this.
|
|
2400
|
-
this.inputDataFields =
|
|
2364
|
+
this.controlToken = null;
|
|
2365
|
+
this.inputDataFields = {};
|
|
2401
2366
|
this.definitionObtained = false;
|
|
2402
2367
|
// Se limpian los manejadores de eventos
|
|
2403
2368
|
this.formVisible = false;
|
|
@@ -2546,35 +2511,61 @@ class BasicFormComponent {
|
|
|
2546
2511
|
subscribeAppEvent(eventName, callback) {
|
|
2547
2512
|
this._eventEmiter.subscribe(eventName, callback);
|
|
2548
2513
|
}
|
|
2514
|
+
openForm(name, data, backData = null, cleanStack = false) {
|
|
2515
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
2516
|
+
let origin = null;
|
|
2517
|
+
if (!cleanStack) {
|
|
2518
|
+
origin = Object.assign(Object.assign({}, backData), { name: this.name, url: this._formRoute, token: this.controlToken });
|
|
2519
|
+
origin.subject = (_a = origin === null || origin === void 0 ? void 0 : origin.subject) !== null && _a !== void 0 ? _a : this.formSubject;
|
|
2520
|
+
origin.state = (_b = origin === null || origin === void 0 ? void 0 : origin.state) !== null && _b !== void 0 ? _b : this.currentState;
|
|
2521
|
+
origin.fields = (_c = origin === null || origin === void 0 ? void 0 : origin.fields) !== null && _c !== void 0 ? _c : {};
|
|
2522
|
+
origin.extra = (_d = origin === null || origin === void 0 ? void 0 : origin.extra) !== null && _d !== void 0 ? _d : {};
|
|
2523
|
+
}
|
|
2524
|
+
const target = Object.assign(Object.assign({}, data), { name });
|
|
2525
|
+
target.subject = (_e = target === null || target === void 0 ? void 0 : target.subject) !== null && _e !== void 0 ? _e : null;
|
|
2526
|
+
target.state = (_f = target === null || target === void 0 ? void 0 : target.state) !== null && _f !== void 0 ? _f : null;
|
|
2527
|
+
target.fields = (_g = target === null || target === void 0 ? void 0 : target.fields) !== null && _g !== void 0 ? _g : {};
|
|
2528
|
+
target.extra = (_h = target === null || target === void 0 ? void 0 : target.extra) !== null && _h !== void 0 ? _h : {};
|
|
2529
|
+
this.formManagerService.openForm(origin, target);
|
|
2530
|
+
}
|
|
2531
|
+
/**
|
|
2532
|
+
* @deprecated Este método ya no debería ser utilizado. Use openForm con el nombre del formulario
|
|
2533
|
+
*/
|
|
2549
2534
|
goToPage(navigationArray, predefinedFields, options = null) {
|
|
2550
|
-
var _a
|
|
2535
|
+
var _a;
|
|
2551
2536
|
let origin = null;
|
|
2552
2537
|
const cleanStack = (_a = options === null || options === void 0 ? void 0 : options.cleanStack) !== null && _a !== void 0 ? _a : false;
|
|
2553
|
-
const params = [];
|
|
2554
|
-
this.currentState && params.push(this.currentState);
|
|
2555
|
-
this.formSubject && params.push(this.formSubject);
|
|
2556
2538
|
if (!cleanStack) {
|
|
2557
2539
|
origin = {
|
|
2558
|
-
|
|
2540
|
+
name: this.name,
|
|
2559
2541
|
url: this._formRoute,
|
|
2560
|
-
|
|
2561
|
-
|
|
2562
|
-
|
|
2542
|
+
token: this.controlToken,
|
|
2543
|
+
fields: this.inputDataFields,
|
|
2544
|
+
extra: this.extraData
|
|
2563
2545
|
};
|
|
2564
2546
|
}
|
|
2565
2547
|
const target = {
|
|
2548
|
+
name: this.formManagerService.getRouteForm(navigationArray === null || navigationArray === void 0 ? void 0 : navigationArray[0]),
|
|
2566
2549
|
url: navigationArray === null || navigationArray === void 0 ? void 0 : navigationArray[0],
|
|
2567
|
-
|
|
2568
|
-
|
|
2550
|
+
state: navigationArray === null || navigationArray === void 0 ? void 0 : navigationArray[1],
|
|
2551
|
+
subject: navigationArray === null || navigationArray === void 0 ? void 0 : navigationArray[2],
|
|
2552
|
+
fields: predefinedFields,
|
|
2553
|
+
extra: null,
|
|
2569
2554
|
};
|
|
2570
|
-
this.formManagerService.
|
|
2555
|
+
this.formManagerService.openForm(origin, target);
|
|
2571
2556
|
}
|
|
2557
|
+
/**
|
|
2558
|
+
* @deprecated Este método ya no debería ser utilizado. Use openForm con el nombre del formulario
|
|
2559
|
+
*/
|
|
2572
2560
|
goToNewPage(nav, flds) { return this.goToPage(nav, flds, { cleanStack: true }); }
|
|
2561
|
+
/**
|
|
2562
|
+
* @deprecated Este método ya no debería ser utilizado. Use openForm con el nombre del formulario
|
|
2563
|
+
*/
|
|
2573
2564
|
goToSubPage(nav, flds) { return this.goToPage(nav, flds, { cleanStack: false }); }
|
|
2574
|
-
canGoBack() { return this.
|
|
2575
|
-
goBack() { return this.formManagerService.
|
|
2565
|
+
canGoBack() { return this.originToken !== null; }
|
|
2566
|
+
goBack() { return this.formManagerService.backTo(); }
|
|
2576
2567
|
goBackForm() { return this.goBack(); }
|
|
2577
|
-
getOriginDetail() { return this.formManagerService.
|
|
2568
|
+
getOriginDetail() { return this.formManagerService.getFormInfo(this.originToken); }
|
|
2578
2569
|
setError(errorType, errorMessage, errorDetail) {
|
|
2579
2570
|
this._errorType = errorType || '';
|
|
2580
2571
|
this.errorMessage = errorMessage || '';
|
|
@@ -2594,33 +2585,23 @@ class BasicFormComponent {
|
|
|
2594
2585
|
get formCode() { return this.name; }
|
|
2595
2586
|
set formCode(name) { this.name = name; }
|
|
2596
2587
|
getFormParameter(name) {
|
|
2597
|
-
|
|
2588
|
+
var _a, _b;
|
|
2589
|
+
return (name) ? ((_b = (_a = this.extraData) === null || _a === void 0 ? void 0 : _a[name]) !== null && _b !== void 0 ? _b : null) : null;
|
|
2598
2590
|
}
|
|
2599
2591
|
getSubject() { return this.formSubject; }
|
|
2600
2592
|
getformSubject() { return this.getSubject(); }
|
|
2601
2593
|
preocessInputParams(params) {
|
|
2602
|
-
var _a, _b
|
|
2603
|
-
|
|
2604
|
-
|
|
2605
|
-
|
|
2606
|
-
|
|
2607
|
-
this.extraData = [];
|
|
2608
|
-
for (const paramName of allParams) {
|
|
2609
|
-
this.extraData[paramName] = params[paramName].toString();
|
|
2610
|
-
}
|
|
2611
|
-
const formName = (_b = (_a = this.extraData) === null || _a === void 0 ? void 0 : _a[FORM_CODE]) !== null && _b !== void 0 ? _b : this.name;
|
|
2612
|
-
if (formName !== this.name) {
|
|
2613
|
-
this.cleanStart();
|
|
2614
|
-
this.name = formName;
|
|
2615
|
-
}
|
|
2616
|
-
this.formSubject = (_d = (_c = this.extraData) === null || _c === void 0 ? void 0 : _c[FORM_SUBJECT]) !== null && _d !== void 0 ? _d : null;
|
|
2617
|
-
const initialState = this.extraData[STATE_PARAM];
|
|
2618
|
-
this.transitionToken = (_e = this.extraData[ORIGIN_PARAM]) !== null && _e !== void 0 ? _e : null;
|
|
2619
|
-
this.inputDataFields = (_f = this.formManagerService.getInputData(this.transitionToken)) !== null && _f !== void 0 ? _f : [];
|
|
2620
|
-
if (!this.transitionToken) {
|
|
2621
|
-
this.formManagerService.cleanStack();
|
|
2594
|
+
var _a, _b;
|
|
2595
|
+
this.controlToken = (_a = params === null || params === void 0 ? void 0 : params[TOKEN].toString()) !== null && _a !== void 0 ? _a : null;
|
|
2596
|
+
const { token, subject, state, fields, extra, originToken } = this.formManagerService.getFormInfo(this.controlToken);
|
|
2597
|
+
if (!this.controlToken || this.controlToken !== token) {
|
|
2598
|
+
console.log(`No se obtuvo un token válido para abrir el formulario ${this.controlToken}->${token}`);
|
|
2622
2599
|
}
|
|
2623
|
-
|
|
2600
|
+
this.formSubject = (_b = params === null || params === void 0 ? void 0 : params[SUBJECT].toString()) !== null && _b !== void 0 ? _b : subject;
|
|
2601
|
+
this.inputDataFields = fields;
|
|
2602
|
+
this.extraData = extra;
|
|
2603
|
+
this.originToken = originToken;
|
|
2604
|
+
return state;
|
|
2624
2605
|
}
|
|
2625
2606
|
subscribeSectionActivation() {
|
|
2626
2607
|
const formSections = this.formStructure.getSections();
|
|
@@ -2668,7 +2649,6 @@ class BasicFormComponent {
|
|
|
2668
2649
|
}
|
|
2669
2650
|
}
|
|
2670
2651
|
formInit(params) {
|
|
2671
|
-
var _a;
|
|
2672
2652
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2673
2653
|
let initialState = this.preocessInputParams(params);
|
|
2674
2654
|
if (!this.name) {
|
|
@@ -2678,7 +2658,7 @@ class BasicFormComponent {
|
|
|
2678
2658
|
this.inServerProcess = true;
|
|
2679
2659
|
const formDefinition = yield this.formManagerService.getFormDefinition(this.name);
|
|
2680
2660
|
this.inServerProcess = false;
|
|
2681
|
-
this.formStructure = new FormStructureAndData(formDefinition);
|
|
2661
|
+
this.formStructure = new FormStructureAndData(formDefinition, this.formConfig);
|
|
2682
2662
|
this.definitionObtained = true;
|
|
2683
2663
|
}
|
|
2684
2664
|
else {
|
|
@@ -2688,23 +2668,13 @@ class BasicFormComponent {
|
|
|
2688
2668
|
initialState = this.formStructure.defaultState;
|
|
2689
2669
|
}
|
|
2690
2670
|
this.formStructure.changeState(initialState || this.formStructure.defaultState);
|
|
2691
|
-
|
|
2692
|
-
|
|
2693
|
-
|
|
2694
|
-
|
|
2695
|
-
|
|
2696
|
-
}
|
|
2697
|
-
}
|
|
2698
|
-
}
|
|
2699
|
-
else {
|
|
2700
|
-
const fieldCodes = Object.keys((_a = this.inputDataFields) !== null && _a !== void 0 ? _a : {});
|
|
2701
|
-
for (let index = 0; index < fieldCodes.length; index++) {
|
|
2702
|
-
const fieldCode = fieldCodes[index];
|
|
2703
|
-
const fieldValue = this.inputDataFields[fieldCode];
|
|
2704
|
-
this.setFieldValue(fieldCode, fieldValue);
|
|
2705
|
-
}
|
|
2671
|
+
const inputFieldNames = Object.keys(this.inputDataFields);
|
|
2672
|
+
for (let index = 0; index < inputFieldNames.length; index++) {
|
|
2673
|
+
const fieldCode = inputFieldNames[index];
|
|
2674
|
+
const fieldValue = this.inputDataFields[fieldCode];
|
|
2675
|
+
this.setFieldValue(fieldCode, fieldValue);
|
|
2706
2676
|
}
|
|
2707
|
-
const recordResponse = yield this.requestFormAction(
|
|
2677
|
+
const recordResponse = yield this.requestFormAction(formActions.getData);
|
|
2708
2678
|
this.checkErrorRecordReceived(recordResponse);
|
|
2709
2679
|
this.formVisible = true;
|
|
2710
2680
|
this.subscribeSectionActivation();
|
|
@@ -2724,7 +2694,7 @@ class BasicFormComponent {
|
|
|
2724
2694
|
this.errorDetail = recordResponse.errorDetail;
|
|
2725
2695
|
}
|
|
2726
2696
|
errorOccured() {
|
|
2727
|
-
return (this.errorCode !==
|
|
2697
|
+
return (this.errorCode !== '00');
|
|
2728
2698
|
}
|
|
2729
2699
|
changeState(state) { return this.formStructure.changeState(state); }
|
|
2730
2700
|
changeFormMode(state) { return this.changeState(state); }
|
|
@@ -3005,7 +2975,7 @@ class BasicFormComponent {
|
|
|
3005
2975
|
if (fieldObj.backend) {
|
|
3006
2976
|
fieldObj.validating = true;
|
|
3007
2977
|
validationResult = yield this
|
|
3008
|
-
.requestFormAction(
|
|
2978
|
+
.requestFormAction(formActions.validate, fieldObj.fieldCode);
|
|
3009
2979
|
finish = !this.errorOccured();
|
|
3010
2980
|
}
|
|
3011
2981
|
if (finish) {
|
|
@@ -3194,7 +3164,7 @@ class BasicFormComponent {
|
|
|
3194
3164
|
actionCode
|
|
3195
3165
|
};
|
|
3196
3166
|
actionResult = yield this
|
|
3197
|
-
.requestFormAction(
|
|
3167
|
+
.requestFormAction(formActions.tableAction, actionSubject);
|
|
3198
3168
|
finish = !this.errorOccured();
|
|
3199
3169
|
}
|
|
3200
3170
|
if (finish) {
|
|
@@ -3271,13 +3241,13 @@ class BasicFormComponent {
|
|
|
3271
3241
|
if (action.backend) {
|
|
3272
3242
|
const actionSubject = {
|
|
3273
3243
|
tableCode,
|
|
3274
|
-
actionType:
|
|
3244
|
+
actionType: this.formConfig.tableActions.inline,
|
|
3275
3245
|
actionCode,
|
|
3276
3246
|
tableRecordId: recordId,
|
|
3277
3247
|
tableRecordData: recordData
|
|
3278
3248
|
};
|
|
3279
3249
|
actionResult = yield this
|
|
3280
|
-
.requestFormAction(
|
|
3250
|
+
.requestFormAction(formActions.tableAction, actionSubject);
|
|
3281
3251
|
finish = !this.errorOccured();
|
|
3282
3252
|
}
|
|
3283
3253
|
if (finish) {
|
|
@@ -3350,13 +3320,13 @@ class BasicFormComponent {
|
|
|
3350
3320
|
if (tableObject.selectionBackend) {
|
|
3351
3321
|
const actionSubject = {
|
|
3352
3322
|
tableCode,
|
|
3353
|
-
actionType:
|
|
3323
|
+
actionType: this.formConfig.tableActions.rowSelection,
|
|
3354
3324
|
actionCode: null,
|
|
3355
3325
|
tableRecordId: recordId,
|
|
3356
3326
|
tableRecordData: recordData
|
|
3357
3327
|
};
|
|
3358
3328
|
actionResult = yield this
|
|
3359
|
-
.requestFormAction(
|
|
3329
|
+
.requestFormAction(formActions.tableAction, actionSubject);
|
|
3360
3330
|
finish = !this.errorOccured();
|
|
3361
3331
|
}
|
|
3362
3332
|
if (finish) {
|
|
@@ -3430,12 +3400,12 @@ class BasicFormComponent {
|
|
|
3430
3400
|
if (action.backend) {
|
|
3431
3401
|
const actionSubject = {
|
|
3432
3402
|
tableCode,
|
|
3433
|
-
actionType:
|
|
3403
|
+
actionType: this.formConfig.tableActions.selection,
|
|
3434
3404
|
actionCode,
|
|
3435
3405
|
selectedRecords
|
|
3436
3406
|
};
|
|
3437
3407
|
actionResult = yield this
|
|
3438
|
-
.requestFormAction(
|
|
3408
|
+
.requestFormAction(formActions.tableAction, actionSubject);
|
|
3439
3409
|
finish = !this.errorOccured();
|
|
3440
3410
|
}
|
|
3441
3411
|
if (finish) {
|
|
@@ -3493,7 +3463,7 @@ class BasicFormComponent {
|
|
|
3493
3463
|
tableObject.putOnWait();
|
|
3494
3464
|
const actionSubject = { tableCode };
|
|
3495
3465
|
const actionResult = yield this
|
|
3496
|
-
.requestFormAction(
|
|
3466
|
+
.requestFormAction(formActions.getTableData, actionSubject);
|
|
3497
3467
|
if (this.errorOccured()) {
|
|
3498
3468
|
this.displayTableServerError();
|
|
3499
3469
|
}
|
|
@@ -3519,7 +3489,7 @@ class BasicFormComponent {
|
|
|
3519
3489
|
}
|
|
3520
3490
|
checkSectionRequiredFields(sectionCode, reqFieldMessage) {
|
|
3521
3491
|
this.cleanErrorFields(null, sectionCode);
|
|
3522
|
-
const requiredFieldMessage = reqFieldMessage
|
|
3492
|
+
const requiredFieldMessage = reqFieldMessage !== null && reqFieldMessage !== void 0 ? reqFieldMessage : this.formConfig.formStandardErrors.requiredField;
|
|
3523
3493
|
const numErrors = this.tagFieldsWithError(this.getRequiredEmptyFields(null, sectionCode), null, requiredFieldMessage);
|
|
3524
3494
|
return (numErrors === 0);
|
|
3525
3495
|
}
|
|
@@ -3527,15 +3497,15 @@ class BasicFormComponent {
|
|
|
3527
3497
|
this.resetError();
|
|
3528
3498
|
const completeFields = this.checkSectionRequiredFields(sectionCode, reqFieldMessage);
|
|
3529
3499
|
if (!completeFields) {
|
|
3530
|
-
this.setError(
|
|
3500
|
+
this.setError(this.formConfig.formStandardErrors.typeWarning, this.formConfig.formStandardErrors.validationTitle, this.formConfig.formStandardErrors.requiredFields);
|
|
3531
3501
|
return;
|
|
3532
3502
|
}
|
|
3533
3503
|
let validationError = false;
|
|
3534
3504
|
const requiredEmptyFields = this.getRequiredEmptyFields(null, sectionCode);
|
|
3535
3505
|
if (requiredEmptyFields.length > 0) {
|
|
3536
3506
|
validationError = true;
|
|
3537
|
-
this.setError(
|
|
3538
|
-
this.tagFieldsWithError(requiredEmptyFields, null,
|
|
3507
|
+
this.setError(this.formConfig.formStandardErrors.typeWarning, this.formConfig.formStandardErrors.validationTitle, this.formConfig.formStandardErrors.requiredFields);
|
|
3508
|
+
this.tagFieldsWithError(requiredEmptyFields, null, this.formConfig.formStandardErrors.requiredField);
|
|
3539
3509
|
for (const fieldCode of requiredEmptyFields) {
|
|
3540
3510
|
const requiredEmptyField = this.getField(fieldCode);
|
|
3541
3511
|
if (requiredEmptyField && requiredEmptyField.widget
|
|
@@ -3548,7 +3518,7 @@ class BasicFormComponent {
|
|
|
3548
3518
|
const validationIssueFields = this.getFieldsWithValidationIssues(null, sectionCode);
|
|
3549
3519
|
if (!validationError && validationIssueFields.length > 0) {
|
|
3550
3520
|
validationError = true;
|
|
3551
|
-
this.setError(
|
|
3521
|
+
this.setError(this.formConfig.formStandardErrors.typeWarning, this.formConfig.formStandardErrors.validationTitle, this.formConfig.formStandardErrors.validationFields);
|
|
3552
3522
|
for (const fieldCode of validationIssueFields) {
|
|
3553
3523
|
const validationIssueField = this.getField(fieldCode);
|
|
3554
3524
|
if (validationIssueField && validationIssueField.widget
|
|
@@ -3664,13 +3634,13 @@ class BasicFormComponent {
|
|
|
3664
3634
|
const requiredEmptyFields = this.getRequiredEmptyFields(recordCaptureFields, null);
|
|
3665
3635
|
if (requiredEmptyFields.length > 0) {
|
|
3666
3636
|
validationOk = false;
|
|
3667
|
-
this.setError(
|
|
3668
|
-
this.tagFieldsWithError(requiredEmptyFields, null,
|
|
3637
|
+
this.setError(this.formConfig.formStandardErrors.typeWarning, this.formConfig.formStandardErrors.validationTitle, this.formConfig.formStandardErrors.requiredFields);
|
|
3638
|
+
this.tagFieldsWithError(requiredEmptyFields, null, this.formConfig.formStandardErrors.requiredField);
|
|
3669
3639
|
}
|
|
3670
3640
|
const validationIssueFields = this.getFieldsWithValidationIssues(recordCaptureFields, null);
|
|
3671
3641
|
if (validationIssueFields.length > 0) {
|
|
3672
3642
|
validationOk = false;
|
|
3673
|
-
this.setError(
|
|
3643
|
+
this.setError(this.formConfig.formStandardErrors.typeWarning, this.formConfig.formStandardErrors.validationTitle, this.formConfig.formStandardErrors.validationFields);
|
|
3674
3644
|
}
|
|
3675
3645
|
return validationOk;
|
|
3676
3646
|
}
|