tuain-ng-forms-lib 12.0.10 → 12.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.
@@ -23,7 +23,7 @@ class ActionComponent {
23
23
  this.actionObject.notifyActivation();
24
24
  }
25
25
  }
26
- get isVisible() {
26
+ visibleOnRestriction() {
27
27
  var _a, _b, _c, _d, _e;
28
28
  if (!((_a = this.actionObject) === null || _a === void 0 ? void 0 : _a.restrictedOnField)) {
29
29
  return true;
@@ -35,6 +35,14 @@ class ActionComponent {
35
35
  return true;
36
36
  }
37
37
  }
38
+ get visible() {
39
+ var _a;
40
+ return ((_a = this.actionObject) === null || _a === void 0 ? void 0 : _a.visibleOn(this.currentState)) && this.visibleOnRestriction();
41
+ }
42
+ get disabled() {
43
+ var _a;
44
+ return !((_a = this.actionObject) === null || _a === void 0 ? void 0 : _a.enabledOn(this.currentState));
45
+ }
38
46
  }
39
47
  ActionComponent.decorators = [
40
48
  { type: Component, args: [{
@@ -44,9 +52,9 @@ ActionComponent.decorators = [
44
52
  ];
45
53
  ActionComponent.propDecorators = {
46
54
  actionObject: [{ type: Input }],
47
- disabled: [{ type: Input }],
48
- formBusy: [{ type: Input }],
55
+ busy: [{ type: Input }],
49
56
  relatedField: [{ type: Input }],
57
+ currentState: [{ type: Input }],
50
58
  style: [{ type: Input }],
51
59
  showLabel: [{ type: Input }]
52
60
  };
@@ -60,8 +68,14 @@ class FieldComponent {
60
68
  // Inicialización
61
69
  const mapping = Object.entries(this.formConfig.componentFieldAttrMap);
62
70
  for (let index = 0; index < mapping.length; index++) {
63
- const [fieldAttr, compAttr] = mapping[index];
64
- this[compAttr.toString()] = (_b = this.fieldObject) === null || _b === void 0 ? void 0 : _b[fieldAttr.toString()];
71
+ const [fieldAttr, compAttr1] = mapping[index];
72
+ const compAttr = compAttr1.toString();
73
+ if (compAttr === VALUE) {
74
+ this.updateValue();
75
+ }
76
+ else {
77
+ this[compAttr] = (_b = this.fieldObject) === null || _b === void 0 ? void 0 : _b[fieldAttr.toString()];
78
+ }
65
79
  }
66
80
  // Subscripción a cambios en atributos
67
81
  this.fieldObject.attributeChange.subscribe(event => {
@@ -70,7 +84,7 @@ class FieldComponent {
70
84
  if (compAttr === VALUE) {
71
85
  this.updateValue();
72
86
  }
73
- else if (this.hasOwnProperty(compAttr)) {
87
+ else {
74
88
  this[compAttr] = value;
75
89
  }
76
90
  });
@@ -94,6 +108,14 @@ class FieldComponent {
94
108
  const k = event.charCode;
95
109
  return (k > 47 && k < 58);
96
110
  }
111
+ get visible() {
112
+ var _a;
113
+ return (_a = this.fieldObject) === null || _a === void 0 ? void 0 : _a.visibleOn(this.currentState);
114
+ }
115
+ get disabled() {
116
+ var _a;
117
+ return !((_a = this.fieldObject) === null || _a === void 0 ? void 0 : _a.enabledOn(this.currentState));
118
+ }
97
119
  }
98
120
  FieldComponent.decorators = [
99
121
  { type: Component, args: [{
@@ -103,7 +125,7 @@ FieldComponent.decorators = [
103
125
  ];
104
126
  FieldComponent.propDecorators = {
105
127
  fieldObject: [{ type: Input }],
106
- disabled: [{ type: Input }]
128
+ currentState: [{ type: Input }]
107
129
  };
108
130
 
109
131
  class ElementComponent {
@@ -114,14 +136,12 @@ class ElementComponent {
114
136
  }
115
137
  start() { }
116
138
  get visible() {
117
- var _a, _b, _c, _d;
118
- const visible = (_b = (_a = this.formElement) === null || _a === void 0 ? void 0 : _a.visible) !== null && _b !== void 0 ? _b : true;
119
- return visible && ((_c = this.formElement) === null || _c === void 0 ? void 0 : _c.viewOnState((_d = this.formManager) === null || _d === void 0 ? void 0 : _d.currentState));
139
+ var _a, _b;
140
+ return (_a = this.formElement) === null || _a === void 0 ? void 0 : _a.visibleOn((_b = this.formManager) === null || _b === void 0 ? void 0 : _b.currentState);
120
141
  }
121
142
  get disabled() {
122
- var _a, _b, _c, _d;
123
- const disabled = (_b = (_a = this.formElement) === null || _a === void 0 ? void 0 : _a.disabled) !== null && _b !== void 0 ? _b : false;
124
- return disabled || !((_c = this.formElement) === null || _c === void 0 ? void 0 : _c.enabledOnState((_d = this.formManager) === null || _d === void 0 ? void 0 : _d.currentState));
143
+ var _a, _b;
144
+ return !((_a = this.formElement) === null || _a === void 0 ? void 0 : _a.enabledOn((_b = this.formManager) === null || _b === void 0 ? void 0 : _b.currentState));
125
145
  }
126
146
  }
127
147
  ElementComponent.decorators = [
@@ -283,6 +303,12 @@ class FormElement {
283
303
  supportMode(state) { return this.viewOnState(state); }
284
304
  get visible() { return (this._isForced) ? this._visibleForced : this._visible; }
285
305
  set visible(visible) { this.setVisibility(visible); }
306
+ visibleOn(state) {
307
+ return this.visible && this.viewOnState(state);
308
+ }
309
+ enabledOn(state) {
310
+ return !this.disabled && this.enabledOnState(state);
311
+ }
286
312
  setVisibility(visible, forced = null) {
287
313
  this._visible = visible && true;
288
314
  if (forced != null) {
@@ -1868,6 +1894,7 @@ class FormStructureAndData {
1868
1894
  ? this._sectionsObj[sectionCode] : null;
1869
1895
  return (section) ? section.getSubsection(subsectionCode) : null;
1870
1896
  }
1897
+ get actions() { return this._actionsObj; }
1871
1898
  getSection(sectionCode) {
1872
1899
  return (this._sectionsObj && this._sectionsObj[sectionCode])
1873
1900
  ? this._sectionsObj[sectionCode] : null;
@@ -1999,6 +2026,7 @@ class FormStructureAndData {
1999
2026
  const actionNames = (Array.isArray(actionArray)) ? actionArray : [actionArray];
2000
2027
  actionNames.forEach(actionCode => this.disableAction(actionCode));
2001
2028
  }
2029
+ get fields() { return this._fieldsObj; }
2002
2030
  enableField(fieldCode) {
2003
2031
  const fieldObject = this.getFieldObject(fieldCode);
2004
2032
  return (fieldObject) ? fieldObject.enable() : null;
@@ -2379,6 +2407,8 @@ class BasicFormComponent {
2379
2407
  this.errorMessage = '';
2380
2408
  this.errorDetail = '';
2381
2409
  this.formStructure = null;
2410
+ this.fields = null;
2411
+ this.actions = null;
2382
2412
  this.controlToken = null;
2383
2413
  this.inputDataFields = {};
2384
2414
  this.definitionObtained = false;
@@ -2399,6 +2429,7 @@ class BasicFormComponent {
2399
2429
  this.tableGetDataStart = {};
2400
2430
  this.tableGetDataFinish = {};
2401
2431
  }
2432
+ get form() { return this.formStructure; }
2402
2433
  get currentState() { return this.formStructure.state; }
2403
2434
  set currentState(state) { this.formStructure.changeState(state); }
2404
2435
  get currentMode() { return this.currentState; }
@@ -2644,6 +2675,8 @@ class BasicFormComponent {
2644
2675
  const formDefinition = yield this.formManagerService.getFormDefinition(this.name);
2645
2676
  this.inServerProcess = false;
2646
2677
  this.formStructure = new FormStructureAndData(formDefinition, this.formConfig);
2678
+ this.fields = this.formStructure.fields;
2679
+ this.actions = this.formStructure.actions;
2647
2680
  this.definitionObtained = true;
2648
2681
  }
2649
2682
  else {
@@ -2717,7 +2750,7 @@ class BasicFormComponent {
2717
2750
  }
2718
2751
  updateFormWithServerData(formContent) {
2719
2752
  const { currentMode, formSubject, actions, fields, recordTables, returnedFile, immutableData, extraInfo, } = formContent;
2720
- this.changeState(currentMode !== null && currentMode !== void 0 ? currentMode : this.formStructure.state);
2753
+ currentMode && this.changeState(currentMode);
2721
2754
  if (formSubject) {
2722
2755
  this.formSubject = formSubject;
2723
2756
  }
@@ -2855,7 +2888,7 @@ class BasicFormComponent {
2855
2888
  }
2856
2889
  if (finish) {
2857
2890
  yield this.finishAction(action, actionResult);
2858
- this.changeState(action.newState);
2891
+ action.newState && this.changeState(action.newState);
2859
2892
  }
2860
2893
  else {
2861
2894
  this.displayActionServerError();
@@ -3152,7 +3185,7 @@ class BasicFormComponent {
3152
3185
  }
3153
3186
  if (finish) {
3154
3187
  yield this.finishTableGlobalAction(tableActionDetail, actionResult);
3155
- this.changeState(action.newState);
3188
+ action.newState && this.changeState(action.newState);
3156
3189
  }
3157
3190
  else {
3158
3191
  this.displayTableServerError();
@@ -3235,7 +3268,7 @@ class BasicFormComponent {
3235
3268
  }
3236
3269
  if (finish) {
3237
3270
  this.finishTableAction(tableActionDetail, actionResult);
3238
- this.changeState(action.newState);
3271
+ action.newState && this.changeState(action.newState);
3239
3272
  }
3240
3273
  else {
3241
3274
  this.displayTableServerError();
@@ -3393,7 +3426,7 @@ class BasicFormComponent {
3393
3426
  }
3394
3427
  if (finish) {
3395
3428
  this.finishTableSelectionAction(tableActionDetail, actionResult);
3396
- this.changeState(action.newState);
3429
+ action.newState && this.changeState(action.newState);
3397
3430
  }
3398
3431
  else {
3399
3432
  this.displayTableServerError();