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.
@@ -342,15 +342,18 @@ class LibTableRecordActionComponent extends PieceComponent {
342
342
  }
343
343
  start() {
344
344
  if (this.action && this.action.restrictedOnField && this.recordData) {
345
- const relatedField = this.recordData[this.action.restrictedOnField];
345
+ const relatedField = this.action.restrictedOnField;
346
346
  if (relatedField) {
347
- const fieldValue = relatedField;
347
+ const relatedFieldValue = this.recordData[relatedField];
348
348
  const restrictionOper = this.action.restrictedOnOperator;
349
349
  const restrictionValue = this.action.restrictedOnValue;
350
- if ((restrictionOper === '==' && fieldValue !== restrictionValue)
351
- || (restrictionOper === '!=' && fieldValue === restrictionValue)) {
350
+ if ((restrictionOper === '==' && relatedFieldValue !== restrictionValue)
351
+ || (restrictionOper === '!=' && relatedFieldValue === restrictionValue)) {
352
352
  this.isVisible = false;
353
353
  }
354
+ else {
355
+ this.isVisible = true;
356
+ }
354
357
  }
355
358
  }
356
359
  }
@@ -1307,6 +1310,13 @@ class TableAction extends FormPiece {
1307
1310
  this.restrictedOnOperator = actionDefinition.operatorRestricted || null;
1308
1311
  }
1309
1312
  }
1313
+ formStateChange(state) {
1314
+ if (state) {
1315
+ this._formState = state;
1316
+ this._visible = this._absoluteVisible && this.viewOnState(state);
1317
+ this._disabled = this._absoluteDisabled || !this.enabledOnState(state);
1318
+ }
1319
+ }
1310
1320
  }
1311
1321
 
1312
1322
  class TableRecordData {
@@ -2111,34 +2121,52 @@ const ENABLE = 'enable';
2111
2121
  const DISABLE = 'disable';
2112
2122
  const CLEAN = 'clean';
2113
2123
  class FormStructureAndData {
2114
- constructor(definitionReceived, formConfig) {
2124
+ constructor() {
2115
2125
  this._stateChange = new Subject();
2116
- this._name = '';
2117
- this._title = '';
2118
- this._fields = {};
2119
- this._actions = {};
2120
- this._tables = {};
2121
- this._sections = {};
2126
+ this.name = '';
2127
+ this.title = '';
2128
+ this.subject = null;
2129
+ this.fields = {};
2130
+ this.actions = {};
2131
+ this.tables = {};
2132
+ this.sections = {};
2122
2133
  this._immutableData = {};
2123
2134
  this._extraInfo = {};
2124
2135
  this._exclusiveSectionsByAttr = {};
2125
- this._formConfig = formConfig;
2126
2136
  this.state = '';
2127
- this._actionArray = [];
2128
- this._fieldArray = [];
2129
- this._tableArray = [];
2130
- this._sectionArray = [];
2131
- this._stateFlow = {
2137
+ this.actionArray = [];
2138
+ this.fieldArray = [];
2139
+ this.tableArray = [];
2140
+ this.sectionArray = [];
2141
+ this.stateFlow = {
2132
2142
  defaultState: '',
2133
2143
  states: [],
2134
2144
  transitions: [],
2135
2145
  };
2146
+ }
2147
+ setConfig(formConfig) {
2148
+ this.formConfig = formConfig;
2149
+ }
2150
+ cleanForm() {
2151
+ this.actionArray = [];
2152
+ this.fieldArray = [];
2153
+ this.tableArray = [];
2154
+ this.sectionArray = [];
2155
+ this.stateFlow = {
2156
+ defaultState: '',
2157
+ states: [],
2158
+ transitions: [],
2159
+ };
2160
+ }
2161
+ loadDefinition(definitionReceived) {
2162
+ var _a, _b;
2163
+ this.state = '';
2164
+ this.cleanForm();
2136
2165
  if (!definitionReceived) {
2137
2166
  return;
2138
2167
  }
2139
- this._name = (definitionReceived.form && definitionReceived.form.formCode)
2140
- ? definitionReceived.form.formCode : this._name;
2141
- this._title = (definitionReceived.form && definitionReceived.form.formTitle)
2168
+ this.name = (_a = this.name) !== null && _a !== void 0 ? _a : (_b = definitionReceived === null || definitionReceived === void 0 ? void 0 : definitionReceived.form) === null || _b === void 0 ? void 0 : _b.formCode;
2169
+ this.title = (definitionReceived.form && definitionReceived.form.formTitle)
2142
2170
  ? definitionReceived.form.formTitle : '';
2143
2171
  this.setStateFlow(definitionReceived === null || definitionReceived === void 0 ? void 0 : definitionReceived.states, definitionReceived === null || definitionReceived === void 0 ? void 0 : definitionReceived.transitions, definitionReceived === null || definitionReceived === void 0 ? void 0 : definitionReceived.defaultState);
2144
2172
  this.immutableData = definitionReceived.immutableData;
@@ -2157,11 +2185,11 @@ class FormStructureAndData {
2157
2185
  return Object.assign(Object.assign({}, objDef), { visibleStates, enabledStates });
2158
2186
  });
2159
2187
  for (const actionReceived of formActions) {
2160
- const globalAction = new FormAction(actionReceived, this._formConfig);
2188
+ const globalAction = new FormAction(actionReceived, this.formConfig);
2161
2189
  const globalActionCode = globalAction.actionCode;
2162
2190
  if (globalActionCode) {
2163
- this._actionArray.push(globalAction);
2164
- this._actions[globalActionCode] = globalAction;
2191
+ this.actionArray.push(globalAction);
2192
+ this.actions[globalActionCode] = globalAction;
2165
2193
  }
2166
2194
  }
2167
2195
  }
@@ -2179,11 +2207,11 @@ class FormStructureAndData {
2179
2207
  return Object.assign(Object.assign({}, objDef), { visibleStates, enabledStates });
2180
2208
  });
2181
2209
  for (const fieldReceived of formFields) {
2182
- const fieldToAdd = new FieldDescriptor(fieldReceived, this._formConfig);
2210
+ const fieldToAdd = new FieldDescriptor(fieldReceived, this.formConfig);
2183
2211
  const fieldCode = fieldToAdd.code;
2184
2212
  if (fieldCode) {
2185
- this._fieldArray.push(fieldToAdd);
2186
- this._fields[fieldCode] = fieldToAdd;
2213
+ this.fieldArray.push(fieldToAdd);
2214
+ this.fields[fieldCode] = fieldToAdd;
2187
2215
  }
2188
2216
  }
2189
2217
  }
@@ -2200,11 +2228,11 @@ class FormStructureAndData {
2200
2228
  return Object.assign(Object.assign({}, objDef), { visibleStates, enabledStates });
2201
2229
  });
2202
2230
  for (const tableReceived of tables) {
2203
- const tableToAdd = new RecordTable(tableReceived, this._formConfig);
2231
+ const tableToAdd = new RecordTable(tableReceived, this.formConfig);
2204
2232
  const tableCode = tableToAdd.tableCode;
2205
2233
  if (tableCode) {
2206
- this._tableArray.push(tableToAdd);
2207
- this._tables[tableCode] = tableToAdd;
2234
+ this.tableArray.push(tableToAdd);
2235
+ this.tables[tableCode] = tableToAdd;
2208
2236
  }
2209
2237
  }
