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.
@@ -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,10 +2222,18 @@ 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 = '';
2235
+ this.errorFullCode = '';
2236
+ this.errorName = '';
2225
2237
  this.errorMessage = '';
2226
2238
  this.errorDetail = '';
2227
2239
  this.visible = false;
@@ -2234,20 +2246,20 @@ class BasicFormComponent {
2234
2246
  setTitle(title) { var _a; return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.setTitle(title); }
2235
2247
  cleanData() { var _a; return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.cleanData(); }
2236
2248
  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); }
2249
+ 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; }
2250
+ 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
2251
  getStates() { var _a; return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.states; }
2240
2252
  getImmutableElement(name) { var _a; return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.getImmutableElement(name); }
2241
2253
  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); }
2254
+ getFields() { var _a, _b; return (_b = (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.getFields()) !== null && _b !== void 0 ? _b : null; }
2255
+ getFieldNames() { var _a, _b; return (_b = (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.getFieldNames()) !== null && _b !== void 0 ? _b : null; }
2256
+ 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
2257
  enableField(code) { var _a; return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.enableField(code); }
2246
2258
  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); }
2259
+ 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
2260
  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); }
2261
+ 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; }
2262
+ 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
2263
  setFieldValue(code, value) { var _a; return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.setFieldValue(code, value); }
2252
2264
  setFieldRequired(code, required) { var _a; return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.setFieldRequired(code, required); }
2253
2265
  setFieldErrorMessage(code, errorMessage) { var _a; return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.setFieldErrorMessage(code, errorMessage); }
@@ -2262,7 +2274,7 @@ class BasicFormComponent {
2262
2274
  }
2263
2275
  getFieldSet(filterFunc, codes, secCode, subCode) {
2264
2276
  var _a;
2265
- return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.getFieldSet(filterFunc, codes, secCode, subCode);
2277
+ 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
2278
  }
