tuain-ng-forms-lib 12.0.29 → 12.0.33

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.
@@ -37,11 +37,11 @@ class ActionComponent {
37
37
  }
38
38
  get visible() {
39
39
  var _a;
40
- return ((_a = this.action) === null || _a === void 0 ? void 0 : _a.visibleOn(this.currentState)) && this.visibleOnRestriction();
40
+ return ((_a = this.action) === null || _a === void 0 ? void 0 : _a.visibleOn(this.state)) && this.visibleOnRestriction();
41
41
  }
42
42
  get disabled() {
43
43
  var _a;
44
- return !((_a = this.action) === null || _a === void 0 ? void 0 : _a.enabledOn(this.currentState));
44
+ return !((_a = this.action) === null || _a === void 0 ? void 0 : _a.enabledOn(this.state));
45
45
  }
46
46
  }
47
47
  ActionComponent.decorators = [
@@ -54,7 +54,7 @@ ActionComponent.propDecorators = {
54
54
  action: [{ type: Input }],
55
55
  busy: [{ type: Input }],
56
56
  relatedField: [{ type: Input }],
57
- currentState: [{ type: Input }],
57
+ state: [{ type: Input }],
58
58
  style: [{ type: Input }],
59
59
  showLabel: [{ type: Input }]
60
60
  };
@@ -94,18 +94,18 @@ class FieldComponent {
94
94
  start() { }
95
95
  focus() { }
96
96
  updateObject() {
97
- this.field._fieldValue = this.value;
97
+ this.field.setValue(this.value);
98
98
  }
99
99
  inputChanged() {
100
- this.field._fieldValue = this.value;
100
+ this.field.setValue(this.value);
101
101
  this.onChangeContent();
102
102
  }
103
103
  inputTyped() {
104
- this.field._fieldValue = this.value;
104
+ this.field.setValue(this.value);
105
105
  this.onInputChange();
106
106
  }
107
107
  updateValue() {
108
- this.value = this.field._fieldValue;
108
+ this.value = this.field.getValue();
109
109
  }
110
110
  onInputChange() {
111
111
  setTimeout(() => this.field.notifyEditionPartial(), 50);
@@ -122,11 +122,11 @@ class FieldComponent {
122
122
  }
123
123
  get visible() {
124
124
  var _a;
125
- return (_a = this.field) === null || _a === void 0 ? void 0 : _a.visibleOn(this.currentState);
125
+ return (_a = this.field) === null || _a === void 0 ? void 0 : _a.visibleOn(this.state);
126
126
  }
127
127
  get disabled() {
128
128
  var _a;
129
- return !((_a = this.field) === null || _a === void 0 ? void 0 : _a.enabledOn(this.currentState));
129
+ return !((_a = this.field) === null || _a === void 0 ? void 0 : _a.enabledOn(this.state));
130
130
  }
131
131
  }
132
132
  FieldComponent.decorators = [
@@ -137,7 +137,7 @@ FieldComponent.decorators = [
137
137
  ];
138
138
  FieldComponent.propDecorators = {
139
139
  field: [{ type: Input }],
140
- currentState: [{ type: Input }]
140
+ state: [{ type: Input }]
141
141
  };
142
142
 
143
143
  class ElementComponent {
@@ -149,11 +149,11 @@ class ElementComponent {
149
149
  start() { }
150
150
  get visible() {
151
151
  var _a;
152
- return (_a = this.element) === null || _a === void 0 ? void 0 : _a.visibleOn(this.currentState);
152
+ return (_a = this.element) === null || _a === void 0 ? void 0 : _a.visibleOn(this.state);
153
153
  }
154
154
  get disabled() {
155
155
  var _a;
156
- return !((_a = this.element) === null || _a === void 0 ? void 0 : _a.enabledOn(this.currentState));
156
+ return !((_a = this.element) === null || _a === void 0 ? void 0 : _a.enabledOn(this.state));
157
157
  }
158
158
  }
159
159
  ElementComponent.decorators = [
@@ -165,7 +165,7 @@ ElementComponent.decorators = [
165
165
  ElementComponent.propDecorators = {
166
166
  element: [{ type: Input }],
167
167
  form: [{ type: Input }],
168
- currentState: [{ type: Input }]
168
+ state: [{ type: Input }]
169
169
  };
170
170
 
171
171
  class FormErrorComponent {
@@ -1100,7 +1100,7 @@ LibTableComponent.propDecorators = {
1100
1100
  table: [{ type: Input }],
1101
1101
  tableRecords: [{ type: Input }],
1102
1102
  disabled: [{ type: Input }],
1103
- currentState: [{ type: Input }],
1103
+ state: [{ type: Input }],
1104
1104
  waiting: [{ type: Input }]
1105
1105
  };
1106
1106
 
@@ -1145,7 +1145,7 @@ const STD_MAX_LENGTH = 50;
1145
1145
  const BIG_MAX_LENGTH = 500;
1146
1146
  const fldAttr = {
1147
1147
  validateOnServer: 'validateOnServer',
1148
- value: '_fieldValue',
1148
+ value: '_value',
1149
1149
  minValue: '_minValue',
1150
1150
  maxValue: '_maxValue',
1151
1151
  maxLength: '_maxLength',
@@ -1272,7 +1272,6 @@ class FieldDescriptor extends FormElement {
1272
1272
  hideLabel() { this.setVisibleLabel(false); }
1273
1273
  setChanged(hasChanged) { this.setAttr(fldAttr.hasChanged, hasChanged); }
1274
1274
  changed() { this.setChanged(true); }
1275
- getRawValue() { return this._fieldValue; }
1276
1275
  setLabel(label) { this.setAttr(fldAttr.title, label); }
1277
1276
  clean() { this.setValue(this.defaultValue || ''); this.resetError(); }
1278
1277
  get backend() { return this.validateOnServer; }
@@ -1305,22 +1304,11 @@ class FieldDescriptor extends FormElement {
1305
1304
  return fieldCurrentValue === '';
1306
1305
  }
1307
1306
  getValue() {
1308
- var _a, _b;
1309
- switch (this.fieldType) {
1310
- case this._formConfig.fieldTypes.boolean:
1311
- return (_a = this._fieldValue) !== null && _a !== void 0 ? _a : false;
1312
- break;
1313
- case this._formConfig.fieldTypes.check:
1314
- return (_b = this._fieldValue) !== null && _b !== void 0 ? _b : false;
1315
- break;
1316
- case this._formConfig.fieldTypes.currency:
1317
- return (typeof this._fieldValue === 'string')
1318
- ? this._fieldValue.replace(',', '') : this._fieldValue;
1319
- break;
1320
- default:
1321
- return this._fieldValue;
1322
- break;
1307
+ if (this.fieldType === this._formConfig.fieldTypes.boolean
1308
+ || this.fieldType === this._formConfig.fieldTypes.check) {
1309
+ return !!this._value;
1323
1310
  }
1311
+ return this._value;
1324
1312
  }
1325
1313
  updateFromServer(fld) {
1326
1314
  var _a;
@@ -1398,14 +1386,14 @@ class FieldDescriptor extends FormElement {
1398
1386
  if (this.fieldType === this._formConfig.fieldTypes.array && this.widget) {
1399
1387
  return (_a = this.widget) === null || _a === void 0 ? void 0 : _a.refereshContent();
1400
1388
  }
1401
- if (this._fieldValue) {
1402
- if (this.fieldType === this._formConfig.fieldTypes.array && Array.isArray(this._fieldValue)) {
1403
- const fieldValue = (_b = this._fieldValue) === null || _b === void 0 ? void 0 : _b.filter(item => this.fieldOptions.find(opt => opt.fieldOptionId === item));
1389
+ if (this._value) {
1390
+ if (this.fieldType === this._formConfig.fieldTypes.array && Array.isArray(this._value)) {
1391
+ const fieldValue = (_b = this._value) === null || _b === void 0 ? void 0 : _b.filter(item => this.fieldOptions.find(opt => opt.fieldOptionId === item));
1404
1392
  this.setAttr(fldAttr.value, fieldValue);
1405
1393
  }
1406
1394
  else {
1407
1395
  const valInOptions = this.fieldOptions
1408
- .find(item => item.fieldOptionId === this._fieldValue);
1396
+ .find(item => item.fieldOptionId === this._value);
1409
1397
  if (!valInOptions) {
1410
1398
  this.setValue('');
1411
1399
  }
@@ -1460,7 +1448,7 @@ class FieldDescriptor extends FormElement {
1460
1448
  newFinalValue = newValue;
1461
1449
  break;
1462
1450
  }
1463
- if (this._fieldValue !== newFinalValue) {
1451
+ if (this._value !== newFinalValue) {
1464
1452
  this.setChanged(true);
1465
1453
  this.setAttr(fldAttr.value, newFinalValue);
1466
1454
  }
@@ -1817,7 +1805,7 @@ class FormStructureAndData {
1817
1805
  getField(code) { var _a; return (code && ((_a = this._fields) === null || _a === void 0 ? void 0 : _a[code])) ? this._fields[code] : null; }
1818
1806
  enableField(code) { var _a; (_a = this.getField(code)) === null || _a === void 0 ? void 0 : _a.enable(); }
1819
1807
  disableField(code) { var _a; (_a = this.getField(code)) === null || _a === void 0 ? void 0 : _a.disable(); }
1820
- getFieldValue(code) { var _a; (_a = this.getField(code)) === null || _a === void 0 ? void 0 : _a.getValue(); }
1808
+ getFieldValue(code) { var _a; return (_a = this.getField(code)) === null || _a === void 0 ? void 0 : _a.getValue(); }
1821
1809
  getFieldOptions(code) { var _a; (_a = this.getField(code)) === null || _a === void 0 ? void 0 : _a.getFieldOptions(); }
1822
1810
  setFieldValue(code, value) { var _a; (_a = this.getField(code)) === null || _a === void 0 ? void 0 : _a.setValue(value); }
1823
1811
  setFieldError(code, message, type = 'error') { var _a; (_a = this.getField(code)) === null || _a === void 0 ? void 0 : _a.setError(code, message, type); }
@@ -2536,10 +2524,9 @@ class BasicFormComponent {
2536
2524
  set formCode(name) { this.name = name; }
2537
2525
  get inServerProcess() { return this.busy; }
2538
2526
  get form() { return this._formStructure; }
2539
- get state() { return this.getCurrentState(); }
2527
+ get state() { var _a; return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.state; }
2540
2528
  get currentState() { var _a; return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.state; }
2541
2529
  set currentState(state) { this._formStructure.changeState(state); }
2542
- get currentMode() { return this.currentState; }
2543
2530
  get immutableData() { var _a; return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.immutableData; }
2544
2531
  get extraInfo() { var _a; return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.extraInfo; }
2545
2532
  get visibleSections() { var _a; return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.visibleSections; }
@@ -2601,7 +2588,7 @@ class BasicFormComponent {
2601
2588
  if (!cleanStack) {
2602
2589
  origin = Object.assign(Object.assign({}, backData), { name: this.name, url: this._formRoute, token: this._controlToken });
2603
2590
  origin.subject = (_a = origin === null || origin === void 0 ? void 0 : origin.subject) !== null && _a !== void 0 ? _a : this.formSubject;
2604
- origin.state = (_b = origin === null || origin === void 0 ? void 0 : origin.state) !== null && _b !== void 0 ? _b : this.currentState;
2591
+ origin.state = (_b = origin === null || origin === void 0 ? void 0 : origin.state) !== null && _b !== void 0 ? _b : this.state;
2605
2592
  origin.fields = (_c = origin === null || origin === void 0 ? void 0 : origin.fields) !== null && _c !== void 0 ? _c : {};
2606
2593
  origin.extra = (_d = origin === null || origin === void 0 ? void 0 : origin.extra) !== null && _d !== void 0 ? _d : {};
2607
2594
  }