2210
2238
  }
@@ -2219,34 +2247,29 @@ class FormStructureAndData {
2219
2247
  return Object.assign(Object.assign({}, objDef), { visibleStates });
2220
2248
  });
2221
2249
  for (const sectionReceived of formSections) {
2222
- const sectionToAdd = new RecordFormSection(sectionReceived, this, this._formConfig);
2250
+ const sectionToAdd = new RecordFormSection(sectionReceived, this, this.formConfig);
2223
2251
  const sectionCode = sectionToAdd.sectionCode;
2224
2252
  if (sectionCode) {
2225
- this._sectionArray.push(sectionToAdd);
2226
- this._sections[sectionCode] = sectionToAdd;
2253
+ this.sectionArray.push(sectionToAdd);
2254
+ this.sections[sectionCode] = sectionToAdd;
2227
2255
  }
2228
2256
  }
2229
2257
  }
2230
2258
  }
2231
- getTitle() { return this._title; }
2232
- setTitle(title) { this._title = title; }
2233
- get name() { return this._name; }
2234
- set name(name) { this._name = name; }
2235
2259
  // Estados
2236
- get defaultState() { return this._stateFlow.defaultState; }
2237
- supportState(state) { var _a; return (_a = this._stateFlow.states) === null || _a === void 0 ? void 0 : _a.includes(state); }
2238
- supportMode(state) { return this.supportState(state); }
2239
- get states() { return this._stateFlow.states; }
2240
- getCurrentState() { return this.state; }
2260
+ get defaultState() { return this.stateFlow.defaultState; }
2261
+ get states() { return this.stateFlow.states; }
2262
+ supportState(state = '') { var _a; return (!!state && ((_a = this.stateFlow.states) === null || _a === void 0 ? void 0 : _a.includes(state))); }
2241
2263
  changeState(newState) {
2242
- if (!newState || !this.supportState(newState)) {
2264
+ const currentState = this.state;
2265
+ if (!newState || !this.supportState(newState) || currentState === newState) {
2243
2266
  return false;
2244
2267
  }
2245
2268
  if (!this.state) {
2246
2269
  this.state = newState;
2247
2270
  }
2248
2271
  else {
2249
- const transitionToChange = this._stateFlow.transitions.find(trns => trns.source === this.state && trns.destination === newState);
2272
+ const transitionToChange = this.stateFlow.transitions.find(trns => trns.source === this.state && trns.destination === newState);
2250
2273
  if (transitionToChange) {
2251
2274
  this.state = newState;
2252
2275
  }
@@ -2256,12 +2279,12 @@ class FormStructureAndData {
2256
2279
  }
2257
2280
  get stateChange() { return this._stateChange; }
2258
2281
  setStateFlow(states, transitions, defaultState) {
2259
- this._stateFlow.states = states;
2260
- this._stateFlow.defaultState = defaultState || this._stateFlow.states[0];
2261
- this._stateFlow.transitions = transitions.map(transition => {
2282
+ this.stateFlow.states = states;
2283
+ this.stateFlow.defaultState = defaultState || this.stateFlow.states[0];
2284
+ this.stateFlow.transitions = transitions.map(transition => {
2262
2285
  const name = transition.name;
2263
- const source = (this._stateFlow.states.includes(transition.source)) ? transition.source : '';
2264
- const destination = (this._stateFlow.states.includes(transition.destination)) ? transition.destination : '';
2286
+ const source = (this.stateFlow.states.includes(transition.source)) ? transition.source : '';
2287
+ const destination = (this.stateFlow.states.includes(transition.destination)) ? transition.destination : '';
2265
2288
  return { name, source, destination };
2266
2289
  }).filter(item => item.name && item.source && item.destination);
2267
2290
  }
@@ -2274,11 +2297,10 @@ class FormStructureAndData {
2274
2297
  set extraInfo(extraInfo) { Object.assign(this._extraInfo, extraInfo); }
2275
2298
  get extraInfo() { return JSON.parse(JSON.stringify(this._extraInfo)); }
2276
2299
  // Fields
2277
- get fields() { return this._fields; }
2278
2300
  get fieldNames() { return this.getFieldNames(); }
2279
- getFields() { return this._fieldArray; }
2280
- getFieldNames() { return this._fieldArray.map(field => field.code); }
2281
- getField(code) { var _a; return (code && ((_a = this._fields) === null || _a === void 0 ? void 0 : _a[code])) ? this._fields[code] : null; }
2301
+ getFields() { return this.fieldArray; }
2302
+ getFieldNames() { return this.fieldArray.map(field => field.code); }
2303
+ getField(code) { var _a; return (code && ((_a = this.fields) === null || _a === void 0 ? void 0 : _a[code])) ? this.fields[code] : null; }
2282
2304
  enableField(code) { var _a; (_a = this.getField(code)) === null || _a === void 0 ? void 0 : _a.enable(); }
2283
2305
  disableField(code) { var _a; (_a = this.getField(code)) === null || _a === void 0 ? void 0 : _a.disable(); }
2284
2306
  getFieldValue(code) { var _a; return (_a = this.getField(code)) === null || _a === void 0 ? void 0 : _a.value; }
@@ -2353,6 +2375,9 @@ class FormStructureAndData {
2353
2375
  }
2354
2376
  return processedFields;
2355
2377
  }
2378
+ applyProcessToAllFields(processFunc) {
2379
+ return this.applyOnFields(processFunc);
2380
+ }
2356
2381
  enableFields(codes, secCode, subCode) {
2357
2382
  return this.applyOnFields(fld => fld === null || fld === void 0 ? void 0 : fld.enable(), codes, secCode, subCode);
2358
2383
  }
@@ -2408,20 +2433,26 @@ class FormStructureAndData {
2408
2433
  for (let index = 0; index < codes.length; index++) {
2409
2434
  const code = codes[index];
2410
2435
  if (code) {
2411
- resultObject[code] = (_c = (_b = (_a = this._fields) === null || _a === void 0 ? void 0 : _a[code]) === null || _b === void 0 ? void 0 : _b.getValue()) !== null && _c !== void 0 ? _c : null;
2436
+ resultObject[code] = (_c = (_b = (_a = this.fields) === null || _a === void 0 ? void 0 : _a[code]) === null || _b === void 0 ? void 0 : _b.getValue()) !== null && _c !== void 0 ? _c : null;
2412
2437
  }
2413
2438
  }
2414
2439
  return resultObject;
2415
2440
  }
2416
2441
  // Acciones
2417
- get actions() { return this._actions; }
2418
- getActionsByAttribute(name, value) { return this._actionArray.filter(actionItem => actionItem.matchAttribute(name, value)); }
2419
- getActions() { return this._actionArray; }
2420
- getAction(code) { var _a; return (code && ((_a = this._actions) === null || _a === void 0 ? void 0 : _a[code])) ? this._actions[code] : null; }
2442
+ getActions() { return this.actionArray; }
2443
+ getAction(code) { var _a; return (code && ((_a = this.actions) === null || _a === void 0 ? void 0 : _a[code])) ? this.actions[code] : null; }
2421
2444
  showActions(codes) { return this.execOnActions(codes, SHOW); }
2422
2445
  hideActions(codes) { return this.execOnActions(codes, HIDE); }
2423
2446
  enableActions(codes) { return this.execOnActions(codes, ENABLE); }
2424
2447
  disableActions(codes) { return this.execOnActions(codes, DISABLE); }
2448
+ enableAction(code) { return this.enableActions(code); }
2449
+ disableAction(code) { return this.disableActions(code); }
2450
+ showAction(code) { return this.showActions(code); }
2451
+ hideAction(code) { return this.hideActions(code); }
2452
+ getHeaderActions() { return this.getActionsByAttribute('location', HEADER$1); }
2453
+ getActionsByAttribute(name, value) {
2454
+ return this.actionArray.filter(actionItem => actionItem.matchAttribute(name, value));
2455
+ }
2425
2456
  execOnActions(codes, functionName) {
2426
2457
  const actionCodes = (Array.isArray(codes)) ? codes : (codes ? [codes] : []);
2427
2458
  if (!functionName || actionCodes.length === 0) {
@@ -2434,15 +2465,17 @@ class FormStructureAndData {
2434
2465
  });
2435
2466
  }
2436
2467
  // Tablas
2437
- get tables() { return this.tables; }
2438
- getTables() { return this._tableArray; }
2439
- getTable(code) { var _a; return (code && ((_a = this._tables) === null || _a === void 0 ? void 0 : _a[code])) ? this._tables[code] : null; }
2468
+ getTables() { return this.tableArray; }
2469
+ getTable(code) { var _a; return (code && ((_a = this.tables) === null || _a === void 0 ? void 0 : _a[code])) ? this.tables[code] : null; }
2440
2470
  getTableRecord(code, id) { var _a; return (_a = this.getTable(code)) === null || _a === void 0 ? void 0 : _a.getTableRecord(id); }
2441
2471
  enableTables(codes) { return this.execOnTables(codes, ENABLE); }
2442
2472
  disableTables(codes) { return this.execOnTables(codes, DISABLE); }
2443
2473
  showTables(codes) { return this.execOnTables(codes, SHOW); }
2444
2474
  hideTables(codes) { return this.execOnTables(codes, HIDE); }
2445
2475
  cleanTables(codes) { return this.execOnTables(codes, CLEAN); }
2476
+ showTable(code) { return this.showTables(code); }
2477
+ hideTable(code) { return this.hideTables(code); }
2478
+ cleanTable(code) { var _a; return (_a = this.getTable(code)) === null || _a === void 0 ? void 0 : _a.clean(); }
2446
2479
  execOnTables(codes, functionName) {
2447
2480
  const tableCodes = (Array.isArray(codes)) ? codes : (codes ? [codes] : []);
2448
2481
  if (!functionName || tableCodes.length === 0) {
@@ -2455,17 +2488,22 @@ class FormStructureAndData {
2455
2488
  });
2456
2489
  }
2457
2490
  // Secciones
2458
- get sections() { return this._sections; }
2459
- getSections() { return this._sectionArray; }
2460
- getSectionsByAttribute(name, value) { return this._sectionArray.filter(item => item.matchAttribute(name, value)); }
2461
- get sectionTitles() { return this._sectionArray.map(formSection => formSection.sectionTitle); }
2462
- get visibleSections() { return this._sectionArray.filter(sec => sec.absoluteVisible); }
2463
- getSection(code) { var _a; return (code && ((_a = this._sections) === null || _a === void 0 ? void 0 : _a[code])) ? this._sections[code] : null; }
2491
+ getSections() { return this.sectionArray; }
2492
+ getSectionsTitles() { var _a; return (_a = this.getSections()) === null || _a === void 0 ? void 0 : _a.filter(sec => sec === null || sec === void 0 ? void 0 : sec.title).map(sec => { var _a; return (_a = sec === null || sec === void 0 ? void 0 : sec.title) !== null && _a !== void 0 ? _a : ''; }); }
2493
+ numSections() { return this.sectionArray.length; }
2494
+ getSectionsByAttribute(name, value) { return this.sectionArray.filter(item => item.matchAttribute(name, value)); }
2495
+ get sectionTitles() { return this.getSectionsTitles(); }
2496
+ get visibleSections() { return this.sectionArray.filter(sec => sec.absoluteVisible); }
2497
+ getSection(code) { var _a; return (code && ((_a = this.sections) === null || _a === void 0 ? void 0 : _a[code])) ? this.sections[code] : null; }
2464
2498
  showSections(codes) { this.execOnSections(codes, SHOW); }
2465
2499
  hideSections(codes) { this.execOnSections(codes, HIDE); }
2500
+ showSection(code) { return this.showSections(code); }
2501
+ hideSection(code) { return this.hideSections(code); }
2466
2502
  activeSection() { return this._exclusiveSectionsByAttr[ACTIVE]; }
2467
2503
  getSubSection(code, subCode) { var _a, _b; return (_b = (_a = this.getSection(code)) === null || _a === void 0 ? void 0 : _a.getSubsection(subCode)) !== null && _b !== void 0 ? _b : null; }
2468
2504
  showSubSections(code, subCodes) { return this.execOnSubSections(code, subCodes, SHOW); }
2505
+ showSubSection(code, subCode) { return this.showSubSections(code, subCode); }
2506
+ hideSubSection(code, subCode) { return this.hideSubSections(code, subCode); }
2469
2507
  hideSubSections(code, subCodes) { return this.execOnSubSections(code, subCodes, HIDE); }
2470
2508
  getSectionActions(code) { var _a, _b; return (_b = (_a = this.getSection(code)) === null || _a === void 0 ? void 0 : _a.getActions()) !== null && _b !== void 0 ? _b : null; }
2471
2509
  getSectionActionNames(code) { var _a, _b; return (_b = (_a = this.getSection(code)) === null || _a === void 0 ? void 0 : _a.getActionNames()) !== null && _b !== void 0 ? _b : null; }
@@ -2505,18 +2543,15 @@ class FormStructureAndData {
2505
2543
  * Métodos propios de gestión del formulario
2506
2544
  */
2507
2545
  cleanData() {
2508
- for (const field of this._fieldArray) {
2546
+ for (const field of this.fieldArray) {
2509
2547
  field.setValue(field.defaultValue);
2510
2548
  }
2511
- for (const table of this._tableArray) {
2549
+ for (const table of this.tableArray) {
2512
2550
  table.clean();
2513
2551
  }
2514
2552
  }
2515
2553
  getPayload() {
2516
- const formData = {
2517
- fields: [],
2518
- tables: [],
2519
- };
2554
+ const formData = { fields: [], tables: [] };
2520
2555
  formData.fields = this.getFields().filter(fld => !(fld === null || fld === void 0 ? void 0 : fld.outputOnly))
2521
2556
  .map(fld => {
2522
2557
  const fieldPayload = {
@@ -2544,6 +2579,78 @@ class FormStructureAndData {
2544
2579
  });
2545
2580
  return formData;
2546
2581
  }
2582
+ /**
2583
+ * @deprecated Use subject
2584
+ */
2585
+ get formSubject() { return this.subject; }
2586
+ /**
2587
+ * @deprecated Use subject
2588
+ */
2589
+ set formSubject(subject) { this.subject = subject; }
2590
+ /**
2591
+ * @deprecated Use states
2592
+ */
2593
+ getStates() { return this.states; }
2594
+ /**
2595
+ * @deprecated Use state
2596
+ */
2597
+ getCurrentState() { return this.state; }
2598
+ /**
2599
+ * @deprecated Use title
2600
+ */
2601
+ getTitle() { return this.title; }
2602
+ /**
2603
+ * @deprecated Use title
2604
+ */
2605
+ setTitle(title) { this.title = title; }
2606
+ /**
2607
+ * @deprecated Use supportState
2608
+ */
2609
+ supportMode(state) { return this.supportState(state); }
2610
+ /**
2611
+ * @deprecated Use enableFields
2612
+ */
2613
+ enableEditFields(codes, secCode, subCode) {
2614
+ return this.enableFields(codes, secCode, subCode);
2615
+ }
2616
+ /**
2617
+ * @deprecated Use disableFields
2618
+ */
2619
+ disableEditFields(codes, secCode, subCode) {
2620
+ return this.disableFields(codes, secCode, subCode);
2621
+ }
2622
+ /**
2623
+ * @deprecated Use getField
2624
+ */
2625
+ getFieldObject(code) { return this.getField(code); }
2626
+ /**
2627
+ * @deprecated Use getAction
2628
+ */
2629
+ getActionObject(code) { return this.getAction(code); }
2630
+ /**
2631
+ * @deprecated Use getTable
2632
+ */
2633
+ getTableObject(code) { return this.getTable(code); }
2634
+ /**
2635
+ * @deprecated Use getSection
2636
+ */
2637
+ getSectionObject(code) { return this.getSection(code); }
2638
+ /**
2639
+ * @deprecated Use changeState
2640
+ */
2641
+ changeFormMode(state) { return this.changeState(state); }
2642
+ /**
2643
+ * @deprecated Use subject
2644
+ */
2645
+ getFormSubject() { return this.subject; }
2646
+ /**
2647
+ * @deprecated Use subject
2648
+ */
2649
+ getSubject() { var _a; return (_a = this.subject) !== null && _a !== void 0 ? _a : ''; }
2650
+ /**
2651
+ * @deprecated Use subject
2652
+ */
2653
+ getformSubject() { var _a; return (_a = this.subject) !== null && _a !== void 0 ? _a : ''; }
2547
2654
  }
2548
2655
 
2549
2656
  class LibFormManagerService {
@@ -2660,12 +2767,12 @@ const GLOBAL_ACTION = 'GLOBAL';
2660
2767
  const GET_DATA_ACTION = 'GETDATA';
2661
2768
  const SUBJECT = 'subject';
2662
2769
  const TOKEN = 'token';
2663
- class BasicFormComponent {
2770
+ class BasicFormComponent extends FormStructureAndData {
2664
2771
  constructor(formManagerService, _eventManager, fileMgmtServices) {
2772
+ super();
2665
2773
  this.formManagerService = formManagerService;
2666
2774
  this._eventManager = _eventManager;
2667
2775
  this.fileMgmtServices = fileMgmtServices;
2668
- this._formStructure = null;
2669
2776
  this._controlToken = null;
2670
2777
  this._originToken = null;
2671
2778
  this._formRoute = null;
@@ -2687,279 +2794,28 @@ class BasicFormComponent {
2687
2794
  this._tableActionsFinish = {};
2688
2795
  this._tableGetDataStart = {};
2689
2796
  this._tableGetDataFinish = {};
2797
+ // Errores en procesos
2690
2798
  this._actionServerError = [];
2691
2799
  this._fieldServerError = [];
2692
2800
  this._tableServerError = [];
2801
+ // Datos complementarios del formulario
2693
2802
  this.inputDataFields = {};
2694
2803
  this.extraData = {};
2695
2804
  this.enabledSections = [];
2696
- this.name = null;
2697
- this.formSubject = null;
2805
+ // Gestión de error
2698
2806
  this._errorType = '';
2699
2807
  this.errorCode = '';
2700
2808
  this.errorFullCode = '';
2701
2809
  this.errorName = '';
2702
2810
  this.errorMessage = '';
2703
2811
  this.errorDetail = '';
2812
+ // Control de estado
2704
2813
  this.visible = false;
2705
- this.fieldsArray = null;
2706
- this.actionsArray = null;
2707
- this.sectionsArray = null;
2708
2814
  this.busy = false;
2709
2815
  this._eventEmiter = this._eventManager;
2710
2816
  this.cleanStart();
2711
2817
  this.customPreProcessing();
2712
2818
  }
2713
- get title() { var _a; return (_a = this.getTitle()) !== null && _a !== void 0 ? _a : ''; }
2714
- set title(title) { this.setTitle(title); }
2715
- getTitle() { var _a; return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.getTitle(); }
2716
- setTitle(title) { var _a; return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.setTitle(title); }
2717
- cleanData() { var _a; return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.cleanData(); }
2718
- getCurrentState() { var _a; return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.getCurrentState(); }
2719
- supportState(state) { var _a, _b; return (_b = (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.supportState(state !== null && state !== void 0 ? state : '')) !== null && _b !== void 0 ? _b : false; }
2720
- getStates() { var _a; return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.states; }
2721
- getImmutableElement(name) { var _a; return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.getImmutableElement(name); }
2722
- getExtraInfo(name) { var _a; return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.getExtraInfo(name); }
2723
- getFields() { var _a, _b; return (_b = (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.getFields()) !== null && _b !== void 0 ? _b : null; }
2724
- getFieldNames() { var _a, _b; return (_b = (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.getFieldNames()) !== null && _b !== void 0 ? _b : null; }
2725
- getField(code) { var _a, _b; return (_b = (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.getField(code)) !== null && _b !== void 0 ? _b : null; }
2726
- enableField(code) { var _a; return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.enableField(code); }
2727
- disableField(code) { var _a; return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.disableField(code); }
2728
- getFieldValue(code) { var _a, _b; return (_b = (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.getFieldValue(code)) !== null && _b !== void 0 ? _b : null; }
2729
- getFieldOptionText(code) { var _a; return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.getFieldOptionText(code); }
2730
- getFieldsValues(codes) { var _a, _b; return (_b = (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.getFieldsValues(codes)) !== null && _b !== void 0 ? _b : null; }
2731
- getFieldOptions(code) { var _a, _b; return (_b = (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.getFieldOptions(code)) !== null && _b !== void 0 ? _b : null; }
2732
- setFieldValue(code, value) { var _a; return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.setFieldValue(code, value); }
2733
- setFieldRequired(inputCodes, required) { var _a; return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.setFieldRequired(inputCodes, required); }
2734
- setFieldErrorMessage(code, errorMessage) { var _a; return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.setFieldErrorMessage(code, errorMessage); }
2735
- setFieldError(code, errorCode, message, type) { var _a; return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.setFieldError(code, errorCode, message, type); }
2736
- setFieldIntrinsicErrorMessage(code, message) {
2737
- var _a;
2738
- return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.setFieldIntrinsicErrorMessage(code, message);
2739
- }
2740
- setFieldOptions(code, optionsArray, idAttribute, nameAttribute) {
2741
- var _a;
2742
- return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.setFieldOptions(code, optionsArray, idAttribute, nameAttribute);
2743
- }
2744
- getFieldSet(filterFunc, codes, secCode, subCode) {
2745
- var _a;
2746
- return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.getFieldSet(filterFunc, codes !== null && codes !== void 0 ? codes : null, secCode !== null && secCode !== void 0 ? secCode : null, subCode !== null && subCode !== void 0 ? subCode : null);
2747
- }
2748
- applyOnFields(processFunc, codes, secCode, subCode) {
2749
- var _a;
2750
- return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.applyOnFields(processFunc, codes, secCode, subCode);
2751
- }
2752
- applyProcessToAllFields(processFunc) {
2753
- var _a;
2754
- return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.applyOnFields(processFunc);
2755
- }
2756
- cleanFields(codes, secCode, subCode) {
2757
- var _a;
2758
- return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.cleanFields(codes, secCode, subCode);
2759
- }
2760
- getRequiredFields(codes, secCode, subCode) {
2761
- var _a;
2762
- return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.getRequiredFields(codes, secCode, subCode);
2763
- }
2764
- getRequiredEmptyFields(codes, secCode, subCode, onlyVisible) {
2765
- var _a, _b;
2766
- return (_b = (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.getRequiredEmptyFields(codes, secCode, subCode, onlyVisible)) !== null && _b !== void 0 ? _b : null;
2767
- }
2768
- getChangedFields(codes, secCode, subCode) {
2769
- var _a;
2770
- return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.getChangedFields(codes, secCode, subCode);
2771
- }
2772
- getFieldsWithValidationIssues(codes, secCode, subCode, onlyVisible) {
2773
- var _a;
2774
- return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.getFieldsWithValidationIssues(codes, secCode, subCode, onlyVisible);
2775
- }
2776
- tagFieldsWithError(errorMessage, codes, secCode, subCode) {
2777
- var _a;
2778
- return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.tagFieldsWithError(errorMessage, codes, secCode, subCode);
2779
- }
2780
- cleanErrorFields(codes, secCode, subCode) {
2781
- var _a;
2782
- return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.cleanErrorFields(codes, secCode, subCode);
2783
- }
2784
- showLabelFields(codes, secCode, subCode) {
2785
- var _a;
2786
- return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.showLabelFields(codes, secCode, subCode);
2787
- }
2788
- hideLabelFields(codes, secCode, subCode) {
2789
- var _a;
2790
- return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.hideLabelFields(codes, secCode, subCode);
2791
- }
2792
- enableFields(codes, secCode, subCode) {
2793
- var _a;
2794
- return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.enableFields(codes, secCode, subCode);
2795
- }
2796
- disableFields(codes, secCode, subCode) {
2797
- var _a;
2798
- return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.disableFields(codes, secCode, subCode);
2799
- }
2800
- /**
2801
- * @deprecated Use enableFields
2802
- */
2803
- enableEditFields(codes, secCode, subCode) {
2804
- return this.enableFields(codes, secCode, subCode);
2805
- }
2806
- /**
2807
- * @deprecated Use disableFields
2808
- */
2809
- disableEditFields(codes, secCode, subCode) {
2810
- return this.disableFields(codes, secCode, subCode);
2811
- }
2812
- showFields(codes, secCode, subCode) {
2813
- var _a;
2814
- return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.showFields(codes, secCode, subCode);
2815
- }
2816
- hideFields(codes, secCode, subCode) {
2817
- var _a;
2818
- return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.hideFields(codes, secCode, subCode);
2819
- }
2820
- getActionsByAttribute(name, value) {
2821
- var _a;
2822
- return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.getActionsByAttribute(name, value);
2823
- }
2824
- getHeaderActions() {
2825
- var _a;
2826
- return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.getActionsByAttribute('location', HEADER$1);
2827
- }
2828
- getAction(actionCode) {
2829
- var _a, _b;
2830
- return (_b = (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.getAction(actionCode)) !== null && _b !== void 0 ? _b : null;
2831
- }
2832
- showActions(actionArray) {
2833
- var _a;
2834
- return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.showActions(actionArray);
2835
- }
2836
- hideActions(actionArray) {
2837
- var _a;
2838
- return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.hideActions(actionArray);
2839
- }
2840
- enableActions(actionArray) {
2841
- var _a;
2842
- return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.enableActions(actionArray);
2843
- }
2844
- disableActions(actionArray) {
2845
- var _a;
2846
- return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.disableActions(actionArray);
2847
- }
2848
- showAction(code) {
2849
- var _a;
2850
- return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.showActions(code);
2851
- }
2852
- hideAction(code) {
2853
- var _a;
2854
- return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.hideActions(code);
2855
- }
2856
- enableAction(code) {
2857
- var _a;
2858
- return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.enableActions(code);
2859
- }
2860
- disableAction(code) {
2861
- var _a;
2862
- return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.disableActions(code);
2863
- }
2864
- getSections() {
2865
- var _a, _b;
2866
- return (_b = (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.getSections()) !== null && _b !== void 0 ? _b : null;
2867
- }
2868
- activateSection(code) {
2869
- var _a;
2870
- return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.activateSection(code);
2871
- }
2872
- getSectionsTitles() {
2873
- var _a, _b;
2874
- return (_b = (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.getSections().map(sec => sec.title)) !== null && _b !== void 0 ? _b : null;
2875
- }
2876
- getSection(code) {
2877
- var _a, _b;
2878
- return (_b = (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.getSection(code)) !== null && _b !== void 0 ? _b : null;
2879
- }
2880
- showSection(code) {
2881
- var _a;
2882
- return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.showSections(code);
2883
- }
2884
- hideSection(code) {
2885
- var _a;
2886
- return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.hideSections(code);
2887
- }
2888
- showSections(codes) {
2889
- var _a;
2890
- return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.showSections(codes);
2891
- }
2892
- hideSections(codes) {
2893
- var _a;
2894
- return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.hideSections(codes);
2895
- }
2896
- getSubSection(code, subCode) {
2897
- var _a, _b;
2898
- return (_b = (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.getSubSection(code, subCode)) !== null && _b !== void 0 ? _b : null;
2899
- }
2900
- showSubSection(code, subCode) {
2901
- var _a;
2902
- return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.showSubSections(code, subCode);
2903
- }
2904
- hideSubSection(code, subCode) {
2905
- var _a;
2906
- return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.hideSubSections(code, subCode);
2907
- }
2908
- showSubSections(code, subCodes) {
2909
- var _a;
2910
- return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.showSubSections(code, subCodes);
2911
- }
2912
- hideSubSections(code, subCodes) {
2913
- var _a;
2914
- return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.hideSubSections(code, subCodes);
2915
- }
2916
- getSectionActions(code) {
2917
- var _a, _b;
2918
- return (_b = (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.getSectionActions(code)) !== null && _b !== void 0 ? _b : null;
2919
- }
2920
- getSectionActionNames(code) {
2921
- var _a, _b;
2922
- return (_b = (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.getSectionActionNames(code)) !== null && _b !== void 0 ? _b : null;
2923
- }
2924
- getTables() {
2925
- var _a;
2926
- return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.getTables();
2927
- }
2928
- showTables(codes) {
2929
- var _a;
2930
- return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.showTables(codes);
2931
- }
2932
- hideTables(codes) {
2933
- var _a;
2934
- return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.hideTables(codes);
2935
- }
2936
- cleanTables(codes) {
2937
- var _a;
2938
- return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.cleanTables(codes);
2939
- }
2940
- getTable(code) {
2941
- var _a, _b;
2942
- return (_b = (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.getTable(code)) !== null && _b !== void 0 ? _b : null;
2943
- }
2944
- showTable(code) {
2945
- var _a;
2946
- return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.showTables(code);
2947
- }
2948
- hideTable(code) {
2949
- var _a;
2950
- return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.hideTables(code);
2951
- }
2952
- cleanTable(code) {
2953
- var _a, _b;
2954
- return (_b = (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.getTable(code)) === null || _b === void 0 ? void 0 : _b.clean();
2955
- }
2956
- getTableRecord(code, recordId) {
2957
- var _a;
2958
- return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.getTableRecord(code, recordId);
2959
- }
2960
- setConfig(formConfig) {
2961
- this.formConfig = formConfig;
2962
- }
2963
2819
  cleanStart() {
2964
2820
  this._errorType = '';
2965
2821
  this.errorCode = '';
@@ -2967,10 +2823,7 @@ class BasicFormComponent {
2967
2823
  this.errorName = '';
2968
2824
  this.errorMessage = '';
2969
2825
  this.errorDetail = '';
2970
- this._formStructure = null;
2971
- this.fields = null;
2972
- this.actions = null;
2973
- this.sections = null;
2826
+ this.cleanForm();
2974
2827
  this._controlToken = null;
2975
2828
  this.inputDataFields = {};
2976
2829
  this._definitionObtained = false;
@@ -3001,19 +2854,6 @@ class BasicFormComponent {
3001
2854
  }
3002
2855
  get formVisible() { return this.visible; }
3003
2856
  get form() { return this; }
3004
- get formCode() { var _a; return (_a = this.name) !== null && _a !== void 0 ? _a : ''; }
3005
- set formCode(name) { this.name = name; }
3006
- get inServerProcess() { return this.busy; }
3007
- get formStructure() { return this._formStructure; }
3008
- get state() { var _a, _b; return (_b = (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.state) !== null && _b !== void 0 ? _b : null; }
3009
- get currentState() { var _a, _b; return (_b = (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.state) !== null && _b !== void 0 ? _b : ''; }
3010
- set currentState(state) { this === null || this === void 0 ? void 0 : this.changeState(state); }
3011
- get immutableData() { var _a; return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.immutableData; }
3012
- get extraInfo() { var _a; return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.extraInfo; }
3013
- get visibleSections() { var _a, _b; return (_b = (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.visibleSections) !== null && _b !== void 0 ? _b : null; }
3014
- get formRoute() { var _a; return (_a = this._formRoute) !== null && _a !== void 0 ? _a : ''; }
3015
- set formRoute(route) { this._formRoute = route; }
3016
- get subject() { var _a; return (_a = this.formSubject) !== null && _a !== void 0 ? _a : ''; }
3017
2857
  // Métodos virtuales
3018
2858
  customPreProcessing() { }
3019
2859
  start() { }
@@ -3024,43 +2864,6 @@ class BasicFormComponent {
3024
2864
  showFieldInfo(code, detail) { }
3025
2865
  showModalDialog(title, body, options, callback, params) { }
3026
2866
  openUploadDialog(title, body, options, callback, params) { }
3027
- /**
3028
- * @deprecated Use supportState
3029
- */
3030
- supportMode(state) { return this.supportState(state); }
3031
- /**
3032
- * @deprecated Use getField
3033
- */
3034
- getFieldObject(code) { return this.getField(code); }
3035
- /**
3036
- * @deprecated Use getAction
3037
- */
3038
- getActionObject(code) { return this.getAction(code); }
3039
- /**
3040
- * @deprecated Use getTable
3041
- */
3042
- getTableObject(code) { return this.getTable(code); }
3043
- /**
3044
- * @deprecated Use getSection
3045
- */
3046
- getSectionObject(code) { return this.getSection(code); }
3047
- /**
3048
- * @deprecated Use changeState
3049
- */
3050
- changeFormMode(state) { return this.changeState(state); }
3051
- /**
3052
- * @deprecated Use subject
3053
- */
3054
- getFormSubject() { return this.subject; }
3055
- /**
3056
- * @deprecated Use subject
3057
- */
3058
- getSubject() { var _a; return (_a = this.formSubject) !== null && _a !== void 0 ? _a : ''; }
3059
- /**
3060
- * @deprecated Use subject
3061
- */
3062
- getformSubject() { var _a; return (_a = this.formSubject) !== null && _a !== void 0 ? _a : ''; }
3063
- numSections() { var _a; return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.sections.length; }
3064
2867
  subscribeAppEvent(eventName, callback) {
3065
2868
  this._eventEmiter.subscribe(eventName, callback);
3066
2869
  }
@@ -3069,7 +2872,7 @@ class BasicFormComponent {
3069
2872
  let origin = null;
3070
2873
  if (!cleanStack) {
3071
2874
  origin = Object.assign(Object.assign({}, backData), { name: this.name, url: this._formRoute, token: this._controlToken });
3072
- origin.subject = (_a = origin === null || origin === void 0 ? void 0 : origin.subject) !== null && _a !== void 0 ? _a : this.formSubject;
2875
+ origin.subject = (_a = origin === null || origin === void 0 ? void 0 : origin.subject) !== null && _a !== void 0 ? _a : this.subject;
3073
2876
  origin.state = (_b = origin === null || origin === void 0 ? void 0 : origin.state) !== null && _b !== void 0 ? _b : this.state;
3074
2877
  origin.fields = (_c = origin === null || origin === void 0 ? void 0 : origin.fields) !== null && _c !== void 0 ? _c : {};
3075
2878
  origin.extra = (_d = origin === null || origin === void 0 ? void 0 : origin.extra) !== null && _d !== void 0 ? _d : {};
@@ -3110,11 +2913,11 @@ class BasicFormComponent {
3110
2913
  preocessInputParams(params) {
3111
2914
  var _a, _b, _c, _d;
3112
2915
  this._controlToken = (_a = params === null || params === void 0 ? void 0 : params[TOKEN]) !== null && _a !== void 0 ? _a : null;
3113
- this.formSubject = (_b = params === null || params === void 0 ? void 0 : params[SUBJECT]) !== null && _b !== void 0 ? _b : null;
2916
+ this.subject = (_b = params === null || params === void 0 ? void 0 : params[SUBJECT]) !== null && _b !== void 0 ? _b : null;
3114
2917
  const tokenInfo = (this._controlToken) ? this.formManagerService.getFormInfo(this._controlToken) : {};
3115
2918
  const { token, subject, state, fields, extra, originToken } = tokenInfo;
3116
2919
  if (token && this._controlToken === token) {
3117
- this.formSubject = (_d = (_c = this.formSubject) !== null && _c !== void 0 ? _c : subject) !== null && _d !== void 0 ? _d : null;
2920
+ this.subject = (_d = (_c = this.subject) !== null && _c !== void 0 ? _c : subject) !== null && _d !== void 0 ? _d : null;
3118
2921
  this.inputDataFields = fields;
3119
2922
  this.extraData = extra;
3120
2923
  this._originToken = originToken;
@@ -3123,8 +2926,7 @@ class BasicFormComponent {
3123
2926
  return null;
3124
2927
  }
3125
2928
  subscribeSectionActivation() {
3126
- var _a, _b;
3127
- const formSections = (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.sections;
2929
+ const formSections = this.sections;
3128
2930
  const sectionNames = Object.keys(formSections);
3129
2931
  for (let index = 0; index < sectionNames.length; index++) {
3130
2932
  const sectionName = sectionNames[index];
@@ -3132,15 +2934,13 @@ class BasicFormComponent {
3132
2934
  section.activation.subscribe((code) => this.launchSectionActivation(code));
3133
2935
  section.inactivation.subscribe((code) => this.launchSectionInactivation(code));
3134
2936
  // Adicionalmente se le pide a la sección se subscriba al cambio de estado del formulario
3135
- section.connectWithParentForm(this, (_b = this._formStructure) === null || _b === void 0 ? void 0 : _b.stateChange);
2937
+ section.connectWithParentForm(this, this.stateChange);
3136
2938
  }
3137
2939
  }
3138
2940
  subscribeFieldsSubjects() {
3139
- var _a;
3140
- const formFields = (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.getFields();
2941
+ const formFields = this.getFields();
3141
2942
  if (Array.isArray(formFields)) {
3142
2943
  formFields.forEach(field => {
3143
- var _a;
3144
2944
  field.editionFinish.subscribe(event => {
3145
2945
  const { code, intrinsicValidation } = event;
3146
2946
  this.startFieldValidation(code, intrinsicValidation);
@@ -3151,40 +2951,36 @@ class BasicFormComponent {
3151
2951
  });
3152
2952
  field.detailRequest.subscribe(event => this.showFieldInfo(event.code, event.detail));
3153
2953
  // Adicionalmente se le pide al campo se subscriba al cambio de estado del formulario
3154
- field.connectWithParentForm(this, (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.stateChange);
2954
+ field.connectWithParentForm(this, this.stateChange);
3155
2955
  });
3156
2956
  }
3157
2957
  }
3158
2958
  subscribeActionSubjects() {
3159
- var _a;
3160
- const formActions = (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.getActions();
2959
+ const formActions = this.getActions();
3161
2960
  if (Array.isArray(formActions)) {
3162
2961
  formActions.forEach(action => {
3163
- var _a;
3164
2962
  action.actionActivated.subscribe(code => this.startAction(code));
3165
2963
  // Adicionalmente se le pide a la acción se subscriba al cambio de estado del formulario
3166
- action.connectWithParentForm(this, (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.stateChange);
2964
+ action.connectWithParentForm(this, this.stateChange);
3167
2965
  });
3168
2966
  }
3169
2967
  }
3170
2968
  subscribeTableSubjects() {
3171
- var _a;
3172
- const formTables = (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.getTables();
2969
+ const formTables = this.getTables();
3173
2970
  if (Array.isArray(formTables)) {
3174
2971
  formTables.forEach(table => {
3175
- var _a;
3176
2972
  table.inlineActionTrigger.subscribe(event => this.startTableAction(event));
3177
2973
  table.globalActionTrigger.subscribe(event => this.startTableGlobalAction(event));
3178
2974
  table.recordSelectionTrigger.subscribe(event => this.startTableRecordSelection(event));
3179
2975
  table.selectionActionTrigger.subscribe(event => this.startTableSelectionAction(event));
3180
2976
  table.getDataTrigger.subscribe(event => this.startTableGetData(event));
3181
2977
  // Adicionalmente se le pide a la tabla se subscriba al cambio de estado del formulario
3182
- table.connectWithParentForm(this, (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.stateChange);
2978
+ table.connectWithParentForm(this, this.stateChange);
3183
2979
  });
3184
2980
  }
3185
2981
  }
3186
2982
  formInit(params, forceReload = false) {
3187
- var _a, _b, _c, _d, _e, _f, _g, _h;
2983
+ var _a, _b;
3188
2984
  return __awaiter(this, void 0, void 0, function* () {
3189
2985
  let initialState = this.preocessInputParams(params);
3190
2986
  if (!this.name) {
@@ -3194,23 +2990,14 @@ class BasicFormComponent {
3194
2990
  this.busy = true;
3195
2991
  const formDefinition = yield this.formManagerService.getFormDefinition(this.name);
3196
2992
  this.busy = false;
3197
- this._formStructure = new FormStructureAndData(formDefinition, this.formConfig);
3198
- this.fields = (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.fields;
3199
- this.actions = (_b = this._formStructure) === null || _b === void 0 ? void 0 : _b.actions;
3200
- this.sections = (_c = this._formStructure) === null || _c === void 0 ? void 0 : _c.sections;
3201
- this.fieldsArray = Object.keys(this.fields)
3202
- .reduce((accumulator, value) => accumulator.concat(this.fields[value]), []);
3203
- this.actionsArray = Object.keys(this.actions)
3204
- .reduce((accumulator, value) => accumulator.concat(this.actions[value]), []);
3205
- this.sectionsArray = Object.keys(this.sections)
3206
- .reduce((accumulator, value) => accumulator.concat(this.sections[value]), []);
2993
+ this.loadDefinition(formDefinition);
3207
2994
  this._definitionObtained = true;
3208
2995
  }
3209
2996
  else {
3210
2997
  this.cleanData();
3211
2998
  }
3212
- if (!this.supportState(initialState)) {
3213
- initialState = (_e = (_d = this._formStructure) === null || _d === void 0 ? void 0 : _d.defaultState) !== null && _e !== void 0 ? _e : null;
2999
+ if (!this.supportState(initialState !== null && initialState !== void 0 ? initialState : '')) {
3000
+ initialState = (_a = this.defaultState) !== null && _a !== void 0 ? _a : null;
3214
3001
  }
3215
3002
  const inputFieldNames = Object.keys(this.inputDataFields);
3216
3003
  for (let index = 0; index < inputFieldNames.length; index++) {
@@ -3223,18 +3010,18 @@ class BasicFormComponent {
3223
3010
  this.subscribeActionSubjects();
3224
3011
  this.subscribeTableSubjects();
3225
3012
  // Se define el estado inicial y se solicita la acción inicial
3226
- this.changeState(initialState || ((_f = this._formStructure) === null || _f === void 0 ? void 0 : _f.defaultState));
3013
+ this.changeState(initialState || this.defaultState);
3227
3014
  const recordResponse = yield this.requestFormAction(formActions.getData);
3228
3015
  this.checkErrorRecordReceived(recordResponse);
3229
3016
  this.visible = true;
3230
- this.enabledSections = (_h = (_g = this._formStructure) === null || _g === void 0 ? void 0 : _g.visibleSections) !== null && _h !== void 0 ? _h : [];
3017
+ this.enabledSections = (_b = this.visibleSections) !== null && _b !== void 0 ? _b : [];
3231
3018
  this.start();
3232
3019
  this.customFormStart();
3233
3020
  });
3234
3021
  }
3235
3022
  changeState(state) {
3236
- var _a, _b;
3237
- const stateChanged = (_b = (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.changeState(state !== null && state !== void 0 ? state : '')) !== null && _b !== void 0 ? _b : false;
3023
+ var _a;
3024
+ const stateChanged = (_a = super.changeState(state !== null && state !== void 0 ? state : '')) !== null && _a !== void 0 ? _a : false;
3238
3025
  if (stateChanged) {
3239
3026
  const clientActionMethods = this._formChangeState;
3240
3027
  if (clientActionMethods && clientActionMethods.length > 0) {
@@ -3264,17 +3051,16 @@ class BasicFormComponent {
3264
3051
  * Soporte manejo de eventos de formulario
3265
3052
  */
3266
3053
  requestFormAction(actionCode, actionSubject = {}) {
3267
- var _a, _b, _c;
3268
3054
  return __awaiter(this, void 0, void 0, function* () {
3269
3055
  const actionDetail = {
3270
3056
  formCode: this.name,
3271
- formSubject: this.formSubject,
3272
- currentMode: (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.state,
3057
+ formSubject: this.subject,
3058
+ currentMode: this.state,
3273
3059
  actionCode,
3274
3060
  actionSubject,
3275
3061
  version: PAYLOAD_VERSION,
3276
- formData: (_b = this._formStructure) === null || _b === void 0 ? void 0 : _b.getPayload(),
3277
- immutableData: (_c = this._formStructure) === null || _c === void 0 ? void 0 : _c.immutableData,
3062
+ formData: this.getPayload(),
3063
+ immutableData: this.immutableData,
3278
3064
  };
3279
3065
  this.errorCode = NO_ERROR;
3280
3066
  this.errorFullCode = '';
@@ -3301,7 +3087,7 @@ class BasicFormComponent {
3301
3087
  const { currentMode, formSubject, actions, fields, recordTables, returnedFile, immutableData, extraInfo, } = formContent;
3302
3088
  currentMode && this.changeState(currentMode);
3303
3089
  if (formSubject) {
3304
- this.formSubject = formSubject;
3090
+ this.subject = formSubject;
3305
3091
  }
3306
3092
  if (actions && actions.length > 0) {
3307
3093
  for (const changedAction of actions) {
@@ -3330,32 +3116,18 @@ class BasicFormComponent {
3330
3116
  if (returnedFile && returnedFile.file) {
3331
3117
  this.fileMgmtServices.saveFile(returnedFile.file, returnedFile.name, returnedFile.type);
3332
3118
  }
3333
- if (this._formStructure) {
3334
- this._formStructure.immutableData = immutableData;
3335
- this._formStructure.extraInfo = extraInfo;
3336
- }
3119
+ this.immutableData = immutableData;
3120
+ this.extraInfo = extraInfo;
3337
3121
  }
3338
3122
  /**
3339
3123
  * Manejo de event handlers para errores Server del formulario
3340
3124
  */
3341
- cleanActionServerError() {
3342
- this._actionServerError = [];
3343
- }
3344
- cleanFieldServerError() {
3345
- this._fieldServerError = [];
3346
- }
3347
- cleanTableServerError() {
3348
- this._tableServerError = [];
3349
- }
3350
- onActionServerError(callback, properties = null) {
3351
- this._actionServerError.push({ callback, properties });
3352
- }
3353
- onValidationServerError(callback, properties = null) {
3354
- this._fieldServerError.push({ callback, properties });
3355
- }
3356
- onTableServerError(callback, properties = null) {
3357
- this._tableServerError.push({ callback, properties });
3358
- }
3125
+ cleanActionServerError() { this._actionServerError = []; }
3126
+ cleanFieldServerError() { this._fieldServerError = []; }
3127
+ cleanTableServerError() { this._tableServerError = []; }
3128
+ onActionServerError(callback, properties = null) { this._actionServerError.push({ callback, properties }); }
3129
+ onValidationServerError(callback, properties = null) { this._fieldServerError.push({ callback, properties }); }
3130
+ onTableServerError(callback, properties = null) { this._tableServerError.push({ callback, properties }); }
3359
3131
  /**
3360
3132
  * Manejo de event handlers para acciones sobre el formulario
3361
3133
  */
@@ -3408,9 +3180,8 @@ class BasicFormComponent {
3408
3180
  });
3409
3181
  }
3410
3182
  verifySectionActivation(code) {
3411
- var _a;
3412
3183
  return __awaiter(this, void 0, void 0, function* () {
3413
- const sectionObject = (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.getSection(code);
3184
+ const sectionObject = this.getSection(code);
3414
3185
  if (!sectionObject) {
3415
3186
  return false;
3416
3187
  }
@@ -3428,10 +3199,9 @@ class BasicFormComponent {
3428
3199
  });
3429
3200
  }
3430
3201
  launchSectionActivation(code) {
3431
- var _a;
3432
3202
  return __awaiter(this, void 0, void 0, function* () {
3433
3203
  this.notifyFormActivity();
3434
- const sectionObject = (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.getSection(code);
3204
+ const sectionObject = this.getSection(code);
3435
3205
  if (!sectionObject) {
3436
3206
  return;
3437
3207
  }
@@ -3445,10 +3215,9 @@ class BasicFormComponent {
3445
3215
  });
3446
3216
  }
3447
3217
  launchSectionInactivation(code) {
3448
- var _a;
3449
3218
  return __awaiter(this, void 0, void 0, function* () {
3450
3219
  this.notifyFormActivity();
3451
- const sectionObject = (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.getSection(code);
3220
+ const sectionObject = this.getSection(code);
3452
3221
  if (!sectionObject) {
3453
3222
  return;
3454
3223
  }
@@ -3496,9 +3265,9 @@ class BasicFormComponent {
3496
3265
  let actionResult = null;
3497
3266
  if (action.backend) {
3498
3267
  actionResult = yield this.requestFormAction(action.actionCode);
3499
- serverError = !!this.errorOccured();
3500
3268
  }
3501
3269
  yield this.finishAction(action, actionResult, serverError);
3270
+ serverError = !!this.errorOccured();
3502
3271
  if (!serverError) {
3503
3272
  action.newState && this.changeState(action.newState);
3504
3273
  }
@@ -4241,8 +4010,36 @@ class BasicFormComponent {
4241
4010
  * Métodos Legacy de compatibilidad hacia atrás
4242
4011
  */
4243
4012
  /**
4244
- * @deprecated Use onSectionActivation
4245
- */
4013
+ * @deprecated Use name
4014
+ */
4015
+ get formCode() { var _a; return (_a = this.name) !== null && _a !== void 0 ? _a : ''; }
4016
+ /**
4017
+ * @deprecated Use name
4018
+ */
4019
+ set formCode(name) { this.name = name; }
4020
+ /**
4021
+ * @deprecated Use busy
4022
+ */
4023
+ get inServerProcess() { return this.busy; }
4024
+ /**
4025
+ * @deprecated Use state
4026
+ */
4027
+ get currentState() { var _a; return (_a = this.state) !== null && _a !== void 0 ? _a : ''; }
4028
+ /**
4029
+ * @deprecated Use changeState
4030
+ */
4031
+ set currentState(state) { this === null || this === void 0 ? void 0 : this.changeState(state); }
4032
+ /**
4033
+ * @deprecated Use onSectionActivation
4034
+ */
4035
+ get formRoute() { var _a; return (_a = this._formRoute) !== null && _a !== void 0 ? _a : ''; }
4036
+ /**
4037
+ * @deprecated Use onSectionActivation
4038
+ */
4039
+ set formRoute(route) { this._formRoute = route; }
4040
+ /**
4041
+ * @deprecated Use onSectionActivation
4042
+ */
4246
4043
  addSectionActivation(codes, callback, properties = null) {
4247
4044
  return this.onSectionActivation(codes, callback, properties);
4248
4045
  }
@@ -4320,7 +4117,7 @@ class BasicFormComponent {
4320
4117
  }
4321
4118
  }
4322
4119
  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 });
4323
- 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 });
4120
+ 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 });
4324
4121
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: BasicFormComponent, decorators: [{
4325
4122
  type: Component,
4326
4123
  args: [{