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.
@@ -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,7 +1894,7 @@ class FormStructureAndData {
1868
1894
  ? this._sectionsObj[sectionCode] : null;
1869
1895
  return (section) ? section.getSubsection(subsectionCode) : null;
1870
1896
  }
1871
- get actions() { return this.getActions(); }
1897
+ get actions() { return this._actionsObj; }
1872
1898
  getSection(sectionCode) {
1873
1899
  return (this._sectionsObj && this._sectionsObj[sectionCode])
1874
1900
  ? this._sectionsObj[sectionCode] : null;
@@ -2000,7 +2026,7 @@ class FormStructureAndData {
2000
2026
  const actionNames = (Array.isArray(actionArray)) ? actionArray : [actionArray];
2001
2027
  actionNames.forEach(actionCode => this.disableAction(actionCode));
2002
2028
  }
2003
- get fields() { return this.getFields(); }
2029
+ get fields() { return this._fieldsObj; }
2004
2030
  enableField(fieldCode) {
2005
2031
  const fieldObject = this.getFieldObject(fieldCode);
2006
2032
  return (fieldObject) ? fieldObject.enable() : null;
@@ -2353,7 +2379,7 @@ class BasicFormComponent {
2353
2379
  this.extraData = {};
2354
2380
  this.definitionObtained = false;
2355
2381
  this.formVisible = false;
2356
- this.inServerProcess = false;
2382
+ this.busy = false;
2357
2383
  this.formSectionsActivate = {};
2358
2384
  this.formSectionsInactivate = {};
2359
2385
  this.formActionsStart = {};
@@ -2372,6 +2398,7 @@ class BasicFormComponent {
2372
2398
  this.cleanStart();
2373
2399
  this.customPreProcessing();
2374
2400
  }
2401
+ get inServerProcess() { return this.busy; }
2375
2402
  setConfig(formConfig) {
2376
2403
  this.formConfig = formConfig;
2377
2404
  }
@@ -2388,7 +2415,7 @@ class BasicFormComponent {
2388
2415
  this.definitionObtained = false;
2389
2416
  // Se limpian los manejadores de eventos
2390
2417
  this.formVisible = false;
2391
- this.inServerProcess = false;
2418
+ this.busy = false;
2392
2419
  this.formSectionsActivate = {};
2393
2420
  this.formSectionsInactivate = {};
2394
2421
  this.formActionsStart = {};
@@ -2403,6 +2430,7 @@ class BasicFormComponent {
2403
2430
  this.tableGetDataStart = {};
2404
2431
  this.tableGetDataFinish = {};
2405
2432
  }
2433
+ get form() { return this.formStructure; }
2406
2434
  get currentState() { return this.formStructure.state; }
2407
2435
  set currentState(state) { this.formStructure.changeState(state); }
2408
2436
  get currentMode() { return this.currentState; }
@@ -2644,9 +2672,9 @@ class BasicFormComponent {
2644
2672
  return;
2645
2673
  }
2646
2674
  if (!this.definitionObtained) {
2647
- this.inServerProcess = true;
2675
+ this.busy = true;
2648
2676
  const formDefinition = yield this.formManagerService.getFormDefinition(this.name);
2649
- this.inServerProcess = false;
2677
+ this.busy = false;
2650
2678
  this.formStructure = new FormStructureAndData(formDefinition, this.formConfig);
2651
2679
  this.fields = this.formStructure.fields;
2652
2680
  this.actions = this.formStructure.actions;
@@ -2704,9 +2732,9 @@ class BasicFormComponent {
2704
2732
  this.errorCode = NO_ERROR;
2705
2733
  this.errorMessage = '';
2706
2734
  this.errorDetail = '';
2707
- this.inServerProcess = true;
2735
+ this.busy = true;
2708
2736
  const formActionResponse = yield this.formManagerService.execServerAction(actionDetail);
2709
- this.inServerProcess = false;
2737
+ this.busy = false;
2710
2738
  if (formActionResponse && formActionResponse.error.errorType) {
2711
2739
  console.log('Excepción no soportada');
2712
2740
  }
@@ -2723,7 +2751,7 @@ class BasicFormComponent {
2723
2751
  }
2724
2752
  updateFormWithServerData(formContent) {
2725
2753
  const { currentMode, formSubject, actions, fields, recordTables, returnedFile, immutableData, extraInfo, } = formContent;
2726
- this.changeState(currentMode !== null && currentMode !== void 0 ? currentMode : this.formStructure.state);
2754
+ currentMode && this.changeState(currentMode);
2727
2755
  if (formSubject) {
2728
2756
  this.formSubject = formSubject;
2729
2757
  }
@@ -2861,7 +2889,7 @@ class BasicFormComponent {
2861
2889
  }
2862
2890
  if (finish) {
2863
2891
  yield this.finishAction(action, actionResult);
2864
- this.changeState(action.newState);
2892
+ action.newState && this.changeState(action.newState);
2865
2893
  }
2866
2894
  else {
2867
2895
  this.displayActionServerError();
@@ -3158,7 +3186,7 @@ class BasicFormComponent {
3158
3186
  }
3159
3187
  if (finish) {
3160
3188
  yield this.finishTableGlobalAction(tableActionDetail, actionResult);
3161
- this.changeState(action.newState);
3189
+ action.newState && this.changeState(action.newState);
3162
3190
  }
3163
3191
  else {
3164
3192
  this.displayTableServerError();
@@ -3241,7 +3269,7 @@ class BasicFormComponent {
3241
3269
  }
3242
3270
  if (finish) {
3243
3271
  this.finishTableAction(tableActionDetail, actionResult);
3244
- this.changeState(action.newState);
3272
+ action.newState && this.changeState(action.newState);
3245
3273
  }
3246
3274
  else {
3247
3275
  this.displayTableServerError();
@@ -3399,7 +3427,7 @@ class BasicFormComponent {
3399
3427
  }
3400
3428
  if (finish) {
3401
3429
  this.finishTableSelectionAction(tableActionDetail, actionResult);
3402
- this.changeState(action.newState);
3430
+ action.newState && this.changeState(action.newState);
3403
3431
  }
3404
3432
  else {
3405
3433
  this.displayTableServerError();