tuain-ng-forms-lib 12.0.12 → 12.0.16
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/README.md +1 -1
- package/bundles/tuain-ng-forms-lib.umd.js +78 -39
- package/bundles/tuain-ng-forms-lib.umd.js.map +1 -1
- package/esm2015/lib/components/elements/action.component.js +21 -13
- package/esm2015/lib/components/elements/field.component.js +26 -12
- package/esm2015/lib/components/forms/basic-form.js +13 -12
- package/fesm2015/tuain-ng-forms-lib.js +57 -34
- package/fesm2015/tuain-ng-forms-lib.js.map +1 -1
- package/lib/components/elements/action.component.d.ts +7 -4
- package/lib/components/elements/field.component.d.ts +4 -2
- package/lib/components/forms/basic-form.d.ts +2 -1
- package/package.json +1 -1
- package/tuain-ng-forms-lib.metadata.json +1 -1
|
@@ -13,28 +13,36 @@ class ActionComponent {
|
|
|
13
13
|
}
|
|
14
14
|
ngOnInit() {
|
|
15
15
|
var _a;
|
|
16
|
-
this.formConfig = (_a = this.
|
|
16
|
+
this.formConfig = (_a = this.action) === null || _a === void 0 ? void 0 : _a._formConfig;
|
|
17
17
|
this.start();
|
|
18
18
|
}
|
|
19
19
|
start() { }
|
|
20
20
|
activate() {
|
|
21
21
|
var _a;
|
|
22
|
-
if ((_a = this.
|
|
23
|
-
this.
|
|
22
|
+
if ((_a = this.action) === null || _a === void 0 ? void 0 : _a.notifyActivation) {
|
|
23
|
+
this.action.notifyActivation();
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
|
-
|
|
26
|
+
visibleOnRestriction() {
|
|
27
27
|
var _a, _b, _c, _d, _e;
|
|
28
|
-
if (!((_a = this.
|
|
28
|
+
if (!((_a = this.action) === null || _a === void 0 ? void 0 : _a.restrictedOnField)) {
|
|
29
29
|
return true;
|
|
30
30
|
}
|
|
31
|
-
if ((((_b = this.
|
|
32
|
-
&& this.relatedField === ((_c = this.
|
|
33
|
-
|| (((_d = this.
|
|
34
|
-
&& this.relatedField !== ((_e = this.
|
|
31
|
+
if ((((_b = this.action) === null || _b === void 0 ? void 0 : _b.restrictedOnOperator) === '=='
|
|
32
|
+
&& this.relatedField === ((_c = this.action) === null || _c === void 0 ? void 0 : _c.restrictedOnValue))
|
|
33
|
+
|| (((_d = this.action) === null || _d === void 0 ? void 0 : _d.restrictedOnOperator) === '!='
|
|
34
|
+
&& this.relatedField !== ((_e = this.action) === null || _e === void 0 ? void 0 : _e.restrictedOnValue))) {
|
|
35
35
|
return true;
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
|
+
get visible() {
|
|
39
|
+
var _a;
|
|
40
|
+
return ((_a = this.action) === null || _a === void 0 ? void 0 : _a.visibleOn(this.currentState)) && this.visibleOnRestriction();
|
|
41
|
+
}
|
|
42
|
+
get disabled() {
|
|
43
|
+
var _a;
|
|
44
|
+
return !((_a = this.action) === null || _a === void 0 ? void 0 : _a.enabledOn(this.currentState));
|
|
45
|
+
}
|
|
38
46
|
}
|
|
39
47
|
ActionComponent.decorators = [
|
|
40
48
|
{ type: Component, args: [{
|
|
@@ -43,10 +51,10 @@ ActionComponent.decorators = [
|
|
|
43
51
|
},] }
|
|
44
52
|
];
|
|
45
53
|
ActionComponent.propDecorators = {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
formBusy: [{ type: Input }],
|
|
54
|
+
action: [{ 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
|
};
|
|
@@ -55,22 +63,28 @@ const VALUE = '';
|
|
|
55
63
|
class FieldComponent {
|
|
56
64
|
ngOnInit() {
|
|
57
65
|
var _a, _b;
|
|
58
|
-
if (this.
|
|
59
|
-
this.formConfig = (_a = this.
|
|
66
|
+
if (this.field) {
|
|
67
|
+
this.formConfig = (_a = this.field) === null || _a === void 0 ? void 0 : _a._formConfig;
|
|
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,
|
|
64
|
-
|
|
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.field) === null || _b === void 0 ? void 0 : _b[fieldAttr.toString()];
|
|
78
|
+
}
|
|
65
79
|
}
|
|
66
80
|
// Subscripción a cambios en atributos
|
|
67
|
-
this.
|
|
81
|
+
this.field.attributeChange.subscribe(event => {
|
|
68
82
|
const { name: fieldAttr, value } = event;
|
|
69
83
|
const compAttr = this.formConfig.componentFieldAttrMap[fieldAttr];
|
|
70
84
|
if (compAttr === VALUE) {
|
|
71
85
|
this.updateValue();
|
|
72
86
|
}
|
|
73
|
-
else
|
|
87
|
+
else {
|
|
74
88
|
this[compAttr] = value;
|
|
75
89
|
}
|
|
76
90
|
});
|
|
@@ -82,18 +96,26 @@ class FieldComponent {
|
|
|
82
96
|
updateValue() { }
|
|
83
97
|
updateObject() { }
|
|
84
98
|
onInputChange() {
|
|
85
|
-
setTimeout(() => this.
|
|
99
|
+
setTimeout(() => this.field.notifyEditionPartial(), 50);
|
|
86
100
|
}
|
|
87
101
|
onChangeContent() {
|
|
88
|
-
setTimeout(() => this.
|
|
102
|
+
setTimeout(() => this.field.notifyEditionFinish(), 50);
|
|
89
103
|
}
|
|
90
104
|
onShowInfo() {
|
|
91
|
-
setTimeout(() => this.
|
|
105
|
+
setTimeout(() => this.field.notifyEditionDetailRequest(), 50);
|
|
92
106
|
}
|
|
93
107
|
numberInputValidation(event) {
|
|
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.field) === null || _a === void 0 ? void 0 : _a.visibleOn(this.currentState);
|
|
114
|
+
}
|
|
115
|
+
get disabled() {
|
|
116
|
+
var _a;
|
|
117
|
+
return !((_a = this.field) === null || _a === void 0 ? void 0 : _a.enabledOn(this.currentState));
|
|
118
|
+
}
|
|
97
119
|
}
|
|
98
120
|
FieldComponent.decorators = [
|
|
99
121
|
{ type: Component, args: [{
|
|
@@ -102,8 +124,8 @@ FieldComponent.decorators = [
|
|
|
102
124
|
},] }
|
|
103
125
|
];
|
|
104
126
|
FieldComponent.propDecorators = {
|
|
105
|
-
|
|
106
|
-
|
|
127
|
+
field: [{ type: Input }],
|
|
128
|
+
currentState: [{ type: Input }]
|
|
107
129
|
};
|
|
108
130
|
|
|
109
131
|
class ElementComponent {
|
|
@@ -2357,7 +2379,7 @@ class BasicFormComponent {
|
|
|
2357
2379
|
this.extraData = {};
|
|
2358
2380
|
this.definitionObtained = false;
|
|
2359
2381
|
this.formVisible = false;
|
|
2360
|
-
this.
|
|
2382
|
+
this.busy = false;
|
|
2361
2383
|
this.formSectionsActivate = {};
|
|
2362
2384
|
this.formSectionsInactivate = {};
|
|
2363
2385
|
this.formActionsStart = {};
|
|
@@ -2376,6 +2398,7 @@ class BasicFormComponent {
|
|
|
2376
2398
|
this.cleanStart();
|
|
2377
2399
|
this.customPreProcessing();
|
|
2378
2400
|
}
|
|
2401
|
+
get inServerProcess() { return this.busy; }
|
|
2379
2402
|
setConfig(formConfig) {
|
|
2380
2403
|
this.formConfig = formConfig;
|
|
2381
2404
|
}
|
|
@@ -2392,7 +2415,7 @@ class BasicFormComponent {
|
|
|
2392
2415
|
this.definitionObtained = false;
|
|
2393
2416
|
// Se limpian los manejadores de eventos
|
|
2394
2417
|
this.formVisible = false;
|
|
2395
|
-
this.
|
|
2418
|
+
this.busy = false;
|
|
2396
2419
|
this.formSectionsActivate = {};
|
|
2397
2420
|
this.formSectionsInactivate = {};
|
|
2398
2421
|
this.formActionsStart = {};
|
|
@@ -2649,9 +2672,9 @@ class BasicFormComponent {
|
|
|
2649
2672
|
return;
|
|
2650
2673
|
}
|
|
2651
2674
|
if (!this.definitionObtained) {
|
|
2652
|
-
this.
|
|
2675
|
+
this.busy = true;
|
|
2653
2676
|
const formDefinition = yield this.formManagerService.getFormDefinition(this.name);
|
|
2654
|
-
this.
|
|
2677
|
+
this.busy = false;
|
|
2655
2678
|
this.formStructure = new FormStructureAndData(formDefinition, this.formConfig);
|
|
2656
2679
|
this.fields = this.formStructure.fields;
|
|
2657
2680
|
this.actions = this.formStructure.actions;
|
|
@@ -2709,9 +2732,9 @@ class BasicFormComponent {
|
|
|
2709
2732
|
this.errorCode = NO_ERROR;
|
|
2710
2733
|
this.errorMessage = '';
|
|
2711
2734
|
this.errorDetail = '';
|
|
2712
|
-
this.
|
|
2735
|
+
this.busy = true;
|
|
2713
2736
|
const formActionResponse = yield this.formManagerService.execServerAction(actionDetail);
|
|
2714
|
-
this.
|
|
2737
|
+
this.busy = false;
|
|
2715
2738
|
if (formActionResponse && formActionResponse.error.errorType) {
|
|
2716
2739
|
console.log('Excepción no soportada');
|
|
2717
2740
|
}
|
|
@@ -2728,7 +2751,7 @@ class BasicFormComponent {
|
|
|
2728
2751
|
}
|
|
2729
2752
|
updateFormWithServerData(formContent) {
|
|
2730
2753
|
const { currentMode, formSubject, actions, fields, recordTables, returnedFile, immutableData, extraInfo, } = formContent;
|
|
2731
|
-
|
|
2754
|
+
currentMode && this.changeState(currentMode);
|
|
2732
2755
|
if (formSubject) {
|
|
2733
2756
|
this.formSubject = formSubject;
|
|
2734
2757
|
}
|
|
@@ -2866,7 +2889,7 @@ class BasicFormComponent {
|
|
|
2866
2889
|
}
|
|
2867
2890
|
if (finish) {
|
|
2868
2891
|
yield this.finishAction(action, actionResult);
|
|
2869
|
-
this.changeState(action.newState);
|
|
2892
|
+
action.newState && this.changeState(action.newState);
|
|
2870
2893
|
}
|
|
2871
2894
|
else {
|
|
2872
2895
|
this.displayActionServerError();
|
|
@@ -3163,7 +3186,7 @@ class BasicFormComponent {
|
|
|
3163
3186
|
}
|
|
3164
3187
|
if (finish) {
|
|
3165
3188
|
yield this.finishTableGlobalAction(tableActionDetail, actionResult);
|
|
3166
|
-
this.changeState(action.newState);
|
|
3189
|
+
action.newState && this.changeState(action.newState);
|
|
3167
3190
|
}
|
|
3168
3191
|
else {
|
|
3169
3192
|
this.displayTableServerError();
|
|
@@ -3246,7 +3269,7 @@ class BasicFormComponent {
|
|
|
3246
3269
|
}
|
|
3247
3270
|
if (finish) {
|
|
3248
3271
|
this.finishTableAction(tableActionDetail, actionResult);
|
|
3249
|
-
this.changeState(action.newState);
|
|
3272
|
+
action.newState && this.changeState(action.newState);
|
|
3250
3273
|
}
|
|
3251
3274
|
else {
|
|
3252
3275
|
this.displayTableServerError();
|
|
@@ -3404,7 +3427,7 @@ class BasicFormComponent {
|
|
|
3404
3427
|
}
|
|
3405
3428
|
if (finish) {
|
|
3406
3429
|
this.finishTableSelectionAction(tableActionDetail, actionResult);
|
|
3407
|
-
this.changeState(action.newState);
|
|
3430
|
+
action.newState && this.changeState(action.newState);
|
|
3408
3431
|
}
|
|
3409
3432
|
else {
|
|
3410
3433
|
this.displayTableServerError();
|