tuain-ng-forms-lib 12.0.8 → 12.0.12

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.
@@ -51,6 +51,7 @@ ActionComponent.propDecorators = {
51
51
  showLabel: [{ type: Input }]
52
52
  };
53
53
 
54
+ const VALUE = '';
54
55
  class FieldComponent {
55
56
  ngOnInit() {
56
57
  var _a, _b;
@@ -66,13 +67,20 @@ class FieldComponent {
66
67
  this.fieldObject.attributeChange.subscribe(event => {
67
68
  const { name: fieldAttr, value } = event;
68
69
  const compAttr = this.formConfig.componentFieldAttrMap[fieldAttr];
69
- this.hasOwnProperty(compAttr) && (this[compAttr] = value);
70
+ if (compAttr === VALUE) {
71
+ this.updateValue();
72
+ }
73
+ else if (this.hasOwnProperty(compAttr)) {
74
+ this[compAttr] = value;
75
+ }
70
76
  });
71
77
  }
72
78
  this.start();
73
79
  }
74
80
  start() { }
75
81
  focus() { }
82
+ updateValue() { }
83
+ updateObject() { }
76
84
  onInputChange() {
77
85
  setTimeout(() => this.fieldObject.notifyEditionPartial(), 50);
78
86
  }
@@ -106,14 +114,12 @@ class ElementComponent {
106
114
  }
107
115
  start() { }
108
116
  get visible() {
109
- var _a, _b, _c, _d;
110
- const visible = (_b = (_a = this.formElement) === null || _a === void 0 ? void 0 : _a.visible) !== null && _b !== void 0 ? _b : true;
111
- return visible && ((_c = this.formElement) === null || _c === void 0 ? void 0 : _c.viewOnState((_d = this.formManager) === null || _d === void 0 ? void 0 : _d.currentState));
117
+ var _a, _b;
118
+ return (_a = this.formElement) === null || _a === void 0 ? void 0 : _a.visibleOn((_b = this.formManager) === null || _b === void 0 ? void 0 : _b.currentState);
112
119
  }
113
120
  get disabled() {
114
- var _a, _b, _c, _d;
115
- const disabled = (_b = (_a = this.formElement) === null || _a === void 0 ? void 0 : _a.disabled) !== null && _b !== void 0 ? _b : false;
116
- return disabled || !((_c = this.formElement) === null || _c === void 0 ? void 0 : _c.enabledOnState((_d = this.formManager) === null || _d === void 0 ? void 0 : _d.currentState));
121
+ var _a, _b;
122
+ return !((_a = this.formElement) === null || _a === void 0 ? void 0 : _a.enabledOn((_b = this.formManager) === null || _b === void 0 ? void 0 : _b.currentState));
117
123
  }
118
124
  }
119
125
  ElementComponent.decorators = [
@@ -275,6 +281,12 @@ class FormElement {
275
281
  supportMode(state) { return this.viewOnState(state); }
276
282
  get visible() { return (this._isForced) ? this._visibleForced : this._visible; }
277
283
  set visible(visible) { this.setVisibility(visible); }
284
+ visibleOn(state) {
285
+ return this.visible && this.viewOnState(state);
286
+ }
287
+ enabledOn(state) {
288
+ return !this.disabled && this.enabledOnState(state);
289
+ }
278
290
  setVisibility(visible, forced = null) {
279
291
  this._visible = visible && true;
280
292
  if (forced != null) {
@@ -1643,7 +1655,7 @@ class FieldDescriptor extends FormElement {
1643
1655
  }
1644
1656
  break;
1645
1657
  case this._formConfig.fieldTypes.currency:
1646
- newFinalValue = formatCurrency(this._fieldValue);
1658
+ newFinalValue = formatCurrency(newValue);
1647
1659
  break;
1648
1660
  default:
1649
1661
  newFinalValue = newValue;
@@ -1860,6 +1872,7 @@ class FormStructureAndData {
1860
1872
  ? this._sectionsObj[sectionCode] : null;
1861
1873
  return (section) ? section.getSubsection(subsectionCode) : null;
1862
1874
  }
1875
+ get actions() { return this._actionsObj; }
1863
1876
  getSection(sectionCode) {
1864
1877
  return (this._sectionsObj && this._sectionsObj[sectionCode])
1865
1878
  ? this._sectionsObj[sectionCode] : null;
@@ -1991,6 +2004,7 @@ class FormStructureAndData {
1991
2004
  const actionNames = (Array.isArray(actionArray)) ? actionArray : [actionArray];
1992
2005
  actionNames.forEach(actionCode => this.disableAction(actionCode));
1993
2006
  }
2007
+ get fields() { return this._fieldsObj; }
1994
2008
  enableField(fieldCode) {
1995
2009
  const fieldObject = this.getFieldObject(fieldCode);
1996
2010
  return (fieldObject) ? fieldObject.enable() : null;
@@ -2371,6 +2385,8 @@ class BasicFormComponent {
2371
2385
  this.errorMessage = '';
2372
2386
  this.errorDetail = '';
2373
2387
  this.formStructure = null;
2388
+ this.fields = null;
2389
+ this.actions = null;
2374
2390
  this.controlToken = null;
2375
2391
  this.inputDataFields = {};
2376
2392
  this.definitionObtained = false;
@@ -2391,6 +2407,7 @@ class BasicFormComponent {
2391
2407
  this.tableGetDataStart = {};
2392
2408
  this.tableGetDataFinish = {};
2393
2409
  }
2410
+ get form() { return this.formStructure; }
2394
2411
  get currentState() { return this.formStructure.state; }
2395
2412
  set currentState(state) { this.formStructure.changeState(state); }
2396
2413
  get currentMode() { return this.currentState; }
@@ -2636,6 +2653,8 @@ class BasicFormComponent {
2636
2653
  const formDefinition = yield this.formManagerService.getFormDefinition(this.name);
2637
2654
  this.inServerProcess = false;
2638
2655
  this.formStructure = new FormStructureAndData(formDefinition, this.formConfig);
2656
+ this.fields = this.formStructure.fields;
2657
+ this.actions = this.formStructure.actions;
2639
2658
  this.definitionObtained = true;
2640
2659
  }
2641
2660
  else {