tuain-ng-forms-lib 13.0.12 → 13.0.14

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,10 +2180,18 @@ 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 = '';
2193
+ this.errorFullCode = '';
2194
+ this.errorName = '';
2183
2195
  this.errorMessage = '';
2184
2196
  this.errorDetail = '';
2185
2197
  this.visible = false;
@@ -2192,20 +2204,20 @@ class BasicFormComponent {
2192
2204
  setTitle(title) { return this._formStructure?.setTitle(title); }
2193
2205
  cleanData() { return this._formStructure?.cleanData(); }
2194
2206
  getCurrentState() { return this._formStructure?.getCurrentState(); }
2195
- supportState(state) { return this._formStructure?.supportState(state); }
2196
- changeState(state) { return this._formStructure?.changeState(state); }
2207
+ supportState(state) { return this._formStructure?.supportState(state ?? '') ?? false; }
2208
+ changeState(state) { return this._formStructure?.changeState(state) ?? false; }
2197
2209
  getStates() { return this._formStructure?.states; }
2198
2210
  getImmutableElement(name) { return this._formStructure?.getImmutableElement(name); }
2199
2211
  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); }
2212
+ getFields() { return this._formStructure?.getFields() ?? null; }
2213
+ getFieldNames() { return this._formStructure?.getFieldNames() ?? null; }
2214
+ getField(code) { return this._formStructure?.getField(code) ?? null; }
2203
2215
  enableField(code) { return this._formStructure?.enableField(code); }
2204
2216
  disableField(code) { return this._formStructure?.disableField(code); }
2205
- getFieldValue(code) { return this._formStructure?.getFieldValue(code); }
2217
+ getFieldValue(code) { return this._formStructure?.getFieldValue(code) ?? null; }
2206
2218
  getFieldOptionText(code) { return this._formStructure?.getFieldOptionText(code); }
2207
- getFieldsValues(codes) { return this._formStructure?.getFieldsValues(codes); }
2208
- getFieldOptions(code) { return this._formStructure?.getFieldOptions(code); }
2219
+ getFieldsValues(codes) { return this._formStructure?.getFieldsValues(codes) ?? null; }
2220
+ getFieldOptions(code) { return this._formStructure?.getFieldOptions(code) ?? null; }
2209
2221
  setFieldValue(code, value) { return this._formStructure?.setFieldValue(code, value); }
2210
2222
  setFieldRequired(code, required) { return this._formStructure?.setFieldRequired(code, required); }
2211
2223
  setFieldErrorMessage(code, errorMessage) { return this._formStructure?.setFieldErrorMessage(code, errorMessage); }
@@ -2217,7 +2229,7 @@ class BasicFormComponent {
2217
2229
  return this._formStructure?.setFieldOptions(code, optionsArray, idAttribute, nameAttribute);
2218
2230
  }
2219
2231
  getFieldSet(filterFunc, codes, secCode, subCode) {
2220
- return this._formStructure?.getFieldSet(filterFunc, codes, secCode, subCode);
2232
+ return this._formStructure?.getFieldSet(filterFunc, codes ?? null, secCode ?? null, subCode ?? null);
2221
2233
  }
