tuain-ng-forms-lib 12.0.9 → 12.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.
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 if (this.hasOwnProperty(compAttr)) {
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) {
@@ -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;
@@ -2318,7 +2356,7 @@
2318
2356
  }
2319
2357
  break;
2320
2358
  case this._formConfig.fieldTypes.currency:
2321
- newFinalValue = formatCurrency(this._fieldValue);
2359
+ newFinalValue = formatCurrency(newValue);
2322
2360
  break;
2323
2361
  default:
2324
2362
  newFinalValue = newValue;
@@ -2600,6 +2638,11 @@
2600
2638
  ? this._sectionsObj[sectionCode] : null;
2601
2639
  return (section) ? section.getSubsection(subsectionCode) : null;
2602
2640
  };
2641
+ Object.defineProperty(FormStructureAndData.prototype, "actions", {
2642
+ get: function () { return this._actionsObj; },
2643
+ enumerable: false,
2644
+ configurable: true
2645
+ });
2603
2646
  FormStructureAndData.prototype.getSection = function (sectionCode) {
2604
2647
  return (this._sectionsObj && this._sectionsObj[sectionCode])
2605
2648
  ? this._sectionsObj[sectionCode] : null;
@@ -2784,6 +2827,11 @@
2784
2827
  var actionNames = (Array.isArray(actionArray)) ? actionArray : [actionArray];
2785
2828
  actionNames.forEach(function (actionCode) { return _this.disableAction(actionCode); });
2786
2829
  };
2830
+ Object.defineProperty(FormStructureAndData.prototype, "fields", {
2831
+ get: function () { return this._fieldsObj; },
2832
+ enumerable: false,
2833
+ configurable: true
2834
+ });
2787
2835
  FormStructureAndData.prototype.enableField = function (fieldCode) {
2788
2836
  var fieldObject = this.getFieldObject(fieldCode);
2789
2837
  return (fieldObject) ? fieldObject.enable() : null;
@@ -3273,6 +3321,8 @@
3273
3321
  this.errorMessage = '';
3274
3322
  this.errorDetail = '';
3275
3323
  this.formStructure = null;
3324
+ this.fields = null;
3325
+ this.actions = null;
3276
3326
  this.controlToken = null;
3277
3327
  this.inputDataFields = {};
3278
3328
  this.definitionObtained = false;
@@ -3293,6 +3343,11 @@
3293
3343
  this.tableGetDataStart = {};
3294
3344
  this.tableGetDataFinish = {};
3295
3345
  };
3346
+ Object.defineProperty(BasicFormComponent.prototype, "form", {
3347
+ get: function () { return this.formStructure; },
3348
+ enumerable: false,
3349
+ configurable: true
3350
+ });
3296
3351
  Object.defineProperty(BasicFormComponent.prototype, "currentState", {
3297
3352
  get: function () { return this.formStructure.state; },
3298
3353
  set: function (state) { this.formStructure.changeState(state); },
@@ -3586,6 +3641,8 @@
3586
3641
  formDefinition = _j.sent();
3587
3642
  this.inServerProcess = false;
3588
3643
  this.formStructure = new FormStructureAndData(formDefinition, this.formConfig);
3644
+ this.fields = this.formStructure.fields;
3645
+ this.actions = this.formStructure.actions;
3589
3646
  this.definitionObtained = true;
3590
3647
  return [3 /*break*/, 3];
3591
3648
  case 2:
@@ -3675,7 +3732,7 @@
3675
3732
  BasicFormComponent.prototype.updateFormWithServerData = function (formContent) {
3676
3733
  var e_1, _j, e_2, _k, e_3, _l;
3677
3734
  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;
3678
- this.changeState(currentMode !== null && currentMode !== void 0 ? currentMode : this.formStructure.state);
3735
+ currentMode && this.changeState(currentMode);
3679
3736
  if (formSubject) {
3680
3737
  this.formSubject = formSubject;
3681
3738
  }
@@ -3907,7 +3964,7 @@
3907
3964
  return [4 /*yield*/, this.finishAction(action, actionResult)];
3908
3965
  case 3:
3909
3966
  _j.sent();
3910
- this.changeState(action.newState);
3967
+ action.newState && this.changeState(action.newState);
3911
3968
  return [3 /*break*/, 5];
3912
3969
  case 4:
3913
3970
  this.displayActionServerError();
@@ -4339,7 +4396,7 @@
4339
4396
  return [4 /*yield*/, this.finishTableGlobalAction(tableActionDetail, actionResult)];
4340
4397
  case 3:
4341
4398
  _j.sent();
4342
- this.changeState(action.newState);
4399
+ action.newState && this.changeState(action.newState);
4343
4400
  return [3 /*break*/, 5];
4344
4401
  case 4:
4345
4402
  this.displayTableServerError();
@@ -4474,7 +4531,7 @@
4474
4531
  case 2:
4475
4532
  if (finish) {
4476
4533
  this.finishTableAction(tableActionDetail, actionResult);
4477
- this.changeState(action.newState);
4534
+ action.newState && this.changeState(action.newState);
4478
4535
  }
4479
4536
  else {
4480
4537
  this.displayTableServerError();
@@ -4734,7 +4791,7 @@
4734
4791
  case 2:
4735
4792
  if (finish) {
4736
4793
  this.finishTableSelectionAction(tableActionDetail, actionResult);
4737
- this.changeState(action.newState);
4794
+ action.newState && this.changeState(action.newState);
4738
4795
  }
4739
4796
  else {
4740
4797
  this.displayTableServerError();