tuain-ng-forms-lib 12.0.11 → 12.0.15

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.
package/README.md CHANGED
@@ -80,7 +80,7 @@ This component allows to receive the following information
80
80
  | --- | ----------- |
81
81
  | actionObjec | Defines the action object of the form |
82
82
  | currentMode | Defines the current state of the form in order to define if the element can be visible or actionable |
83
- | formBusy | Defines in the form is makinh an exclusive process that prevents the action execution |
83
+ | busy | Defines in the form is makinh an exclusive process that prevents the action execution |
84
84
  | relatedField | Describe the field object related with this action |
85
85
  | style | Define a style attribute for the action |
86
86
  | showLabel | Define if the action shows it's label
@@ -21,18 +21,30 @@
21
21
  this.actionObject.notifyActivation();
22
22
  }
23
23
  };
24
- Object.defineProperty(ActionComponent.prototype, "isVisible", {
24
+ ActionComponent.prototype.visibleOnRestriction = function () {
25
+ var _a, _b, _c, _d, _e;
26
+ if (!((_a = this.actionObject) === null || _a === void 0 ? void 0 : _a.restrictedOnField)) {
27
+ return true;
28
+ }
29
+ if ((((_b = this.actionObject) === null || _b === void 0 ? void 0 : _b.restrictedOnOperator) === '=='
30
+ && this.relatedField === ((_c = this.actionObject) === null || _c === void 0 ? void 0 : _c.restrictedOnValue))
31
+ || (((_d = this.actionObject) === null || _d === void 0 ? void 0 : _d.restrictedOnOperator) === '!='
32
+ && this.relatedField !== ((_e = this.actionObject) === null || _e === void 0 ? void 0 : _e.restrictedOnValue))) {
33
+ return true;
34
+ }
35
+ };
36
+ Object.defineProperty(ActionComponent.prototype, "visible", {
25
37
  get: function () {
26
- var _a, _b, _c, _d, _e;
27
- if (!((_a = this.actionObject) === null || _a === void 0 ? void 0 : _a.restrictedOnField)) {
28
- return true;
29
- }
30
- if ((((_b = this.actionObject) === null || _b === void 0 ? void 0 : _b.restrictedOnOperator) === '=='
31
- && this.relatedField === ((_c = this.actionObject) === null || _c === void 0 ? void 0 : _c.restrictedOnValue))
32
- || (((_d = this.actionObject) === null || _d === void 0 ? void 0 : _d.restrictedOnOperator) === '!='
33
- && this.relatedField !== ((_e = this.actionObject) === null || _e === void 0 ? void 0 : _e.restrictedOnValue))) {
34
- return true;
35
- }
38
+ var _a;
39
+ return ((_a = this.actionObject) === null || _a === void 0 ? void 0 : _a.visibleOn(this.currentState)) && this.visibleOnRestriction();
40
+ },
41
+ enumerable: false,
42
+ configurable: true
43
+ });
44
+ Object.defineProperty(ActionComponent.prototype, "disabled", {
45
+ get: function () {
46
+ var _a;
47
+ return !((_a = this.actionObject) === null || _a === void 0 ? void 0 : _a.enabledOn(this.currentState));
36
48
  },
37
49
  enumerable: false,
38
50
  configurable: true
@@ -47,9 +59,9 @@
47
59
  ];
48
60
  ActionComponent.propDecorators = {
49
61
  actionObject: [{ type: core.Input }],
50
- disabled: [{ type: core.Input }],
51
- formBusy: [{ type: core.Input }],
62
+ busy: [{ type: core.Input }],
52
63
  relatedField: [{ type: core.Input }],
64
+ currentState: [{ type: core.Input }],
53
65
  style: [{ type: core.Input }],
54
66
  showLabel: [{ type: core.Input }]
55
67
  };
@@ -384,8 +396,14 @@
384
396
  // Inicialización
385
397
  var mapping = Object.entries(this.formConfig.componentFieldAttrMap);
386
398
  for (var index = 0; index < mapping.length; index++) {
387
- var _c = __read(mapping[index], 2), fieldAttr = _c[0], compAttr = _c[1];
388
- this[compAttr.toString()] = (_b = this.fieldObject) === null || _b === void 0 ? void 0 : _b[fieldAttr.toString()];
399
+ var _c = __read(mapping[index], 2), fieldAttr = _c[0], compAttr1 = _c[1];
400
+ var compAttr = compAttr1.toString();
401
+ if (compAttr === VALUE) {
402
+ this.updateValue();
403
+ }
404
+ else {
405
+ this[compAttr] = (_b = this.fieldObject) === null || _b === void 0 ? void 0 : _b[fieldAttr.toString()];
406
+ }
389
407
  }
390
408
  // Subscripción a cambios en atributos
391
409
  this.fieldObject.attributeChange.subscribe(function (event) {
@@ -394,7 +412,7 @@
394
412
  if (compAttr === VALUE) {
395
413
  _this.updateValue();
396
414
  }
397
- else if (_this.hasOwnProperty(compAttr)) {
415
+ else {
398
416
  _this[compAttr] = value;
399
417
  }
400
418
  });
@@ -421,6 +439,22 @@
421
439
  var k = event.charCode;
422
440
  return (k > 47 && k < 58);
423
441
  };
442
+ Object.defineProperty(FieldComponent.prototype, "visible", {
443
+ get: function () {
444
+ var _a;
445
+ return (_a = this.fieldObject) === null || _a === void 0 ? void 0 : _a.visibleOn(this.currentState);
446
+ },
447
+ enumerable: false,
448
+ configurable: true
449
+ });
450
+ Object.defineProperty(FieldComponent.prototype, "disabled", {
451
+ get: function () {
452
+ var _a;
453
+ return !((_a = this.fieldObject) === null || _a === void 0 ? void 0 : _a.enabledOn(this.currentState));
454
+ },
455
+ enumerable: false,
456
+ configurable: true
457
+ });
424
458
  return FieldComponent;
425
459
  }());
426
460
  FieldComponent.decorators = [
@@ -431,7 +465,7 @@
431
465
  ];
432
466
  FieldComponent.propDecorators = {
433
467
  fieldObject: [{ type: core.Input }],
434
- disabled: [{ type: core.Input }]
468
+ currentState: [{ type: core.Input }]
435
469
  };
436
470
 
437
471
  var ElementComponent = /** @class */ (function () {
@@ -445,18 +479,16 @@
445
479
  ElementComponent.prototype.start = function () { };
446
480
  Object.defineProperty(ElementComponent.prototype, "visible", {
447
481
  get: function () {
448
- var _a, _b, _c, _d;
449
- var visible = (_b = (_a = this.formElement) === null || _a === void 0 ? void 0 : _a.visible) !== null && _b !== void 0 ? _b : true;
450
- return visible && ((_c = this.formElement) === null || _c === void 0 ? void 0 : _c.viewOnState((_d = this.formManager) === null || _d === void 0 ? void 0 : _d.currentState));
482
+ var _a, _b;
483
+ return (_a = this.formElement) === null || _a === void 0 ? void 0 : _a.visibleOn((_b = this.formManager) === null || _b === void 0 ? void 0 : _b.currentState);
451
484
  },
452
485
  enumerable: false,
453
486
  configurable: true
454
487
  });
455
488
  Object.defineProperty(ElementComponent.prototype, "disabled", {
456
489
  get: function () {
457
- var _a, _b, _c, _d;
458
- var disabled = (_b = (_a = this.formElement) === null || _a === void 0 ? void 0 : _a.disabled) !== null && _b !== void 0 ? _b : false;
459
- return disabled || !((_c = this.formElement) === null || _c === void 0 ? void 0 : _c.enabledOnState((_d = this.formManager) === null || _d === void 0 ? void 0 : _d.currentState));
490
+ var _a, _b;
491
+ return !((_a = this.formElement) === null || _a === void 0 ? void 0 : _a.enabledOn((_b = this.formManager) === null || _b === void 0 ? void 0 : _b.currentState));
460
492
  },
461
493
  enumerable: false,
462
494
  configurable: true
@@ -638,6 +670,12 @@
638
670
  enumerable: false,
639
671
  configurable: true
640
672
  });
673
+ FormElement.prototype.visibleOn = function (state) {
674
+ return this.visible && this.viewOnState(state);
675
+ };
676
+ FormElement.prototype.enabledOn = function (state) {
677
+ return !this.disabled && this.enabledOnState(state);
678
+ };
641
679
  FormElement.prototype.setVisibility = function (visible, forced) {
642
680
  if (forced === void 0) { forced = null; }
643
681
  this._visible = visible && true;
@@ -2601,7 +2639,7 @@
2601
2639
  return (section) ? section.getSubsection(subsectionCode) : null;
2602
2640
  };
2603
2641
  Object.defineProperty(FormStructureAndData.prototype, "actions", {
2604
- get: function () { return this.getActions(); },
2642
+ get: function () { return this._actionsObj; },
2605
2643
  enumerable: false,
2606
2644
  configurable: true
2607
2645
  });
@@ -2790,7 +2828,7 @@
2790
2828
  actionNames.forEach(function (actionCode) { return _this.disableAction(actionCode); });
2791
2829
  };
2792
2830
  Object.defineProperty(FormStructureAndData.prototype, "fields", {
2793
- get: function () { return this.getFields(); },
2831
+ get: function () { return this._fieldsObj; },
2794
2832
  enumerable: false,
2795
2833
  configurable: true
2796
2834
  });
@@ -3255,7 +3293,7 @@
3255
3293
  this.extraData = {};
3256
3294
  this.definitionObtained = false;
3257
3295
  this.formVisible = false;
3258
- this.inServerProcess = false;
3296
+ this.busy = false;
3259
3297
  this.formSectionsActivate = {};
3260
3298
  this.formSectionsInactivate = {};
3261
3299
  this.formActionsStart = {};
@@ -3274,6 +3312,11 @@
3274
3312
  this.cleanStart();
3275
3313
  this.customPreProcessing();
3276
3314
  }
3315
+ Object.defineProperty(BasicFormComponent.prototype, "inServerProcess", {
3316
+ get: function () { return this.busy; },
3317
+ enumerable: false,
3318
+ configurable: true
3319
+ });
3277
3320
  BasicFormComponent.prototype.setConfig = function (formConfig) {
3278
3321
  this.formConfig = formConfig;
3279
3322
  };
@@ -3290,7 +3333,7 @@
3290
3333
  this.definitionObtained = false;
3291
3334
  // Se limpian los manejadores de eventos
3292
3335
  this.formVisible = false;
3293
- this.inServerProcess = false;
3336
+ this.busy = false;
3294
3337
  this.formSectionsActivate = {};
3295
3338
  this.formSectionsInactivate = {};
3296
3339
  this.formActionsStart = {};
@@ -3305,6 +3348,11 @@
3305
3348
  this.tableGetDataStart = {};
3306
3349
  this.tableGetDataFinish = {};
3307
3350
  };
