tuain-ng-forms-lib 0.12.32 → 12.0.4
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 +590 -622
- package/bundles/tuain-ng-forms-lib.umd.js.map +1 -1
- package/esm2015/lib/classes/forms/field.js +15 -8
- package/esm2015/lib/classes/forms/form.constants.js +3 -1
- package/esm2015/lib/classes/forms/form.js +2 -3
- package/esm2015/lib/components/elements/field.component.js +12 -40
- package/esm2015/lib/components/forms/basic-form.js +71 -71
- package/esm2015/lib/services/form-manager.service.js +60 -54
- package/fesm2015/tuain-ng-forms-lib.js +158 -173
- package/fesm2015/tuain-ng-forms-lib.js.map +1 -1
- package/lib/classes/forms/field.d.ts +1 -0
- package/lib/classes/forms/form.constants.d.ts +2 -0
- package/lib/components/elements/field.component.d.ts +0 -1
- package/lib/components/forms/basic-form.d.ts +21 -3
- package/lib/services/form-manager.service.d.ts +22 -15
- package/package.json +1 -1
- package/tuain-ng-forms-lib.metadata.json +1 -1
|
@@ -51,50 +51,22 @@ ActionComponent.propDecorators = {
|
|
|
51
51
|
showLabel: [{ type: Input }]
|
|
52
52
|
};
|
|
53
53
|
|
|
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',
|
|
67
|
-
};
|
|
68
54
|
class FieldComponent {
|
|
69
55
|
ngOnInit() {
|
|
70
|
-
var _a;
|
|
56
|
+
var _a, _b;
|
|
71
57
|
if (this.fieldObject) {
|
|
72
58
|
this.formConfig = (_a = this.fieldObject) === null || _a === void 0 ? void 0 : _a._formConfig;
|
|
73
|
-
//
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
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
|
|
59
|
+
// Inicialización
|
|
60
|
+
const mapping = Object.entries(this.formConfig.componentFieldAttrMap);
|
|
61
|
+
for (let index = 0; index < mapping.length; index++) {
|
|
62
|
+
const [fieldAttr, compAttr] = mapping[index];
|
|
63
|
+
this[compAttr.toString()] = (_b = this.fieldObject) === null || _b === void 0 ? void 0 : _b[fieldAttr.toString()];
|
|
64
|
+
}
|
|
65
|
+
// Subscripción a cambios en atributos
|
|
93
66
|
this.fieldObject.attributeChange.subscribe(event => {
|
|
94
|
-
const { name, value } = event;
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
}
|
|
67
|
+
const { name: fieldAttr, value } = event;
|
|
68
|
+
const compAttr = this.formConfig.componentFieldAttrMap[fieldAttr];
|
|
69
|
+
this.hasOwnProperty(compAttr) && (this[compAttr] = value);
|
|
98
70
|
});
|
|
99
71
|
}
|
|
100
72
|
this.start();
|
|
@@ -245,6 +217,8 @@ class Filter {
|
|
|
245
217
|
}
|
|
246
218
|
}
|
|
247
219
|
|
|
220
|
+
const NO_ERROR = '00';
|
|
221
|
+
const HEADER$1 = 'HEADER';
|
|
248
222
|
const elementTypes = {
|
|
249
223
|
action: 'ACTION',
|
|
250
224
|
field: 'FIELD',
|
|
@@ -1276,7 +1250,7 @@ class RecordFormSection {
|
|
|
1276
1250
|
supportMode(state) { return this.viewOnState(state); }
|
|
1277
1251
|
}
|
|
1278
1252
|
|
|
1279
|
-
const HEADER
|
|
1253
|
+
const HEADER = 'HEADER';
|
|
1280
1254
|
class FormAction extends FormElement {
|
|
1281
1255
|
constructor(actionDefinition, formConfig) {
|
|
1282
1256
|
var _a, _b;
|
|
@@ -1287,7 +1261,7 @@ class FormAction extends FormElement {
|
|
|
1287
1261
|
this.actionCode = actionDefinition.actionCode ? actionDefinition.actionCode.toString() : '';
|
|
1288
1262
|
this.actionName = actionDefinition.actionTitle;
|
|
1289
1263
|
this.iconName = actionDefinition.iconName || this.actionCode;
|
|
1290
|
-
this.location = actionDefinition.position || HEADER
|
|
1264
|
+
this.location = actionDefinition.position || HEADER;
|
|
1291
1265
|
this.backend = (_a = actionDefinition === null || actionDefinition === void 0 ? void 0 : actionDefinition.serverAction) !== null && _a !== void 0 ? _a : false;
|
|
1292
1266
|
this.newState = actionDefinition === null || actionDefinition === void 0 ? void 0 : actionDefinition.newState;
|
|
1293
1267
|
this.customAttributes = (_b = actionDefinition === null || actionDefinition === void 0 ? void 0 : actionDefinition.customAttributes) !== null && _b !== void 0 ? _b : null;
|
|
@@ -1450,10 +1424,11 @@ class FieldDescriptor extends FormElement {
|
|
|
1450
1424
|
clean() { this.setValue(this.defaultValue || ''); }
|
|
1451
1425
|
get backend() { return this.validateOnServer; }
|
|
1452
1426
|
setEditable(editable = true) { (editable) ? this.enable() : this.disable(); }
|
|
1453
|
-
hasError() { return this.errorCode !==
|
|
1427
|
+
hasError() { return this.errorCode !== NO_ERROR; }
|
|
1428
|
+
resetError() { (this.errorCode !== NO_ERROR) && this.setError(NO_ERROR, null); }
|
|
1454
1429
|
setError(code, message, type = DEFAULT_ERROR_TYPE) {
|
|
1455
|
-
this.setAttr(fldAttr.errorCode, code !== null && code !== void 0 ? code :
|
|
1456
|
-
this.setAttr(fldAttr.errorType, (this.errorCode ===
|
|
1430
|
+
this.setAttr(fldAttr.errorCode, code !== null && code !== void 0 ? code : NO_ERROR);
|
|
1431
|
+
this.setAttr(fldAttr.errorType, (this.errorCode === NO_ERROR) ? '' : type);
|
|
1457
1432
|
this.setAttr(fldAttr.errorMessage, message !== null && message !== void 0 ? message : '');
|
|
1458
1433
|
}
|
|
1459
1434
|
getError() { return { type: this.errorType, code: this.errorCode, message: this.errorMessage }; }
|
|
@@ -1476,11 +1451,14 @@ class FieldDescriptor extends FormElement {
|
|
|
1476
1451
|
return fieldCurrentValue === '';
|
|
1477
1452
|
}
|
|
1478
1453
|
getValue() {
|
|
1479
|
-
var _a;
|
|
1454
|
+
var _a, _b;
|
|
1480
1455
|
switch (this.fieldType) {
|
|
1481
|
-
case this._formConfig.fieldTypes.
|
|
1456
|
+
case this._formConfig.fieldTypes.boolean:
|
|
1482
1457
|
return (_a = this._fieldValue) !== null && _a !== void 0 ? _a : false;
|
|
1483
1458
|
break;
|
|
1459
|
+
case this._formConfig.fieldTypes.check:
|
|
1460
|
+
return (_b = this._fieldValue) !== null && _b !== void 0 ? _b : false;
|
|
1461
|
+
break;
|
|
1484
1462
|
case this._formConfig.fieldTypes.currency:
|
|
1485
1463
|
return this._fieldValue.replace(',', '');
|
|
1486
1464
|
break;
|
|
@@ -1504,7 +1482,7 @@ class FieldDescriptor extends FormElement {
|
|
|
1504
1482
|
(attrName === this._formConfig.apifieldattrs.info) && this.setAttr(fldAttr.info, fld.info);
|
|
1505
1483
|
(attrName === this._formConfig.apifieldattrs.editable) && this.setEditable(fld.editable);
|
|
1506
1484
|
(attrName === this._formConfig.apifieldattrs.title) && this.setLabel(fld.fieldTitle.toString());
|
|
1507
|
-
(attrName === this._formConfig.apifieldattrs.value) && (this.setValue(fld.
|
|
1485
|
+
(attrName === this._formConfig.apifieldattrs.value) && (this.setValue(fld.fieldValue) && this.setChanged(false));
|
|
1508
1486
|
(attrName === this._formConfig.apifieldattrs.options) && this.setFieldOptions(fld.fieldOptions);
|
|
1509
1487
|
(attrName === this._formConfig.apifieldattrs.captureType) && this.setAttr(fldAttr.captureType, fld.captureType || 'INPUT');
|
|
1510
1488
|
(attrName === this._formConfig.apifieldattrs.type) && this.setFieldType(fld.fieldTypeCode);
|
|
@@ -1600,6 +1578,9 @@ class FieldDescriptor extends FormElement {
|
|
|
1600
1578
|
case 'BOOLEAN':
|
|
1601
1579
|
newFinalValue = !!newValue;
|
|
1602
1580
|
break;
|
|
1581
|
+
case this._formConfig.fieldTypes.boolean:
|
|
1582
|
+
newFinalValue = !!newValue;
|
|
1583
|
+
break;
|
|
1603
1584
|
case this._formConfig.fieldTypes.check:
|
|
1604
1585
|
newFinalValue = !!newValue;
|
|
1605
1586
|
break;
|
|
@@ -1640,8 +1621,6 @@ class FieldDescriptor extends FormElement {
|
|
|
1640
1621
|
}
|
|
1641
1622
|
}
|
|
1642
1623
|
|
|
1643
|
-
const HEADER = 'HEADER';
|
|
1644
|
-
const NO_ERROR = '00';
|
|
1645
1624
|
class FormStructureAndData {
|
|
1646
1625
|
constructor(definitionReceived, formConfig) {
|
|
1647
1626
|
this._fieldsObj = {};
|
|
@@ -1826,7 +1805,7 @@ class FormStructureAndData {
|
|
|
1826
1805
|
return this._actions;
|
|
1827
1806
|
}
|
|
1828
1807
|
getHeaderActions() {
|
|
1829
|
-
return this._actions.filter(actionItem => actionItem.location === HEADER);
|
|
1808
|
+
return this._actions.filter(actionItem => actionItem.location === HEADER$1);
|
|
1830
1809
|
}
|
|
1831
1810
|
getFieldObject(elementId) {
|
|
1832
1811
|
return (this._fieldsObj && elementId && this._fieldsObj[elementId])
|
|
@@ -2210,71 +2189,77 @@ class LibFormManagerService {
|
|
|
2210
2189
|
constructor() {
|
|
2211
2190
|
this.cleanStack();
|
|
2212
2191
|
}
|
|
2213
|
-
|
|
2214
|
-
* Métodos virtuales de manejo de formularios
|
|
2215
|
-
*/
|
|
2192
|
+
// Métodos virtuales para las aplicaciones
|
|
2216
2193
|
getFormDefinition(formCode) { }
|
|
2194
|
+
getFormRoute(formCode) { }
|
|
2195
|
+
getRouteForm(path) { }
|
|
2217
2196
|
execServerAction(actionDetail) { }
|
|
2218
|
-
|
|
2219
|
-
/**
|
|
2220
|
-
* Manejo del stack de navegación con atributos estados y parámetros
|
|
2221
|
-
*/
|
|
2222
|
-
resetPageStack() { this.cleanStack(); }
|
|
2223
|
-
cleanStack() {
|
|
2224
|
-
this.pageStack = [];
|
|
2225
|
-
}
|
|
2197
|
+
goToForm(formCode, token, subject) { }
|
|
2226
2198
|
loadStack() { }
|
|
2227
2199
|
saveStack() { }
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
this.
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2200
|
+
cleanStack() { this.pageStack = []; }
|
|
2201
|
+
resetPageStack() { this.cleanStack(); }
|
|
2202
|
+
findFormInStack(token) {
|
|
2203
|
+
const index = this.pageStack.findIndex(item => (item === null || item === void 0 ? void 0 : item.token) === token);
|
|
2204
|
+
const data = (index >= 0) ? this.pageStack[index] : null;
|
|
2205
|
+
return { index, data };
|
|
2206
|
+
}
|
|
2207
|
+
replaceItem(token, formInfo) {
|
|
2208
|
+
var _a, _b;
|
|
2209
|
+
if (!token || !formInfo) {
|
|
2210
|
+
return;
|
|
2211
|
+
}
|
|
2212
|
+
const { index, data: storedForm } = this.findFormInStack(token);
|
|
2213
|
+
let updatedForm = null;
|
|
2214
|
+
if (index >= 0) {
|
|
2215
|
+
updatedForm = Object.assign({}, storedForm);
|
|
2216
|
+
updatedForm.subject = (_a = formInfo === null || formInfo === void 0 ? void 0 : formInfo.subject) !== null && _a !== void 0 ? _a : storedForm.subject;
|
|
2217
|
+
updatedForm.state = (_b = formInfo === null || formInfo === void 0 ? void 0 : formInfo.state) !== null && _b !== void 0 ? _b : storedForm.state;
|
|
2218
|
+
Object.assign(updatedForm.fields, formInfo.fields);
|
|
2219
|
+
Object.assign(updatedForm.extra, formInfo.extra);
|
|
2220
|
+
this.pageStack[index] = updatedForm;
|
|
2240
2221
|
this.saveStack();
|
|
2241
|
-
return formData;
|
|
2242
2222
|
}
|
|
2243
2223
|
}
|
|
2244
|
-
|
|
2245
|
-
const
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2224
|
+
stack(origin, target) {
|
|
2225
|
+
const token = nanoid(6);
|
|
2226
|
+
this.replaceItem(target.originToken, origin);
|
|
2227
|
+
this.pageStack.push(Object.assign({ token }, target));
|
|
2228
|
+
this.saveStack();
|
|
2229
|
+
return token;
|
|
2230
|
+
}
|
|
2231
|
+
unstack(token = null) {
|
|
2232
|
+
let index = (token) ? this.findFormInStack(token).index : this.pageStack.length - 2;
|
|
2233
|
+
let formInfo = null;
|
|
2234
|
+
if (index >= 0) {
|
|
2235
|
+
formInfo = this.pageStack[index];
|
|
2236
|
+
this.pageStack.splice(index + 1);
|
|
2237
|
+
this.saveStack();
|
|
2249
2238
|
}
|
|
2250
|
-
return
|
|
2239
|
+
return formInfo;
|
|
2251
2240
|
}
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
|
|
2241
|
+
getFormInfo(token) {
|
|
2242
|
+
var _a, _b;
|
|
2243
|
+
const { data } = this.findFormInStack(token);
|
|
2244
|
+
return {
|
|
2245
|
+
token: data === null || data === void 0 ? void 0 : data.token,
|
|
2246
|
+
subject: data === null || data === void 0 ? void 0 : data.subject,
|
|
2247
|
+
state: data === null || data === void 0 ? void 0 : data.state,
|
|
2248
|
+
originToken: data === null || data === void 0 ? void 0 : data.originToken,
|
|
2249
|
+
fields: (_a = data === null || data === void 0 ? void 0 : data.fields) !== null && _a !== void 0 ? _a : {},
|
|
2250
|
+
extra: (_b = data === null || data === void 0 ? void 0 : data.extra) !== null && _b !== void 0 ? _b : {}
|
|
2251
|
+
};
|
|
2259
2252
|
}
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
const
|
|
2265
|
-
|
|
2266
|
-
const navigationArray = [url, ...params, newToken];
|
|
2267
|
-
this.goToRoute(navigationArray);
|
|
2253
|
+
openForm(origin, target) {
|
|
2254
|
+
var _a;
|
|
2255
|
+
(!origin) && this.cleanStack();
|
|
2256
|
+
target.originToken = (_a = origin === null || origin === void 0 ? void 0 : origin.token) !== null && _a !== void 0 ? _a : null;
|
|
2257
|
+
const token = this.stack(origin, target);
|
|
2258
|
+
this.goToForm(target.name, token, target.subject);
|
|
2268
2259
|
}
|
|
2269
|
-
|
|
2270
|
-
const
|
|
2271
|
-
|
|
2272
|
-
return;
|
|
2273
|
-
}
|
|
2274
|
-
const { origin: { url, params, token } } = prevForm;
|
|
2275
|
-
const navigationArray = [url, ...params];
|
|
2276
|
-
token && navigationArray.push(token);
|
|
2277
|
-
this.goToRoute(navigationArray);
|
|
2260
|
+
backTo(targetToken = null) {
|
|
2261
|
+
const formInfo = this.unstack(targetToken);
|
|
2262
|
+
formInfo && formInfo.name && this.goToForm(formInfo.name, formInfo.token, formInfo.subject);
|
|
2278
2263
|
}
|
|
2279
2264
|
}
|
|
2280
2265
|
|
|
@@ -2305,11 +2290,8 @@ const PAYLOAD_VERSION = 'TUAINEXCHANGE_1.0';
|
|
|
2305
2290
|
const INLINE_ACTION = 'INLINE';
|
|
2306
2291
|
const GLOBAL_ACTION = 'GLOBAL';
|
|
2307
2292
|
const GET_DATA_ACTION = 'GETDATA';
|
|
2308
|
-
const
|
|
2309
|
-
const
|
|
2310
|
-
const ORIGIN_PARAM = 'origin';
|
|
2311
|
-
const STATE_PARAM = 'mode';
|
|
2312
|
-
const REQUIRED_FIELD_MESSAGE = 'Campo requerido';
|
|
2293
|
+
const SUBJECT = 'subject';
|
|
2294
|
+
const TOKEN = 'token';
|
|
2313
2295
|
class BasicFormComponent {
|
|
2314
2296
|
constructor(formManagerService, _eventManager, fileMgmtServices) {
|
|
2315
2297
|
this.formManagerService = formManagerService;
|
|
@@ -2319,9 +2301,9 @@ class BasicFormComponent {
|
|
|
2319
2301
|
this.errorMessage = '';
|
|
2320
2302
|
this.errorDetail = '';
|
|
2321
2303
|
this.formStructure = null;
|
|
2322
|
-
this.
|
|
2323
|
-
this.inputDataFields =
|
|
2324
|
-
this.extraData =
|
|
2304
|
+
this.controlToken = null;
|
|
2305
|
+
this.inputDataFields = {};
|
|
2306
|
+
this.extraData = {};
|
|
2325
2307
|
this.definitionObtained = false;
|
|
2326
2308
|
this.formVisible = false;
|
|
2327
2309
|
this.inServerProcess = false;
|
|
@@ -2352,8 +2334,8 @@ class BasicFormComponent {
|
|
|
2352
2334
|
this.errorMessage = '';
|
|
2353
2335
|
this.errorDetail = '';
|
|
2354
2336
|
this.formStructure = null;
|
|
2355
|
-
this.
|
|
2356
|
-
this.inputDataFields =
|
|
2337
|
+
this.controlToken = null;
|
|
2338
|
+
this.inputDataFields = {};
|
|
2357
2339
|
this.definitionObtained = false;
|
|
2358
2340
|
// Se limpian los manejadores de eventos
|
|
2359
2341
|
this.formVisible = false;
|
|
@@ -2502,35 +2484,61 @@ class BasicFormComponent {
|
|
|
2502
2484
|
subscribeAppEvent(eventName, callback) {
|
|
2503
2485
|
this._eventEmiter.subscribe(eventName, callback);
|
|
2504
2486
|
}
|
|
2487
|
+
openForm(name, data = null, backData = null, cleanStack = false) {
|
|
2488
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
2489
|
+
let origin = null;
|
|
2490
|
+
if (!cleanStack) {
|
|
2491
|
+
origin = Object.assign(Object.assign({}, backData), { name: this.name, url: this._formRoute, token: this.controlToken });
|
|
2492
|
+
origin.subject = (_a = origin === null || origin === void 0 ? void 0 : origin.subject) !== null && _a !== void 0 ? _a : this.formSubject;
|
|
2493
|
+
origin.state = (_b = origin === null || origin === void 0 ? void 0 : origin.state) !== null && _b !== void 0 ? _b : this.currentState;
|
|
2494
|
+
origin.fields = (_c = origin === null || origin === void 0 ? void 0 : origin.fields) !== null && _c !== void 0 ? _c : {};
|
|
2495
|
+
origin.extra = (_d = origin === null || origin === void 0 ? void 0 : origin.extra) !== null && _d !== void 0 ? _d : {};
|
|
2496
|
+
}
|
|
2497
|
+
const target = Object.assign(Object.assign({}, data), { name });
|
|
2498
|
+
target.subject = (_e = target === null || target === void 0 ? void 0 : target.subject) !== null && _e !== void 0 ? _e : null;
|
|
2499
|
+
target.state = (_f = target === null || target === void 0 ? void 0 : target.state) !== null && _f !== void 0 ? _f : null;
|
|
2500
|
+
target.fields = (_g = target === null || target === void 0 ? void 0 : target.fields) !== null && _g !== void 0 ? _g : {};
|
|
2501
|
+
target.extra = (_h = target === null || target === void 0 ? void 0 : target.extra) !== null && _h !== void 0 ? _h : {};
|
|
2502
|
+
this.formManagerService.openForm(origin, target);
|
|
2503
|
+
}
|
|
2504
|
+
/**
|
|
2505
|
+
* @deprecated Este método ya no debería ser utilizado. Use openForm con el nombre del formulario
|
|
2506
|
+
*/
|
|
2505
2507
|
goToPage(navigationArray, predefinedFields, options = null) {
|
|
2506
|
-
var _a
|
|
2508
|
+
var _a;
|
|
2507
2509
|
let origin = null;
|
|
2508
2510
|
const cleanStack = (_a = options === null || options === void 0 ? void 0 : options.cleanStack) !== null && _a !== void 0 ? _a : false;
|
|
2509
|
-
const params = [];
|
|
2510
|
-
this.currentState && params.push(this.currentState);
|
|
2511
|
-
this.formSubject && params.push(this.formSubject);
|
|
2512
2511
|
if (!cleanStack) {
|
|
2513
2512
|
origin = {
|
|
2514
|
-
|
|
2513
|
+
name: this.name,
|
|
2515
2514
|
url: this._formRoute,
|
|
2516
|
-
|
|
2517
|
-
|
|
2518
|
-
|
|
2515
|
+
token: this.controlToken,
|
|
2516
|
+
fields: this.inputDataFields,
|
|
2517
|
+
extra: this.extraData
|
|
2519
2518
|
};
|
|
2520
2519
|
}
|
|
2521
2520
|
const target = {
|
|
2521
|
+
name: this.formManagerService.getRouteForm(navigationArray === null || navigationArray === void 0 ? void 0 : navigationArray[0]),
|
|
2522
2522
|
url: navigationArray === null || navigationArray === void 0 ? void 0 : navigationArray[0],
|
|
2523
|
-
|
|
2524
|
-
|
|
2523
|
+
state: navigationArray === null || navigationArray === void 0 ? void 0 : navigationArray[1],
|
|
2524
|
+
subject: navigationArray === null || navigationArray === void 0 ? void 0 : navigationArray[2],
|
|
2525
|
+
fields: predefinedFields,
|
|
2526
|
+
extra: null,
|
|
2525
2527
|
};
|
|
2526
|
-
this.formManagerService.
|
|
2528
|
+
this.formManagerService.openForm(origin, target);
|
|
2527
2529
|
}
|
|
2530
|
+
/**
|
|
2531
|
+
* @deprecated Este método ya no debería ser utilizado. Use openForm con el nombre del formulario
|
|
2532
|
+
*/
|
|
2528
2533
|
goToNewPage(nav, flds) { return this.goToPage(nav, flds, { cleanStack: true }); }
|
|
2534
|
+
/**
|
|
2535
|
+
* @deprecated Este método ya no debería ser utilizado. Use openForm con el nombre del formulario
|
|
2536
|
+
*/
|
|
2529
2537
|
goToSubPage(nav, flds) { return this.goToPage(nav, flds, { cleanStack: false }); }
|
|
2530
|
-
canGoBack() { return this.
|
|
2531
|
-
goBack() { return this.formManagerService.
|
|
2538
|
+
canGoBack() { return this.originToken !== null; }
|
|
2539
|
+
goBack() { return this.formManagerService.backTo(); }
|
|
2532
2540
|
goBackForm() { return this.goBack(); }
|
|
2533
|
-
getOriginDetail() { return this.formManagerService.
|
|
2541
|
+
getOriginDetail() { return this.formManagerService.getFormInfo(this.originToken); }
|
|
2534
2542
|
setError(errorType, errorMessage, errorDetail) {
|
|
2535
2543
|
this._errorType = errorType || '';
|
|
2536
2544
|
this.errorMessage = errorMessage || '';
|
|
@@ -2550,33 +2558,23 @@ class BasicFormComponent {
|
|
|
2550
2558
|
get formCode() { return this.name; }
|
|
2551
2559
|
set formCode(name) { this.name = name; }
|
|
2552
2560
|
getFormParameter(name) {
|
|
2553
|
-
|
|
2561
|
+
var _a, _b;
|
|
2562
|
+
return (name) ? ((_b = (_a = this.extraData) === null || _a === void 0 ? void 0 : _a[name]) !== null && _b !== void 0 ? _b : null) : null;
|
|
2554
2563
|
}
|
|
2555
2564
|
getSubject() { return this.formSubject; }
|
|
2556
2565
|
getformSubject() { return this.getSubject(); }
|
|
2557
2566
|
preocessInputParams(params) {
|
|
2558
|
-
var _a, _b, _c
|
|
2559
|
-
|
|
2560
|
-
|
|
2561
|
-
|
|
2562
|
-
|
|
2563
|
-
this.extraData = [];
|
|
2564
|
-
for (const paramName of allParams) {
|
|
2565
|
-
this.extraData[paramName] = params[paramName].toString();
|
|
2566
|
-
}
|
|
2567
|
-
const formName = (_b = (_a = this.extraData) === null || _a === void 0 ? void 0 : _a[FORM_CODE]) !== null && _b !== void 0 ? _b : this.name;
|
|
2568
|
-
if (formName !== this.name) {
|
|
2569
|
-
this.cleanStart();
|
|
2570
|
-
this.name = formName;
|
|
2571
|
-
}
|
|
2572
|
-
this.formSubject = (_d = (_c = this.extraData) === null || _c === void 0 ? void 0 : _c[FORM_SUBJECT]) !== null && _d !== void 0 ? _d : null;
|
|
2573
|
-
const initialState = this.extraData[STATE_PARAM];
|
|
2574
|
-
this.transitionToken = (_e = this.extraData[ORIGIN_PARAM]) !== null && _e !== void 0 ? _e : null;
|
|
2575
|
-
this.inputDataFields = (_f = this.formManagerService.getInputData(this.transitionToken)) !== null && _f !== void 0 ? _f : [];
|
|
2576
|
-
if (!this.transitionToken) {
|
|
2577
|
-
this.formManagerService.cleanStack();
|
|
2567
|
+
var _a, _b, _c;
|
|
2568
|
+
this.controlToken = (_a = params === null || params === void 0 ? void 0 : params[TOKEN]) !== null && _a !== void 0 ? _a : null;
|
|
2569
|
+
const { token, subject, state, fields, extra, originToken } = this.formManagerService.getFormInfo(this.controlToken);
|
|
2570
|
+
if (!this.controlToken || this.controlToken !== token) {
|
|
2571
|
+
console.log(`No se obtuvo un token válido para abrir el formulario ${this.controlToken}->${token}`);
|
|
2578
2572
|
}
|
|
2579
|
-
|
|
2573
|
+
this.formSubject = (_c = (_b = params === null || params === void 0 ? void 0 : params[SUBJECT]) !== null && _b !== void 0 ? _b : subject) !== null && _c !== void 0 ? _c : null;
|
|
2574
|
+
this.inputDataFields = fields;
|
|
2575
|
+
this.extraData = extra;
|
|
2576
|
+
this.originToken = originToken;
|
|
2577
|
+
return state;
|
|
2580
2578
|
}
|
|
2581
2579
|
subscribeSectionActivation() {
|
|
2582
2580
|
const formSections = this.formStructure.getSections();
|
|
@@ -2624,7 +2622,6 @@ class BasicFormComponent {
|
|
|
2624
2622
|
}
|
|
2625
2623
|
}
|
|
2626
2624
|
formInit(params) {
|
|
2627
|
-
var _a;
|
|
2628
2625
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2629
2626
|
let initialState = this.preocessInputParams(params);
|
|
2630
2627
|
if (!this.name) {
|
|
@@ -2644,21 +2641,11 @@ class BasicFormComponent {
|
|
|
2644
2641
|
initialState = this.formStructure.defaultState;
|
|
2645
2642
|
}
|
|
2646
2643
|
this.formStructure.changeState(initialState || this.formStructure.defaultState);
|
|
2647
|
-
|
|
2648
|
-
|
|
2649
|
-
|
|
2650
|
-
|
|
2651
|
-
|
|
2652
|
-
}
|
|
2653
|
-
}
|
|
2654
|
-
}
|
|
2655
|
-
else {
|
|
2656
|
-
const fieldCodes = Object.keys((_a = this.inputDataFields) !== null && _a !== void 0 ? _a : {});
|
|
2657
|
-
for (let index = 0; index < fieldCodes.length; index++) {
|
|
2658
|
-
const fieldCode = fieldCodes[index];
|
|
2659
|
-
const fieldValue = this.inputDataFields[fieldCode];
|
|
2660
|
-
this.setFieldValue(fieldCode, fieldValue);
|
|
2661
|
-
}
|
|
2644
|
+
const inputFieldNames = Object.keys(this.inputDataFields);
|
|
2645
|
+
for (let index = 0; index < inputFieldNames.length; index++) {
|
|
2646
|
+
const fieldCode = inputFieldNames[index];
|
|
2647
|
+
const fieldValue = this.inputDataFields[fieldCode];
|
|
2648
|
+
this.setFieldValue(fieldCode, fieldValue);
|
|
2662
2649
|
}
|
|
2663
2650
|
const recordResponse = yield this.requestFormAction(formActions.getData);
|
|
2664
2651
|
this.checkErrorRecordReceived(recordResponse);
|
|
@@ -2680,7 +2667,7 @@ class BasicFormComponent {
|
|
|
2680
2667
|
this.errorDetail = recordResponse.errorDetail;
|
|
2681
2668
|
}
|
|
2682
2669
|
errorOccured() {
|
|
2683
|
-
return (this.errorCode !==
|
|
2670
|
+
return (this.errorCode !== NO_ERROR);
|
|
2684
2671
|
}
|
|
2685
2672
|
changeState(state) { return this.formStructure.changeState(state); }
|
|
2686
2673
|
changeFormMode(state) { return this.changeState(state); }
|
|
@@ -2696,7 +2683,7 @@ class BasicFormComponent {
|
|
|
2696
2683
|
formData: this.formStructure.getPayload(),
|
|
2697
2684
|
immutableData: this.formStructure.immutableData,
|
|
2698
2685
|
};
|
|
2699
|
-
this.errorCode =
|
|
2686
|
+
this.errorCode = NO_ERROR;
|
|
2700
2687
|
this.errorMessage = '';
|
|
2701
2688
|
this.errorDetail = '';
|
|
2702
2689
|
this.inServerProcess = true;
|
|
@@ -2915,8 +2902,7 @@ class BasicFormComponent {
|
|
|
2915
2902
|
if (!fieldToValidate) {
|
|
2916
2903
|
return false;
|
|
2917
2904
|
}
|
|
2918
|
-
fieldToValidate.
|
|
2919
|
-
fieldToValidate.setErrorCode('00');
|
|
2905
|
+
fieldToValidate.resetError();
|
|
2920
2906
|
const validationCallbacks = this.fieldInputValidation[fieldCode];
|
|
2921
2907
|
if (validationCallbacks) {
|
|
2922
2908
|
const clientValidationPromises = [];
|
|
@@ -2934,8 +2920,7 @@ class BasicFormComponent {
|
|
|
2934
2920
|
if (!fieldToValidate || !intrinsicValidation) {
|
|
2935
2921
|
return;
|
|
2936
2922
|
}
|
|
2937
|
-
fieldToValidate.
|
|
2938
|
-
fieldToValidate.setErrorCode('00');
|
|
2923
|
+
fieldToValidate.resetError();
|
|
2939
2924
|
const validationCallbacks = this.fieldValidationsStart[fieldCode];
|
|
2940
2925
|
if (validationCallbacks) {
|
|
2941
2926
|
const clientValidationPromises = [];
|
|
@@ -3475,7 +3460,7 @@ class BasicFormComponent {
|
|
|
3475
3460
|
}
|
|
3476
3461
|
checkSectionRequiredFields(sectionCode, reqFieldMessage) {
|
|
3477
3462
|
this.cleanErrorFields(null, sectionCode);
|
|
3478
|
-
const requiredFieldMessage = reqFieldMessage
|
|
3463
|
+
const requiredFieldMessage = reqFieldMessage !== null && reqFieldMessage !== void 0 ? reqFieldMessage : this.formConfig.formStandardErrors.requiredField;
|
|
3479
3464
|
const numErrors = this.tagFieldsWithError(this.getRequiredEmptyFields(null, sectionCode), null, requiredFieldMessage);
|
|
3480
3465
|
return (numErrors === 0);
|
|
3481
3466
|
}
|