tuain-ng-forms-lib 0.12.22 → 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 +287 -318
- 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 +146 -166
- package/esm2015/lib/classes/forms/form.constants.js +11 -82
- package/esm2015/lib/classes/forms/form.js +8 -8
- package/esm2015/lib/classes/forms/subsection.js +6 -6
- package/esm2015/lib/classes/forms/table/column.js +5 -5
- package/esm2015/lib/classes/forms/table/row-data.js +6 -4
- package/esm2015/lib/classes/forms/table/table.js +15 -13
- package/esm2015/lib/components/elements/action.component.js +3 -1
- package/esm2015/lib/components/elements/field.component.js +45 -7
- package/esm2015/lib/components/elements/layout/element.component.js +3 -6
- package/esm2015/lib/components/elements/layout/form-error.component.js +1 -1
- package/esm2015/lib/components/elements/tables/table.component.js +7 -7
- package/esm2015/lib/components/forms/basic-form.js +24 -22
- package/fesm2015/tuain-ng-forms-lib.js +282 -323
- package/fesm2015/tuain-ng-forms-lib.js.map +1 -1
- package/lib/classes/forms/action.d.ts +1 -1
- package/lib/classes/forms/element.d.ts +3 -2
- package/lib/classes/forms/field.d.ts +20 -14
- package/lib/classes/forms/form.constants.d.ts +10 -74
- package/lib/classes/forms/form.d.ts +2 -1
- package/lib/classes/forms/table/column.d.ts +2 -1
- package/lib/classes/forms/table/table.d.ts +1 -1
- package/lib/components/elements/action.component.d.ts +1 -0
- package/lib/components/elements/field.component.d.ts +17 -2
- package/lib/components/elements/layout/element.component.d.ts +1 -2
- package/lib/components/elements/layout/form-error.component.d.ts +0 -1
- package/lib/components/elements/tables/table.component.d.ts +1 -0
- package/lib/components/forms/basic-form.d.ts +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,106 +51,52 @@ ActionComponent.propDecorators = {
|
|
|
49
51
|
showLabel: [{ type: Input }]
|
|
50
52
|
};
|
|
51
53
|
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
FORMERROR_TYPE_WARNING: 'WARNING',
|
|
66
|
-
FORMERROR_REQUIRED_FIELDS: 'Todos los campos requeridos deben ser diligenciados',
|
|
67
|
-
FORMERROR_VALIDATION_TITLE: 'Advertencia',
|
|
68
|
-
FORMERROR_VALIDATION_FIELDS: 'Existen campos con problemas de validación',
|
|
69
|
-
// Valores para los controles de navegació
|
|
70
|
-
FORMNAVIGATION_FIRST: 'first',
|
|
71
|
-
FORMNAVIGATION_PREVGROUP: 'prevgroup',
|
|
72
|
-
FORMNAVIGATION_NEXTGROUP: 'nextgroup',
|
|
73
|
-
FORMNAVIGATION_LAST: 'last',
|
|
74
|
-
FIELDTYPE_ARRAY: 'ARRAY',
|
|
75
|
-
FIELDTYPE_CHECK: 'CHECK',
|
|
76
|
-
FIELDTYPE_DATE: 'DATE',
|
|
77
|
-
FIELDTYPE_MAP: 'MAP',
|
|
78
|
-
FIELDTYPE_CURRENCY: 'CURRENCY',
|
|
79
|
-
FIELDTYPE_SELECT: 'SELECT',
|
|
80
|
-
FIELDTYPE_TEXT: 'TEXT',
|
|
81
|
-
FIELD_REQUIRED_MESSAGE: 'Campo requerido',
|
|
82
|
-
FORMTABLEACTION_SORT: 'SORT',
|
|
83
|
-
FORMTABLEACTION_REFRESH: 'REFRESH',
|
|
84
|
-
FORMTABLEACTION_NAVIGATE: 'NAVIGATE',
|
|
85
|
-
FORMTABLEACTION_INLINE: 'INLINE',
|
|
86
|
-
FORMTABLEACTION_GLOBAL: 'GLOBAL',
|
|
87
|
-
FORMTABLEACTION_ROWSELECTION: 'ROWSELECTION',
|
|
88
|
-
FORMTABLEACTION_SELECTION: 'SELECTION',
|
|
89
|
-
TABLE_SORT_ASCENDING: 'asc',
|
|
90
|
-
TABLE_SORT_DESCENDING: 'desc',
|
|
91
|
-
SERVICE_ERRORCODE_NOERROR: '00',
|
|
54
|
+
const MONITORED_ATTRIBUTES = {
|
|
55
|
+
_maxLength: 'maxLength',
|
|
56
|
+
_onValidation: 'onValidation',
|
|
57
|
+
_fieldValue: 'value',
|
|
58
|
+
captureType: 'captureType',
|
|
59
|
+
fieldTitle: 'title',
|
|
60
|
+
fieldType: 'type',
|
|
61
|
+
errorMessage: 'errorMessage',
|
|
62
|
+
errorType: 'errorType',
|
|
63
|
+
errorCode: 'errorCode',
|
|
64
|
+
visibleLabel: 'visibleLabel',
|
|
65
|
+
fieldRequired: 'required',
|
|
66
|
+
fieldOptions: 'options',
|
|
92
67
|
};
|
|
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
68
|
class FieldComponent {
|
|
147
|
-
constructor() {
|
|
148
|
-
this.componentConstants = Object.assign({}, componentConstants);
|
|
149
|
-
}
|
|
150
69
|
ngOnInit() {
|
|
151
|
-
|
|
70
|
+
var _a;
|
|
71
|
+
if (this.fieldObject) {
|
|
72
|
+
this.formConfig = (_a = this.fieldObject) === null || _a === void 0 ? void 0 : _a._formConfig;
|
|
73
|
+
// Atributos estáticos
|
|
74
|
+
this.code = this.fieldObject.fieldCode;
|
|
75
|
+
this.fieldInfo = this.fieldObject.fieldInfo;
|
|
76
|
+
this.fieldAlignment = this.fieldObject.fieldAlignment;
|
|
77
|
+
this.tooltipText = this.fieldObject.tooltipText;
|
|
78
|
+
// Cargue inicial
|
|
79
|
+
this.maxLength = this.fieldObject._maxLength;
|
|
80
|
+
this.onValidation = this.fieldObject._onValidation;
|
|
81
|
+
this.value = this.fieldObject._fieldValue;
|
|
82
|
+
this.captureType = this.fieldObject.captureType;
|
|
83
|
+
this.title = this.fieldObject.fieldTitle;
|
|
84
|
+
this.type = this.fieldObject.fieldType;
|
|
85
|
+
this.errorMessage = this.fieldObject.errorMessage;
|
|
86
|
+
this.errorType = this.fieldObject.errorType;
|
|
87
|
+
this.errorCode = this.fieldObject.errorCode;
|
|
88
|
+
this.visibleLabel = this.fieldObject.visibleLabel;
|
|
89
|
+
this.required = this.fieldObject.fieldRequired;
|
|
90
|
+
this.options = this.fieldObject.fieldOptions;
|
|
91
|
+
this.fieldObject.widget = this;
|
|
92
|
+
// Atributos dinámicos
|
|
93
|
+
this.fieldObject.attributeChange.subscribe(event => {
|
|
94
|
+
const { name, value } = event;
|
|
95
|
+
if (this[MONITORED_ATTRIBUTES[name]]) {
|
|
96
|
+
this[MONITORED_ATTRIBUTES[name]] = value;
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
}
|
|
152
100
|
this.start();
|
|
153
101
|
}
|
|
154
102
|
start() { }
|
|
@@ -173,17 +121,15 @@ FieldComponent.decorators = [
|
|
|
173
121
|
template: `<ng-content></ng-content>`
|
|
174
122
|
},] }
|
|
175
123
|
];
|
|
176
|
-
FieldComponent.ctorParameters = () => [];
|
|
177
124
|
FieldComponent.propDecorators = {
|
|
178
125
|
fieldObject: [{ type: Input }],
|
|
179
126
|
disabled: [{ type: Input }]
|
|
180
127
|
};
|
|
181
128
|
|
|
182
129
|
class ElementComponent {
|
|
183
|
-
constructor() {
|
|
184
|
-
this.componentConstants = Object.assign({}, componentConstants);
|
|
185
|
-
}
|
|
186
130
|
ngOnInit() {
|
|
131
|
+
var _a;
|
|
132
|
+
this.formConfig = (_a = this.formElement) === null || _a === void 0 ? void 0 : _a._formConfig;
|
|
187
133
|
this.start();
|
|
188
134
|
}
|
|
189
135
|
start() { }
|
|
@@ -204,7 +150,6 @@ ElementComponent.decorators = [
|
|
|
204
150
|
template: `<ng-content></ng-content>`
|
|
205
151
|
},] }
|
|
206
152
|
];
|
|
207
|
-
ElementComponent.ctorParameters = () => [];
|
|
208
153
|
ElementComponent.propDecorators = {
|
|
209
154
|
formElement: [{ type: Input }],
|
|
210
155
|
formManager: [{ type: Input }]
|
|
@@ -300,9 +245,33 @@ class Filter {
|
|
|
300
245
|
}
|
|
301
246
|
}
|
|
302
247
|
|
|
248
|
+
const elementTypes = {
|
|
249
|
+
action: 'ACTION',
|
|
250
|
+
field: 'FIELD',
|
|
251
|
+
table: 'TABLE',
|
|
252
|
+
};
|
|
253
|
+
const formActions = {
|
|
254
|
+
tableAction: 'TABLEACTION',
|
|
255
|
+
getData: 'GETDATA',
|
|
256
|
+
getTableData: 'GETTABLEDATA',
|
|
257
|
+
validate: 'VALIDATE',
|
|
258
|
+
};
|
|
259
|
+
const operators = {
|
|
260
|
+
G: '>',
|
|
261
|
+
L: '<',
|
|
262
|
+
GE: '>=',
|
|
263
|
+
LE: '<=',
|
|
264
|
+
EQ: '==',
|
|
265
|
+
NOT_EQ: '!=',
|
|
266
|
+
CONTENT: 'Contiene',
|
|
267
|
+
NOT_CONTENT: 'No Contiene',
|
|
268
|
+
BETWEEN: 'Entre',
|
|
269
|
+
};
|
|
270
|
+
|
|
303
271
|
class FormElement {
|
|
304
|
-
constructor(elementDefinition) {
|
|
272
|
+
constructor(elementDefinition, formConfig) {
|
|
305
273
|
var _a, _b;
|
|
274
|
+
this._formConfig = formConfig;
|
|
306
275
|
this._isForced = false;
|
|
307
276
|
this.setVisibleStates(elementDefinition.visibleStates);
|
|
308
277
|
this.setEnabledStates(elementDefinition.enabledStates);
|
|
@@ -311,9 +280,9 @@ class FormElement {
|
|
|
311
280
|
this.setVisibility((_b = elementDefinition === null || elementDefinition === void 0 ? void 0 : elementDefinition.visible) !== null && _b !== void 0 ? _b : true);
|
|
312
281
|
this.widget = null;
|
|
313
282
|
}
|
|
314
|
-
isField() { return this.
|
|
315
|
-
isAction() { return this.
|
|
316
|
-
isTable() { return this.
|
|
283
|
+
isField() { return this.elementType === elementTypes.field; }
|
|
284
|
+
isAction() { return this.elementType === elementTypes.action; }
|
|
285
|
+
isTable() { return this.elementType === elementTypes.table; }
|
|
317
286
|
setVisibleStates(newStates) {
|
|
318
287
|
const visibleStates = (!Array.isArray(newStates) && typeof newStates === 'string')
|
|
319
288
|
? newStates.split(',').map(state => state.trim()).filter(state => state.length > 0)
|
|
@@ -359,13 +328,14 @@ class FormElement {
|
|
|
359
328
|
}
|
|
360
329
|
|
|
361
330
|
class RecordTableColumn {
|
|
362
|
-
constructor(recTableColReceived) {
|
|
331
|
+
constructor(recTableColReceived, formConfig) {
|
|
363
332
|
var _a, _b, _c;
|
|
333
|
+
this._formConfig = formConfig;
|
|
364
334
|
if (recTableColReceived) {
|
|
365
335
|
this.fieldCode = recTableColReceived.fieldCode;
|
|
366
336
|
this.fieldTitle = recTableColReceived.fieldTitle;
|
|
367
|
-
this.fieldType = recTableColReceived.fieldTypeCode ||
|
|
368
|
-
const defaultTypeAlignment = (tableFieldStyles[this.fieldType] != null) ? tableFieldStyles[this.fieldType]['text-align'] : 'left';
|
|
337
|
+
this.fieldType = recTableColReceived.fieldTypeCode || this._formConfig.fieldTypes.text;
|
|
338
|
+
const defaultTypeAlignment = (this._formConfig.tableFieldStyles[this.fieldType] != null) ? this._formConfig.tableFieldStyles[this.fieldType]['text-align'] : 'left';
|
|
369
339
|
this.fieldAlignment = (recTableColReceived.alignment != null) ? recTableColReceived.alignment.toLowerCase() : defaultTypeAlignment;
|
|
370
340
|
this.visible = (_a = recTableColReceived === null || recTableColReceived === void 0 ? void 0 : recTableColReceived.visible) !== null && _a !== void 0 ? _a : true;
|
|
371
341
|
this.sortable = (_b = recTableColReceived === null || recTableColReceived === void 0 ? void 0 : recTableColReceived.sortable) !== null && _b !== void 0 ? _b : false;
|
|
@@ -452,6 +422,8 @@ function formatCurrency(inputValue) {
|
|
|
452
422
|
return outputValue;
|
|
453
423
|
}
|
|
454
424
|
|
|
425
|
+
const DATE_TYPE = 'DATE';
|
|
426
|
+
const CURRENCY_TYPE = 'CURRENCY';
|
|
455
427
|
class TableRecordData {
|
|
456
428
|
constructor(recordReceived, recordDefinition, selectionFieldName = null) {
|
|
457
429
|
this.recordData = {};
|
|
@@ -486,10 +458,10 @@ class TableRecordData {
|
|
|
486
458
|
}
|
|
487
459
|
}
|
|
488
460
|
formatFieldValue(fieldType, fieldValue) {
|
|
489
|
-
if (fieldType ===
|
|
461
|
+
if (fieldType === CURRENCY_TYPE) {
|
|
490
462
|
return formatCurrency(fieldValue);
|
|
491
463
|
}
|
|
492
|
-
else if (fieldType ===
|
|
464
|
+
else if (fieldType === DATE_TYPE && fieldValue) {
|
|
493
465
|
return new Date(fieldValue).toISOString().split('T')[0];
|
|
494
466
|
}
|
|
495
467
|
return fieldValue || '';
|
|
@@ -573,6 +545,8 @@ class TableRecordData {
|
|
|
573
545
|
}
|
|
574
546
|
}
|
|
575
547
|
|
|
548
|
+
const TABLE_SORT_ASCENDING = 'asc';
|
|
549
|
+
const TABLE_SORT_DESCENDING = 'desc';
|
|
576
550
|
const TABLE_FILTER_TYPES = {
|
|
577
551
|
simpleFilterChange: 'SIMPLE_CHANGE',
|
|
578
552
|
simpleFilterFinish: 'SIMPLE_FINISH',
|
|
@@ -580,9 +554,9 @@ const TABLE_FILTER_TYPES = {
|
|
|
580
554
|
complexFilterRemove: 'COMPLEX_REMOVE',
|
|
581
555
|
};
|
|
582
556
|
class RecordTable extends FormElement {
|
|
583
|
-
constructor(tableReceived) {
|
|
557
|
+
constructor(tableReceived, formConfig) {
|
|
584
558
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
585
|
-
super(tableReceived);
|
|
559
|
+
super(tableReceived, formConfig);
|
|
586
560
|
this._inlineActionTrigger = new Subject();
|
|
587
561
|
this._globalActionTrigger = new Subject();
|
|
588
562
|
this._recordSelectionTrigger = new Subject();
|
|
@@ -592,7 +566,7 @@ class RecordTable extends FormElement {
|
|
|
592
566
|
this._tableColumnObj = {};
|
|
593
567
|
this._actionsObj = {};
|
|
594
568
|
this.allSelected = false;
|
|
595
|
-
this.
|
|
569
|
+
this.elementType = elementTypes.table;
|
|
596
570
|
this.waiting = false;
|
|
597
571
|
this.complexFilter = false;
|
|
598
572
|
this.currentPage = 1;
|
|
@@ -615,10 +589,10 @@ class RecordTable extends FormElement {
|
|
|
615
589
|
this.customAttributes = (_f = tableReceived === null || tableReceived === void 0 ? void 0 : tableReceived.customAttributes) !== null && _f !== void 0 ? _f : {};
|
|
616
590
|
this.sortable = (_g = tableReceived === null || tableReceived === void 0 ? void 0 : tableReceived.sortable) !== null && _g !== void 0 ? _g : false;
|
|
617
591
|
this.sorting = { columnName: '', direction: '' };
|
|
618
|
-
this.recordsPerPage =
|
|
592
|
+
this.recordsPerPage = formConfig.defaultRecordsPerPage;
|
|
619
593
|
if (tableReceived.fields) {
|
|
620
594
|
for (const columnReceived of tableReceived.fields) {
|
|
621
|
-
const columnDefinition = new RecordTableColumn(columnReceived);
|
|
595
|
+
const columnDefinition = new RecordTableColumn(columnReceived, this._formConfig);
|
|
622
596
|
this.columns.push(columnDefinition);
|
|
623
597
|
this._tableColumnObj[columnDefinition.fieldCode] = columnDefinition;
|
|
624
598
|
}
|
|
@@ -795,7 +769,7 @@ class RecordTable extends FormElement {
|
|
|
795
769
|
return (this._actionsObj && actionCode && this._actionsObj[actionCode])
|
|
796
770
|
? this._actionsObj[actionCode] : null;
|
|
797
771
|
}
|
|
798
|
-
getActions(actionClass =
|
|
772
|
+
getActions(actionClass = this._formConfig.tableActions.inline, actionTypes = null) {
|
|
799
773
|
return this._actions.filter(actionDef => {
|
|
800
774
|
const typeIncluded = (actionTypes) ? actionTypes.includes(actionDef.actionType) : true;
|
|
801
775
|
return actionDef.actionClass === actionClass && typeIncluded;
|
|
@@ -856,14 +830,14 @@ class RecordTable extends FormElement {
|
|
|
856
830
|
setRequiredOrder(columnField) {
|
|
857
831
|
if (columnField !== this.sorting.columnName) {
|
|
858
832
|
this.sorting.columnName = columnField;
|
|
859
|
-
this.sorting.direction =
|
|
833
|
+
this.sorting.direction = TABLE_SORT_ASCENDING;
|
|
860
834
|
}
|
|
861
835
|
else {
|
|
862
|
-
if (this.sorting.direction ===
|
|
863
|
-
this.sorting.direction =
|
|
836
|
+
if (this.sorting.direction === TABLE_SORT_ASCENDING) {
|
|
837
|
+
this.sorting.direction = TABLE_SORT_DESCENDING;
|
|
864
838
|
}
|
|
865
839
|
else {
|
|
866
|
-
this.sorting.direction =
|
|
840
|
+
this.sorting.direction = TABLE_SORT_ASCENDING;
|
|
867
841
|
}
|
|
868
842
|
}
|
|
869
843
|
}
|
|
@@ -884,7 +858,7 @@ class RecordTable extends FormElement {
|
|
|
884
858
|
else if (recordAColumn > recordBColumn) {
|
|
885
859
|
result = 1;
|
|
886
860
|
}
|
|
887
|
-
return direction ===
|
|
861
|
+
return direction === TABLE_SORT_ASCENDING ? result : -result;
|
|
888
862
|
}
|
|
889
863
|
}
|
|
890
864
|
|
|
@@ -1040,13 +1014,15 @@ class LibTableComponent {
|
|
|
1040
1014
|
this.hasActions = false;
|
|
1041
1015
|
}
|
|
1042
1016
|
ngOnInit() {
|
|
1043
|
-
|
|
1017
|
+
var _a;
|
|
1018
|
+
this.formConfig = (_a = this.tableObject) === null || _a === void 0 ? void 0 : _a._formConfig;
|
|
1019
|
+
this.tableFieldStyles = this.formConfig.tableFieldStyles;
|
|
1044
1020
|
this.selectable = this.tableObject.selectable;
|
|
1045
1021
|
this.hasActions = this.tableObject.hasActions;
|
|
1046
1022
|
this.tableObject.widget = this;
|
|
1047
|
-
this.inlineActions = this.tableObject.getActions(
|
|
1048
|
-
this.globalActions = this.tableObject.getActions(
|
|
1049
|
-
this.selectionActions = this.tableObject.getActions(
|
|
1023
|
+
this.inlineActions = this.tableObject.getActions(this.formConfig.tableActions.inline);
|
|
1024
|
+
this.globalActions = this.tableObject.getActions(this.formConfig.tableActions.global);
|
|
1025
|
+
this.selectionActions = this.tableObject.getActions(this.formConfig.tableActions.selection);
|
|
1050
1026
|
this.start();
|
|
1051
1027
|
}
|
|
1052
1028
|
start() { }
|
|
@@ -1156,21 +1132,21 @@ class RecordFormSubSection {
|
|
|
1156
1132
|
let arrayToAdd = null;
|
|
1157
1133
|
const { type, code } = receivedElement;
|
|
1158
1134
|
switch (type) {
|
|
1159
|
-
case
|
|
1135
|
+
case elementTypes.field:
|
|
1160
1136
|
elementObject = formObject.getFieldObject(code);
|
|
1161
1137
|
arrayToAdd = this.subSectionFields;
|
|
1162
1138
|
break;
|
|
1163
|
-
case
|
|
1139
|
+
case elementTypes.table:
|
|
1164
1140
|
elementObject = formObject.getTableObject(code);
|
|
1165
1141
|
arrayToAdd = this.subSectionTables;
|
|
1166
1142
|
break;
|
|
1167
|
-
case
|
|
1143
|
+
case elementTypes.action:
|
|
1168
1144
|
elementObject = formObject.getActionObject(code);
|
|
1169
1145
|
arrayToAdd = this.subSectionActions;
|
|
1170
1146
|
break;
|
|
1171
1147
|
}
|
|
1172
1148
|
if (elementObject) {
|
|
1173
|
-
elementObject.
|
|
1149
|
+
elementObject.elementType = type;
|
|
1174
1150
|
arrayToAdd.push(elementObject);
|
|
1175
1151
|
this.subSectionElements.push(elementObject);
|
|
1176
1152
|
this.elementsArray[code] = elementObject;
|
|
@@ -1302,12 +1278,12 @@ class RecordFormSection {
|
|
|
1302
1278
|
|
|
1303
1279
|
const HEADER$1 = 'HEADER';
|
|
1304
1280
|
class FormAction extends FormElement {
|
|
1305
|
-
constructor(actionDefinition) {
|
|
1281
|
+
constructor(actionDefinition, formConfig) {
|
|
1306
1282
|
var _a, _b;
|
|
1307
|
-
super(actionDefinition);
|
|
1283
|
+
super(actionDefinition, formConfig);
|
|
1308
1284
|
this._actionActivated = new Subject();
|
|
1309
1285
|
this.inProgress = false;
|
|
1310
|
-
this.
|
|
1286
|
+
this.elementType = elementTypes.action;
|
|
1311
1287
|
this.actionCode = actionDefinition.actionCode ? actionDefinition.actionCode.toString() : '';
|
|
1312
1288
|
this.actionName = actionDefinition.actionTitle;
|
|
1313
1289
|
this.iconName = actionDefinition.iconName || this.actionCode;
|
|
@@ -1335,104 +1311,103 @@ class FormAction extends FormElement {
|
|
|
1335
1311
|
}
|
|
1336
1312
|
|
|
1337
1313
|
const UNDEFINED = 'undefined';
|
|
1338
|
-
const
|
|
1339
|
-
const
|
|
1340
|
-
const
|
|
1341
|
-
const FIELD_CAPTURE_TYPE = 'captureType';
|
|
1342
|
-
const FIELD_TYPE = 'fieldTypeCode';
|
|
1343
|
-
const FIELD_MAX_LENGTH = 'maxLength';
|
|
1344
|
-
const FIELD_VISIBLE = 'visible';
|
|
1345
|
-
const FIELD_LABEL_VISIBLE = 'visibleLabel';
|
|
1346
|
-
const FIELD_REQUIRED = 'required';
|
|
1347
|
-
const FIELD_ERR_CODE = 'errorCode';
|
|
1348
|
-
const FIELD_ERR_MSG = 'errorMessage';
|
|
1349
|
-
const FIELD_TOOLTIP = 'tooltipText';
|
|
1350
|
-
const FIELD_INFO = 'info';
|
|
1351
|
-
const FIELD_EDITABLE = 'editable';
|
|
1352
|
-
const FIELD_TYPES = {
|
|
1353
|
-
array: 'ARRAY',
|
|
1354
|
-
check: 'CHECK',
|
|
1355
|
-
date: 'DATE',
|
|
1356
|
-
daterange: 'DATERANGE',
|
|
1357
|
-
time: 'TIME',
|
|
1358
|
-
timerange: 'TIMERANGE',
|
|
1359
|
-
map: 'MAP',
|
|
1360
|
-
number: 'NUMBER',
|
|
1361
|
-
decimal: 'DECIMAL',
|
|
1362
|
-
currency: 'CURRENCY',
|
|
1363
|
-
select: 'SELECT',
|
|
1364
|
-
typeahead: 'TYPEAHEAD',
|
|
1365
|
-
text: 'TEXT',
|
|
1366
|
-
password: 'PASSWORD',
|
|
1367
|
-
label: 'LABEL',
|
|
1368
|
-
html: 'HTML',
|
|
1369
|
-
title: 'TITLE',
|
|
1370
|
-
message: 'MESSAGE',
|
|
1371
|
-
link: 'LINK',
|
|
1372
|
-
warning: 'WARNING',
|
|
1373
|
-
avatar: 'AVATAR',
|
|
1374
|
-
email: 'EMAIL',
|
|
1375
|
-
phone: 'PHONE',
|
|
1376
|
-
};
|
|
1377
|
-
const FIELD_TYPES_FORMATS = {
|
|
1378
|
-
EMAIL: '^\\w+([\\.-]?\\w+)@\\w+([\\.-]?\\w+)(\\.\\w{2,3})+$',
|
|
1379
|
-
};
|
|
1314
|
+
const DEFAULT_ERROR_TYPE = 'error';
|
|
1315
|
+
const DEFAULT_CAPTURE_TYPE = 'INPUT';
|
|
1316
|
+
const DEFAULT_ALIGNMENT = 'left';
|
|
1380
1317
|
const STD_MAX_LENGTH = 50;
|
|
1381
1318
|
const BIG_MAX_LENGTH = 500;
|
|
1319
|
+
const fldAttr = {
|
|
1320
|
+
validateOnServer: 'validateOnServer',
|
|
1321
|
+
value: '_fieldValue',
|
|
1322
|
+
minValue: '_minValue',
|
|
1323
|
+
maxValue: '_maxValue',
|
|
1324
|
+
maxLength: '_maxLength',
|
|
1325
|
+
onValidation: '_onValidation',
|
|
1326
|
+
intrinsicErrorMessage: '_intrinsicErrorMessage',
|
|
1327
|
+
code: 'fieldCode',
|
|
1328
|
+
info: 'fieldInfo',
|
|
1329
|
+
defaultValue: 'defaultValue',
|
|
1330
|
+
defaultEditable: 'defaultEditable',
|
|
1331
|
+
customAttributes: 'customAttributes',
|
|
1332
|
+
visibleLabel: 'visibleLabel',
|
|
1333
|
+
required: 'fieldRequired',
|
|
1334
|
+
hasChanged: 'hasChanged',
|
|
1335
|
+
outputOnly: 'outputOnly',
|
|
1336
|
+
captureType: 'captureType',
|
|
1337
|
+
title: 'fieldTitle',
|
|
1338
|
+
type: 'fieldType',
|
|
1339
|
+
alignment: 'fieldAlignment',
|
|
1340
|
+
format: 'fieldFormat',
|
|
1341
|
+
externalValue: 'externalValue',
|
|
1342
|
+
tooltipText: 'tooltipText',
|
|
1343
|
+
errorType: 'errorType',
|
|
1344
|
+
errorCode: 'errorCode',
|
|
1345
|
+
errorMessage: 'errorMessage',
|
|
1346
|
+
options: 'fieldOptions',
|
|
1347
|
+
};
|
|
1382
1348
|
class FieldDescriptor extends FormElement {
|
|
1383
|
-
constructor(inputFieldReceived) {
|
|
1384
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
1385
|
-
super(inputFieldReceived);
|
|
1349
|
+
constructor(inputFieldReceived, formConfig) {
|
|
1350
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
1351
|
+
super(inputFieldReceived, formConfig);
|
|
1386
1352
|
this._editionFinish = new Subject();
|
|
1387
1353
|
this._editionPartial = new Subject();
|
|
1388
1354
|
this._detailRequest = new Subject();
|
|
1389
|
-
this.
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
this.
|
|
1393
|
-
this.
|
|
1394
|
-
this.captureType =
|
|
1395
|
-
this.
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
this.
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
this.
|
|
1409
|
-
this.
|
|
1410
|
-
this.
|
|
1411
|
-
this.
|
|
1412
|
-
this.
|
|
1413
|
-
this.
|
|
1414
|
-
this.
|
|
1415
|
-
|
|
1416
|
-
|
|
1355
|
+
this._attributeChange = new Subject();
|
|
1356
|
+
this.elementType = elementTypes.field;
|
|
1357
|
+
const fld = (inputFieldReceived) ? inputFieldReceived : {};
|
|
1358
|
+
this.setAttr(fldAttr.code, fld.fieldCode);
|
|
1359
|
+
this.setAttr(fldAttr.title, (_a = fld.fieldTitle) !== null && _a !== void 0 ? _a : this.fieldCode);
|
|
1360
|
+
this.setAttr(fldAttr.captureType, (_b = fld.captureType) !== null && _b !== void 0 ? _b : DEFAULT_CAPTURE_TYPE);
|
|
1361
|
+
this.setAttr(fldAttr.defaultValue, (_c = fld.defaultValue) !== null && _c !== void 0 ? _c : null);
|
|
1362
|
+
const defaultTypeAlignment = (this._formConfig.tableFieldStyles[this.fieldType] != null)
|
|
1363
|
+
? this._formConfig.tableFieldStyles[this.fieldType]['text-align'] : DEFAULT_ALIGNMENT;
|
|
1364
|
+
const fieldAlignment = (fld.alignment != null) ? fld.alignment.toLowerCase() : defaultTypeAlignment;
|
|
1365
|
+
this.setAttr(fldAttr.alignment, fieldAlignment);
|
|
1366
|
+
this.setAttr(fldAttr.info, fld.info || '');
|
|
1367
|
+
let fieldFormat;
|
|
1368
|
+
try {
|
|
1369
|
+
fieldFormat = (fld.format) ? new RegExp(fld.format) : null;
|
|
1370
|
+
}
|
|
1371
|
+
catch (e) {
|
|
1372
|
+
fieldFormat = null;
|
|
1373
|
+
}
|
|
1374
|
+
this.setAttr(fldAttr.format, fieldFormat);
|
|
1375
|
+
this.setAttr(fldAttr.validateOnServer, (_d = fld.serverAction) !== null && _d !== void 0 ? _d : false);
|
|
1376
|
+
this.setAttr(fldAttr.customAttributes, (_e = fld.customAttributes) !== null && _e !== void 0 ? _e : {});
|
|
1377
|
+
this.setAttr(fldAttr.tooltipText, fld.tooltip || '');
|
|
1378
|
+
this.setAttr(fldAttr.defaultEditable, this.enabled);
|
|
1379
|
+
this.setAttr(fldAttr.required, (_f = fld.required) !== null && _f !== void 0 ? _f : false);
|
|
1380
|
+
this.setError(fld.errorCode, fld.errorMessage, (_g = fld.errorType) !== null && _g !== void 0 ? _g : DEFAULT_ERROR_TYPE);
|
|
1381
|
+
this.setAttr(fldAttr.outputOnly, (_h = fld.outputOnly) !== null && _h !== void 0 ? _h : false);
|
|
1382
|
+
const maxLength = (_j = fld.maxLength) !== null && _j !== void 0 ? _j : (this.captureType === 'TEXTAREA' ? BIG_MAX_LENGTH : STD_MAX_LENGTH);
|
|
1383
|
+
this.setAttr(fldAttr.maxLength, maxLength);
|
|
1384
|
+
this.setAttr(fldAttr.intrinsicErrorMessage, (_k = this._formConfig.fieldTypeErrMsg[this.fieldType]) !== null && _k !== void 0 ? _k : this._formConfig.fieldTypeErrMsg.DEFAULT);
|
|
1385
|
+
this.setFieldType(fld.fieldTypeCode);
|
|
1386
|
+
this.setEditable((_l = fld.editable) !== null && _l !== void 0 ? _l : true);
|
|
1387
|
+
this.setVisibleLabel((_m = fld.visibleLabel) !== null && _m !== void 0 ? _m : true);
|
|
1388
|
+
this.setVisibility(fld.visible);
|
|
1389
|
+
this.setFieldOptions(fld.fieldOptions);
|
|
1390
|
+
this.setValue(fld.fieldValue || this.defaultValue || '');
|
|
1417
1391
|
}
|
|
1418
1392
|
get name() { return this.fieldCode; }
|
|
1419
1393
|
get editionFinish() { return this._editionFinish; }
|
|
1394
|
+
get attributeChange() { return this._attributeChange; }
|
|
1420
1395
|
get editionPartial() { return this._editionPartial; }
|
|
1421
1396
|
get detailRequest() { return this._detailRequest; }
|
|
1422
1397
|
get validating() { return this._onValidation; }
|
|
1423
|
-
set validating(isValidating) { this.
|
|
1424
|
-
setIntrinsicErrorMessage(message) { this.
|
|
1398
|
+
set validating(isValidating) { this.setAttr(fldAttr.onValidation, isValidating); }
|
|
1399
|
+
setIntrinsicErrorMessage(message) { this.setAttr(fldAttr.intrinsicErrorMessage, message); }
|
|
1425
1400
|
set intrinsicErrorMessage(message) { this.setIntrinsicErrorMessage(message); }
|
|
1426
1401
|
get fieldValue() { return this.getValue(); }
|
|
1427
1402
|
get required() { return this.fieldRequired; }
|
|
1428
|
-
set required(required) { this.
|
|
1403
|
+
set required(required) { this.setAttr(fldAttr.required, required !== null && required !== void 0 ? required : false); }
|
|
1429
1404
|
get maxLength() { return (this._maxLength > 0) ? this._maxLength.toString() : ''; }
|
|
1430
1405
|
set maxLength(requiredMaxLength) {
|
|
1431
1406
|
if (typeof requiredMaxLength === 'string') {
|
|
1432
|
-
this.
|
|
1407
|
+
this.setAttr(fldAttr.maxLength, parseInt(requiredMaxLength, 10));
|
|
1433
1408
|
}
|
|
1434
1409
|
else if (typeof requiredMaxLength === 'number') {
|
|
1435
|
-
this.
|
|
1410
|
+
this.setAttr(fldAttr.maxLength, requiredMaxLength);
|
|
1436
1411
|
}
|
|
1437
1412
|
}
|
|
1438
1413
|
get value() { return this.getValue(); }
|
|
@@ -1442,41 +1417,48 @@ class FieldDescriptor extends FormElement {
|
|
|
1442
1417
|
this._editionPartial.next({ code: this.fieldCode, intrinsicValidation });
|
|
1443
1418
|
}
|
|
1444
1419
|
notifyEditionFinish() {
|
|
1445
|
-
var _a, _b;
|
|
1420
|
+
var _a, _b, _c, _d, _e;
|
|
1446
1421
|
let intrinsicValidation = true;
|
|
1447
|
-
const fieldDefaultFormat = (
|
|
1448
|
-
? new RegExp(FIELD_TYPES_FORMATS === null || FIELD_TYPES_FORMATS === void 0 ? void 0 : FIELD_TYPES_FORMATS[this.fieldType]) : null;
|
|
1449
|
-
const fieldFormat = (this.fieldFormat) ? new RegExp(this.fieldFormat) : null;
|
|
1422
|
+
const fieldDefaultFormat = (_b = (_a = this._formConfig.fieldTypesPatterns) === null || _a === void 0 ? void 0 : _a[this.fieldType]) !== null && _b !== void 0 ? _b : null;
|
|
1450
1423
|
const fieldValue = this.getValue();
|
|
1451
|
-
if (fieldValue && (fieldDefaultFormat || fieldFormat)) {
|
|
1452
|
-
intrinsicValidation = ((
|
|
1453
|
-
&& ((
|
|
1424
|
+
if (fieldValue && (fieldDefaultFormat || this.fieldFormat)) {
|
|
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);
|
|
1454
1427
|
if (!intrinsicValidation) {
|
|
1455
1428
|
this.setError('99', this._intrinsicErrorMessage);
|
|
1456
1429
|
}
|
|
1457
1430
|
}
|
|
1458
1431
|
this._editionFinish.next({ code: this.fieldCode, intrinsicValidation });
|
|
1459
1432
|
}
|
|
1433
|
+
setAttr(name, value) {
|
|
1434
|
+
this[name] = value;
|
|
1435
|
+
if (this._formConfig.monitoredFieldAttributes.includes(name)) {
|
|
1436
|
+
this._attributeChange.next({ name, value });
|
|
1437
|
+
}
|
|
1438
|
+
}
|
|
1460
1439
|
notifyEditionDetailRequest() {
|
|
1461
1440
|
this._detailRequest.next(this.fieldCode);
|
|
1462
1441
|
}
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1442
|
+
getCustomAttribute(name) { var _a, _b; return (_b = (_a = this.customAttributes) === null || _a === void 0 ? void 0 : _a[name]) !== null && _b !== void 0 ? _b : null; }
|
|
1443
|
+
setVisibleLabel(visibleLabel) { this.setAttr(fldAttr.visibleLabel, visibleLabel); }
|
|
1444
|
+
showLabel() { this.setVisibleLabel(true); }
|
|
1445
|
+
hideLabel() { this.setVisibleLabel(false); }
|
|
1446
|
+
setChanged(hasChanged) { this.setAttr(fldAttr.hasChanged, hasChanged); }
|
|
1447
|
+
changed() { this.setChanged(true); }
|
|
1466
1448
|
getRawValue() { return this._fieldValue; }
|
|
1467
|
-
setLabel(label) { this.
|
|
1449
|
+
setLabel(label) { this.setAttr(fldAttr.title, label); }
|
|
1468
1450
|
clean() { this.setValue(this.defaultValue || ''); }
|
|
1469
1451
|
get backend() { return this.validateOnServer; }
|
|
1470
|
-
setVisibleLabel(visibleLabel) { this.visibleLabel = visibleLabel; }
|
|
1471
1452
|
setEditable(editable = true) { (editable) ? this.enable() : this.disable(); }
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
this.errorCode
|
|
1475
|
-
this.
|
|
1453
|
+
hasError() { return this.errorCode !== '00'; }
|
|
1454
|
+
setError(code, message, type = DEFAULT_ERROR_TYPE) {
|
|
1455
|
+
this.setAttr(fldAttr.errorCode, code !== null && code !== void 0 ? code : '00');
|
|
1456
|
+
this.setAttr(fldAttr.errorType, (this.errorCode === '00') ? '' : type);
|
|
1457
|
+
this.setAttr(fldAttr.errorMessage, message !== null && message !== void 0 ? message : '');
|
|
1476
1458
|
}
|
|
1477
1459
|
getError() { return { type: this.errorType, code: this.errorCode, message: this.errorMessage }; }
|
|
1478
1460
|
get error() { return this.getError(); }
|
|
1479
|
-
set error(errorObj) { this.setError(errorObj.code, errorObj.message, errorObj.type); }
|
|
1461
|
+
set error(errorObj) { var _a; this.setError(errorObj.code, errorObj.message, (_a = errorObj.type) !== null && _a !== void 0 ? _a : DEFAULT_ERROR_TYPE); }
|
|
1480
1462
|
getErrorCode() { return this.getError().code; }
|
|
1481
1463
|
setErrorCode(code) { this.setError(code, this.errorMessage); }
|
|
1482
1464
|
getErrorMessage() { return this.getError().message; }
|
|
@@ -1486,7 +1468,7 @@ class FieldDescriptor extends FormElement {
|
|
|
1486
1468
|
if (fieldCurrentValue === undefined || fieldCurrentValue === null) {
|
|
1487
1469
|
return true;
|
|
1488
1470
|
}
|
|
1489
|
-
if ((this.fieldType ===
|
|
1471
|
+
if ((this.fieldType === this._formConfig.fieldTypes.array || this.fieldType === this._formConfig.fieldTypes.phone)
|
|
1490
1472
|
&& Array.isArray(fieldCurrentValue) && fieldCurrentValue.length === 0) {
|
|
1491
1473
|
return true;
|
|
1492
1474
|
}
|
|
@@ -1496,10 +1478,10 @@ class FieldDescriptor extends FormElement {
|
|
|
1496
1478
|
getValue() {
|
|
1497
1479
|
var _a;
|
|
1498
1480
|
switch (this.fieldType) {
|
|
1499
|
-
case
|
|
1481
|
+
case this._formConfig.fieldTypes.check:
|
|
1500
1482
|
return (_a = this._fieldValue) !== null && _a !== void 0 ? _a : false;
|
|
1501
1483
|
break;
|
|
1502
|
-
case
|
|
1484
|
+
case this._formConfig.fieldTypes.currency:
|
|
1503
1485
|
return this._fieldValue.replace(',', '');
|
|
1504
1486
|
break;
|
|
1505
1487
|
default:
|
|
@@ -1509,68 +1491,39 @@ class FieldDescriptor extends FormElement {
|
|
|
1509
1491
|
}
|
|
1510
1492
|
updateFromServer(fld) {
|
|
1511
1493
|
var _a;
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
this.
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
this.
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
(this.
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
(this.
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
(this.
|
|
1529
|
-
|
|
1530
|
-
if (FIELD_INFO in fld) {
|
|
1531
|
-
(this.fieldInfo = fld.info);
|
|
1532
|
-
}
|
|
1533
|
-
if (FIELD_EDITABLE in fld) {
|
|
1534
|
-
this.setEditable(fld.editable);
|
|
1535
|
-
}
|
|
1536
|
-
if (FIELD_TITLE in fld) {
|
|
1537
|
-
this.setLabel(fld.fieldTitle.toString());
|
|
1538
|
-
}
|
|
1539
|
-
if (FIELD_VALUE in fld) {
|
|
1540
|
-
this.hasChanged = false;
|
|
1541
|
-
this.setValue(fld.fieldValue);
|
|
1542
|
-
}
|
|
1543
|
-
if (FIELD_OPTIONS in fld) {
|
|
1544
|
-
this.setFieldOptions(fld.fieldOptions);
|
|
1545
|
-
}
|
|
1546
|
-
if (FIELD_CAPTURE_TYPE in fld) {
|
|
1547
|
-
this.captureType = fld.captureType || 'INPUT';
|
|
1548
|
-
}
|
|
1549
|
-
if (FIELD_TYPE in fld) {
|
|
1550
|
-
this.setFieldType(fld.fieldTypeCode);
|
|
1551
|
-
}
|
|
1552
|
-
if (FIELD_MAX_LENGTH in fld) {
|
|
1553
|
-
this.maxLength = fld.maxLength;
|
|
1494
|
+
const fieldKeys = Object.keys(fld);
|
|
1495
|
+
for (let index = 0; index < fieldKeys.length; index++) {
|
|
1496
|
+
const attrName = fieldKeys[index];
|
|
1497
|
+
const attrValue = fld[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);
|
|
1554
1512
|
}
|
|
1555
1513
|
}
|
|
1556
1514
|
setFieldType(inputFieldType) {
|
|
1557
|
-
this.
|
|
1558
|
-
/**
|
|
1559
|
-
* Se elimina la validación de que sea un tipo conocido
|
|
1560
|
-
* this.fieldType = (inputFieldType && FIELDTYPES.includes(inputFieldType))
|
|
1561
|
-
* ? inputFieldType : componentConstants.FIELDTYPE_TEXT;
|
|
1562
|
-
*/
|
|
1515
|
+
this.setAttr(fldAttr.type, inputFieldType);
|
|
1563
1516
|
}
|
|
1564
1517
|
format() {
|
|
1565
|
-
if (this.fieldType ===
|
|
1566
|
-
this.
|
|
1518
|
+
if (this.fieldType === this._formConfig.fieldTypes.currency) {
|
|
1519
|
+
this.setAttr(fldAttr.value, formatCurrency(this._fieldValue));
|
|
1567
1520
|
}
|
|
1568
1521
|
}
|
|
1569
1522
|
setMinValue(minValue) {
|
|
1570
1523
|
var _a, _b, _c;
|
|
1571
|
-
if (this.fieldType ===
|
|
1524
|
+
if (this.fieldType === this._formConfig.fieldTypes.date
|
|
1572
1525
|
&& ((_a = this.widget) === null || _a === void 0 ? void 0 : _a.setMinValue)) {
|
|
1573
|
-
this.
|
|
1526
|
+
this.setAttr(fldAttr.minValue, minValue);
|
|
1574
1527
|
if (!minValue) {
|
|
1575
1528
|
(_b = this.widget) === null || _b === void 0 ? void 0 : _b.setMinValue(false);
|
|
1576
1529
|
}
|
|
@@ -1582,9 +1535,9 @@ class FieldDescriptor extends FormElement {
|
|
|
1582
1535
|
}
|
|
1583
1536
|
setMaxValue(maxValue) {
|
|
1584
1537
|
var _a, _b, _c;
|
|
1585
|
-
if (this.fieldType ===
|
|
1538
|
+
if (this.fieldType === this._formConfig.fieldTypes.date
|
|
1586
1539
|
&& ((_a = this.widget) === null || _a === void 0 ? void 0 : _a.setMaxValue)) {
|
|
1587
|
-
this.
|
|
1540
|
+
this.setAttr(fldAttr.maxValue, maxValue);
|
|
1588
1541
|
if (!maxValue) {
|
|
1589
1542
|
(_b = this.widget) === null || _b === void 0 ? void 0 : _b.setMaxValue(false);
|
|
1590
1543
|
}
|
|
@@ -1604,21 +1557,23 @@ class FieldDescriptor extends FormElement {
|
|
|
1604
1557
|
|| !Array.isArray(newOptions)) {
|
|
1605
1558
|
return;
|
|
1606
1559
|
}
|
|
1607
|
-
|
|
1560
|
+
let fieldOptions = newOptions.map(option => {
|
|
1608
1561
|
if (option.text !== undefined && option.text !== null
|
|
1609
1562
|
&& option.value !== undefined && option.value !== null) {
|
|
1610
1563
|
return { fieldOptionValue: option.text, fieldOptionId: option.value };
|
|
1611
1564
|
}
|
|
1612
1565
|
return Object.assign({}, option);
|
|
1613
1566
|
});
|
|
1614
|
-
|
|
1567
|
+
fieldOptions = (fieldOptions && Array.isArray(fieldOptions)
|
|
1615
1568
|
&& fieldOptions.length > 0) ? fieldOptions : [];
|
|
1616
|
-
|
|
1569
|
+
this.setAttr(fldAttr.options, fieldOptions);
|
|
1570
|
+
if (this.fieldType === this._formConfig.fieldTypes.array && this.widget) {
|
|
1617
1571
|
return (_a = this.widget) === null || _a === void 0 ? void 0 : _a.refereshContent();
|
|
1618
1572
|
}
|
|
1619
1573
|
if (this._fieldValue) {
|
|
1620
|
-
if (this.fieldType ===
|
|
1621
|
-
|
|
1574
|
+
if (this.fieldType === this._formConfig.fieldTypes.array && Array.isArray(this._fieldValue)) {
|
|
1575
|
+
const fieldValue = (_b = this._fieldValue) === null || _b === void 0 ? void 0 : _b.filter(item => this.fieldOptions.find(opt => opt.fieldOptionId === item));
|
|
1576
|
+
this.setAttr(fldAttr.value, fieldValue);
|
|
1622
1577
|
}
|
|
1623
1578
|
else {
|
|
1624
1579
|
const valInOptions = this.fieldOptions
|
|
@@ -1638,17 +1593,17 @@ class FieldDescriptor extends FormElement {
|
|
|
1638
1593
|
setValue(newValue, widgetUpdate = true) {
|
|
1639
1594
|
var _a;
|
|
1640
1595
|
if (typeof newValue === UNDEFINED || newValue === null) {
|
|
1641
|
-
return;
|
|
1596
|
+
return true;
|
|
1642
1597
|
}
|
|
1643
1598
|
let newFinalValue;
|
|
1644
1599
|
switch (this.fieldType) {
|
|
1645
1600
|
case 'BOOLEAN':
|
|
1646
1601
|
newFinalValue = !!newValue;
|
|
1647
1602
|
break;
|
|
1648
|
-
case
|
|
1603
|
+
case this._formConfig.fieldTypes.check:
|
|
1649
1604
|
newFinalValue = !!newValue;
|
|
1650
1605
|
break;
|
|
1651
|
-
case
|
|
1606
|
+
case this._formConfig.fieldTypes.array:
|
|
1652
1607
|
if (newValue === null || newValue === '') {
|
|
1653
1608
|
newFinalValue = [];
|
|
1654
1609
|
}
|
|
@@ -1662,7 +1617,7 @@ class FieldDescriptor extends FormElement {
|
|
|
1662
1617
|
newFinalValue = newValue;
|
|
1663
1618
|
}
|
|
1664
1619
|
break;
|
|
1665
|
-
case
|
|
1620
|
+
case this._formConfig.fieldTypes.map:
|
|
1666
1621
|
newFinalValue = newValue;
|
|
1667
1622
|
if (newFinalValue && this.widget && widgetUpdate) {
|
|
1668
1623
|
const latitude = parseFloat(newFinalValue[0]);
|
|
@@ -1670,7 +1625,7 @@ class FieldDescriptor extends FormElement {
|
|
|
1670
1625
|
(_a = this.widget) === null || _a === void 0 ? void 0 : _a.setLocation(latitude, longitude);
|
|
1671
1626
|
}
|
|
1672
1627
|
break;
|
|
1673
|
-
case
|
|
1628
|
+
case this._formConfig.fieldTypes.currency:
|
|
1674
1629
|
newFinalValue = formatCurrency(this._fieldValue);
|
|
1675
1630
|
break;
|
|
1676
1631
|
default:
|
|
@@ -1678,22 +1633,24 @@ class FieldDescriptor extends FormElement {
|
|
|
1678
1633
|
break;
|
|
1679
1634
|
}
|
|
1680
1635
|
if (this._fieldValue !== newFinalValue) {
|
|
1681
|
-
this.
|
|
1682
|
-
this.
|
|
1636
|
+
this.setChanged(true);
|
|
1637
|
+
this.setAttr(fldAttr.value, newFinalValue);
|
|
1683
1638
|
}
|
|
1639
|
+
return true;
|
|
1684
1640
|
}
|
|
1685
1641
|
}
|
|
1686
1642
|
|
|
1687
1643
|
const HEADER = 'HEADER';
|
|
1688
1644
|
const NO_ERROR = '00';
|
|
1689
1645
|
class FormStructureAndData {
|
|
1690
|
-
constructor(definitionReceived) {
|
|
1646
|
+
constructor(definitionReceived, formConfig) {
|
|
1691
1647
|
this._fieldsObj = {};
|
|
1692
1648
|
this._actionsObj = {};
|
|
1693
1649
|
this._tableObj = {};
|
|
1694
1650
|
this._sectionsObj = {};
|
|
1695
1651
|
this._immutableData = {};
|
|
1696
1652
|
this._extraInfo = {};
|
|
1653
|
+
this._formConfig = formConfig;
|
|
1697
1654
|
this.state = '';
|
|
1698
1655
|
this._actions = [];
|
|
1699
1656
|
this._fields = [];
|
|
@@ -1727,7 +1684,7 @@ class FormStructureAndData {
|
|
|
1727
1684
|
return Object.assign(Object.assign({}, objDef), { visibleStates, enabledStates });
|
|
1728
1685
|
});
|
|
1729
1686
|
for (const actionReceived of formActions) {
|
|
1730
|
-
const globalAction = new FormAction(actionReceived);
|
|
1687
|
+
const globalAction = new FormAction(actionReceived, this._formConfig);
|
|
1731
1688
|
const globalActionCode = globalAction.actionCode;
|
|
1732
1689
|
if (globalActionCode) {
|
|
1733
1690
|
this._actions.push(globalAction);
|
|
@@ -1748,7 +1705,7 @@ class FormStructureAndData {
|
|
|
1748
1705
|
return Object.assign(Object.assign({}, objDef), { visibleStates, enabledStates });
|
|
1749
1706
|
});
|
|
1750
1707
|
for (const fieldReceived of formFields) {
|
|
1751
|
-
const fieldToAdd = new FieldDescriptor(fieldReceived);
|
|
1708
|
+
const fieldToAdd = new FieldDescriptor(fieldReceived, this._formConfig);
|
|
1752
1709
|
const fieldCode = fieldToAdd.fieldCode;
|
|
1753
1710
|
if (fieldCode) {
|
|
1754
1711
|
this._fields.push(fieldToAdd);
|
|
@@ -1767,12 +1724,12 @@ class FormStructureAndData {
|
|
|
1767
1724
|
enabledStates = [...visibleStates];
|
|
1768
1725
|
}
|
|
1769
1726
|
if (!visibleStates || visibleStates.length === 0) {
|
|
1770
|
-
visibleStates =
|
|
1727
|
+
visibleStates = this._formConfig.defaultStateFlow.states;
|
|
1771
1728
|
}
|
|
1772
1729
|
return Object.assign(Object.assign({}, objDef), { visibleStates, enabledStates });
|
|
1773
1730
|
});
|
|
1774
1731
|
for (const tableReceived of tables) {
|
|
1775
|
-
const tableToAdd = new RecordTable(tableReceived);
|
|
1732
|
+
const tableToAdd = new RecordTable(tableReceived, this._formConfig);
|
|
1776
1733
|
const tableCode = tableToAdd.tableCode;
|
|
1777
1734
|
if (tableCode) {
|
|
1778
1735
|
this._tables.push(tableToAdd);
|
|
@@ -1824,7 +1781,7 @@ class FormStructureAndData {
|
|
|
1824
1781
|
}
|
|
1825
1782
|
setStateFlow(states, transitions, defaultState) {
|
|
1826
1783
|
if (!states || !transitions) {
|
|
1827
|
-
this._stateFlow = JSON.parse(JSON.stringify(
|
|
1784
|
+
this._stateFlow = JSON.parse(JSON.stringify(this._formConfig.defaultStateFlow));
|
|
1828
1785
|
return;
|
|
1829
1786
|
}
|
|
1830
1787
|
this._stateFlow.states = states;
|
|
@@ -2365,7 +2322,6 @@ class BasicFormComponent {
|
|
|
2365
2322
|
this.transitionToken = null;
|
|
2366
2323
|
this.inputDataFields = [];
|
|
2367
2324
|
this.extraData = null;
|
|
2368
|
-
this.componentConstants = componentConstants;
|
|
2369
2325
|
this.definitionObtained = false;
|
|
2370
2326
|
this.formVisible = false;
|
|
2371
2327
|
this.inServerProcess = false;
|
|
@@ -2387,6 +2343,9 @@ class BasicFormComponent {
|
|
|
2387
2343
|
this.cleanStart();
|
|
2388
2344
|
this.customPreProcessing();
|
|
2389
2345
|
}
|
|
2346
|
+
setConfig(formConfig) {
|
|
2347
|
+
this.formConfig = formConfig;
|
|
2348
|
+
}
|
|
2390
2349
|
cleanStart() {
|
|
2391
2350
|
this._errorType = '';
|
|
2392
2351
|
this.errorCode = '';
|
|
@@ -2675,7 +2634,7 @@ class BasicFormComponent {
|
|
|
2675
2634
|
this.inServerProcess = true;
|
|
2676
2635
|
const formDefinition = yield this.formManagerService.getFormDefinition(this.name);
|
|
2677
2636
|
this.inServerProcess = false;
|
|
2678
|
-
this.formStructure = new FormStructureAndData(formDefinition);
|
|
2637
|
+
this.formStructure = new FormStructureAndData(formDefinition, this.formConfig);
|
|
2679
2638
|
this.definitionObtained = true;
|
|
2680
2639
|
}
|
|
2681
2640
|
else {
|
|
@@ -2701,7 +2660,7 @@ class BasicFormComponent {
|
|
|
2701
2660
|
this.setFieldValue(fieldCode, fieldValue);
|
|
2702
2661
|
}
|
|
2703
2662
|
}
|
|
2704
|
-
const recordResponse = yield this.requestFormAction(
|
|
2663
|
+
const recordResponse = yield this.requestFormAction(formActions.getData);
|
|
2705
2664
|
this.checkErrorRecordReceived(recordResponse);
|
|
2706
2665
|
this.formVisible = true;
|
|
2707
2666
|
this.subscribeSectionActivation();
|
|
@@ -2721,7 +2680,7 @@ class BasicFormComponent {
|
|
|
2721
2680
|
this.errorDetail = recordResponse.errorDetail;
|
|
2722
2681
|
}
|
|
2723
2682
|
errorOccured() {
|
|
2724
|
-
return (this.errorCode !==
|
|
2683
|
+
return (this.errorCode !== '00');
|
|
2725
2684
|
}
|
|
2726
2685
|
changeState(state) { return this.formStructure.changeState(state); }
|
|
2727
2686
|
changeFormMode(state) { return this.changeState(state); }
|
|
@@ -3002,7 +2961,7 @@ class BasicFormComponent {
|
|
|
3002
2961
|
if (fieldObj.backend) {
|
|
3003
2962
|
fieldObj.validating = true;
|
|
3004
2963
|
validationResult = yield this
|
|
3005
|
-
.requestFormAction(
|
|
2964
|
+
.requestFormAction(formActions.validate, fieldObj.fieldCode);
|
|
3006
2965
|
finish = !this.errorOccured();
|
|
3007
2966
|
}
|
|
3008
2967
|
if (finish) {
|
|
@@ -3191,7 +3150,7 @@ class BasicFormComponent {
|
|
|
3191
3150
|
actionCode
|
|
3192
3151
|
};
|
|
3193
3152
|
actionResult = yield this
|
|
3194
|
-
.requestFormAction(
|
|
3153
|
+
.requestFormAction(formActions.tableAction, actionSubject);
|
|
3195
3154
|
finish = !this.errorOccured();
|
|
3196
3155
|
}
|
|
3197
3156
|
if (finish) {
|
|
@@ -3268,13 +3227,13 @@ class BasicFormComponent {
|
|
|
3268
3227
|
if (action.backend) {
|
|
3269
3228
|
const actionSubject = {
|
|
3270
3229
|
tableCode,
|
|
3271
|
-
actionType:
|
|
3230
|
+
actionType: this.formConfig.tableActions.inline,
|
|
3272
3231
|
actionCode,
|
|
3273
3232
|
tableRecordId: recordId,
|
|
3274
3233
|
tableRecordData: recordData
|
|
3275
3234
|
};
|
|
3276
3235
|
actionResult = yield this
|
|
3277
|
-
.requestFormAction(
|
|
3236
|
+
.requestFormAction(formActions.tableAction, actionSubject);
|
|
3278
3237
|
finish = !this.errorOccured();
|
|
3279
3238
|
}
|
|
3280
3239
|
if (finish) {
|
|
@@ -3347,13 +3306,13 @@ class BasicFormComponent {
|
|
|
3347
3306
|
if (tableObject.selectionBackend) {
|
|
3348
3307
|
const actionSubject = {
|
|
3349
3308
|
tableCode,
|
|
3350
|
-
actionType:
|
|
3309
|
+
actionType: this.formConfig.tableActions.rowSelection,
|
|
3351
3310
|
actionCode: null,
|
|
3352
3311
|
tableRecordId: recordId,
|
|
3353
3312
|
tableRecordData: recordData
|
|
3354
3313
|
};
|
|
3355
3314
|
actionResult = yield this
|
|
3356
|
-
.requestFormAction(
|
|
3315
|
+
.requestFormAction(formActions.tableAction, actionSubject);
|
|
3357
3316
|
finish = !this.errorOccured();
|
|
3358
3317
|
}
|
|
3359
3318
|
if (finish) {
|
|
@@ -3427,12 +3386,12 @@ class BasicFormComponent {
|
|
|
3427
3386
|
if (action.backend) {
|
|
3428
3387
|
const actionSubject = {
|
|
3429
3388
|
tableCode,
|
|
3430
|
-
actionType:
|
|
3389
|
+
actionType: this.formConfig.tableActions.selection,
|
|
3431
3390
|
actionCode,
|
|
3432
3391
|
selectedRecords
|
|
3433
3392
|
};
|
|
3434
3393
|
actionResult = yield this
|
|
3435
|
-
.requestFormAction(
|
|
3394
|
+
.requestFormAction(formActions.tableAction, actionSubject);
|
|
3436
3395
|
finish = !this.errorOccured();
|
|
3437
3396
|
}
|
|
3438
3397
|
if (finish) {
|
|
@@ -3490,7 +3449,7 @@ class BasicFormComponent {
|
|
|
3490
3449
|
tableObject.putOnWait();
|
|
3491
3450
|
const actionSubject = { tableCode };
|
|
3492
3451
|
const actionResult = yield this
|
|
3493
|
-
.requestFormAction(
|
|
3452
|
+
.requestFormAction(formActions.getTableData, actionSubject);
|
|
3494
3453
|
if (this.errorOccured()) {
|
|
3495
3454
|
this.displayTableServerError();
|
|
3496
3455
|
}
|
|
@@ -3524,15 +3483,15 @@ class BasicFormComponent {
|
|
|
3524
3483
|
this.resetError();
|
|
3525
3484
|
const completeFields = this.checkSectionRequiredFields(sectionCode, reqFieldMessage);
|
|
3526
3485
|
if (!completeFields) {
|
|
3527
|
-
this.setError(
|
|
3486
|
+
this.setError(this.formConfig.formStandardErrors.typeWarning, this.formConfig.formStandardErrors.validationTitle, this.formConfig.formStandardErrors.requiredFields);
|
|
3528
3487
|
return;
|
|
3529
3488
|
}
|
|
3530
3489
|
let validationError = false;
|
|
3531
3490
|
const requiredEmptyFields = this.getRequiredEmptyFields(null, sectionCode);
|
|
3532
3491
|
if (requiredEmptyFields.length > 0) {
|
|
3533
3492
|
validationError = true;
|
|
3534
|
-
this.setError(
|
|
3535
|
-
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);
|
|
3536
3495
|
for (const fieldCode of requiredEmptyFields) {
|
|
3537
3496
|
const requiredEmptyField = this.getField(fieldCode);
|
|
3538
3497
|
if (requiredEmptyField && requiredEmptyField.widget
|
|
@@ -3545,7 +3504,7 @@ class BasicFormComponent {
|
|
|
3545
3504
|
const validationIssueFields = this.getFieldsWithValidationIssues(null, sectionCode);
|
|
3546
3505
|
if (!validationError && validationIssueFields.length > 0) {
|
|
3547
3506
|
validationError = true;
|
|
3548
|
-
this.setError(
|
|
3507
|
+
this.setError(this.formConfig.formStandardErrors.typeWarning, this.formConfig.formStandardErrors.validationTitle, this.formConfig.formStandardErrors.validationFields);
|
|
3549
3508
|
for (const fieldCode of validationIssueFields) {
|
|
3550
3509
|
const validationIssueField = this.getField(fieldCode);
|
|
3551
3510
|
if (validationIssueField && validationIssueField.widget
|
|
@@ -3661,13 +3620,13 @@ class BasicFormComponent {
|
|
|
3661
3620
|
const requiredEmptyFields = this.getRequiredEmptyFields(recordCaptureFields, null);
|
|
3662
3621
|
if (requiredEmptyFields.length > 0) {
|
|
3663
3622
|
validationOk = false;
|
|
3664
|
-
this.setError(
|
|
3665
|
-
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);
|
|
3666
3625
|
}
|
|
3667
3626
|
const validationIssueFields = this.getFieldsWithValidationIssues(recordCaptureFields, null);
|
|
3668
3627
|
if (validationIssueFields.length > 0) {
|
|
3669
3628
|
validationOk = false;
|
|
3670
|
-
this.setError(
|
|
3629
|
+
this.setError(this.formConfig.formStandardErrors.typeWarning, this.formConfig.formStandardErrors.validationTitle, this.formConfig.formStandardErrors.validationFields);
|
|
3671
3630
|
}
|
|
3672
3631
|
return validationOk;
|
|
3673
3632
|
}
|