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.
@@ -1670,6 +1670,8 @@ const DISABLE = 'disable';
1670
1670
  const CLEAN = 'clean';
1671
1671
  class FormStructureAndData {
1672
1672
  constructor(definitionReceived, formConfig) {
1673
+ this._name = '';
1674
+ this._title = '';
1673
1675
  this._fields = {};
1674
1676
  this._actions = {};
1675
1677
  this._tables = {};
@@ -1858,13 +1860,13 @@ class FormStructureAndData {
1858
1860
  }
1859
1861
  }
1860
1862
  getFieldSet(filter, inputCodes, secCode, subCode) {
1861
- var _a, _b, _c, _d;
1862
- let codes = null;
1863
+ var _a, _b, _c, _d, _e;
1864
+ let codes = [];
1863
1865
  if (typeof inputCodes === 'string' && inputCodes) {
1864
1866
  codes = [inputCodes];
1865
1867
  }
1866
1868
  else if (Array.isArray(inputCodes) && inputCodes.length > 0) {
1867
- codes = inputCodes;
1869
+ codes = inputCodes !== null && inputCodes !== void 0 ? inputCodes : [];
1868
1870
  }
1869
1871
  else if (secCode && !subCode) {
1870
1872
  codes = (_b = (_a = this.getSection(secCode)) === null || _a === void 0 ? void 0 : _a.getFieldNames()) !== null && _b !== void 0 ? _b : [];
@@ -1873,7 +1875,7 @@ class FormStructureAndData {
1873
1875
  codes = (_d = (_c = this.getSubSection(secCode, subCode)) === null || _c === void 0 ? void 0 : _c.getFieldNames()) !== null && _d !== void 0 ? _d : [];
1874
1876
  }
1875
1877
  else {
1876
- codes = this.getFieldNames();
1878
+ codes = (_e = this.getFieldNames()) !== null && _e !== void 0 ? _e : [];
1877
1879
  }
1878
1880
  return (filter) ? codes.filter(fld => filter(this.getField(fld))) : codes;
1879
1881
  }
@@ -1881,7 +1883,7 @@ class FormStructureAndData {
1881
1883
  if (!processFunc) {
1882
1884
  return 0;
1883
1885
  }
1884
- const codes = this.getFieldSet(null, inputCodes, secCode, subCode);
1886
+ const codes = this.getFieldSet(null, inputCodes !== null && inputCodes !== void 0 ? inputCodes : null, secCode, subCode);
1885
1887
  let processedFields = 0;
1886
1888
  for (const code of codes) {
1887
1889
  const field = this.getField(code);
@@ -1928,20 +1930,20 @@ class FormStructureAndData {
1928
1930
  return this.tagFieldsWithError(message, this.getRequiredEmptyFields(codes, secCode, subCode)) > 0;
1929
1931
  }
1930
1932
  getRequiredFields(codes, secCode, subCode) {
1931
- return this.getFieldSet(fld => fld.required, codes, secCode, subCode);
1933
+ return this.getFieldSet(fld => fld.required, codes !== null && codes !== void 0 ? codes : null, secCode, subCode);
1932
1934
  }
1933
1935
  getRequiredEmptyFields(codes, secCode, subCode) {
1934
- return this.getFieldSet(fld => fld.required && fld.empty, codes, secCode, subCode);
1936
+ return this.getFieldSet(fld => fld.required && fld.empty, codes !== null && codes !== void 0 ? codes : null, secCode, subCode);
1935
1937
  }
1936
1938
  getChangedFields(codes, secCode, subCode) {
1937
- return this.getFieldSet(fld => !fld.outputOnly && fld.hasChanged(), codes, secCode, subCode);
1939
+ return this.getFieldSet(fld => !fld.outputOnly && fld.hasChanged(), codes !== null && codes !== void 0 ? codes : null, secCode, subCode);
1938
1940
  }
1939
1941
  getFieldsWithValidationIssues(codes, secCode, subCode) {
1940
- return this.getFieldSet(fld => fld.errorCode !== NO_ERROR, codes, secCode, subCode);
1942
+ return this.getFieldSet(fld => fld.errorCode !== NO_ERROR, codes !== null && codes !== void 0 ? codes : null, secCode, subCode);
1941
1943
  }
1942
1944
  getFieldsValues(inputCodes, secCode, subCode) {
1943
1945
  var _a, _b, _c;
1944
- const codes = this.getFieldSet(null, inputCodes, secCode, subCode);
1946
+ const codes = this.getFieldSet(null, inputCodes !== null && inputCodes !== void 0 ? inputCodes : null, secCode, subCode);
1945
1947
  const resultObject = {};
1946
1948
  for (let index = 0; index < codes.length; index++) {
1947
1949
  const code = codes[index];
@@ -2202,6 +2204,8 @@ class BasicFormComponent {
2202
2204
  this.fileMgmtServices = fileMgmtServices;
2203
2205
  this._formStructure = null;
2204
2206
  this._controlToken = null;
2207
+ this._originToken = null;
2208
+ this._formRoute = null;
2205
2209
  this._definitionObtained = false;
2206
2210
  // Eventos de acciones y campos
2207
2211
  this._formSectionsActivate = {};
@@ -2218,8 +2222,14 @@ class BasicFormComponent {
2218
2222
  this._tableActionsFinish = {};
2219
2223
  this._tableGetDataStart = {};
2220
2224
  this._tableGetDataFinish = {};
2225
+ this._actionServerError = [];
2226
+ this._fieldServerError = [];
2227
+ this._tableServerError = [];
2221
2228
  this.inputDataFields = {};
2222
2229
  this.extraData = {};
2230
+ this.enabledSections = [];
2231
+ this.name = null;
2232
+ this.formSubject = null;
2223
2233
  this._errorType = '';
2224
2234
  this.errorCode = '';
2225
2235
  this.errorMessage = '';
@@ -2234,20 +2244,20 @@ class BasicFormComponent {
2234
2244
  setTitle(title) { var _a; return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.setTitle(title); }
2235
2245
  cleanData() { var _a; return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.cleanData(); }
2236
2246
  getCurrentState() { var _a; return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.getCurrentState(); }
2237
- supportState(state) { var _a; return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.supportState(state); }
2238
- changeState(state) { var _a; return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.changeState(state); }
2247
+ supportState(state) { var _a, _b; return (_b = (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.supportState(state !== null && state !== void 0 ? state : '')) !== null && _b !== void 0 ? _b : false; }
2248
+ changeState(state) { var _a, _b; return (_b = (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.changeState(state)) !== null && _b !== void 0 ? _b : false; }
2239
2249
  getStates() { var _a; return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.states; }
2240
2250
  getImmutableElement(name) { var _a; return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.getImmutableElement(name); }
2241
2251
  getExtraInfo(name) { var _a; return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.getExtraInfo(name); }
2242
- getFields() { var _a; return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.getFields(); }
2243
- getFieldNames() { var _a; return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.getFieldNames(); }
2244
- getField(code) { var _a; return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.getField(code); }
2252
+ getFields() { var _a, _b; return (_b = (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.getFields()) !== null && _b !== void 0 ? _b : null; }
2253
+ getFieldNames() { var _a, _b; return (_b = (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.getFieldNames()) !== null && _b !== void 0 ? _b : null; }
2254
+ getField(code) { var _a, _b; return (_b = (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.getField(code)) !== null && _b !== void 0 ? _b : null; }
2245
2255
  enableField(code) { var _a; return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.enableField(code); }
2246
2256
  disableField(code) { var _a; return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.disableField(code); }
2247
- getFieldValue(code) { var _a; return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.getFieldValue(code); }
2257
+ getFieldValue(code) { var _a, _b; return (_b = (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.getFieldValue(code)) !== null && _b !== void 0 ? _b : null; }
2248
2258
  getFieldOptionText(code) { var _a; return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.getFieldOptionText(code); }
2249
- getFieldsValues(codes) { var _a; return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.getFieldsValues(codes); }
2250
- getFieldOptions(code) { var _a; return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.getFieldOptions(code); }
2259
+ getFieldsValues(codes) { var _a, _b; return (_b = (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.getFieldsValues(codes)) !== null && _b !== void 0 ? _b : null; }
2260
+ getFieldOptions(code) { var _a, _b; return (_b = (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.getFieldOptions(code)) !== null && _b !== void 0 ? _b : null; }
2251
2261
  setFieldValue(code, value) { var _a; return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.setFieldValue(code, value); }
2252
2262
  setFieldRequired(code, required) { var _a; return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.setFieldRequired(code, required); }
2253
2263
  setFieldErrorMessage(code, errorMessage) { var _a; return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.setFieldErrorMessage(code, errorMessage); }
@@ -2262,7 +2272,7 @@ class BasicFormComponent {
2262
2272
  }
2263
2273
  getFieldSet(filterFunc, codes, secCode, subCode) {
2264
2274
  var _a;
2265
- return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.getFieldSet(filterFunc, codes, secCode, subCode);
2275
+ return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.getFieldSet(filterFunc, codes !== null && codes !== void 0 ? codes : null, secCode !== null && secCode !== void 0 ? secCode : null, subCode !== null && subCode !== void 0 ? subCode : null);
2266
2276
  }
2267
2277
  applyOnFields(processFunc, codes, secCode, subCode) {
2268
2278
  var _a;
@@ -2281,8 +2291,8 @@ class BasicFormComponent {
2281
2291
  return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.getRequiredFields(codes, secCode, subCode);
2282
2292
  }
2283
2293
  getRequiredEmptyFields(codes, secCode, subCode) {
2284
- var _a;
2285
- return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.getRequiredEmptyFields(codes, secCode, subCode);
2294
+ var _a, _b;
2295
+ return (_b = (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.getRequiredEmptyFields(codes, secCode, subCode)) !== null && _b !== void 0 ? _b : null;
2286
2296
  }
2287
2297
  getChangedFields(codes, secCode, subCode) {
2288
2298
  var _a;
@@ -2345,8 +2355,8 @@ class BasicFormComponent {
2345
2355
  return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.getActionsByAttribute('location', HEADER$1);
2346
2356
  }
2347
2357
  getAction(actionCode) {
2348
- var _a;
2349
- return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.getAction(actionCode);
2358
+ var _a, _b;
2359
+ return (_b = (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.getAction(actionCode)) !== null && _b !== void 0 ? _b : null;
2350
2360
  }
2351
2361
  showActions(actionArray) {
2352
2362
  var _a;
@@ -2381,20 +2391,20 @@ class BasicFormComponent {
2381
2391
  return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.disableActions(code);
2382
2392
  }
2383
2393
  getSections() {
2384
- var _a;
2385
- return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.getSections();
2394
+ var _a, _b;
2395
+ return (_b = (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.getSections()) !== null && _b !== void 0 ? _b : null;
2386
2396
  }
2387
2397
  activateSection(code) {
2388
2398
  var _a;
2389
2399
  return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.activateSection(code);
2390
2400
  }
2391
2401
  getSectionsTitles() {
2392
- var _a;
2393
- return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.getSections().map(sec => sec.title);
2402
+ var _a, _b;
2403
+ return (_b = (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.getSections().map(sec => sec.title)) !== null && _b !== void 0 ? _b : null;
2394
2404
  }
2395
2405
  getSection(code) {
2396
- var _a;
2397
- return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.getSection(code);
2406
+ var _a, _b;
2407
+ return (_b = (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.getSection(code)) !== null && _b !== void 0 ? _b : null;
2398
2408
  }
2399
2409
  showSection(code) {
2400
2410
  var _a;
@@ -2413,8 +2423,8 @@ class BasicFormComponent {
2413
2423
  return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.hideSections(codes);
2414
2424
  }
2415
2425
  getSubSection(code, subCode) {
2416
- var _a;
2417
- return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.getSubSection(code, subCode);
2426
+ var _a, _b;
2427
+ return (_b = (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.getSubSection(code, subCode)) !== null && _b !== void 0 ? _b : null;
2418
2428
  }
2419
2429
  showSubSection(code, subCode) {
2420
2430
  var _a;
@@ -2433,12 +2443,12 @@ class BasicFormComponent {
2433
2443
  return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.hideSubSections(code, subCodes);
2434
2444
  }
2435
2445
  getSectionActions(code) {
2436
- var _a;
2437
- return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.getSectionActions(code);
2446
+ var _a, _b;
2447
+ return (_b = (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.getSectionActions(code)) !== null && _b !== void 0 ? _b : null;
2438
2448
  }
2439
2449
  getSectionActionNames(code) {
2440
- var _a;
2441
- return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.getSectionActionNames(code);
2450
+ var _a, _b;
2451
+ return (_b = (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.getSectionActionNames(code)) !== null && _b !== void 0 ? _b : null;
2442
2452
  }
2443
2453
  getTables() {
2444
2454
  var _a;
@@ -2457,8 +2467,8 @@ class BasicFormComponent {
2457
2467
  return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.cleanTables(codes);
2458
2468
  }
2459
2469
  getTable(code) {
2460
- var _a;
2461
- return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.getTable(code);
2470
+ var _a, _b;
2471
+ return (_b = (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.getTable(code)) !== null && _b !== void 0 ? _b : null;
2462
2472
  }
2463
2473
  showTable(code) {
2464
2474
  var _a;
@@ -2507,22 +2517,28 @@ class BasicFormComponent {
2507
2517
  this._tableActionsFinish = {};
2508
2518
  this._tableGetDataStart = {};
2509
2519
  this._tableGetDataFinish = {};
2520
+ this._actionServerError = [];
2521
+ this._fieldServerError = [];
2522
+ this._tableServerError = [];
2523
+ this.onActionServerError(() => this.displayActionServerError());
2524
+ this.onValidationServerError(() => this.displayValidationServerError());
2525
+ this.onTableServerError(() => this.displayTableServerError());
2510
2526
  }
2511
2527
  get formVisible() { return this.visible; }
2512
2528
  get formManager() { return this; }
2513
- get formCode() { return this.name; }
2529
+ get formCode() { var _a; return (_a = this.name) !== null && _a !== void 0 ? _a : ''; }
2514
2530
  set formCode(name) { this.name = name; }
2515
2531
  get inServerProcess() { return this.busy; }
2516
2532
  get form() { return this._formStructure; }
2517
- get state() { var _a; return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.state; }
2518
- get currentState() { var _a; return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.state; }
2519
- set currentState(state) { this._formStructure.changeState(state); }
2533
+ get state() { var _a, _b; return (_b = (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.state) !== null && _b !== void 0 ? _b : null; }
2534
+ get currentState() { var _a, _b; return (_b = (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.state) !== null && _b !== void 0 ? _b : ''; }
2535
+ set currentState(state) { var _a; (_a = this === null || this === void 0 ? void 0 : this._formStructure) === null || _a === void 0 ? void 0 : _a.changeState(state); }
2520
2536
  get immutableData() { var _a; return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.immutableData; }
2521
2537
  get extraInfo() { var _a; return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.extraInfo; }
2522
- get visibleSections() { var _a; return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.visibleSections; }
2523
- get formRoute() { return this._formRoute; }
2538
+ get visibleSections() { var _a, _b; return (_b = (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.visibleSections) !== null && _b !== void 0 ? _b : null; }
2539
+ get formRoute() { var _a; return (_a = this._formRoute) !== null && _a !== void 0 ? _a : ''; }
2524
2540
  set formRoute(route) { this._formRoute = route; }
2525
- get subject() { return this.formSubject; }
2541
+ get subject() { var _a; return (_a = this.formSubject) !== null && _a !== void 0 ? _a : ''; }
2526
2542
  // Métodos virtuales
2527
2543
  customPreProcessing() { }
2528
2544
  customFormStart() { }
@@ -2563,11 +2579,11 @@ class BasicFormComponent {
2563
2579
  /**
2564
2580
  * @deprecated Use subject
2565
2581
  */
2566
- getSubject() { return this.formSubject; }
2582
+ getSubject() { var _a; return (_a = this.formSubject) !== null && _a !== void 0 ? _a : ''; }
2567
2583
  /**
2568
2584
  * @deprecated Use subject
2569
2585
  */
2570
- getformSubject() { return this.getSubject(); }
2586
+ getformSubject() { var _a; return (_a = this.formSubject) !== null && _a !== void 0 ? _a : ''; }
2571
2587
  numSections() { var _a; return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.sections.length; }
2572
2588
  subscribeAppEvent(eventName, callback) {
2573
2589
  this._eventEmiter.subscribe(eventName, callback);
@@ -2592,7 +2608,7 @@ class BasicFormComponent {
2592
2608
  canGoBack() { return this._originToken !== null; }
2593
2609
  goBack() { return this.formManagerService.backTo(); }
2594
2610
  goBackForm() { return this.goBack(); }
2595
- getOriginDetail() { return this.formManagerService.getFormInfo(this._originToken); }
2611
+ getOriginDetail() { var _a, _b; return (_a = this.formManagerService) === null || _a === void 0 ? void 0 : _a.getFormInfo((_b = this._originToken) !== null && _b !== void 0 ? _b : ''); }
2596
2612
  setError(errorType, errorMessage, errorDetail) {
2597
2613
  this._errorType = errorType || '';
2598
2614
  this.errorMessage = errorMessage || '';
@@ -2623,7 +2639,8 @@ class BasicFormComponent {
2623
2639
  return null;
2624
2640
  }
2625
2641
  subscribeSectionActivation() {
2626
- const formSections = this._formStructure.sections;
2642
+ var _a;
2643
+ const formSections = (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.sections;
2627
2644
  const sectionNames = Object.keys(formSections);
2628
2645
  for (let index = 0; index < sectionNames.length; index++) {
2629
2646
  const sectionName = sectionNames[index];
@@ -2633,7 +2650,8 @@ class BasicFormComponent {
2633
2650
  }
2634
2651
  }
2635
2652
  subscribeFieldsSubjects() {
2636
- const formFields = this._formStructure.getFields();
2653
+ var _a;
2654
+ const formFields = (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.getFields();
2637
2655
  if (Array.isArray(formFields)) {
2638
2656
  formFields.forEach(field => {
2639
2657
  field.editionFinish.subscribe(event => {
@@ -2649,7 +2667,8 @@ class BasicFormComponent {
2649
2667
  }
2650
2668
  }
2651
2669
  subscribeActionSubjects() {
2652
- const formActions = this._formStructure.getActions();
2670
+ var _a;
2671
+ const formActions = (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.getActions();
2653
2672
  if (Array.isArray(formActions)) {
2654
2673
  formActions.forEach(action => {
2655
2674
  action.actionActivated.subscribe(code => this.startAction(code));
@@ -2657,7 +2676,8 @@ class BasicFormComponent {
2657
2676
  }
2658
2677
  }
2659
2678
  subscribeTableSubjects() {
2660
- const formTables = this._formStructure.getTables();
2679
+ var _a;
2680
+ const formTables = (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.getTables();
2661
2681
  if (Array.isArray(formTables)) {
2662
2682
  formTables.forEach(table => {
2663
2683
  table.inlineActionTrigger.subscribe(event => this.startTableAction(event));
@@ -2669,7 +2689,7 @@ class BasicFormComponent {
2669
2689
  }
2670
2690
  }
2671
2691
  formInit(params) {
2672
- var _a;
2692
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
2673
2693
  return __awaiter(this, void 0, void 0, function* () {
2674
2694
  let initialState = this.preocessInputParams(params);
2675
2695
  if (!this.name) {
@@ -2680,18 +2700,18 @@ class BasicFormComponent {
2680
2700
  const formDefinition = yield this.formManagerService.getFormDefinition(this.name);
2681
2701
  this.busy = false;
2682
2702
  this._formStructure = new FormStructureAndData(formDefinition, this.formConfig);
2683
- this.fields = this._formStructure.fields;
2684
- this.actions = this._formStructure.actions;
2685
- this.sections = this._formStructure.sections;
2703
+ this.fields = (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.fields;
2704
+ this.actions = (_b = this._formStructure) === null || _b === void 0 ? void 0 : _b.actions;
2705
+ this.sections = (_c = this._formStructure) === null || _c === void 0 ? void 0 : _c.sections;
2686
2706
  this._definitionObtained = true;
2687
2707
  }
2688
2708
  else {
2689
2709
  this.cleanData();
2690
2710
  }
2691
2711
  if (!this.supportState(initialState)) {
2692
- initialState = this._formStructure.defaultState;
2712
+ initialState = (_e = (_d = this._formStructure) === null || _d === void 0 ? void 0 : _d.defaultState) !== null && _e !== void 0 ? _e : null;
2693
2713
  }
2694
- this._formStructure.changeState(initialState || this._formStructure.defaultState);
2714
+ (_f = this._formStructure) === null || _f === void 0 ? void 0 : _f.changeState(initialState || ((_g = this._formStructure) === null || _g === void 0 ? void 0 : _g.defaultState));
2695
2715
  const inputFieldNames = Object.keys(this.inputDataFields);
2696
2716
  for (let index = 0; index < inputFieldNames.length; index++) {
2697
2717
  const fieldCode = inputFieldNames[index];
@@ -2701,7 +2721,7 @@ class BasicFormComponent {
2701
2721
  const recordResponse = yield this.requestFormAction(formActions.getData);
2702
2722
  this.checkErrorRecordReceived(recordResponse);
2703
2723
  this.visible = true;
2704
- this.enabledSections = (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.visibleSections;
2724
+ this.enabledSections = (_j = (_h = this._formStructure) === null || _h === void 0 ? void 0 : _h.visibleSections) !== null && _j !== void 0 ? _j : [];
2705
2725
  this.subscribeSectionActivation();
2706
2726
  this.subscribeFieldsSubjects();
2707
2727
  this.subscribeActionSubjects();
@@ -2726,16 +2746,17 @@ class BasicFormComponent {
2726
2746
  * Soporte manejo de eventos de formulario
2727
2747
  */
2728
2748
  requestFormAction(actionCode, actionSubject = {}) {
2749
+ var _a, _b, _c;
2729
2750
  return __awaiter(this, void 0, void 0, function* () {
2730
2751
  const actionDetail = {
2731
2752
  formCode: this.name,
2732
2753
  formSubject: this.formSubject,
2733
- currentMode: this._formStructure.state,
2754
+ currentMode: (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.state,
2734
2755
  actionCode,
2735
2756
  actionSubject,
2736
2757
  version: PAYLOAD_VERSION,
2737
- formData: this._formStructure.getPayload(),
2738
- immutableData: this._formStructure.immutableData,
2758
+ formData: (_b = this._formStructure) === null || _b === void 0 ? void 0 : _b.getPayload(),
2759
+ immutableData: (_c = this._formStructure) === null || _c === void 0 ? void 0 : _c.immutableData,
2739
2760
  };
2740
2761
  this.errorCode = NO_ERROR;
2741
2762
  this.errorMessage = '';
@@ -2790,13 +2811,36 @@ class BasicFormComponent {
2790
2811
  if (returnedFile && returnedFile.file) {
2791
2812
  this.fileMgmtServices.saveFile(returnedFile.file, returnedFile.name, returnedFile.type);
2792
2813
  }
2793
- this._formStructure.immutableData = immutableData;
2794
- this._formStructure.extraInfo = extraInfo;
2814
+ if (this._formStructure) {
2815
+ this._formStructure.immutableData = immutableData;
2816
+ this._formStructure.extraInfo = extraInfo;
2817
+ }
2818
+ }
2819
+ /**
2820
+ * Manejo de event handlers para errores Server del formulario
2821
+ */
2822
+ cleanActionServerError() {
2823
+ this._actionServerError = [];
2824
+ }
2825
+ cleanFieldServerError() {
2826
+ this._fieldServerError = [];
2827
+ }
2828
+ cleanTableServerError() {
2829
+ this._tableServerError = [];
2830
+ }
2831
+ onActionServerError(callback, properties = null) {
2832
+ this._actionServerError.push({ callback, properties });
2833
+ }
2834
+ onValidationServerError(callback, properties = null) {
2835
+ this._fieldServerError.push({ callback, properties });
2836
+ }
2837
+ onTableServerError(callback, properties = null) {
2838
+ this._tableServerError.push({ callback, properties });
2795
2839
  }
2796
2840
  /**
2797
2841
  * Manejo de event handlers para acciones sobre el formulario
2798
2842
  */
2799
- addSectionActivation(codes, callback, properties = null) {
2843
+ onSectionActivation(codes, callback, properties = null) {
2800
2844
  const sectionSet = (Array.isArray(codes)) ? codes : (codes ? [codes] : []);
2801
2845
  sectionSet.forEach((sectionName) => {
2802
2846
  if (!this._formSectionsActivate[sectionName]) {
@@ -2805,7 +2849,7 @@ class BasicFormComponent {
2805
2849
  this._formSectionsActivate[sectionName].push({ callback, properties });
2806
2850
  });
2807
2851
  }
2808
- addSectionInactivation(codes, callback, properties = null) {
2852
+ onSectionInactivation(codes, callback, properties = null) {
2809
2853
  const sectionSet = (Array.isArray(codes)) ? codes : (codes ? [codes] : []);
2810
2854
  sectionSet.forEach((sectionName) => {
2811
2855
  if (!this._formSectionsInactivate[sectionName]) {
@@ -2814,7 +2858,7 @@ class BasicFormComponent {
2814
2858
  this._formSectionsInactivate[sectionName].push({ callback, properties });
2815
2859
  });
2816
2860
  }
2817
- addActionMethodStart(codes, callback, properties = null) {
2861
+ onActionStart(codes, callback, properties = null) {
2818
2862
  const actionSet = (Array.isArray(codes)) ? codes : (codes ? [codes] : []);
2819
2863
  actionSet.forEach((actionName) => {
2820
2864
  if (!this._formActionsStart[actionName]) {
@@ -2823,7 +2867,7 @@ class BasicFormComponent {
2823
2867
  this._formActionsStart[actionName].push({ callback, properties });
2824
2868
  });
2825
2869
  }
2826
- addActionMethodFinish(codes, callback, properties = null) {
2870
+ onActionFinish(codes, callback, properties = null) {
2827
2871
  const actionSet = (Array.isArray(codes)) ? codes : (codes ? [codes] : []);
2828
2872
  actionSet.forEach((actionName) => {
2829
2873
  if (!this._formActionsFinish[actionName]) {
@@ -2833,8 +2877,9 @@ class BasicFormComponent {
2833
2877
  });
2834
2878
  }
2835
2879
  launchSectionActivation(code) {
2880
+ var _a;
2836
2881
  return __awaiter(this, void 0, void 0, function* () {
2837
- const sectionObject = this._formStructure.getSection(code);
2882
+ const sectionObject = (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.getSection(code);
2838
2883
  if (!sectionObject) {
2839
2884
  return;
2840
2885
  }
@@ -2848,8 +2893,9 @@ class BasicFormComponent {
2848
2893
  });
2849
2894
  }
2850
2895
  launchSectionInactivation(code) {
2896
+ var _a;
2851
2897
  return __awaiter(this, void 0, void 0, function* () {
2852
- const sectionObject = this._formStructure.getSection(code);
2898
+ const sectionObject = (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.getSection(code);
2853
2899
  if (!sectionObject) {
2854
2900
  return;
2855
2901
  }
@@ -2903,7 +2949,10 @@ class BasicFormComponent {
2903
2949
  action.newState && this.changeState(action.newState);
2904
2950
  }
2905
2951
  else {
2906
- this.displayActionServerError();
2952
+ for (let index = 0; index < this._actionServerError.length; index++) {
2953
+ const { callback, properties } = this._actionServerError[index];
2954
+ callback(action);
2955
+ }
2907
2956
  }
2908
2957
  action.stop();
2909
2958
  });
@@ -2931,7 +2980,7 @@ class BasicFormComponent {
2931
2980
  /**
2932
2981
  * Manejadores de eventos para validaciones sobre campos
2933
2982
  */
2934
- addFieldInputValidation(codes, callback, properties = null) {
2983
+ onFieldInput(codes, callback, properties = null) {
2935
2984
  const fieldSet = (Array.isArray(codes)) ? codes : (codes ? [codes] : []);
2936
2985
  fieldSet.forEach((fieldCode) => {
2937
2986
  if (!this._fieldInputValidation[fieldCode]) {
@@ -2940,7 +2989,7 @@ class BasicFormComponent {
2940
2989
  this._fieldInputValidation[fieldCode].push({ callback, properties });
2941
2990
  });
2942
2991
  }
2943
- addFieldValidationStart(codes, callback, properties = null) {
2992
+ onFieldValidationStart(codes, callback, properties = null) {
2944
2993
  const fieldSet = (Array.isArray(codes)) ? codes : (codes ? [codes] : []);
2945
2994
  fieldSet.forEach((fieldCode) => {
2946
2995
  if (!this._fieldValidationsStart[fieldCode]) {
@@ -2949,7 +2998,7 @@ class BasicFormComponent {
2949
2998
  this._fieldValidationsStart[fieldCode].push({ callback, properties });
2950
2999
  });
2951
3000
  }
2952
- addFieldValidationFinish(codes, callback, properties = null) {
3001
+ onFieldValidationFinish(codes, callback, properties = null) {
2953
3002
  const fieldSet = (Array.isArray(codes)) ? codes : (codes ? [codes] : []);
2954
3003
  fieldSet.forEach((fieldCode) => {
2955
3004
  if (!this._fieldValidationsFinish[fieldCode]) {
@@ -3010,6 +3059,9 @@ class BasicFormComponent {
3010
3059
  ? this.getField(inputField) : inputField;
3011
3060
  let serverError = false;
3012
3061
  let validationResult = true;
3062
+ if (!fieldObj) {
3063
+ return;
3064
+ }
3013
3065
  if (fieldObj.backend) {
3014
3066
  fieldObj.validating = true;
3015
3067
  validationResult = yield this
@@ -3018,9 +3070,12 @@ class BasicFormComponent {
3018
3070
  }
3019
3071
  yield this.finishFieldValidation(fieldObj, validationResult, serverError);
3020
3072
  if (serverError) {
3021
- fieldObj.setErrorCode(this.errorCode);
3022
- fieldObj.setErrorMessage(this.errorMessage);
3023
- this.displayValidationServerError();
3073
+ fieldObj === null || fieldObj === void 0 ? void 0 : fieldObj.setErrorCode(this.errorCode);
3074
+ fieldObj === null || fieldObj === void 0 ? void 0 : fieldObj.setErrorMessage(this.errorMessage);
3075
+ for (let index = 0; index < this._fieldServerError.length; index++) {
3076
+ const { callback, properties } = this._fieldServerError[index];
3077
+ callback(fieldObj);
3078
+ }
3024
3079
  }
3025
3080
  fieldObj.validating = false;
3026
3081
  });
@@ -3050,7 +3105,7 @@ class BasicFormComponent {
3050
3105
  /**
3051
3106
  * Manejadores de eventos para acciones sobre Tablas
3052
3107
  */
3053
- addTableActionStart(code, actionCode, callback, properties = null) {
3108
+ onTableActionStart(code, actionCode, callback, properties = null) {
3054
3109
  const tableObject = this.getTable(code);
3055
3110
  if (!tableObject) {
3056
3111
  return;
@@ -3072,7 +3127,7 @@ class BasicFormComponent {
3072
3127
  }
3073
3128
  tableEventHandlers[actionCode].push({ callback, properties });
3074
3129
  }
3075
- addTableActionFinish(code, actionCode, callback, properties = null) {
3130
+ onTableActionFinish(code, actionCode, callback, properties = null) {
3076
3131
  const tableObject = this.getTable(code);
3077
3132
  if (!tableObject) {
3078
3133
  return;
@@ -3094,7 +3149,7 @@ class BasicFormComponent {
3094
3149
  }
3095
3150
  tableEventHandlers[actionCode].push({ callback, properties });
3096
3151
  }
3097
- addTableSelectionStart(code, callback, properties = null) {
3152
+ onTableSelectionStart(code, callback, properties = null) {
3098
3153
  const tableObject = this.getTable(code);
3099
3154
  if (!tableObject) {
3100
3155
  return;
@@ -3109,7 +3164,7 @@ class BasicFormComponent {
3109
3164
  }
3110
3165
  tableEventHandlers.push({ callback, properties });
3111
3166
  }
3112
- addTableSelectionFinish(code, callback, properties = null) {
3167
+ onTableSelectionFinish(code, callback, properties = null) {
3113
3168
  const tableObject = this.getTable(code);
3114
3169
  if (!tableObject) {
3115
3170
  return;
@@ -3124,7 +3179,7 @@ class BasicFormComponent {
3124
3179
  }
3125
3180
  tableEventHandlers.push({ callback, properties });
3126
3181
  }
3127
- addTableGetDataStart(code, callback, properties = null) {
3182
+ onTableGetDataStart(code, callback, properties = null) {
3128
3183
  const tableObject = this.getTable(code);
3129
3184
  if (!tableObject) {
3130
3185
  return;
@@ -3139,7 +3194,7 @@ class BasicFormComponent {
3139
3194
  }
3140
3195
  tableEventHandlers.push({ callback, properties });
3141
3196
  }
3142
- addTableGetDataFinish(code, callback, properties = null) {
3197
+ onTableGetDataFinish(code, callback, properties = null) {
3143
3198
  const tableObject = this.getTable(code);
3144
3199
  if (!tableObject) {
3145
3200
  return;
@@ -3214,7 +3269,10 @@ class BasicFormComponent {
3214
3269
  action.newState && this.changeState(action.newState);
3215
3270
  }
3216
3271
  else {
3217
- this.displayTableServerError();
3272
+ for (let index = 0; index < this._tableServerError.length; index++) {
3273
+ const { callback, properties } = this._tableServerError[index];
3274
+ callback(tableObject);
3275
+ }
3218
3276
  }
3219
3277
  tableObject.freeWaiting();
3220
3278
  });
@@ -3563,6 +3621,7 @@ class BasicFormComponent {
3563
3621
  return (numErrors === 0);
3564
3622
  }
3565
3623
  validateSectionConsistency(sectionCode, reqFieldMessage) {
3624
+ var _a, _b;
3566
3625
  this.resetError();
3567
3626
  const completeFields = this.checkSectionRequiredFields(sectionCode, reqFieldMessage);
3568
3627
  if (!completeFields) {
@@ -3570,8 +3629,8 @@ class BasicFormComponent {
3570
3629
  return false;
3571
3630
  }
3572
3631
  let validationError = false;
3573
- const requiredEmptyFields = this.getRequiredEmptyFields(null, sectionCode);
3574
- if (requiredEmptyFields.length > 0) {
3632
+ const requiredEmptyFields = (_a = this.getRequiredEmptyFields(null, sectionCode)) !== null && _a !== void 0 ? _a : [];
3633
+ if ((requiredEmptyFields === null || requiredEmptyFields === void 0 ? void 0 : requiredEmptyFields.length) > 0) {
3575
3634
  validationError = true;
3576
3635
  this.setError(this.formConfig.formStandardErrors.typeWarning, this.formConfig.formStandardErrors.validationTitle, this.formConfig.formStandardErrors.requiredFields);
3577
3636
  this.tagFieldsWithError(this.formConfig.formStandardErrors.requiredField, requiredEmptyFields);
@@ -3581,13 +3640,15 @@ class BasicFormComponent {
3581
3640
  break;
3582
3641
  }
3583
3642
  }
3584
- const validationIssueFields = this.getFieldsWithValidationIssues(null, sectionCode);
3643
+ const validationIssueFields = (_b = this.getFieldsWithValidationIssues(null, sectionCode)) !== null && _b !== void 0 ? _b : [];
3585
3644
  if (!validationError && validationIssueFields.length > 0) {
3586
3645
  validationError = true;
3587
3646
  this.setError(this.formConfig.formStandardErrors.typeWarning, this.formConfig.formStandardErrors.validationTitle, this.formConfig.formStandardErrors.validationFields);
3588
3647
  for (const fieldCode of validationIssueFields) {
3589
3648
  const validationIssueField = this.getField(fieldCode);
3590
- validationIssueField.focus();
3649
+ if (validationIssueField) {
3650
+ validationIssueField.focus();
3651
+ }
3591
3652
  break;
3592
3653
  }
3593
3654
  }
@@ -3596,14 +3657,59 @@ class BasicFormComponent {
3596
3657
  copyTableRecordToFields(tableObj, mappingTable = null) {
3597
3658
  var _a, _b;
3598
3659
  const tableObject = this.getTable(tableObj.tableCode);
3599
- const tableRecord = tableObject.getTableRecord(tableObj.recordId);
3600
- const columnNames = tableObject.columnNames;
3601
- for (const columnName of columnNames) {
3602
- const columnValue = (_a = tableRecord.getFieldValue(columnName)) !== null && _a !== void 0 ? _a : '';
3603
- const fieldCode = (_b = mappingTable === null || mappingTable === void 0 ? void 0 : mappingTable[columnName]) !== null && _b !== void 0 ? _b : columnName;
3604
- this.setFieldValue(fieldCode, columnValue);
3660
+ const tableRecord = tableObject === null || tableObject === void 0 ? void 0 : tableObject.getTableRecord(tableObj.recordId);
3661
+ const columnNames = tableObject === null || tableObject === void 0 ? void 0 : tableObject.columnNames;
3662
+ if (tableRecord && columnNames) {
3663
+ for (const columnName of columnNames) {
3664
+ const columnValue = (_a = tableRecord.getFieldValue(columnName)) !== null && _a !== void 0 ? _a : '';
3665
+ const fieldCode = (_b = mappingTable === null || mappingTable === void 0 ? void 0 : mappingTable[columnName]) !== null && _b !== void 0 ? _b : columnName;
3666
+ this.setFieldValue(fieldCode, columnValue);
3667
+ }
3668
+ return true;
3605
3669
  }
3606
- return true;
3670
+ return false;
3671
+ }
3672
+ /**
3673
+ * Métodos Legacy de compatibilidad hacia atrás
3674
+ */
3675
+ addSectionActivation(codes, callback, properties = null) {
3676
+ return this.onSectionActivation(codes, callback, properties);
3677
+ }
3678
+ addSectionInactivation(codes, callback, properties = null) {
3679
+ return this.onSectionInactivation(codes, callback, properties);
3680
+ }
3681
+ addActionMethodStart(codes, callback, properties = null) {
3682
+ return this.onActionStart(codes, callback, properties);
3683
+ }
3684
+ addActionMethodFinish(codes, callback, properties = null) {
3685
+ return this.onActionFinish(codes, callback, properties);
3686
+ }
3687
+ addFieldInputValidation(codes, callback, properties = null) {
3688
+ return this.onFieldInput(codes, callback, properties);
3689
+ }
3690
+ addFieldValidationStart(codes, callback, properties = null) {
3691
+ return this.onFieldValidationStart(codes, callback, properties);
3692
+ }
3693
+ addFieldValidationFinish(codes, callback, properties = null) {
3694
+ return this.onFieldValidationFinish(codes, callback, properties);
3695
+ }
3696
+ addTableActionStart(code, actionCode, callback, properties = null) {
3697
+ return this.onTableActionStart(code, actionCode, callback, properties);
3698
+ }
3699
+ addTableActionFinish(code, actionCode, callback, properties = null) {
3700
+ return this.onTableActionFinish(code, actionCode, callback, properties);
3701
+ }
3702
+ addTableSelectionStart(code, callback, properties = null) {
3703
+ return this.onTableSelectionStart(code, callback, properties);
3704
+ }
3705
+ addTableSelectionFinish(code, callback, properties = null) {
3706
+ return this.onTableSelectionFinish(code, callback, properties);
3707
+ }
3708
+ addTableGetDataStart(code, callback, properties = null) {
3709
+ return this.onTableGetDataStart(code, callback, properties);
3710
+ }
3711
+ addTableGetDataFinish(code, callback, properties = null) {
3712
+ return this.onTableGetDataFinish(code, callback, properties);
3607
3713
  }
3608
3714
  }
3609
3715
  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 });