tuain-ng-forms-lib 0.12.23 → 0.12.33
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 +285 -319
- 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 +142 -165
- package/esm2015/lib/classes/forms/form.constants.js +11 -82
- package/esm2015/lib/classes/forms/form.js +10 -10
- 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 +280 -324
- package/fesm2015/tuain-ng-forms-lib.js.map +1 -1
- package/lib/classes/forms/action.d.ts +1 -1
- package/lib/classes/forms/element.d.ts +3 -2
- package/lib/classes/forms/field.d.ts +19 -13
- package/lib/classes/forms/form.constants.d.ts +10 -74
- package/lib/classes/forms/form.d.ts +3 -2
- 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 +2 -2
- 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,109 +1311,103 @@ class FormAction extends FormElement {
|
|
|
1335
1311
|
}
|
|
1336
1312
|
|
|
1337
1313
|
const UNDEFINED = 'undefined';
|
|
1338
|
-
const
|
|
1339
|
-
const
|
|
1340
|
-
const
|
|
1341
|
-
const FIELD_CAPTURE_TYPE = 'captureType';
|
|
1342
|
-
const FIELD_TYPE = 'fieldTypeCode';
|
|
1343
|
-
const FIELD_MAX_LENGTH = 'maxLength';
|
|
1344
|
-
const FIELD_VISIBLE = 'visible';
|
|
1345
|
-
const FIELD_LABEL_VISIBLE = 'visibleLabel';
|
|
1346
|
-
const FIELD_REQUIRED = 'required';
|
|
1347
|
-
const FIELD_ERR_CODE = 'errorCode';
|
|
1348
|
-
const FIELD_ERR_MSG = 'errorMessage';
|
|
1349
|
-
const FIELD_TOOLTIP = 'tooltipText';
|
|
1350
|
-
const FIELD_INFO = 'info';
|
|
1351
|
-
const FIELD_EDITABLE = 'editable';
|
|
1352
|
-
const FIELD_TYPES = {
|
|
1353
|
-
array: 'ARRAY',
|
|
1354
|
-
check: 'CHECK',
|
|
1355
|
-
date: 'DATE',
|
|
1356
|
-
daterange: 'DATERANGE',
|
|
1357
|
-
time: 'TIME',
|
|
1358
|
-
timerange: 'TIMERANGE',
|
|
1359
|
-
map: 'MAP',
|
|
1360
|
-
number: 'NUMBER',
|
|
1361
|
-
decimal: 'DECIMAL',
|
|
1362
|
-
currency: 'CURRENCY',
|
|
1363
|
-
select: 'SELECT',
|
|
1364
|
-
typeahead: 'TYPEAHEAD',
|
|
1365
|
-
text: 'TEXT',
|
|
1366
|
-
password: 'PASSWORD',
|
|
1367
|
-
label: 'LABEL',
|
|
1368
|
-
html: 'HTML',
|
|
1369
|
-
title: 'TITLE',
|
|
1370
|
-
message: 'MESSAGE',
|
|
1371
|
-
link: 'LINK',
|
|
1372
|
-
warning: 'WARNING',
|
|
1373
|
-
avatar: 'AVATAR',
|
|
1374
|
-
email: 'EMAIL',
|
|
1375
|
-
phone: 'PHONE',
|
|
1376
|
-
};
|
|
1377
|
-
const FIELD_TYPES_FORMATS = {
|
|
1378
|
-
EMAIL: new RegExp('^\\w+([\\.-]?\\w+)@\\w+([\\.-]?\\w+)(\\.\\w{2,3})+$'),
|
|
1379
|
-
};
|
|
1314
|
+
const DEFAULT_ERROR_TYPE = 'error';
|
|
1315
|
+
const DEFAULT_CAPTURE_TYPE = 'INPUT';
|
|
1316
|
+
const DEFAULT_ALIGNMENT = 'left';
|
|
1380
1317
|
const STD_MAX_LENGTH = 50;
|
|
1381
1318
|
const BIG_MAX_LENGTH = 500;
|
|
1319
|
+
const fldAttr = {
|
|
1320
|
+
validateOnServer: 'validateOnServer',
|
|
1321
|
+
value: '_fieldValue',
|
|
1322
|
+
minValue: '_minValue',
|
|
1323
|
+
maxValue: '_maxValue',
|
|
1324
|
+
maxLength: '_maxLength',
|
|
1325
|
+
onValidation: '_onValidation',
|
|
1326
|
+
intrinsicErrorMessage: '_intrinsicErrorMessage',
|
|
1327
|
+
code: 'fieldCode',
|
|
1328
|
+
info: 'fieldInfo',
|
|
1329
|
+
defaultValue: 'defaultValue',
|
|
1330
|
+
defaultEditable: 'defaultEditable',
|
|
1331
|
+
customAttributes: 'customAttributes',
|
|
1332
|
+
visibleLabel: 'visibleLabel',
|
|
1333
|
+
required: 'fieldRequired',
|
|
1334
|
+
hasChanged: 'hasChanged',
|
|
1335
|
+
outputOnly: 'outputOnly',
|
|
1336
|
+
captureType: 'captureType',
|
|
1337
|
+
title: 'fieldTitle',
|
|
1338
|
+
type: 'fieldType',
|
|
1339
|
+
alignment: 'fieldAlignment',
|
|
1340
|
+
format: 'fieldFormat',
|
|
1341
|
+
externalValue: 'externalValue',
|
|
1342
|
+
tooltipText: 'tooltipText',
|
|
1343
|
+
errorType: 'errorType',
|
|
1344
|
+
errorCode: 'errorCode',
|
|
1345
|
+
errorMessage: 'errorMessage',
|
|
1346
|
+
options: 'fieldOptions',
|
|
1347
|
+
};
|
|
1382
1348
|
class FieldDescriptor extends FormElement {
|
|
1383
|
-
constructor(inputFieldReceived) {
|
|
1384
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
1385
|
-
super(inputFieldReceived);
|
|
1349
|
+
constructor(inputFieldReceived, formConfig) {
|
|
1350
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
1351
|
+
super(inputFieldReceived, formConfig);
|
|
1386
1352
|
this._editionFinish = new Subject();
|
|
1387
1353
|
this._editionPartial = new Subject();
|
|
1388
1354
|
this._detailRequest = new Subject();
|
|
1389
|
-
this.
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
this.
|
|
1393
|
-
this.
|
|
1394
|
-
this.captureType =
|
|
1395
|
-
this.
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
this.
|
|
1401
|
-
|
|
1355
|
+
this._attributeChange = new Subject();
|
|
1356
|
+
this.elementType = elementTypes.field;
|
|
1357
|
+
const fld = (inputFieldReceived) ? inputFieldReceived : {};
|
|
1358
|
+
this.setAttr(fldAttr.code, fld.fieldCode);
|
|
1359
|
+
this.setAttr(fldAttr.title, (_a = fld.fieldTitle) !== null && _a !== void 0 ? _a : this.fieldCode);
|
|
1360
|
+
this.setAttr(fldAttr.captureType, (_b = fld.captureType) !== null && _b !== void 0 ? _b : DEFAULT_CAPTURE_TYPE);
|
|
1361
|
+
this.setAttr(fldAttr.defaultValue, (_c = fld.defaultValue) !== null && _c !== void 0 ? _c : null);
|
|
1362
|
+
const defaultTypeAlignment = (this._formConfig.tableFieldStyles[this.fieldType] != null)
|
|
1363
|
+
? this._formConfig.tableFieldStyles[this.fieldType]['text-align'] : DEFAULT_ALIGNMENT;
|
|
1364
|
+
const fieldAlignment = (fld.alignment != null) ? fld.alignment.toLowerCase() : defaultTypeAlignment;
|
|
1365
|
+
this.setAttr(fldAttr.alignment, fieldAlignment);
|
|
1366
|
+
this.setAttr(fldAttr.info, fld.info || '');
|
|
1367
|
+
let fieldFormat;
|
|
1402
1368
|
try {
|
|
1403
|
-
|
|
1369
|
+
fieldFormat = (fld.format) ? new RegExp(fld.format) : null;
|
|
1404
1370
|
}
|
|
1405
1371
|
catch (e) {
|
|
1406
|
-
|
|
1407
|
-
}
|
|
1408
|
-
this.
|
|
1409
|
-
this.
|
|
1410
|
-
this.
|
|
1411
|
-
this.
|
|
1412
|
-
this.
|
|
1413
|
-
this.
|
|
1414
|
-
this.
|
|
1415
|
-
this.
|
|
1416
|
-
|
|
1417
|
-
this.
|
|
1418
|
-
this.
|
|
1419
|
-
this.
|
|
1420
|
-
|
|
1421
|
-
|
|
1372
|
+
fieldFormat = null;
|
|
1373
|
+
}
|
|
1374
|
+
this.setAttr(fldAttr.format, fieldFormat);
|
|
1375
|
+
this.setAttr(fldAttr.validateOnServer, (_d = fld.serverAction) !== null && _d !== void 0 ? _d : false);
|
|
1376
|
+
this.setAttr(fldAttr.customAttributes, (_e = fld.customAttributes) !== null && _e !== void 0 ? _e : {});
|
|
1377
|
+
this.setAttr(fldAttr.tooltipText, fld.tooltip || '');
|
|
1378
|
+
this.setAttr(fldAttr.defaultEditable, this.enabled);
|
|
1379
|
+
this.setAttr(fldAttr.required, (_f = fld.required) !== null && _f !== void 0 ? _f : false);
|
|
1380
|
+
this.setError(fld.errorCode, fld.errorMessage, (_g = fld.errorType) !== null && _g !== void 0 ? _g : DEFAULT_ERROR_TYPE);
|
|
1381
|
+
this.setAttr(fldAttr.outputOnly, (_h = fld.outputOnly) !== null && _h !== void 0 ? _h : false);
|
|
1382
|
+
const maxLength = (_j = fld.maxLength) !== null && _j !== void 0 ? _j : (this.captureType === 'TEXTAREA' ? BIG_MAX_LENGTH : STD_MAX_LENGTH);
|
|
1383
|
+
this.setAttr(fldAttr.maxLength, maxLength);
|
|
1384
|
+
this.setAttr(fldAttr.intrinsicErrorMessage, (_k = this._formConfig.fieldTypeErrMsg[this.fieldType]) !== null && _k !== void 0 ? _k : this._formConfig.fieldTypeErrMsg.DEFAULT);
|
|
1385
|
+
this.setFieldType(fld.fieldTypeCode);
|
|
1386
|
+
this.setEditable((_l = fld.editable) !== null && _l !== void 0 ? _l : true);
|
|
1387
|
+
this.setVisibleLabel((_m = fld.visibleLabel) !== null && _m !== void 0 ? _m : true);
|
|
1388
|
+
this.setVisibility(fld.visible);
|
|
1389
|
+
this.setFieldOptions(fld.fieldOptions);
|
|
1390
|
+
this.setValue(fld.fieldValue || this.defaultValue || '');
|
|
1422
1391
|
}
|
|
1423
1392
|
get name() { return this.fieldCode; }
|
|
1424
1393
|
get editionFinish() { return this._editionFinish; }
|
|
1394
|
+
get attributeChange() { return this._attributeChange; }
|
|
1425
1395
|
get editionPartial() { return this._editionPartial; }
|
|
1426
1396
|
get detailRequest() { return this._detailRequest; }
|
|
1427
1397
|
get validating() { return this._onValidation; }
|
|
1428
|
-
set validating(isValidating) { this.
|
|
1429
|
-
setIntrinsicErrorMessage(message) { this.
|
|
1398
|
+
set validating(isValidating) { this.setAttr(fldAttr.onValidation, isValidating); }
|
|
1399
|
+
setIntrinsicErrorMessage(message) { this.setAttr(fldAttr.intrinsicErrorMessage, message); }
|
|
1430
1400
|
set intrinsicErrorMessage(message) { this.setIntrinsicErrorMessage(message); }
|
|
1431
1401
|
get fieldValue() { return this.getValue(); }
|
|
1432
1402
|
get required() { return this.fieldRequired; }
|
|
1433
|
-
set required(required) { this.
|
|
1403
|
+
set required(required) { this.setAttr(fldAttr.required, required !== null && required !== void 0 ? required : false); }
|
|
1434
1404
|
get maxLength() { return (this._maxLength > 0) ? this._maxLength.toString() : ''; }
|
|
1435
1405
|
set maxLength(requiredMaxLength) {
|
|
1436
1406
|
if (typeof requiredMaxLength === 'string') {
|
|
1437
|
-
this.
|
|
1407
|
+
this.setAttr(fldAttr.maxLength, parseInt(requiredMaxLength, 10));
|
|
1438
1408
|
}
|
|
1439
1409
|
else if (typeof requiredMaxLength === 'number') {
|
|
1440
|
-
this.
|
|
1410
|
+
this.setAttr(fldAttr.maxLength, requiredMaxLength);
|
|
1441
1411
|
}
|
|
1442
1412
|
}
|
|
1443
1413
|
get value() { return this.getValue(); }
|
|
@@ -1447,39 +1417,48 @@ class FieldDescriptor extends FormElement {
|
|
|
1447
1417
|
this._editionPartial.next({ code: this.fieldCode, intrinsicValidation });
|
|
1448
1418
|
}
|
|
1449
1419
|
notifyEditionFinish() {
|
|
1450
|
-
var _a, _b, _c, _d;
|
|
1420
|
+
var _a, _b, _c, _d, _e;
|
|
1451
1421
|
let intrinsicValidation = true;
|
|
1452
|
-
const fieldDefaultFormat = (_a =
|
|
1422
|
+
const fieldDefaultFormat = (_b = (_a = this._formConfig.fieldTypesPatterns) === null || _a === void 0 ? void 0 : _a[this.fieldType]) !== null && _b !== void 0 ? _b : null;
|
|
1453
1423
|
const fieldValue = this.getValue();
|
|
1454
1424
|
if (fieldValue && (fieldDefaultFormat || this.fieldFormat)) {
|
|
1455
|
-
intrinsicValidation = ((
|
|
1456
|
-
&& ((
|
|
1425
|
+
intrinsicValidation = ((_c = fieldDefaultFormat === null || fieldDefaultFormat === void 0 ? void 0 : fieldDefaultFormat.test(fieldValue)) !== null && _c !== void 0 ? _c : true)
|
|
1426
|
+
&& ((_e = (_d = this.fieldFormat) === null || _d === void 0 ? void 0 : _d.test(fieldValue)) !== null && _e !== void 0 ? _e : true);
|
|
1457
1427
|
if (!intrinsicValidation) {
|
|
1458
1428
|
this.setError('99', this._intrinsicErrorMessage);
|
|
1459
1429
|
}
|
|
1460
1430
|
}
|
|
1461
1431
|
this._editionFinish.next({ code: this.fieldCode, intrinsicValidation });
|
|
1462
1432
|
}
|
|
1433
|
+
setAttr(name, value) {
|
|
1434
|
+
this[name] = value;
|
|
1435
|
+
if (this._formConfig.monitoredFieldAttributes.includes(name)) {
|
|
1436
|
+
this._attributeChange.next({ name, value });
|
|
1437
|
+
}
|
|
1438
|
+
}
|
|
1463
1439
|
notifyEditionDetailRequest() {
|
|
1464
1440
|
this._detailRequest.next(this.fieldCode);
|
|
1465
1441
|
}
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1442
|
+
getCustomAttribute(name) { var _a, _b; return (_b = (_a = this.customAttributes) === null || _a === void 0 ? void 0 : _a[name]) !== null && _b !== void 0 ? _b : null; }
|
|
1443
|
+
setVisibleLabel(visibleLabel) { this.setAttr(fldAttr.visibleLabel, visibleLabel); }
|
|
1444
|
+
showLabel() { this.setVisibleLabel(true); }
|
|
1445
|
+
hideLabel() { this.setVisibleLabel(false); }
|
|
1446
|
+
setChanged(hasChanged) { this.setAttr(fldAttr.hasChanged, hasChanged); }
|
|
1447
|
+
changed() { this.setChanged(true); }
|
|
1469
1448
|
getRawValue() { return this._fieldValue; }
|
|
1470
|
-
setLabel(label) { this.
|
|
1449
|
+
setLabel(label) { this.setAttr(fldAttr.title, label); }
|
|
1471
1450
|
clean() { this.setValue(this.defaultValue || ''); }
|
|
1472
1451
|
get backend() { return this.validateOnServer; }
|
|
1473
|
-
setVisibleLabel(visibleLabel) { this.visibleLabel = visibleLabel; }
|
|
1474
1452
|
setEditable(editable = true) { (editable) ? this.enable() : this.disable(); }
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
this.errorCode
|
|
1478
|
-
this.
|
|
1453
|
+
hasError() { return this.errorCode !== '00'; }
|
|
1454
|
+
setError(code, message, type = DEFAULT_ERROR_TYPE) {
|
|
1455
|
+
this.setAttr(fldAttr.errorCode, code !== null && code !== void 0 ? code : '00');
|
|
1456
|
+
this.setAttr(fldAttr.errorType, (this.errorCode === '00') ? '' : type);
|
|
1457
|
+
this.setAttr(fldAttr.errorMessage, message !== null && message !== void 0 ? message : '');
|
|
1479
1458
|
}
|
|
1480
1459
|
getError() { return { type: this.errorType, code: this.errorCode, message: this.errorMessage }; }
|
|
1481
1460
|
get error() { return this.getError(); }
|
|
1482
|
-
set error(errorObj) { this.setError(errorObj.code, errorObj.message, errorObj.type); }
|
|
1461
|
+
set error(errorObj) { var _a; this.setError(errorObj.code, errorObj.message, (_a = errorObj.type) !== null && _a !== void 0 ? _a : DEFAULT_ERROR_TYPE); }
|
|
1483
1462
|
getErrorCode() { return this.getError().code; }
|
|
1484
1463
|
setErrorCode(code) { this.setError(code, this.errorMessage); }
|
|
1485
1464
|
getErrorMessage() { return this.getError().message; }
|
|
@@ -1489,7 +1468,7 @@ class FieldDescriptor extends FormElement {
|
|
|
1489
1468
|
if (fieldCurrentValue === undefined || fieldCurrentValue === null) {
|
|
1490
1469
|
return true;
|
|
1491
1470
|
}
|
|
1492
|
-
if ((this.fieldType ===
|
|
1471
|
+
if ((this.fieldType === this._formConfig.fieldTypes.array || this.fieldType === this._formConfig.fieldTypes.phone)
|
|
1493
1472
|
&& Array.isArray(fieldCurrentValue) && fieldCurrentValue.length === 0) {
|
|
1494
1473
|
return true;
|
|
1495
1474
|
}
|
|
@@ -1499,10 +1478,10 @@ class FieldDescriptor extends FormElement {
|
|
|
1499
1478
|
getValue() {
|
|
1500
1479
|
var _a;
|
|
1501
1480
|
switch (this.fieldType) {
|
|
1502
|
-
case
|
|
1481
|
+
case this._formConfig.fieldTypes.check:
|
|
1503
1482
|
return (_a = this._fieldValue) !== null && _a !== void 0 ? _a : false;
|
|
1504
1483
|
break;
|
|
1505
|
-
case
|
|
1484
|
+
case this._formConfig.fieldTypes.currency:
|
|
1506
1485
|
return this._fieldValue.replace(',', '');
|
|
1507
1486
|
break;
|
|
1508
1487
|
default:
|
|
@@ -1512,68 +1491,39 @@ class FieldDescriptor extends FormElement {
|
|
|
1512
1491
|
}
|
|
1513
1492
|
updateFromServer(fld) {
|
|
1514
1493
|
var _a;
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
this.
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
this.
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
(this.
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
(this.
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
(this.
|
|
1532
|
-
|
|
1533
|
-
if (FIELD_INFO in fld) {
|
|
1534
|
-
(this.fieldInfo = fld.info);
|
|
1535
|
-
}
|
|
1536
|
-
if (FIELD_EDITABLE in fld) {
|
|
1537
|
-
this.setEditable(fld.editable);
|
|
1538
|
-
}
|
|
1539
|
-
if (FIELD_TITLE in fld) {
|
|
1540
|
-
this.setLabel(fld.fieldTitle.toString());
|
|
1541
|
-
}
|
|
1542
|
-
if (FIELD_VALUE in fld) {
|
|
1543
|
-
this.hasChanged = false;
|
|
1544
|
-
this.setValue(fld.fieldValue);
|
|
1545
|
-
}
|
|
1546
|
-
if (FIELD_OPTIONS in fld) {
|
|
1547
|
-
this.setFieldOptions(fld.fieldOptions);
|
|
1548
|
-
}
|
|
1549
|
-
if (FIELD_CAPTURE_TYPE in fld) {
|
|
1550
|
-
this.captureType = fld.captureType || 'INPUT';
|
|
1551
|
-
}
|
|
1552
|
-
if (FIELD_TYPE in fld) {
|
|
1553
|
-
this.setFieldType(fld.fieldTypeCode);
|
|
1554
|
-
}
|
|
1555
|
-
if (FIELD_MAX_LENGTH in fld) {
|
|
1556
|
-
this.maxLength = fld.maxLength;
|
|
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);
|
|
1557
1512
|
}
|
|
1558
1513
|
}
|
|
1559
1514
|
setFieldType(inputFieldType) {
|
|
1560
|
-
this.
|
|
1561
|
-
/**
|
|
1562
|
-
* Se elimina la validación de que sea un tipo conocido
|
|
1563
|
-
* this.fieldType = (inputFieldType && FIELDTYPES.includes(inputFieldType))
|
|
1564
|
-
* ? inputFieldType : componentConstants.FIELDTYPE_TEXT;
|
|
1565
|
-
*/
|
|
1515
|
+
this.setAttr(fldAttr.type, inputFieldType);
|
|
1566
1516
|
}
|
|
1567
1517
|
format() {
|
|
1568
|
-
if (this.fieldType ===
|
|
1569
|
-
this.
|
|
1518
|
+
if (this.fieldType === this._formConfig.fieldTypes.currency) {
|
|
1519
|
+
this.setAttr(fldAttr.value, formatCurrency(this._fieldValue));
|
|
1570
1520
|
}
|
|
1571
1521
|
}
|
|
1572
1522
|
setMinValue(minValue) {
|
|
1573
1523
|
var _a, _b, _c;
|
|
1574
|
-
if (this.fieldType ===
|
|
1524
|
+
if (this.fieldType === this._formConfig.fieldTypes.date
|
|
1575
1525
|
&& ((_a = this.widget) === null || _a === void 0 ? void 0 : _a.setMinValue)) {
|
|
1576
|
-
this.
|
|
1526
|
+
this.setAttr(fldAttr.minValue, minValue);
|
|
1577
1527
|
if (!minValue) {
|
|
1578
1528
|
(_b = this.widget) === null || _b === void 0 ? void 0 : _b.setMinValue(false);
|
|
1579
1529
|
}
|
|
@@ -1585,9 +1535,9 @@ class FieldDescriptor extends FormElement {
|
|
|
1585
1535
|
}
|
|
1586
1536
|
setMaxValue(maxValue) {
|
|
1587
1537
|
var _a, _b, _c;
|
|
1588
|
-
if (this.fieldType ===
|
|
1538
|
+
if (this.fieldType === this._formConfig.fieldTypes.date
|
|
1589
1539
|
&& ((_a = this.widget) === null || _a === void 0 ? void 0 : _a.setMaxValue)) {
|
|
1590
|
-
this.
|
|
1540
|
+
this.setAttr(fldAttr.maxValue, maxValue);
|
|
1591
1541
|
if (!maxValue) {
|
|
1592
1542
|
(_b = this.widget) === null || _b === void 0 ? void 0 : _b.setMaxValue(false);
|
|
1593
1543
|
}
|
|
@@ -1607,21 +1557,23 @@ class FieldDescriptor extends FormElement {
|
|
|
1607
1557
|
|| !Array.isArray(newOptions)) {
|
|
1608
1558
|
return;
|
|
1609
1559
|
}
|
|
1610
|
-
|
|
1560
|
+
let fieldOptions = newOptions.map(option => {
|
|
1611
1561
|
if (option.text !== undefined && option.text !== null
|
|
1612
1562
|
&& option.value !== undefined && option.value !== null) {
|
|
1613
1563
|
return { fieldOptionValue: option.text, fieldOptionId: option.value };
|
|
1614
1564
|
}
|
|
1615
1565
|
return Object.assign({}, option);
|
|
1616
1566
|
});
|
|
1617
|
-
|
|
1567
|
+
fieldOptions = (fieldOptions && Array.isArray(fieldOptions)
|
|
1618
1568
|
&& fieldOptions.length > 0) ? fieldOptions : [];
|
|
1619
|
-
|
|
1569
|
+
this.setAttr(fldAttr.options, fieldOptions);
|
|
1570
|
+
if (this.fieldType === this._formConfig.fieldTypes.array && this.widget) {
|
|
1620
1571
|
return (_a = this.widget) === null || _a === void 0 ? void 0 : _a.refereshContent();
|
|
1621
1572
|
}
|
|
1622
1573
|
if (this._fieldValue) {
|
|
1623
|
-
if (this.fieldType ===
|
|
1624
|
-
|
|
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);
|
|
1625
1577
|
}
|
|
1626
1578
|
else {
|
|
1627
1579
|
const valInOptions = this.fieldOptions
|
|
@@ -1641,17 +1593,17 @@ class FieldDescriptor extends FormElement {
|
|
|
1641
1593
|
setValue(newValue, widgetUpdate = true) {
|
|
1642
1594
|
var _a;
|
|
1643
1595
|
if (typeof newValue === UNDEFINED || newValue === null) {
|
|
1644
|
-
return;
|
|
1596
|
+
return true;
|
|
1645
1597
|
}
|
|
1646
1598
|
let newFinalValue;
|
|
1647
1599
|
switch (this.fieldType) {
|
|
1648
1600
|
case 'BOOLEAN':
|
|
1649
1601
|
newFinalValue = !!newValue;
|
|
1650
1602
|
break;
|
|
1651
|
-
case
|
|
1603
|
+
case this._formConfig.fieldTypes.check:
|
|
1652
1604
|
newFinalValue = !!newValue;
|
|
1653
1605
|
break;
|
|
1654
|
-
case
|
|
1606
|
+
case this._formConfig.fieldTypes.array:
|
|
1655
1607
|
if (newValue === null || newValue === '') {
|
|
1656
1608
|
newFinalValue = [];
|
|
1657
1609
|
}
|
|
@@ -1665,7 +1617,7 @@ class FieldDescriptor extends FormElement {
|
|
|
1665
1617
|
newFinalValue = newValue;
|
|
1666
1618
|
}
|
|
1667
1619
|
break;
|
|
1668
|
-
case
|
|
1620
|
+
case this._formConfig.fieldTypes.map:
|
|
1669
1621
|
newFinalValue = newValue;
|
|
1670
1622
|
if (newFinalValue && this.widget && widgetUpdate) {
|
|
1671
1623
|
const latitude = parseFloat(newFinalValue[0]);
|
|
@@ -1673,7 +1625,7 @@ class FieldDescriptor extends FormElement {
|
|
|
1673
1625
|
(_a = this.widget) === null || _a === void 0 ? void 0 : _a.setLocation(latitude, longitude);
|
|
1674
1626
|
}
|
|
1675
1627
|
break;
|
|
1676
|
-
case
|
|
1628
|
+
case this._formConfig.fieldTypes.currency:
|
|
1677
1629
|
newFinalValue = formatCurrency(this._fieldValue);
|
|
1678
1630
|
break;
|
|
1679
1631
|
default:
|
|
@@ -1681,22 +1633,24 @@ class FieldDescriptor extends FormElement {
|
|
|
1681
1633
|
break;
|
|
1682
1634
|
}
|
|
1683
1635
|
if (this._fieldValue !== newFinalValue) {
|
|
1684
|
-
this.
|
|
1685
|
-
this.
|
|
1636
|
+
this.setChanged(true);
|
|
1637
|
+
this.setAttr(fldAttr.value, newFinalValue);
|
|
1686
1638
|
}
|
|
1639
|
+
return true;
|
|
1687
1640
|
}
|
|
1688
1641
|
}
|
|
1689
1642
|
|
|
1690
1643
|
const HEADER = 'HEADER';
|
|
1691
1644
|
const NO_ERROR = '00';
|
|
1692
1645
|
class FormStructureAndData {
|
|
1693
|
-
constructor(definitionReceived) {
|
|
1646
|
+
constructor(definitionReceived, formConfig) {
|
|
1694
1647
|
this._fieldsObj = {};
|
|
1695
1648
|
this._actionsObj = {};
|
|
1696
1649
|
this._tableObj = {};
|
|
1697
1650
|
this._sectionsObj = {};
|
|
1698
1651
|
this._immutableData = {};
|
|
1699
1652
|
this._extraInfo = {};
|
|
1653
|
+
this._formConfig = formConfig;
|
|
1700
1654
|
this.state = '';
|
|
1701
1655
|
this._actions = [];
|
|
1702
1656
|
this._fields = [];
|
|
@@ -1730,7 +1684,7 @@ class FormStructureAndData {
|
|
|
1730
1684
|
return Object.assign(Object.assign({}, objDef), { visibleStates, enabledStates });
|
|
1731
1685
|
});
|
|
1732
1686
|
for (const actionReceived of formActions) {
|
|
1733
|
-
const globalAction = new FormAction(actionReceived);
|
|
1687
|
+
const globalAction = new FormAction(actionReceived, this._formConfig);
|
|
1734
1688
|
const globalActionCode = globalAction.actionCode;
|
|
1735
1689
|
if (globalActionCode) {
|
|
1736
1690
|
this._actions.push(globalAction);
|
|
@@ -1751,7 +1705,7 @@ class FormStructureAndData {
|
|
|
1751
1705
|
return Object.assign(Object.assign({}, objDef), { visibleStates, enabledStates });
|
|
1752
1706
|
});
|
|
1753
1707
|
for (const fieldReceived of formFields) {
|
|
1754
|
-
const fieldToAdd = new FieldDescriptor(fieldReceived);
|
|
1708
|
+
const fieldToAdd = new FieldDescriptor(fieldReceived, this._formConfig);
|
|
1755
1709
|
const fieldCode = fieldToAdd.fieldCode;
|
|
1756
1710
|
if (fieldCode) {
|
|
1757
1711
|
this._fields.push(fieldToAdd);
|
|
@@ -1770,12 +1724,12 @@ class FormStructureAndData {
|
|
|
1770
1724
|
enabledStates = [...visibleStates];
|
|
1771
1725
|
}
|
|
1772
1726
|
if (!visibleStates || visibleStates.length === 0) {
|
|
1773
|
-
visibleStates =
|
|
1727
|
+
visibleStates = this._formConfig.defaultStateFlow.states;
|
|
1774
1728
|
}
|
|
1775
1729
|
return Object.assign(Object.assign({}, objDef), { visibleStates, enabledStates });
|
|
1776
1730
|
});
|
|
1777
1731
|
for (const tableReceived of tables) {
|
|
1778
|
-
const tableToAdd = new RecordTable(tableReceived);
|
|
1732
|
+
const tableToAdd = new RecordTable(tableReceived, this._formConfig);
|
|
1779
1733
|
const tableCode = tableToAdd.tableCode;
|
|
1780
1734
|
if (tableCode) {
|
|
1781
1735
|
this._tables.push(tableToAdd);
|
|
@@ -1827,7 +1781,7 @@ class FormStructureAndData {
|
|
|
1827
1781
|
}
|
|
1828
1782
|
setStateFlow(states, transitions, defaultState) {
|
|
1829
1783
|
if (!states || !transitions) {
|
|
1830
|
-
this._stateFlow = JSON.parse(JSON.stringify(
|
|
1784
|
+
this._stateFlow = JSON.parse(JSON.stringify(this._formConfig.defaultStateFlow));
|
|
1831
1785
|
return;
|
|
1832
1786
|
}
|
|
1833
1787
|
this._stateFlow.states = states;
|
|
@@ -2053,8 +2007,8 @@ class FormStructureAndData {
|
|
|
2053
2007
|
const fieldObject = this.getFieldObject(fieldCode);
|
|
2054
2008
|
return (fieldObject) ? fieldObject.setValue(fieldValue) : null;
|
|
2055
2009
|
}
|
|
2056
|
-
setFieldError(code, message, type = 'error') {
|
|
2057
|
-
const fieldObject = this.getFieldObject(
|
|
2010
|
+
setFieldError(fieldCode, code, message, type = 'error') {
|
|
2011
|
+
const fieldObject = this.getFieldObject(fieldCode);
|
|
2058
2012
|
return (fieldObject) ? fieldObject.setError(code, message, type) : null;
|
|
2059
2013
|
}
|
|
2060
2014
|
setFieldIntrinsicErrorMessage(code, message) {
|
|
@@ -2368,7 +2322,6 @@ class BasicFormComponent {
|
|
|
2368
2322
|
this.transitionToken = null;
|
|
2369
2323
|
this.inputDataFields = [];
|
|
2370
2324
|
this.extraData = null;
|
|
2371
|
-
this.componentConstants = componentConstants;
|
|
2372
2325
|
this.definitionObtained = false;
|
|
2373
2326
|
this.formVisible = false;
|
|
2374
2327
|
this.inServerProcess = false;
|
|
@@ -2390,6 +2343,9 @@ class BasicFormComponent {
|
|
|
2390
2343
|
this.cleanStart();
|
|
2391
2344
|
this.customPreProcessing();
|
|
2392
2345
|
}
|
|
2346
|
+
setConfig(formConfig) {
|
|
2347
|
+
this.formConfig = formConfig;
|
|
2348
|
+
}
|
|
2393
2349
|
cleanStart() {
|
|
2394
2350
|
this._errorType = '';
|
|
2395
2351
|
this.errorCode = '';
|
|
@@ -2678,7 +2634,7 @@ class BasicFormComponent {
|
|
|
2678
2634
|
this.inServerProcess = true;
|
|
2679
2635
|
const formDefinition = yield this.formManagerService.getFormDefinition(this.name);
|
|
2680
2636
|
this.inServerProcess = false;
|
|
2681
|
-
this.formStructure = new FormStructureAndData(formDefinition);
|
|
2637
|
+
this.formStructure = new FormStructureAndData(formDefinition, this.formConfig);
|
|
2682
2638
|
this.definitionObtained = true;
|
|
2683
2639
|
}
|
|
2684
2640
|
else {
|
|
@@ -2704,7 +2660,7 @@ class BasicFormComponent {
|
|
|
2704
2660
|
this.setFieldValue(fieldCode, fieldValue);
|
|
2705
2661
|
}
|
|
2706
2662
|
}
|
|
2707
|
-
const recordResponse = yield this.requestFormAction(
|
|
2663
|
+
const recordResponse = yield this.requestFormAction(formActions.getData);
|
|
2708
2664
|
this.checkErrorRecordReceived(recordResponse);
|
|
2709
2665
|
this.formVisible = true;
|
|
2710
2666
|
this.subscribeSectionActivation();
|
|
@@ -2724,7 +2680,7 @@ class BasicFormComponent {
|
|
|
2724
2680
|
this.errorDetail = recordResponse.errorDetail;
|
|
2725
2681
|
}
|
|
2726
2682
|
errorOccured() {
|
|
2727
|
-
return (this.errorCode !==
|
|
2683
|
+
return (this.errorCode !== '00');
|
|
2728
2684
|
}
|
|
2729
2685
|
changeState(state) { return this.formStructure.changeState(state); }
|
|
2730
2686
|
changeFormMode(state) { return this.changeState(state); }
|
|
@@ -3005,7 +2961,7 @@ class BasicFormComponent {
|
|
|
3005
2961
|
if (fieldObj.backend) {
|
|
3006
2962
|
fieldObj.validating = true;
|
|
3007
2963
|
validationResult = yield this
|
|
3008
|
-
.requestFormAction(
|
|
2964
|
+
.requestFormAction(formActions.validate, fieldObj.fieldCode);
|
|
3009
2965
|
finish = !this.errorOccured();
|
|
3010
2966
|
}
|
|
3011
2967
|
if (finish) {
|
|
@@ -3194,7 +3150,7 @@ class BasicFormComponent {
|
|
|
3194
3150
|
actionCode
|
|
3195
3151
|
};
|
|
3196
3152
|
actionResult = yield this
|
|
3197
|
-
.requestFormAction(
|
|
3153
|
+
.requestFormAction(formActions.tableAction, actionSubject);
|
|
3198
3154
|
finish = !this.errorOccured();
|
|
3199
3155
|
}
|
|
3200
3156
|
if (finish) {
|
|
@@ -3271,13 +3227,13 @@ class BasicFormComponent {
|
|
|
3271
3227
|
if (action.backend) {
|
|
3272
3228
|
const actionSubject = {
|
|
3273
3229
|
tableCode,
|
|
3274
|
-
actionType:
|
|
3230
|
+
actionType: this.formConfig.tableActions.inline,
|
|
3275
3231
|
actionCode,
|
|
3276
3232
|
tableRecordId: recordId,
|
|
3277
3233
|
tableRecordData: recordData
|
|
3278
3234
|
};
|
|
3279
3235
|
actionResult = yield this
|
|
3280
|
-
.requestFormAction(
|
|
3236
|
+
.requestFormAction(formActions.tableAction, actionSubject);
|
|
3281
3237
|
finish = !this.errorOccured();
|
|
3282
3238
|
}
|
|
3283
3239
|
if (finish) {
|
|
@@ -3350,13 +3306,13 @@ class BasicFormComponent {
|
|
|
3350
3306
|
if (tableObject.selectionBackend) {
|
|
3351
3307
|
const actionSubject = {
|
|
3352
3308
|
tableCode,
|
|
3353
|
-
actionType:
|
|
3309
|
+
actionType: this.formConfig.tableActions.rowSelection,
|
|
3354
3310
|
actionCode: null,
|
|
3355
3311
|
tableRecordId: recordId,
|
|
3356
3312
|
tableRecordData: recordData
|
|
3357
3313
|
};
|
|
3358
3314
|
actionResult = yield this
|
|
3359
|
-
.requestFormAction(
|
|
3315
|
+
.requestFormAction(formActions.tableAction, actionSubject);
|
|
3360
3316
|
finish = !this.errorOccured();
|
|
3361
3317
|
}
|
|
3362
3318
|
if (finish) {
|
|
@@ -3430,12 +3386,12 @@ class BasicFormComponent {
|
|
|
3430
3386
|
if (action.backend) {
|
|
3431
3387
|
const actionSubject = {
|
|
3432
3388
|
tableCode,
|
|
3433
|
-
actionType:
|
|
3389
|
+
actionType: this.formConfig.tableActions.selection,
|
|
3434
3390
|
actionCode,
|
|
3435
3391
|
selectedRecords
|
|
3436
3392
|
};
|
|
3437
3393
|
actionResult = yield this
|
|
3438
|
-
.requestFormAction(
|
|
3394
|
+
.requestFormAction(formActions.tableAction, actionSubject);
|
|
3439
3395
|
finish = !this.errorOccured();
|
|
3440
3396
|
}
|
|
3441
3397
|
if (finish) {
|
|
@@ -3493,7 +3449,7 @@ class BasicFormComponent {
|
|
|
3493
3449
|
tableObject.putOnWait();
|
|
3494
3450
|
const actionSubject = { tableCode };
|
|
3495
3451
|
const actionResult = yield this
|
|
3496
|
-
.requestFormAction(
|
|
3452
|
+
.requestFormAction(formActions.getTableData, actionSubject);
|
|
3497
3453
|
if (this.errorOccured()) {
|
|
3498
3454
|
this.displayTableServerError();
|
|
3499
3455
|
}
|
|
@@ -3527,15 +3483,15 @@ class BasicFormComponent {
|
|
|
3527
3483
|
this.resetError();
|
|
3528
3484
|
const completeFields = this.checkSectionRequiredFields(sectionCode, reqFieldMessage);
|
|
3529
3485
|
if (!completeFields) {
|
|
3530
|
-
this.setError(
|
|
3486
|
+
this.setError(this.formConfig.formStandardErrors.typeWarning, this.formConfig.formStandardErrors.validationTitle, this.formConfig.formStandardErrors.requiredFields);
|
|
3531
3487
|
return;
|
|
3532
3488
|
}
|
|
3533
3489
|
let validationError = false;
|
|
3534
3490
|
const requiredEmptyFields = this.getRequiredEmptyFields(null, sectionCode);
|
|
3535
3491
|
if (requiredEmptyFields.length > 0) {
|
|
3536
3492
|
validationError = true;
|
|
3537
|
-
this.setError(
|
|
3538
|
-
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);
|
|
3539
3495
|
for (const fieldCode of requiredEmptyFields) {
|
|
3540
3496
|
const requiredEmptyField = this.getField(fieldCode);
|
|
3541
3497
|
if (requiredEmptyField && requiredEmptyField.widget
|
|
@@ -3548,7 +3504,7 @@ class BasicFormComponent {
|
|
|
3548
3504
|
const validationIssueFields = this.getFieldsWithValidationIssues(null, sectionCode);
|
|
3549
3505
|
if (!validationError && validationIssueFields.length > 0) {
|
|
3550
3506
|
validationError = true;
|
|
3551
|
-
this.setError(
|
|
3507
|
+
this.setError(this.formConfig.formStandardErrors.typeWarning, this.formConfig.formStandardErrors.validationTitle, this.formConfig.formStandardErrors.validationFields);
|
|
3552
3508
|
for (const fieldCode of validationIssueFields) {
|
|
3553
3509
|
const validationIssueField = this.getField(fieldCode);
|
|
3554
3510
|
if (validationIssueField && validationIssueField.widget
|
|
@@ -3664,13 +3620,13 @@ class BasicFormComponent {
|
|
|
3664
3620
|
const requiredEmptyFields = this.getRequiredEmptyFields(recordCaptureFields, null);
|
|
3665
3621
|
if (requiredEmptyFields.length > 0) {
|
|
3666
3622
|
validationOk = false;
|
|
3667
|
-
this.setError(
|
|
3668
|
-
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);
|
|
3669
3625
|
}
|
|
3670
3626
|
const validationIssueFields = this.getFieldsWithValidationIssues(recordCaptureFields, null);
|
|
3671
3627
|
if (validationIssueFields.length > 0) {
|
|
3672
3628
|
validationOk = false;
|
|
3673
|
-
this.setError(
|
|
3629
|
+
this.setError(this.formConfig.formStandardErrors.typeWarning, this.formConfig.formStandardErrors.validationTitle, this.formConfig.formStandardErrors.validationFields);
|
|
3674
3630
|
}
|
|
3675
3631
|
return validationOk;
|
|
3676
3632
|
}
|