2222
2234
  applyOnFields(processFunc, codes, secCode, subCode) {
2223
2235
  return this._formStructure?.applyOnFields(processFunc, codes, secCode, subCode);
@@ -2232,7 +2244,7 @@ class BasicFormComponent {
2232
2244
  return this._formStructure?.getRequiredFields(codes, secCode, subCode);
2233
2245
  }
2234
2246
  getRequiredEmptyFields(codes, secCode, subCode) {
2235
- return this._formStructure?.getRequiredEmptyFields(codes, secCode, subCode);
2247
+ return this._formStructure?.getRequiredEmptyFields(codes, secCode, subCode) ?? null;
2236
2248
  }
2237
2249
  getChangedFields(codes, secCode, subCode) {
2238
2250
  return this._formStructure?.getChangedFields(codes, secCode, subCode);
@@ -2283,7 +2295,7 @@ class BasicFormComponent {
2283
2295
  return this._formStructure?.getActionsByAttribute('location', HEADER$1);
2284
2296
  }
2285
2297
  getAction(actionCode) {
2286
- return this._formStructure?.getAction(actionCode);
2298
+ return this._formStructure?.getAction(actionCode) ?? null;
2287
2299
  }
2288
2300
  showActions(actionArray) {
2289
2301
  return this._formStructure?.showActions(actionArray);
@@ -2310,16 +2322,16 @@ class BasicFormComponent {
2310
2322
  return this._formStructure?.disableActions(code);
2311
2323
  }
2312
2324
  getSections() {
2313
- return this._formStructure?.getSections();
2325
+ return this._formStructure?.getSections() ?? null;
2314
2326
  }
2315
2327
  activateSection(code) {
2316
2328
  return this._formStructure?.activateSection(code);
2317
2329
  }
2318
2330
  getSectionsTitles() {
2319
- return this._formStructure?.getSections().map(sec => sec.title);
2331
+ return this._formStructure?.getSections().map(sec => sec.title) ?? null;
2320
2332
  }
2321
2333
  getSection(code) {
2322
- return this._formStructure?.getSection(code);
2334
+ return this._formStructure?.getSection(code) ?? null;
2323
2335
  }
2324
2336
  showSection(code) {
2325
2337
  return this._formStructure?.showSections(code);
@@ -2334,7 +2346,7 @@ class BasicFormComponent {
2334
2346
  return this._formStructure?.hideSections(codes);
2335
2347
  }
2336
2348
  getSubSection(code, subCode) {
2337
- return this._formStructure?.getSubSection(code, subCode);
2349
+ return this._formStructure?.getSubSection(code, subCode) ?? null;
2338
2350
  }
2339
2351
  showSubSection(code, subCode) {
2340
2352
  return this._formStructure?.showSubSections(code, subCode);
@@ -2349,10 +2361,10 @@ class BasicFormComponent {
2349
2361
  return this._formStructure?.hideSubSections(code, subCodes);
2350
2362
  }
2351
2363
  getSectionActions(code) {
2352
- return this._formStructure?.getSectionActions(code);
2364
+ return this._formStructure?.getSectionActions(code) ?? null;
2353
2365
  }
2354
2366
  getSectionActionNames(code) {
2355
- return this._formStructure?.getSectionActionNames(code);
2367
+ return this._formStructure?.getSectionActionNames(code) ?? null;
2356
2368
  }
2357
2369
  getTables() {
2358
2370
  return this._formStructure?.getTables();
@@ -2367,7 +2379,7 @@ class BasicFormComponent {
2367
2379
  return this._formStructure?.cleanTables(codes);
2368
2380
  }
2369
2381
  getTable(code) {
2370
- return this._formStructure?.getTable(code);
2382
+ return this._formStructure?.getTable(code) ?? null;
2371
2383
  }
2372
2384
  showTable(code) {
2373
2385
  return this._formStructure?.showTables(code);
@@ -2387,6 +2399,8 @@ class BasicFormComponent {
2387
2399
  cleanStart() {
2388
2400
  this._errorType = '';
2389
2401
  this.errorCode = '';
2402
+ this.errorFullCode = '';
2403
+ this.errorName = '';
2390
2404
  this.errorMessage = '';
2391
2405
  this.errorDetail = '';
2392
2406
  this._formStructure = null;
@@ -2412,22 +2426,28 @@ class BasicFormComponent {
2412
2426
  this._tableActionsFinish = {};
2413
2427
  this._tableGetDataStart = {};
2414
2428
  this._tableGetDataFinish = {};
2429
+ this._actionServerError = [];
2430
+ this._fieldServerError = [];
2431
+ this._tableServerError = [];
2432
+ this.onActionServerError(() => this.displayActionServerError());
2433
+ this.onValidationServerError(() => this.displayValidationServerError());
2434
+ this.onTableServerError(() => this.displayTableServerError());
2415
2435
  }
2416
2436
  get formVisible() { return this.visible; }
2417
2437
  get formManager() { return this; }
2418
- get formCode() { return this.name; }
2438
+ get formCode() { return this.name ?? ''; }
2419
2439
  set formCode(name) { this.name = name; }
2420
2440
  get inServerProcess() { return this.busy; }
2421
2441
  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); }
2442
+ get state() { return this._formStructure?.state ?? null; }
2443
+ get currentState() { return this._formStructure?.state ?? ''; }
2444
+ set currentState(state) { this?._formStructure?.changeState(state); }
2425
2445
  get immutableData() { return this._formStructure?.immutableData; }
2426
2446
  get extraInfo() { return this._formStructure?.extraInfo; }
2427
- get visibleSections() { return this._formStructure?.visibleSections; }
2428
- get formRoute() { return this._formRoute; }
2447
+ get visibleSections() { return this._formStructure?.visibleSections ?? null; }
2448
+ get formRoute() { return this._formRoute ?? ''; }
2429
2449
  set formRoute(route) { this._formRoute = route; }
2430
- get subject() { return this.formSubject; }
2450
+ get subject() { return this.formSubject ?? ''; }
2431
2451
  // Métodos virtuales
2432
2452
  customPreProcessing() { }
2433
2453
  customFormStart() { }
@@ -2468,11 +2488,11 @@ class BasicFormComponent {
2468
2488
  /**
2469
2489
  * @deprecated Use subject
2470
2490
  */
2471
- getSubject() { return this.formSubject; }
2491
+ getSubject() { return this.formSubject ?? ''; }
2472
2492
  /**
2473
2493
  * @deprecated Use subject
2474
2494
  */
2475
- getformSubject() { return this.getSubject(); }
2495
+ getformSubject() { return this.formSubject ?? ''; }
2476
2496
  numSections() { return this._formStructure?.sections.length; }
2477
2497
  subscribeAppEvent(eventName, callback) {
2478
2498
  this._eventEmiter.subscribe(eventName, callback);
@@ -2496,7 +2516,7 @@ class BasicFormComponent {
2496
2516
  canGoBack() { return this._originToken !== null; }
2497
2517
  goBack() { return this.formManagerService.backTo(); }
2498
2518
  goBackForm() { return this.goBack(); }
2499
- getOriginDetail() { return this.formManagerService.getFormInfo(this._originToken); }
2519
+ getOriginDetail() { return this.formManagerService?.getFormInfo(this._originToken ?? ''); }
2500
2520
  setError(errorType, errorMessage, errorDetail) {
2501
2521
  this._errorType = errorType || '';
2502
2522
  this.errorMessage = errorMessage || '';
@@ -2506,6 +2526,8 @@ class BasicFormComponent {
2506
2526
  getErrorType() { return this._errorType; }
2507
2527
  getErrorMessage() { return this.errorMessage; }
2508
2528
  getErrorDetail() { return this.errorDetail; }
2529
+ getErrorName() { return this.errorName; }
2530
+ getErrorFullCode() { return this.errorFullCode; }
2509
2531
  getErrorCode() { return this._errorType; }
2510
2532
  getFormParameter(name) {
2511
2533
  return (name) ? (this.extraData?.[name] ?? null) : null;
@@ -2525,7 +2547,7 @@ class BasicFormComponent {
2525
2547
  return null;
2526
2548
  }
2527
2549
  subscribeSectionActivation() {
2528
- const formSections = this._formStructure.sections;
2550
+ const formSections = this._formStructure?.sections;
2529
2551
  const sectionNames = Object.keys(formSections);
2530
2552
  for (let index = 0; index < sectionNames.length; index++) {
2531
2553
  const sectionName = sectionNames[index];
@@ -2535,7 +2557,7 @@ class BasicFormComponent {
2535
2557
  }
2536
2558
  }
2537
2559
  subscribeFieldsSubjects() {
2538
- const formFields = this._formStructure.getFields();
2560
+ const formFields = this._formStructure?.getFields();
2539
2561
  if (Array.isArray(formFields)) {
2540
2562
  formFields.forEach(field => {
2541
2563
  field.editionFinish.subscribe(event => {
@@ -2551,7 +2573,7 @@ class BasicFormComponent {
2551
2573
  }
2552
2574
  }
2553
2575
  subscribeActionSubjects() {
2554
- const formActions = this._formStructure.getActions();
2576
+ const formActions = this._formStructure?.getActions();
2555
2577
  if (Array.isArray(formActions)) {
2556
2578
  formActions.forEach(action => {
2557
2579
  action.actionActivated.subscribe(code => this.startAction(code));
@@ -2559,7 +2581,7 @@ class BasicFormComponent {
2559
2581
  }
2560
2582
  }
2561
2583
  subscribeTableSubjects() {
2562
- const formTables = this._formStructure.getTables();
2584
+ const formTables = this._formStructure?.getTables();
2563
2585
  if (Array.isArray(formTables)) {
2564
2586
  formTables.forEach(table => {
2565
2587
  table.inlineActionTrigger.subscribe(event => this.startTableAction(event));
@@ -2580,18 +2602,18 @@ class BasicFormComponent {
2580
2602
  const formDefinition = await this.formManagerService.getFormDefinition(this.name);
2581
2603
  this.busy = false;
2582
2604
  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;
2605
+ this.fields = this._formStructure?.fields;
2606
+ this.actions = this._formStructure?.actions;
2607
+ this.sections = this._formStructure?.sections;
2586
2608
  this._definitionObtained = true;
2587
2609
  }
2588
2610
  else {
2589
2611
  this.cleanData();
2590
2612
  }
2591
2613
  if (!this.supportState(initialState)) {
2592
- initialState = this._formStructure.defaultState;
2614
+ initialState = this._formStructure?.defaultState ?? null;
2593
2615
  }
2594
- this._formStructure.changeState(initialState || this._formStructure.defaultState);
2616
+ this._formStructure?.changeState(initialState || this._formStructure?.defaultState);
2595
2617
  const inputFieldNames = Object.keys(this.inputDataFields);
2596
2618
  for (let index = 0; index < inputFieldNames.length; index++) {
2597
2619
  const fieldCode = inputFieldNames[index];
@@ -2601,7 +2623,7 @@ class BasicFormComponent {
2601
2623
  const recordResponse = await this.requestFormAction(formActions.getData);
2602
2624
  this.checkErrorRecordReceived(recordResponse);
2603
2625
  this.visible = true;
2604
- this.enabledSections = this._formStructure?.visibleSections;
2626
+ this.enabledSections = this._formStructure?.visibleSections ?? [];
2605
2627
  this.subscribeSectionActivation();
2606
2628
  this.subscribeFieldsSubjects();
2607
2629
  this.subscribeActionSubjects();
@@ -2614,6 +2636,8 @@ class BasicFormComponent {
2614
2636
  return false;
2615
2637
  }
2616
2638
  this.errorCode = recordResponse.errorCode;
2639
+ this.errorFullCode = recordResponse.errorFullCode;
2640
+ this.errorName = recordResponse.errorName;
2617
2641
  this.errorMessage = recordResponse.errorMessage;
2618
2642
  this.errorDetail = recordResponse.errorDetail;
2619
2643
  return true;
@@ -2628,14 +2652,16 @@ class BasicFormComponent {
2628
2652
  const actionDetail = {
2629
2653
  formCode: this.name,
2630
2654
  formSubject: this.formSubject,
2631
- currentMode: this._formStructure.state,
2655
+ currentMode: this._formStructure?.state,
2632
2656
  actionCode,
2633
2657
  actionSubject,
2634
2658
  version: PAYLOAD_VERSION,
2635
- formData: this._formStructure.getPayload(),
2636
- immutableData: this._formStructure.immutableData,
2659
+ formData: this._formStructure?.getPayload(),
2660
+ immutableData: this._formStructure?.immutableData,
2637
2661
  };
2638
2662
  this.errorCode = NO_ERROR;
2663
+ this.errorFullCode = '';
2664
+ this.errorName = '';
2639
2665
  this.errorMessage = '';
2640
2666
  this.errorDetail = '';
2641
2667
  this.busy = true;
@@ -2647,6 +2673,8 @@ class BasicFormComponent {
2647
2673
  if (formActionResponse.hasError()) {
2648
2674
  const error = formActionResponse.error;
2649
2675
  this.errorCode = error.errorCode;
2676
+ this.errorFullCode = error.errorFullCode;
2677
+ this.errorName = error.errorName;
2650
2678
  this.errorMessage = error.errorMessage;
2651
2679
  this.errorDetail = error.errorDetail;
2652
2680
  }
@@ -2687,13 +2715,36 @@ class BasicFormComponent {
2687
2715
  if (returnedFile && returnedFile.file) {
2688
2716
  this.fileMgmtServices.saveFile(returnedFile.file, returnedFile.name, returnedFile.type);
2689
2717
  }
2690
- this._formStructure.immutableData = immutableData;
2691
- this._formStructure.extraInfo = extraInfo;
2718
+ if (this._formStructure) {
2719
+ this._formStructure.immutableData = immutableData;
2720
+ this._formStructure.extraInfo = extraInfo;
2721
+ }
2722
+ }
2723
+ /**
2724
+ * Manejo de event handlers para errores Server del formulario
2725
+ */
2726
+ cleanActionServerError() {
2727
+ this._actionServerError = [];
2728
+ }
2729
+ cleanFieldServerError() {
2730
+ this._fieldServerError = [];
2731
+ }
2732
+ cleanTableServerError() {
2733
+ this._tableServerError = [];
2734
+ }
2735
+ onActionServerError(callback, properties = null) {
2736
+ this._actionServerError.push({ callback, properties });
2737
+ }
2738
+ onValidationServerError(callback, properties = null) {
2739
+ this._fieldServerError.push({ callback, properties });
2740
+ }
2741
+ onTableServerError(callback, properties = null) {
2742
+ this._tableServerError.push({ callback, properties });
2692
2743
  }
2693
2744
  /**
2694
2745
  * Manejo de event handlers para acciones sobre el formulario
2695
2746
  */
2696
- addSectionActivation(codes, callback, properties = null) {
2747
+ onSectionActivation(codes, callback, properties = null) {
2697
2748
  const sectionSet = (Array.isArray(codes)) ? codes : (codes ? [codes] : []);
2698
2749
  sectionSet.forEach((sectionName) => {
2699
2750
  if (!this._formSectionsActivate[sectionName]) {
@@ -2702,7 +2753,7 @@ class BasicFormComponent {
2702
2753
  this._formSectionsActivate[sectionName].push({ callback, properties });
2703
2754
  });
2704
2755
  }
2705
- addSectionInactivation(codes, callback, properties = null) {
2756
+ onSectionInactivation(codes, callback, properties = null) {
2706
2757
  const sectionSet = (Array.isArray(codes)) ? codes : (codes ? [codes] : []);
2707
2758
  sectionSet.forEach((sectionName) => {
2708
2759
  if (!this._formSectionsInactivate[sectionName]) {
@@ -2711,7 +2762,7 @@ class BasicFormComponent {
2711
2762
  this._formSectionsInactivate[sectionName].push({ callback, properties });
2712
2763
  });
2713
2764
  }
2714
- addActionMethodStart(codes, callback, properties = null) {
2765
+ onActionStart(codes, callback, properties = null) {
2715
2766
  const actionSet = (Array.isArray(codes)) ? codes : (codes ? [codes] : []);
2716
2767
  actionSet.forEach((actionName) => {
2717
2768
  if (!this._formActionsStart[actionName]) {
@@ -2720,7 +2771,7 @@ class BasicFormComponent {
2720
2771
  this._formActionsStart[actionName].push({ callback, properties });
2721
2772
  });
2722
2773
  }
2723
- addActionMethodFinish(codes, callback, properties = null) {
2774
+ onActionFinish(codes, callback, properties = null) {
2724
2775
  const actionSet = (Array.isArray(codes)) ? codes : (codes ? [codes] : []);
2725
2776
  actionSet.forEach((actionName) => {
2726
2777
  if (!this._formActionsFinish[actionName]) {
@@ -2730,7 +2781,7 @@ class BasicFormComponent {
2730
2781
  });
2731
2782
  }
2732
2783
  async launchSectionActivation(code) {
2733
- const sectionObject = this._formStructure.getSection(code);
2784
+ const sectionObject = this._formStructure?.getSection(code);
2734
2785
  if (!sectionObject) {
2735
2786
  return;
2736
2787
  }
@@ -2743,7 +2794,7 @@ class BasicFormComponent {
2743
2794
  }
2744
2795
  }
2745
2796
  async launchSectionInactivation(code) {
2746
- const sectionObject = this._formStructure.getSection(code);
2797
+ const sectionObject = this._formStructure?.getSection(code);
2747
2798
  if (!sectionObject) {
2748
2799
  return;
2749
2800
  }
@@ -2793,7 +2844,10 @@ class BasicFormComponent {
2793
2844
  action.newState && this.changeState(action.newState);
2794
2845
  }
2795
2846
  else {
2796
- this.displayActionServerError();
2847
+ for (let index = 0; index < this._actionServerError.length; index++) {
2848
+ const { callback, properties } = this._actionServerError[index];
2849
+ callback(action);
2850
+ }
2797
2851
  }
2798
2852
  action.stop();
2799
2853
  }
@@ -2817,7 +2871,7 @@ class BasicFormComponent {
2817
2871
  /**
2818
2872
  * Manejadores de eventos para validaciones sobre campos
2819
2873
  */
2820
- addFieldInputValidation(codes, callback, properties = null) {
2874
+ onFieldInput(codes, callback, properties = null) {
2821
2875
  const fieldSet = (Array.isArray(codes)) ? codes : (codes ? [codes] : []);
2822
2876
  fieldSet.forEach((fieldCode) => {
2823
2877
  if (!this._fieldInputValidation[fieldCode]) {
@@ -2826,7 +2880,7 @@ class BasicFormComponent {
2826
2880
  this._fieldInputValidation[fieldCode].push({ callback, properties });
2827
2881
  });
2828
2882
  }
2829
- addFieldValidationStart(codes, callback, properties = null) {
2883
+ onFieldValidationStart(codes, callback, properties = null) {
2830
2884
  const fieldSet = (Array.isArray(codes)) ? codes : (codes ? [codes] : []);
2831
2885
  fieldSet.forEach((fieldCode) => {
2832
2886
  if (!this._fieldValidationsStart[fieldCode]) {
@@ -2835,7 +2889,7 @@ class BasicFormComponent {
2835
2889
  this._fieldValidationsStart[fieldCode].push({ callback, properties });
2836
2890
  });
2837
2891
  }
2838
- addFieldValidationFinish(codes, callback, properties = null) {
2892
+ onFieldValidationFinish(codes, callback, properties = null) {
2839
2893
  const fieldSet = (Array.isArray(codes)) ? codes : (codes ? [codes] : []);
2840
2894
  fieldSet.forEach((fieldCode) => {
2841
2895
  if (!this._fieldValidationsFinish[fieldCode]) {
@@ -2891,6 +2945,9 @@ class BasicFormComponent {
2891
2945
  ? this.getField(inputField) : inputField;
2892
2946
  let serverError = false;
2893
2947
  let validationResult = true;
2948
+ if (!fieldObj) {
2949
+ return;
2950
+ }
2894
2951
  if (fieldObj.backend) {
2895
2952
  fieldObj.validating = true;
2896
2953
  validationResult = await this
@@ -2899,9 +2956,12 @@ class BasicFormComponent {
2899
2956
  }
2900
2957
  await this.finishFieldValidation(fieldObj, validationResult, serverError);
2901
2958
  if (serverError) {
2902
- fieldObj.setErrorCode(this.errorCode);
2903
- fieldObj.setErrorMessage(this.errorMessage);
2904
- this.displayValidationServerError();
2959
+ fieldObj?.setErrorCode(this.errorCode);
2960
+ fieldObj?.setErrorMessage(this.errorMessage);
2961
+ for (let index = 0; index < this._fieldServerError.length; index++) {
2962
+ const { callback, properties } = this._fieldServerError[index];
2963
+ callback(fieldObj);
2964
+ }
2905
2965
  }
2906
2966
  fieldObj.validating = false;
2907
2967
  }
@@ -2925,7 +2985,7 @@ class BasicFormComponent {
2925
2985
  /**
2926
2986
  * Manejadores de eventos para acciones sobre Tablas
2927
2987
  */
2928
- addTableActionStart(code, actionCode, callback, properties = null) {
2988
+ onTableActionStart(code, actionCode, callback, properties = null) {
2929
2989
  const tableObject = this.getTable(code);
2930
2990
  if (!tableObject) {
2931
2991
  return;
@@ -2947,7 +3007,7 @@ class BasicFormComponent {
2947
3007
  }
2948
3008
  tableEventHandlers[actionCode].push({ callback, properties });
2949
3009
  }
2950
- addTableActionFinish(code, actionCode, callback, properties = null) {
3010
+ onTableActionFinish(code, actionCode, callback, properties = null) {
2951
3011
  const tableObject = this.getTable(code);
2952
3012
  if (!tableObject) {
2953
3013
  return;
@@ -2969,7 +3029,7 @@ class BasicFormComponent {
2969
3029
  }
2970
3030
  tableEventHandlers[actionCode].push({ callback, properties });
2971
3031
  }
2972
- addTableSelectionStart(code, callback, properties = null) {
3032
+ onTableSelectionStart(code, callback, properties = null) {
2973
3033
  const tableObject = this.getTable(code);
2974
3034
  if (!tableObject) {
2975
3035
  return;
@@ -2984,7 +3044,7 @@ class BasicFormComponent {
2984
3044
  }
2985
3045
  tableEventHandlers.push({ callback, properties });
2986
3046
  }
2987
- addTableSelectionFinish(code, callback, properties = null) {
3047
+ onTableSelectionFinish(code, callback, properties = null) {
2988
3048
  const tableObject = this.getTable(code);
2989
3049
  if (!tableObject) {
2990
3050
  return;
@@ -2999,7 +3059,7 @@ class BasicFormComponent {
2999
3059
  }
3000
3060
  tableEventHandlers.push({ callback, properties });
3001
3061
  }
3002
- addTableGetDataStart(code, callback, properties = null) {
3062
+ onTableGetDataStart(code, callback, properties = null) {
3003
3063
  const tableObject = this.getTable(code);
3004
3064
  if (!tableObject) {
3005
3065
  return;
@@ -3014,7 +3074,7 @@ class BasicFormComponent {
3014
3074
  }
3015
3075
  tableEventHandlers.push({ callback, properties });
3016
3076
  }
3017
- addTableGetDataFinish(code, callback, properties = null) {
3077
+ onTableGetDataFinish(code, callback, properties = null) {
3018
3078
  const tableObject = this.getTable(code);
3019
3079
  if (!tableObject) {
3020
3080
  return;
@@ -3086,7 +3146,10 @@ class BasicFormComponent {
3086
3146
  action.newState && this.changeState(action.newState);
3087
3147
  }
3088
3148
  else {
3089
- this.displayTableServerError();
3149
+ for (let index = 0; index < this._tableServerError.length; index++) {
3150
+ const { callback, properties } = this._tableServerError[index];
3151
+ callback(tableObject);
3152
+ }
3090
3153
  }
3091
3154
  tableObject.freeWaiting();
3092
3155
  }
@@ -3410,8 +3473,8 @@ class BasicFormComponent {
3410
3473
  return false;
3411
3474
  }
3412
3475
  let validationError = false;
3413
- const requiredEmptyFields = this.getRequiredEmptyFields(null, sectionCode);
3414
- if (requiredEmptyFields.length > 0) {
3476
+ const requiredEmptyFields = this.getRequiredEmptyFields(null, sectionCode) ?? [];
3477
+ if (requiredEmptyFields?.length > 0) {
3415
3478
  validationError = true;
3416
3479
  this.setError(this.formConfig.formStandardErrors.typeWarning, this.formConfig.formStandardErrors.validationTitle, this.formConfig.formStandardErrors.requiredFields);
3417
3480
  this.tagFieldsWithError(this.formConfig.formStandardErrors.requiredField, requiredEmptyFields);
@@ -3421,13 +3484,15 @@ class BasicFormComponent {
3421
3484
  break;
3422
3485
  }
3423
3486
  }
3424
- const validationIssueFields = this.getFieldsWithValidationIssues(null, sectionCode);
3487
+ const validationIssueFields = this.getFieldsWithValidationIssues(null, sectionCode) ?? [];
3425
3488
  if (!validationError && validationIssueFields.length > 0) {
3426
3489
  validationError = true;
3427
3490
  this.setError(this.formConfig.formStandardErrors.typeWarning, this.formConfig.formStandardErrors.validationTitle, this.formConfig.formStandardErrors.validationFields);
3428
3491
  for (const fieldCode of validationIssueFields) {
3429
3492
  const validationIssueField = this.getField(fieldCode);
3430
- validationIssueField.focus();
3493
+ if (validationIssueField) {
3494
+ validationIssueField.focus();
3495
+ }
3431
3496
  break;
3432
3497
  }
3433
3498
  }
@@ -3435,14 +3500,59 @@ class BasicFormComponent {
3435
3500
  }
3436
3501
  copyTableRecordToFields(tableObj, mappingTable = null) {
3437
3502
  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);
3503
+ const tableRecord = tableObject?.getTableRecord(tableObj.recordId);
3504
+ const columnNames = tableObject?.columnNames;
3505
+ if (tableRecord && columnNames) {
3506
+ for (const columnName of columnNames) {
3507
+ const columnValue = tableRecord.getFieldValue(columnName) ?? '';
3508
+ const fieldCode = mappingTable?.[columnName] ?? columnName;
3509
+ this.setFieldValue(fieldCode, columnValue);
3510
+ }
3511
+ return true;
3444
3512
  }
3445
- return true;
3513
+ return false;
3514
+ }
3515
+ /**
3516
+ * Métodos Legacy de compatibilidad hacia atrás
3517
+ */
3518
+ addSectionActivation(codes, callback, properties = null) {
3519
+ return this.onSectionActivation(codes, callback, properties);
3520
+ }
3521
+ addSectionInactivation(codes, callback, properties = null) {
3522
+ return this.onSectionInactivation(codes, callback, properties);
3523
+ }
3524
+ addActionMethodStart(codes, callback, properties = null) {
3525
+ return this.onActionStart(codes, callback, properties);
3526
+ }
3527
+ addActionMethodFinish(codes, callback, properties = null) {
3528
+ return this.onActionFinish(codes, callback, properties);
3529
+ }
3530
+ addFieldInputValidation(codes, callback, properties = null) {
3531
+ return this.onFieldInput(codes, callback, properties);
3532
+ }
3533
+ addFieldValidationStart(codes, callback, properties = null) {
3534
+ return this.onFieldValidationStart(codes, callback, properties);
3535
+ }
3536
+ addFieldValidationFinish(codes, callback, properties = null) {
3537
+ return this.onFieldValidationFinish(codes, callback, properties);
3538
+ }
3539
+ addTableActionStart(code, actionCode, callback, properties = null) {
3540
+ return this.onTableActionStart(code, actionCode, callback, properties);
3541
+ }
3542
+ addTableActionFinish(code, actionCode, callback, properties = null) {
3543
+ return this.onTableActionFinish(code, actionCode, callback, properties);
3544
+ }
3545
+ addTableSelectionStart(code, callback, properties = null) {
3546
+ return this.onTableSelectionStart(code, callback, properties);
3547
+ }
3548
+ addTableSelectionFinish(code, callback, properties = null) {
3549
+ return this.onTableSelectionFinish(code, callback, properties);
3550
+ }
3551
+ addTableGetDataStart(code, callback, properties = null) {
3552
+ return this.onTableGetDataStart(code, callback, properties);
3553
+ }
3554
+ addTableGetDataFinish(code, callback, properties = null) {
3555
+ return this.onTableGetDataFinish(code, callback, properties);
3446
3556
  }
3447
3557
  }
3448
3558
  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 });