tuain-ng-forms-lib 0.12.31 → 12.0.3
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 +721 -847
- 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 +52 -95
- package/esm2015/lib/classes/forms/form.constants.js +13 -82
- package/esm2015/lib/classes/forms/form.js +9 -10
- package/esm2015/lib/classes/forms/subsection.js +5 -5
- 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 +13 -31
- 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 +92 -90
- package/esm2015/lib/services/form-manager.service.js +60 -54
- package/fesm2015/tuain-ng-forms-lib.js +289 -403
- 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 +2 -1
- package/lib/classes/forms/field.d.ts +3 -1
- package/lib/classes/forms/form.constants.d.ts +12 -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 +1 -3
- 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,132 +51,22 @@ ActionComponent.propDecorators = {
|
|
|
49
51
|
showLabel: [{ type: Input }]
|
|
50
52
|
};
|
|
51
53
|
|
|
52
|
-
const componentConstants = {
|
|
53
|
-
recordsPerPage: 10,
|
|
54
|
-
// Constantes para el despliegue de formularios
|
|
55
|
-
ELEMENTTYPE_ACTION: 'ACTION',
|
|
56
|
-
ELEMENTTYPE_FIELD: 'FIELD',
|
|
57
|
-
ELEMENTTYPE_TABLE: 'TABLE',
|
|
58
|
-
// Acciones de formularios
|
|
59
|
-
FORMACTION_TABLEACTION: 'TABLEACTION',
|
|
60
|
-
FORMACTION_GETDATA: 'GETDATA',
|
|
61
|
-
FORMACTION_GETTABLEDATA: 'GETTABLEDATA',
|
|
62
|
-
FORMACTION_VALIDATE: 'VALIDATE',
|
|
63
|
-
// Errores etándar de formularios
|
|
64
|
-
FORMERROR_VALIDATION_CODE: '13',
|
|
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
|
-
]
|
|
144
|
-
};
|
|
145
|
-
|
|
146
|
-
const MONITORED_ATTRIBUTES$1 = {
|
|
147
|
-
_maxLength: 'maxLength',
|
|
148
|
-
_onValidation: '_onValidation',
|
|
149
|
-
_fieldValue: 'value',
|
|
150
|
-
captureType: 'captureType',
|
|
151
|
-
fieldTitle: 'fieldTitle',
|
|
152
|
-
fieldType: 'fieldType',
|
|
153
|
-
errorMessage: 'errorMessage',
|
|
154
|
-
errorType: 'errorType',
|
|
155
|
-
errorCode: 'errorCode',
|
|
156
|
-
visibleLabel: 'visibleLabel',
|
|
157
|
-
fieldRequired: 'fieldRequired',
|
|
158
|
-
fieldOptions: 'fieldOptions',
|
|
159
|
-
};
|
|
160
54
|
class FieldComponent {
|
|
161
|
-
constructor() {
|
|
162
|
-
this.componentConstants = Object.assign({}, componentConstants);
|
|
163
|
-
}
|
|
164
55
|
ngOnInit() {
|
|
56
|
+
var _a, _b;
|
|
165
57
|
if (this.fieldObject) {
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
58
|
+
this.formConfig = (_a = this.fieldObject) === null || _a === void 0 ? void 0 : _a._formConfig;
|
|
59
|
+
// Inicialización
|
|
60
|
+
const mapping = Object.entries(this.formConfig.componentFieldAttrMap);
|
|
61
|
+
for (let index = 0; index < mapping.length; index++) {
|
|
62
|
+
const [fieldAttr, compAttr] = mapping[index];
|
|
63
|
+
this[compAttr.toString()] = (_b = this.fieldObject) === null || _b === void 0 ? void 0 : _b[fieldAttr.toString()];
|
|
64
|
+
}
|
|
65
|
+
// Subscripción a cambios en atributos
|
|
173
66
|
this.fieldObject.attributeChange.subscribe(event => {
|
|
174
|
-
const { name, value } = event;
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
}
|
|
67
|
+
const { name: fieldAttr, value } = event;
|
|
68
|
+
const compAttr = this.formConfig.componentFieldAttrMap[fieldAttr];
|
|
69
|
+
this.hasOwnProperty(compAttr) && (this[compAttr] = value);
|
|
178
70
|
});
|
|
179
71
|
}
|
|
180
72
|
this.start();
|
|
@@ -201,17 +93,15 @@ FieldComponent.decorators = [
|
|
|
201
93
|
template: `<ng-content></ng-content>`
|
|
202
94
|
},] }
|
|
203
95
|
];
|
|
204
|
-
FieldComponent.ctorParameters = () => [];
|
|
205
96
|
FieldComponent.propDecorators = {
|
|
206
97
|
fieldObject: [{ type: Input }],
|
|
207
98
|
disabled: [{ type: Input }]
|
|
208
99
|
};
|
|
209
100
|
|
|
210
101
|
class ElementComponent {
|
|
211
|
-
constructor() {
|
|
212
|
-
this.componentConstants = Object.assign({}, componentConstants);
|
|
213
|
-
}
|
|
214
102
|
ngOnInit() {
|
|
103
|
+
var _a;
|
|
104
|
+
this.formConfig = (_a = this.formElement) === null || _a === void 0 ? void 0 : _a._formConfig;
|
|
215
105
|
this.start();
|
|
216
106
|
}
|
|
217
107
|
start() { }
|
|
@@ -232,7 +122,6 @@ ElementComponent.decorators = [
|
|
|
232
122
|
template: `<ng-content></ng-content>`
|
|
233
123
|
},] }
|
|
234
124
|
];
|
|
235
|
-
ElementComponent.ctorParameters = () => [];
|
|
236
125
|
ElementComponent.propDecorators = {
|
|
237
126
|
formElement: [{ type: Input }],
|
|
238
127
|
formManager: [{ type: Input }]
|
|
@@ -328,9 +217,35 @@ class Filter {
|
|
|
328
217
|
}
|
|
329
218
|
}
|
|
330
219
|
|
|
220
|
+
const NO_ERROR = '00';
|
|
221
|
+
const HEADER$1 = 'HEADER';
|
|
222
|
+
const elementTypes = {
|
|
223
|
+
action: 'ACTION',
|
|
224
|
+
field: 'FIELD',
|
|
225
|
+
table: 'TABLE',
|
|
226
|
+
};
|
|
227
|
+
const formActions = {
|
|
228
|
+
tableAction: 'TABLEACTION',
|
|
229
|
+
getData: 'GETDATA',
|
|
230
|
+
getTableData: 'GETTABLEDATA',
|
|
231
|
+
validate: 'VALIDATE',
|
|
232
|
+
};
|
|
233
|
+
const operators = {
|
|
234
|
+
G: '>',
|
|
235
|
+
L: '<',
|
|
236
|
+
GE: '>=',
|
|
237
|
+
LE: '<=',
|
|
238
|
+
EQ: '==',
|
|
239
|
+
NOT_EQ: '!=',
|
|
240
|
+
CONTENT: 'Contiene',
|
|
241
|
+
NOT_CONTENT: 'No Contiene',
|
|
242
|
+
BETWEEN: 'Entre',
|
|
243
|
+
};
|
|
244
|
+
|
|
331
245
|
class FormElement {
|
|
332
|
-
constructor(elementDefinition) {
|
|
246
|
+
constructor(elementDefinition, formConfig) {
|
|
333
247
|
var _a, _b;
|
|
248
|
+
this._formConfig = formConfig;
|
|
334
249
|
this._isForced = false;
|
|
335
250
|
this.setVisibleStates(elementDefinition.visibleStates);
|
|
336
251
|
this.setEnabledStates(elementDefinition.enabledStates);
|
|
@@ -339,9 +254,9 @@ class FormElement {
|
|
|
339
254
|
this.setVisibility((_b = elementDefinition === null || elementDefinition === void 0 ? void 0 : elementDefinition.visible) !== null && _b !== void 0 ? _b : true);
|
|
340
255
|
this.widget = null;
|
|
341
256
|
}
|
|
342
|
-
isField() { return this.elementType ===
|
|
343
|
-
isAction() { return this.elementType ===
|
|
344
|
-
isTable() { return this.elementType ===
|
|
257
|
+
isField() { return this.elementType === elementTypes.field; }
|
|
258
|
+
isAction() { return this.elementType === elementTypes.action; }
|
|
259
|
+
isTable() { return this.elementType === elementTypes.table; }
|
|
345
260
|
setVisibleStates(newStates) {
|
|
346
261
|
const visibleStates = (!Array.isArray(newStates) && typeof newStates === 'string')
|
|
347
262
|
? newStates.split(',').map(state => state.trim()).filter(state => state.length > 0)
|
|
@@ -387,13 +302,14 @@ class FormElement {
|
|
|
387
302
|
}
|
|
388
303
|
|
|
389
304
|
class RecordTableColumn {
|
|
390
|
-
constructor(recTableColReceived) {
|
|
305
|
+
constructor(recTableColReceived, formConfig) {
|
|
391
306
|
var _a, _b, _c;
|
|
307
|
+
this._formConfig = formConfig;
|
|
392
308
|
if (recTableColReceived) {
|
|
393
309
|
this.fieldCode = recTableColReceived.fieldCode;
|
|
394
310
|
this.fieldTitle = recTableColReceived.fieldTitle;
|
|
395
|
-
this.fieldType = recTableColReceived.fieldTypeCode ||
|
|
396
|
-
const defaultTypeAlignment = (tableFieldStyles[this.fieldType] != null) ? tableFieldStyles[this.fieldType]['text-align'] : 'left';
|
|
311
|
+
this.fieldType = recTableColReceived.fieldTypeCode || this._formConfig.fieldTypes.text;
|
|
312
|
+
const defaultTypeAlignment = (this._formConfig.tableFieldStyles[this.fieldType] != null) ? this._formConfig.tableFieldStyles[this.fieldType]['text-align'] : 'left';
|
|
397
313
|
this.fieldAlignment = (recTableColReceived.alignment != null) ? recTableColReceived.alignment.toLowerCase() : defaultTypeAlignment;
|
|
398
314
|
this.visible = (_a = recTableColReceived === null || recTableColReceived === void 0 ? void 0 : recTableColReceived.visible) !== null && _a !== void 0 ? _a : true;
|
|
399
315
|
this.sortable = (_b = recTableColReceived === null || recTableColReceived === void 0 ? void 0 : recTableColReceived.sortable) !== null && _b !== void 0 ? _b : false;
|
|
@@ -480,6 +396,8 @@ function formatCurrency(inputValue) {
|
|
|
480
396
|
return outputValue;
|
|
481
397
|
}
|
|
482
398
|
|
|
399
|
+
const DATE_TYPE = 'DATE';
|
|
400
|
+
const CURRENCY_TYPE = 'CURRENCY';
|
|
483
401
|
class TableRecordData {
|
|
484
402
|
constructor(recordReceived, recordDefinition, selectionFieldName = null) {
|
|
485
403
|
this.recordData = {};
|
|
@@ -514,10 +432,10 @@ class TableRecordData {
|
|
|
514
432
|
}
|
|
515
433
|
}
|
|
516
434
|
formatFieldValue(fieldType, fieldValue) {
|
|
517
|
-
if (fieldType ===
|
|
435
|
+
if (fieldType === CURRENCY_TYPE) {
|
|
518
436
|
return formatCurrency(fieldValue);
|
|
519
437
|
}
|
|
520
|
-
else if (fieldType ===
|
|
438
|
+
else if (fieldType === DATE_TYPE && fieldValue) {
|
|
521
439
|
return new Date(fieldValue).toISOString().split('T')[0];
|
|
522
440
|
}
|
|
523
441
|
return fieldValue || '';
|
|
@@ -601,6 +519,8 @@ class TableRecordData {
|
|
|
601
519
|
}
|
|
602
520
|
}
|
|
603
521
|
|
|
522
|
+
const TABLE_SORT_ASCENDING = 'asc';
|
|
523
|
+
const TABLE_SORT_DESCENDING = 'desc';
|
|
604
524
|
const TABLE_FILTER_TYPES = {
|
|
605
525
|
simpleFilterChange: 'SIMPLE_CHANGE',
|
|
606
526
|
simpleFilterFinish: 'SIMPLE_FINISH',
|
|
@@ -608,9 +528,9 @@ const TABLE_FILTER_TYPES = {
|
|
|
608
528
|
complexFilterRemove: 'COMPLEX_REMOVE',
|
|
609
529
|
};
|
|
610
530
|
class RecordTable extends FormElement {
|
|
611
|
-
constructor(tableReceived) {
|
|
531
|
+
constructor(tableReceived, formConfig) {
|
|
612
532
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
613
|
-
super(tableReceived);
|
|
533
|
+
super(tableReceived, formConfig);
|
|
614
534
|
this._inlineActionTrigger = new Subject();
|
|
615
535
|
this._globalActionTrigger = new Subject();
|
|
616
536
|
this._recordSelectionTrigger = new Subject();
|
|
@@ -620,7 +540,7 @@ class RecordTable extends FormElement {
|
|
|
620
540
|
this._tableColumnObj = {};
|
|
621
541
|
this._actionsObj = {};
|
|
622
542
|
this.allSelected = false;
|
|
623
|
-
this.elementType =
|
|
543
|
+
this.elementType = elementTypes.table;
|
|
624
544
|
this.waiting = false;
|
|
625
545
|
this.complexFilter = false;
|
|
626
546
|
this.currentPage = 1;
|
|
@@ -643,10 +563,10 @@ class RecordTable extends FormElement {
|
|
|
643
563
|
this.customAttributes = (_f = tableReceived === null || tableReceived === void 0 ? void 0 : tableReceived.customAttributes) !== null && _f !== void 0 ? _f : {};
|
|
644
564
|
this.sortable = (_g = tableReceived === null || tableReceived === void 0 ? void 0 : tableReceived.sortable) !== null && _g !== void 0 ? _g : false;
|
|
645
565
|
this.sorting = { columnName: '', direction: '' };
|
|
646
|
-
this.recordsPerPage =
|
|
566
|
+
this.recordsPerPage = formConfig.defaultRecordsPerPage;
|
|
647
567
|
if (tableReceived.fields) {
|
|
648
568
|
for (const columnReceived of tableReceived.fields) {
|
|
649
|
-
const columnDefinition = new RecordTableColumn(columnReceived);
|
|
569
|
+
const columnDefinition = new RecordTableColumn(columnReceived, this._formConfig);
|
|
650
570
|
this.columns.push(columnDefinition);
|
|
651
571
|
this._tableColumnObj[columnDefinition.fieldCode] = columnDefinition;
|
|
652
572
|
}
|
|
@@ -823,7 +743,7 @@ class RecordTable extends FormElement {
|
|
|
823
743
|
return (this._actionsObj && actionCode && this._actionsObj[actionCode])
|
|
824
744
|
? this._actionsObj[actionCode] : null;
|
|
825
745
|
}
|
|
826
|
-
getActions(actionClass =
|
|
746
|
+
getActions(actionClass = this._formConfig.tableActions.inline, actionTypes = null) {
|
|
827
747
|
return this._actions.filter(actionDef => {
|
|
828
748
|
const typeIncluded = (actionTypes) ? actionTypes.includes(actionDef.actionType) : true;
|
|
829
749
|
return actionDef.actionClass === actionClass && typeIncluded;
|
|
@@ -884,14 +804,14 @@ class RecordTable extends FormElement {
|
|
|
884
804
|
setRequiredOrder(columnField) {
|
|
885
805
|
if (columnField !== this.sorting.columnName) {
|
|
886
806
|
this.sorting.columnName = columnField;
|
|
887
|
-
this.sorting.direction =
|
|
807
|
+
this.sorting.direction = TABLE_SORT_ASCENDING;
|
|
888
808
|
}
|
|
889
809
|
else {
|
|
890
|
-
if (this.sorting.direction ===
|
|
891
|
-
this.sorting.direction =
|
|
810
|
+
if (this.sorting.direction === TABLE_SORT_ASCENDING) {
|
|
811
|
+
this.sorting.direction = TABLE_SORT_DESCENDING;
|
|
892
812
|
}
|
|
893
813
|
else {
|
|
894
|
-
this.sorting.direction =
|
|
814
|
+
this.sorting.direction = TABLE_SORT_ASCENDING;
|
|
895
815
|
}
|
|
896
816
|
}
|
|
897
817
|
}
|
|
@@ -912,7 +832,7 @@ class RecordTable extends FormElement {
|
|
|
912
832
|
else if (recordAColumn > recordBColumn) {
|
|
913
833
|
result = 1;
|
|
914
834
|
}
|
|
915
|
-
return direction ===
|
|
835
|
+
return direction === TABLE_SORT_ASCENDING ? result : -result;
|
|
916
836
|
}
|
|
917
837
|
}
|
|
918
838
|
|
|
@@ -1068,13 +988,15 @@ class LibTableComponent {
|
|
|
1068
988
|
this.hasActions = false;
|
|
1069
989
|
}
|
|
1070
990
|
ngOnInit() {
|
|
1071
|
-
|
|
991
|
+
var _a;
|
|
992
|
+
this.formConfig = (_a = this.tableObject) === null || _a === void 0 ? void 0 : _a._formConfig;
|
|
993
|
+
this.tableFieldStyles = this.formConfig.tableFieldStyles;
|
|
1072
994
|
this.selectable = this.tableObject.selectable;
|
|
1073
995
|
this.hasActions = this.tableObject.hasActions;
|
|
1074
996
|
this.tableObject.widget = this;
|
|
1075
|
-
this.inlineActions = this.tableObject.getActions(
|
|
1076
|
-
this.globalActions = this.tableObject.getActions(
|
|
1077
|
-
this.selectionActions = this.tableObject.getActions(
|
|
997
|
+
this.inlineActions = this.tableObject.getActions(this.formConfig.tableActions.inline);
|
|
998
|
+
this.globalActions = this.tableObject.getActions(this.formConfig.tableActions.global);
|
|
999
|
+
this.selectionActions = this.tableObject.getActions(this.formConfig.tableActions.selection);
|
|
1078
1000
|
this.start();
|
|
1079
1001
|
}
|
|
1080
1002
|
start() { }
|
|
@@ -1184,15 +1106,15 @@ class RecordFormSubSection {
|
|
|
1184
1106
|
let arrayToAdd = null;
|
|
1185
1107
|
const { type, code } = receivedElement;
|
|
1186
1108
|
switch (type) {
|
|
1187
|
-
case
|
|
1109
|
+
case elementTypes.field:
|
|
1188
1110
|
elementObject = formObject.getFieldObject(code);
|
|
1189
1111
|
arrayToAdd = this.subSectionFields;
|
|
1190
1112
|
break;
|
|
1191
|
-
case
|
|
1113
|
+
case elementTypes.table:
|
|
1192
1114
|
elementObject = formObject.getTableObject(code);
|
|
1193
1115
|
arrayToAdd = this.subSectionTables;
|
|
1194
1116
|
break;
|
|
1195
|
-
case
|
|
1117
|
+
case elementTypes.action:
|
|
1196
1118
|
elementObject = formObject.getActionObject(code);
|
|
1197
1119
|
arrayToAdd = this.subSectionActions;
|
|
1198
1120
|
break;
|
|
@@ -1328,18 +1250,18 @@ class RecordFormSection {
|
|
|
1328
1250
|
supportMode(state) { return this.viewOnState(state); }
|
|
1329
1251
|
}
|
|
1330
1252
|
|
|
1331
|
-
const HEADER
|
|
1253
|
+
const HEADER = 'HEADER';
|
|
1332
1254
|
class FormAction extends FormElement {
|
|
1333
|
-
constructor(actionDefinition) {
|
|
1255
|
+
constructor(actionDefinition, formConfig) {
|
|
1334
1256
|
var _a, _b;
|
|
1335
|
-
super(actionDefinition);
|
|
1257
|
+
super(actionDefinition, formConfig);
|
|
1336
1258
|
this._actionActivated = new Subject();
|
|
1337
1259
|
this.inProgress = false;
|
|
1338
|
-
this.elementType =
|
|
1260
|
+
this.elementType = elementTypes.action;
|
|
1339
1261
|
this.actionCode = actionDefinition.actionCode ? actionDefinition.actionCode.toString() : '';
|
|
1340
1262
|
this.actionName = actionDefinition.actionTitle;
|
|
1341
1263
|
this.iconName = actionDefinition.iconName || this.actionCode;
|
|
1342
|
-
this.location = actionDefinition.position || HEADER
|
|
1264
|
+
this.location = actionDefinition.position || HEADER;
|
|
1343
1265
|
this.backend = (_a = actionDefinition === null || actionDefinition === void 0 ? void 0 : actionDefinition.serverAction) !== null && _a !== void 0 ? _a : false;
|
|
1344
1266
|
this.newState = actionDefinition === null || actionDefinition === void 0 ? void 0 : actionDefinition.newState;
|
|
1345
1267
|
this.customAttributes = (_b = actionDefinition === null || actionDefinition === void 0 ? void 0 : actionDefinition.customAttributes) !== null && _b !== void 0 ? _b : null;
|
|
@@ -1363,58 +1285,9 @@ class FormAction extends FormElement {
|
|
|
1363
1285
|
}
|
|
1364
1286
|
|
|
1365
1287
|
const UNDEFINED = 'undefined';
|
|
1366
|
-
const FIELD_VALUE = 'fieldValue';
|
|
1367
|
-
const FIELD_OPTIONS = 'fieldOptions';
|
|
1368
|
-
const FIELD_TITLE = 'fieldTitle';
|
|
1369
|
-
const FIELD_CAPTURE_TYPE = 'captureType';
|
|
1370
|
-
const FIELD_TYPE = 'fieldTypeCode';
|
|
1371
|
-
const FIELD_MAX_LENGTH = 'maxLength';
|
|
1372
|
-
const FIELD_VISIBLE = 'visible';
|
|
1373
|
-
const FIELD_LABEL_VISIBLE = 'visibleLabel';
|
|
1374
|
-
const FIELD_REQUIRED = 'required';
|
|
1375
|
-
const FIELD_ERR_CODE = 'errorCode';
|
|
1376
|
-
const FIELD_ERR_MSG = 'errorMessage';
|
|
1377
|
-
const FIELD_TOOLTIP = 'tooltipText';
|
|
1378
|
-
const FIELD_INFO = 'info';
|
|
1379
|
-
const FIELD_EDITABLE = 'editable';
|
|
1380
|
-
const FIELD_TYPES = {
|
|
1381
|
-
boolean: 'BOOLEAN',
|
|
1382
|
-
array: 'ARRAY',
|
|
1383
|
-
check: 'CHECK',
|
|
1384
|
-
date: 'DATE',
|
|
1385
|
-
daterange: 'DATERANGE',
|
|
1386
|
-
time: 'TIME',
|
|
1387
|
-
timerange: 'TIMERANGE',
|
|
1388
|
-
map: 'MAP',
|
|
1389
|
-
number: 'NUMBER',
|
|
1390
|
-
decimal: 'DECIMAL',
|
|
1391
|
-
currency: 'CURRENCY',
|
|
1392
|
-
select: 'SELECT',
|
|
1393
|
-
typeahead: 'TYPEAHEAD',
|
|
1394
|
-
text: 'TEXT',
|
|
1395
|
-
password: 'PASSWORD',
|
|
1396
|
-
label: 'LABEL',
|
|
1397
|
-
html: 'HTML',
|
|
1398
|
-
title: 'TITLE',
|
|
1399
|
-
message: 'MESSAGE',
|
|
1400
|
-
link: 'LINK',
|
|
1401
|
-
warning: 'WARNING',
|
|
1402
|
-
avatar: 'AVATAR',
|
|
1403
|
-
email: 'EMAIL',
|
|
1404
|
-
phone: 'PHONE',
|
|
1405
|
-
};
|
|
1406
|
-
const FIELD_TYPES_FORMATS = {
|
|
1407
|
-
EMAIL: new RegExp('^\\w+([\\.-]?\\w+)@\\w+([\\.-]?\\w+)(\\.\\w{2,3})+$'),
|
|
1408
|
-
};
|
|
1409
|
-
const INTRINSIC_ERROR_MESSAGES = {
|
|
1410
|
-
EMAIL: `El valor no corresponde a un correo válido`,
|
|
1411
|
-
DEFAULT: `El valor no se ajusta al formato establecido`,
|
|
1412
|
-
};
|
|
1413
1288
|
const DEFAULT_ERROR_TYPE = 'error';
|
|
1414
1289
|
const DEFAULT_CAPTURE_TYPE = 'INPUT';
|
|
1415
1290
|
const DEFAULT_ALIGNMENT = 'left';
|
|
1416
|
-
const MONITORED_ATTRIBUTES = ['_maxLength', '_onValidation', 'captureType', 'fieldTitle', 'fieldType',
|
|
1417
|
-
'errorMessage', 'errorType', 'errorCode', 'visibleLabel', 'fieldRequired', 'fieldOptions', '_fieldValue'];
|
|
1418
1291
|
const STD_MAX_LENGTH = 50;
|
|
1419
1292
|
const BIG_MAX_LENGTH = 500;
|
|
1420
1293
|
const fldAttr = {
|
|
@@ -1447,21 +1320,21 @@ const fldAttr = {
|
|
|
1447
1320
|
options: 'fieldOptions',
|
|
1448
1321
|
};
|
|
1449
1322
|
class FieldDescriptor extends FormElement {
|
|
1450
|
-
constructor(inputFieldReceived) {
|
|
1323
|
+
constructor(inputFieldReceived, formConfig) {
|
|
1451
1324
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
1452
|
-
super(inputFieldReceived);
|
|
1325
|
+
super(inputFieldReceived, formConfig);
|
|
1453
1326
|
this._editionFinish = new Subject();
|
|
1454
1327
|
this._editionPartial = new Subject();
|
|
1455
1328
|
this._detailRequest = new Subject();
|
|
1456
1329
|
this._attributeChange = new Subject();
|
|
1457
|
-
this.elementType =
|
|
1330
|
+
this.elementType = elementTypes.field;
|
|
1458
1331
|
const fld = (inputFieldReceived) ? inputFieldReceived : {};
|
|
1459
1332
|
this.setAttr(fldAttr.code, fld.fieldCode);
|
|
1460
1333
|
this.setAttr(fldAttr.title, (_a = fld.fieldTitle) !== null && _a !== void 0 ? _a : this.fieldCode);
|
|
1461
1334
|
this.setAttr(fldAttr.captureType, (_b = fld.captureType) !== null && _b !== void 0 ? _b : DEFAULT_CAPTURE_TYPE);
|
|
1462
1335
|
this.setAttr(fldAttr.defaultValue, (_c = fld.defaultValue) !== null && _c !== void 0 ? _c : null);
|
|
1463
|
-
const defaultTypeAlignment = (tableFieldStyles[this.fieldType] != null)
|
|
1464
|
-
? tableFieldStyles[this.fieldType]['text-align'] : DEFAULT_ALIGNMENT;
|
|
1336
|
+
const defaultTypeAlignment = (this._formConfig.tableFieldStyles[this.fieldType] != null)
|
|
1337
|
+
? this._formConfig.tableFieldStyles[this.fieldType]['text-align'] : DEFAULT_ALIGNMENT;
|
|
1465
1338
|
const fieldAlignment = (fld.alignment != null) ? fld.alignment.toLowerCase() : defaultTypeAlignment;
|
|
1466
1339
|
this.setAttr(fldAttr.alignment, fieldAlignment);
|
|
1467
1340
|
this.setAttr(fldAttr.info, fld.info || '');
|
|
@@ -1482,7 +1355,7 @@ class FieldDescriptor extends FormElement {
|
|
|
1482
1355
|
this.setAttr(fldAttr.outputOnly, (_h = fld.outputOnly) !== null && _h !== void 0 ? _h : false);
|
|
1483
1356
|
const maxLength = (_j = fld.maxLength) !== null && _j !== void 0 ? _j : (this.captureType === 'TEXTAREA' ? BIG_MAX_LENGTH : STD_MAX_LENGTH);
|
|
1484
1357
|
this.setAttr(fldAttr.maxLength, maxLength);
|
|
1485
|
-
this.setAttr(fldAttr.intrinsicErrorMessage, (_k =
|
|
1358
|
+
this.setAttr(fldAttr.intrinsicErrorMessage, (_k = this._formConfig.fieldTypeErrMsg[this.fieldType]) !== null && _k !== void 0 ? _k : this._formConfig.fieldTypeErrMsg.DEFAULT);
|
|
1486
1359
|
this.setFieldType(fld.fieldTypeCode);
|
|
1487
1360
|
this.setEditable((_l = fld.editable) !== null && _l !== void 0 ? _l : true);
|
|
1488
1361
|
this.setVisibleLabel((_m = fld.visibleLabel) !== null && _m !== void 0 ? _m : true);
|
|
@@ -1518,13 +1391,13 @@ class FieldDescriptor extends FormElement {
|
|
|
1518
1391
|
this._editionPartial.next({ code: this.fieldCode, intrinsicValidation });
|
|
1519
1392
|
}
|
|
1520
1393
|
notifyEditionFinish() {
|
|
1521
|
-
var _a, _b, _c, _d;
|
|
1394
|
+
var _a, _b, _c, _d, _e;
|
|
1522
1395
|
let intrinsicValidation = true;
|
|
1523
|
-
const fieldDefaultFormat = (_a =
|
|
1396
|
+
const fieldDefaultFormat = (_b = (_a = this._formConfig.fieldTypesPatterns) === null || _a === void 0 ? void 0 : _a[this.fieldType]) !== null && _b !== void 0 ? _b : null;
|
|
1524
1397
|
const fieldValue = this.getValue();
|
|
1525
1398
|
if (fieldValue && (fieldDefaultFormat || this.fieldFormat)) {
|
|
1526
|
-
intrinsicValidation = ((
|
|
1527
|
-
&& ((
|
|
1399
|
+
intrinsicValidation = ((_c = fieldDefaultFormat === null || fieldDefaultFormat === void 0 ? void 0 : fieldDefaultFormat.test(fieldValue)) !== null && _c !== void 0 ? _c : true)
|
|
1400
|
+
&& ((_e = (_d = this.fieldFormat) === null || _d === void 0 ? void 0 : _d.test(fieldValue)) !== null && _e !== void 0 ? _e : true);
|
|
1528
1401
|
if (!intrinsicValidation) {
|
|
1529
1402
|
this.setError('99', this._intrinsicErrorMessage);
|
|
1530
1403
|
}
|
|
@@ -1532,16 +1405,15 @@ class FieldDescriptor extends FormElement {
|
|
|
1532
1405
|
this._editionFinish.next({ code: this.fieldCode, intrinsicValidation });
|
|
1533
1406
|
}
|
|
1534
1407
|
setAttr(name, value) {
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
}
|
|
1538
|
-
if (MONITORED_ATTRIBUTES.includes(name)) {
|
|
1408
|
+
this[name] = value;
|
|
1409
|
+
if (this._formConfig.monitoredFieldAttributes.includes(name)) {
|
|
1539
1410
|
this._attributeChange.next({ name, value });
|
|
1540
1411
|
}
|
|
1541
1412
|
}
|
|
1542
1413
|
notifyEditionDetailRequest() {
|
|
1543
1414
|
this._detailRequest.next(this.fieldCode);
|
|
1544
1415
|
}
|
|
1416
|
+
getCustomAttribute(name) { var _a, _b; return (_b = (_a = this.customAttributes) === null || _a === void 0 ? void 0 : _a[name]) !== null && _b !== void 0 ? _b : null; }
|
|
1545
1417
|
setVisibleLabel(visibleLabel) { this.setAttr(fldAttr.visibleLabel, visibleLabel); }
|
|
1546
1418
|
showLabel() { this.setVisibleLabel(true); }
|
|
1547
1419
|
hideLabel() { this.setVisibleLabel(false); }
|
|
@@ -1552,10 +1424,11 @@ class FieldDescriptor extends FormElement {
|
|
|
1552
1424
|
clean() { this.setValue(this.defaultValue || ''); }
|
|
1553
1425
|
get backend() { return this.validateOnServer; }
|
|
1554
1426
|
setEditable(editable = true) { (editable) ? this.enable() : this.disable(); }
|
|
1555
|
-
hasError() { return this.errorCode !==
|
|
1427
|
+
hasError() { return this.errorCode !== NO_ERROR; }
|
|
1428
|
+
resetError() { (this.errorCode !== NO_ERROR) && this.setError(NO_ERROR, null); }
|
|
1556
1429
|
setError(code, message, type = DEFAULT_ERROR_TYPE) {
|
|
1557
|
-
this.setAttr(fldAttr.errorCode, code !== null && code !== void 0 ? code :
|
|
1558
|
-
this.setAttr(fldAttr.errorType, (this.errorCode ===
|
|
1430
|
+
this.setAttr(fldAttr.errorCode, code !== null && code !== void 0 ? code : NO_ERROR);
|
|
1431
|
+
this.setAttr(fldAttr.errorType, (this.errorCode === NO_ERROR) ? '' : type);
|
|
1559
1432
|
this.setAttr(fldAttr.errorMessage, message !== null && message !== void 0 ? message : '');
|
|
1560
1433
|
}
|
|
1561
1434
|
getError() { return { type: this.errorType, code: this.errorCode, message: this.errorMessage }; }
|
|
@@ -1570,7 +1443,7 @@ class FieldDescriptor extends FormElement {
|
|
|
1570
1443
|
if (fieldCurrentValue === undefined || fieldCurrentValue === null) {
|
|
1571
1444
|
return true;
|
|
1572
1445
|
}
|
|
1573
|
-
if ((this.fieldType ===
|
|
1446
|
+
if ((this.fieldType === this._formConfig.fieldTypes.array || this.fieldType === this._formConfig.fieldTypes.phone)
|
|
1574
1447
|
&& Array.isArray(fieldCurrentValue) && fieldCurrentValue.length === 0) {
|
|
1575
1448
|
return true;
|
|
1576
1449
|
}
|
|
@@ -1578,12 +1451,15 @@ class FieldDescriptor extends FormElement {
|
|
|
1578
1451
|
return fieldCurrentValue === '';
|
|
1579
1452
|
}
|
|
1580
1453
|
getValue() {
|
|
1581
|
-
var _a;
|
|
1454
|
+
var _a, _b;
|
|
1582
1455
|
switch (this.fieldType) {
|
|
1583
|
-
case
|
|
1456
|
+
case this._formConfig.fieldTypes.boolean:
|
|
1584
1457
|
return (_a = this._fieldValue) !== null && _a !== void 0 ? _a : false;
|
|
1585
1458
|
break;
|
|
1586
|
-
case
|
|
1459
|
+
case this._formConfig.fieldTypes.check:
|
|
1460
|
+
return (_b = this._fieldValue) !== null && _b !== void 0 ? _b : false;
|
|
1461
|
+
break;
|
|
1462
|
+
case this._formConfig.fieldTypes.currency:
|
|
1587
1463
|
return this._fieldValue.replace(',', '');
|
|
1588
1464
|
break;
|
|
1589
1465
|
default:
|
|
@@ -1597,33 +1473,33 @@ class FieldDescriptor extends FormElement {
|
|
|
1597
1473
|
for (let index = 0; index < fieldKeys.length; index++) {
|
|
1598
1474
|
const attrName = fieldKeys[index];
|
|
1599
1475
|
const attrValue = fld[attrName];
|
|
1600
|
-
(attrName ===
|
|
1601
|
-
(attrName ===
|
|
1602
|
-
(attrName ===
|
|
1603
|
-
(attrName ===
|
|
1604
|
-
(attrName ===
|
|
1605
|
-
(attrName ===
|
|
1606
|
-
(attrName ===
|
|
1607
|
-
(attrName ===
|
|
1608
|
-
(attrName ===
|
|
1609
|
-
(attrName ===
|
|
1610
|
-
(attrName ===
|
|
1611
|
-
(attrName ===
|
|
1612
|
-
(attrName ===
|
|
1613
|
-
(attrName ===
|
|
1476
|
+
(attrName === this._formConfig.apifieldattrs.visible) && this.setVisibility(attrValue);
|
|
1477
|
+
(attrName === this._formConfig.apifieldattrs.labelVisible) && this.setVisibleLabel(fld.visibleLabel);
|
|
1478
|
+
(attrName === this._formConfig.apifieldattrs.required) && this.setAttr(fldAttr.required, (_a = fld.required) !== null && _a !== void 0 ? _a : false);
|
|
1479
|
+
(attrName === this._formConfig.apifieldattrs.errorCode) && this.setAttr(fldAttr.errorCode, fld.errorCode);
|
|
1480
|
+
(attrName === this._formConfig.apifieldattrs.errorMessage) && this.setAttr(fldAttr.errorMessage, fld.errorMessage);
|
|
1481
|
+
(attrName === this._formConfig.apifieldattrs.tooltip) && this.setAttr(fldAttr.tooltipText, fld.tooltip);
|
|
1482
|
+
(attrName === this._formConfig.apifieldattrs.info) && this.setAttr(fldAttr.info, fld.info);
|
|
1483
|
+
(attrName === this._formConfig.apifieldattrs.editable) && this.setEditable(fld.editable);
|
|
1484
|
+
(attrName === this._formConfig.apifieldattrs.title) && this.setLabel(fld.fieldTitle.toString());
|
|
1485
|
+
(attrName === this._formConfig.apifieldattrs.value) && (this.setValue(fld._fieldValue) && this.setChanged(false));
|
|
1486
|
+
(attrName === this._formConfig.apifieldattrs.options) && this.setFieldOptions(fld.fieldOptions);
|
|
1487
|
+
(attrName === this._formConfig.apifieldattrs.captureType) && this.setAttr(fldAttr.captureType, fld.captureType || 'INPUT');
|
|
1488
|
+
(attrName === this._formConfig.apifieldattrs.type) && this.setFieldType(fld.fieldTypeCode);
|
|
1489
|
+
(attrName === this._formConfig.apifieldattrs.maxLength) && this.setAttr(fldAttr.maxLength, fld.maxLength);
|
|
1614
1490
|
}
|
|
1615
1491
|
}
|
|
1616
1492
|
setFieldType(inputFieldType) {
|
|
1617
1493
|
this.setAttr(fldAttr.type, inputFieldType);
|
|
1618
1494
|
}
|
|
1619
1495
|
format() {
|
|
1620
|
-
if (this.fieldType ===
|
|
1496
|
+
if (this.fieldType === this._formConfig.fieldTypes.currency) {
|
|
1621
1497
|
this.setAttr(fldAttr.value, formatCurrency(this._fieldValue));
|
|
1622
1498
|
}
|
|
1623
1499
|
}
|
|
1624
1500
|
setMinValue(minValue) {
|
|
1625
1501
|
var _a, _b, _c;
|
|
1626
|
-
if (this.fieldType ===
|
|
1502
|
+
if (this.fieldType === this._formConfig.fieldTypes.date
|
|
1627
1503
|
&& ((_a = this.widget) === null || _a === void 0 ? void 0 : _a.setMinValue)) {
|
|
1628
1504
|
this.setAttr(fldAttr.minValue, minValue);
|
|
1629
1505
|
if (!minValue) {
|
|
@@ -1637,7 +1513,7 @@ class FieldDescriptor extends FormElement {
|
|
|
1637
1513
|
}
|
|
1638
1514
|
setMaxValue(maxValue) {
|
|
1639
1515
|
var _a, _b, _c;
|
|
1640
|
-
if (this.fieldType ===
|
|
1516
|
+
if (this.fieldType === this._formConfig.fieldTypes.date
|
|
1641
1517
|
&& ((_a = this.widget) === null || _a === void 0 ? void 0 : _a.setMaxValue)) {
|
|
1642
1518
|
this.setAttr(fldAttr.maxValue, maxValue);
|
|
1643
1519
|
if (!maxValue) {
|
|
@@ -1669,11 +1545,11 @@ class FieldDescriptor extends FormElement {
|
|
|
1669
1545
|
fieldOptions = (fieldOptions && Array.isArray(fieldOptions)
|
|
1670
1546
|
&& fieldOptions.length > 0) ? fieldOptions : [];
|
|
1671
1547
|
this.setAttr(fldAttr.options, fieldOptions);
|
|
1672
|
-
if (this.fieldType ===
|
|
1548
|
+
if (this.fieldType === this._formConfig.fieldTypes.array && this.widget) {
|
|
1673
1549
|
return (_a = this.widget) === null || _a === void 0 ? void 0 : _a.refereshContent();
|
|
1674
1550
|
}
|
|
1675
1551
|
if (this._fieldValue) {
|
|
1676
|
-
if (this.fieldType ===
|
|
1552
|
+
if (this.fieldType === this._formConfig.fieldTypes.array && Array.isArray(this._fieldValue)) {
|
|
1677
1553
|
const fieldValue = (_b = this._fieldValue) === null || _b === void 0 ? void 0 : _b.filter(item => this.fieldOptions.find(opt => opt.fieldOptionId === item));
|
|
1678
1554
|
this.setAttr(fldAttr.value, fieldValue);
|
|
1679
1555
|
}
|
|
@@ -1702,10 +1578,13 @@ class FieldDescriptor extends FormElement {
|
|
|
1702
1578
|
case 'BOOLEAN':
|
|
1703
1579
|
newFinalValue = !!newValue;
|
|
1704
1580
|
break;
|
|
1705
|
-
case
|
|
1581
|
+
case this._formConfig.fieldTypes.boolean:
|
|
1706
1582
|
newFinalValue = !!newValue;
|
|
1707
1583
|
break;
|
|
1708
|
-
case
|
|
1584
|
+
case this._formConfig.fieldTypes.check:
|
|
1585
|
+
newFinalValue = !!newValue;
|
|
1586
|
+
break;
|
|
1587
|
+
case this._formConfig.fieldTypes.array:
|
|
1709
1588
|
if (newValue === null || newValue === '') {
|
|
1710
1589
|
newFinalValue = [];
|
|
1711
1590
|
}
|
|
@@ -1719,7 +1598,7 @@ class FieldDescriptor extends FormElement {
|
|
|
1719
1598
|
newFinalValue = newValue;
|
|
1720
1599
|
}
|
|
1721
1600
|
break;
|
|
1722
|
-
case
|
|
1601
|
+
case this._formConfig.fieldTypes.map:
|
|
1723
1602
|
newFinalValue = newValue;
|
|
1724
1603
|
if (newFinalValue && this.widget && widgetUpdate) {
|
|
1725
1604
|
const latitude = parseFloat(newFinalValue[0]);
|
|
@@ -1727,7 +1606,7 @@ class FieldDescriptor extends FormElement {
|
|
|
1727
1606
|
(_a = this.widget) === null || _a === void 0 ? void 0 : _a.setLocation(latitude, longitude);
|
|
1728
1607
|
}
|
|
1729
1608
|
break;
|
|
1730
|
-
case
|
|
1609
|
+
case this._formConfig.fieldTypes.currency:
|
|
1731
1610
|
newFinalValue = formatCurrency(this._fieldValue);
|
|
1732
1611
|
break;
|
|
1733
1612
|
default:
|
|
@@ -1742,16 +1621,15 @@ class FieldDescriptor extends FormElement {
|
|
|
1742
1621
|
}
|
|
1743
1622
|
}
|
|
1744
1623
|
|
|
1745
|
-
const HEADER = 'HEADER';
|
|
1746
|
-
const NO_ERROR = '00';
|
|
1747
1624
|
class FormStructureAndData {
|
|
1748
|
-
constructor(definitionReceived) {
|
|
1625
|
+
constructor(definitionReceived, formConfig) {
|
|
1749
1626
|
this._fieldsObj = {};
|
|
1750
1627
|
this._actionsObj = {};
|
|
1751
1628
|
this._tableObj = {};
|
|
1752
1629
|
this._sectionsObj = {};
|
|
1753
1630
|
this._immutableData = {};
|
|
1754
1631
|
this._extraInfo = {};
|
|
1632
|
+
this._formConfig = formConfig;
|
|
1755
1633
|
this.state = '';
|
|
1756
1634
|
this._actions = [];
|
|
1757
1635
|
this._fields = [];
|
|
@@ -1785,7 +1663,7 @@ class FormStructureAndData {
|
|
|
1785
1663
|
return Object.assign(Object.assign({}, objDef), { visibleStates, enabledStates });
|
|
1786
1664
|
});
|
|
1787
1665
|
for (const actionReceived of formActions) {
|
|
1788
|
-
const globalAction = new FormAction(actionReceived);
|
|
1666
|
+
const globalAction = new FormAction(actionReceived, this._formConfig);
|
|
1789
1667
|
const globalActionCode = globalAction.actionCode;
|
|
1790
1668
|
if (globalActionCode) {
|
|
1791
1669
|
this._actions.push(globalAction);
|
|
@@ -1806,7 +1684,7 @@ class FormStructureAndData {
|
|
|
1806
1684
|
return Object.assign(Object.assign({}, objDef), { visibleStates, enabledStates });
|
|
1807
1685
|
});
|
|
1808
1686
|
for (const fieldReceived of formFields) {
|
|
1809
|
-
const fieldToAdd = new FieldDescriptor(fieldReceived);
|
|
1687
|
+
const fieldToAdd = new FieldDescriptor(fieldReceived, this._formConfig);
|
|
1810
1688
|
const fieldCode = fieldToAdd.fieldCode;
|
|
1811
1689
|
if (fieldCode) {
|
|
1812
1690
|
this._fields.push(fieldToAdd);
|
|
@@ -1825,12 +1703,12 @@ class FormStructureAndData {
|
|
|
1825
1703
|
enabledStates = [...visibleStates];
|
|
1826
1704
|
}
|
|
1827
1705
|
if (!visibleStates || visibleStates.length === 0) {
|
|
1828
|
-
visibleStates =
|
|
1706
|
+
visibleStates = this._formConfig.defaultStateFlow.states;
|
|
1829
1707
|
}
|
|
1830
1708
|
return Object.assign(Object.assign({}, objDef), { visibleStates, enabledStates });
|
|
1831
1709
|
});
|
|
1832
1710
|
for (const tableReceived of tables) {
|
|
1833
|
-
const tableToAdd = new RecordTable(tableReceived);
|
|
1711
|
+
const tableToAdd = new RecordTable(tableReceived, this._formConfig);
|
|
1834
1712
|
const tableCode = tableToAdd.tableCode;
|
|
1835
1713
|
if (tableCode) {
|
|
1836
1714
|
this._tables.push(tableToAdd);
|
|
@@ -1882,7 +1760,7 @@ class FormStructureAndData {
|
|
|
1882
1760
|
}
|
|
1883
1761
|
setStateFlow(states, transitions, defaultState) {
|
|
1884
1762
|
if (!states || !transitions) {
|
|
1885
|
-
this._stateFlow = JSON.parse(JSON.stringify(
|
|
1763
|
+
this._stateFlow = JSON.parse(JSON.stringify(this._formConfig.defaultStateFlow));
|
|
1886
1764
|
return;
|
|
1887
1765
|
}
|
|
1888
1766
|
this._stateFlow.states = states;
|
|
@@ -1927,7 +1805,7 @@ class FormStructureAndData {
|
|
|
1927
1805
|
return this._actions;
|
|
1928
1806
|
}
|
|
1929
1807
|
getHeaderActions() {
|
|
1930
|
-
return this._actions.filter(actionItem => actionItem.location === HEADER);
|
|
1808
|
+
return this._actions.filter(actionItem => actionItem.location === HEADER$1);
|
|
1931
1809
|
}
|
|
1932
1810
|
getFieldObject(elementId) {
|
|
1933
1811
|
return (this._fieldsObj && elementId && this._fieldsObj[elementId])
|
|
@@ -2311,71 +2189,77 @@ class LibFormManagerService {
|
|
|
2311
2189
|
constructor() {
|
|
2312
2190
|
this.cleanStack();
|
|
2313
2191
|
}
|
|
2314
|
-
|
|
2315
|
-
* Métodos virtuales de manejo de formularios
|
|
2316
|
-
*/
|
|
2192
|
+
// Métodos virtuales para las aplicaciones
|
|
2317
2193
|
getFormDefinition(formCode) { }
|
|
2194
|
+
getFormRoute(formCode) { }
|
|
2195
|
+
getRouteForm(path) { }
|
|
2318
2196
|
execServerAction(actionDetail) { }
|
|
2319
|
-
|
|
2320
|
-
/**
|
|
2321
|
-
* Manejo del stack de navegación con atributos estados y parámetros
|
|
2322
|
-
*/
|
|
2323
|
-
resetPageStack() { this.cleanStack(); }
|
|
2324
|
-
cleanStack() {
|
|
2325
|
-
this.pageStack = [];
|
|
2326
|
-
}
|
|
2197
|
+
goToForm(formCode, token, subject) { }
|
|
2327
2198
|
loadStack() { }
|
|
2328
2199
|
saveStack() { }
|
|
2329
|
-
|
|
2330
|
-
|
|
2331
|
-
|
|
2332
|
-
this.
|
|
2333
|
-
|
|
2334
|
-
|
|
2335
|
-
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
|
|
2200
|
+
cleanStack() { this.pageStack = []; }
|
|
2201
|
+
resetPageStack() { this.cleanStack(); }
|
|
2202
|
+
findFormInStack(token) {
|
|
2203
|
+
const index = this.pageStack.findIndex(item => (item === null || item === void 0 ? void 0 : item.token) === token);
|
|
2204
|
+
const data = (index >= 0) ? this.pageStack[index] : null;
|
|
2205
|
+
return { index, data };
|
|
2206
|
+
}
|
|
2207
|
+
replaceItem(token, formInfo) {
|
|
2208
|
+
var _a, _b;
|
|
2209
|
+
if (!token || !formInfo) {
|
|
2210
|
+
return;
|
|
2211
|
+
}
|
|
2212
|
+
const { index, data: storedForm } = this.findFormInStack(token);
|
|
2213
|
+
let updatedForm = null;
|
|
2214
|
+
if (index >= 0) {
|
|
2215
|
+
updatedForm = Object.assign({}, storedForm);
|
|
2216
|
+
updatedForm.subject = (_a = formInfo === null || formInfo === void 0 ? void 0 : formInfo.subject) !== null && _a !== void 0 ? _a : storedForm.subject;
|
|
2217
|
+
updatedForm.state = (_b = formInfo === null || formInfo === void 0 ? void 0 : formInfo.state) !== null && _b !== void 0 ? _b : storedForm.state;
|
|
2218
|
+
Object.assign(updatedForm.fields, formInfo.fields);
|
|
2219
|
+
Object.assign(updatedForm.extra, formInfo.extra);
|
|
2220
|
+
this.pageStack[index] = updatedForm;
|
|
2341
2221
|
this.saveStack();
|
|
2342
|
-
return formData;
|
|
2343
2222
|
}
|
|
2344
2223
|
}
|
|
2345
|
-
|
|
2346
|
-
const
|
|
2347
|
-
|
|
2348
|
-
|
|
2349
|
-
|
|
2224
|
+
stack(origin, target) {
|
|
2225
|
+
const token = nanoid(6);
|
|
2226
|
+
this.replaceItem(target.originToken, origin);
|
|
2227
|
+
this.pageStack.push(Object.assign({ token }, target));
|
|
2228
|
+
this.saveStack();
|
|
2229
|
+
return token;
|
|
2230
|
+
}
|
|
2231
|
+
unstack(token = null) {
|
|
2232
|
+
let index = (token) ? this.findFormInStack(token).index : this.pageStack.length - 2;
|
|
2233
|
+
let formInfo = null;
|
|
2234
|
+
if (index >= 0) {
|
|
2235
|
+
formInfo = this.pageStack[index];
|
|
2236
|
+
this.pageStack.splice(index + 1);
|
|
2237
|
+
this.saveStack();
|
|
2350
2238
|
}
|
|
2351
|
-
return
|
|
2239
|
+
return formInfo;
|
|
2352
2240
|
}
|
|
2353
|
-
|
|
2354
|
-
|
|
2355
|
-
|
|
2356
|
-
|
|
2357
|
-
|
|
2358
|
-
|
|
2359
|
-
|
|
2241
|
+
getFormInfo(token) {
|
|
2242
|
+
var _a, _b;
|
|
2243
|
+
const { data } = this.findFormInStack(token);
|
|
2244
|
+
return {
|
|
2245
|
+
token: data === null || data === void 0 ? void 0 : data.token,
|
|
2246
|
+
subject: data === null || data === void 0 ? void 0 : data.subject,
|
|
2247
|
+
state: data === null || data === void 0 ? void 0 : data.state,
|
|
2248
|
+
originToken: data === null || data === void 0 ? void 0 : data.originToken,
|
|
2249
|
+
fields: (_a = data === null || data === void 0 ? void 0 : data.fields) !== null && _a !== void 0 ? _a : {},
|
|
2250
|
+
extra: (_b = data === null || data === void 0 ? void 0 : data.extra) !== null && _b !== void 0 ? _b : {}
|
|
2251
|
+
};
|
|
2360
2252
|
}
|
|
2361
|
-
|
|
2362
|
-
|
|
2363
|
-
|
|
2364
|
-
|
|
2365
|
-
const
|
|
2366
|
-
|
|
2367
|
-
const navigationArray = [url, ...params, newToken];
|
|
2368
|
-
this.goToRoute(navigationArray);
|
|
2253
|
+
openForm(origin, target) {
|
|
2254
|
+
var _a;
|
|
2255
|
+
(!origin) && this.cleanStack();
|
|
2256
|
+
target.originToken = (_a = origin === null || origin === void 0 ? void 0 : origin.token) !== null && _a !== void 0 ? _a : null;
|
|
2257
|
+
const token = this.stack(origin, target);
|
|
2258
|
+
this.goToForm(target.name, token, target.subject);
|
|
2369
2259
|
}
|
|
2370
|
-
|
|
2371
|
-
const
|
|
2372
|
-
|
|
2373
|
-
return;
|
|
2374
|
-
}
|
|
2375
|
-
const { origin: { url, params, token } } = prevForm;
|
|
2376
|
-
const navigationArray = [url, ...params];
|
|
2377
|
-
token && navigationArray.push(token);
|
|
2378
|
-
this.goToRoute(navigationArray);
|
|
2260
|
+
backTo(targetToken = null) {
|
|
2261
|
+
const formInfo = this.unstack(targetToken);
|
|
2262
|
+
formInfo && formInfo.name && this.goToForm(formInfo.name, formInfo.token, formInfo.subject);
|
|
2379
2263
|
}
|
|
2380
2264
|
}
|
|
2381
2265
|
|
|
@@ -2406,11 +2290,8 @@ const PAYLOAD_VERSION = 'TUAINEXCHANGE_1.0';
|
|
|
2406
2290
|
const INLINE_ACTION = 'INLINE';
|
|
2407
2291
|
const GLOBAL_ACTION = 'GLOBAL';
|
|
2408
2292
|
const GET_DATA_ACTION = 'GETDATA';
|
|
2409
|
-
const
|
|
2410
|
-
const
|
|
2411
|
-
const ORIGIN_PARAM = 'origin';
|
|
2412
|
-
const STATE_PARAM = 'mode';
|
|
2413
|
-
const REQUIRED_FIELD_MESSAGE = 'Campo requerido';
|
|
2293
|
+
const SUBJECT = 'subject';
|
|
2294
|
+
const TOKEN = 'token';
|
|
2414
2295
|
class BasicFormComponent {
|
|
2415
2296
|
constructor(formManagerService, _eventManager, fileMgmtServices) {
|
|
2416
2297
|
this.formManagerService = formManagerService;
|
|
@@ -2420,10 +2301,9 @@ class BasicFormComponent {
|
|
|
2420
2301
|
this.errorMessage = '';
|
|
2421
2302
|
this.errorDetail = '';
|
|
2422
2303
|
this.formStructure = null;
|
|
2423
|
-
this.
|
|
2424
|
-
this.inputDataFields =
|
|
2425
|
-
this.extraData =
|
|
2426
|
-
this.componentConstants = componentConstants;
|
|
2304
|
+
this.controlToken = null;
|
|
2305
|
+
this.inputDataFields = {};
|
|
2306
|
+
this.extraData = {};
|
|
2427
2307
|
this.definitionObtained = false;
|
|
2428
2308
|
this.formVisible = false;
|
|
2429
2309
|
this.inServerProcess = false;
|
|
@@ -2445,14 +2325,17 @@ class BasicFormComponent {
|
|
|
2445
2325
|
this.cleanStart();
|
|
2446
2326
|
this.customPreProcessing();
|
|
2447
2327
|
}
|
|
2328
|
+
setConfig(formConfig) {
|
|
2329
|
+
this.formConfig = formConfig;
|
|
2330
|
+
}
|
|
2448
2331
|
cleanStart() {
|
|
2449
2332
|
this._errorType = '';
|
|
2450
2333
|
this.errorCode = '';
|
|
2451
2334
|
this.errorMessage = '';
|
|
2452
2335
|
this.errorDetail = '';
|
|
2453
2336
|
this.formStructure = null;
|
|
2454
|
-
this.
|
|
2455
|
-
this.inputDataFields =
|
|
2337
|
+
this.controlToken = null;
|
|
2338
|
+
this.inputDataFields = {};
|
|
2456
2339
|
this.definitionObtained = false;
|
|
2457
2340
|
// Se limpian los manejadores de eventos
|
|
2458
2341
|
this.formVisible = false;
|
|
@@ -2601,35 +2484,61 @@ class BasicFormComponent {
|
|
|
2601
2484
|
subscribeAppEvent(eventName, callback) {
|
|
2602
2485
|
this._eventEmiter.subscribe(eventName, callback);
|
|
2603
2486
|
}
|
|
2487
|
+
openForm(name, data = null, backData = null, cleanStack = false) {
|
|
2488
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
2489
|
+
let origin = null;
|
|
2490
|
+
if (!cleanStack) {
|
|
2491
|
+
origin = Object.assign(Object.assign({}, backData), { name: this.name, url: this._formRoute, token: this.controlToken });
|
|
2492
|
+
origin.subject = (_a = origin === null || origin === void 0 ? void 0 : origin.subject) !== null && _a !== void 0 ? _a : this.formSubject;
|
|
2493
|
+
origin.state = (_b = origin === null || origin === void 0 ? void 0 : origin.state) !== null && _b !== void 0 ? _b : this.currentState;
|
|
2494
|
+
origin.fields = (_c = origin === null || origin === void 0 ? void 0 : origin.fields) !== null && _c !== void 0 ? _c : {};
|
|
2495
|
+
origin.extra = (_d = origin === null || origin === void 0 ? void 0 : origin.extra) !== null && _d !== void 0 ? _d : {};
|
|
2496
|
+
}
|
|
2497
|
+
const target = Object.assign(Object.assign({}, data), { name });
|
|
2498
|
+
target.subject = (_e = target === null || target === void 0 ? void 0 : target.subject) !== null && _e !== void 0 ? _e : null;
|
|
2499
|
+
target.state = (_f = target === null || target === void 0 ? void 0 : target.state) !== null && _f !== void 0 ? _f : null;
|
|
2500
|
+
target.fields = (_g = target === null || target === void 0 ? void 0 : target.fields) !== null && _g !== void 0 ? _g : {};
|
|
2501
|
+
target.extra = (_h = target === null || target === void 0 ? void 0 : target.extra) !== null && _h !== void 0 ? _h : {};
|
|
2502
|
+
this.formManagerService.openForm(origin, target);
|
|
2503
|
+
}
|
|
2504
|
+
/**
|
|
2505
|
+
* @deprecated Este método ya no debería ser utilizado. Use openForm con el nombre del formulario
|
|
2506
|
+
*/
|
|
2604
2507
|
goToPage(navigationArray, predefinedFields, options = null) {
|
|
2605
|
-
var _a
|
|
2508
|
+
var _a;
|
|
2606
2509
|
let origin = null;
|
|
2607
2510
|
const cleanStack = (_a = options === null || options === void 0 ? void 0 : options.cleanStack) !== null && _a !== void 0 ? _a : false;
|
|
2608
|
-
const params = [];
|
|
2609
|
-
this.currentState && params.push(this.currentState);
|
|
2610
|
-
this.formSubject && params.push(this.formSubject);
|
|
2611
2511
|
if (!cleanStack) {
|
|
2612
2512
|
origin = {
|
|
2613
|
-
|
|
2513
|
+
name: this.name,
|
|
2614
2514
|
url: this._formRoute,
|
|
2615
|
-
|
|
2616
|
-
|
|
2617
|
-
|
|
2515
|
+
token: this.controlToken,
|
|
2516
|
+
fields: this.inputDataFields,
|
|
2517
|
+
extra: this.extraData
|
|
2618
2518
|
};
|
|
2619
2519
|
}
|
|
2620
2520
|
const target = {
|
|
2521
|
+
name: this.formManagerService.getRouteForm(navigationArray === null || navigationArray === void 0 ? void 0 : navigationArray[0]),
|
|
2621
2522
|
url: navigationArray === null || navigationArray === void 0 ? void 0 : navigationArray[0],
|
|
2622
|
-
|
|
2623
|
-
|
|
2523
|
+
state: navigationArray === null || navigationArray === void 0 ? void 0 : navigationArray[1],
|
|
2524
|
+
subject: navigationArray === null || navigationArray === void 0 ? void 0 : navigationArray[2],
|
|
2525
|
+
fields: predefinedFields,
|
|
2526
|
+
extra: null,
|
|
2624
2527
|
};
|
|
2625
|
-
this.formManagerService.
|
|
2528
|
+
this.formManagerService.openForm(origin, target);
|
|
2626
2529
|
}
|
|
2530
|
+
/**
|
|
2531
|
+
* @deprecated Este método ya no debería ser utilizado. Use openForm con el nombre del formulario
|
|
2532
|
+
*/
|
|
2627
2533
|
goToNewPage(nav, flds) { return this.goToPage(nav, flds, { cleanStack: true }); }
|
|
2534
|
+
/**
|
|
2535
|
+
* @deprecated Este método ya no debería ser utilizado. Use openForm con el nombre del formulario
|
|
2536
|
+
*/
|
|
2628
2537
|
goToSubPage(nav, flds) { return this.goToPage(nav, flds, { cleanStack: false }); }
|
|
2629
|
-
canGoBack() { return this.
|
|
2630
|
-
goBack() { return this.formManagerService.
|
|
2538
|
+
canGoBack() { return this.originToken !== null; }
|
|
2539
|
+
goBack() { return this.formManagerService.backTo(); }
|
|
2631
2540
|
goBackForm() { return this.goBack(); }
|
|
2632
|
-
getOriginDetail() { return this.formManagerService.
|
|
2541
|
+
getOriginDetail() { return this.formManagerService.getFormInfo(this.originToken); }
|
|
2633
2542
|
setError(errorType, errorMessage, errorDetail) {
|
|
2634
2543
|
this._errorType = errorType || '';
|
|
2635
2544
|
this.errorMessage = errorMessage || '';
|
|
@@ -2649,33 +2558,23 @@ class BasicFormComponent {
|
|
|
2649
2558
|
get formCode() { return this.name; }
|
|
2650
2559
|
set formCode(name) { this.name = name; }
|
|
2651
2560
|
getFormParameter(name) {
|
|
2652
|
-
|
|
2561
|
+
var _a, _b;
|
|
2562
|
+
return (name) ? ((_b = (_a = this.extraData) === null || _a === void 0 ? void 0 : _a[name]) !== null && _b !== void 0 ? _b : null) : null;
|
|
2653
2563
|
}
|
|
2654
2564
|
getSubject() { return this.formSubject; }
|
|
2655
2565
|
getformSubject() { return this.getSubject(); }
|
|
2656
2566
|
preocessInputParams(params) {
|
|
2657
|
-
var _a, _b, _c
|
|
2658
|
-
|
|
2659
|
-
|
|
2660
|
-
|
|
2661
|
-
|
|
2662
|
-
this.extraData = [];
|
|
2663
|
-
for (const paramName of allParams) {
|
|
2664
|
-
this.extraData[paramName] = params[paramName].toString();
|
|
2665
|
-
}
|
|
2666
|
-
const formName = (_b = (_a = this.extraData) === null || _a === void 0 ? void 0 : _a[FORM_CODE]) !== null && _b !== void 0 ? _b : this.name;
|
|
2667
|
-
if (formName !== this.name) {
|
|
2668
|
-
this.cleanStart();
|
|
2669
|
-
this.name = formName;
|
|
2670
|
-
}
|
|
2671
|
-
this.formSubject = (_d = (_c = this.extraData) === null || _c === void 0 ? void 0 : _c[FORM_SUBJECT]) !== null && _d !== void 0 ? _d : null;
|
|
2672
|
-
const initialState = this.extraData[STATE_PARAM];
|
|
2673
|
-
this.transitionToken = (_e = this.extraData[ORIGIN_PARAM]) !== null && _e !== void 0 ? _e : null;
|
|
2674
|
-
this.inputDataFields = (_f = this.formManagerService.getInputData(this.transitionToken)) !== null && _f !== void 0 ? _f : [];
|
|
2675
|
-
if (!this.transitionToken) {
|
|
2676
|
-
this.formManagerService.cleanStack();
|
|
2567
|
+
var _a, _b, _c;
|
|
2568
|
+
this.controlToken = (_a = params === null || params === void 0 ? void 0 : params[TOKEN]) !== null && _a !== void 0 ? _a : null;
|
|
2569
|
+
const { token, subject, state, fields, extra, originToken } = this.formManagerService.getFormInfo(this.controlToken);
|
|
2570
|
+
if (!this.controlToken || this.controlToken !== token) {
|
|
2571
|
+
console.log(`No se obtuvo un token válido para abrir el formulario ${this.controlToken}->${token}`);
|
|
2677
2572
|
}
|
|
2678
|
-
|
|
2573
|
+
this.formSubject = (_c = (_b = params === null || params === void 0 ? void 0 : params[SUBJECT]) !== null && _b !== void 0 ? _b : subject) !== null && _c !== void 0 ? _c : null;
|
|
2574
|
+
this.inputDataFields = fields;
|
|
2575
|
+
this.extraData = extra;
|
|
2576
|
+
this.originToken = originToken;
|
|
2577
|
+
return state;
|
|
2679
2578
|
}
|
|
2680
2579
|
subscribeSectionActivation() {
|
|
2681
2580
|
const formSections = this.formStructure.getSections();
|
|
@@ -2723,7 +2622,6 @@ class BasicFormComponent {
|
|
|
2723
2622
|
}
|
|
2724
2623
|
}
|
|
2725
2624
|
formInit(params) {
|
|
2726
|
-
var _a;
|
|
2727
2625
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2728
2626
|
let initialState = this.preocessInputParams(params);
|
|
2729
2627
|
if (!this.name) {
|
|
@@ -2733,7 +2631,7 @@ class BasicFormComponent {
|
|
|
2733
2631
|
this.inServerProcess = true;
|
|
2734
2632
|
const formDefinition = yield this.formManagerService.getFormDefinition(this.name);
|
|
2735
2633
|
this.inServerProcess = false;
|
|
2736
|
-
this.formStructure = new FormStructureAndData(formDefinition);
|
|
2634
|
+
this.formStructure = new FormStructureAndData(formDefinition, this.formConfig);
|
|
2737
2635
|
this.definitionObtained = true;
|
|
2738
2636
|
}
|
|
2739
2637
|
else {
|
|
@@ -2743,23 +2641,13 @@ class BasicFormComponent {
|
|
|
2743
2641
|
initialState = this.formStructure.defaultState;
|
|
2744
2642
|
}
|
|
2745
2643
|
this.formStructure.changeState(initialState || this.formStructure.defaultState);
|
|
2746
|
-
|
|
2747
|
-
|
|
2748
|
-
|
|
2749
|
-
|
|
2750
|
-
|
|
2751
|
-
}
|
|
2752
|
-
}
|
|
2753
|
-
}
|
|
2754
|
-
else {
|
|
2755
|
-
const fieldCodes = Object.keys((_a = this.inputDataFields) !== null && _a !== void 0 ? _a : {});
|
|
2756
|
-
for (let index = 0; index < fieldCodes.length; index++) {
|
|
2757
|
-
const fieldCode = fieldCodes[index];
|
|
2758
|
-
const fieldValue = this.inputDataFields[fieldCode];
|
|
2759
|
-
this.setFieldValue(fieldCode, fieldValue);
|
|
2760
|
-
}
|
|
2644
|
+
const inputFieldNames = Object.keys(this.inputDataFields);
|
|
2645
|
+
for (let index = 0; index < inputFieldNames.length; index++) {
|
|
2646
|
+
const fieldCode = inputFieldNames[index];
|
|
2647
|
+
const fieldValue = this.inputDataFields[fieldCode];
|
|
2648
|
+
this.setFieldValue(fieldCode, fieldValue);
|
|
2761
2649
|
}
|
|
2762
|
-
const recordResponse = yield this.requestFormAction(
|
|
2650
|
+
const recordResponse = yield this.requestFormAction(formActions.getData);
|
|
2763
2651
|
this.checkErrorRecordReceived(recordResponse);
|
|
2764
2652
|
this.formVisible = true;
|
|
2765
2653
|
this.subscribeSectionActivation();
|
|
@@ -2779,7 +2667,7 @@ class BasicFormComponent {
|
|
|
2779
2667
|
this.errorDetail = recordResponse.errorDetail;
|
|
2780
2668
|
}
|
|
2781
2669
|
errorOccured() {
|
|
2782
|
-
return (this.errorCode !==
|
|
2670
|
+
return (this.errorCode !== NO_ERROR);
|
|
2783
2671
|
}
|
|
2784
2672
|
changeState(state) { return this.formStructure.changeState(state); }
|
|
2785
2673
|
changeFormMode(state) { return this.changeState(state); }
|
|
@@ -2795,7 +2683,7 @@ class BasicFormComponent {
|
|
|
2795
2683
|
formData: this.formStructure.getPayload(),
|
|
2796
2684
|
immutableData: this.formStructure.immutableData,
|
|
2797
2685
|
};
|
|
2798
|
-
this.errorCode =
|
|
2686
|
+
this.errorCode = NO_ERROR;
|
|
2799
2687
|
this.errorMessage = '';
|
|
2800
2688
|
this.errorDetail = '';
|
|
2801
2689
|
this.inServerProcess = true;
|
|
@@ -3014,8 +2902,7 @@ class BasicFormComponent {
|
|
|
3014
2902
|
if (!fieldToValidate) {
|
|
3015
2903
|
return false;
|
|
3016
2904
|
}
|
|
3017
|
-
fieldToValidate.
|
|
3018
|
-
fieldToValidate.setErrorCode('00');
|
|
2905
|
+
fieldToValidate.resetError();
|
|
3019
2906
|
const validationCallbacks = this.fieldInputValidation[fieldCode];
|
|
3020
2907
|
if (validationCallbacks) {
|
|
3021
2908
|
const clientValidationPromises = [];
|
|
@@ -3033,8 +2920,7 @@ class BasicFormComponent {
|
|
|
3033
2920
|
if (!fieldToValidate || !intrinsicValidation) {
|
|
3034
2921
|
return;
|
|
3035
2922
|
}
|
|
3036
|
-
fieldToValidate.
|
|
3037
|
-
fieldToValidate.setErrorCode('00');
|
|
2923
|
+
fieldToValidate.resetError();
|
|
3038
2924
|
const validationCallbacks = this.fieldValidationsStart[fieldCode];
|
|
3039
2925
|
if (validationCallbacks) {
|
|
3040
2926
|
const clientValidationPromises = [];
|
|
@@ -3060,7 +2946,7 @@ class BasicFormComponent {
|
|
|
3060
2946
|
if (fieldObj.backend) {
|
|
3061
2947
|
fieldObj.validating = true;
|
|
3062
2948
|
validationResult = yield this
|
|
3063
|
-
.requestFormAction(
|
|
2949
|
+
.requestFormAction(formActions.validate, fieldObj.fieldCode);
|
|
3064
2950
|
finish = !this.errorOccured();
|
|
3065
2951
|
}
|
|
3066
2952
|
if (finish) {
|
|
@@ -3249,7 +3135,7 @@ class BasicFormComponent {
|
|
|
3249
3135
|
actionCode
|
|
3250
3136
|
};
|
|
3251
3137
|
actionResult = yield this
|
|
3252
|
-
.requestFormAction(
|
|
3138
|
+
.requestFormAction(formActions.tableAction, actionSubject);
|
|
3253
3139
|
finish = !this.errorOccured();
|
|
3254
3140
|
}
|
|
3255
3141
|
if (finish) {
|
|
@@ -3326,13 +3212,13 @@ class BasicFormComponent {
|
|
|
3326
3212
|
if (action.backend) {
|
|
3327
3213
|
const actionSubject = {
|
|
3328
3214
|
tableCode,
|
|
3329
|
-
actionType:
|
|
3215
|
+
actionType: this.formConfig.tableActions.inline,
|
|
3330
3216
|
actionCode,
|
|
3331
3217
|
tableRecordId: recordId,
|
|
3332
3218
|
tableRecordData: recordData
|
|
3333
3219
|
};
|
|
3334
3220
|
actionResult = yield this
|
|
3335
|
-
.requestFormAction(
|
|
3221
|
+
.requestFormAction(formActions.tableAction, actionSubject);
|
|
3336
3222
|
finish = !this.errorOccured();
|
|
3337
3223
|
}
|
|
3338
3224
|
if (finish) {
|
|
@@ -3405,13 +3291,13 @@ class BasicFormComponent {
|
|
|
3405
3291
|
if (tableObject.selectionBackend) {
|
|
3406
3292
|
const actionSubject = {
|
|
3407
3293
|
tableCode,
|
|
3408
|
-
actionType:
|
|
3294
|
+
actionType: this.formConfig.tableActions.rowSelection,
|
|
3409
3295
|
actionCode: null,
|
|
3410
3296
|
tableRecordId: recordId,
|
|
3411
3297
|
tableRecordData: recordData
|
|
3412
3298
|
};
|
|
3413
3299
|
actionResult = yield this
|
|
3414
|
-
.requestFormAction(
|
|
3300
|
+
.requestFormAction(formActions.tableAction, actionSubject);
|
|
3415
3301
|
finish = !this.errorOccured();
|
|
3416
3302
|
}
|
|
3417
3303
|
if (finish) {
|
|
@@ -3485,12 +3371,12 @@ class BasicFormComponent {
|
|
|
3485
3371
|
if (action.backend) {
|
|
3486
3372
|
const actionSubject = {
|
|
3487
3373
|
tableCode,
|
|
3488
|
-
actionType:
|
|
3374
|
+
actionType: this.formConfig.tableActions.selection,
|
|
3489
3375
|
actionCode,
|
|
3490
3376
|
selectedRecords
|
|
3491
3377
|
};
|
|
3492
3378
|
actionResult = yield this
|
|
3493
|
-
.requestFormAction(
|
|
3379
|
+
.requestFormAction(formActions.tableAction, actionSubject);
|
|
3494
3380
|
finish = !this.errorOccured();
|
|
3495
3381
|
}
|
|
3496
3382
|
if (finish) {
|
|
@@ -3548,7 +3434,7 @@ class BasicFormComponent {
|
|
|
3548
3434
|
tableObject.putOnWait();
|
|
3549
3435
|
const actionSubject = { tableCode };
|
|
3550
3436
|
const actionResult = yield this
|
|
3551
|
-
.requestFormAction(
|
|
3437
|
+
.requestFormAction(formActions.getTableData, actionSubject);
|
|
3552
3438
|
if (this.errorOccured()) {
|
|
3553
3439
|
this.displayTableServerError();
|
|
3554
3440
|
}
|
|
@@ -3574,7 +3460,7 @@ class BasicFormComponent {
|
|
|
3574
3460
|
}
|
|
3575
3461
|
checkSectionRequiredFields(sectionCode, reqFieldMessage) {
|
|
3576
3462
|
this.cleanErrorFields(null, sectionCode);
|
|
3577
|
-
const requiredFieldMessage = reqFieldMessage
|
|
3463
|
+
const requiredFieldMessage = reqFieldMessage !== null && reqFieldMessage !== void 0 ? reqFieldMessage : this.formConfig.formStandardErrors.requiredField;
|
|
3578
3464
|
const numErrors = this.tagFieldsWithError(this.getRequiredEmptyFields(null, sectionCode), null, requiredFieldMessage);
|
|
3579
3465
|
return (numErrors === 0);
|
|
3580
3466
|
}
|
|
@@ -3582,15 +3468,15 @@ class BasicFormComponent {
|
|
|
3582
3468
|
this.resetError();
|
|
3583
3469
|
const completeFields = this.checkSectionRequiredFields(sectionCode, reqFieldMessage);
|
|
3584
3470
|
if (!completeFields) {
|
|
3585
|
-
this.setError(
|
|
3471
|
+
this.setError(this.formConfig.formStandardErrors.typeWarning, this.formConfig.formStandardErrors.validationTitle, this.formConfig.formStandardErrors.requiredFields);
|
|
3586
3472
|
return;
|
|
3587
3473
|
}
|
|
3588
3474
|
let validationError = false;
|
|
3589
3475
|
const requiredEmptyFields = this.getRequiredEmptyFields(null, sectionCode);
|
|
3590
3476
|
if (requiredEmptyFields.length > 0) {
|
|
3591
3477
|
validationError = true;
|
|
3592
|
-
this.setError(
|
|
3593
|
-
this.tagFieldsWithError(requiredEmptyFields, null,
|
|
3478
|
+
this.setError(this.formConfig.formStandardErrors.typeWarning, this.formConfig.formStandardErrors.validationTitle, this.formConfig.formStandardErrors.requiredFields);
|
|
3479
|
+
this.tagFieldsWithError(requiredEmptyFields, null, this.formConfig.formStandardErrors.requiredField);
|
|
3594
3480
|
for (const fieldCode of requiredEmptyFields) {
|
|
3595
3481
|
const requiredEmptyField = this.getField(fieldCode);
|
|
3596
3482
|
if (requiredEmptyField && requiredEmptyField.widget
|
|
@@ -3603,7 +3489,7 @@ class BasicFormComponent {
|
|
|
3603
3489
|
const validationIssueFields = this.getFieldsWithValidationIssues(null, sectionCode);
|
|
3604
3490
|
if (!validationError && validationIssueFields.length > 0) {
|
|
3605
3491
|
validationError = true;
|
|
3606
|
-
this.setError(
|
|
3492
|
+
this.setError(this.formConfig.formStandardErrors.typeWarning, this.formConfig.formStandardErrors.validationTitle, this.formConfig.formStandardErrors.validationFields);
|
|
3607
3493
|
for (const fieldCode of validationIssueFields) {
|
|
3608
3494
|
const validationIssueField = this.getField(fieldCode);
|
|
3609
3495
|
if (validationIssueField && validationIssueField.widget
|
|
@@ -3719,13 +3605,13 @@ class BasicFormComponent {
|
|
|
3719
3605
|
const requiredEmptyFields = this.getRequiredEmptyFields(recordCaptureFields, null);
|
|
3720
3606
|
if (requiredEmptyFields.length > 0) {
|
|
3721
3607
|
validationOk = false;
|
|
3722
|
-
this.setError(
|
|
3723
|
-
this.tagFieldsWithError(requiredEmptyFields, null,
|
|
3608
|
+
this.setError(this.formConfig.formStandardErrors.typeWarning, this.formConfig.formStandardErrors.validationTitle, this.formConfig.formStandardErrors.requiredFields);
|
|
3609
|
+
this.tagFieldsWithError(requiredEmptyFields, null, this.formConfig.formStandardErrors.requiredField);
|
|
3724
3610
|
}
|
|
3725
3611
|
const validationIssueFields = this.getFieldsWithValidationIssues(recordCaptureFields, null);
|
|
3726
3612
|
if (validationIssueFields.length > 0) {
|
|
3727
3613
|
validationOk = false;
|
|
3728
|
-
this.setError(
|
|
3614
|
+
this.setError(this.formConfig.formStandardErrors.typeWarning, this.formConfig.formStandardErrors.validationTitle, this.formConfig.formStandardErrors.validationFields);
|
|
3729
3615
|
}
|
|
3730
3616
|
return validationOk;
|
|
3731
3617
|
}
|