tuain-ng-forms-lib 13.0.12 → 13.0.13

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.
@@ -1638,6 +1638,8 @@ const DISABLE = 'disable';
1638
1638
  const CLEAN = 'clean';
1639
1639
  class FormStructureAndData {
1640
1640
  constructor(definitionReceived, formConfig) {
1641
+ this._name = '';
1642
+ this._title = '';
1641
1643
  this._fields = {};
1642
1644
  this._actions = {};
1643
1645
  this._tables = {};
@@ -1826,12 +1828,12 @@ class FormStructureAndData {
1826
1828
  }
1827
1829
  }
1828
1830
  getFieldSet(filter, inputCodes, secCode, subCode) {
1829
- let codes = null;
1831
+ let codes = [];
1830
1832
  if (typeof inputCodes === 'string' && inputCodes) {
1831
1833
  codes = [inputCodes];
1832
1834
  }
1833
1835
  else if (Array.isArray(inputCodes) && inputCodes.length > 0) {
1834
- codes = inputCodes;
1836
+ codes = inputCodes ?? [];
1835
1837
  }
1836
1838
  else if (secCode && !subCode) {
1837
1839
  codes = this.getSection(secCode)?.getFieldNames() ?? [];
@@ -1840,7 +1842,7 @@ class FormStructureAndData {
1840
1842
  codes = this.getSubSection(secCode, subCode)?.getFieldNames() ?? [];
1841
1843
  }
1842
1844
  else {
1843
- codes = this.getFieldNames();
1845
+ codes = this.getFieldNames() ?? [];
1844
1846
  }
1845
1847
  return (filter) ? codes.filter(fld => filter(this.getField(fld))) : codes;
1846
1848
  }
@@ -1848,7 +1850,7 @@ class FormStructureAndData {
1848
1850
  if (!processFunc) {
1849
1851
  return 0;
1850
1852
  }
1851
- const codes = this.getFieldSet(null, inputCodes, secCode, subCode);
1853
+ const codes = this.getFieldSet(null, inputCodes ?? null, secCode, subCode);
1852
1854
  let processedFields = 0;
1853
1855
  for (const code of codes) {
1854
1856
  const field = this.getField(code);
@@ -1895,19 +1897,19 @@ class FormStructureAndData {
1895
1897
  return this.tagFieldsWithError(message, this.getRequiredEmptyFields(codes, secCode, subCode)) > 0;
1896
1898
  }
1897
1899
  getRequiredFields(codes, secCode, subCode) {
1898
- return this.getFieldSet(fld => fld.required, codes, secCode, subCode);
1900
+ return this.getFieldSet(fld => fld.required, codes ?? null, secCode, subCode);
1899
1901
  }
1900
1902
  getRequiredEmptyFields(codes, secCode, subCode) {
1901
- return this.getFieldSet(fld => fld.required && fld.empty, codes, secCode, subCode);
1903
+ return this.getFieldSet(fld => fld.required && fld.empty, codes ?? null, secCode, subCode);
1902
1904
  }
1903
1905
  getChangedFields(codes, secCode, subCode) {
1904
- return this.getFieldSet(fld => !fld.outputOnly && fld.hasChanged(), codes, secCode, subCode);
1906
+ return this.getFieldSet(fld => !fld.outputOnly && fld.hasChanged(), codes ?? null, secCode, subCode);
1905
1907
  }
1906
1908
  getFieldsWithValidationIssues(codes, secCode, subCode) {
1907
- return this.getFieldSet(fld => fld.errorCode !== NO_ERROR, codes, secCode, subCode);
1909
+ return this.getFieldSet(fld => fld.errorCode !== NO_ERROR, codes ?? null, secCode, subCode);
1908
1910
  }
1909
1911
  getFieldsValues(inputCodes, secCode, subCode) {
1910
- const codes = this.getFieldSet(null, inputCodes, secCode, subCode);
1912
+ const codes = this.getFieldSet(null, inputCodes ?? null, secCode, subCode);
1911
1913
  const resultObject = {};
1912
1914
  for (let index = 0; index < codes.length; index++) {
1913
1915
  const code = codes[index];
@@ -2160,6 +2162,8 @@ class BasicFormComponent {
2160
2162
  this.fileMgmtServices = fileMgmtServices;
2161
2163
  this._formStructure = null;
2162
2164
  this._controlToken = null;
2165
+ this._originToken = null;
2166
+ this._formRoute = null;
2163
2167
  this._definitionObtained = false;
2164
2168
  // Eventos de acciones y campos
2165
2169
  this._formSectionsActivate = {};
@@ -2176,8 +2180,14 @@ class BasicFormComponent {
2176
2180
  this._tableActionsFinish = {};
2177
2181
  this._tableGetDataStart = {};
2178
2182
  this._tableGetDataFinish = {};
2183
+ this._actionServerError = [];
2184
+ this._fieldServerError = [];
2185
+ this._tableServerError = [];
2179
2186
  this.inputDataFields = {};
2180
2187
  this.extraData = {};
2188
+ this.enabledSections = [];
2189
+ this.name = null;
2190
+ this.formSubject = null;
2181
2191
  this._errorType = '';
2182
2192
  this.errorCode = '';
2183
2193
  this.errorMessage = '';
@@ -2192,20 +2202,20 @@ class BasicFormComponent {
2192
2202
  setTitle(title) { return this._formStructure?.setTitle(title); }
2193
2203
  cleanData() { return this._formStructure?.cleanData(); }
2194
2204
  getCurrentState() { return this._formStructure?.getCurrentState(); }
2195
- supportState(state) { return this._formStructure?.supportState(state); }
2196
- changeState(state) { return this._formStructure?.changeState(state); }
2205
+ supportState(state) { return this._formStructure?.supportState(state ?? '') ?? false; }
2206
+ changeState(state) { return this._formStructure?.changeState(state) ?? false; }
2197
2207
  getStates() { return this._formStructure?.states; }
2198
2208
  getImmutableElement(name) { return this._formStructure?.getImmutableElement(name); }
2199
2209
  getExtraInfo(name) { return this._formStructure?.getExtraInfo(name); }
2200
- getFields() { return this._formStructure?.getFields(); }
2201
- getFieldNames() { return this._formStructure?.getFieldNames(); }
2202
- getField(code) { return this._formStructure?.getField(code); }
2210
+ getFields() { return this._formStructure?.getFields() ?? null; }
2211
+ getFieldNames() { return this._formStructure?.getFieldNames() ?? null; }
2212
+ getField(code) { return this._formStructure?.getField(code) ?? null; }
2203
2213
  enableField(code) { return this._formStructure?.enableField(code); }
2204
2214
  disableField(code) { return this._formStructure?.disableField(code); }
2205
- getFieldValue(code) { return this._formStructure?.getFieldValue(code); }
2215
+ getFieldValue(code) { return this._formStructure?.getFieldValue(code) ?? null; }
2206
2216
  getFieldOptionText(code) { return this._formStructure?.getFieldOptionText(code); }
2207
- getFieldsValues(codes) { return this._formStructure?.getFieldsValues(codes); }
2208
- getFieldOptions(code) { return this._formStructure?.getFieldOptions(code); }
2217
+ getFieldsValues(codes) { return this._formStructure?.getFieldsValues(codes) ?? null; }
2218
+ getFieldOptions(code) { return this._formStructure?.getFieldOptions(code) ?? null; }
2209
2219
  setFieldValue(code, value) { return this._formStructure?.setFieldValue(code, value); }
2210
2220
  setFieldRequired(code, required) { return this._formStructure?.setFieldRequired(code, required); }
2211
2221
  setFieldErrorMessage(code, errorMessage) { return this._formStructure?.setFieldErrorMessage(code, errorMessage); }
@@ -2217,7 +2227,7 @@ class BasicFormComponent {
2217
2227
  return this._formStructure?.setFieldOptions(code, optionsArray, idAttribute, nameAttribute);
2218
2228
  }
2219
2229
  getFieldSet(filterFunc, codes, secCode, subCode) {
2220
- return this._formStructure?.getFieldSet(filterFunc, codes, secCode, subCode);
2230
+ return this._formStructure?.getFieldSet(filterFunc, codes ?? null, secCode ?? null, subCode ?? null);
2221
2231
  }
2222
2232
  applyOnFields(processFunc, codes, secCode, subCode) {
2223
2233
  return this._formStructure?.applyOnFields(processFunc, codes, secCode, subCode);
@@ -2232,7 +2242,7 @@ class BasicFormComponent {
2232
2242
  return this._formStructure?.getRequiredFields(codes, secCode, subCode);
2233
2243
  }
2234
2244
  getRequiredEmptyFields(codes, secCode, subCode) {
2235
- return this._formStructure?.getRequiredEmptyFields(codes, secCode, subCode);
2245
+ return this._formStructure?.getRequiredEmptyFields(codes, secCode, subCode) ?? null;
2236
2246
  }
2237
2247
  getChangedFields(codes, secCode, subCode) {
2238
2248
  return this._formStructure?.getChangedFields(codes, secCode, subCode);
@@ -2283,7 +2293,7 @@ class BasicFormComponent {
2283
2293
  return this._formStructure?.getActionsByAttribute('location', HEADER$1);
2284
2294
  }
2285
2295
  getAction(actionCode) {
2286
- return this._formStructure?.getAction(actionCode);
2296
+ return this._formStructure?.getAction(actionCode) ?? null;
2287
2297
  }
2288
2298
  showActions(actionArray) {
2289
2299
  return this._formStructure?.showActions(actionArray);
@@ -2310,16 +2320,16 @@ class BasicFormComponent {
2310
2320
  return this._formStructure?.disableActions(code);
2311
2321
  }
2312
2322
  getSections() {
2313
- return this._formStructure?.getSections();
2323
+ return this._formStructure?.getSections() ?? null;
2314
2324
  }
2315
2325
  activateSection(code) {
2316
2326
  return this._formStructure?.activateSection(code);
2317
2327
  }
2318
2328
  getSectionsTitles() {
2319
- return this._formStructure?.getSections().map(sec => sec.title);
2329
+ return this._formStructure?.getSections().map(sec => sec.title) ?? null;
2320
2330
  }
2321
2331
  getSection(code) {
2322
- return this._formStructure?.getSection(code);
2332
+ return this._formStructure?.getSection(code) ?? null;
2323
2333
  }
2324
2334
  showSection(code) {
2325
2335
  return this._formStructure?.showSections(code);
@@ -2334,7 +2344,7 @@ class BasicFormComponent {
2334
2344
  return this._formStructure?.hideSections(codes);
2335
2345
  }
2336
2346
  getSubSection(code, subCode) {
2337
- return this._formStructure?.getSubSection(code, subCode);
2347
+ return this._formStructure?.getSubSection(code, subCode) ?? null;
2338
2348
  }
2339
2349
  showSubSection(code, subCode) {
2340
2350
  return this._formStructure?.showSubSections(code, subCode);
@@ -2349,10 +2359,10 @@ class BasicFormComponent {
2349
2359
  return this._formStructure?.hideSubSections(code, subCodes);
2350
2360
  }
2351
2361
  getSectionActions(code) {
2352
- return this._formStructure?.getSectionActions(code);
2362
+ return this._formStructure?.getSectionActions(code) ?? null;
2353
2363
  }
2354
2364
  getSectionActionNames(code) {
2355
- return this._formStructure?.getSectionActionNames(code);
2365
+ return this._formStructure?.getSectionActionNames(code) ?? null;
2356
2366
  }
2357
2367
  getTables() {
2358
2368
  return this._formStructure?.getTables();
@@ -2367,7 +2377,7 @@ class BasicFormComponent {
2367
2377
  return this._formStructure?.cleanTables(codes);
2368
2378
  }
2369
2379
  getTable(code) {
2370
- return this._formStructure?.getTable(code);
2380
+ return this._formStructure?.getTable(code) ?? null;
2371
2381
  }
2372
2382
  showTable(code) {
2373
2383
  return this._formStructure?.showTables(code);
@@ -2412,22 +2422,28 @@ class BasicFormComponent {
2412
2422
  this._tableActionsFinish = {};
2413
2423
  this._tableGetDataStart = {};
2414
2424
  this._tableGetDataFinish = {};
2425
+ this._actionServerError = [];
2426
+ this._fieldServerError = [];
2427
+ this._tableServerError = [];
2428
+ this.onActionServerError(() => this.displayActionServerError());
2429
+ this.onValidationServerError(() => this.displayValidationServerError());
2430
+ this.onTableServerError(() => this.displayTableServerError());
2415
2431
  }
2416
2432
  get formVisible() { return this.visible; }
2417
2433
  get formManager() { return this; }
2418
- get formCode() { return this.name; }
2434
+ get formCode() { return this.name ?? ''; }
2419
2435
  set formCode(name) { this.name = name; }
2420
2436
  get inServerProcess() { return this.busy; }
2421
2437
  get form() { return this._formStructure; }
2422
- get state() { return this._formStructure?.state; }
2423
- get currentState() { return this._formStructure?.state; }
2424
- set currentState(state) { this._formStructure.changeState(state); }
2438
+ get state() { return this._formStructure?.state ?? null; }
2439
+ get currentState() { return this._formStructure?.state ?? ''; }
2440
+ set currentState(state) { this?._formStructure?.changeState(state); }
2425
2441
  get immutableData() { return this._formStructure?.immutableData; }
2426
2442
  get extraInfo() { return this._formStructure?.extraInfo; }
2427
- get visibleSections() { return this._formStructure?.visibleSections; }
2428
- get formRoute() { return this._formRoute; }
2443
+ get visibleSections() { return this._formStructure?.visibleSections ?? null; }
2444
+ get formRoute() { return this._formRoute ?? ''; }
2429
2445
  set formRoute(route) { this._formRoute = route; }
2430
- get subject() { return this.formSubject; }
2446
+ get subject() { return this.formSubject ?? ''; }
2431
2447
  // Métodos virtuales
2432
2448
  customPreProcessing() { }
2433
2449
  customFormStart() { }
@@ -2468,11 +2484,11 @@ class BasicFormComponent {
2468
2484
  /**
2469
2485
  * @deprecated Use subject
2470
2486
  */
2471
- getSubject() { return this.formSubject; }
2487
+ getSubject() { return this.formSubject ?? ''; }
2472
2488
  /**
2473
2489
  * @deprecated Use subject
2474
2490
  */
2475
- getformSubject() { return this.getSubject(); }
2491
+ getformSubject() { return this.formSubject ?? ''; }
2476
2492
  numSections() { return this._formStructure?.sections.length; }
2477
2493
  subscribeAppEvent(eventName, callback) {
2478
2494
  this._eventEmiter.subscribe(eventName, callback);
@@ -2496,7 +2512,7 @@ class BasicFormComponent {
2496
2512
  canGoBack() { return this._originToken !== null; }
2497
2513
  goBack() { return this.formManagerService.backTo(); }
2498
2514
  goBackForm() { return this.goBack(); }
2499
- getOriginDetail() { return this.formManagerService.getFormInfo(this._originToken); }
2515
+ getOriginDetail() { return this.formManagerService?.getFormInfo(this._originToken ?? ''); }
2500
2516
  setError(errorType, errorMessage, errorDetail) {
2501
2517
  this._errorType = errorType || '';
2502
2518
  this.errorMessage = errorMessage || '';
@@ -2525,7 +2541,7 @@ class BasicFormComponent {
2525
2541
  return null;
2526
2542
  }
2527
2543
  subscribeSectionActivation() {
2528
- const formSections = this._formStructure.sections;
2544
+ const formSections = this._formStructure?.sections;
2529
2545
  const sectionNames = Object.keys(formSections);
2530
2546
  for (let index = 0; index < sectionNames.length; index++) {
2531
2547
  const sectionName = sectionNames[index];
@@ -2535,7 +2551,7 @@ class BasicFormComponent {
2535
2551
  }
2536
2552
  }
2537
2553
  subscribeFieldsSubjects() {
2538
- const formFields = this._formStructure.getFields();
2554
+ const formFields = this._formStructure?.getFields();
2539
2555
  if (Array.isArray(formFields)) {
2540
2556
  formFields.forEach(field => {
2541
2557
  field.editionFinish.subscribe(event => {
@@ -2551,7 +2567,7 @@ class BasicFormComponent {
2551
2567
  }
2552
2568
  }
2553
2569
  subscribeActionSubjects() {
2554
- const formActions = this._formStructure.getActions();
2570
+ const formActions = this._formStructure?.getActions();
2555
2571
  if (Array.isArray(formActions)) {
2556
2572
  formActions.forEach(action => {
2557
2573
  action.actionActivated.subscribe(code => this.startAction(code));
@@ -2559,7 +2575,7 @@ class BasicFormComponent {
2559
2575
  }
2560
2576
  }
2561
2577
  subscribeTableSubjects() {
2562
- const formTables = this._formStructure.getTables();
2578
+ const formTables = this._formStructure?.getTables();
2563
2579
  if (Array.isArray(formTables)) {
2564
2580
  formTables.forEach(table => {
2565
2581
  table.inlineActionTrigger.subscribe(event => this.startTableAction(event));
@@ -2580,18 +2596,18 @@ class BasicFormComponent {
2580
2596
  const formDefinition = await this.formManagerService.getFormDefinition(this.name);
2581
2597
  this.busy = false;
2582
2598
  this._formStructure = new FormStructureAndData(formDefinition, this.formConfig);
2583
- this.fields = this._formStructure.fields;
2584
- this.actions = this._formStructure.actions;
2585
- this.sections = this._formStructure.sections;
2599
+ this.fields = this._formStructure?.fields;
2600
+ this.actions = this._formStructure?.actions;
2601
+ this.sections = this._formStructure?.sections;
2586
2602
  this._definitionObtained = true;
2587
2603
  }
2588
2604
  else {
2589
2605
  this.cleanData();
2590
2606
  }
2591
2607
  if (!this.supportState(initialState)) {
2592
- initialState = this._formStructure.defaultState;
2608
+ initialState = this._formStructure?.defaultState ?? null;
2593
2609
  }
2594
- this._formStructure.changeState(initialState || this._formStructure.defaultState);
2610
+ this._formStructure?.changeState(initialState || this._formStructure?.defaultState);
2595
2611
  const inputFieldNames = Object.keys(this.inputDataFields);
2596
2612
  for (let index = 0; index < inputFieldNames.length; index++) {
2597
2613
  const fieldCode = inputFieldNames[index];
@@ -2601,7 +2617,7 @@ class BasicFormComponent {
2601
2617
  const recordResponse = await this.requestFormAction(formActions.getData);
2602
2618
  this.checkErrorRecordReceived(recordResponse);
2603
2619
  this.visible = true;
2604
- this.enabledSections = this._formStructure?.visibleSections;
2620
+ this.enabledSections = this._formStructure?.visibleSections ?? [];
2605
2621
  this.subscribeSectionActivation();
2606
2622
  this.subscribeFieldsSubjects();
2607
2623
  this.subscribeActionSubjects();
@@ -2628,12 +2644,12 @@ class BasicFormComponent {
2628
2644
  const actionDetail = {
2629
2645
  formCode: this.name,
2630
2646
  formSubject: this.formSubject,
2631
- currentMode: this._formStructure.state,
2647
+ currentMode: this._formStructure?.state,
2632
2648
  actionCode,
2633
2649
  actionSubject,
2634
2650
  version: PAYLOAD_VERSION,
2635
- formData: this._formStructure.getPayload(),
2636
- immutableData: this._formStructure.immutableData,
2651
+ formData: this._formStructure?.getPayload(),
2652
+ immutableData: this._formStructure?.immutableData,
2637
2653
  };
2638
2654
  this.errorCode = NO_ERROR;
2639
2655
  this.errorMessage = '';
@@ -2687,13 +2703,36 @@ class BasicFormComponent {
2687
2703
  if (returnedFile && returnedFile.file) {
2688
2704
  this.fileMgmtServices.saveFile(returnedFile.file, returnedFile.name, returnedFile.type);
2689
2705
  }
2690
- this._formStructure.immutableData = immutableData;
2691
- this._formStructure.extraInfo = extraInfo;
2706
+ if (this._formStructure) {
2707
+ this._formStructure.immutableData = immutableData;
2708
+ this._formStructure.extraInfo = extraInfo;
2709
+ }
2710
+ }
2711
+ /**
2712
+ * Manejo de event handlers para errores Server del formulario
2713
+ */
2714
+ cleanActionServerError() {
2715
+ this._actionServerError = [];
2716
+ }
2717
+ cleanFieldServerError() {
2718
+ this._fieldServerError = [];
2719
+ }
2720
+ cleanTableServerError() {
2721
+ this._tableServerError = [];
2722
+ }
2723
+ onActionServerError(callback, properties = null) {
2724
+ this._actionServerError.push({ callback, properties });
2725
+ }
2726
+ onValidationServerError(callback, properties = null) {
2727
+ this._fieldServerError.push({ callback, properties });
2728
+ }
2729
+ onTableServerError(callback, properties = null) {
2730
+ this._tableServerError.push({ callback, properties });
2692
2731
  }
2693
2732
  /**
2694
2733
  * Manejo de event handlers para acciones sobre el formulario
2695
2734
  */
2696
- addSectionActivation(codes, callback, properties = null) {
2735
+ onSectionActivation(codes, callback, properties = null) {
2697
2736
  const sectionSet = (Array.isArray(codes)) ? codes : (codes ? [codes] : []);
2698
2737
  sectionSet.forEach((sectionName) => {
2699
2738
  if (!this._formSectionsActivate[sectionName]) {
@@ -2702,7 +2741,7 @@ class BasicFormComponent {
2702
2741
  this._formSectionsActivate[sectionName].push({ callback, properties });
2703
2742
  });
2704
2743
  }
2705
- addSectionInactivation(codes, callback, properties = null) {
2744
+ onSectionInactivation(codes, callback, properties = null) {
2706
2745
  const sectionSet = (Array.isArray(codes)) ? codes : (codes ? [codes] : []);
2707
2746
  sectionSet.forEach((sectionName) => {
2708
2747
  if (!this._formSectionsInactivate[sectionName]) {
@@ -2711,7 +2750,7 @@ class BasicFormComponent {
2711
2750
  this._formSectionsInactivate[sectionName].push({ callback, properties });
2712
2751
  });
2713
2752
  }
2714
- addActionMethodStart(codes, callback, properties = null) {
2753
+ onActionStart(codes, callback, properties = null) {
2715
2754
  const actionSet = (Array.isArray(codes)) ? codes : (codes ? [codes] : []);
2716
2755
  actionSet.forEach((actionName) => {
2717
2756
  if (!this._formActionsStart[actionName]) {
@@ -2720,7 +2759,7 @@ class BasicFormComponent {
2720
2759
  this._formActionsStart[actionName].push({ callback, properties });
2721
2760
  });
2722
2761
  }
2723
- addActionMethodFinish(codes, callback, properties = null) {
2762
+ onActionFinish(codes, callback, properties = null) {
2724
2763
  const actionSet = (Array.isArray(codes)) ? codes : (codes ? [codes] : []);
2725
2764
  actionSet.forEach((actionName) => {
2726
2765
  if (!this._formActionsFinish[actionName]) {
@@ -2730,7 +2769,7 @@ class BasicFormComponent {
2730
2769
  });
2731
2770
  }
2732
2771
  async launchSectionActivation(code) {
2733
- const sectionObject = this._formStructure.getSection(code);
2772
+ const sectionObject = this._formStructure?.getSection(code);
2734
2773
  if (!sectionObject) {
2735
2774
  return;
2736
2775
  }
@@ -2743,7 +2782,7 @@ class BasicFormComponent {
2743
2782
  }
2744
2783
  }
2745
2784
  async launchSectionInactivation(code) {
2746
- const sectionObject = this._formStructure.getSection(code);
2785
+ const sectionObject = this._formStructure?.getSection(code);
2747
2786
  if (!sectionObject) {
2748
2787
  return;
2749
2788
  }
@@ -2793,7 +2832,10 @@ class BasicFormComponent {
2793
2832
  action.newState && this.changeState(action.newState);
2794
2833
  }
2795
2834
  else {
2796
- this.displayActionServerError();
2835
+ for (let index = 0; index < this._actionServerError.length; index++) {
2836
+ const { callback, properties } = this._actionServerError[index];
2837
+ callback(action);
2838
+ }
2797
2839
  }
2798
2840
  action.stop();
2799
2841
  }
@@ -2817,7 +2859,7 @@ class BasicFormComponent {
2817
2859
  /**
2818
2860
  * Manejadores de eventos para validaciones sobre campos
2819
2861
  */
2820
- addFieldInputValidation(codes, callback, properties = null) {
2862
+ onFieldInput(codes, callback, properties = null) {
2821
2863
  const fieldSet = (Array.isArray(codes)) ? codes : (codes ? [codes] : []);
2822
2864
  fieldSet.forEach((fieldCode) => {
2823
2865
  if (!this._fieldInputValidation[fieldCode]) {
@@ -2826,7 +2868,7 @@ class BasicFormComponent {
2826
2868
  this._fieldInputValidation[fieldCode].push({ callback, properties });
2827
2869
  });
2828
2870
  }
2829
- addFieldValidationStart(codes, callback, properties = null) {
2871
+ onFieldValidationStart(codes, callback, properties = null) {
2830
2872
  const fieldSet = (Array.isArray(codes)) ? codes : (codes ? [codes] : []);
2831
2873
  fieldSet.forEach((fieldCode) => {
2832
2874
  if (!this._fieldValidationsStart[fieldCode]) {
@@ -2835,7 +2877,7 @@ class BasicFormComponent {
2835
2877
  this._fieldValidationsStart[fieldCode].push({ callback, properties });
2836
2878
  });
2837
2879
  }
2838
- addFieldValidationFinish(codes, callback, properties = null) {
2880
+ onFieldValidationFinish(codes, callback, properties = null) {
2839
2881
  const fieldSet = (Array.isArray(codes)) ? codes : (codes ? [codes] : []);
2840
2882
  fieldSet.forEach((fieldCode) => {
2841
2883
  if (!this._fieldValidationsFinish[fieldCode]) {
@@ -2891,6 +2933,9 @@ class BasicFormComponent {
2891
2933
  ? this.getField(inputField) : inputField;
2892
2934
  let serverError = false;
2893
2935
  let validationResult = true;
2936
+ if (!fieldObj) {
2937
+ return;
2938
+ }
2894
2939
  if (fieldObj.backend) {
2895
2940
  fieldObj.validating = true;
2896
2941
  validationResult = await this
@@ -2899,9 +2944,12 @@ class BasicFormComponent {
2899
2944
  }
2900
2945
  await this.finishFieldValidation(fieldObj, validationResult, serverError);
2901
2946
  if (serverError) {
2902
- fieldObj.setErrorCode(this.errorCode);
2903
- fieldObj.setErrorMessage(this.errorMessage);
2904
- this.displayValidationServerError();
2947
+ fieldObj?.setErrorCode(this.errorCode);
2948
+ fieldObj?.setErrorMessage(this.errorMessage);
2949
+ for (let index = 0; index < this._fieldServerError.length; index++) {
2950
+ const { callback, properties } = this._fieldServerError[index];
2951
+ callback(fieldObj);
2952
+ }
2905
2953
  }
2906
2954
  fieldObj.validating = false;
2907
2955
  }
@@ -2925,7 +2973,7 @@ class BasicFormComponent {
2925
2973
  /**
2926
2974
  * Manejadores de eventos para acciones sobre Tablas
2927
2975
  */
2928
- addTableActionStart(code, actionCode, callback, properties = null) {
2976
+ onTableActionStart(code, actionCode, callback, properties = null) {
2929
2977
  const tableObject = this.getTable(code);
2930
2978
  if (!tableObject) {
2931
2979
  return;
@@ -2947,7 +2995,7 @@ class BasicFormComponent {
2947
2995
  }
2948
2996
  tableEventHandlers[actionCode].push({ callback, properties });
2949
2997
  }
2950
- addTableActionFinish(code, actionCode, callback, properties = null) {
2998
+ onTableActionFinish(code, actionCode, callback, properties = null) {
2951
2999
  const tableObject = this.getTable(code);
2952
3000
  if (!tableObject) {
2953
3001
  return;
@@ -2969,7 +3017,7 @@ class BasicFormComponent {
2969
3017
  }
2970
3018
  tableEventHandlers[actionCode].push({ callback, properties });
2971
3019
  }
2972
- addTableSelectionStart(code, callback, properties = null) {
3020
+ onTableSelectionStart(code, callback, properties = null) {
2973
3021
  const tableObject = this.getTable(code);
2974
3022
  if (!tableObject) {
2975
3023
  return;
@@ -2984,7 +3032,7 @@ class BasicFormComponent {
2984
3032
  }
2985
3033
  tableEventHandlers.push({ callback, properties });
2986
3034
  }
2987
- addTableSelectionFinish(code, callback, properties = null) {
3035
+ onTableSelectionFinish(code, callback, properties = null) {
2988
3036
  const tableObject = this.getTable(code);
2989
3037
  if (!tableObject) {
2990
3038
  return;
@@ -2999,7 +3047,7 @@ class BasicFormComponent {
2999
3047
  }
3000
3048
  tableEventHandlers.push({ callback, properties });
3001
3049
  }
3002
- addTableGetDataStart(code, callback, properties = null) {
3050
+ onTableGetDataStart(code, callback, properties = null) {
3003
3051
  const tableObject = this.getTable(code);
3004
3052
  if (!tableObject) {
3005
3053
  return;
@@ -3014,7 +3062,7 @@ class BasicFormComponent {
3014
3062
  }
3015
3063
  tableEventHandlers.push({ callback, properties });
3016
3064
  }
3017
- addTableGetDataFinish(code, callback, properties = null) {
3065
+ onTableGetDataFinish(code, callback, properties = null) {
3018
3066
  const tableObject = this.getTable(code);
3019
3067
  if (!tableObject) {
3020
3068
  return;
@@ -3086,7 +3134,10 @@ class BasicFormComponent {
3086
3134
  action.newState && this.changeState(action.newState);
3087
3135
  }
3088
3136
  else {
3089
- this.displayTableServerError();
3137
+ for (let index = 0; index < this._tableServerError.length; index++) {
3138
+ const { callback, properties } = this._tableServerError[index];
3139
+ callback(tableObject);
3140
+ }
3090
3141
  }
3091
3142
  tableObject.freeWaiting();
3092
3143
  }
@@ -3410,8 +3461,8 @@ class BasicFormComponent {
3410
3461
  return false;
3411
3462
  }
3412
3463
  let validationError = false;
3413
- const requiredEmptyFields = this.getRequiredEmptyFields(null, sectionCode);
3414
- if (requiredEmptyFields.length > 0) {
3464
+ const requiredEmptyFields = this.getRequiredEmptyFields(null, sectionCode) ?? [];
3465
+ if (requiredEmptyFields?.length > 0) {
3415
3466
  validationError = true;
3416
3467
  this.setError(this.formConfig.formStandardErrors.typeWarning, this.formConfig.formStandardErrors.validationTitle, this.formConfig.formStandardErrors.requiredFields);
3417
3468
  this.tagFieldsWithError(this.formConfig.formStandardErrors.requiredField, requiredEmptyFields);
@@ -3421,13 +3472,15 @@ class BasicFormComponent {
3421
3472
  break;
3422
3473
  }
3423
3474
  }
3424
- const validationIssueFields = this.getFieldsWithValidationIssues(null, sectionCode);
3475
+ const validationIssueFields = this.getFieldsWithValidationIssues(null, sectionCode) ?? [];
3425
3476
  if (!validationError && validationIssueFields.length > 0) {
3426
3477
  validationError = true;
3427
3478
  this.setError(this.formConfig.formStandardErrors.typeWarning, this.formConfig.formStandardErrors.validationTitle, this.formConfig.formStandardErrors.validationFields);
3428
3479
  for (const fieldCode of validationIssueFields) {
3429
3480
  const validationIssueField = this.getField(fieldCode);
3430
- validationIssueField.focus();
3481
+ if (validationIssueField) {
3482
+ validationIssueField.focus();
3483
+ }
3431
3484
  break;
3432
3485
  }
3433
3486
  }
@@ -3435,14 +3488,59 @@ class BasicFormComponent {
3435
3488
  }
3436
3489
  copyTableRecordToFields(tableObj, mappingTable = null) {
3437
3490
  const tableObject = this.getTable(tableObj.tableCode);
3438
- const tableRecord = tableObject.getTableRecord(tableObj.recordId);
3439
- const columnNames = tableObject.columnNames;
3440
- for (const columnName of columnNames) {
3441
- const columnValue = tableRecord.getFieldValue(columnName) ?? '';
3442
- const fieldCode = mappingTable?.[columnName] ?? columnName;
3443
- this.setFieldValue(fieldCode, columnValue);
3491
+ const tableRecord = tableObject?.getTableRecord(tableObj.recordId);
3492
+ const columnNames = tableObject?.columnNames;
3493
+ if (tableRecord && columnNames) {
3494
+ for (const columnName of columnNames) {
3495
+ const columnValue = tableRecord.getFieldValue(columnName) ?? '';
3496
+ const fieldCode = mappingTable?.[columnName] ?? columnName;
3497
+ this.setFieldValue(fieldCode, columnValue);
3498
+ }
3499
+ return true;
3444
3500
  }
3445
- return true;
3501
+ return false;
3502
+ }
3503
+ /**
3504
+ * Métodos Legacy de compatibilidad hacia atrás
3505
+ */
3506
+ addSectionActivation(codes, callback, properties = null) {
3507
+ return this.onSectionActivation(codes, callback, properties);
3508
+ }
3509
+ addSectionInactivation(codes, callback, properties = null) {
3510
+ return this.onSectionInactivation(codes, callback, properties);
3511
+ }
3512
+ addActionMethodStart(codes, callback, properties = null) {
3513
+ return this.onActionStart(codes, callback, properties);
3514
+ }
3515
+ addActionMethodFinish(codes, callback, properties = null) {
3516
+ return this.onActionFinish(codes, callback, properties);
3517
+ }
3518
+ addFieldInputValidation(codes, callback, properties = null) {
3519
+ return this.onFieldInput(codes, callback, properties);
3520
+ }
3521
+ addFieldValidationStart(codes, callback, properties = null) {
3522
+ return this.onFieldValidationStart(codes, callback, properties);
3523
+ }
3524
+ addFieldValidationFinish(codes, callback, properties = null) {
3525
+ return this.onFieldValidationFinish(codes, callback, properties);
3526
+ }
3527
+ addTableActionStart(code, actionCode, callback, properties = null) {
3528
+ return this.onTableActionStart(code, actionCode, callback, properties);
3529
+ }
3530
+ addTableActionFinish(code, actionCode, callback, properties = null) {
3531
+ return this.onTableActionFinish(code, actionCode, callback, properties);
3532
+ }
3533
+ addTableSelectionStart(code, callback, properties = null) {
3534
+ return this.onTableSelectionStart(code, callback, properties);
3535
+ }
3536
+ addTableSelectionFinish(code, callback, properties = null) {
3537
+ return this.onTableSelectionFinish(code, callback, properties);
3538
+ }
3539
+ addTableGetDataStart(code, callback, properties = null) {
3540
+ return this.onTableGetDataStart(code, callback, properties);
3541
+ }
3542
+ addTableGetDataFinish(code, callback, properties = null) {
3543
+ return this.onTableGetDataFinish(code, callback, properties);
3446
3544
  }
3447
3545
  }
3448
3546
  BasicFormComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.1", ngImport: i0, type: BasicFormComponent, deps: [{ token: LibFormManagerService }, { token: LibEventManagerService }, { token: LibFileManagementService }], target: i0.ɵɵFactoryTarget.Component });