tuain-ng-forms-lib 0.12.31 → 0.12.32
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 +157 -251
- 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 +41 -91
- 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 +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 +21 -11
- 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 +24 -22
- package/fesm2015/tuain-ng-forms-lib.js +156 -255
- 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 +2 -1
- 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 +1 -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 +2 -1
- 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,131 +51,49 @@ ActionComponent.propDecorators = {
|
|
|
49
51
|
showLabel: [{ type: Input }]
|
|
50
52
|
};
|
|
51
53
|
|
|
52
|
-
const
|
|
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 = {
|
|
54
|
+
const MONITORED_ATTRIBUTES = {
|
|
147
55
|
_maxLength: 'maxLength',
|
|
148
|
-
_onValidation: '
|
|
56
|
+
_onValidation: 'onValidation',
|
|
149
57
|
_fieldValue: 'value',
|
|
150
58
|
captureType: 'captureType',
|
|
151
|
-
fieldTitle: '
|
|
152
|
-
fieldType: '
|
|
59
|
+
fieldTitle: 'title',
|
|
60
|
+
fieldType: 'type',
|
|
153
61
|
errorMessage: 'errorMessage',
|
|
154
62
|
errorType: 'errorType',
|
|
155
63
|
errorCode: 'errorCode',
|
|
156
64
|
visibleLabel: 'visibleLabel',
|
|
157
|
-
fieldRequired: '
|
|
158
|
-
fieldOptions: '
|
|
65
|
+
fieldRequired: 'required',
|
|
66
|
+
fieldOptions: 'options',
|
|
159
67
|
};
|
|
160
68
|
class FieldComponent {
|
|
161
|
-
constructor() {
|
|
162
|
-
this.componentConstants = Object.assign({}, componentConstants);
|
|
163
|
-
}
|
|
164
69
|
ngOnInit() {
|
|
70
|
+
var _a;
|
|
165
71
|
if (this.fieldObject) {
|
|
72
|
+
this.formConfig = (_a = this.fieldObject) === null || _a === void 0 ? void 0 : _a._formConfig;
|
|
166
73
|
// Atributos estáticos
|
|
167
74
|
this.code = this.fieldObject.fieldCode;
|
|
168
75
|
this.fieldInfo = this.fieldObject.fieldInfo;
|
|
169
76
|
this.fieldAlignment = this.fieldObject.fieldAlignment;
|
|
170
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;
|
|
171
91
|
this.fieldObject.widget = this;
|
|
172
92
|
// Atributos dinámicos
|
|
173
93
|
this.fieldObject.attributeChange.subscribe(event => {
|
|
174
94
|
const { name, value } = event;
|
|
175
|
-
if (this[MONITORED_ATTRIBUTES
|
|
176
|
-
this[MONITORED_ATTRIBUTES
|
|
95
|
+
if (this[MONITORED_ATTRIBUTES[name]]) {
|
|
96
|
+
this[MONITORED_ATTRIBUTES[name]] = value;
|
|
177
97
|
}
|
|
178
98
|
});
|
|
179
99
|
}
|
|
@@ -201,17 +121,15 @@ FieldComponent.decorators = [
|
|
|
201
121
|
template: `<ng-content></ng-content>`
|
|
202
122
|
},] }
|
|
203
123
|
];
|
|
204
|
-
FieldComponent.ctorParameters = () => [];
|
|
205
124
|
FieldComponent.propDecorators = {
|
|
206
125
|
fieldObject: [{ type: Input }],
|
|
207
126
|
disabled: [{ type: Input }]
|
|
208
127
|
};
|
|
209
128
|
|
|
210
129
|
class ElementComponent {
|
|
211
|
-
constructor() {
|
|
212
|
-
this.componentConstants = Object.assign({}, componentConstants);
|
|
213
|
-
}
|
|
214
130
|
ngOnInit() {
|
|
131
|
+
var _a;
|
|
132
|
+
this.formConfig = (_a = this.formElement) === null || _a === void 0 ? void 0 : _a._formConfig;
|
|
215
133
|
this.start();
|
|
216
134
|
}
|
|
217
135
|
start() { }
|
|
@@ -232,7 +150,6 @@ ElementComponent.decorators = [
|
|
|
232
150
|
template: `<ng-content></ng-content>`
|
|
233
151
|
},] }
|
|
234
152
|
];
|
|
235
|
-
ElementComponent.ctorParameters = () => [];
|
|
236
153
|
ElementComponent.propDecorators = {
|
|
237
154
|
formElement: [{ type: Input }],
|
|
238
155
|
formManager: [{ type: Input }]
|
|
@@ -328,9 +245,33 @@ class Filter {
|
|
|
328
245
|
}
|
|
329
246
|
}
|
|
330
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
|
+
|
|
331
271
|
class FormElement {
|
|
332
|
-
constructor(elementDefinition) {
|
|
272
|
+
constructor(elementDefinition, formConfig) {
|
|
333
273
|
var _a, _b;
|
|
274
|
+
this._formConfig = formConfig;
|
|
334
275
|
this._isForced = false;
|
|
335
276
|
this.setVisibleStates(elementDefinition.visibleStates);
|
|
336
277
|
this.setEnabledStates(elementDefinition.enabledStates);
|
|
@@ -339,9 +280,9 @@ class FormElement {
|
|
|
339
280
|
this.setVisibility((_b = elementDefinition === null || elementDefinition === void 0 ? void 0 : elementDefinition.visible) !== null && _b !== void 0 ? _b : true);
|
|
340
281
|
this.widget = null;
|
|
341
282
|
}
|
|
342
|
-
isField() { return this.elementType ===
|
|
343
|
-
isAction() { return this.elementType ===
|
|
344
|
-
isTable() { return this.elementType ===
|
|
283
|
+
isField() { return this.elementType === elementTypes.field; }
|
|
284
|
+
isAction() { return this.elementType === elementTypes.action; }
|
|
285
|
+
isTable() { return this.elementType === elementTypes.table; }
|
|
345
286
|
setVisibleStates(newStates) {
|
|
346
287
|
const visibleStates = (!Array.isArray(newStates) && typeof newStates === 'string')
|
|
347
288
|
? newStates.split(',').map(state => state.trim()).filter(state => state.length > 0)
|
|
@@ -387,13 +328,14 @@ class FormElement {
|
|
|
387
328
|
}
|
|
388
329
|
|
|
389
330
|
class RecordTableColumn {
|
|
390
|
-
constructor(recTableColReceived) {
|
|
331
|
+
constructor(recTableColReceived, formConfig) {
|
|
391
332
|
var _a, _b, _c;
|
|
333
|
+
this._formConfig = formConfig;
|
|
392
334
|
if (recTableColReceived) {
|
|
393
335
|
this.fieldCode = recTableColReceived.fieldCode;
|
|
394
336
|
this.fieldTitle = recTableColReceived.fieldTitle;
|
|
395
|
-
this.fieldType = recTableColReceived.fieldTypeCode ||
|
|
396
|
-
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';
|
|
397
339
|
this.fieldAlignment = (recTableColReceived.alignment != null) ? recTableColReceived.alignment.toLowerCase() : defaultTypeAlignment;
|
|
398
340
|
this.visible = (_a = recTableColReceived === null || recTableColReceived === void 0 ? void 0 : recTableColReceived.visible) !== null && _a !== void 0 ? _a : true;
|
|
399
341
|
this.sortable = (_b = recTableColReceived === null || recTableColReceived === void 0 ? void 0 : recTableColReceived.sortable) !== null && _b !== void 0 ? _b : false;
|
|
@@ -480,6 +422,8 @@ function formatCurrency(inputValue) {
|
|
|
480
422
|
return outputValue;
|
|
481
423
|
}
|
|
482
424
|
|
|
425
|
+
const DATE_TYPE = 'DATE';
|
|
426
|
+
const CURRENCY_TYPE = 'CURRENCY';
|
|
483
427
|
class TableRecordData {
|
|
484
428
|
constructor(recordReceived, recordDefinition, selectionFieldName = null) {
|
|
485
429
|
this.recordData = {};
|
|
@@ -514,10 +458,10 @@ class TableRecordData {
|
|
|
514
458
|
}
|
|
515
459
|
}
|
|
516
460
|
formatFieldValue(fieldType, fieldValue) {
|
|
517
|
-
if (fieldType ===
|
|
461
|
+
if (fieldType === CURRENCY_TYPE) {
|
|
518
462
|
return formatCurrency(fieldValue);
|
|
519
463
|
}
|
|
520
|
-
else if (fieldType ===
|
|
464
|
+
else if (fieldType === DATE_TYPE && fieldValue) {
|
|
521
465
|
return new Date(fieldValue).toISOString().split('T')[0];
|
|
522
466
|
}
|
|
523
467
|
return fieldValue || '';
|
|
@@ -601,6 +545,8 @@ class TableRecordData {
|
|
|
601
545
|
}
|
|
602
546
|
}
|
|
603
547
|
|
|
548
|
+
const TABLE_SORT_ASCENDING = 'asc';
|
|
549
|
+
const TABLE_SORT_DESCENDING = 'desc';
|
|
604
550
|
const TABLE_FILTER_TYPES = {
|
|
605
551
|
simpleFilterChange: 'SIMPLE_CHANGE',
|
|
606
552
|
simpleFilterFinish: 'SIMPLE_FINISH',
|
|
@@ -608,9 +554,9 @@ const TABLE_FILTER_TYPES = {
|
|
|
608
554
|
complexFilterRemove: 'COMPLEX_REMOVE',
|
|
609
555
|
};
|
|
610
556
|
class RecordTable extends FormElement {
|
|
611
|
-
constructor(tableReceived) {
|
|
557
|
+
constructor(tableReceived, formConfig) {
|
|
612
558
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
613
|
-
super(tableReceived);
|
|
559
|
+
super(tableReceived, formConfig);
|
|
614
560
|
this._inlineActionTrigger = new Subject();
|
|
615
561
|
this._globalActionTrigger = new Subject();
|
|
616
562
|
this._recordSelectionTrigger = new Subject();
|
|
@@ -620,7 +566,7 @@ class RecordTable extends FormElement {
|
|
|
620
566
|
this._tableColumnObj = {};
|
|
621
567
|
this._actionsObj = {};
|
|
622
568
|
this.allSelected = false;
|
|
623
|
-
this.elementType =
|
|
569
|
+
this.elementType = elementTypes.table;
|
|
624
570
|
this.waiting = false;
|
|
625
571
|
this.complexFilter = false;
|
|
626
572
|
this.currentPage = 1;
|
|
@@ -643,10 +589,10 @@ class RecordTable extends FormElement {
|
|
|
643
589
|
this.customAttributes = (_f = tableReceived === null || tableReceived === void 0 ? void 0 : tableReceived.customAttributes) !== null && _f !== void 0 ? _f : {};
|
|
644
590
|
this.sortable = (_g = tableReceived === null || tableReceived === void 0 ? void 0 : tableReceived.sortable) !== null && _g !== void 0 ? _g : false;
|
|
645
591
|
this.sorting = { columnName: '', direction: '' };
|
|
646
|
-
this.recordsPerPage =
|
|
592
|
+
this.recordsPerPage = formConfig.defaultRecordsPerPage;
|
|
647
593
|
if (tableReceived.fields) {
|
|
648
594
|
for (const columnReceived of tableReceived.fields) {
|
|
649
|
-
const columnDefinition = new RecordTableColumn(columnReceived);
|
|
595
|
+
const columnDefinition = new RecordTableColumn(columnReceived, this._formConfig);
|
|
650
596
|
this.columns.push(columnDefinition);
|
|
651
597
|
this._tableColumnObj[columnDefinition.fieldCode] = columnDefinition;
|
|
652
598
|
}
|
|
@@ -823,7 +769,7 @@ class RecordTable extends FormElement {
|
|
|
823
769
|
return (this._actionsObj && actionCode && this._actionsObj[actionCode])
|
|
824
770
|
? this._actionsObj[actionCode] : null;
|
|
825
771
|
}
|
|
826
|
-
getActions(actionClass =
|
|
772
|
+
getActions(actionClass = this._formConfig.tableActions.inline, actionTypes = null) {
|
|
827
773
|
return this._actions.filter(actionDef => {
|
|
828
774
|
const typeIncluded = (actionTypes) ? actionTypes.includes(actionDef.actionType) : true;
|
|
829
775
|
return actionDef.actionClass === actionClass && typeIncluded;
|
|
@@ -884,14 +830,14 @@ class RecordTable extends FormElement {
|
|
|
884
830
|
setRequiredOrder(columnField) {
|
|
885
831
|
if (columnField !== this.sorting.columnName) {
|
|
886
832
|
this.sorting.columnName = columnField;
|
|
887
|
-
this.sorting.direction =
|
|
833
|
+
this.sorting.direction = TABLE_SORT_ASCENDING;
|
|
888
834
|
}
|
|
889
835
|
else {
|
|
890
|
-
if (this.sorting.direction ===
|
|
891
|
-
this.sorting.direction =
|
|
836
|
+
if (this.sorting.direction === TABLE_SORT_ASCENDING) {
|
|
837
|
+
this.sorting.direction = TABLE_SORT_DESCENDING;
|
|
892
838
|
}
|
|
893
839
|
else {
|
|
894
|
-
this.sorting.direction =
|
|
840
|
+
this.sorting.direction = TABLE_SORT_ASCENDING;
|
|
895
841
|
}
|
|
896
842
|
}
|
|
897
843
|
}
|
|
@@ -912,7 +858,7 @@ class RecordTable extends FormElement {
|
|
|
912
858
|
else if (recordAColumn > recordBColumn) {
|
|
913
859
|
result = 1;
|
|
914
860
|
}
|
|
915
|
-
return direction ===
|
|
861
|
+
return direction === TABLE_SORT_ASCENDING ? result : -result;
|
|
916
862
|
}
|
|
917
863
|
}
|
|
918
864
|
|
|
@@ -1068,13 +1014,15 @@ class LibTableComponent {
|
|
|
1068
1014
|
this.hasActions = false;
|
|
1069
1015
|
}
|
|
1070
1016
|
ngOnInit() {
|
|
1071
|
-
|
|
1017
|
+
var _a;
|
|
1018
|
+
this.formConfig = (_a = this.tableObject) === null || _a === void 0 ? void 0 : _a._formConfig;
|
|
1019
|
+
this.tableFieldStyles = this.formConfig.tableFieldStyles;
|
|
1072
1020
|
this.selectable = this.tableObject.selectable;
|
|
1073
1021
|
this.hasActions = this.tableObject.hasActions;
|
|
1074
1022
|
this.tableObject.widget = this;
|
|
1075
|
-
this.inlineActions = this.tableObject.getActions(
|
|
1076
|
-
this.globalActions = this.tableObject.getActions(
|
|
1077
|
-
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);
|
|
1078
1026
|
this.start();
|
|
1079
1027
|
}
|
|
1080
1028
|
start() { }
|
|
@@ -1184,15 +1132,15 @@ class RecordFormSubSection {
|
|
|
1184
1132
|
let arrayToAdd = null;
|
|
1185
1133
|
const { type, code } = receivedElement;
|
|
1186
1134
|
switch (type) {
|
|
1187
|
-
case
|
|
1135
|
+
case elementTypes.field:
|
|
1188
1136
|
elementObject = formObject.getFieldObject(code);
|
|
1189
1137
|
arrayToAdd = this.subSectionFields;
|
|
1190
1138
|
break;
|
|
1191
|
-
case
|
|
1139
|
+
case elementTypes.table:
|
|
1192
1140
|
elementObject = formObject.getTableObject(code);
|
|
1193
1141
|
arrayToAdd = this.subSectionTables;
|
|
1194
1142
|
break;
|
|
1195
|
-
case
|
|
1143
|
+
case elementTypes.action:
|
|
1196
1144
|
elementObject = formObject.getActionObject(code);
|
|
1197
1145
|
arrayToAdd = this.subSectionActions;
|
|
1198
1146
|
break;
|
|
@@ -1330,12 +1278,12 @@ class RecordFormSection {
|
|
|
1330
1278
|
|
|
1331
1279
|
const HEADER$1 = 'HEADER';
|
|
1332
1280
|
class FormAction extends FormElement {
|
|
1333
|
-
constructor(actionDefinition) {
|
|
1281
|
+
constructor(actionDefinition, formConfig) {
|
|
1334
1282
|
var _a, _b;
|
|
1335
|
-
super(actionDefinition);
|
|
1283
|
+
super(actionDefinition, formConfig);
|
|
1336
1284
|
this._actionActivated = new Subject();
|
|
1337
1285
|
this.inProgress = false;
|
|
1338
|
-
this.elementType =
|
|
1286
|
+
this.elementType = elementTypes.action;
|
|
1339
1287
|
this.actionCode = actionDefinition.actionCode ? actionDefinition.actionCode.toString() : '';
|
|
1340
1288
|
this.actionName = actionDefinition.actionTitle;
|
|
1341
1289
|
this.iconName = actionDefinition.iconName || this.actionCode;
|
|
@@ -1363,58 +1311,9 @@ class FormAction extends FormElement {
|
|
|
1363
1311
|
}
|
|
1364
1312
|
|
|
1365
1313
|
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
1314
|
const DEFAULT_ERROR_TYPE = 'error';
|
|
1414
1315
|
const DEFAULT_CAPTURE_TYPE = 'INPUT';
|
|
1415
1316
|
const DEFAULT_ALIGNMENT = 'left';
|
|
1416
|
-
const MONITORED_ATTRIBUTES = ['_maxLength', '_onValidation', 'captureType', 'fieldTitle', 'fieldType',
|
|
1417
|
-
'errorMessage', 'errorType', 'errorCode', 'visibleLabel', 'fieldRequired', 'fieldOptions', '_fieldValue'];
|
|
1418
1317
|
const STD_MAX_LENGTH = 50;
|
|
1419
1318
|
const BIG_MAX_LENGTH = 500;
|
|
1420
1319
|
const fldAttr = {
|
|
@@ -1447,21 +1346,21 @@ const fldAttr = {
|
|
|
1447
1346
|
options: 'fieldOptions',
|
|
1448
1347
|
};
|
|
1449
1348
|
class FieldDescriptor extends FormElement {
|
|
1450
|
-
constructor(inputFieldReceived) {
|
|
1349
|
+
constructor(inputFieldReceived, formConfig) {
|
|
1451
1350
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
1452
|
-
super(inputFieldReceived);
|
|
1351
|
+
super(inputFieldReceived, formConfig);
|
|
1453
1352
|
this._editionFinish = new Subject();
|
|
1454
1353
|
this._editionPartial = new Subject();
|
|
1455
1354
|
this._detailRequest = new Subject();
|
|
1456
1355
|
this._attributeChange = new Subject();
|
|
1457
|
-
this.elementType =
|
|
1356
|
+
this.elementType = elementTypes.field;
|
|
1458
1357
|
const fld = (inputFieldReceived) ? inputFieldReceived : {};
|
|
1459
1358
|
this.setAttr(fldAttr.code, fld.fieldCode);
|
|
1460
1359
|
this.setAttr(fldAttr.title, (_a = fld.fieldTitle) !== null && _a !== void 0 ? _a : this.fieldCode);
|
|
1461
1360
|
this.setAttr(fldAttr.captureType, (_b = fld.captureType) !== null && _b !== void 0 ? _b : DEFAULT_CAPTURE_TYPE);
|
|
1462
1361
|
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;
|
|
1362
|
+
const defaultTypeAlignment = (this._formConfig.tableFieldStyles[this.fieldType] != null)
|
|
1363
|
+
? this._formConfig.tableFieldStyles[this.fieldType]['text-align'] : DEFAULT_ALIGNMENT;
|
|
1465
1364
|
const fieldAlignment = (fld.alignment != null) ? fld.alignment.toLowerCase() : defaultTypeAlignment;
|
|
1466
1365
|
this.setAttr(fldAttr.alignment, fieldAlignment);
|
|
1467
1366
|
this.setAttr(fldAttr.info, fld.info || '');
|
|
@@ -1482,7 +1381,7 @@ class FieldDescriptor extends FormElement {
|
|
|
1482
1381
|
this.setAttr(fldAttr.outputOnly, (_h = fld.outputOnly) !== null && _h !== void 0 ? _h : false);
|
|
1483
1382
|
const maxLength = (_j = fld.maxLength) !== null && _j !== void 0 ? _j : (this.captureType === 'TEXTAREA' ? BIG_MAX_LENGTH : STD_MAX_LENGTH);
|
|
1484
1383
|
this.setAttr(fldAttr.maxLength, maxLength);
|
|
1485
|
-
this.setAttr(fldAttr.intrinsicErrorMessage, (_k =
|
|
1384
|
+
this.setAttr(fldAttr.intrinsicErrorMessage, (_k = this._formConfig.fieldTypeErrMsg[this.fieldType]) !== null && _k !== void 0 ? _k : this._formConfig.fieldTypeErrMsg.DEFAULT);
|
|
1486
1385
|
this.setFieldType(fld.fieldTypeCode);
|
|
1487
1386
|
this.setEditable((_l = fld.editable) !== null && _l !== void 0 ? _l : true);
|
|
1488
1387
|
this.setVisibleLabel((_m = fld.visibleLabel) !== null && _m !== void 0 ? _m : true);
|
|
@@ -1518,13 +1417,13 @@ class FieldDescriptor extends FormElement {
|
|
|
1518
1417
|
this._editionPartial.next({ code: this.fieldCode, intrinsicValidation });
|
|
1519
1418
|
}
|
|
1520
1419
|
notifyEditionFinish() {
|
|
1521
|
-
var _a, _b, _c, _d;
|
|
1420
|
+
var _a, _b, _c, _d, _e;
|
|
1522
1421
|
let intrinsicValidation = true;
|
|
1523
|
-
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;
|
|
1524
1423
|
const fieldValue = this.getValue();
|
|
1525
1424
|
if (fieldValue && (fieldDefaultFormat || this.fieldFormat)) {
|
|
1526
|
-
intrinsicValidation = ((
|
|
1527
|
-
&& ((
|
|
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);
|
|
1528
1427
|
if (!intrinsicValidation) {
|
|
1529
1428
|
this.setError('99', this._intrinsicErrorMessage);
|
|
1530
1429
|
}
|
|
@@ -1532,16 +1431,15 @@ class FieldDescriptor extends FormElement {
|
|
|
1532
1431
|
this._editionFinish.next({ code: this.fieldCode, intrinsicValidation });
|
|
1533
1432
|
}
|
|
1534
1433
|
setAttr(name, value) {
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
}
|
|
1538
|
-
if (MONITORED_ATTRIBUTES.includes(name)) {
|
|
1434
|
+
this[name] = value;
|
|
1435
|
+
if (this._formConfig.monitoredFieldAttributes.includes(name)) {
|
|
1539
1436
|
this._attributeChange.next({ name, value });
|
|
1540
1437
|
}
|
|
1541
1438
|
}
|
|
1542
1439
|
notifyEditionDetailRequest() {
|
|
1543
1440
|
this._detailRequest.next(this.fieldCode);
|
|
1544
1441
|
}
|
|
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; }
|
|
1545
1443
|
setVisibleLabel(visibleLabel) { this.setAttr(fldAttr.visibleLabel, visibleLabel); }
|
|
1546
1444
|
showLabel() { this.setVisibleLabel(true); }
|
|
1547
1445
|
hideLabel() { this.setVisibleLabel(false); }
|
|
@@ -1570,7 +1468,7 @@ class FieldDescriptor extends FormElement {
|
|
|
1570
1468
|
if (fieldCurrentValue === undefined || fieldCurrentValue === null) {
|
|
1571
1469
|
return true;
|
|
1572
1470
|
}
|
|
1573
|
-
if ((this.fieldType ===
|
|
1471
|
+
if ((this.fieldType === this._formConfig.fieldTypes.array || this.fieldType === this._formConfig.fieldTypes.phone)
|
|
1574
1472
|
&& Array.isArray(fieldCurrentValue) && fieldCurrentValue.length === 0) {
|
|
1575
1473
|
return true;
|
|
1576
1474
|
}
|
|
@@ -1580,10 +1478,10 @@ class FieldDescriptor extends FormElement {
|
|
|
1580
1478
|
getValue() {
|
|
1581
1479
|
var _a;
|
|
1582
1480
|
switch (this.fieldType) {
|
|
1583
|
-
case
|
|
1481
|
+
case this._formConfig.fieldTypes.check:
|
|
1584
1482
|
return (_a = this._fieldValue) !== null && _a !== void 0 ? _a : false;
|
|
1585
1483
|
break;
|
|
1586
|
-
case
|
|
1484
|
+
case this._formConfig.fieldTypes.currency:
|
|
1587
1485
|
return this._fieldValue.replace(',', '');
|
|
1588
1486
|
break;
|
|
1589
1487
|
default:
|
|
@@ -1597,33 +1495,33 @@ class FieldDescriptor extends FormElement {
|
|
|
1597
1495
|
for (let index = 0; index < fieldKeys.length; index++) {
|
|
1598
1496
|
const attrName = fieldKeys[index];
|
|
1599
1497
|
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 ===
|
|
1498
|
+
(attrName === this._formConfig.apifieldattrs.visible) && this.setVisibility(attrValue);
|
|
1499
|
+
(attrName === this._formConfig.apifieldattrs.labelVisible) && this.setVisibleLabel(fld.visibleLabel);
|
|
1500
|
+
(attrName === this._formConfig.apifieldattrs.required) && this.setAttr(fldAttr.required, (_a = fld.required) !== null && _a !== void 0 ? _a : false);
|
|
1501
|
+
(attrName === this._formConfig.apifieldattrs.errorCode) && this.setAttr(fldAttr.errorCode, fld.errorCode);
|
|
1502
|
+
(attrName === this._formConfig.apifieldattrs.errorMessage) && this.setAttr(fldAttr.errorMessage, fld.errorMessage);
|
|
1503
|
+
(attrName === this._formConfig.apifieldattrs.tooltip) && this.setAttr(fldAttr.tooltipText, fld.tooltip);
|
|
1504
|
+
(attrName === this._formConfig.apifieldattrs.info) && this.setAttr(fldAttr.info, fld.info);
|
|
1505
|
+
(attrName === this._formConfig.apifieldattrs.editable) && this.setEditable(fld.editable);
|
|
1506
|
+
(attrName === this._formConfig.apifieldattrs.title) && this.setLabel(fld.fieldTitle.toString());
|
|
1507
|
+
(attrName === this._formConfig.apifieldattrs.value) && (this.setValue(fld._fieldValue) && this.setChanged(false));
|
|
1508
|
+
(attrName === this._formConfig.apifieldattrs.options) && this.setFieldOptions(fld.fieldOptions);
|
|
1509
|
+
(attrName === this._formConfig.apifieldattrs.captureType) && this.setAttr(fldAttr.captureType, fld.captureType || 'INPUT');
|
|
1510
|
+
(attrName === this._formConfig.apifieldattrs.type) && this.setFieldType(fld.fieldTypeCode);
|
|
1511
|
+
(attrName === this._formConfig.apifieldattrs.maxLength) && this.setAttr(fldAttr.maxLength, fld.maxLength);
|
|
1614
1512
|
}
|
|
1615
1513
|
}
|
|
1616
1514
|
setFieldType(inputFieldType) {
|
|
1617
1515
|
this.setAttr(fldAttr.type, inputFieldType);
|
|
1618
1516
|
}
|
|
1619
1517
|
format() {
|
|
1620
|
-
if (this.fieldType ===
|
|
1518
|
+
if (this.fieldType === this._formConfig.fieldTypes.currency) {
|
|
1621
1519
|
this.setAttr(fldAttr.value, formatCurrency(this._fieldValue));
|
|
1622
1520
|
}
|
|
1623
1521
|
}
|
|
1624
1522
|
setMinValue(minValue) {
|
|
1625
1523
|
var _a, _b, _c;
|
|
1626
|
-
if (this.fieldType ===
|
|
1524
|
+
if (this.fieldType === this._formConfig.fieldTypes.date
|
|
1627
1525
|
&& ((_a = this.widget) === null || _a === void 0 ? void 0 : _a.setMinValue)) {
|
|
1628
1526
|
this.setAttr(fldAttr.minValue, minValue);
|
|
1629
1527
|
if (!minValue) {
|
|
@@ -1637,7 +1535,7 @@ class FieldDescriptor extends FormElement {
|
|
|
1637
1535
|
}
|
|
1638
1536
|
setMaxValue(maxValue) {
|
|
1639
1537
|
var _a, _b, _c;
|
|
1640
|
-
if (this.fieldType ===
|
|
1538
|
+
if (this.fieldType === this._formConfig.fieldTypes.date
|
|
1641
1539
|
&& ((_a = this.widget) === null || _a === void 0 ? void 0 : _a.setMaxValue)) {
|
|
1642
1540
|
this.setAttr(fldAttr.maxValue, maxValue);
|
|
1643
1541
|
if (!maxValue) {
|
|
@@ -1669,11 +1567,11 @@ class FieldDescriptor extends FormElement {
|
|
|
1669
1567
|
fieldOptions = (fieldOptions && Array.isArray(fieldOptions)
|
|
1670
1568
|
&& fieldOptions.length > 0) ? fieldOptions : [];
|
|
1671
1569
|
this.setAttr(fldAttr.options, fieldOptions);
|
|
1672
|
-
if (this.fieldType ===
|
|
1570
|
+
if (this.fieldType === this._formConfig.fieldTypes.array && this.widget) {
|
|
1673
1571
|
return (_a = this.widget) === null || _a === void 0 ? void 0 : _a.refereshContent();
|
|
1674
1572
|
}
|
|
1675
1573
|
if (this._fieldValue) {
|
|
1676
|
-
if (this.fieldType ===
|
|
1574
|
+
if (this.fieldType === this._formConfig.fieldTypes.array && Array.isArray(this._fieldValue)) {
|
|
1677
1575
|
const fieldValue = (_b = this._fieldValue) === null || _b === void 0 ? void 0 : _b.filter(item => this.fieldOptions.find(opt => opt.fieldOptionId === item));
|
|
1678
1576
|
this.setAttr(fldAttr.value, fieldValue);
|
|
1679
1577
|
}
|
|
@@ -1702,10 +1600,10 @@ class FieldDescriptor extends FormElement {
|
|
|
1702
1600
|
case 'BOOLEAN':
|
|
1703
1601
|
newFinalValue = !!newValue;
|
|
1704
1602
|
break;
|
|
1705
|
-
case
|
|
1603
|
+
case this._formConfig.fieldTypes.check:
|
|
1706
1604
|
newFinalValue = !!newValue;
|
|
1707
1605
|
break;
|
|
1708
|
-
case
|
|
1606
|
+
case this._formConfig.fieldTypes.array:
|
|
1709
1607
|
if (newValue === null || newValue === '') {
|
|
1710
1608
|
newFinalValue = [];
|
|
1711
1609
|
}
|
|
@@ -1719,7 +1617,7 @@ class FieldDescriptor extends FormElement {
|
|
|
1719
1617
|
newFinalValue = newValue;
|
|
1720
1618
|
}
|
|
1721
1619
|
break;
|
|
1722
|
-
case
|
|
1620
|
+
case this._formConfig.fieldTypes.map:
|
|
1723
1621
|
newFinalValue = newValue;
|
|
1724
1622
|
if (newFinalValue && this.widget && widgetUpdate) {
|
|
1725
1623
|
const latitude = parseFloat(newFinalValue[0]);
|
|
@@ -1727,7 +1625,7 @@ class FieldDescriptor extends FormElement {
|
|
|
1727
1625
|
(_a = this.widget) === null || _a === void 0 ? void 0 : _a.setLocation(latitude, longitude);
|
|
1728
1626
|
}
|
|
1729
1627
|
break;
|
|
1730
|
-
case
|
|
1628
|
+
case this._formConfig.fieldTypes.currency:
|
|
1731
1629
|
newFinalValue = formatCurrency(this._fieldValue);
|
|
1732
1630
|
break;
|
|
1733
1631
|
default:
|
|
@@ -1745,13 +1643,14 @@ class FieldDescriptor extends FormElement {
|
|
|
1745
1643
|
const HEADER = 'HEADER';
|
|
1746
1644
|
const NO_ERROR = '00';
|
|
1747
1645
|
class FormStructureAndData {
|
|
1748
|
-
constructor(definitionReceived) {
|
|
1646
|
+
constructor(definitionReceived, formConfig) {
|
|
1749
1647
|
this._fieldsObj = {};
|
|
1750
1648
|
this._actionsObj = {};
|
|
1751
1649
|
this._tableObj = {};
|
|
1752
1650
|
this._sectionsObj = {};
|
|
1753
1651
|
this._immutableData = {};
|
|
1754
1652
|
this._extraInfo = {};
|
|
1653
|
+
this._formConfig = formConfig;
|
|
1755
1654
|
this.state = '';
|
|
1756
1655
|
this._actions = [];
|
|
1757
1656
|
this._fields = [];
|
|
@@ -1785,7 +1684,7 @@ class FormStructureAndData {
|
|
|
1785
1684
|
return Object.assign(Object.assign({}, objDef), { visibleStates, enabledStates });
|
|
1786
1685
|
});
|
|
1787
1686
|
for (const actionReceived of formActions) {
|
|
1788
|
-
const globalAction = new FormAction(actionReceived);
|
|
1687
|
+
const globalAction = new FormAction(actionReceived, this._formConfig);
|
|
1789
1688
|
const globalActionCode = globalAction.actionCode;
|
|
1790
1689
|
if (globalActionCode) {
|
|
1791
1690
|
this._actions.push(globalAction);
|
|
@@ -1806,7 +1705,7 @@ class FormStructureAndData {
|
|
|
1806
1705
|
return Object.assign(Object.assign({}, objDef), { visibleStates, enabledStates });
|
|
1807
1706
|
});
|
|
1808
1707
|
for (const fieldReceived of formFields) {
|
|
1809
|
-
const fieldToAdd = new FieldDescriptor(fieldReceived);
|
|
1708
|
+
const fieldToAdd = new FieldDescriptor(fieldReceived, this._formConfig);
|
|
1810
1709
|
const fieldCode = fieldToAdd.fieldCode;
|
|
1811
1710
|
if (fieldCode) {
|
|
1812
1711
|
this._fields.push(fieldToAdd);
|
|
@@ -1825,12 +1724,12 @@ class FormStructureAndData {
|
|
|
1825
1724
|
enabledStates = [...visibleStates];
|
|
1826
1725
|
}
|
|
1827
1726
|
if (!visibleStates || visibleStates.length === 0) {
|
|
1828
|
-
visibleStates =
|
|
1727
|
+
visibleStates = this._formConfig.defaultStateFlow.states;
|
|
1829
1728
|
}
|
|
1830
1729
|
return Object.assign(Object.assign({}, objDef), { visibleStates, enabledStates });
|
|
1831
1730
|
});
|
|
1832
1731
|
for (const tableReceived of tables) {
|
|
1833
|
-
const tableToAdd = new RecordTable(tableReceived);
|
|
1732
|
+
const tableToAdd = new RecordTable(tableReceived, this._formConfig);
|
|
1834
1733
|
const tableCode = tableToAdd.tableCode;
|
|
1835
1734
|
if (tableCode) {
|
|
1836
1735
|
this._tables.push(tableToAdd);
|
|
@@ -1882,7 +1781,7 @@ class FormStructureAndData {
|
|
|
1882
1781
|
}
|
|
1883
1782
|
setStateFlow(states, transitions, defaultState) {
|
|
1884
1783
|
if (!states || !transitions) {
|
|
1885
|
-
this._stateFlow = JSON.parse(JSON.stringify(
|
|
1784
|
+
this._stateFlow = JSON.parse(JSON.stringify(this._formConfig.defaultStateFlow));
|
|
1886
1785
|
return;
|
|
1887
1786
|
}
|
|
1888
1787
|
this._stateFlow.states = states;
|
|
@@ -2423,7 +2322,6 @@ class BasicFormComponent {
|
|
|
2423
2322
|
this.transitionToken = null;
|
|
2424
2323
|
this.inputDataFields = [];
|
|
2425
2324
|
this.extraData = null;
|
|
2426
|
-
this.componentConstants = componentConstants;
|
|
2427
2325
|
this.definitionObtained = false;
|
|
2428
2326
|
this.formVisible = false;
|
|
2429
2327
|
this.inServerProcess = false;
|
|
@@ -2445,6 +2343,9 @@ class BasicFormComponent {
|
|
|
2445
2343
|
this.cleanStart();
|
|
2446
2344
|
this.customPreProcessing();
|
|
2447
2345
|
}
|
|
2346
|
+
setConfig(formConfig) {
|
|
2347
|
+
this.formConfig = formConfig;
|
|
2348
|
+
}
|
|
2448
2349
|
cleanStart() {
|
|
2449
2350
|
this._errorType = '';
|
|
2450
2351
|
this.errorCode = '';
|
|
@@ -2733,7 +2634,7 @@ class BasicFormComponent {
|
|
|
2733
2634
|
this.inServerProcess = true;
|
|
2734
2635
|
const formDefinition = yield this.formManagerService.getFormDefinition(this.name);
|
|
2735
2636
|
this.inServerProcess = false;
|
|
2736
|
-
this.formStructure = new FormStructureAndData(formDefinition);
|
|
2637
|
+
this.formStructure = new FormStructureAndData(formDefinition, this.formConfig);
|
|
2737
2638
|
this.definitionObtained = true;
|
|
2738
2639
|
}
|
|
2739
2640
|
else {
|
|
@@ -2759,7 +2660,7 @@ class BasicFormComponent {
|
|
|
2759
2660
|
this.setFieldValue(fieldCode, fieldValue);
|
|
2760
2661
|
}
|
|
2761
2662
|
}
|
|
2762
|
-
const recordResponse = yield this.requestFormAction(
|
|
2663
|
+
const recordResponse = yield this.requestFormAction(formActions.getData);
|
|
2763
2664
|
this.checkErrorRecordReceived(recordResponse);
|
|
2764
2665
|
this.formVisible = true;
|
|
2765
2666
|
this.subscribeSectionActivation();
|
|
@@ -2779,7 +2680,7 @@ class BasicFormComponent {
|
|
|
2779
2680
|
this.errorDetail = recordResponse.errorDetail;
|
|
2780
2681
|
}
|
|
2781
2682
|
errorOccured() {
|
|
2782
|
-
return (this.errorCode !==
|
|
2683
|
+
return (this.errorCode !== '00');
|
|
2783
2684
|
}
|
|
2784
2685
|
changeState(state) { return this.formStructure.changeState(state); }
|
|
2785
2686
|
changeFormMode(state) { return this.changeState(state); }
|
|
@@ -3060,7 +2961,7 @@ class BasicFormComponent {
|
|
|
3060
2961
|
if (fieldObj.backend) {
|
|
3061
2962
|
fieldObj.validating = true;
|
|
3062
2963
|
validationResult = yield this
|
|
3063
|
-
.requestFormAction(
|
|
2964
|
+
.requestFormAction(formActions.validate, fieldObj.fieldCode);
|
|
3064
2965
|
finish = !this.errorOccured();
|
|
3065
2966
|
}
|
|
3066
2967
|
if (finish) {
|
|
@@ -3249,7 +3150,7 @@ class BasicFormComponent {
|
|
|
3249
3150
|
actionCode
|
|
3250
3151
|
};
|
|
3251
3152
|
actionResult = yield this
|
|
3252
|
-
.requestFormAction(
|
|
3153
|
+
.requestFormAction(formActions.tableAction, actionSubject);
|
|
3253
3154
|
finish = !this.errorOccured();
|
|
3254
3155
|
}
|
|
3255
3156
|
if (finish) {
|
|
@@ -3326,13 +3227,13 @@ class BasicFormComponent {
|
|
|
3326
3227
|
if (action.backend) {
|
|
3327
3228
|
const actionSubject = {
|
|
3328
3229
|
tableCode,
|
|
3329
|
-
actionType:
|
|
3230
|
+
actionType: this.formConfig.tableActions.inline,
|
|
3330
3231
|
actionCode,
|
|
3331
3232
|
tableRecordId: recordId,
|
|
3332
3233
|
tableRecordData: recordData
|
|
3333
3234
|
};
|
|
3334
3235
|
actionResult = yield this
|
|
3335
|
-
.requestFormAction(
|
|
3236
|
+
.requestFormAction(formActions.tableAction, actionSubject);
|
|
3336
3237
|
finish = !this.errorOccured();
|
|
3337
3238
|
}
|
|
3338
3239
|
if (finish) {
|
|
@@ -3405,13 +3306,13 @@ class BasicFormComponent {
|
|
|
3405
3306
|
if (tableObject.selectionBackend) {
|
|
3406
3307
|
const actionSubject = {
|
|
3407
3308
|
tableCode,
|
|
3408
|
-
actionType:
|
|
3309
|
+
actionType: this.formConfig.tableActions.rowSelection,
|
|
3409
3310
|
actionCode: null,
|
|
3410
3311
|
tableRecordId: recordId,
|
|
3411
3312
|
tableRecordData: recordData
|
|
3412
3313
|
};
|
|
3413
3314
|
actionResult = yield this
|
|
3414
|
-
.requestFormAction(
|
|
3315
|
+
.requestFormAction(formActions.tableAction, actionSubject);
|
|
3415
3316
|
finish = !this.errorOccured();
|
|
3416
3317
|
}
|
|
3417
3318
|
if (finish) {
|
|
@@ -3485,12 +3386,12 @@ class BasicFormComponent {
|
|
|
3485
3386
|
if (action.backend) {
|
|
3486
3387
|
const actionSubject = {
|
|
3487
3388
|
tableCode,
|
|
3488
|
-
actionType:
|
|
3389
|
+
actionType: this.formConfig.tableActions.selection,
|
|
3489
3390
|
actionCode,
|
|
3490
3391
|
selectedRecords
|
|
3491
3392
|
};
|
|
3492
3393
|
actionResult = yield this
|
|
3493
|
-
.requestFormAction(
|
|
3394
|
+
.requestFormAction(formActions.tableAction, actionSubject);
|
|
3494
3395
|
finish = !this.errorOccured();
|
|
3495
3396
|
}
|
|
3496
3397
|
if (finish) {
|
|
@@ -3548,7 +3449,7 @@ class BasicFormComponent {
|
|
|
3548
3449
|
tableObject.putOnWait();
|
|
3549
3450
|
const actionSubject = { tableCode };
|
|
3550
3451
|
const actionResult = yield this
|
|
3551
|
-
.requestFormAction(
|
|
3452
|
+
.requestFormAction(formActions.getTableData, actionSubject);
|
|
3552
3453
|
if (this.errorOccured()) {
|
|
3553
3454
|
this.displayTableServerError();
|
|
3554
3455
|
}
|
|
@@ -3582,15 +3483,15 @@ class BasicFormComponent {
|
|
|
3582
3483
|
this.resetError();
|
|
3583
3484
|
const completeFields = this.checkSectionRequiredFields(sectionCode, reqFieldMessage);
|
|
3584
3485
|
if (!completeFields) {
|
|
3585
|
-
this.setError(
|
|
3486
|
+
this.setError(this.formConfig.formStandardErrors.typeWarning, this.formConfig.formStandardErrors.validationTitle, this.formConfig.formStandardErrors.requiredFields);
|
|
3586
3487
|
return;
|
|
3587
3488
|
}
|
|
3588
3489
|
let validationError = false;
|
|
3589
3490
|
const requiredEmptyFields = this.getRequiredEmptyFields(null, sectionCode);
|
|
3590
3491
|
if (requiredEmptyFields.length > 0) {
|
|
3591
3492
|
validationError = true;
|
|
3592
|
-
this.setError(
|
|
3593
|
-
this.tagFieldsWithError(requiredEmptyFields, null,
|
|
3493
|
+
this.setError(this.formConfig.formStandardErrors.typeWarning, this.formConfig.formStandardErrors.validationTitle, this.formConfig.formStandardErrors.requiredFields);
|
|
3494
|
+
this.tagFieldsWithError(requiredEmptyFields, null, this.formConfig.formStandardErrors.requiredField);
|
|
3594
3495
|
for (const fieldCode of requiredEmptyFields) {
|
|
3595
3496
|
const requiredEmptyField = this.getField(fieldCode);
|
|
3596
3497
|
if (requiredEmptyField && requiredEmptyField.widget
|
|
@@ -3603,7 +3504,7 @@ class BasicFormComponent {
|
|
|
3603
3504
|
const validationIssueFields = this.getFieldsWithValidationIssues(null, sectionCode);
|
|
3604
3505
|
if (!validationError && validationIssueFields.length > 0) {
|
|
3605
3506
|
validationError = true;
|
|
3606
|
-
this.setError(
|
|
3507
|
+
this.setError(this.formConfig.formStandardErrors.typeWarning, this.formConfig.formStandardErrors.validationTitle, this.formConfig.formStandardErrors.validationFields);
|
|
3607
3508
|
for (const fieldCode of validationIssueFields) {
|
|
3608
3509
|
const validationIssueField = this.getField(fieldCode);
|
|
3609
3510
|
if (validationIssueField && validationIssueField.widget
|
|
@@ -3719,13 +3620,13 @@ class BasicFormComponent {
|
|
|
3719
3620
|
const requiredEmptyFields = this.getRequiredEmptyFields(recordCaptureFields, null);
|
|
3720
3621
|
if (requiredEmptyFields.length > 0) {
|
|
3721
3622
|
validationOk = false;
|
|
3722
|
-
this.setError(
|
|
3723
|
-
this.tagFieldsWithError(requiredEmptyFields, null,
|
|
3623
|
+
this.setError(this.formConfig.formStandardErrors.typeWarning, this.formConfig.formStandardErrors.validationTitle, this.formConfig.formStandardErrors.requiredFields);
|
|
3624
|
+
this.tagFieldsWithError(requiredEmptyFields, null, this.formConfig.formStandardErrors.requiredField);
|
|
3724
3625
|
}
|
|
3725
3626
|
const validationIssueFields = this.getFieldsWithValidationIssues(recordCaptureFields, null);
|
|
3726
3627
|
if (validationIssueFields.length > 0) {
|
|
3727
3628
|
validationOk = false;
|
|
3728
|
-
this.setError(
|
|
3629
|
+
this.setError(this.formConfig.formStandardErrors.typeWarning, this.formConfig.formStandardErrors.validationTitle, this.formConfig.formStandardErrors.validationFields);
|
|
3729
3630
|
}
|
|
3730
3631
|
return validationOk;
|
|
3731
3632
|
}
|