tuain-ng-forms-lib 14.5.37 → 15.0.10
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/esm2020/lib/classes/forms/form.mjs +166 -69
- package/esm2020/lib/classes/forms/piece.mjs +1 -1
- package/esm2020/lib/classes/forms/table/action.mjs +8 -1
- package/esm2020/lib/components/elements/tables/table-record-action.component.mjs +8 -5
- package/esm2020/lib/components/forms/basic-form.mjs +74 -320
- package/fesm2015/tuain-ng-forms-lib.mjs +253 -456
- package/fesm2015/tuain-ng-forms-lib.mjs.map +1 -1
- package/fesm2020/tuain-ng-forms-lib.mjs +250 -390
- package/fesm2020/tuain-ng-forms-lib.mjs.map +1 -1
- package/lib/classes/forms/form.d.ts +113 -25
- package/lib/classes/forms/table/action.d.ts +1 -0
- package/lib/components/forms/basic-form.d.ts +32 -152
- package/package.json +1 -1
|
@@ -330,15 +330,18 @@ class LibTableRecordActionComponent extends PieceComponent {
|
|
|
330
330
|
}
|
|
331
331
|
start() {
|
|
332
332
|
if (this.action && this.action.restrictedOnField && this.recordData) {
|
|
333
|
-
const relatedField = this.
|
|
333
|
+
const relatedField = this.action.restrictedOnField;
|
|
334
334
|
if (relatedField) {
|
|
335
|
-
const
|
|
335
|
+
const relatedFieldValue = this.recordData[relatedField];
|
|
336
336
|
const restrictionOper = this.action.restrictedOnOperator;
|
|
337
337
|
const restrictionValue = this.action.restrictedOnValue;
|
|
338
|
-
if ((restrictionOper === '==' &&
|
|
339
|
-
|| (restrictionOper === '!=' &&
|
|
338
|
+
if ((restrictionOper === '==' && relatedFieldValue !== restrictionValue)
|
|
339
|
+
|| (restrictionOper === '!=' && relatedFieldValue === restrictionValue)) {
|
|
340
340
|
this.isVisible = false;
|
|
341
341
|
}
|
|
342
|
+
else {
|
|
343
|
+
this.isVisible = true;
|
|
344
|
+
}
|
|
342
345
|
}
|
|
343
346
|
}
|
|
344
347
|
}
|
|
@@ -1276,6 +1279,13 @@ class TableAction extends FormPiece {
|
|
|
1276
1279
|
this.restrictedOnOperator = actionDefinition.operatorRestricted || null;
|
|
1277
1280
|
}
|
|
1278
1281
|
}
|
|
1282
|
+
formStateChange(state) {
|
|
1283
|
+
if (state) {
|
|
1284
|
+
this._formState = state;
|
|
1285
|
+
this._visible = this._absoluteVisible && this.viewOnState(state);
|
|
1286
|
+
this._disabled = this._absoluteDisabled || !this.enabledOnState(state);
|
|
1287
|
+
}
|
|
1288
|
+
}
|
|
1279
1289
|
}
|
|
1280
1290
|
|
|
1281
1291
|
class TableRecordData {
|
|
@@ -2071,34 +2081,51 @@ const ENABLE = 'enable';
|
|
|
2071
2081
|
const DISABLE = 'disable';
|
|
2072
2082
|
const CLEAN = 'clean';
|
|
2073
2083
|
class FormStructureAndData {
|
|
2074
|
-
constructor(
|
|
2084
|
+
constructor() {
|
|
2075
2085
|
this._stateChange = new Subject();
|
|
2076
|
-
this.
|
|
2077
|
-
this.
|
|
2078
|
-
this.
|
|
2079
|
-
this.
|
|
2080
|
-
this.
|
|
2081
|
-
this.
|
|
2086
|
+
this.name = '';
|
|
2087
|
+
this.title = '';
|
|
2088
|
+
this.subject = null;
|
|
2089
|
+
this.fields = {};
|
|
2090
|
+
this.actions = {};
|
|
2091
|
+
this.tables = {};
|
|
2092
|
+
this.sections = {};
|
|
2082
2093
|
this._immutableData = {};
|
|
2083
2094
|
this._extraInfo = {};
|
|
2084
2095
|
this._exclusiveSectionsByAttr = {};
|
|
2085
|
-
this._formConfig = formConfig;
|
|
2086
2096
|
this.state = '';
|
|
2087
|
-
this.
|
|
2088
|
-
this.
|
|
2089
|
-
this.
|
|
2090
|
-
this.
|
|
2091
|
-
this.
|
|
2097
|
+
this.actionArray = [];
|
|
2098
|
+
this.fieldArray = [];
|
|
2099
|
+
this.tableArray = [];
|
|
2100
|
+
this.sectionArray = [];
|
|
2101
|
+
this.stateFlow = {
|
|
2102
|
+
defaultState: '',
|
|
2103
|
+
states: [],
|
|
2104
|
+
transitions: [],
|
|
2105
|
+
};
|
|
2106
|
+
}
|
|
2107
|
+
setConfig(formConfig) {
|
|
2108
|
+
this.formConfig = formConfig;
|
|
2109
|
+
}
|
|
2110
|
+
cleanForm() {
|
|
2111
|
+
this.actionArray = [];
|
|
2112
|
+
this.fieldArray = [];
|
|
2113
|
+
this.tableArray = [];
|
|
2114
|
+
this.sectionArray = [];
|
|
2115
|
+
this.stateFlow = {
|
|
2092
2116
|
defaultState: '',
|
|
2093
2117
|
states: [],
|
|
2094
2118
|
transitions: [],
|
|
2095
2119
|
};
|
|
2120
|
+
}
|
|
2121
|
+
loadDefinition(definitionReceived) {
|
|
2122
|
+
this.state = '';
|
|
2123
|
+
this.cleanForm();
|
|
2096
2124
|
if (!definitionReceived) {
|
|
2097
2125
|
return;
|
|
2098
2126
|
}
|
|
2099
|
-
this.
|
|
2100
|
-
|
|
2101
|
-
this._title = (definitionReceived.form && definitionReceived.form.formTitle)
|
|
2127
|
+
this.name = this.name ?? definitionReceived?.form?.formCode;
|
|
2128
|
+
this.title = (definitionReceived.form && definitionReceived.form.formTitle)
|
|
2102
2129
|
? definitionReceived.form.formTitle : '';
|
|
2103
2130
|
this.setStateFlow(definitionReceived?.states, definitionReceived?.transitions, definitionReceived?.defaultState);
|
|
2104
2131
|
this.immutableData = definitionReceived.immutableData;
|
|
@@ -2116,11 +2143,11 @@ class FormStructureAndData {
|
|
|
2116
2143
|
return { ...objDef, visibleStates, enabledStates };
|
|
2117
2144
|
});
|
|
2118
2145
|
for (const actionReceived of formActions) {
|
|
2119
|
-
const globalAction = new FormAction(actionReceived, this.
|
|
2146
|
+
const globalAction = new FormAction(actionReceived, this.formConfig);
|
|
2120
2147
|
const globalActionCode = globalAction.actionCode;
|
|
2121
2148
|
if (globalActionCode) {
|
|
2122
|
-
this.
|
|
2123
|
-
this.
|
|
2149
|
+
this.actionArray.push(globalAction);
|
|
2150
|
+
this.actions[globalActionCode] = globalAction;
|
|
2124
2151
|
}
|
|
2125
2152
|
}
|
|
2126
2153
|
}
|
|
@@ -2137,11 +2164,11 @@ class FormStructureAndData {
|
|
|
2137
2164
|
return { ...objDef, visibleStates, enabledStates };
|
|
2138
2165
|
});
|
|
2139
2166
|
for (const fieldReceived of formFields) {
|
|
2140
|
-
const fieldToAdd = new FieldDescriptor(fieldReceived, this.
|
|
2167
|
+
const fieldToAdd = new FieldDescriptor(fieldReceived, this.formConfig);
|
|
2141
2168
|
const fieldCode = fieldToAdd.code;
|
|
2142
2169
|
if (fieldCode) {
|
|
2143
|
-
this.
|
|
2144
|
-
this.
|
|
2170
|
+
this.fieldArray.push(fieldToAdd);
|
|
2171
|
+
this.fields[fieldCode] = fieldToAdd;
|
|
2145
2172
|
}
|
|
2146
2173
|
}
|
|
2147
2174
|
}
|
|
@@ -2158,11 +2185,11 @@ class FormStructureAndData {
|
|
|
2158
2185
|
return { ...objDef, visibleStates, enabledStates };
|
|
2159
2186
|
});
|
|
2160
2187
|
for (const tableReceived of tables) {
|
|
2161
|
-
const tableToAdd = new RecordTable(tableReceived, this.
|
|
2188
|
+
const tableToAdd = new RecordTable(tableReceived, this.formConfig);
|
|
2162
2189
|
const tableCode = tableToAdd.tableCode;
|
|
2163
2190
|
if (tableCode) {
|
|
2164
|
-
this.
|
|
2165
|
-
this.
|
|
2191
|
+
this.tableArray.push(tableToAdd);
|
|
2192
|
+
this.tables[tableCode] = tableToAdd;
|
|
2166
2193
|
}
|
|
2167
2194
|
}
|
|
2168
2195
|
}
|
|
@@ -2177,34 +2204,29 @@ class FormStructureAndData {
|
|
|
2177
2204
|
return { ...objDef, visibleStates };
|
|
2178
2205
|
});
|
|
2179
2206
|
for (const sectionReceived of formSections) {
|
|
2180
|
-
const sectionToAdd = new RecordFormSection(sectionReceived, this, this.
|
|
2207
|
+
const sectionToAdd = new RecordFormSection(sectionReceived, this, this.formConfig);
|
|
2181
2208
|
const sectionCode = sectionToAdd.sectionCode;
|
|
2182
2209
|
if (sectionCode) {
|
|
2183
|
-
this.
|
|
2184
|
-
this.
|
|
2210
|
+
this.sectionArray.push(sectionToAdd);
|
|
2211
|
+
this.sections[sectionCode] = sectionToAdd;
|
|
2185
2212
|
}
|
|
2186
2213
|
}
|
|
2187
2214
|
}
|
|
2188
2215
|
}
|
|
2189
|
-
getTitle() { return this._title; }
|
|
2190
|
-
setTitle(title) { this._title = title; }
|
|
2191
|
-
get name() { return this._name; }
|
|
2192
|
-
set name(name) { this._name = name; }
|
|
2193
2216
|
// Estados
|
|
2194
|
-
get defaultState() { return this.
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
get states() { return this._stateFlow.states; }
|
|
2198
|
-
getCurrentState() { return this.state; }
|
|
2217
|
+
get defaultState() { return this.stateFlow.defaultState; }
|
|
2218
|
+
get states() { return this.stateFlow.states; }
|
|
2219
|
+
supportState(state = '') { return (!!state && this.stateFlow.states?.includes(state)); }
|
|
2199
2220
|
changeState(newState) {
|
|
2200
|
-
|
|
2221
|
+
const currentState = this.state;
|
|
2222
|
+
if (!newState || !this.supportState(newState) || currentState === newState) {
|
|
2201
2223
|
return false;
|
|
2202
2224
|
}
|
|
2203
2225
|
if (!this.state) {
|
|
2204
2226
|
this.state = newState;
|
|
2205
2227
|
}
|
|
2206
2228
|
else {
|
|
2207
|
-
const transitionToChange = this.
|
|
2229
|
+
const transitionToChange = this.stateFlow.transitions.find(trns => trns.source === this.state && trns.destination === newState);
|
|
2208
2230
|
if (transitionToChange) {
|
|
2209
2231
|
this.state = newState;
|
|
2210
2232
|
}
|
|
@@ -2214,12 +2236,12 @@ class FormStructureAndData {
|
|
|
2214
2236
|
}
|
|
2215
2237
|
get stateChange() { return this._stateChange; }
|
|
2216
2238
|
setStateFlow(states, transitions, defaultState) {
|
|
2217
|
-
this.
|
|
2218
|
-
this.
|
|
2219
|
-
this.
|
|
2239
|
+
this.stateFlow.states = states;
|
|
2240
|
+
this.stateFlow.defaultState = defaultState || this.stateFlow.states[0];
|
|
2241
|
+
this.stateFlow.transitions = transitions.map(transition => {
|
|
2220
2242
|
const name = transition.name;
|
|
2221
|
-
const source = (this.
|
|
2222
|
-
const destination = (this.
|
|
2243
|
+
const source = (this.stateFlow.states.includes(transition.source)) ? transition.source : '';
|
|
2244
|
+
const destination = (this.stateFlow.states.includes(transition.destination)) ? transition.destination : '';
|
|
2223
2245
|
return { name, source, destination };
|
|
2224
2246
|
}).filter(item => item.name && item.source && item.destination);
|
|
2225
2247
|
}
|
|
@@ -2232,11 +2254,10 @@ class FormStructureAndData {
|
|
|
2232
2254
|
set extraInfo(extraInfo) { Object.assign(this._extraInfo, extraInfo); }
|
|
2233
2255
|
get extraInfo() { return JSON.parse(JSON.stringify(this._extraInfo)); }
|
|
2234
2256
|
// Fields
|
|
2235
|
-
get fields() { return this._fields; }
|
|
2236
2257
|
get fieldNames() { return this.getFieldNames(); }
|
|
2237
|
-
getFields() { return this.
|
|
2238
|
-
getFieldNames() { return this.
|
|
2239
|
-
getField(code) { return (code && this.
|
|
2258
|
+
getFields() { return this.fieldArray; }
|
|
2259
|
+
getFieldNames() { return this.fieldArray.map(field => field.code); }
|
|
2260
|
+
getField(code) { return (code && this.fields?.[code]) ? this.fields[code] : null; }
|
|
2240
2261
|
enableField(code) { this.getField(code)?.enable(); }
|
|
2241
2262
|
disableField(code) { this.getField(code)?.disable(); }
|
|
2242
2263
|
getFieldValue(code) { return this.getField(code)?.value; }
|
|
@@ -2309,6 +2330,9 @@ class FormStructureAndData {
|
|
|
2309
2330
|
}
|
|
2310
2331
|
return processedFields;
|
|
2311
2332
|
}
|
|
2333
|
+
applyProcessToAllFields(processFunc) {
|
|
2334
|
+
return this.applyOnFields(processFunc);
|
|
2335
|
+
}
|
|
2312
2336
|
enableFields(codes, secCode, subCode) {
|
|
2313
2337
|
return this.applyOnFields(fld => fld?.enable(), codes, secCode, subCode);
|
|
2314
2338
|
}
|
|
@@ -2363,20 +2387,26 @@ class FormStructureAndData {
|
|
|
2363
2387
|
for (let index = 0; index < codes.length; index++) {
|
|
2364
2388
|
const code = codes[index];
|
|
2365
2389
|
if (code) {
|
|
2366
|
-
resultObject[code] = this.
|
|
2390
|
+
resultObject[code] = this.fields?.[code]?.getValue() ?? null;
|
|
2367
2391
|
}
|
|
2368
2392
|
}
|
|
2369
2393
|
return resultObject;
|
|
2370
2394
|
}
|
|
2371
2395
|
// Acciones
|
|
2372
|
-
|
|
2373
|
-
|
|
2374
|
-
getActions() { return this._actionArray; }
|
|
2375
|
-
getAction(code) { return (code && this._actions?.[code]) ? this._actions[code] : null; }
|
|
2396
|
+
getActions() { return this.actionArray; }
|
|
2397
|
+
getAction(code) { return (code && this.actions?.[code]) ? this.actions[code] : null; }
|
|
2376
2398
|
showActions(codes) { return this.execOnActions(codes, SHOW); }
|
|
2377
2399
|
hideActions(codes) { return this.execOnActions(codes, HIDE); }
|
|
2378
2400
|
enableActions(codes) { return this.execOnActions(codes, ENABLE); }
|
|
2379
2401
|
disableActions(codes) { return this.execOnActions(codes, DISABLE); }
|
|
2402
|
+
enableAction(code) { return this.enableActions(code); }
|
|
2403
|
+
disableAction(code) { return this.disableActions(code); }
|
|
2404
|
+
showAction(code) { return this.showActions(code); }
|
|
2405
|
+
hideAction(code) { return this.hideActions(code); }
|
|
2406
|
+
getHeaderActions() { return this.getActionsByAttribute('location', HEADER$1); }
|
|
2407
|
+
getActionsByAttribute(name, value) {
|
|
2408
|
+
return this.actionArray.filter(actionItem => actionItem.matchAttribute(name, value));
|
|
2409
|
+
}
|
|
2380
2410
|
execOnActions(codes, functionName) {
|
|
2381
2411
|
const actionCodes = (Array.isArray(codes)) ? codes : (codes ? [codes] : []);
|
|
2382
2412
|
if (!functionName || actionCodes.length === 0) {
|
|
@@ -2388,15 +2418,17 @@ class FormStructureAndData {
|
|
|
2388
2418
|
});
|
|
2389
2419
|
}
|
|
2390
2420
|
// Tablas
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
getTable(code) { return (code && this._tables?.[code]) ? this._tables[code] : null; }
|
|
2421
|
+
getTables() { return this.tableArray; }
|
|
2422
|
+
getTable(code) { return (code && this.tables?.[code]) ? this.tables[code] : null; }
|
|
2394
2423
|
getTableRecord(code, id) { return this.getTable(code)?.getTableRecord(id); }
|
|
2395
2424
|
enableTables(codes) { return this.execOnTables(codes, ENABLE); }
|
|
2396
2425
|
disableTables(codes) { return this.execOnTables(codes, DISABLE); }
|
|
2397
2426
|
showTables(codes) { return this.execOnTables(codes, SHOW); }
|
|
2398
2427
|
hideTables(codes) { return this.execOnTables(codes, HIDE); }
|
|
2399
2428
|
cleanTables(codes) { return this.execOnTables(codes, CLEAN); }
|
|
2429
|
+
showTable(code) { return this.showTables(code); }
|
|
2430
|
+
hideTable(code) { return this.hideTables(code); }
|
|
2431
|
+
cleanTable(code) { return this.getTable(code)?.clean(); }
|
|
2400
2432
|
execOnTables(codes, functionName) {
|
|
2401
2433
|
const tableCodes = (Array.isArray(codes)) ? codes : (codes ? [codes] : []);
|
|
2402
2434
|
if (!functionName || tableCodes.length === 0) {
|
|
@@ -2408,17 +2440,22 @@ class FormStructureAndData {
|
|
|
2408
2440
|
});
|
|
2409
2441
|
}
|
|
2410
2442
|
// Secciones
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
get
|
|
2416
|
-
|
|
2443
|
+
getSections() { return this.sectionArray; }
|
|
2444
|
+
getSectionsTitles() { return this.getSections()?.filter(sec => sec?.title).map(sec => sec?.title ?? ''); }
|
|
2445
|
+
numSections() { return this.sectionArray.length; }
|
|
2446
|
+
getSectionsByAttribute(name, value) { return this.sectionArray.filter(item => item.matchAttribute(name, value)); }
|
|
2447
|
+
get sectionTitles() { return this.getSectionsTitles(); }
|
|
2448
|
+
get visibleSections() { return this.sectionArray.filter(sec => sec.absoluteVisible); }
|
|
2449
|
+
getSection(code) { return (code && this.sections?.[code]) ? this.sections[code] : null; }
|
|
2417
2450
|
showSections(codes) { this.execOnSections(codes, SHOW); }
|
|
2418
2451
|
hideSections(codes) { this.execOnSections(codes, HIDE); }
|
|
2452
|
+
showSection(code) { return this.showSections(code); }
|
|
2453
|
+
hideSection(code) { return this.hideSections(code); }
|
|
2419
2454
|
activeSection() { return this._exclusiveSectionsByAttr[ACTIVE]; }
|
|
2420
2455
|
getSubSection(code, subCode) { return this.getSection(code)?.getSubsection(subCode) ?? null; }
|
|
2421
2456
|
showSubSections(code, subCodes) { return this.execOnSubSections(code, subCodes, SHOW); }
|
|
2457
|
+
showSubSection(code, subCode) { return this.showSubSections(code, subCode); }
|
|
2458
|
+
hideSubSection(code, subCode) { return this.hideSubSections(code, subCode); }
|
|
2422
2459
|
hideSubSections(code, subCodes) { return this.execOnSubSections(code, subCodes, HIDE); }
|
|
2423
2460
|
getSectionActions(code) { return this.getSection(code)?.getActions() ?? null; }
|
|
2424
2461
|
getSectionActionNames(code) { return this.getSection(code)?.getActionNames() ?? null; }
|
|
@@ -2455,18 +2492,15 @@ class FormStructureAndData {
|
|
|
2455
2492
|
* Métodos propios de gestión del formulario
|
|
2456
2493
|
*/
|
|
2457
2494
|
cleanData() {
|
|
2458
|
-
for (const field of this.
|
|
2495
|
+
for (const field of this.fieldArray) {
|
|
2459
2496
|
field.setValue(field.defaultValue);
|
|
2460
2497
|
}
|
|
2461
|
-
for (const table of this.
|
|
2498
|
+
for (const table of this.tableArray) {
|
|
2462
2499
|
table.clean();
|
|
2463
2500
|
}
|
|
2464
2501
|
}
|
|
2465
2502
|
getPayload() {
|
|
2466
|
-
const formData = {
|
|
2467
|
-
fields: [],
|
|
2468
|
-
tables: [],
|
|
2469
|
-
};
|
|
2503
|
+
const formData = { fields: [], tables: [] };
|
|
2470
2504
|
formData.fields = this.getFields().filter(fld => !fld?.outputOnly)
|
|
2471
2505
|
.map(fld => {
|
|
2472
2506
|
const fieldPayload = {
|
|
@@ -2494,6 +2528,78 @@ class FormStructureAndData {
|
|
|
2494
2528
|
});
|
|
2495
2529
|
return formData;
|
|
2496
2530
|
}
|
|
2531
|
+
/**
|
|
2532
|
+
* @deprecated Use subject
|
|
2533
|
+
*/
|
|
2534
|
+
get formSubject() { return this.subject; }
|
|
2535
|
+
/**
|
|
2536
|
+
* @deprecated Use subject
|
|
2537
|
+
*/
|
|
2538
|
+
set formSubject(subject) { this.subject = subject; }
|
|
2539
|
+
/**
|
|
2540
|
+
* @deprecated Use states
|
|
2541
|
+
*/
|
|
2542
|
+
getStates() { return this.states; }
|
|
2543
|
+
/**
|
|
2544
|
+
* @deprecated Use state
|
|
2545
|
+
*/
|
|
2546
|
+
getCurrentState() { return this.state; }
|
|
2547
|
+
/**
|
|
2548
|
+
* @deprecated Use title
|
|
2549
|
+
*/
|
|
2550
|
+
getTitle() { return this.title; }
|
|
2551
|
+
/**
|
|
2552
|
+
* @deprecated Use title
|
|
2553
|
+
*/
|
|
2554
|
+
setTitle(title) { this.title = title; }
|
|
2555
|
+
/**
|
|
2556
|
+
* @deprecated Use supportState
|
|
2557
|
+
*/
|
|
2558
|
+
supportMode(state) { return this.supportState(state); }
|
|
2559
|
+
/**
|
|
2560
|
+
* @deprecated Use enableFields
|
|
2561
|
+
*/
|
|
2562
|
+
enableEditFields(codes, secCode, subCode) {
|
|
2563
|
+
return this.enableFields(codes, secCode, subCode);
|
|
2564
|
+
}
|
|
2565
|
+
/**
|
|
2566
|
+
* @deprecated Use disableFields
|
|
2567
|
+
*/
|
|
2568
|
+
disableEditFields(codes, secCode, subCode) {
|
|
2569
|
+
return this.disableFields(codes, secCode, subCode);
|
|
2570
|
+
}
|
|
2571
|
+
/**
|
|
2572
|
+
* @deprecated Use getField
|
|
2573
|
+
*/
|
|
2574
|
+
getFieldObject(code) { return this.getField(code); }
|
|
2575
|
+
/**
|
|
2576
|
+
* @deprecated Use getAction
|
|
2577
|
+
*/
|
|
2578
|
+
getActionObject(code) { return this.getAction(code); }
|
|
2579
|
+
/**
|
|
2580
|
+
* @deprecated Use getTable
|
|
2581
|
+
*/
|
|
2582
|
+
getTableObject(code) { return this.getTable(code); }
|
|
2583
|
+
/**
|
|
2584
|
+
* @deprecated Use getSection
|
|
2585
|
+
*/
|
|
2586
|
+
getSectionObject(code) { return this.getSection(code); }
|
|
2587
|
+
/**
|
|
2588
|
+
* @deprecated Use changeState
|
|
2589
|
+
*/
|
|
2590
|
+
changeFormMode(state) { return this.changeState(state); }
|
|
2591
|
+
/**
|
|
2592
|
+
* @deprecated Use subject
|
|
2593
|
+
*/
|
|
2594
|
+
getFormSubject() { return this.subject; }
|
|
2595
|
+
/**
|
|
2596
|
+
* @deprecated Use subject
|
|
2597
|
+
*/
|
|
2598
|
+
getSubject() { return this.subject ?? ''; }
|
|
2599
|
+
/**
|
|
2600
|
+
* @deprecated Use subject
|
|
2601
|
+
*/
|
|
2602
|
+
getformSubject() { return this.subject ?? ''; }
|
|
2497
2603
|
}
|
|
2498
2604
|
|
|
2499
2605
|
class LibFormManagerService {
|
|
@@ -2605,12 +2711,12 @@ const GLOBAL_ACTION = 'GLOBAL';
|
|
|
2605
2711
|
const GET_DATA_ACTION = 'GETDATA';
|
|
2606
2712
|
const SUBJECT = 'subject';
|
|
2607
2713
|
const TOKEN = 'token';
|
|
2608
|
-
class BasicFormComponent {
|
|
2714
|
+
class BasicFormComponent extends FormStructureAndData {
|
|
2609
2715
|
constructor(formManagerService, _eventManager, fileMgmtServices) {
|
|
2716
|
+
super();
|
|
2610
2717
|
this.formManagerService = formManagerService;
|
|
2611
2718
|
this._eventManager = _eventManager;
|
|
2612
2719
|
this.fileMgmtServices = fileMgmtServices;
|
|
2613
|
-
this._formStructure = null;
|
|
2614
2720
|
this._controlToken = null;
|
|
2615
2721
|
this._originToken = null;
|
|
2616
2722
|
this._formRoute = null;
|
|
@@ -2632,226 +2738,28 @@ class BasicFormComponent {
|
|
|
2632
2738
|
this._tableActionsFinish = {};
|
|
2633
2739
|
this._tableGetDataStart = {};
|
|
2634
2740
|
this._tableGetDataFinish = {};
|
|
2741
|
+
// Errores en procesos
|
|
2635
2742
|
this._actionServerError = [];
|
|
2636
2743
|
this._fieldServerError = [];
|
|
2637
2744
|
this._tableServerError = [];
|
|
2745
|
+
// Datos complementarios del formulario
|
|
2638
2746
|
this.inputDataFields = {};
|
|
2639
2747
|
this.extraData = {};
|
|
2640
2748
|
this.enabledSections = [];
|
|
2641
|
-
|
|
2642
|
-
this.formSubject = null;
|
|
2749
|
+
// Gestión de error
|
|
2643
2750
|
this._errorType = '';
|
|
2644
2751
|
this.errorCode = '';
|
|
2645
2752
|
this.errorFullCode = '';
|
|
2646
2753
|
this.errorName = '';
|
|
2647
2754
|
this.errorMessage = '';
|
|
2648
2755
|
this.errorDetail = '';
|
|
2756
|
+
// Control de estado
|
|
2649
2757
|
this.visible = false;
|
|
2650
|
-
this.fieldsArray = null;
|
|
2651
|
-
this.actionsArray = null;
|
|
2652
|
-
this.sectionsArray = null;
|
|
2653
2758
|
this.busy = false;
|
|
2654
2759
|
this._eventEmiter = this._eventManager;
|
|
2655
2760
|
this.cleanStart();
|
|
2656
2761
|
this.customPreProcessing();
|
|
2657
2762
|
}
|
|
2658
|
-
get title() { return this.getTitle() ?? ''; }
|
|
2659
|
-
set title(title) { this.setTitle(title); }
|
|
2660
|
-
getTitle() { return this._formStructure?.getTitle(); }
|
|
2661
|
-
setTitle(title) { return this._formStructure?.setTitle(title); }
|
|
2662
|
-
cleanData() { return this._formStructure?.cleanData(); }
|
|
2663
|
-
getCurrentState() { return this._formStructure?.getCurrentState(); }
|
|
2664
|
-
supportState(state) { return this._formStructure?.supportState(state ?? '') ?? false; }
|
|
2665
|
-
getStates() { return this._formStructure?.states; }
|
|
2666
|
-
getImmutableElement(name) { return this._formStructure?.getImmutableElement(name); }
|
|
2667
|
-
getExtraInfo(name) { return this._formStructure?.getExtraInfo(name); }
|
|
2668
|
-
getFields() { return this._formStructure?.getFields() ?? null; }
|
|
2669
|
-
getFieldNames() { return this._formStructure?.getFieldNames() ?? null; }
|
|
2670
|
-
getField(code) { return this._formStructure?.getField(code) ?? null; }
|
|
2671
|
-
enableField(code) { return this._formStructure?.enableField(code); }
|
|
2672
|
-
disableField(code) { return this._formStructure?.disableField(code); }
|
|
2673
|
-
getFieldValue(code) { return this._formStructure?.getFieldValue(code) ?? null; }
|
|
2674
|
-
getFieldOptionText(code) { return this._formStructure?.getFieldOptionText(code); }
|
|
2675
|
-
getFieldsValues(codes) { return this._formStructure?.getFieldsValues(codes) ?? null; }
|
|
2676
|
-
getFieldOptions(code) { return this._formStructure?.getFieldOptions(code) ?? null; }
|
|
2677
|
-
setFieldValue(code, value) { return this._formStructure?.setFieldValue(code, value); }
|
|
2678
|
-
setFieldRequired(inputCodes, required) { return this._formStructure?.setFieldRequired(inputCodes, required); }
|
|
2679
|
-
setFieldErrorMessage(code, errorMessage) { return this._formStructure?.setFieldErrorMessage(code, errorMessage); }
|
|
2680
|
-
setFieldError(code, errorCode, message, type) { return this._formStructure?.setFieldError(code, errorCode, message, type); }
|
|
2681
|
-
setFieldIntrinsicErrorMessage(code, message) {
|
|
2682
|
-
return this._formStructure?.setFieldIntrinsicErrorMessage(code, message);
|
|
2683
|
-
}
|
|
2684
|
-
setFieldOptions(code, optionsArray, idAttribute, nameAttribute) {
|
|
2685
|
-
return this._formStructure?.setFieldOptions(code, optionsArray, idAttribute, nameAttribute);
|
|
2686
|
-
}
|
|
2687
|
-
getFieldSet(filterFunc, codes, secCode, subCode) {
|
|
2688
|
-
return this._formStructure?.getFieldSet(filterFunc, codes ?? null, secCode ?? null, subCode ?? null);
|
|
2689
|
-
}
|
|
2690
|
-
applyOnFields(processFunc, codes, secCode, subCode) {
|
|
2691
|
-
return this._formStructure?.applyOnFields(processFunc, codes, secCode, subCode);
|
|
2692
|
-
}
|
|
2693
|
-
applyProcessToAllFields(processFunc) {
|
|
2694
|
-
return this._formStructure?.applyOnFields(processFunc);
|
|
2695
|
-
}
|
|
2696
|
-
cleanFields(codes, secCode, subCode) {
|
|
2697
|
-
return this._formStructure?.cleanFields(codes, secCode, subCode);
|
|
2698
|
-
}
|
|
2699
|
-
getRequiredFields(codes, secCode, subCode) {
|
|
2700
|
-
return this._formStructure?.getRequiredFields(codes, secCode, subCode);
|
|
2701
|
-
}
|
|
2702
|
-
getRequiredEmptyFields(codes, secCode, subCode, onlyVisible) {
|
|
2703
|
-
return this._formStructure?.getRequiredEmptyFields(codes, secCode, subCode, onlyVisible) ?? null;
|
|
2704
|
-
}
|
|
2705
|
-
getChangedFields(codes, secCode, subCode) {
|
|
2706
|
-
return this._formStructure?.getChangedFields(codes, secCode, subCode);
|
|
2707
|
-
}
|
|
2708
|
-
getFieldsWithValidationIssues(codes, secCode, subCode, onlyVisible) {
|
|
2709
|
-
return this._formStructure?.getFieldsWithValidationIssues(codes, secCode, subCode, onlyVisible);
|
|
2710
|
-
}
|
|
2711
|
-
tagFieldsWithError(errorMessage, codes, secCode, subCode) {
|
|
2712
|
-
return this._formStructure?.tagFieldsWithError(errorMessage, codes, secCode, subCode);
|
|
2713
|
-
}
|
|
2714
|
-
cleanErrorFields(codes, secCode, subCode) {
|
|
2715
|
-
return this._formStructure?.cleanErrorFields(codes, secCode, subCode);
|
|
2716
|
-
}
|
|
2717
|
-
showLabelFields(codes, secCode, subCode) {
|
|
2718
|
-
return this._formStructure?.showLabelFields(codes, secCode, subCode);
|
|
2719
|
-
}
|
|
2720
|
-
hideLabelFields(codes, secCode, subCode) {
|
|
2721
|
-
return this._formStructure?.hideLabelFields(codes, secCode, subCode);
|
|
2722
|
-
}
|
|
2723
|
-
enableFields(codes, secCode, subCode) {
|
|
2724
|
-
return this._formStructure?.enableFields(codes, secCode, subCode);
|
|
2725
|
-
}
|
|
2726
|
-
disableFields(codes, secCode, subCode) {
|
|
2727
|
-
return this._formStructure?.disableFields(codes, secCode, subCode);
|
|
2728
|
-
}
|
|
2729
|
-
/**
|
|
2730
|
-
* @deprecated Use enableFields
|
|
2731
|
-
*/
|
|
2732
|
-
enableEditFields(codes, secCode, subCode) {
|
|
2733
|
-
return this.enableFields(codes, secCode, subCode);
|
|
2734
|
-
}
|
|
2735
|
-
/**
|
|
2736
|
-
* @deprecated Use disableFields
|
|
2737
|
-
*/
|
|
2738
|
-
disableEditFields(codes, secCode, subCode) {
|
|
2739
|
-
return this.disableFields(codes, secCode, subCode);
|
|
2740
|
-
}
|
|
2741
|
-
showFields(codes, secCode, subCode) {
|
|
2742
|
-
return this._formStructure?.showFields(codes, secCode, subCode);
|
|
2743
|
-
}
|
|
2744
|
-
hideFields(codes, secCode, subCode) {
|
|
2745
|
-
return this._formStructure?.hideFields(codes, secCode, subCode);
|
|
2746
|
-
}
|
|
2747
|
-
getActionsByAttribute(name, value) {
|
|
2748
|
-
return this._formStructure?.getActionsByAttribute(name, value);
|
|
2749
|
-
}
|
|
2750
|
-
getHeaderActions() {
|
|
2751
|
-
return this._formStructure?.getActionsByAttribute('location', HEADER$1);
|
|
2752
|
-
}
|
|
2753
|
-
getAction(actionCode) {
|
|
2754
|
-
return this._formStructure?.getAction(actionCode) ?? null;
|
|
2755
|
-
}
|
|
2756
|
-
showActions(actionArray) {
|
|
2757
|
-
return this._formStructure?.showActions(actionArray);
|
|
2758
|
-
}
|
|
2759
|
-
hideActions(actionArray) {
|
|
2760
|
-
return this._formStructure?.hideActions(actionArray);
|
|
2761
|
-
}
|
|
2762
|
-
enableActions(actionArray) {
|
|
2763
|
-
return this._formStructure?.enableActions(actionArray);
|
|
2764
|
-
}
|
|
2765
|
-
disableActions(actionArray) {
|
|
2766
|
-
return this._formStructure?.disableActions(actionArray);
|
|
2767
|
-
}
|
|
2768
|
-
showAction(code) {
|
|
2769
|
-
return this._formStructure?.showActions(code);
|
|
2770
|
-
}
|
|
2771
|
-
hideAction(code) {
|
|
2772
|
-
return this._formStructure?.hideActions(code);
|
|
2773
|
-
}
|
|
2774
|
-
enableAction(code) {
|
|
2775
|
-
return this._formStructure?.enableActions(code);
|
|
2776
|
-
}
|
|
2777
|
-
disableAction(code) {
|
|
2778
|
-
return this._formStructure?.disableActions(code);
|
|
2779
|
-
}
|
|
2780
|
-
getSections() {
|
|
2781
|
-
return this._formStructure?.getSections() ?? null;
|
|
2782
|
-
}
|
|
2783
|
-
activateSection(code) {
|
|
2784
|
-
return this._formStructure?.activateSection(code);
|
|
2785
|
-
}
|
|
2786
|
-
getSectionsTitles() {
|
|
2787
|
-
return this._formStructure?.getSections().map(sec => sec.title) ?? null;
|
|
2788
|
-
}
|
|
2789
|
-
getSection(code) {
|
|
2790
|
-
return this._formStructure?.getSection(code) ?? null;
|
|
2791
|
-
}
|
|
2792
|
-
showSection(code) {
|
|
2793
|
-
return this._formStructure?.showSections(code);
|
|
2794
|
-
}
|
|
2795
|
-
hideSection(code) {
|
|
2796
|
-
return this._formStructure?.hideSections(code);
|
|
2797
|
-
}
|
|
2798
|
-
showSections(codes) {
|
|
2799
|
-
return this._formStructure?.showSections(codes);
|
|
2800
|
-
}
|
|
2801
|
-
hideSections(codes) {
|
|
2802
|
-
return this._formStructure?.hideSections(codes);
|
|
2803
|
-
}
|
|
2804
|
-
getSubSection(code, subCode) {
|
|
2805
|
-
return this._formStructure?.getSubSection(code, subCode) ?? null;
|
|
2806
|
-
}
|
|
2807
|
-
showSubSection(code, subCode) {
|
|
2808
|
-
return this._formStructure?.showSubSections(code, subCode);
|
|
2809
|
-
}
|
|
2810
|
-
hideSubSection(code, subCode) {
|
|
2811
|
-
return this._formStructure?.hideSubSections(code, subCode);
|
|
2812
|
-
}
|
|
2813
|
-
showSubSections(code, subCodes) {
|
|
2814
|
-
return this._formStructure?.showSubSections(code, subCodes);
|
|
2815
|
-
}
|
|
2816
|
-
hideSubSections(code, subCodes) {
|
|
2817
|
-
return this._formStructure?.hideSubSections(code, subCodes);
|
|
2818
|
-
}
|
|
2819
|
-
getSectionActions(code) {
|
|
2820
|
-
return this._formStructure?.getSectionActions(code) ?? null;
|
|
2821
|
-
}
|
|
2822
|
-
getSectionActionNames(code) {
|
|
2823
|
-
return this._formStructure?.getSectionActionNames(code) ?? null;
|
|
2824
|
-
}
|
|
2825
|
-
getTables() {
|
|
2826
|
-
return this._formStructure?.getTables();
|
|
2827
|
-
}
|
|
2828
|
-
showTables(codes) {
|
|
2829
|
-
return this._formStructure?.showTables(codes);
|
|
2830
|
-
}
|
|
2831
|
-
hideTables(codes) {
|
|
2832
|
-
return this._formStructure?.hideTables(codes);
|
|
2833
|
-
}
|
|
2834
|
-
cleanTables(codes) {
|
|
2835
|
-
return this._formStructure?.cleanTables(codes);
|
|
2836
|
-
}
|
|
2837
|
-
getTable(code) {
|
|
2838
|
-
return this._formStructure?.getTable(code) ?? null;
|
|
2839
|
-
}
|
|
2840
|
-
showTable(code) {
|
|
2841
|
-
return this._formStructure?.showTables(code);
|
|
2842
|
-
}
|
|
2843
|
-
hideTable(code) {
|
|
2844
|
-
return this._formStructure?.hideTables(code);
|
|
2845
|
-
}
|
|
2846
|
-
cleanTable(code) {
|
|
2847
|
-
return this._formStructure?.getTable(code)?.clean();
|
|
2848
|
-
}
|
|
2849
|
-
getTableRecord(code, recordId) {
|
|
2850
|
-
return this._formStructure?.getTableRecord(code, recordId);
|
|
2851
|
-
}
|
|
2852
|
-
setConfig(formConfig) {
|
|
2853
|
-
this.formConfig = formConfig;
|
|
2854
|
-
}
|
|
2855
2763
|
cleanStart() {
|
|
2856
2764
|
this._errorType = '';
|
|
2857
2765
|
this.errorCode = '';
|
|
@@ -2859,10 +2767,7 @@ class BasicFormComponent {
|
|
|
2859
2767
|
this.errorName = '';
|
|
2860
2768
|
this.errorMessage = '';
|
|
2861
2769
|
this.errorDetail = '';
|
|
2862
|
-
this.
|
|
2863
|
-
this.fields = null;
|
|
2864
|
-
this.actions = null;
|
|
2865
|
-
this.sections = null;
|
|
2770
|
+
this.cleanForm();
|
|
2866
2771
|
this._controlToken = null;
|
|
2867
2772
|
this.inputDataFields = {};
|
|
2868
2773
|
this._definitionObtained = false;
|
|
@@ -2893,19 +2798,6 @@ class BasicFormComponent {
|
|
|
2893
2798
|
}
|
|
2894
2799
|
get formVisible() { return this.visible; }
|
|
2895
2800
|
get form() { return this; }
|
|
2896
|
-
get formCode() { return this.name ?? ''; }
|
|
2897
|
-
set formCode(name) { this.name = name; }
|
|
2898
|
-
get inServerProcess() { return this.busy; }
|
|
2899
|
-
get formStructure() { return this._formStructure; }
|
|
2900
|
-
get state() { return this._formStructure?.state ?? null; }
|
|
2901
|
-
get currentState() { return this._formStructure?.state ?? ''; }
|
|
2902
|
-
set currentState(state) { this?.changeState(state); }
|
|
2903
|
-
get immutableData() { return this._formStructure?.immutableData; }
|
|
2904
|
-
get extraInfo() { return this._formStructure?.extraInfo; }
|
|
2905
|
-
get visibleSections() { return this._formStructure?.visibleSections ?? null; }
|
|
2906
|
-
get formRoute() { return this._formRoute ?? ''; }
|
|
2907
|
-
set formRoute(route) { this._formRoute = route; }
|
|
2908
|
-
get subject() { return this.formSubject ?? ''; }
|
|
2909
2801
|
// Métodos virtuales
|
|
2910
2802
|
customPreProcessing() { }
|
|
2911
2803
|
start() { }
|
|
@@ -2916,43 +2808,6 @@ class BasicFormComponent {
|
|
|
2916
2808
|
showFieldInfo(code, detail) { }
|
|
2917
2809
|
showModalDialog(title, body, options, callback, params) { }
|
|
2918
2810
|
openUploadDialog(title, body, options, callback, params) { }
|
|
2919
|
-
/**
|
|
2920
|
-
* @deprecated Use supportState
|
|
2921
|
-
*/
|
|
2922
|
-
supportMode(state) { return this.supportState(state); }
|
|
2923
|
-
/**
|
|
2924
|
-
* @deprecated Use getField
|
|
2925
|
-
*/
|
|
2926
|
-
getFieldObject(code) { return this.getField(code); }
|
|
2927
|
-
/**
|
|
2928
|
-
* @deprecated Use getAction
|
|
2929
|
-
*/
|
|
2930
|
-
getActionObject(code) { return this.getAction(code); }
|
|
2931
|
-
/**
|
|
2932
|
-
* @deprecated Use getTable
|
|
2933
|
-
*/
|
|
2934
|
-
getTableObject(code) { return this.getTable(code); }
|
|
2935
|
-
/**
|
|
2936
|
-
* @deprecated Use getSection
|
|
2937
|
-
*/
|
|
2938
|
-
getSectionObject(code) { return this.getSection(code); }
|
|
2939
|
-
/**
|
|
2940
|
-
* @deprecated Use changeState
|
|
2941
|
-
*/
|
|
2942
|
-
changeFormMode(state) { return this.changeState(state); }
|
|
2943
|
-
/**
|
|
2944
|
-
* @deprecated Use subject
|
|
2945
|
-
*/
|
|
2946
|
-
getFormSubject() { return this.subject; }
|
|
2947
|
-
/**
|
|
2948
|
-
* @deprecated Use subject
|
|
2949
|
-
*/
|
|
2950
|
-
getSubject() { return this.formSubject ?? ''; }
|
|
2951
|
-
/**
|
|
2952
|
-
* @deprecated Use subject
|
|
2953
|
-
*/
|
|
2954
|
-
getformSubject() { return this.formSubject ?? ''; }
|
|
2955
|
-
numSections() { return this._formStructure?.sections.length; }
|
|
2956
2811
|
subscribeAppEvent(eventName, callback) {
|
|
2957
2812
|
this._eventEmiter.subscribe(eventName, callback);
|
|
2958
2813
|
}
|
|
@@ -2960,7 +2815,7 @@ class BasicFormComponent {
|
|
|
2960
2815
|
let origin = null;
|
|
2961
2816
|
if (!cleanStack) {
|
|
2962
2817
|
origin = { ...backData, name: this.name, url: this._formRoute, token: this._controlToken };
|
|
2963
|
-
origin.subject = origin?.subject ?? this.
|
|
2818
|
+
origin.subject = origin?.subject ?? this.subject;
|
|
2964
2819
|
origin.state = origin?.state ?? this.state;
|
|
2965
2820
|
origin.fields = origin?.fields ?? {};
|
|
2966
2821
|
origin.extra = origin?.extra ?? {};
|
|
@@ -2999,11 +2854,11 @@ class BasicFormComponent {
|
|
|
2999
2854
|
}
|
|
3000
2855
|
preocessInputParams(params) {
|
|
3001
2856
|
this._controlToken = params?.[TOKEN] ?? null;
|
|
3002
|
-
this.
|
|
2857
|
+
this.subject = params?.[SUBJECT] ?? null;
|
|
3003
2858
|
const tokenInfo = (this._controlToken) ? this.formManagerService.getFormInfo(this._controlToken) : {};
|
|
3004
2859
|
const { token, subject, state, fields, extra, originToken } = tokenInfo;
|
|
3005
2860
|
if (token && this._controlToken === token) {
|
|
3006
|
-
this.
|
|
2861
|
+
this.subject = this.subject ?? subject ?? null;
|
|
3007
2862
|
this.inputDataFields = fields;
|
|
3008
2863
|
this.extraData = extra;
|
|
3009
2864
|
this._originToken = originToken;
|
|
@@ -3012,7 +2867,7 @@ class BasicFormComponent {
|
|
|
3012
2867
|
return null;
|
|
3013
2868
|
}
|
|
3014
2869
|
subscribeSectionActivation() {
|
|
3015
|
-
const formSections = this.
|
|
2870
|
+
const formSections = this.sections;
|
|
3016
2871
|
const sectionNames = Object.keys(formSections);
|
|
3017
2872
|
for (let index = 0; index < sectionNames.length; index++) {
|
|
3018
2873
|
const sectionName = sectionNames[index];
|
|
@@ -3020,11 +2875,11 @@ class BasicFormComponent {
|
|
|
3020
2875
|
section.activation.subscribe((code) => this.launchSectionActivation(code));
|
|
3021
2876
|
section.inactivation.subscribe((code) => this.launchSectionInactivation(code));
|
|
3022
2877
|
// Adicionalmente se le pide a la sección se subscriba al cambio de estado del formulario
|
|
3023
|
-
section.connectWithParentForm(this, this.
|
|
2878
|
+
section.connectWithParentForm(this, this.stateChange);
|
|
3024
2879
|
}
|
|
3025
2880
|
}
|
|
3026
2881
|
subscribeFieldsSubjects() {
|
|
3027
|
-
const formFields = this.
|
|
2882
|
+
const formFields = this.getFields();
|
|
3028
2883
|
if (Array.isArray(formFields)) {
|
|
3029
2884
|
formFields.forEach(field => {
|
|
3030
2885
|
field.editionFinish.subscribe(event => {
|
|
@@ -3037,22 +2892,22 @@ class BasicFormComponent {
|
|
|
3037
2892
|
});
|
|
3038
2893
|
field.detailRequest.subscribe(event => this.showFieldInfo(event.code, event.detail));
|
|
3039
2894
|
// Adicionalmente se le pide al campo se subscriba al cambio de estado del formulario
|
|
3040
|
-
field.connectWithParentForm(this, this.
|
|
2895
|
+
field.connectWithParentForm(this, this.stateChange);
|
|
3041
2896
|
});
|
|
3042
2897
|
}
|
|
3043
2898
|
}
|
|
3044
2899
|
subscribeActionSubjects() {
|
|
3045
|
-
const formActions = this.
|
|
2900
|
+
const formActions = this.getActions();
|
|
3046
2901
|
if (Array.isArray(formActions)) {
|
|
3047
2902
|
formActions.forEach(action => {
|
|
3048
2903
|
action.actionActivated.subscribe(code => this.startAction(code));
|
|
3049
2904
|
// Adicionalmente se le pide a la acción se subscriba al cambio de estado del formulario
|
|
3050
|
-
action.connectWithParentForm(this, this.
|
|
2905
|
+
action.connectWithParentForm(this, this.stateChange);
|
|
3051
2906
|
});
|
|
3052
2907
|
}
|
|
3053
2908
|
}
|
|
3054
2909
|
subscribeTableSubjects() {
|
|
3055
|
-
const formTables = this.
|
|
2910
|
+
const formTables = this.getTables();
|
|
3056
2911
|
if (Array.isArray(formTables)) {
|
|
3057
2912
|
formTables.forEach(table => {
|
|
3058
2913
|
table.inlineActionTrigger.subscribe(event => this.startTableAction(event));
|
|
@@ -3061,7 +2916,7 @@ class BasicFormComponent {
|
|
|
3061
2916
|
table.selectionActionTrigger.subscribe(event => this.startTableSelectionAction(event));
|
|
3062
2917
|
table.getDataTrigger.subscribe(event => this.startTableGetData(event));
|
|
3063
2918
|
// Adicionalmente se le pide a la tabla se subscriba al cambio de estado del formulario
|
|
3064
|
-
table.connectWithParentForm(this, this.
|
|
2919
|
+
table.connectWithParentForm(this, this.stateChange);
|
|
3065
2920
|
});
|
|
3066
2921
|
}
|
|
3067
2922
|
}
|
|
@@ -3074,23 +2929,14 @@ class BasicFormComponent {
|
|
|
3074
2929
|
this.busy = true;
|
|
3075
2930
|
const formDefinition = await this.formManagerService.getFormDefinition(this.name);
|
|
3076
2931
|
this.busy = false;
|
|
3077
|
-
this.
|
|
3078
|
-
this.fields = this._formStructure?.fields;
|
|
3079
|
-
this.actions = this._formStructure?.actions;
|
|
3080
|
-
this.sections = this._formStructure?.sections;
|
|
3081
|
-
this.fieldsArray = Object.keys(this.fields)
|
|
3082
|
-
.reduce((accumulator, value) => accumulator.concat(this.fields[value]), []);
|
|
3083
|
-
this.actionsArray = Object.keys(this.actions)
|
|
3084
|
-
.reduce((accumulator, value) => accumulator.concat(this.actions[value]), []);
|
|
3085
|
-
this.sectionsArray = Object.keys(this.sections)
|
|
3086
|
-
.reduce((accumulator, value) => accumulator.concat(this.sections[value]), []);
|
|
2932
|
+
this.loadDefinition(formDefinition);
|
|
3087
2933
|
this._definitionObtained = true;
|
|
3088
2934
|
}
|
|
3089
2935
|
else {
|
|
3090
2936
|
this.cleanData();
|
|
3091
2937
|
}
|
|
3092
|
-
if (!this.supportState(initialState)) {
|
|
3093
|
-
initialState = this.
|
|
2938
|
+
if (!this.supportState(initialState ?? '')) {
|
|
2939
|
+
initialState = this.defaultState ?? null;
|
|
3094
2940
|
}
|
|
3095
2941
|
const inputFieldNames = Object.keys(this.inputDataFields);
|
|
3096
2942
|
for (let index = 0; index < inputFieldNames.length; index++) {
|
|
@@ -3103,16 +2949,16 @@ class BasicFormComponent {
|
|
|
3103
2949
|
this.subscribeActionSubjects();
|
|
3104
2950
|
this.subscribeTableSubjects();
|
|
3105
2951
|
// Se define el estado inicial y se solicita la acción inicial
|
|
3106
|
-
this.changeState(initialState || this.
|
|
2952
|
+
this.changeState(initialState || this.defaultState);
|
|
3107
2953
|
const recordResponse = await this.requestFormAction(formActions.getData);
|
|
3108
2954
|
this.checkErrorRecordReceived(recordResponse);
|
|
3109
2955
|
this.visible = true;
|
|
3110
|
-
this.enabledSections = this.
|
|
2956
|
+
this.enabledSections = this.visibleSections ?? [];
|
|
3111
2957
|
this.start();
|
|
3112
2958
|
this.customFormStart();
|
|
3113
2959
|
}
|
|
3114
2960
|
changeState(state) {
|
|
3115
|
-
const stateChanged =
|
|
2961
|
+
const stateChanged = super.changeState(state ?? '') ?? false;
|
|
3116
2962
|
if (stateChanged) {
|
|
3117
2963
|
const clientActionMethods = this._formChangeState;
|
|
3118
2964
|
if (clientActionMethods && clientActionMethods.length > 0) {
|
|
@@ -3144,13 +2990,13 @@ class BasicFormComponent {
|
|
|
3144
2990
|
async requestFormAction(actionCode, actionSubject = {}) {
|
|
3145
2991
|
const actionDetail = {
|
|
3146
2992
|
formCode: this.name,
|
|
3147
|
-
formSubject: this.
|
|
3148
|
-
currentMode: this.
|
|
2993
|
+
formSubject: this.subject,
|
|
2994
|
+
currentMode: this.state,
|
|
3149
2995
|
actionCode,
|
|
3150
2996
|
actionSubject,
|
|
3151
2997
|
version: PAYLOAD_VERSION,
|
|
3152
|
-
formData: this.
|
|
3153
|
-
immutableData: this.
|
|
2998
|
+
formData: this.getPayload(),
|
|
2999
|
+
immutableData: this.immutableData,
|
|
3154
3000
|
};
|
|
3155
3001
|
this.errorCode = NO_ERROR;
|
|
3156
3002
|
this.errorFullCode = '';
|
|
@@ -3176,7 +3022,7 @@ class BasicFormComponent {
|
|
|
3176
3022
|
const { currentMode, formSubject, actions, fields, recordTables, returnedFile, immutableData, extraInfo, } = formContent;
|
|
3177
3023
|
currentMode && this.changeState(currentMode);
|
|
3178
3024
|
if (formSubject) {
|
|
3179
|
-
this.
|
|
3025
|
+
this.subject = formSubject;
|
|
3180
3026
|
}
|
|
3181
3027
|
if (actions && actions.length > 0) {
|
|
3182
3028
|
for (const changedAction of actions) {
|
|
@@ -3205,32 +3051,18 @@ class BasicFormComponent {
|
|
|
3205
3051
|
if (returnedFile && returnedFile.file) {
|
|
3206
3052
|
this.fileMgmtServices.saveFile(returnedFile.file, returnedFile.name, returnedFile.type);
|
|
3207
3053
|
}
|
|
3208
|
-
|
|
3209
|
-
|
|
3210
|
-
this._formStructure.extraInfo = extraInfo;
|
|
3211
|
-
}
|
|
3054
|
+
this.immutableData = immutableData;
|
|
3055
|
+
this.extraInfo = extraInfo;
|
|
3212
3056
|
}
|
|
3213
3057
|
/**
|
|
3214
3058
|
* Manejo de event handlers para errores Server del formulario
|
|
3215
3059
|
*/
|
|
3216
|
-
cleanActionServerError() {
|
|
3217
|
-
|
|
3218
|
-
}
|
|
3219
|
-
|
|
3220
|
-
|
|
3221
|
-
}
|
|
3222
|
-
cleanTableServerError() {
|
|
3223
|
-
this._tableServerError = [];
|
|
3224
|
-
}
|
|
3225
|
-
onActionServerError(callback, properties = null) {
|
|
3226
|
-
this._actionServerError.push({ callback, properties });
|
|
3227
|
-
}
|
|
3228
|
-
onValidationServerError(callback, properties = null) {
|
|
3229
|
-
this._fieldServerError.push({ callback, properties });
|
|
3230
|
-
}
|
|
3231
|
-
onTableServerError(callback, properties = null) {
|
|
3232
|
-
this._tableServerError.push({ callback, properties });
|
|
3233
|
-
}
|
|
3060
|
+
cleanActionServerError() { this._actionServerError = []; }
|
|
3061
|
+
cleanFieldServerError() { this._fieldServerError = []; }
|
|
3062
|
+
cleanTableServerError() { this._tableServerError = []; }
|
|
3063
|
+
onActionServerError(callback, properties = null) { this._actionServerError.push({ callback, properties }); }
|
|
3064
|
+
onValidationServerError(callback, properties = null) { this._fieldServerError.push({ callback, properties }); }
|
|
3065
|
+
onTableServerError(callback, properties = null) { this._tableServerError.push({ callback, properties }); }
|
|
3234
3066
|
/**
|
|
3235
3067
|
* Manejo de event handlers para acciones sobre el formulario
|
|
3236
3068
|
*/
|
|
@@ -3283,7 +3115,7 @@ class BasicFormComponent {
|
|
|
3283
3115
|
});
|
|
3284
3116
|
}
|
|
3285
3117
|
async verifySectionActivation(code) {
|
|
3286
|
-
const sectionObject = this.
|
|
3118
|
+
const sectionObject = this.getSection(code);
|
|
3287
3119
|
if (!sectionObject) {
|
|
3288
3120
|
return false;
|
|
3289
3121
|
}
|
|
@@ -3301,7 +3133,7 @@ class BasicFormComponent {
|
|
|
3301
3133
|
}
|
|
3302
3134
|
async launchSectionActivation(code) {
|
|
3303
3135
|
this.notifyFormActivity();
|
|
3304
|
-
const sectionObject = this.
|
|
3136
|
+
const sectionObject = this.getSection(code);
|
|
3305
3137
|
if (!sectionObject) {
|
|
3306
3138
|
return;
|
|
3307
3139
|
}
|
|
@@ -3315,7 +3147,7 @@ class BasicFormComponent {
|
|
|
3315
3147
|
}
|
|
3316
3148
|
async launchSectionInactivation(code) {
|
|
3317
3149
|
this.notifyFormActivity();
|
|
3318
|
-
const sectionObject = this.
|
|
3150
|
+
const sectionObject = this.getSection(code);
|
|
3319
3151
|
if (!sectionObject) {
|
|
3320
3152
|
return;
|
|
3321
3153
|
}
|
|
@@ -3359,9 +3191,9 @@ class BasicFormComponent {
|
|
|
3359
3191
|
let actionResult = null;
|
|
3360
3192
|
if (action.backend) {
|
|
3361
3193
|
actionResult = await this.requestFormAction(action.actionCode);
|
|
3362
|
-
serverError = !!this.errorOccured();
|
|
3363
3194
|
}
|
|
3364
3195
|
await this.finishAction(action, actionResult, serverError);
|
|
3196
|
+
serverError = !!this.errorOccured();
|
|
3365
3197
|
if (!serverError) {
|
|
3366
3198
|
action.newState && this.changeState(action.newState);
|
|
3367
3199
|
}
|
|
@@ -4048,8 +3880,36 @@ class BasicFormComponent {
|
|
|
4048
3880
|
* Métodos Legacy de compatibilidad hacia atrás
|
|
4049
3881
|
*/
|
|
4050
3882
|
/**
|
|
4051
|
-
|
|
4052
|
-
|
|
3883
|
+
* @deprecated Use name
|
|
3884
|
+
*/
|
|
3885
|
+
get formCode() { return this.name ?? ''; }
|
|
3886
|
+
/**
|
|
3887
|
+
* @deprecated Use name
|
|
3888
|
+
*/
|
|
3889
|
+
set formCode(name) { this.name = name; }
|
|
3890
|
+
/**
|
|
3891
|
+
* @deprecated Use busy
|
|
3892
|
+
*/
|
|
3893
|
+
get inServerProcess() { return this.busy; }
|
|
3894
|
+
/**
|
|
3895
|
+
* @deprecated Use state
|
|
3896
|
+
*/
|
|
3897
|
+
get currentState() { return this.state ?? ''; }
|
|
3898
|
+
/**
|
|
3899
|
+
* @deprecated Use changeState
|
|
3900
|
+
*/
|
|
3901
|
+
set currentState(state) { this?.changeState(state); }
|
|
3902
|
+
/**
|
|
3903
|
+
* @deprecated Use onSectionActivation
|
|
3904
|
+
*/
|
|
3905
|
+
get formRoute() { return this._formRoute ?? ''; }
|
|
3906
|
+
/**
|
|
3907
|
+
* @deprecated Use onSectionActivation
|
|
3908
|
+
*/
|
|
3909
|
+
set formRoute(route) { this._formRoute = route; }
|
|
3910
|
+
/**
|
|
3911
|
+
* @deprecated Use onSectionActivation
|
|
3912
|
+
*/
|
|
4053
3913
|
addSectionActivation(codes, callback, properties = null) {
|
|
4054
3914
|
return this.onSectionActivation(codes, callback, properties);
|
|
4055
3915
|
}
|
|
@@ -4127,7 +3987,7 @@ class BasicFormComponent {
|
|
|
4127
3987
|
}
|
|
4128
3988
|
}
|
|
4129
3989
|
BasicFormComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: BasicFormComponent, deps: [{ token: LibFormManagerService }, { token: LibEventManagerService }, { token: LibFileManagementService }], target: i0.ɵɵFactoryTarget.Component });
|
|
4130
|
-
BasicFormComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.6", type: BasicFormComponent, selector: "ng-component", ngImport: i0, template: `<ng-content></ng-content>`, isInline: true });
|
|
3990
|
+
BasicFormComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.6", type: BasicFormComponent, selector: "ng-component", usesInheritance: true, ngImport: i0, template: `<ng-content></ng-content>`, isInline: true });
|
|
4131
3991
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: BasicFormComponent, decorators: [{
|
|
4132
3992
|
type: Component,
|
|
4133
3993
|
args: [{
|