tuain-ng-forms-lib 12.0.30 → 12.0.35
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/bundles/tuain-ng-forms-lib.umd.js +35 -50
- package/bundles/tuain-ng-forms-lib.umd.js.map +1 -1
- package/esm2015/lib/classes/forms/field.js +12 -25
- package/esm2015/lib/classes/forms/form.js +2 -2
- package/esm2015/lib/components/elements/action.component.js +4 -4
- package/esm2015/lib/components/elements/field.component.js +8 -8
- package/esm2015/lib/components/elements/layout/element.component.js +4 -4
- package/esm2015/lib/components/elements/tables/table.component.js +2 -2
- package/esm2015/lib/components/forms/basic-form.js +3 -4
- package/fesm2015/tuain-ng-forms-lib.js +28 -42
- package/fesm2015/tuain-ng-forms-lib.js.map +1 -1
- package/lib/classes/forms/field.d.ts +1 -2
- package/lib/components/elements/action.component.d.ts +1 -1
- package/lib/components/elements/field.component.d.ts +1 -1
- package/lib/components/elements/layout/element.component.d.ts +1 -1
- package/lib/components/elements/tables/table.component.d.ts +1 -1
- package/lib/components/forms/basic-form.d.ts +0 -1
- package/package.json +1 -1
- package/tuain-ng-forms-lib.metadata.json +1 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Component, Input, EventEmitter, Output, ChangeDetectionStrategy, NgModule } from '@angular/core';
|
|
2
2
|
import { Subject, ReplaySubject } from 'rxjs';
|
|
3
3
|
import { __awaiter } from 'tslib';
|
|
4
|
+
import yn from 'yn';
|
|
4
5
|
import { nanoid } from 'nanoid';
|
|
5
6
|
import { CommonModule } from '@angular/common';
|
|
6
7
|
import { RouterModule } from '@angular/router';
|
|
@@ -37,11 +38,11 @@ class ActionComponent {
|
|
|
37
38
|
}
|
|
38
39
|
get visible() {
|
|
39
40
|
var _a;
|
|
40
|
-
return ((_a = this.action) === null || _a === void 0 ? void 0 : _a.visibleOn(this.
|
|
41
|
+
return ((_a = this.action) === null || _a === void 0 ? void 0 : _a.visibleOn(this.state)) && this.visibleOnRestriction();
|
|
41
42
|
}
|
|
42
43
|
get disabled() {
|
|
43
44
|
var _a;
|
|
44
|
-
return !((_a = this.action) === null || _a === void 0 ? void 0 : _a.enabledOn(this.
|
|
45
|
+
return !((_a = this.action) === null || _a === void 0 ? void 0 : _a.enabledOn(this.state));
|
|
45
46
|
}
|
|
46
47
|
}
|
|
47
48
|
ActionComponent.decorators = [
|
|
@@ -54,7 +55,7 @@ ActionComponent.propDecorators = {
|
|
|
54
55
|
action: [{ type: Input }],
|
|
55
56
|
busy: [{ type: Input }],
|
|
56
57
|
relatedField: [{ type: Input }],
|
|
57
|
-
|
|
58
|
+
state: [{ type: Input }],
|
|
58
59
|
style: [{ type: Input }],
|
|
59
60
|
showLabel: [{ type: Input }]
|
|
60
61
|
};
|
|
@@ -94,18 +95,18 @@ class FieldComponent {
|
|
|
94
95
|
start() { }
|
|
95
96
|
focus() { }
|
|
96
97
|
updateObject() {
|
|
97
|
-
this.field.
|
|
98
|
+
this.field.setValue(this.value);
|
|
98
99
|
}
|
|
99
100
|
inputChanged() {
|
|
100
|
-
this.field.
|
|
101
|
+
this.field.setValue(this.value);
|
|
101
102
|
this.onChangeContent();
|
|
102
103
|
}
|
|
103
104
|
inputTyped() {
|
|
104
|
-
this.field.
|
|
105
|
+
this.field.setValue(this.value);
|
|
105
106
|
this.onInputChange();
|
|
106
107
|
}
|
|
107
108
|
updateValue() {
|
|
108
|
-
this.value = this.field.
|
|
109
|
+
this.value = this.field.getValue();
|
|
109
110
|
}
|
|
110
111
|
onInputChange() {
|
|
111
112
|
setTimeout(() => this.field.notifyEditionPartial(), 50);
|
|
@@ -122,11 +123,11 @@ class FieldComponent {
|
|
|
122
123
|
}
|
|
123
124
|
get visible() {
|
|
124
125
|
var _a;
|
|
125
|
-
return (_a = this.field) === null || _a === void 0 ? void 0 : _a.visibleOn(this.
|
|
126
|
+
return (_a = this.field) === null || _a === void 0 ? void 0 : _a.visibleOn(this.state);
|
|
126
127
|
}
|
|
127
128
|
get disabled() {
|
|
128
129
|
var _a;
|
|
129
|
-
return !((_a = this.field) === null || _a === void 0 ? void 0 : _a.enabledOn(this.
|
|
130
|
+
return !((_a = this.field) === null || _a === void 0 ? void 0 : _a.enabledOn(this.state));
|
|
130
131
|
}
|
|
131
132
|
}
|
|
132
133
|
FieldComponent.decorators = [
|
|
@@ -137,7 +138,7 @@ FieldComponent.decorators = [
|
|
|
137
138
|
];
|
|
138
139
|
FieldComponent.propDecorators = {
|
|
139
140
|
field: [{ type: Input }],
|
|
140
|
-
|
|
141
|
+
state: [{ type: Input }]
|
|
141
142
|
};
|
|
142
143
|
|
|
143
144
|
class ElementComponent {
|
|
@@ -149,11 +150,11 @@ class ElementComponent {
|
|
|
149
150
|
start() { }
|
|
150
151
|
get visible() {
|
|
151
152
|
var _a;
|
|
152
|
-
return (_a = this.element) === null || _a === void 0 ? void 0 : _a.visibleOn(this.
|
|
153
|
+
return (_a = this.element) === null || _a === void 0 ? void 0 : _a.visibleOn(this.state);
|
|
153
154
|
}
|
|
154
155
|
get disabled() {
|
|
155
156
|
var _a;
|
|
156
|
-
return !((_a = this.element) === null || _a === void 0 ? void 0 : _a.enabledOn(this.
|
|
157
|
+
return !((_a = this.element) === null || _a === void 0 ? void 0 : _a.enabledOn(this.state));
|
|
157
158
|
}
|
|
158
159
|
}
|
|
159
160
|
ElementComponent.decorators = [
|
|
@@ -165,7 +166,7 @@ ElementComponent.decorators = [
|
|
|
165
166
|
ElementComponent.propDecorators = {
|
|
166
167
|
element: [{ type: Input }],
|
|
167
168
|
form: [{ type: Input }],
|
|
168
|
-
|
|
169
|
+
state: [{ type: Input }]
|
|
169
170
|
};
|
|
170
171
|
|
|
171
172
|
class FormErrorComponent {
|
|
@@ -1100,7 +1101,7 @@ LibTableComponent.propDecorators = {
|
|
|
1100
1101
|
table: [{ type: Input }],
|
|
1101
1102
|
tableRecords: [{ type: Input }],
|
|
1102
1103
|
disabled: [{ type: Input }],
|
|
1103
|
-
|
|
1104
|
+
state: [{ type: Input }],
|
|
1104
1105
|
waiting: [{ type: Input }]
|
|
1105
1106
|
};
|
|
1106
1107
|
|
|
@@ -1145,7 +1146,7 @@ const STD_MAX_LENGTH = 50;
|
|
|
1145
1146
|
const BIG_MAX_LENGTH = 500;
|
|
1146
1147
|
const fldAttr = {
|
|
1147
1148
|
validateOnServer: 'validateOnServer',
|
|
1148
|
-
value: '
|
|
1149
|
+
value: '_value',
|
|
1149
1150
|
minValue: '_minValue',
|
|
1150
1151
|
maxValue: '_maxValue',
|
|
1151
1152
|
maxLength: '_maxLength',
|
|
@@ -1272,7 +1273,6 @@ class FieldDescriptor extends FormElement {
|
|
|
1272
1273
|
hideLabel() { this.setVisibleLabel(false); }
|
|
1273
1274
|
setChanged(hasChanged) { this.setAttr(fldAttr.hasChanged, hasChanged); }
|
|
1274
1275
|
changed() { this.setChanged(true); }
|
|
1275
|
-
getRawValue() { return this._fieldValue; }
|
|
1276
1276
|
setLabel(label) { this.setAttr(fldAttr.title, label); }
|
|
1277
1277
|
clean() { this.setValue(this.defaultValue || ''); this.resetError(); }
|
|
1278
1278
|
get backend() { return this.validateOnServer; }
|
|
@@ -1305,24 +1305,11 @@ class FieldDescriptor extends FormElement {
|
|
|
1305
1305
|
return fieldCurrentValue === '';
|
|
1306
1306
|
}
|
|
1307
1307
|
getValue() {
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
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
|
-
console.log('Valor del campo...');
|
|
1322
|
-
console.log(this._fieldValue);
|
|
1323
|
-
return this._fieldValue;
|
|
1324
|
-
break;
|
|
1308
|
+
if (this.fieldType === this._formConfig.fieldTypes.boolean
|
|
1309
|
+
|| this.fieldType === this._formConfig.fieldTypes.check) {
|
|
1310
|
+
return yn(this._value);
|
|
1325
1311
|
}
|
|
1312
|
+
return this._value;
|
|
1326
1313
|
}
|
|
1327
1314
|
updateFromServer(fld) {
|
|
1328
1315
|
var _a;
|
|
@@ -1400,14 +1387,14 @@ class FieldDescriptor extends FormElement {
|
|
|
1400
1387
|
if (this.fieldType === this._formConfig.fieldTypes.array && this.widget) {
|
|
1401
1388
|
return (_a = this.widget) === null || _a === void 0 ? void 0 : _a.refereshContent();
|
|
1402
1389
|
}
|
|
1403
|
-
if (this.
|
|
1404
|
-
if (this.fieldType === this._formConfig.fieldTypes.array && Array.isArray(this.
|
|
1405
|
-
const fieldValue = (_b = this.
|
|
1390
|
+
if (this._value) {
|
|
1391
|
+
if (this.fieldType === this._formConfig.fieldTypes.array && Array.isArray(this._value)) {
|
|
1392
|
+
const fieldValue = (_b = this._value) === null || _b === void 0 ? void 0 : _b.filter(item => this.fieldOptions.find(opt => opt.fieldOptionId === item));
|
|
1406
1393
|
this.setAttr(fldAttr.value, fieldValue);
|
|
1407
1394
|
}
|
|
1408
1395
|
else {
|
|
1409
1396
|
const valInOptions = this.fieldOptions
|
|
1410
|
-
.find(item => item.fieldOptionId === this.
|
|
1397
|
+
.find(item => item.fieldOptionId === this._value);
|
|
1411
1398
|
if (!valInOptions) {
|
|
1412
1399
|
this.setValue('');
|
|
1413
1400
|
}
|
|
@@ -1462,7 +1449,7 @@ class FieldDescriptor extends FormElement {
|
|
|
1462
1449
|
newFinalValue = newValue;
|
|
1463
1450
|
break;
|
|
1464
1451
|
}
|
|
1465
|
-
if (this.
|
|
1452
|
+
if (this._value !== newFinalValue) {
|
|
1466
1453
|
this.setChanged(true);
|
|
1467
1454
|
this.setAttr(fldAttr.value, newFinalValue);
|
|
1468
1455
|
}
|
|
@@ -1819,7 +1806,7 @@ class FormStructureAndData {
|
|
|
1819
1806
|
getField(code) { var _a; return (code && ((_a = this._fields) === null || _a === void 0 ? void 0 : _a[code])) ? this._fields[code] : null; }
|
|
1820
1807
|
enableField(code) { var _a; (_a = this.getField(code)) === null || _a === void 0 ? void 0 : _a.enable(); }
|
|
1821
1808
|
disableField(code) { var _a; (_a = this.getField(code)) === null || _a === void 0 ? void 0 : _a.disable(); }
|
|
1822
|
-
getFieldValue(code) { var _a; (_a = this.getField(code)) === null || _a === void 0 ? void 0 : _a.getValue(); }
|
|
1809
|
+
getFieldValue(code) { var _a; return (_a = this.getField(code)) === null || _a === void 0 ? void 0 : _a.getValue(); }
|
|
1823
1810
|
getFieldOptions(code) { var _a; (_a = this.getField(code)) === null || _a === void 0 ? void 0 : _a.getFieldOptions(); }
|
|
1824
1811
|
setFieldValue(code, value) { var _a; (_a = this.getField(code)) === null || _a === void 0 ? void 0 : _a.setValue(value); }
|
|
1825
1812
|
setFieldError(code, message, type = 'error') { var _a; (_a = this.getField(code)) === null || _a === void 0 ? void 0 : _a.setError(code, message, type); }
|
|
@@ -2538,10 +2525,9 @@ class BasicFormComponent {
|
|
|
2538
2525
|
set formCode(name) { this.name = name; }
|
|
2539
2526
|
get inServerProcess() { return this.busy; }
|
|
2540
2527
|
get form() { return this._formStructure; }
|
|
2541
|
-
get state() { return this.
|
|
2528
|
+
get state() { var _a; return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.state; }
|
|
2542
2529
|
get currentState() { var _a; return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.state; }
|
|
2543
2530
|
set currentState(state) { this._formStructure.changeState(state); }
|
|
2544
|
-
get currentMode() { return this.currentState; }
|
|
2545
2531
|
get immutableData() { var _a; return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.immutableData; }
|
|
2546
2532
|
get extraInfo() { var _a; return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.extraInfo; }
|
|
2547
2533
|
get visibleSections() { var _a; return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.visibleSections; }
|
|
@@ -2603,7 +2589,7 @@ class BasicFormComponent {
|
|
|
2603
2589
|
if (!cleanStack) {
|
|
2604
2590
|
origin = Object.assign(Object.assign({}, backData), { name: this.name, url: this._formRoute, token: this._controlToken });
|
|
2605
2591
|
origin.subject = (_a = origin === null || origin === void 0 ? void 0 : origin.subject) !== null && _a !== void 0 ? _a : this.formSubject;
|
|
2606
|
-
origin.state = (_b = origin === null || origin === void 0 ? void 0 : origin.state) !== null && _b !== void 0 ? _b : this.
|
|
2592
|
+
origin.state = (_b = origin === null || origin === void 0 ? void 0 : origin.state) !== null && _b !== void 0 ? _b : this.state;
|
|
2607
2593
|
origin.fields = (_c = origin === null || origin === void 0 ? void 0 : origin.fields) !== null && _c !== void 0 ? _c : {};
|
|
2608
2594
|
origin.extra = (_d = origin === null || origin === void 0 ? void 0 : origin.extra) !== null && _d !== void 0 ? _d : {};
|
|
2609
2595
|
}
|