3351
+ Object.defineProperty(BasicFormComponent.prototype, "form", {
3352
+ get: function () { return this.formStructure; },
3353
+ enumerable: false,
3354
+ configurable: true
3355
+ });
3308
3356
  Object.defineProperty(BasicFormComponent.prototype, "currentState", {
3309
3357
  get: function () { return this.formStructure.state; },
3310
3358
  set: function (state) { this.formStructure.changeState(state); },
@@ -3592,11 +3640,11 @@
3592
3640
  return [2 /*return*/];
3593
3641
  }
3594
3642
  if (!!this.definitionObtained) return [3 /*break*/, 2];
3595
- this.inServerProcess = true;
3643
+ this.busy = true;
3596
3644
  return [4 /*yield*/, this.formManagerService.getFormDefinition(this.name)];
3597
3645
  case 1:
3598
3646
  formDefinition = _j.sent();
3599
- this.inServerProcess = false;
3647
+ this.busy = false;
3600
3648
  this.formStructure = new FormStructureAndData(formDefinition, this.formConfig);
3601
3649
  this.fields = this.formStructure.fields;
3602
3650
  this.actions = this.formStructure.actions;
@@ -3665,11 +3713,11 @@
3665
3713
  this.errorCode = NO_ERROR;
3666
3714
  this.errorMessage = '';
3667
3715
  this.errorDetail = '';
3668
- this.inServerProcess = true;
3716
+ this.busy = true;
3669
3717
  return [4 /*yield*/, this.formManagerService.execServerAction(actionDetail)];
3670
3718
  case 1:
3671
3719
  formActionResponse = _j.sent();
3672
- this.inServerProcess = false;
3720
+ this.busy = false;
3673
3721
  if (formActionResponse && formActionResponse.error.errorType) {
3674
3722
  console.log('Excepción no soportada');
3675
3723
  }
@@ -3689,7 +3737,7 @@
3689
3737
  BasicFormComponent.prototype.updateFormWithServerData = function (formContent) {
3690
3738
  var e_1, _j, e_2, _k, e_3, _l;
3691
3739
  var currentMode = formContent.currentMode, formSubject = formContent.formSubject, actions = formContent.actions, fields = formContent.fields, recordTables = formContent.recordTables, returnedFile = formContent.returnedFile, immutableData = formContent.immutableData, extraInfo = formContent.extraInfo;
3692
- this.changeState(currentMode !== null && currentMode !== void 0 ? currentMode : this.formStructure.state);
3740
+ currentMode && this.changeState(currentMode);
3693
3741
  if (formSubject) {
3694
3742
  this.formSubject = formSubject;
3695
3743
  }
@@ -3921,7 +3969,7 @@
3921
3969
  return [4 /*yield*/, this.finishAction(action, actionResult)];
3922
3970
  case 3:
3923
3971
  _j.sent();
3924
- this.changeState(action.newState);
3972
+ action.newState && this.changeState(action.newState);
3925
3973
  return [3 /*break*/, 5];
3926
3974
  case 4:
3927
3975
  this.displayActionServerError();
@@ -4353,7 +4401,7 @@
4353
4401
  return [4 /*yield*/, this.finishTableGlobalAction(tableActionDetail, actionResult)];
4354
4402
  case 3:
4355
4403
  _j.sent();
4356
- this.changeState(action.newState);
4404
+ action.newState && this.changeState(action.newState);
4357
4405
  return [3 /*break*/, 5];
4358
4406
  case 4:
4359
4407
  this.displayTableServerError();
@@ -4488,7 +4536,7 @@
4488
4536
  case 2:
4489
4537
  if (finish) {
4490
4538
  this.finishTableAction(tableActionDetail, actionResult);
4491
- this.changeState(action.newState);
4539
+ action.newState && this.changeState(action.newState);
4492
4540
  }
4493
4541
  else {
4494
4542
  this.displayTableServerError();
@@ -4748,7 +4796,7 @@
4748
4796
  case 2:
4749
4797
  if (finish) {
4750
4798
  this.finishTableSelectionAction(tableActionDetail, actionResult);
4751
- this.changeState(action.newState);
4799
+ action.newState && this.changeState(action.newState);
4752
4800
  }
4753
4801
  else {
4754
4802
  this.displayTableServerError();