2267
2279
  applyOnFields(processFunc, codes, secCode, subCode) {
2268
2280
  var _a;
@@ -2281,8 +2293,8 @@ class BasicFormComponent {
2281
2293
  return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.getRequiredFields(codes, secCode, subCode);
2282
2294
  }
2283
2295
  getRequiredEmptyFields(codes, secCode, subCode) {
2284
- var _a;
2285
- return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.getRequiredEmptyFields(codes, secCode, subCode);
2296
+ var _a, _b;
2297
+ return (_b = (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.getRequiredEmptyFields(codes, secCode, subCode)) !== null && _b !== void 0 ? _b : null;
2286
2298
  }
2287
2299
  getChangedFields(codes, secCode, subCode) {
2288
2300
  var _a;
@@ -2345,8 +2357,8 @@ class BasicFormComponent {
2345
2357
  return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.getActionsByAttribute('location', HEADER$1);
2346
2358
  }
2347
2359
  getAction(actionCode) {
2348
- var _a;
2349
- return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.getAction(actionCode);
2360
+ var _a, _b;
2361
+ return (_b = (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.getAction(actionCode)) !== null && _b !== void 0 ? _b : null;
2350
2362
  }
2351
2363
  showActions(actionArray) {
2352
2364
  var _a;
@@ -2381,20 +2393,20 @@ class BasicFormComponent {
2381
2393
  return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.disableActions(code);
2382
2394
  }
2383
2395
  getSections() {
2384
- var _a;
2385
- return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.getSections();
2396
+ var _a, _b;
2397
+ return (_b = (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.getSections()) !== null && _b !== void 0 ? _b : null;
2386
2398
  }
2387
2399
  activateSection(code) {
2388
2400
  var _a;
2389
2401
  return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.activateSection(code);
2390
2402
  }
2391
2403
  getSectionsTitles() {
2392
- var _a;
2393
- return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.getSections().map(sec => sec.title);
2404
+ var _a, _b;
2405
+ return (_b = (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.getSections().map(sec => sec.title)) !== null && _b !== void 0 ? _b : null;
2394
2406
  }
2395
2407
  getSection(code) {
2396
- var _a;
2397
- return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.getSection(code);
2408
+ var _a, _b;
2409
+ return (_b = (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.getSection(code)) !== null && _b !== void 0 ? _b : null;
2398
2410
  }
2399
2411
  showSection(code) {
2400
2412
  var _a;
@@ -2413,8 +2425,8 @@ class BasicFormComponent {
2413
2425
  return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.hideSections(codes);
2414
2426
  }
2415
2427
  getSubSection(code, subCode) {
2416
- var _a;
2417
- return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.getSubSection(code, subCode);
2428
+ var _a, _b;
2429
+ return (_b = (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.getSubSection(code, subCode)) !== null && _b !== void 0 ? _b : null;
2418
2430
  }
2419
2431
  showSubSection(code, subCode) {
2420
2432
  var _a;
@@ -2433,12 +2445,12 @@ class BasicFormComponent {
2433
2445
  return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.hideSubSections(code, subCodes);
2434
2446
  }
2435
2447
  getSectionActions(code) {
2436
- var _a;
2437
- return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.getSectionActions(code);
2448
+ var _a, _b;
2449
+ return (_b = (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.getSectionActions(code)) !== null && _b !== void 0 ? _b : null;
2438
2450
  }
2439
2451
  getSectionActionNames(code) {
2440
- var _a;
2441
- return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.getSectionActionNames(code);
2452
+ var _a, _b;
2453
+ return (_b = (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.getSectionActionNames(code)) !== null && _b !== void 0 ? _b : null;
2442
2454
  }
2443
2455
  getTables() {
2444
2456
  var _a;
@@ -2457,8 +2469,8 @@ class BasicFormComponent {
2457
2469
  return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.cleanTables(codes);
2458
2470
  }
2459
2471
  getTable(code) {
2460
- var _a;
2461
- return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.getTable(code);
2472
+ var _a, _b;
2473
+ return (_b = (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.getTable(code)) !== null && _b !== void 0 ? _b : null;
2462
2474
  }
2463
2475
  showTable(code) {
2464
2476
  var _a;
@@ -2482,6 +2494,8 @@ class BasicFormComponent {
2482
2494
  cleanStart() {
2483
2495
  this._errorType = '';
2484
2496
  this.errorCode = '';
2497
+ this.errorFullCode = '';
2498
+ this.errorName = '';
2485
2499
  this.errorMessage = '';
2486
2500
  this.errorDetail = '';
2487
2501
  this._formStructure = null;
@@ -2507,22 +2521,28 @@ class BasicFormComponent {
2507
2521
  this._tableActionsFinish = {};
2508
2522
  this._tableGetDataStart = {};
2509
2523
  this._tableGetDataFinish = {};
2524
+ this._actionServerError = [];
2525
+ this._fieldServerError = [];
2526
+ this._tableServerError = [];
2527
+ this.onActionServerError(() => this.displayActionServerError());
2528
+ this.onValidationServerError(() => this.displayValidationServerError());
2529
+ this.onTableServerError(() => this.displayTableServerError());
2510
2530
  }
2511
2531
  get formVisible() { return this.visible; }
2512
2532
  get formManager() { return this; }
2513
- get formCode() { return this.name; }
2533
+ get formCode() { var _a; return (_a = this.name) !== null && _a !== void 0 ? _a : ''; }
2514
2534
  set formCode(name) { this.name = name; }
2515
2535
  get inServerProcess() { return this.busy; }
2516
2536
  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); }
2537
+ get state() { var _a, _b; return (_b = (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.state) !== null && _b !== void 0 ? _b : null; }
2538
+ get currentState() { var _a, _b; return (_b = (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.state) !== null && _b !== void 0 ? _b : ''; }
2539
+ 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
2540
  get immutableData() { var _a; return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.immutableData; }
2521
2541
  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; }
2542
+ get visibleSections() { var _a, _b; return (_b = (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.visibleSections) !== null && _b !== void 0 ? _b : null; }
2543
+ get formRoute() { var _a; return (_a = this._formRoute) !== null && _a !== void 0 ? _a : ''; }
2524
2544
  set formRoute(route) { this._formRoute = route; }
2525
- get subject() { return this.formSubject; }
2545
+ get subject() { var _a; return (_a = this.formSubject) !== null && _a !== void 0 ? _a : ''; }
2526
2546
  // Métodos virtuales
2527
2547
  customPreProcessing() { }
2528
2548
  customFormStart() { }
@@ -2563,11 +2583,11 @@ class BasicFormComponent {
2563
2583
  /**
2564
2584
  * @deprecated Use subject
2565
2585
  */
2566
- getSubject() { return this.formSubject; }
2586
+ getSubject() { var _a; return (_a = this.formSubject) !== null && _a !== void 0 ? _a : ''; }
2567
2587
  /**
2568
2588
  * @deprecated Use subject
2569
2589
  */
2570
- getformSubject() { return this.getSubject(); }
2590
+ getformSubject() { var _a; return (_a = this.formSubject) !== null && _a !== void 0 ? _a : ''; }
2571
2591
  numSections() { var _a; return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.sections.length; }
2572
2592
  subscribeAppEvent(eventName, callback) {
2573
2593
  this._eventEmiter.subscribe(eventName, callback);
@@ -2592,7 +2612,7 @@ class BasicFormComponent {
2592
2612
  canGoBack() { return this._originToken !== null; }
2593
2613
  goBack() { return this.formManagerService.backTo(); }
2594
2614
  goBackForm() { return this.goBack(); }
2595
- getOriginDetail() { return this.formManagerService.getFormInfo(this._originToken); }
2615
+ 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
2616
  setError(errorType, errorMessage, errorDetail) {
2597
2617
  this._errorType = errorType || '';
2598
2618
  this.errorMessage = errorMessage || '';
@@ -2602,6 +2622,8 @@ class BasicFormComponent {
2602
2622
  getErrorType() { return this._errorType; }
2603
2623
  getErrorMessage() { return this.errorMessage; }
2604
2624
  getErrorDetail() { return this.errorDetail; }
2625
+ getErrorName() { return this.errorName; }
2626
+ getErrorFullCode() { return this.errorFullCode; }
2605
2627
  getErrorCode() { return this._errorType; }
2606
2628
  getFormParameter(name) {
2607
2629
  var _a, _b;
@@ -2623,7 +2645,8 @@ class BasicFormComponent {
2623
2645
  return null;
2624
2646
  }
2625
2647
  subscribeSectionActivation() {
2626
- const formSections = this._formStructure.sections;
2648
+ var _a;
2649
+ const formSections = (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.sections;
2627
2650
  const sectionNames = Object.keys(formSections);
2628
2651
  for (let index = 0; index < sectionNames.length; index++) {
2629
2652
  const sectionName = sectionNames[index];
@@ -2633,7 +2656,8 @@ class BasicFormComponent {
2633
2656
  }
2634
2657
  }
2635
2658
  subscribeFieldsSubjects() {
2636
- const formFields = this._formStructure.getFields();
2659
+ var _a;
2660
+ const formFields = (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.getFields();
2637
2661
  if (Array.isArray(formFields)) {
2638
2662
  formFields.forEach(field => {
2639
2663
  field.editionFinish.subscribe(event => {
@@ -2649,7 +2673,8 @@ class BasicFormComponent {
2649
2673
  }
2650
2674
  }
2651
2675
  subscribeActionSubjects() {
2652
- const formActions = this._formStructure.getActions();
2676
+ var _a;
2677
+ const formActions = (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.getActions();
2653
2678
  if (Array.isArray(formActions)) {
2654
2679
  formActions.forEach(action => {
2655
2680
  action.actionActivated.subscribe(code => this.startAction(code));
@@ -2657,7 +2682,8 @@ class BasicFormComponent {
2657
2682
  }
2658
2683
  }
2659
2684
  subscribeTableSubjects() {
2660
- const formTables = this._formStructure.getTables();
2685
+ var _a;
2686
+ const formTables = (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.getTables();
2661
2687
  if (Array.isArray(formTables)) {
2662
2688
  formTables.forEach(table => {
2663
2689
  table.inlineActionTrigger.subscribe(event => this.startTableAction(event));
@@ -2669,7 +2695,7 @@ class BasicFormComponent {
2669
2695
  }
2670
2696
  }
2671
2697
  formInit(params) {
2672
- var _a;
2698
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
2673
2699
  return __awaiter(this, void 0, void 0, function* () {
2674
2700
  let initialState = this.preocessInputParams(params);
2675
2701
  if (!this.name) {
@@ -2680,18 +2706,18 @@ class BasicFormComponent {
2680
2706
  const formDefinition = yield this.formManagerService.getFormDefinition(this.name);
2681
2707
  this.busy = false;
2682
2708
  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;
2709
+ this.fields = (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.fields;
2710
+ this.actions = (_b = this._formStructure) === null || _b === void 0 ? void 0 : _b.actions;
2711
+ this.sections = (_c = this._formStructure) === null || _c === void 0 ? void 0 : _c.sections;
2686
2712
  this._definitionObtained = true;
2687
2713
  }
2688
2714
  else {
2689
2715
  this.cleanData();
2690
2716
  }
2691
2717
  if (!this.supportState(initialState)) {
2692
- initialState = this._formStructure.defaultState;
2718
+ initialState = (_e = (_d = this._formStructure) === null || _d === void 0 ? void 0 : _d.defaultState) !== null && _e !== void 0 ? _e : null;
2693
2719
  }
2694
- this._formStructure.changeState(initialState || this._formStructure.defaultState);
2720
+ (_f = this._formStructure) === null || _f === void 0 ? void 0 : _f.changeState(initialState || ((_g = this._formStructure) === null || _g === void 0 ? void 0 : _g.defaultState));
2695
2721
  const inputFieldNames = Object.keys(this.inputDataFields);
2696
2722
  for (let index = 0; index < inputFieldNames.length; index++) {
2697
2723
  const fieldCode = inputFieldNames[index];
@@ -2701,7 +2727,7 @@ class BasicFormComponent {
2701
2727
  const recordResponse = yield this.requestFormAction(formActions.getData);
2702
2728
  this.checkErrorRecordReceived(recordResponse);
2703
2729
  this.visible = true;
2704
- this.enabledSections = (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.visibleSections;
2730
+ this.enabledSections = (_j = (_h = this._formStructure) === null || _h === void 0 ? void 0 : _h.visibleSections) !== null && _j !== void 0 ? _j : [];
2705
2731
  this.subscribeSectionActivation();
2706
2732
  this.subscribeFieldsSubjects();
2707
2733
  this.subscribeActionSubjects();
@@ -2715,6 +2741,8 @@ class BasicFormComponent {
2715
2741
  return false;
2716
2742
  }
2717
2743
  this.errorCode = recordResponse.errorCode;
2744
+ this.errorFullCode = recordResponse.errorFullCode;
2745
+ this.errorName = recordResponse.errorName;
2718
2746
  this.errorMessage = recordResponse.errorMessage;
2719
2747
  this.errorDetail = recordResponse.errorDetail;
2720
2748
  return true;
@@ -2726,18 +2754,21 @@ class BasicFormComponent {
2726
2754
  * Soporte manejo de eventos de formulario
2727
2755
  */
2728
2756
  requestFormAction(actionCode, actionSubject = {}) {
2757
+ var _a, _b, _c;
2729
2758
  return __awaiter(this, void 0, void 0, function* () {
2730
2759
  const actionDetail = {
2731
2760
  formCode: this.name,
2732
2761
  formSubject: this.formSubject,
2733
- currentMode: this._formStructure.state,
2762
+ currentMode: (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.state,
2734
2763
  actionCode,
2735
2764
  actionSubject,
2736
2765
  version: PAYLOAD_VERSION,
2737
- formData: this._formStructure.getPayload(),
2738
- immutableData: this._formStructure.immutableData,
2766
+ formData: (_b = this._formStructure) === null || _b === void 0 ? void 0 : _b.getPayload(),
2767
+ immutableData: (_c = this._formStructure) === null || _c === void 0 ? void 0 : _c.immutableData,
2739
2768
  };
2740
2769
  this.errorCode = NO_ERROR;
2770
+ this.errorFullCode = '';
2771
+ this.errorName = '';
2741
2772
  this.errorMessage = '';
2742
2773
  this.errorDetail = '';
2743
2774
  this.busy = true;
@@ -2749,6 +2780,8 @@ class BasicFormComponent {
2749
2780
  if (formActionResponse.hasError()) {
2750
2781
  const error = formActionResponse.error;
2751
2782
  this.errorCode = error.errorCode;
2783
+ this.errorFullCode = error.errorFullCode;
2784
+ this.errorName = error.errorName;
2752
2785
  this.errorMessage = error.errorMessage;
2753
2786
  this.errorDetail = error.errorDetail;
2754
2787
  }
@@ -2790,13 +2823,36 @@ class BasicFormComponent {
2790
2823
  if (returnedFile && returnedFile.file) {
2791
2824
  this.fileMgmtServices.saveFile(returnedFile.file, returnedFile.name, returnedFile.type);
2792
2825
  }
2793
- this._formStructure.immutableData = immutableData;
2794
- this._formStructure.extraInfo = extraInfo;
2826
+ if (this._formStructure) {
2827
+ this._formStructure.immutableData = immutableData;
2828
+ this._formStructure.extraInfo = extraInfo;
2829
+ }
2830
+ }
2831
+ /**
2832
+ * Manejo de event handlers para errores Server del formulario
2833
+ */
2834
+ cleanActionServerError() {
2835
+ this._actionServerError = [];
2836
+ }
2837
+ cleanFieldServerError() {
2838
+ this._fieldServerError = [];
2839
+ }
2840
+ cleanTableServerError() {
2841
+ this._tableServerError = [];
2842
+ }
2843
+ onActionServerError(callback, properties = null) {
2844
+ this._actionServerError.push({ callback, properties });
2845
+ }
2846
+ onValidationServerError(callback, properties = null) {
2847
+ this._fieldServerError.push({ callback, properties });
2848
+ }
2849
+ onTableServerError(callback, properties = null) {
2850
+ this._tableServerError.push({ callback, properties });
2795
2851
  }
2796
2852
  /**
2797
2853
  * Manejo de event handlers para acciones sobre el formulario
2798
2854
  */
2799
- addSectionActivation(codes, callback, properties = null) {
2855
+ onSectionActivation(codes, callback, properties = null) {
2800
2856
  const sectionSet = (Array.isArray(codes)) ? codes : (codes ? [codes] : []);
2801
2857
  sectionSet.forEach((sectionName) => {
2802
2858
  if (!this._formSectionsActivate[sectionName]) {
@@ -2805,7 +2861,7 @@ class BasicFormComponent {
2805
2861
  this._formSectionsActivate[sectionName].push({ callback, properties });
2806
2862
  });
2807
2863
  }
2808
- addSectionInactivation(codes, callback, properties = null) {
2864
+ onSectionInactivation(codes, callback, properties = null) {
2809
2865
  const sectionSet = (Array.isArray(codes)) ? codes : (codes ? [codes] : []);
2810
2866
  sectionSet.forEach((sectionName) => {
2811
2867
  if (!this._formSectionsInactivate[sectionName]) {
@@ -2814,7 +2870,7 @@ class BasicFormComponent {
2814
2870
  this._formSectionsInactivate[sectionName].push({ callback, properties });
2815
2871
  });
2816
2872
  }
2817
- addActionMethodStart(codes, callback, properties = null) {
2873
+ onActionStart(codes, callback, properties = null) {
2818
2874
  const actionSet = (Array.isArray(codes)) ? codes : (codes ? [codes] : []);
2819
2875
  actionSet.forEach((actionName) => {
2820
2876
  if (!this._formActionsStart[actionName]) {
@@ -2823,7 +2879,7 @@ class BasicFormComponent {
2823
2879
  this._formActionsStart[actionName].push({ callback, properties });
2824
2880
  });
2825
2881
  }
2826
- addActionMethodFinish(codes, callback, properties = null) {
2882
+ onActionFinish(codes, callback, properties = null) {
2827
2883
  const actionSet = (Array.isArray(codes)) ? codes : (codes ? [codes] : []);
2828
2884
  actionSet.forEach((actionName) => {
2829
2885
  if (!this._formActionsFinish[actionName]) {
@@ -2833,8 +2889,9 @@ class BasicFormComponent {
2833
2889
  });
2834
2890
  }
2835
2891
  launchSectionActivation(code) {
2892
+ var _a;
2836
2893
  return __awaiter(this, void 0, void 0, function* () {
2837
- const sectionObject = this._formStructure.getSection(code);
2894
+ const sectionObject = (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.getSection(code);
2838
2895
  if (!sectionObject) {
2839
2896
  return;
2840
2897
  }
@@ -2848,8 +2905,9 @@ class BasicFormComponent {
2848
2905
  });
2849
2906
  }
2850
2907
  launchSectionInactivation(code) {
2908
+ var _a;
2851
2909
  return __awaiter(this, void 0, void 0, function* () {
2852
- const sectionObject = this._formStructure.getSection(code);
2910
+ const sectionObject = (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.getSection(code);
2853
2911
  if (!sectionObject) {
2854
2912
  return;
2855
2913
  }
@@ -2903,7 +2961,10 @@ class BasicFormComponent {
2903
2961
  action.newState && this.changeState(action.newState);
2904
2962
  }
2905
2963
  else {
2906
- this.displayActionServerError();
2964
+ for (let index = 0; index < this._actionServerError.length; index++) {
2965
+ const { callback, properties } = this._actionServerError[index];
2966
+ callback(action);
2967
+ }
2907
2968
  }
2908
2969
  action.stop();
2909
2970
  });
@@ -2931,7 +2992,7 @@ class BasicFormComponent {
2931
2992
  /**
2932
2993
  * Manejadores de eventos para validaciones sobre campos
2933
2994
  */
2934
- addFieldInputValidation(codes, callback, properties = null) {
2995
+ onFieldInput(codes, callback, properties = null) {
2935
2996
  const fieldSet = (Array.isArray(codes)) ? codes : (codes ? [codes] : []);
2936
2997
  fieldSet.forEach((fieldCode) => {
2937
2998
  if (!this._fieldInputValidation[fieldCode]) {
@@ -2940,7 +3001,7 @@ class BasicFormComponent {
2940
3001
  this._fieldInputValidation[fieldCode].push({ callback, properties });
2941
3002
  });
2942
3003
  }
2943
- addFieldValidationStart(codes, callback, properties = null) {
3004
+ onFieldValidationStart(codes, callback, properties = null) {
2944
3005
  const fieldSet = (Array.isArray(codes)) ? codes : (codes ? [codes] : []);
2945
3006
  fieldSet.forEach((fieldCode) => {
2946
3007
  if (!this._fieldValidationsStart[fieldCode]) {
@@ -2949,7 +3010,7 @@ class BasicFormComponent {
2949
3010
  this._fieldValidationsStart[fieldCode].push({ callback, properties });
2950
3011
  });
2951
3012
  }
2952
- addFieldValidationFinish(codes, callback, properties = null) {
3013
+ onFieldValidationFinish(codes, callback, properties = null) {
2953
3014
  const fieldSet = (Array.isArray(codes)) ? codes : (codes ? [codes] : []);
2954
3015
  fieldSet.forEach((fieldCode) => {
2955
3016
  if (!this._fieldValidationsFinish[fieldCode]) {
@@ -3010,6 +3071,9 @@ class BasicFormComponent {
3010
3071
  ? this.getField(inputField) : inputField;
3011
3072
  let serverError = false;
3012
3073
  let validationResult = true;
3074
+ if (!fieldObj) {
3075
+ return;
3076
+ }
3013
3077
  if (fieldObj.backend) {
3014
3078
  fieldObj.validating = true;
3015
3079
  validationResult = yield this
@@ -3018,9 +3082,12 @@ class BasicFormComponent {
3018
3082
  }
3019
3083
  yield this.finishFieldValidation(fieldObj, validationResult, serverError);
3020
3084
  if (serverError) {
3021
- fieldObj.setErrorCode(this.errorCode);
3022
- fieldObj.setErrorMessage(this.errorMessage);
3023
- this.displayValidationServerError();
3085
+ fieldObj === null || fieldObj === void 0 ? void 0 : fieldObj.setErrorCode(this.errorCode);
3086
+ fieldObj === null || fieldObj === void 0 ? void 0 : fieldObj.setErrorMessage(this.errorMessage);
3087
+ for (let index = 0; index < this._fieldServerError.length; index++) {
3088
+ const { callback, properties } = this._fieldServerError[index];
3089
+ callback(fieldObj);
3090
+ }
3024
3091
  }
3025
3092
  fieldObj.validating = false;
3026
3093
  });
@@ -3050,7 +3117,7 @@ class BasicFormComponent {
3050
3117
  /**
3051
3118
  * Manejadores de eventos para acciones sobre Tablas
3052
3119
  */
3053
- addTableActionStart(code, actionCode, callback, properties = null) {
3120
+ onTableActionStart(code, actionCode, callback, properties = null) {
3054
3121
  const tableObject = this.getTable(code);
3055
3122
  if (!tableObject) {
3056
3123
  return;
@@ -3072,7 +3139,7 @@ class BasicFormComponent {
3072
3139
  }
3073
3140
  tableEventHandlers[actionCode].push({ callback, properties });
3074
3141
  }
3075
- addTableActionFinish(code, actionCode, callback, properties = null) {
3142
+ onTableActionFinish(code, actionCode, callback, properties = null) {
3076
3143
  const tableObject = this.getTable(code);
3077
3144
  if (!tableObject) {
3078
3145
  return;
@@ -3094,7 +3161,7 @@ class BasicFormComponent {
3094
3161
  }
3095
3162
  tableEventHandlers[actionCode].push({ callback, properties });
3096
3163
  }
3097
- addTableSelectionStart(code, callback, properties = null) {
3164
+ onTableSelectionStart(code, callback, properties = null) {
3098
3165
  const tableObject = this.getTable(code);
3099
3166
  if (!tableObject) {
3100
3167
  return;
@@ -3109,7 +3176,7 @@ class BasicFormComponent {
3109
3176
  }
3110
3177
  tableEventHandlers.push({ callback, properties });
3111
3178
  }
3112
- addTableSelectionFinish(code, callback, properties = null) {
3179
+ onTableSelectionFinish(code, callback, properties = null) {
3113
3180
  const tableObject = this.getTable(code);
3114
3181
  if (!tableObject) {
3115
3182
  return;
@@ -3124,7 +3191,7 @@ class BasicFormComponent {
3124
3191
  }
3125
3192
  tableEventHandlers.push({ callback, properties });
3126
3193
  }
3127
- addTableGetDataStart(code, callback, properties = null) {
3194
+ onTableGetDataStart(code, callback, properties = null) {
3128
3195
  const tableObject = this.getTable(code);
3129
3196
  if (!tableObject) {
3130
3197
  return;
@@ -3139,7 +3206,7 @@ class BasicFormComponent {
3139
3206
  }
3140
3207
  tableEventHandlers.push({ callback, properties });
3141
3208
  }
3142
- addTableGetDataFinish(code, callback, properties = null) {
3209
+ onTableGetDataFinish(code, callback, properties = null) {
3143
3210
  const tableObject = this.getTable(code);
3144
3211
  if (!tableObject) {
3145
3212
  return;
@@ -3214,7 +3281,10 @@ class BasicFormComponent {
3214
3281
  action.newState && this.changeState(action.newState);
3215
3282
  }
3216
3283
  else {
3217
- this.displayTableServerError();
3284
+ for (let index = 0; index < this._tableServerError.length; index++) {
3285
+ const { callback, properties } = this._tableServerError[index];
3286
+ callback(tableObject);
3287
+ }
3218
3288
  }
3219
3289
  tableObject.freeWaiting();
3220
3290
  });
@@ -3563,6 +3633,7 @@ class BasicFormComponent {
3563
3633
  return (numErrors === 0);
3564
3634
  }
3565
3635
  validateSectionConsistency(sectionCode, reqFieldMessage) {
3636
+ var _a, _b;
3566
3637
  this.resetError();
3567
3638
  const completeFields = this.checkSectionRequiredFields(sectionCode, reqFieldMessage);
3568
3639
  if (!completeFields) {
@@ -3570,8 +3641,8 @@ class BasicFormComponent {
3570
3641
  return false;
3571
3642
  }
3572
3643
  let validationError = false;
3573
- const requiredEmptyFields = this.getRequiredEmptyFields(null, sectionCode);
3574
- if (requiredEmptyFields.length > 0) {
3644
+ const requiredEmptyFields = (_a = this.getRequiredEmptyFields(null, sectionCode)) !== null && _a !== void 0 ? _a : [];
3645
+ if ((requiredEmptyFields === null || requiredEmptyFields === void 0 ? void 0 : requiredEmptyFields.length) > 0) {
3575
3646
  validationError = true;
3576
3647
  this.setError(this.formConfig.formStandardErrors.typeWarning, this.formConfig.formStandardErrors.validationTitle, this.formConfig.formStandardErrors.requiredFields);
3577
3648
  this.tagFieldsWithError(this.formConfig.formStandardErrors.requiredField, requiredEmptyFields);
@@ -3581,13 +3652,15 @@ class BasicFormComponent {
3581
3652
  break;
3582
3653
  }
3583
3654
  }
3584
- const validationIssueFields = this.getFieldsWithValidationIssues(null, sectionCode);
3655
+ const validationIssueFields = (_b = this.getFieldsWithValidationIssues(null, sectionCode)) !== null && _b !== void 0 ? _b : [];
3585
3656
  if (!validationError && validationIssueFields.length > 0) {
3586
3657
  validationError = true;
3587
3658
  this.setError(this.formConfig.formStandardErrors.typeWarning, this.formConfig.formStandardErrors.validationTitle, this.formConfig.formStandardErrors.validationFields);
3588
3659
  for (const fieldCode of validationIssueFields) {
3589
3660
  const validationIssueField = this.getField(fieldCode);
3590
- validationIssueField.focus();
3661
+ if (validationIssueField) {
3662
+ validationIssueField.focus();
3663
+ }
3591
3664
  break;
3592
3665
  }
3593
3666
  }
@@ -3596,14 +3669,59 @@ class BasicFormComponent {
3596
3669
  copyTableRecordToFields(tableObj, mappingTable = null) {
3597
3670
  var _a, _b;
3598
3671
  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);
3672
+ const tableRecord = tableObject === null || tableObject === void 0 ? void 0 : tableObject.getTableRecord(tableObj.recordId);
3673
+ const columnNames = tableObject === null || tableObject === void 0 ? void 0 : tableObject.columnNames;
3674
+ if (tableRecord && columnNames) {
3675
+ for (const columnName of columnNames) {
3676
+ const columnValue = (_a = tableRecord.getFieldValue(columnName)) !== null && _a !== void 0 ? _a : '';
3677
+ const fieldCode = (_b = mappingTable === null || mappingTable === void 0 ? void 0 : mappingTable[columnName]) !== null && _b !== void 0 ? _b : columnName;
3678
+ this.setFieldValue(fieldCode, columnValue);
3679
+ }
3680
+ return true;
3605
3681
  }
3606
- return true;
3682
+ return false;
3683
+ }
3684
+ /**
3685
+ * Métodos Legacy de compatibilidad hacia atrás
3686
+ */
3687
+ addSectionActivation(codes, callback, properties = null) {
3688
+ return this.onSectionActivation(codes, callback, properties);
3689
+ }
3690
+ addSectionInactivation(codes, callback, properties = null) {
3691
+ return this.onSectionInactivation(codes, callback, properties);
3692
+ }
3693
+ addActionMethodStart(codes, callback, properties = null) {
3694
+ return this.onActionStart(codes, callback, properties);
3695
+ }
3696
+ addActionMethodFinish(codes, callback, properties = null) {
3697
+ return this.onActionFinish(codes, callback, properties);
3698
+ }
3699
+ addFieldInputValidation(codes, callback, properties = null) {
3700
+ return this.onFieldInput(codes, callback, properties);
3701
+ }
3702
+ addFieldValidationStart(codes, callback, properties = null) {
3703
+ return this.onFieldValidationStart(codes, callback, properties);
3704
+ }
3705
+ addFieldValidationFinish(codes, callback, properties = null) {
3706
+ return this.onFieldValidationFinish(codes, callback, properties);
3707
+ }
3708
+ addTableActionStart(code, actionCode, callback, properties = null) {
3709
+ return this.onTableActionStart(code, actionCode, callback, properties);
3710
+ }
3711
+ addTableActionFinish(code, actionCode, callback, properties = null) {
3712
+ return this.onTableActionFinish(code, actionCode, callback, properties);
3713
+ }
3714
+ addTableSelectionStart(code, callback, properties = null) {
3715
+ return this.onTableSelectionStart(code, callback, properties);
3716
+ }
3717
+ addTableSelectionFinish(code, callback, properties = null) {
3718
+ return this.onTableSelectionFinish(code, callback, properties);
3719
+ }
3720
+ addTableGetDataStart(code, callback, properties = null) {
3721
+ return this.onTableGetDataStart(code, callback, properties);
3722
+ }
3723
+ addTableGetDataFinish(code, callback, properties = null) {
3724
+ return this.onTableGetDataFinish(code, callback, properties);
3607
3725
  }
3608
3726
  }
3609
3727
  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 });