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