tuain-ng-forms-lib 15.2.12 → 17.0.0
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/esm2022/lib/classes/forms/action.mjs +78 -0
- package/esm2022/lib/classes/forms/element.mjs +18 -0
- package/esm2022/lib/classes/forms/field.mjs +458 -0
- package/esm2022/lib/classes/forms/form.mjs +581 -0
- package/esm2022/lib/classes/forms/piece-propagate.mjs +39 -0
- package/esm2022/lib/classes/forms/piece.mjs +126 -0
- package/esm2022/lib/classes/forms/section.mjs +139 -0
- package/esm2022/lib/classes/forms/subsection.mjs +81 -0
- package/esm2022/lib/classes/forms/table/action.mjs +38 -0
- package/esm2022/lib/classes/forms/table/column.mjs +74 -0
- package/esm2022/lib/classes/forms/table/row-data.mjs +116 -0
- package/esm2022/lib/classes/forms/table/table.mjs +481 -0
- package/esm2022/lib/components/elements/action.component.mjs +52 -0
- package/esm2022/lib/components/elements/field.component.mjs +112 -0
- package/esm2022/lib/components/elements/layout/element.component.mjs +21 -0
- package/esm2022/lib/components/elements/layout/form-error.component.mjs +23 -0
- package/esm2022/lib/components/elements/layout/form-header.component.mjs +23 -0
- package/esm2022/lib/components/elements/layout/piece.component.mjs +40 -0
- package/esm2022/lib/components/elements/layout/section.component.mjs +40 -0
- package/esm2022/lib/components/elements/layout/sub-section.component.mjs +40 -0
- package/esm2022/lib/components/elements/tables/table-record-action.component.mjs +67 -0
- package/esm2022/lib/components/elements/tables/table-record-field.component.mjs +31 -0
- package/esm2022/lib/components/elements/tables/table.component.mjs +95 -0
- package/esm2022/lib/components/forms/basic-form.mjs +1314 -0
- package/esm2022/lib/services/event-manager.service.mjs +43 -0
- package/esm2022/lib/services/form-manager.service.mjs +81 -0
- package/{esm2020 → esm2022}/lib/tuain-ng-forms-lib.module.mjs +29 -29
- package/{fesm2020 → fesm2022}/tuain-ng-forms-lib.mjs +331 -260
- package/{fesm2020 → fesm2022}/tuain-ng-forms-lib.mjs.map +1 -1
- 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/layout/form-error.component.d.ts +1 -1
- package/lib/components/elements/layout/form-header.component.d.ts +1 -1
- package/lib/components/elements/layout/piece.component.d.ts +1 -1
- package/lib/components/elements/layout/section.component.d.ts +1 -1
- package/lib/components/elements/layout/sub-section.component.d.ts +1 -1
- package/lib/components/elements/tables/table-record-action.component.d.ts +1 -1
- package/lib/components/elements/tables/table-record-field.component.d.ts +1 -1
- package/lib/components/elements/tables/table.component.d.ts +1 -1
- package/lib/components/forms/basic-form.d.ts +1 -1
- package/package.json +7 -13
- package/esm2020/lib/classes/forms/action.mjs +0 -72
- package/esm2020/lib/classes/forms/element.mjs +0 -18
- package/esm2020/lib/classes/forms/field.mjs +0 -454
- package/esm2020/lib/classes/forms/form.mjs +0 -574
- package/esm2020/lib/classes/forms/piece-propagate.mjs +0 -38
- package/esm2020/lib/classes/forms/piece.mjs +0 -123
- package/esm2020/lib/classes/forms/section.mjs +0 -138
- package/esm2020/lib/classes/forms/subsection.mjs +0 -81
- package/esm2020/lib/classes/forms/table/action.mjs +0 -30
- package/esm2020/lib/classes/forms/table/column.mjs +0 -74
- package/esm2020/lib/classes/forms/table/row-data.mjs +0 -116
- package/esm2020/lib/classes/forms/table/table.mjs +0 -464
- package/esm2020/lib/components/elements/action.component.mjs +0 -55
- package/esm2020/lib/components/elements/field.component.mjs +0 -99
- package/esm2020/lib/components/elements/layout/element.component.mjs +0 -20
- package/esm2020/lib/components/elements/layout/form-error.component.mjs +0 -20
- package/esm2020/lib/components/elements/layout/form-header.component.mjs +0 -24
- package/esm2020/lib/components/elements/layout/piece.component.mjs +0 -40
- package/esm2020/lib/components/elements/layout/section.component.mjs +0 -39
- package/esm2020/lib/components/elements/layout/sub-section.component.mjs +0 -39
- package/esm2020/lib/components/elements/tables/table-record-action.component.mjs +0 -67
- package/esm2020/lib/components/elements/tables/table-record-field.component.mjs +0 -30
- package/esm2020/lib/components/elements/tables/table.component.mjs +0 -92
- package/esm2020/lib/components/forms/basic-form.mjs +0 -1310
- package/esm2020/lib/services/event-manager.service.mjs +0 -43
- package/esm2020/lib/services/form-manager.service.mjs +0 -80
- package/fesm2015/tuain-ng-forms-lib.mjs +0 -4305
- package/fesm2015/tuain-ng-forms-lib.mjs.map +0 -1
- /package/{esm2020 → esm2022}/lib/classes/forms/form.constants.mjs +0 -0
- /package/{esm2020 → esm2022}/lib/services/file-manager.service.mjs +0 -0
- /package/{esm2020 → esm2022}/public-api.mjs +0 -0
- /package/{esm2020 → esm2022}/tuain-ng-forms-lib.mjs +0 -0
- /package/{tuain-ng-forms-lib.d.ts → index.d.ts} +0 -0
|
@@ -1,4305 +0,0 @@
|
|
|
1
|
-
import * as i0 from '@angular/core';
|
|
2
|
-
import { Component, Input, EventEmitter, Output, ChangeDetectionStrategy, NgModule } from '@angular/core';
|
|
3
|
-
import { __awaiter } from 'tslib';
|
|
4
|
-
import { BehaviorSubject, Subject, ReplaySubject } from 'rxjs';
|
|
5
|
-
import yn from 'yn';
|
|
6
|
-
import { nanoid } from 'nanoid';
|
|
7
|
-
import { CommonModule } from '@angular/common';
|
|
8
|
-
import { RouterModule } from '@angular/router';
|
|
9
|
-
import { FormsModule } from '@angular/forms';
|
|
10
|
-
|
|
11
|
-
const CUSTOM_ATTRIBUTES = 'customAttributes';
|
|
12
|
-
class PieceComponent {
|
|
13
|
-
constructor() {
|
|
14
|
-
this.visible = true;
|
|
15
|
-
this.disabled = false;
|
|
16
|
-
this.customAttributes = {};
|
|
17
|
-
}
|
|
18
|
-
setForm(form) { this.form = form; }
|
|
19
|
-
defaultProcessAttributeChange(attribute, value) {
|
|
20
|
-
if (!attribute || attribute.trim() === '') {
|
|
21
|
-
return false;
|
|
22
|
-
}
|
|
23
|
-
const attributeParts = attribute.split('.');
|
|
24
|
-
if ((attributeParts === null || attributeParts === void 0 ? void 0 : attributeParts.length) > 1) {
|
|
25
|
-
const [attributeType, subAttribute] = attributeParts;
|
|
26
|
-
if (attributeType === CUSTOM_ATTRIBUTES) {
|
|
27
|
-
this.customAttributes[subAttribute] = value;
|
|
28
|
-
this.customAttributeChange(subAttribute, value);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
else {
|
|
32
|
-
this[attribute] = value;
|
|
33
|
-
}
|
|
34
|
-
return true;
|
|
35
|
-
}
|
|
36
|
-
customProcessAttributeChange(attribute, value) { }
|
|
37
|
-
customAttributeChange(subAttribute, value) { }
|
|
38
|
-
}
|
|
39
|
-
PieceComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: PieceComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
40
|
-
PieceComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.6", type: PieceComponent, selector: "lib-piece", ngImport: i0, template: `<ng-content></ng-content>`, isInline: true });
|
|
41
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: PieceComponent, decorators: [{
|
|
42
|
-
type: Component,
|
|
43
|
-
args: [{
|
|
44
|
-
selector: 'lib-piece',
|
|
45
|
-
template: `<ng-content></ng-content>`
|
|
46
|
-
}]
|
|
47
|
-
}] });
|
|
48
|
-
|
|
49
|
-
class ElementComponent extends PieceComponent {
|
|
50
|
-
start() {
|
|
51
|
-
var _a;
|
|
52
|
-
this.setForm((_a = this.element) === null || _a === void 0 ? void 0 : _a._form);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
ElementComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: ElementComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
56
|
-
ElementComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.6", type: ElementComponent, selector: "lib-element", inputs: { element: "element" }, usesInheritance: true, ngImport: i0, template: `<ng-content></ng-content>`, isInline: true });
|
|
57
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: ElementComponent, decorators: [{
|
|
58
|
-
type: Component,
|
|
59
|
-
args: [{
|
|
60
|
-
selector: 'lib-element',
|
|
61
|
-
template: `<ng-content></ng-content>`
|
|
62
|
-
}]
|
|
63
|
-
}], propDecorators: { element: [{
|
|
64
|
-
type: Input
|
|
65
|
-
}] } });
|
|
66
|
-
|
|
67
|
-
class ActionComponent extends ElementComponent {
|
|
68
|
-
constructor() {
|
|
69
|
-
super(...arguments);
|
|
70
|
-
this.inProgress = false;
|
|
71
|
-
this.action = null;
|
|
72
|
-
}
|
|
73
|
-
ngOnInit() {
|
|
74
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
75
|
-
if (!this.action) {
|
|
76
|
-
return;
|
|
77
|
-
}
|
|
78
|
-
this.formConfig = (_a = this.action) === null || _a === void 0 ? void 0 : _a._formConfig;
|
|
79
|
-
const mapping = Object.entries((_b = this.formConfig) === null || _b === void 0 ? void 0 : _b.actionPropagateAttributes);
|
|
80
|
-
for (let index = 0; index < mapping.length; index++) {
|
|
81
|
-
const actionAttr = (_c = mapping[index]) === null || _c === void 0 ? void 0 : _c[0];
|
|
82
|
-
const componentAttr = (_f = (_e = (_d = mapping[index]) === null || _d === void 0 ? void 0 : _d[1]) === null || _e === void 0 ? void 0 : _e.toString()) !== null && _f !== void 0 ? _f : '';
|
|
83
|
-
if (componentAttr) {
|
|
84
|
-
const value = (_g = this.action) === null || _g === void 0 ? void 0 : _g[actionAttr];
|
|
85
|
-
this.defaultProcessAttributeChange(componentAttr, value);
|
|
86
|
-
this.customProcessAttributeChange(componentAttr, value);
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
(_j = (_h = this.action) === null || _h === void 0 ? void 0 : _h.attributeChange) === null || _j === void 0 ? void 0 : _j.subscribe(event => {
|
|
90
|
-
const { name: componentAttr, value } = event;
|
|
91
|
-
this.defaultProcessAttributeChange(componentAttr, value);
|
|
92
|
-
this.customProcessAttributeChange(componentAttr, value);
|
|
93
|
-
});
|
|
94
|
-
if (this.action) {
|
|
95
|
-
this.action.widget = this;
|
|
96
|
-
}
|
|
97
|
-
this.start();
|
|
98
|
-
}
|
|
99
|
-
start() {
|
|
100
|
-
var _a;
|
|
101
|
-
this.setForm((_a = this.action) === null || _a === void 0 ? void 0 : _a._form);
|
|
102
|
-
}
|
|
103
|
-
activate() {
|
|
104
|
-
var _a;
|
|
105
|
-
if ((_a = this.action) === null || _a === void 0 ? void 0 : _a.notifyActivation) {
|
|
106
|
-
this.action.notifyActivation();
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
ActionComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: ActionComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
111
|
-
ActionComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.6", type: ActionComponent, selector: "lib-action", inputs: { action: "action" }, usesInheritance: true, ngImport: i0, template: `<ng-content></ng-content>`, isInline: true });
|
|
112
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: ActionComponent, decorators: [{
|
|
113
|
-
type: Component,
|
|
114
|
-
args: [{
|
|
115
|
-
selector: 'lib-action',
|
|
116
|
-
template: `<ng-content></ng-content>`
|
|
117
|
-
}]
|
|
118
|
-
}], propDecorators: { action: [{
|
|
119
|
-
type: Input
|
|
120
|
-
}] } });
|
|
121
|
-
|
|
122
|
-
const VALUE = 'value';
|
|
123
|
-
const FOCUS = 'focus';
|
|
124
|
-
class FieldComponent extends ElementComponent {
|
|
125
|
-
constructor() {
|
|
126
|
-
super(...arguments);
|
|
127
|
-
// Atributos obtenidos estáticamente
|
|
128
|
-
this.code = '';
|
|
129
|
-
this.info = '';
|
|
130
|
-
this.alignment = '';
|
|
131
|
-
this.tooltip = '';
|
|
132
|
-
this.field = null;
|
|
133
|
-
}
|
|
134
|
-
ngOnInit() {
|
|
135
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
136
|
-
if (!this.field) {
|
|
137
|
-
return;
|
|
138
|
-
}
|
|
139
|
-
this.formConfig = (_a = this.field) === null || _a === void 0 ? void 0 : _a._formConfig;
|
|
140
|
-
const mapping = Object.entries((_b = this.formConfig) === null || _b === void 0 ? void 0 : _b.fieldPropagateAttributes);
|
|
141
|
-
const customAttributesMapping = (_d = (_c = this.formConfig) === null || _c === void 0 ? void 0 : _c.propagationCustomAttributes.fields) !== null && _d !== void 0 ? _d : [];
|
|
142
|
-
for (let index = 0; index < mapping.length; index++) {
|
|
143
|
-
const fieldAttr = (_e = mapping[index]) === null || _e === void 0 ? void 0 : _e[0];
|
|
144
|
-
const componentAttr = (_h = (_g = (_f = mapping[index]) === null || _f === void 0 ? void 0 : _f[1]) === null || _g === void 0 ? void 0 : _g.toString()) !== null && _h !== void 0 ? _h : '';
|
|
145
|
-
if (componentAttr) {
|
|
146
|
-
const value = (_j = this.field) === null || _j === void 0 ? void 0 : _j[fieldAttr];
|
|
147
|
-
this.defaultProcessAttributeChange(componentAttr, value);
|
|
148
|
-
this.customProcessAttributeChange(componentAttr, value);
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
// Atributos personalizados
|
|
152
|
-
for (let index = 0; index < customAttributesMapping.length; index++) {
|
|
153
|
-
const customAttribute = customAttributesMapping[index];
|
|
154
|
-
if (customAttribute) {
|
|
155
|
-
const value = (_k = this.field) === null || _k === void 0 ? void 0 : _k.getCustomAttribute(customAttribute);
|
|
156
|
-
const fullName = `customAttributes.${customAttribute}`;
|
|
157
|
-
if (value) {
|
|
158
|
-
this.defaultProcessAttributeChange(fullName, value);
|
|
159
|
-
this.customProcessAttributeChange(fullName, value);
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
// Subscripción a cambios en atributos
|
|
164
|
-
(_l = this.field) === null || _l === void 0 ? void 0 : _l.attributeChange.subscribe(event => {
|
|
165
|
-
const { name: componentAttr, value = null } = event !== null && event !== void 0 ? event : {};
|
|
166
|
-
if (componentAttr) {
|
|
167
|
-
this.defaultProcessAttributeChange(componentAttr, value);
|
|
168
|
-
this.customProcessAttributeChange(componentAttr, value);
|
|
169
|
-
}
|
|
170
|
-
});
|
|
171
|
-
if (this.field) {
|
|
172
|
-
this.field.widget = this;
|
|
173
|
-
}
|
|
174
|
-
this.start();
|
|
175
|
-
}
|
|
176
|
-
defaultProcessAttributeChange(attribute, value) {
|
|
177
|
-
if (attribute === VALUE) {
|
|
178
|
-
this.updateValue();
|
|
179
|
-
}
|
|
180
|
-
else if (attribute === FOCUS) {
|
|
181
|
-
this.focus();
|
|
182
|
-
}
|
|
183
|
-
else {
|
|
184
|
-
return super.defaultProcessAttributeChange(attribute, value);
|
|
185
|
-
}
|
|
186
|
-
return true;
|
|
187
|
-
}
|
|
188
|
-
updateValue() { var _a; this.value = (_a = this.field) === null || _a === void 0 ? void 0 : _a.value; }
|
|
189
|
-
onInputChange() { setTimeout(() => { var _a; return (_a = this.field) === null || _a === void 0 ? void 0 : _a.notifyEditionPartial(); }, 50); }
|
|
190
|
-
onChangeContent() { setTimeout(() => { var _a; return (_a = this.field) === null || _a === void 0 ? void 0 : _a.notifyEditionFinish(); }, 50); }
|
|
191
|
-
onShowInfo(detail = null) { setTimeout(() => { var _a; return (_a = this.field) === null || _a === void 0 ? void 0 : _a.notifyEditionDetailRequest(detail); }, 50); }
|
|
192
|
-
focus() { }
|
|
193
|
-
updateObject(widgetUpdate = true) { var _a; (_a = this.field) === null || _a === void 0 ? void 0 : _a.setValue(this.value, widgetUpdate); }
|
|
194
|
-
inputChanged() {
|
|
195
|
-
var _a;
|
|
196
|
-
(_a = this.field) === null || _a === void 0 ? void 0 : _a.setValue(this.value);
|
|
197
|
-
this.onChangeContent();
|
|
198
|
-
}
|
|
199
|
-
inputTyped() {
|
|
200
|
-
this.updateObject(false);
|
|
201
|
-
this.onInputChange();
|
|
202
|
-
}
|
|
203
|
-
numberInputValidation(event) {
|
|
204
|
-
const k = event.charCode;
|
|
205
|
-
return (k > 47 && k < 58);
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
FieldComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: FieldComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
209
|
-
FieldComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.6", type: FieldComponent, selector: "lib-field", inputs: { field: "field" }, usesInheritance: true, ngImport: i0, template: `<ng-content></ng-content>`, isInline: true });
|
|
210
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: FieldComponent, decorators: [{
|
|
211
|
-
type: Component,
|
|
212
|
-
args: [{
|
|
213
|
-
selector: 'lib-field',
|
|
214
|
-
template: `<ng-content></ng-content>`
|
|
215
|
-
}]
|
|
216
|
-
}], propDecorators: { field: [{
|
|
217
|
-
type: Input
|
|
218
|
-
}] } });
|
|
219
|
-
|
|
220
|
-
class FormErrorComponent {
|
|
221
|
-
}
|
|
222
|
-
FormErrorComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: FormErrorComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
223
|
-
FormErrorComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.6", type: FormErrorComponent, selector: "lib-form-error", inputs: { errorTitle: "errorTitle", errorMessage: "errorMessage", errorType: "errorType" }, ngImport: i0, template: `<ng-content></ng-content>`, isInline: true });
|
|
224
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: FormErrorComponent, decorators: [{
|
|
225
|
-
type: Component,
|
|
226
|
-
args: [{
|
|
227
|
-
selector: 'lib-form-error',
|
|
228
|
-
template: `<ng-content></ng-content>`
|
|
229
|
-
}]
|
|
230
|
-
}], propDecorators: { errorTitle: [{
|
|
231
|
-
type: Input
|
|
232
|
-
}], errorMessage: [{
|
|
233
|
-
type: Input
|
|
234
|
-
}], errorType: [{
|
|
235
|
-
type: Input
|
|
236
|
-
}] } });
|
|
237
|
-
|
|
238
|
-
class FormHeaderComponent {
|
|
239
|
-
constructor() {
|
|
240
|
-
this.goBackEvent = new EventEmitter();
|
|
241
|
-
}
|
|
242
|
-
goBackForm() {
|
|
243
|
-
this.goBackEvent.emit();
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
FormHeaderComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: FormHeaderComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
247
|
-
FormHeaderComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.6", type: FormHeaderComponent, selector: "lib-form-header", inputs: { form: "form" }, outputs: { goBackEvent: "goBackEvent" }, ngImport: i0, template: `<ng-content></ng-content>`, isInline: true });
|
|
248
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: FormHeaderComponent, decorators: [{
|
|
249
|
-
type: Component,
|
|
250
|
-
args: [{
|
|
251
|
-
selector: 'lib-form-header',
|
|
252
|
-
template: `<ng-content></ng-content>`
|
|
253
|
-
}]
|
|
254
|
-
}], propDecorators: { form: [{
|
|
255
|
-
type: Input
|
|
256
|
-
}], goBackEvent: [{
|
|
257
|
-
type: Output
|
|
258
|
-
}] } });
|
|
259
|
-
|
|
260
|
-
class SectionComponent extends PieceComponent {
|
|
261
|
-
ngOnInit() {
|
|
262
|
-
var _a, _b, _c, _d;
|
|
263
|
-
this.formConfig = (_a = this.section) === null || _a === void 0 ? void 0 : _a._formConfig;
|
|
264
|
-
const mapping = (_b = this.formConfig) === null || _b === void 0 ? void 0 : _b.sectionPropagateAttributes;
|
|
265
|
-
for (let index = 0; index < mapping.length; index++) {
|
|
266
|
-
const attrName = mapping[index].toString();
|
|
267
|
-
const attributeValue = (_c = this.section) === null || _c === void 0 ? void 0 : _c[attrName];
|
|
268
|
-
this.defaultProcessAttributeChange(attrName, attributeValue);
|
|
269
|
-
this.customProcessAttributeChange(attrName, attributeValue);
|
|
270
|
-
}
|
|
271
|
-
// Subscripción a cambios en atributos
|
|
272
|
-
(_d = this.section) === null || _d === void 0 ? void 0 : _d.attributeChange.subscribe(event => {
|
|
273
|
-
const { name: attrName, value = null } = event !== null && event !== void 0 ? event : {};
|
|
274
|
-
if (attrName) {
|
|
275
|
-
this.defaultProcessAttributeChange(attrName, value);
|
|
276
|
-
this.customProcessAttributeChange(attrName, value);
|
|
277
|
-
}
|
|
278
|
-
});
|
|
279
|
-
this.start();
|
|
280
|
-
}
|
|
281
|
-
start() {
|
|
282
|
-
var _a;
|
|
283
|
-
this.setForm((_a = this.section) === null || _a === void 0 ? void 0 : _a._form);
|
|
284
|
-
}
|
|
285
|
-
}
|
|
286
|
-
SectionComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: SectionComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
287
|
-
SectionComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.6", type: SectionComponent, selector: "lib-section", inputs: { section: "section" }, usesInheritance: true, ngImport: i0, template: `<ng-content></ng-content>`, isInline: true });
|
|
288
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: SectionComponent, decorators: [{
|
|
289
|
-
type: Component,
|
|
290
|
-
args: [{
|
|
291
|
-
selector: 'lib-section',
|
|
292
|
-
template: `<ng-content></ng-content>`
|
|
293
|
-
}]
|
|
294
|
-
}], propDecorators: { section: [{
|
|
295
|
-
type: Input
|
|
296
|
-
}] } });
|
|
297
|
-
|
|
298
|
-
class SubSectionComponent extends PieceComponent {
|
|
299
|
-
ngOnInit() {
|
|
300
|
-
var _a, _b, _c, _d;
|
|
301
|
-
this.formConfig = (_a = this.subSection) === null || _a === void 0 ? void 0 : _a._formConfig;
|
|
302
|
-
const mapping = (_b = this.formConfig) === null || _b === void 0 ? void 0 : _b.subSectionPropagateAttributes;
|
|
303
|
-
for (let index = 0; index < mapping.length; index++) {
|
|
304
|
-
const attrName = mapping[index].toString();
|
|
305
|
-
const attributeValue = (_c = this.subSection) === null || _c === void 0 ? void 0 : _c[attrName];
|
|
306
|
-
this.defaultProcessAttributeChange(attrName, attributeValue);
|
|
307
|
-
this.customProcessAttributeChange(attrName, attributeValue);
|
|
308
|
-
}
|
|
309
|
-
// Subscripción a cambios en atributos
|
|
310
|
-
(_d = this.subSection) === null || _d === void 0 ? void 0 : _d.attributeChange.subscribe(event => {
|
|
311
|
-
const { name: attrName, value = null } = event !== null && event !== void 0 ? event : {};
|
|
312
|
-
if (attrName) {
|
|
313
|
-
this.defaultProcessAttributeChange(attrName, value);
|
|
314
|
-
this.customProcessAttributeChange(attrName, value);
|
|
315
|
-
}
|
|
316
|
-
});
|
|
317
|
-
this.start();
|
|
318
|
-
}
|
|
319
|
-
start() {
|
|
320
|
-
var _a;
|
|
321
|
-
this.setForm((_a = this.subSection) === null || _a === void 0 ? void 0 : _a._form);
|
|
322
|
-
}
|
|
323
|
-
}
|
|
324
|
-
SubSectionComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: SubSectionComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
325
|
-
SubSectionComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.6", type: SubSectionComponent, selector: "lib-subsection", inputs: { subSection: "subSection" }, usesInheritance: true, ngImport: i0, template: `<ng-content></ng-content>`, isInline: true });
|
|
326
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: SubSectionComponent, decorators: [{
|
|
327
|
-
type: Component,
|
|
328
|
-
args: [{
|
|
329
|
-
selector: 'lib-subsection',
|
|
330
|
-
template: `<ng-content></ng-content>`
|
|
331
|
-
}]
|
|
332
|
-
}], propDecorators: { subSection: [{
|
|
333
|
-
type: Input
|
|
334
|
-
}] } });
|
|
335
|
-
|
|
336
|
-
const INLINE_ACTION$1 = 'INLINE';
|
|
337
|
-
class LibTableRecordActionComponent extends PieceComponent {
|
|
338
|
-
constructor() {
|
|
339
|
-
super(...arguments);
|
|
340
|
-
this.isVisible = true;
|
|
341
|
-
this.actionSelected = new EventEmitter();
|
|
342
|
-
}
|
|
343
|
-
ngOnInit() {
|
|
344
|
-
var _a, _b, _c;
|
|
345
|
-
this.formConfig = (_a = this.action) === null || _a === void 0 ? void 0 : _a._formConfig;
|
|
346
|
-
const mapping = (_b = this.formConfig) === null || _b === void 0 ? void 0 : _b.actionPropagateAttributes;
|
|
347
|
-
for (let index = 0; index < mapping.length; index++) {
|
|
348
|
-
const attrName = mapping[index].toString();
|
|
349
|
-
const attributeValue = (_c = this.action) === null || _c === void 0 ? void 0 : _c[attrName];
|
|
350
|
-
this.defaultProcessAttributeChange(attrName, attributeValue);
|
|
351
|
-
this.customProcessAttributeChange(attrName, attributeValue);
|
|
352
|
-
}
|
|
353
|
-
this.start();
|
|
354
|
-
}
|
|
355
|
-
start() {
|
|
356
|
-
if (this.action && this.action.restrictedOnField && this.recordData) {
|
|
357
|
-
const relatedField = this.action.restrictedOnField;
|
|
358
|
-
if (relatedField) {
|
|
359
|
-
const relatedFieldValue = this.recordData[relatedField];
|
|
360
|
-
const restrictionOper = this.action.restrictedOnOperator;
|
|
361
|
-
const restrictionValue = this.action.restrictedOnValue;
|
|
362
|
-
if ((restrictionOper === '==' && relatedFieldValue !== restrictionValue)
|
|
363
|
-
|| (restrictionOper === '!=' && relatedFieldValue === restrictionValue)) {
|
|
364
|
-
this.isVisible = false;
|
|
365
|
-
}
|
|
366
|
-
else {
|
|
367
|
-
this.isVisible = true;
|
|
368
|
-
}
|
|
369
|
-
}
|
|
370
|
-
}
|
|
371
|
-
}
|
|
372
|
-
onActivate() {
|
|
373
|
-
var _a, _b;
|
|
374
|
-
const tableEvent = {
|
|
375
|
-
actionCode: (_b = (_a = this.action) === null || _a === void 0 ? void 0 : _a.actionCode) !== null && _b !== void 0 ? _b : '',
|
|
376
|
-
recordId: this.recordId,
|
|
377
|
-
recordData: this.recordData,
|
|
378
|
-
};
|
|
379
|
-
this.actionSelected.emit(tableEvent);
|
|
380
|
-
}
|
|
381
|
-
class() { }
|
|
382
|
-
}
|
|
383
|
-
LibTableRecordActionComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: LibTableRecordActionComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
384
|
-
LibTableRecordActionComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.6", type: LibTableRecordActionComponent, selector: "lib-table-record-action", inputs: { recordId: "recordId", recordData: "recordData", action: "action" }, outputs: { actionSelected: "actionSelected" }, usesInheritance: true, ngImport: i0, template: `<ng-content></ng-content>`, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
385
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: LibTableRecordActionComponent, decorators: [{
|
|
386
|
-
type: Component,
|
|
387
|
-
args: [{
|
|
388
|
-
selector: 'lib-table-record-action',
|
|
389
|
-
template: `<ng-content></ng-content>`,
|
|
390
|
-
changeDetection: ChangeDetectionStrategy.OnPush
|
|
391
|
-
}]
|
|
392
|
-
}], propDecorators: { recordId: [{
|
|
393
|
-
type: Input
|
|
394
|
-
}], recordData: [{
|
|
395
|
-
type: Input
|
|
396
|
-
}], action: [{
|
|
397
|
-
type: Input
|
|
398
|
-
}], actionSelected: [{
|
|
399
|
-
type: Output
|
|
400
|
-
}] } });
|
|
401
|
-
|
|
402
|
-
class LibTableRecordFieldComponent {
|
|
403
|
-
constructor() {
|
|
404
|
-
this.column = null;
|
|
405
|
-
}
|
|
406
|
-
ngOnInit() {
|
|
407
|
-
this.start();
|
|
408
|
-
}
|
|
409
|
-
start() { }
|
|
410
|
-
}
|
|
411
|
-
LibTableRecordFieldComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: LibTableRecordFieldComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
412
|
-
LibTableRecordFieldComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.6", type: LibTableRecordFieldComponent, selector: "lib-table-record-field", inputs: { fieldCode: "fieldCode", fieldType: "fieldType", fieldValue: "fieldValue", column: "column" }, ngImport: i0, template: `<ng-content></ng-content>`, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
413
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: LibTableRecordFieldComponent, decorators: [{
|
|
414
|
-
type: Component,
|
|
415
|
-
args: [{
|
|
416
|
-
selector: 'lib-table-record-field',
|
|
417
|
-
template: `<ng-content></ng-content>`,
|
|
418
|
-
changeDetection: ChangeDetectionStrategy.OnPush
|
|
419
|
-
}]
|
|
420
|
-
}], propDecorators: { fieldCode: [{
|
|
421
|
-
type: Input
|
|
422
|
-
}], fieldType: [{
|
|
423
|
-
type: Input
|
|
424
|
-
}], fieldValue: [{
|
|
425
|
-
type: Input
|
|
426
|
-
}], column: [{
|
|
427
|
-
type: Input
|
|
428
|
-
}] } });
|
|
429
|
-
|
|
430
|
-
class LibTableComponent extends ElementComponent {
|
|
431
|
-
constructor() {
|
|
432
|
-
super(...arguments);
|
|
433
|
-
this.globalFilterString = '';
|
|
434
|
-
this.loaded = false;
|
|
435
|
-
this.selectable = false;
|
|
436
|
-
this.hasActions = false;
|
|
437
|
-
this.table = null;
|
|
438
|
-
this.visibleRecords = [];
|
|
439
|
-
this.waiting = false;
|
|
440
|
-
}
|
|
441
|
-
ngOnInit() {
|
|
442
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
|
|
443
|
-
if (!this.table) {
|
|
444
|
-
return;
|
|
445
|
-
}
|
|
446
|
-
this.table.setWidget(this);
|
|
447
|
-
this.formConfig = (_a = this.table) === null || _a === void 0 ? void 0 : _a._formConfig;
|
|
448
|
-
this.tableFieldStyles = (_b = this.formConfig) === null || _b === void 0 ? void 0 : _b.tableFieldStyles;
|
|
449
|
-
this.selectable = (_c = this.table) === null || _c === void 0 ? void 0 : _c.selectable;
|
|
450
|
-
this.hasActions = (_d = this.table) === null || _d === void 0 ? void 0 : _d.hasActions();
|
|
451
|
-
this.inlineActions = (_e = this.table) === null || _e === void 0 ? void 0 : _e.getActions((_f = this.formConfig) === null || _f === void 0 ? void 0 : _f.tableActions.inline);
|
|
452
|
-
this.globalActions = (_g = this.table) === null || _g === void 0 ? void 0 : _g.getActions((_h = this.formConfig) === null || _h === void 0 ? void 0 : _h.tableActions.global);
|
|
453
|
-
this.selectionActions = (_j = this.table) === null || _j === void 0 ? void 0 : _j.getActions((_k = this.formConfig) === null || _k === void 0 ? void 0 : _k.tableActions.selection);
|
|
454
|
-
// Inicialización de campos mapeados del objeto
|
|
455
|
-
const mapping = Object.entries((_l = this.formConfig) === null || _l === void 0 ? void 0 : _l.tablePropagationAttributes);
|
|
456
|
-
for (let index = 0; index < mapping.length; index++) {
|
|
457
|
-
const tableAttr = (_m = mapping[index]) === null || _m === void 0 ? void 0 : _m[0];
|
|
458
|
-
const componentAttr = (_q = (_p = (_o = mapping[index]) === null || _o === void 0 ? void 0 : _o[1]) === null || _p === void 0 ? void 0 : _p.toString()) !== null && _q !== void 0 ? _q : '';
|
|
459
|
-
const attributeValue = (_r = this.table) === null || _r === void 0 ? void 0 : _r[tableAttr];
|
|
460
|
-
this.defaultProcessAttributeChange(componentAttr, attributeValue);
|
|
461
|
-
this.customProcessAttributeChange(componentAttr, attributeValue);
|
|
462
|
-
}
|
|
463
|
-
// Subscripción a cambios en atributos
|
|
464
|
-
(_s = this.table) === null || _s === void 0 ? void 0 : _s.attributeChange.subscribe(event => {
|
|
465
|
-
const { name: attrName, value = null } = event !== null && event !== void 0 ? event : {};
|
|
466
|
-
if (attrName) {
|
|
467
|
-
this.defaultProcessAttributeChange(attrName, value);
|
|
468
|
-
this.customProcessAttributeChange(attrName, value);
|
|
469
|
-
}
|
|
470
|
-
});
|
|
471
|
-
this.start();
|
|
472
|
-
}
|
|
473
|
-
updateTableData() { }
|
|
474
|
-
tableGlobalAction(actionCode) { var _a; (_a = this.table) === null || _a === void 0 ? void 0 : _a.notifyGlobalAction(actionCode); }
|
|
475
|
-
tableSelectionAction(actionCode) { var _a; (_a = this.table) === null || _a === void 0 ? void 0 : _a.notifySelectionAction(actionCode); }
|
|
476
|
-
tableActionSelected(actionEvent) { var _a; (_a = this.table) === null || _a === void 0 ? void 0 : _a.notifyInlineAction(actionEvent); }
|
|
477
|
-
tableSelectionToggle(recordId) { var _a; (_a = this.table) === null || _a === void 0 ? void 0 : _a.notifyRecordSelection(recordId); }
|
|
478
|
-
toggleSelectAll() { var _a, _b, _c; return ((_a = this.table) === null || _a === void 0 ? void 0 : _a.allSelected) ? (_b = this.table) === null || _b === void 0 ? void 0 : _b.unSelectAll() : (_c = this.table) === null || _c === void 0 ? void 0 : _c.selectAll(); }
|
|
479
|
-
globalFilterCompleted() { this.changePage(1); }
|
|
480
|
-
changePage(requestedPage) { var _a; (_a = this.table) === null || _a === void 0 ? void 0 : _a.changePage(requestedPage); }
|
|
481
|
-
tableColumnSort(columnName, direction = null) { var _a; (_a = this.table) === null || _a === void 0 ? void 0 : _a.sort(columnName, direction !== null && direction !== void 0 ? direction : 'ascend'); }
|
|
482
|
-
globalFilterChanged() { var _a, _b, _c; (_a = this.table) === null || _a === void 0 ? void 0 : _a.setGlobalFilterString((_c = (_b = this.globalFilterString) === null || _b === void 0 ? void 0 : _b.trim()) !== null && _c !== void 0 ? _c : '', false); }
|
|
483
|
-
defaultProcessAttributeChange(attribute, value) {
|
|
484
|
-
try {
|
|
485
|
-
if (attribute === 'visibleRecords') {
|
|
486
|
-
this.updateTableData();
|
|
487
|
-
}
|
|
488
|
-
return super.defaultProcessAttributeChange(attribute, value);
|
|
489
|
-
}
|
|
490
|
-
catch (_a) {
|
|
491
|
-
return false;
|
|
492
|
-
}
|
|
493
|
-
}
|
|
494
|
-
filterHasChanged(column, values) {
|
|
495
|
-
var _a, _b;
|
|
496
|
-
if (!values || values.length === 0) {
|
|
497
|
-
(_a = this.table) === null || _a === void 0 ? void 0 : _a.removeColumnFilter(column.fieldCode);
|
|
498
|
-
}
|
|
499
|
-
else {
|
|
500
|
-
(_b = this.table) === null || _b === void 0 ? void 0 : _b.addColumnFilter(column.fieldCode, values);
|
|
501
|
-
}
|
|
502
|
-
}
|
|
503
|
-
}
|
|
504
|
-
LibTableComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: LibTableComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
505
|
-
LibTableComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.6", type: LibTableComponent, selector: "lib-table", inputs: { table: "table", visibleRecords: "visibleRecords", waiting: "waiting" }, usesInheritance: true, ngImport: i0, template: `<ng-content></ng-content>`, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
506
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: LibTableComponent, decorators: [{
|
|
507
|
-
type: Component,
|
|
508
|
-
args: [{
|
|
509
|
-
selector: 'lib-table',
|
|
510
|
-
template: `<ng-content></ng-content>`,
|
|
511
|
-
changeDetection: ChangeDetectionStrategy.OnPush
|
|
512
|
-
}]
|
|
513
|
-
}], propDecorators: { table: [{
|
|
514
|
-
type: Input
|
|
515
|
-
}], visibleRecords: [{
|
|
516
|
-
type: Input
|
|
517
|
-
}], waiting: [{
|
|
518
|
-
type: Input
|
|
519
|
-
}] } });
|
|
520
|
-
|
|
521
|
-
const NO_ERROR = '00';
|
|
522
|
-
const HEADER$1 = 'HEADER';
|
|
523
|
-
const elementTypes = {
|
|
524
|
-
action: 'ACTION',
|
|
525
|
-
field: 'FIELD',
|
|
526
|
-
table: 'TABLE',
|
|
527
|
-
};
|
|
528
|
-
const formActions = {
|
|
529
|
-
tableAction: 'TABLEACTION',
|
|
530
|
-
getData: 'GETDATA',
|
|
531
|
-
getTableData: 'GETTABLEDATA',
|
|
532
|
-
validate: 'VALIDATE',
|
|
533
|
-
};
|
|
534
|
-
const operators = {
|
|
535
|
-
G: 'G',
|
|
536
|
-
L: 'L',
|
|
537
|
-
GE: 'GE',
|
|
538
|
-
LE: 'LE',
|
|
539
|
-
EQ: 'EQ',
|
|
540
|
-
NEQ: 'NEQ',
|
|
541
|
-
HAS: 'HAS',
|
|
542
|
-
NOTHAS: 'NOTHAS',
|
|
543
|
-
BETWEEN: 'BETWEEN',
|
|
544
|
-
IN: 'IN',
|
|
545
|
-
};
|
|
546
|
-
|
|
547
|
-
class FormPiece {
|
|
548
|
-
constructor(pieceDefinition, formConfig) {
|
|
549
|
-
var _a, _b, _c, _d;
|
|
550
|
-
this._formState = '';
|
|
551
|
-
this._absoluteVisible = true;
|
|
552
|
-
this._absoluteDisabled = false;
|
|
553
|
-
this._widget = null;
|
|
554
|
-
this.visibleStates = [];
|
|
555
|
-
this.enabledStates = [];
|
|
556
|
-
this._form = null;
|
|
557
|
-
this._visible = true;
|
|
558
|
-
this._disabled = false;
|
|
559
|
-
this.customAttributes = {};
|
|
560
|
-
this._formConfig = formConfig;
|
|
561
|
-
this._isForced = false;
|
|
562
|
-
this._visibleForced = false;
|
|
563
|
-
this.setVisibleStates(pieceDefinition.visibleStates);
|
|
564
|
-
this.setEnabledStates(pieceDefinition.enabledStates);
|
|
565
|
-
this.enabled = (_a = !(pieceDefinition === null || pieceDefinition === void 0 ? void 0 : pieceDefinition.disabled)) !== null && _a !== void 0 ? _a : false;
|
|
566
|
-
this.setVisibility((_b = pieceDefinition === null || pieceDefinition === void 0 ? void 0 : pieceDefinition.visible) !== null && _b !== void 0 ? _b : true);
|
|
567
|
-
this.customAttributes = (_c = pieceDefinition === null || pieceDefinition === void 0 ? void 0 : pieceDefinition.customAttributes) !== null && _c !== void 0 ? _c : {};
|
|
568
|
-
if (pieceDefinition === null || pieceDefinition === void 0 ? void 0 : pieceDefinition.customAttributes) {
|
|
569
|
-
(_d = Object.keys(pieceDefinition === null || pieceDefinition === void 0 ? void 0 : pieceDefinition.customAttributes)) === null || _d === void 0 ? void 0 : _d.forEach(attr => this.customAttributes[attr] = pieceDefinition === null || pieceDefinition === void 0 ? void 0 : pieceDefinition.customAttributes[attr]);
|
|
570
|
-
}
|
|
571
|
-
}
|
|
572
|
-
getCustomAttribute(name) { var _a, _b; return (_b = (_a = this.customAttributes) === null || _a === void 0 ? void 0 : _a[name]) !== null && _b !== void 0 ? _b : null; }
|
|
573
|
-
setCustomAttribute(name, value) {
|
|
574
|
-
if (name) {
|
|
575
|
-
this.customAttributes[name] = value;
|
|
576
|
-
}
|
|
577
|
-
}
|
|
578
|
-
setCustomAttributes(attributes) {
|
|
579
|
-
Object.entries(attributes).forEach(([name, value]) => {
|
|
580
|
-
this.setCustomAttribute(name, value);
|
|
581
|
-
});
|
|
582
|
-
return this;
|
|
583
|
-
}
|
|
584
|
-
matchAttribute(name, value) { var _a; return ((_a = this.customAttributes) === null || _a === void 0 ? void 0 : _a[name]) === value; }
|
|
585
|
-
setVisibleStates(newStates) {
|
|
586
|
-
const visibleStates = (!Array.isArray(newStates) && typeof newStates === 'string')
|
|
587
|
-
? newStates.split(',').map(state => state.trim()).filter(state => state.length > 0)
|
|
588
|
-
: newStates;
|
|
589
|
-
this.visibleStates = (Array.isArray(visibleStates)) ? [...(new Set(visibleStates))] : [];
|
|
590
|
-
}
|
|
591
|
-
addVisibleState(state) {
|
|
592
|
-
if (!this.visibleStates.includes(state)) {
|
|
593
|
-
this.visibleStates.push(state);
|
|
594
|
-
}
|
|
595
|
-
}
|
|
596
|
-
removeVisibleState(state) {
|
|
597
|
-
const existStateIdx = this.visibleStates.findIndex(st => st === state);
|
|
598
|
-
if (existStateIdx >= 0) {
|
|
599
|
-
this.visibleStates.splice(existStateIdx, 1);
|
|
600
|
-
}
|
|
601
|
-
}
|
|
602
|
-
setEnabledStates(newStates) {
|
|
603
|
-
const enabledStates = (!Array.isArray(newStates) && typeof newStates === 'string')
|
|
604
|
-
? newStates.split(',').map(state => state.trim()).filter(state => state.length > 0)
|
|
605
|
-
: newStates;
|
|
606
|
-
this.enabledStates = (Array.isArray(enabledStates)) ? [...(new Set(enabledStates))] : [];
|
|
607
|
-
}
|
|
608
|
-
addEnabledState(state) {
|
|
609
|
-
if (!this.enabledStates.includes(state)) {
|
|
610
|
-
this.enabledStates.push(state);
|
|
611
|
-
}
|
|
612
|
-
}
|
|
613
|
-
removeEnabledState(state) {
|
|
614
|
-
const existStateIdx = this.enabledStates.findIndex(st => st === state);
|
|
615
|
-
if (existStateIdx >= 0) {
|
|
616
|
-
this.enabledStates.splice(existStateIdx, 1);
|
|
617
|
-
}
|
|
618
|
-
}
|
|
619
|
-
viewOnState(state) { return (this.visibleStates && state) ? this.visibleStates.includes(state) : false; }
|
|
620
|
-
enabledOnState(state) { return (this.enabledStates && state) ? this.enabledStates.includes(state) : false; }
|
|
621
|
-
get absoluteVisible() { return this._absoluteVisible; }
|
|
622
|
-
get absoluteDisabled() { return this._absoluteDisabled; }
|
|
623
|
-
get visible() { return this._visible; }
|
|
624
|
-
set visible(visible) { this.setVisibility(visible); }
|
|
625
|
-
visibleOn(state) {
|
|
626
|
-
return this._absoluteVisible && this.viewOnState(state);
|
|
627
|
-
}
|
|
628
|
-
enabledOn(state) {
|
|
629
|
-
return !this._absoluteDisabled && this.enabledOnState(state);
|
|
630
|
-
}
|
|
631
|
-
setVisibility(visible, forced = null) {
|
|
632
|
-
this._absoluteVisible = !!visible;
|
|
633
|
-
if (forced !== null) {
|
|
634
|
-
this._isForced = forced;
|
|
635
|
-
this._visibleForced = visible;
|
|
636
|
-
}
|
|
637
|
-
this._visible = this._absoluteVisible && this.viewOnState(this._formState);
|
|
638
|
-
}
|
|
639
|
-
show(forced = null) {
|
|
640
|
-
this.setVisibility(true, forced);
|
|
641
|
-
}
|
|
642
|
-
hide(forced = null) {
|
|
643
|
-
this.setVisibility(false, forced);
|
|
644
|
-
}
|
|
645
|
-
get enabled() { return !this._disabled; }
|
|
646
|
-
set enabled(enabled) {
|
|
647
|
-
this._absoluteDisabled = !enabled;
|
|
648
|
-
this._disabled = this._absoluteDisabled || !this.enabledOnState(this._formState);
|
|
649
|
-
}
|
|
650
|
-
get editable() { return !this._disabled; }
|
|
651
|
-
get disabled() { return this._disabled; }
|
|
652
|
-
set disabled(disabled) { this.enabled = !disabled; }
|
|
653
|
-
enable() { this.enabled = true; }
|
|
654
|
-
disable() { this.enabled = false; }
|
|
655
|
-
formStateChangeCustomSubscribe(form, formChangeSubject) { }
|
|
656
|
-
formStateChange(state) {
|
|
657
|
-
if (state) {
|
|
658
|
-
this._formState = state;
|
|
659
|
-
this._visible = this._absoluteVisible && this.viewOnState(state);
|
|
660
|
-
this._disabled = this._absoluteDisabled || !this.enabledOnState(state);
|
|
661
|
-
}
|
|
662
|
-
}
|
|
663
|
-
connectWithParentForm(form, formChangeSubject) {
|
|
664
|
-
this._form = form;
|
|
665
|
-
this.formStateChangeCustomSubscribe(form, formChangeSubject);
|
|
666
|
-
formChangeSubject.subscribe(event => this.formStateChange(event === null || event === void 0 ? void 0 : event.state));
|
|
667
|
-
}
|
|
668
|
-
set widget(widget) { this._widget = widget; }
|
|
669
|
-
get widget() { return this._widget; }
|
|
670
|
-
}
|
|
671
|
-
|
|
672
|
-
const VISIBLE = 'visible';
|
|
673
|
-
const DISABLED = 'disabled';
|
|
674
|
-
class FormPiecePropagate extends FormPiece {
|
|
675
|
-
constructor(pieceDefinition, formConfig) {
|
|
676
|
-
super(pieceDefinition, formConfig);
|
|
677
|
-
this.propagationCustomAttributes = [];
|
|
678
|
-
this._attributeChange = new BehaviorSubject(null);
|
|
679
|
-
}
|
|
680
|
-
get attributeChange() { return this._attributeChange; }
|
|
681
|
-
propagateAttribute(name, value) {
|
|
682
|
-
var _a;
|
|
683
|
-
(_a = this._attributeChange) === null || _a === void 0 ? void 0 : _a.next({ name, value });
|
|
684
|
-
}
|
|
685
|
-
setCustomAttribute(name, value) {
|
|
686
|
-
var _a;
|
|
687
|
-
super.setCustomAttribute(name, value);
|
|
688
|
-
if ((_a = this.propagationCustomAttributes) === null || _a === void 0 ? void 0 : _a.includes(name)) {
|
|
689
|
-
const fullName = `customAttributes.${name}`;
|
|
690
|
-
this.propagateAttribute(fullName, value);
|
|
691
|
-
}
|
|
692
|
-
}
|
|
693
|
-
setVisibility(visible, forced = null) {
|
|
694
|
-
super.setVisibility(visible, forced);
|
|
695
|
-
this.propagateAttribute(VISIBLE, this._visible);
|
|
696
|
-
}
|
|
697
|
-
set enabled(enabled) {
|
|
698
|
-
super.enabled = enabled;
|
|
699
|
-
this.propagateAttribute(DISABLED, this._disabled);
|
|
700
|
-
}
|
|
701
|
-
formStateChange(state) {
|
|
702
|
-
super.formStateChange(state);
|
|
703
|
-
if (state) {
|
|
704
|
-
this.propagateAttribute(VISIBLE, this._visible);
|
|
705
|
-
this.propagateAttribute(DISABLED, this._disabled);
|
|
706
|
-
}
|
|
707
|
-
}
|
|
708
|
-
}
|
|
709
|
-
|
|
710
|
-
class FormElement extends FormPiecePropagate {
|
|
711
|
-
constructor(elementDefinition, formConfig) {
|
|
712
|
-
super(elementDefinition, formConfig);
|
|
713
|
-
this.elementType = null;
|
|
714
|
-
}
|
|
715
|
-
;
|
|
716
|
-
setAttr(attr, value) {
|
|
717
|
-
const { name: attrName, propagate: name } = attr;
|
|
718
|
-
this[attrName] = value;
|
|
719
|
-
name && this.propagateAttribute(name, value);
|
|
720
|
-
}
|
|
721
|
-
isField() { return this.elementType === elementTypes.field; }
|
|
722
|
-
isAction() { return this.elementType === elementTypes.action; }
|
|
723
|
-
isTable() { return this.elementType === elementTypes.table; }
|
|
724
|
-
}
|
|
725
|
-
|
|
726
|
-
const HEADER = 'HEADER';
|
|
727
|
-
class FormAction extends FormElement {
|
|
728
|
-
constructor(actionDefinition, formConfig) {
|
|
729
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
730
|
-
super(actionDefinition, formConfig);
|
|
731
|
-
this._actionActivated = new Subject();
|
|
732
|
-
this.inProgress = false;
|
|
733
|
-
this.restrictedOnField = null;
|
|
734
|
-
this.restrictedOnOperator = null;
|
|
735
|
-
this.restrictedOnValue = null;
|
|
736
|
-
this.propagationCustomAttributes = (_c = (_b = (_a = this._formConfig) === null || _a === void 0 ? void 0 : _a.propagationCustomAttributes) === null || _b === void 0 ? void 0 : _b.actions) !== null && _c !== void 0 ? _c : [];
|
|
737
|
-
this.elementType = elementTypes.action;
|
|
738
|
-
this.actionCode = actionDefinition.actionCode ? actionDefinition.actionCode.toString() : '';
|
|
739
|
-
this.actionName = actionDefinition.actionTitle;
|
|
740
|
-
this.iconName = actionDefinition.iconName || this.actionCode;
|
|
741
|
-
this.setCustomAttribute('location', actionDefinition.position || HEADER);
|
|
742
|
-
this.backend = (_d = actionDefinition === null || actionDefinition === void 0 ? void 0 : actionDefinition.serverAction) !== null && _d !== void 0 ? _d : false;
|
|
743
|
-
this.newState = actionDefinition === null || actionDefinition === void 0 ? void 0 : actionDefinition.newState;
|
|
744
|
-
this.restrictedOnField = (_f = (_e = actionDefinition.fieldRestrictedCode) === null || _e === void 0 ? void 0 : _e.toString()) !== null && _f !== void 0 ? _f : null;
|
|
745
|
-
if (this.restrictedOnField) {
|
|
746
|
-
this.restrictedOnOperator = actionDefinition.operatorRestricted || '';
|
|
747
|
-
this.restrictedOnValue = (_g = actionDefinition.valueRestricted) !== null && _g !== void 0 ? _g : '';
|
|
748
|
-
}
|
|
749
|
-
this.customValidation = () => true;
|
|
750
|
-
}
|
|
751
|
-
connectWithParentForm(form, formChangeSubject) {
|
|
752
|
-
var _a;
|
|
753
|
-
super.connectWithParentForm(form, formChangeSubject);
|
|
754
|
-
if (this.restrictedOnField) {
|
|
755
|
-
const relatedField = (_a = this._form.fields) === null || _a === void 0 ? void 0 : _a[this.restrictedOnField];
|
|
756
|
-
if (relatedField) {
|
|
757
|
-
relatedField.editionFinish.subscribe(event => this.updateRestrictedVisibility());
|
|
758
|
-
relatedField.editionPartial.subscribe(event => this.updateRestrictedVisibility());
|
|
759
|
-
}
|
|
760
|
-
}
|
|
761
|
-
}
|
|
762
|
-
updateRestrictedVisibility() {
|
|
763
|
-
const lastVisible = this._visible;
|
|
764
|
-
const newVisible = this._absoluteVisible && this.viewOnState(this._formState);
|
|
765
|
-
if (lastVisible !== newVisible) {
|
|
766
|
-
this.setVisibility(newVisible);
|
|
767
|
-
}
|
|
768
|
-
}
|
|
769
|
-
viewOnState(state) {
|
|
770
|
-
var _a;
|
|
771
|
-
const actionVisible = (this.visibleStates && state) ? this.visibleStates.includes(state) : false;
|
|
772
|
-
if (actionVisible && this._form && this.restrictedOnField) {
|
|
773
|
-
const relatedField = (_a = this._form.fields) === null || _a === void 0 ? void 0 : _a[this.restrictedOnField];
|
|
774
|
-
if (relatedField) {
|
|
775
|
-
const fieldValue = relatedField.value;
|
|
776
|
-
if ((this.restrictedOnOperator === '==' && fieldValue !== this.restrictedOnValue)
|
|
777
|
-
|| (this.restrictedOnOperator === '!=' && fieldValue === this.restrictedOnValue)) {
|
|
778
|
-
return false;
|
|
779
|
-
}
|
|
780
|
-
}
|
|
781
|
-
}
|
|
782
|
-
return actionVisible;
|
|
783
|
-
}
|
|
784
|
-
get actionActivated() { return this._actionActivated; }
|
|
785
|
-
start() { this.inProgress = true; }
|
|
786
|
-
stop() { this.inProgress = false; }
|
|
787
|
-
notifyActivation() { this._actionActivated.next(this.actionCode); }
|
|
788
|
-
updateFromServer(receivedAction) {
|
|
789
|
-
for (const propertyName in receivedAction) {
|
|
790
|
-
if (propertyName !== 'actionCode' && propertyName !== 'actionId') {
|
|
791
|
-
this[propertyName] = receivedAction[propertyName];
|
|
792
|
-
}
|
|
793
|
-
}
|
|
794
|
-
}
|
|
795
|
-
setCustomValidation(callback) { this.customValidation = () => callback(); }
|
|
796
|
-
}
|
|
797
|
-
|
|
798
|
-
const UNDEFINED = 'undefined';
|
|
799
|
-
const DEFAULT_ERROR_TYPE = 'error';
|
|
800
|
-
const DEFAULT_CAPTURE_TYPE = 'INPUT';
|
|
801
|
-
const DEFAULT_ALIGNMENT = 'left';
|
|
802
|
-
const STD_MAX_LENGTH = 50;
|
|
803
|
-
const BIG_MAX_LENGTH = 500;
|
|
804
|
-
const directChanges = [
|
|
805
|
-
'defaultEditable', 'defaultValue', 'alignment', 'required', 'errorCode', 'errorMessage', 'errorType',
|
|
806
|
-
'tooltip', 'info', 'format', 'intrinsicErrorMessage', 'outputOnly', 'captureType', 'title', 'type',
|
|
807
|
-
'maxLength', 'maxValue', 'minLength', 'minValue', 'validateOnServer', 'serverAction', 'visibleLabel',
|
|
808
|
-
'options', 'placeholder',
|
|
809
|
-
];
|
|
810
|
-
const attrs$1 = {
|
|
811
|
-
_captureType: { name: '_captureType', propagate: 'captureType' },
|
|
812
|
-
_errorCode: { name: '_errorCode', propagate: 'errorCode' },
|
|
813
|
-
_errorMessage: { name: '_errorMessage', propagate: 'errorMessage' },
|
|
814
|
-
_errorType: { name: '_errorType', propagate: 'errorType' },
|
|
815
|
-
_defaultValue: { name: '_defaultValue', propagate: 'defaultValue' },
|
|
816
|
-
_defaultEditable: { name: '_defaultEditable', propagate: 'defaultEditable' },
|
|
817
|
-
_fieldAlignment: { name: '_fieldAlignment', propagate: 'alignment' },
|
|
818
|
-
fieldCode: { name: 'fieldCode', propagate: 'code' },
|
|
819
|
-
_fieldInfo: { name: '_fieldInfo', propagate: 'info' },
|
|
820
|
-
_fieldRequired: { name: '_fieldRequired', propagate: 'required' },
|
|
821
|
-
_fieldTitle: { name: '_fieldTitle', propagate: 'title' },
|
|
822
|
-
_fieldType: { name: '_fieldType', propagate: 'type' },
|
|
823
|
-
_fieldFormat: { name: '_fieldFormat', propagate: 'format' },
|
|
824
|
-
fieldOptions: { name: 'fieldOptions', propagate: 'options' },
|
|
825
|
-
_focus: { name: '_focus', propagate: 'focus' },
|
|
826
|
-
_hasChanged: { name: '_hasChanged', propagate: 'hasChanged' },
|
|
827
|
-
_intrinsicErrorMessage: { name: '_intrinsicErrorMessage', propagate: null },
|
|
828
|
-
_maxLength: { name: '_maxLength', propagate: 'maxLength' },
|
|
829
|
-
_maxValue: { name: '_maxValue', propagate: 'maxValue' },
|
|
830
|
-
_minLength: { name: '_minLength', propagate: 'minLength' },
|
|
831
|
-
_minValue: { name: '_minValue', propagate: 'minValue' },
|
|
832
|
-
_onValidation: { name: '_onValidation', propagate: 'onValidation' },
|
|
833
|
-
_outputOnly: { name: '_outputOnly', propagate: 'outputOnly' },
|
|
834
|
-
_placeholder: { name: '_placeholder', propagate: 'placeholder' },
|
|
835
|
-
_tooltipText: { name: '_tooltipText', propagate: 'tooltip' },
|
|
836
|
-
_validateOnServer: { name: '_validateOnServer', propagate: 'validateOnServer' },
|
|
837
|
-
_value: { name: '_value', propagate: 'value' },
|
|
838
|
-
_visibleLabel: { name: '_visibleLabel', propagate: 'visibleLabel' },
|
|
839
|
-
};
|
|
840
|
-
class FieldDescriptor extends FormElement {
|
|
841
|
-
constructor(inputFieldReceived, formConfig) {
|
|
842
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z;
|
|
843
|
-
super(inputFieldReceived, formConfig);
|
|
844
|
-
this._editionFinish = new Subject();
|
|
845
|
-
this._editionPartial = new Subject();
|
|
846
|
-
this._detailRequest = new Subject();
|
|
847
|
-
this._errorType = '';
|
|
848
|
-
this._errorCode = '';
|
|
849
|
-
this._errorMessage = '';
|
|
850
|
-
this._intrinsicErrorMessage = '';
|
|
851
|
-
this._maxLength = 0;
|
|
852
|
-
this._minLength = 0;
|
|
853
|
-
this._focus = false;
|
|
854
|
-
this._onValidation = false;
|
|
855
|
-
this._validateOnServer = false;
|
|
856
|
-
this._visibleLabel = false;
|
|
857
|
-
this._captureType = '';
|
|
858
|
-
this._defaultValue = '';
|
|
859
|
-
this._defaultEditable = false;
|
|
860
|
-
this._fieldAlignment = '';
|
|
861
|
-
this._fieldInfo = '';
|
|
862
|
-
this._fieldRequired = false;
|
|
863
|
-
this._fieldTitle = '';
|
|
864
|
-
this._fieldType = '';
|
|
865
|
-
this._fieldFormat = null;
|
|
866
|
-
this._hasChanged = false;
|
|
867
|
-
this._outputOnly = false;
|
|
868
|
-
this._tooltipText = '';
|
|
869
|
-
this._placeholder = '';
|
|
870
|
-
this.fieldCode = '';
|
|
871
|
-
this.fieldOptions = null;
|
|
872
|
-
this.propagationCustomAttributes = (_c = (_b = (_a = this._formConfig) === null || _a === void 0 ? void 0 : _a.propagationCustomAttributes) === null || _b === void 0 ? void 0 : _b.fields) !== null && _c !== void 0 ? _c : [];
|
|
873
|
-
this.elementType = elementTypes.field;
|
|
874
|
-
const fld = (inputFieldReceived) ? inputFieldReceived : {};
|
|
875
|
-
this.setAttr(attrs$1.fieldCode, fld.fieldCode);
|
|
876
|
-
this.title = (_d = fld.fieldTitle) !== null && _d !== void 0 ? _d : this.fieldCode;
|
|
877
|
-
this.placeholder = (_e = fld.placeholder) !== null && _e !== void 0 ? _e : this.title;
|
|
878
|
-
this.type = fld.fieldTypeCode;
|
|
879
|
-
this.captureType = (_f = fld.captureType) !== null && _f !== void 0 ? _f : DEFAULT_CAPTURE_TYPE;
|
|
880
|
-
const defaultValue = (_g = fld.defaultValue) !== null && _g !== void 0 ? _g : null;
|
|
881
|
-
if (this._fieldType === this._formConfig.fieldTypes.boolean) {
|
|
882
|
-
this.defaultValue = defaultValue !== null && defaultValue !== void 0 ? defaultValue : false;
|
|
883
|
-
}
|
|
884
|
-
else {
|
|
885
|
-
this.defaultValue = defaultValue;
|
|
886
|
-
}
|
|
887
|
-
const defaultTypeAlignment = (this._formConfig.tableFieldStyles[this._fieldType] != null)
|
|
888
|
-
? this._formConfig.tableFieldStyles[this._fieldType]['text-align'] : DEFAULT_ALIGNMENT;
|
|
889
|
-
const fieldAlignment = (fld.alignment != null) ? fld.alignment.toLowerCase() : defaultTypeAlignment;
|
|
890
|
-
this.alignment = fieldAlignment;
|
|
891
|
-
this.info = fld.info || '';
|
|
892
|
-
let fieldFormat;
|
|
893
|
-
try {
|
|
894
|
-
fieldFormat = (fld.format) ? new RegExp(fld.format) : null;
|
|
895
|
-
}
|
|
896
|
-
catch (e) {
|
|
897
|
-
fieldFormat = null;
|
|
898
|
-
}
|
|
899
|
-
this.format = fieldFormat;
|
|
900
|
-
this.validateOnServer = (_h = fld.serverAction) !== null && _h !== void 0 ? _h : false;
|
|
901
|
-
this.tooltip = fld.tooltip || '';
|
|
902
|
-
this.defaultEditable = this.enabled;
|
|
903
|
-
this.required = (_j = fld.required) !== null && _j !== void 0 ? _j : false;
|
|
904
|
-
this.outputOnly = (_k = fld.outputOnly) !== null && _k !== void 0 ? _k : false;
|
|
905
|
-
this.minLength = (_l = fld.minLength) !== null && _l !== void 0 ? _l : 0;
|
|
906
|
-
this.maxLength = fld.maxLength || (this._captureType === 'TEXTAREA' ? BIG_MAX_LENGTH : STD_MAX_LENGTH);
|
|
907
|
-
this.intrinsicErrorMessage = (_u = (_q = (_p = (_o = (_m = this._formConfig) === null || _m === void 0 ? void 0 : _m.fieldValidations) === null || _o === void 0 ? void 0 : _o[this._fieldType]) === null || _p === void 0 ? void 0 : _p.message) !== null && _q !== void 0 ? _q : (_t = (_s = (_r = this._formConfig) === null || _r === void 0 ? void 0 : _r.fieldValidations) === null || _s === void 0 ? void 0 : _s.DEFAULT) === null || _t === void 0 ? void 0 : _t.message) !== null && _u !== void 0 ? _u : '';
|
|
908
|
-
this.setError(fld.errorCode, fld.errorMessage, (_v = fld.errorType) !== null && _v !== void 0 ? _v : DEFAULT_ERROR_TYPE);
|
|
909
|
-
this.setEditable((_w = fld.editable) !== null && _w !== void 0 ? _w : true);
|
|
910
|
-
this.visibleLabel = (_x = fld.visibleLabel) !== null && _x !== void 0 ? _x : true;
|
|
911
|
-
this.setVisibility(fld.visible);
|
|
912
|
-
this.options = fld.fieldOptions;
|
|
913
|
-
this._setValue((_z = (_y = fld.fieldValue) !== null && _y !== void 0 ? _y : this._defaultValue) !== null && _z !== void 0 ? _z : '');
|
|
914
|
-
}
|
|
915
|
-
get alignment() { return this._fieldAlignment; }
|
|
916
|
-
set alignment(alignment) { this.setAttr(attrs$1._fieldAlignment, alignment); }
|
|
917
|
-
get backend() { return this._validateOnServer; }
|
|
918
|
-
get captureType() { return this._captureType; }
|
|
919
|
-
set captureType(captureType) { this.setAttr(attrs$1._captureType, captureType); }
|
|
920
|
-
get placeholder() { return this._placeholder; }
|
|
921
|
-
set placeholder(placeholder) { this.setAttr(attrs$1._placeholder, placeholder); }
|
|
922
|
-
get code() { return this.fieldCode; }
|
|
923
|
-
get defaultValue() { return this._defaultValue; }
|
|
924
|
-
set defaultValue(defaultValue) { this.setAttr(attrs$1._defaultValue, defaultValue); }
|
|
925
|
-
get defaultEditable() { return this._defaultEditable; }
|
|
926
|
-
set defaultEditable(editable) { this.setAttr(attrs$1._defaultEditable, editable); }
|
|
927
|
-
get detailRequest() { return this._detailRequest; }
|
|
928
|
-
get editionFinish() { return this._editionFinish; }
|
|
929
|
-
get editionPartial() { return this._editionPartial; }
|
|
930
|
-
get empty() {
|
|
931
|
-
var _a;
|
|
932
|
-
const fieldCurrentValue = this.value;
|
|
933
|
-
if (fieldCurrentValue === undefined || fieldCurrentValue === null) {
|
|
934
|
-
return true;
|
|
935
|
-
}
|
|
936
|
-
if (this._fieldType === this._formConfig.fieldTypes.array
|
|
937
|
-
&& Array.isArray(fieldCurrentValue) && fieldCurrentValue.length === 0) {
|
|
938
|
-
return true;
|
|
939
|
-
}
|
|
940
|
-
;
|
|
941
|
-
if (this._fieldType === this._formConfig.fieldTypes.phone) {
|
|
942
|
-
if (!Array.isArray(fieldCurrentValue)) {
|
|
943
|
-
return true;
|
|
944
|
-
}
|
|
945
|
-
if (fieldCurrentValue.length !== 2 || !fieldCurrentValue[0] || !fieldCurrentValue[1]) {
|
|
946
|
-
return true;
|
|
947
|
-
}
|
|
948
|
-
return false;
|
|
949
|
-
}
|
|
950
|
-
;
|
|
951
|
-
const arrayFieldTypes = (_a = this._formConfig.arrayFieldTypes) !== null && _a !== void 0 ? _a : null;
|
|
952
|
-
if (arrayFieldTypes && Object.keys(arrayFieldTypes).includes(this._fieldType)) {
|
|
953
|
-
let arraySize = arrayFieldTypes[this._fieldType];
|
|
954
|
-
arraySize = !Number.isNaN(+arraySize) ? +arraySize : 0;
|
|
955
|
-
if (arraySize === 0) {
|
|
956
|
-
return (Array.isArray(fieldCurrentValue) && fieldCurrentValue.length === 0);
|
|
957
|
-
}
|
|
958
|
-
return (Array.isArray(fieldCurrentValue) && fieldCurrentValue.length < arraySize);
|
|
959
|
-
}
|
|
960
|
-
;
|
|
961
|
-
return fieldCurrentValue === '';
|
|
962
|
-
}
|
|
963
|
-
get error() { return { type: this._errorType, code: this._errorCode, message: this._errorMessage }; }
|
|
964
|
-
set error(errorObj) { var _a; this.setError(errorObj.code, errorObj.message, (_a = errorObj.type) !== null && _a !== void 0 ? _a : DEFAULT_ERROR_TYPE); }
|
|
965
|
-
get errorCode() { return this._errorCode; }
|
|
966
|
-
set errorCode(code) { this.setError(code, this._errorMessage); }
|
|
967
|
-
get errorMessage() { return this._errorMessage; }
|
|
968
|
-
set errorMessage(msg) { this.setError(this._errorCode, msg); }
|
|
969
|
-
get errorType() { return this._errorType; }
|
|
970
|
-
get externalValue() { return this._externalValue; }
|
|
971
|
-
get format() { return this._fieldFormat; }
|
|
972
|
-
set format(format) { this.setAttr(attrs$1._fieldFormat, format); }
|
|
973
|
-
get hasChanged() { return this._hasChanged; }
|
|
974
|
-
set hasChanged(hasChanged) { this.setAttr(attrs$1._hasChanged, hasChanged); }
|
|
975
|
-
get info() { return this._fieldInfo; }
|
|
976
|
-
set info(newInfo) { this.setAttr(attrs$1._fieldInfo, newInfo); }
|
|
977
|
-
set intrinsicErrorMessage(message) { this.setAttr(attrs$1._intrinsicErrorMessage, message); }
|
|
978
|
-
get maxLength() { return (this._maxLength > 0) ? this._maxLength.toString() : ''; }
|
|
979
|
-
set maxLength(requiredMaxLength) { this.setAttr(attrs$1._maxLength, requiredMaxLength ? +requiredMaxLength : null); }
|
|
980
|
-
get maxValue() { return this._maxValue; }
|
|
981
|
-
set maxValue(inputMaxValue) {
|
|
982
|
-
let maxValue = inputMaxValue;
|
|
983
|
-
if (this._fieldType === this._formConfig.fieldTypes.date) {
|
|
984
|
-
maxValue = new Date(maxValue);
|
|
985
|
-
}
|
|
986
|
-
this.setAttr(attrs$1._maxValue, maxValue);
|
|
987
|
-
}
|
|
988
|
-
get minLength() { return this._minLength; }
|
|
989
|
-
set minLength(requiredMinLength) {
|
|
990
|
-
this.setAttr(attrs$1._minLength, requiredMinLength ? +requiredMinLength : null);
|
|
991
|
-
}
|
|
992
|
-
get minValue() { return this._minValue; }
|
|
993
|
-
set minValue(inputMinValue) {
|
|
994
|
-
let minValue = inputMinValue;
|
|
995
|
-
if (this._fieldType === this._formConfig.fieldTypes.date) {
|
|
996
|
-
minValue = new Date(minValue);
|
|
997
|
-
}
|
|
998
|
-
this.setAttr(attrs$1._minValue, minValue);
|
|
999
|
-
}
|
|
1000
|
-
get name() { return this.fieldCode; }
|
|
1001
|
-
get options() {
|
|
1002
|
-
var _a, _b;
|
|
1003
|
-
return (_b = (_a = this.fieldOptions) === null || _a === void 0 ? void 0 : _a.map(option => {
|
|
1004
|
-
const optionCopy = Object.assign({}, option);
|
|
1005
|
-
return optionCopy;
|
|
1006
|
-
})) !== null && _b !== void 0 ? _b : null;
|
|
1007
|
-
}
|
|
1008
|
-
set options(newOptions) {
|
|
1009
|
-
var _a, _b, _c, _d, _e;
|
|
1010
|
-
if ((!this._formConfig.captureTypesWithOptions.includes(this._captureType))
|
|
1011
|
-
|| typeof newOptions === UNDEFINED || !newOptions
|
|
1012
|
-
|| !Array.isArray(newOptions)) {
|
|
1013
|
-
return;
|
|
1014
|
-
}
|
|
1015
|
-
let fieldOptions = newOptions.map((option) => {
|
|
1016
|
-
if (option.text !== undefined && option.text !== null
|
|
1017
|
-
&& option.value !== undefined && option.value !== null) {
|
|
1018
|
-
return { fieldOptionValue: option.text, fieldOptionId: option.value };
|
|
1019
|
-
}
|
|
1020
|
-
return option;
|
|
1021
|
-
});
|
|
1022
|
-
fieldOptions = (fieldOptions && Array.isArray(fieldOptions)
|
|
1023
|
-
&& fieldOptions.length > 0) ? fieldOptions : [];
|
|
1024
|
-
this.setAttr(attrs$1.fieldOptions, fieldOptions);
|
|
1025
|
-
if (this._value) {
|
|
1026
|
-
if (this._fieldType === this._formConfig.fieldTypes.array && Array.isArray(this._value)) {
|
|
1027
|
-
const fieldValue = (_a = this._value) === null || _a === void 0 ? void 0 : _a.filter(item => { var _a; return (_a = this.fieldOptions) === null || _a === void 0 ? void 0 : _a.find(opt => opt.fieldOptionId === item); });
|
|
1028
|
-
this.setAttr(attrs$1._value, fieldValue);
|
|
1029
|
-
}
|
|
1030
|
-
else {
|
|
1031
|
-
const valInOptions = (_b = this.fieldOptions) === null || _b === void 0 ? void 0 : _b.find(item => item.fieldOptionId === this._value);
|
|
1032
|
-
if (!valInOptions) {
|
|
1033
|
-
this._setValue('');
|
|
1034
|
-
}
|
|
1035
|
-
}
|
|
1036
|
-
}
|
|
1037
|
-
if (this._fieldRequired && ((_c = this.fieldOptions) === null || _c === void 0 ? void 0 : _c.length) === 1 && this._value !== ((_d = this.fieldOptions) === null || _d === void 0 ? void 0 : _d[0].fieldOptionId)) {
|
|
1038
|
-
this._setValue((_e = this.fieldOptions) === null || _e === void 0 ? void 0 : _e[0].fieldOptionId);
|
|
1039
|
-
this.notifyEditionFinish();
|
|
1040
|
-
}
|
|
1041
|
-
}
|
|
1042
|
-
get optionText() { var _a, _b, _c; return (_c = (_b = (_a = this.fieldOptions) === null || _a === void 0 ? void 0 : _a.find(item => item.fieldOptionId === this._value)) === null || _b === void 0 ? void 0 : _b.fieldOptionValue) !== null && _c !== void 0 ? _c : null; }
|
|
1043
|
-
get outputOnly() { return this._outputOnly; }
|
|
1044
|
-
set outputOnly(outputOnly) { this.setAttr(attrs$1._outputOnly, outputOnly); }
|
|
1045
|
-
get required() { return this._fieldRequired; }
|
|
1046
|
-
set required(required) { this.setAttr(attrs$1._fieldRequired, required !== null && required !== void 0 ? required : false); }
|
|
1047
|
-
get title() { return this._fieldTitle; }
|
|
1048
|
-
set title(title) { var _a; this.setAttr(attrs$1._fieldTitle, (_a = title === null || title === void 0 ? void 0 : title.toString()) !== null && _a !== void 0 ? _a : ''); }
|
|
1049
|
-
get tooltip() { return this._tooltipText; }
|
|
1050
|
-
set tooltip(tooltip) { this.setAttr(attrs$1._tooltipText, tooltip); }
|
|
1051
|
-
get type() { return this._fieldType; }
|
|
1052
|
-
set type(fieldType) { this.setAttr(attrs$1._fieldType, fieldType); }
|
|
1053
|
-
get validating() { return this._onValidation; }
|
|
1054
|
-
set validating(isValidating) { this.setAttr(attrs$1._onValidation, isValidating); }
|
|
1055
|
-
get value() {
|
|
1056
|
-
return (this._fieldType === this._formConfig.fieldTypes.boolean
|
|
1057
|
-
|| this._fieldType === this._formConfig.fieldTypes.check) ? yn(this._value) : this._value;
|
|
1058
|
-
}
|
|
1059
|
-
get validateOnServer() { return this._validateOnServer; }
|
|
1060
|
-
set validateOnServer(validateOnServer) { this.setAttr(attrs$1._validateOnServer, validateOnServer); }
|
|
1061
|
-
get serverAction() { return this._validateOnServer; }
|
|
1062
|
-
set serverAction(validateOnServer) { this.validateOnServer = validateOnServer; }
|
|
1063
|
-
set value(newValue) { this._setValue(newValue); }
|
|
1064
|
-
get visibleLabel() { return this._visibleLabel; }
|
|
1065
|
-
set visibleLabel(visibleLabel) { this.setAttr(attrs$1._visibleLabel, visibleLabel); }
|
|
1066
|
-
/**
|
|
1067
|
-
* @deprecated Use value
|
|
1068
|
-
*/
|
|
1069
|
-
get fieldValue() { return this.value; }
|
|
1070
|
-
/**
|
|
1071
|
-
* @deprecated Use hasChanged
|
|
1072
|
-
*/
|
|
1073
|
-
changed(hasChanged = true) { this.hasChanged = hasChanged; }
|
|
1074
|
-
clean() { this._setValue(this._defaultValue || ''); this.resetError(); }
|
|
1075
|
-
focus() { this.setAttr(attrs$1._focus, true); }
|
|
1076
|
-
getErrorCode() { return this.error.code; }
|
|
1077
|
-
setErrorCode(code) { this.setError(code, this._errorMessage); }
|
|
1078
|
-
getErrorMessage() { return this.error.message; }
|
|
1079
|
-
setErrorMessage(msg) { this.setError(this._errorCode, msg); }
|
|
1080
|
-
getRequired() { return this.required; }
|
|
1081
|
-
hasError() { return this._errorCode !== NO_ERROR; }
|
|
1082
|
-
hideLabel() { this.visibleLabel = false; }
|
|
1083
|
-
resetError() { (this._errorCode !== NO_ERROR) && this.setError(NO_ERROR, null); }
|
|
1084
|
-
setEditable(editable = true) { (editable) ? this.enable() : this.disable(); }
|
|
1085
|
-
setValue(newValue, widgetUpdate = true) { this._setValue(newValue, widgetUpdate); }
|
|
1086
|
-
showLabel() { this.visibleLabel = true; }
|
|
1087
|
-
/**
|
|
1088
|
-
* @deprecated Use title
|
|
1089
|
-
*/
|
|
1090
|
-
setLabel(label) { this.title = label; }
|
|
1091
|
-
/**
|
|
1092
|
-
* @deprecated Use required
|
|
1093
|
-
*/
|
|
1094
|
-
setRequired(required) { this.required = required; }
|
|
1095
|
-
/**
|
|
1096
|
-
* @deprecated Use changed
|
|
1097
|
-
*/
|
|
1098
|
-
setChanged(hasChanged) { this.changed(hasChanged); }
|
|
1099
|
-
/**
|
|
1100
|
-
* @deprecated Use value
|
|
1101
|
-
*/
|
|
1102
|
-
getValue() { return this.value; }
|
|
1103
|
-
/**
|
|
1104
|
-
* @deprecated Use empty
|
|
1105
|
-
*/
|
|
1106
|
-
isEmpty() { return this.empty; }
|
|
1107
|
-
/**
|
|
1108
|
-
* @deprecated Use error
|
|
1109
|
-
*/
|
|
1110
|
-
getError() { return this.error; }
|
|
1111
|
-
/**
|
|
1112
|
-
* @deprecated Use optionText
|
|
1113
|
-
*/
|
|
1114
|
-
getOptionText() { return this.optionText; }
|
|
1115
|
-
/**
|
|
1116
|
-
* @deprecated Use options
|
|
1117
|
-
*/
|
|
1118
|
-
getFieldOptions() { return this.options; }
|
|
1119
|
-
/**
|
|
1120
|
-
* @deprecated Use options
|
|
1121
|
-
*/
|
|
1122
|
-
setFieldOptions(newOptions) { return this.options = newOptions; }
|
|
1123
|
-
/**
|
|
1124
|
-
* @deprecated Use intrinsicErrorMessage
|
|
1125
|
-
*/
|
|
1126
|
-
setIntrinsicErrorMessage(message) { this.intrinsicErrorMessage = message; }
|
|
1127
|
-
/**
|
|
1128
|
-
* @deprecated Use maxValue
|
|
1129
|
-
*/
|
|
1130
|
-
setMaxValue(inputMaxValue) { this.maxValue = inputMaxValue; }
|
|
1131
|
-
/**
|
|
1132
|
-
* @deprecated Use minValue
|
|
1133
|
-
*/
|
|
1134
|
-
setMinValue(inputMinValue) { this.minValue = inputMinValue; }
|
|
1135
|
-
/**
|
|
1136
|
-
* @deprecated Use showLabel
|
|
1137
|
-
*/
|
|
1138
|
-
setVisibleLabel(visibleLabel) { this.visibleLabel = visibleLabel; }
|
|
1139
|
-
notifyEditionPartial() {
|
|
1140
|
-
this.resetError();
|
|
1141
|
-
this._editionPartial.next({ code: this.fieldCode, intrinsicValidation: true });
|
|
1142
|
-
}
|
|
1143
|
-
notifyEditionFinish() {
|
|
1144
|
-
var _a, _b, _c, _d, _e;
|
|
1145
|
-
const fieldValue = this.value;
|
|
1146
|
-
this.resetError();
|
|
1147
|
-
const validationConfig = (_b = (_a = this._formConfig.fieldValidations) === null || _a === void 0 ? void 0 : _a[this._fieldType]) !== null && _b !== void 0 ? _b : {};
|
|
1148
|
-
const { type, validation } = validationConfig;
|
|
1149
|
-
let message = validationConfig === null || validationConfig === void 0 ? void 0 : validationConfig.message;
|
|
1150
|
-
let intrinsicValidation = true;
|
|
1151
|
-
if (fieldValue && (validation || this._fieldFormat)) {
|
|
1152
|
-
if (type === 'regexp') {
|
|
1153
|
-
intrinsicValidation = ((_c = validation === null || validation === void 0 ? void 0 : validation.test(fieldValue)) !== null && _c !== void 0 ? _c : true)
|
|
1154
|
-
&& ((_e = (_d = this._fieldFormat) === null || _d === void 0 ? void 0 : _d.test(fieldValue)) !== null && _e !== void 0 ? _e : true);
|
|
1155
|
-
}
|
|
1156
|
-
else if (type === 'function' && typeof validation === 'function') {
|
|
1157
|
-
const { valid, message: customMessage } = validation(fieldValue, this);
|
|
1158
|
-
intrinsicValidation = valid;
|
|
1159
|
-
message = customMessage;
|
|
1160
|
-
}
|
|
1161
|
-
if (!intrinsicValidation) {
|
|
1162
|
-
this.setError('99', message !== null && message !== void 0 ? message : this._intrinsicErrorMessage);
|
|
1163
|
-
}
|
|
1164
|
-
}
|
|
1165
|
-
if (intrinsicValidation && fieldValue && this._minValue && fieldValue < this._minValue) {
|
|
1166
|
-
intrinsicValidation = false;
|
|
1167
|
-
this.setError('99', 'Campo con valor inferior al mínimo');
|
|
1168
|
-
}
|
|
1169
|
-
if (intrinsicValidation && fieldValue && this._maxValue && fieldValue > this._maxValue) {
|
|
1170
|
-
intrinsicValidation = false;
|
|
1171
|
-
this.setError('99', 'Campo con valor superior al máximo');
|
|
1172
|
-
}
|
|
1173
|
-
if (intrinsicValidation && fieldValue && typeof fieldValue === 'string'
|
|
1174
|
-
&& this._minLength && (fieldValue === null || fieldValue === void 0 ? void 0 : fieldValue.length) < this._minLength) {
|
|
1175
|
-
intrinsicValidation = false;
|
|
1176
|
-
this.setError('99', `Longitud de ${this._fieldTitle} debe ser de al menos ${this._minLength}`);
|
|
1177
|
-
}
|
|
1178
|
-
this._editionFinish.next({ code: this.fieldCode, intrinsicValidation });
|
|
1179
|
-
}
|
|
1180
|
-
notifyEditionDetailRequest(detail) {
|
|
1181
|
-
const detailEvent = { code: this.fieldCode, detail };
|
|
1182
|
-
this._detailRequest.next(detailEvent);
|
|
1183
|
-
}
|
|
1184
|
-
setError(code, message, type = DEFAULT_ERROR_TYPE) {
|
|
1185
|
-
this.setAttr(attrs$1._errorCode, code !== null && code !== void 0 ? code : NO_ERROR);
|
|
1186
|
-
this.setAttr(attrs$1._errorType, (this._errorCode === NO_ERROR) ? '' : type);
|
|
1187
|
-
this.setAttr(attrs$1._errorMessage, message !== null && message !== void 0 ? message : '');
|
|
1188
|
-
}
|
|
1189
|
-
updateFromServer(fld) {
|
|
1190
|
-
const fieldKeys = Object.keys(fld);
|
|
1191
|
-
for (let index = 0; index < fieldKeys.length; index++) {
|
|
1192
|
-
const attrName = fieldKeys[index];
|
|
1193
|
-
const attrValue = fld[attrName];
|
|
1194
|
-
if (directChanges.includes(attrName)) {
|
|
1195
|
-
this[attrName] = attrValue;
|
|
1196
|
-
}
|
|
1197
|
-
else {
|
|
1198
|
-
(attrName === 'label') && (this.title = attrValue);
|
|
1199
|
-
(attrName === 'labelVisible') && (this.visibleLabel = attrValue);
|
|
1200
|
-
(attrName === 'editable') && this.setEditable(attrValue);
|
|
1201
|
-
(attrName === 'visible') && this.setVisibility(attrValue);
|
|
1202
|
-
(attrName === 'value') && (this._setValue(attrValue) && (this.hasChanged = false));
|
|
1203
|
-
(attrName === 'fieldValue') && (this._setValue(attrValue) && (this.hasChanged = false));
|
|
1204
|
-
(attrName === 'fieldOptions') && (this.options = attrValue);
|
|
1205
|
-
(attrName === 'fieldTitle') && (this.title = attrValue);
|
|
1206
|
-
(attrName === 'fieldTypeCode') && (this.type = attrValue);
|
|
1207
|
-
(attrName === 'fieldType') && (this.type = attrValue);
|
|
1208
|
-
(attrName === 'tooltipText') && (this.tooltip = attrValue);
|
|
1209
|
-
}
|
|
1210
|
-
}
|
|
1211
|
-
}
|
|
1212
|
-
_setValue(newValue, widgetUpdate = true) {
|
|
1213
|
-
var _a;
|
|
1214
|
-
if (typeof newValue === UNDEFINED) {
|
|
1215
|
-
return true;
|
|
1216
|
-
}
|
|
1217
|
-
if (newValue === null && this.required) {
|
|
1218
|
-
return true;
|
|
1219
|
-
}
|
|
1220
|
-
let newFinalValue;
|
|
1221
|
-
if (this._fieldType === this._formConfig.fieldTypes.boolean
|
|
1222
|
-
|| this._fieldType === this._formConfig.fieldTypes.check) {
|
|
1223
|
-
newFinalValue = (_a = yn(newValue)) !== null && _a !== void 0 ? _a : false;
|
|
1224
|
-
}
|
|
1225
|
-
else if (this._fieldType === this._formConfig.fieldTypes.array
|
|
1226
|
-
|| this._fieldType === this._formConfig.fieldTypes.map) {
|
|
1227
|
-
if (newValue === null || newValue === '') {
|
|
1228
|
-
newFinalValue = [];
|
|
1229
|
-
}
|
|
1230
|
-
else if (Array.isArray(newValue)) {
|
|
1231
|
-
newFinalValue = newValue;
|
|
1232
|
-
}
|
|
1233
|
-
else {
|
|
1234
|
-
newFinalValue = newValue.toString().split(',');
|
|
1235
|
-
}
|
|
1236
|
-
}
|
|
1237
|
-
else {
|
|
1238
|
-
newFinalValue = newValue;
|
|
1239
|
-
}
|
|
1240
|
-
if (this._value !== newFinalValue) {
|
|
1241
|
-
this.hasChanged = true;
|
|
1242
|
-
if (widgetUpdate) {
|
|
1243
|
-
this.setAttr(attrs$1._value, newFinalValue);
|
|
1244
|
-
}
|
|
1245
|
-
else {
|
|
1246
|
-
this._value = newFinalValue;
|
|
1247
|
-
}
|
|
1248
|
-
}
|
|
1249
|
-
return true;
|
|
1250
|
-
}
|
|
1251
|
-
}
|
|
1252
|
-
|
|
1253
|
-
class RecordTableColumn extends FormPiece {
|
|
1254
|
-
constructor(recTableColReceived, formConfig) {
|
|
1255
|
-
var _a, _b, _c, _d;
|
|
1256
|
-
super(recTableColReceived, formConfig);
|
|
1257
|
-
this.fieldCode = '';
|
|
1258
|
-
this.fieldTitle = '';
|
|
1259
|
-
this.fieldType = '';
|
|
1260
|
-
this.fieldAlignment = '';
|
|
1261
|
-
this.fieldFormat = '';
|
|
1262
|
-
this.sortable = true;
|
|
1263
|
-
this.searchable = true;
|
|
1264
|
-
this.sortDirections = [];
|
|
1265
|
-
// Filtros
|
|
1266
|
-
this.filterVisible = false;
|
|
1267
|
-
this.filterDef = null;
|
|
1268
|
-
this.filterSetup = null;
|
|
1269
|
-
this.filterDef = null;
|
|
1270
|
-
if (recTableColReceived) {
|
|
1271
|
-
this.fieldCode = recTableColReceived.fieldCode;
|
|
1272
|
-
this.fieldTitle = recTableColReceived.fieldTitle;
|
|
1273
|
-
this.fieldType = recTableColReceived.fieldTypeCode || this._formConfig.fieldTypes.text;
|
|
1274
|
-
const defaultTypeAlignment = (this._formConfig.tableFieldStyles[this.fieldType] != null) ? this._formConfig.tableFieldStyles[this.fieldType]['text-align'] : 'left';
|
|
1275
|
-
this.fieldAlignment = (recTableColReceived.alignment != null) ? recTableColReceived.alignment.toLowerCase() : defaultTypeAlignment;
|
|
1276
|
-
this._absoluteVisible = (_a = recTableColReceived === null || recTableColReceived === void 0 ? void 0 : recTableColReceived.visible) !== null && _a !== void 0 ? _a : true;
|
|
1277
|
-
this.sortable = (_b = recTableColReceived === null || recTableColReceived === void 0 ? void 0 : recTableColReceived.sortable) !== null && _b !== void 0 ? _b : false;
|
|
1278
|
-
this.searchable = (_c = recTableColReceived === null || recTableColReceived === void 0 ? void 0 : recTableColReceived.searchable) !== null && _c !== void 0 ? _c : true;
|
|
1279
|
-
this.sortDirections = (this.sortable) ? ['ascend', 'descend'] : [];
|
|
1280
|
-
this.fieldFormat = recTableColReceived.format || '';
|
|
1281
|
-
this.customAttributes = (_d = recTableColReceived === null || recTableColReceived === void 0 ? void 0 : recTableColReceived.customAttributes) !== null && _d !== void 0 ? _d : {};
|
|
1282
|
-
}
|
|
1283
|
-
}
|
|
1284
|
-
setSearchable(searchable = true) { this.searchable = searchable; }
|
|
1285
|
-
hideFilter() {
|
|
1286
|
-
this.filterVisible = false;
|
|
1287
|
-
}
|
|
1288
|
-
addFilterDefinition(filterDefinition) {
|
|
1289
|
-
var _a;
|
|
1290
|
-
this.filterDef = {
|
|
1291
|
-
operators: filterDefinition.operators,
|
|
1292
|
-
options: (_a = filterDefinition.options) !== null && _a !== void 0 ? _a : null,
|
|
1293
|
-
};
|
|
1294
|
-
}
|
|
1295
|
-
get filterDefinition() {
|
|
1296
|
-
return this.filterDef;
|
|
1297
|
-
}
|
|
1298
|
-
addFilter(columnValues, operator) {
|
|
1299
|
-
var _a, _b;
|
|
1300
|
-
this.filterSetup = {
|
|
1301
|
-
fieldCode: this.fieldCode,
|
|
1302
|
-
operator: (_b = operator !== null && operator !== void 0 ? operator : (_a = this.filterDef) === null || _a === void 0 ? void 0 : _a.operators[0]) !== null && _b !== void 0 ? _b : 'IN',
|
|
1303
|
-
values: columnValues,
|
|
1304
|
-
};
|
|
1305
|
-
}
|
|
1306
|
-
get filter() {
|
|
1307
|
-
return this.filterSetup;
|
|
1308
|
-
}
|
|
1309
|
-
removeFilter() {
|
|
1310
|
-
this.filterSetup = null;
|
|
1311
|
-
}
|
|
1312
|
-
get options() {
|
|
1313
|
-
var _a, _b, _c, _d;
|
|
1314
|
-
if (((_b = (_a = this.filterDef) === null || _a === void 0 ? void 0 : _a.operators) === null || _b === void 0 ? void 0 : _b.length) === 1 && ((_c = this.filterDef) === null || _c === void 0 ? void 0 : _c.operators[0]) === 'IN') {
|
|
1315
|
-
return (_d = this.filterDef) === null || _d === void 0 ? void 0 : _d.options;
|
|
1316
|
-
}
|
|
1317
|
-
return null;
|
|
1318
|
-
}
|
|
1319
|
-
serSortDirections(ascend, descend) {
|
|
1320
|
-
this.sortDirections = [];
|
|
1321
|
-
if (ascend) {
|
|
1322
|
-
this.sortDirections.unshift('ascend');
|
|
1323
|
-
}
|
|
1324
|
-
if (descend) {
|
|
1325
|
-
this.sortDirections.unshift('descend');
|
|
1326
|
-
}
|
|
1327
|
-
}
|
|
1328
|
-
}
|
|
1329
|
-
|
|
1330
|
-
class TableAction extends FormPiece {
|
|
1331
|
-
constructor(actionDefinition, formConfig) {
|
|
1332
|
-
var _a, _b, _c;
|
|
1333
|
-
super(actionDefinition, formConfig);
|
|
1334
|
-
this.restrictedOnField = null;
|
|
1335
|
-
this.restrictedOnValue = null;
|
|
1336
|
-
this.restrictedOnOperator = null;
|
|
1337
|
-
this.actionCode = actionDefinition.actionCode;
|
|
1338
|
-
this.actionTitle = actionDefinition.actionTitle;
|
|
1339
|
-
this.iconName = actionDefinition.iconName || this.actionCode;
|
|
1340
|
-
this.actionType = actionDefinition.actionType || 'STANDARD';
|
|
1341
|
-
this.actionClass = actionDefinition.actionClass || 'INLINE';
|
|
1342
|
-
this.newState = actionDefinition.newState;
|
|
1343
|
-
this.stateField = actionDefinition.stateField || '';
|
|
1344
|
-
this.backend = (_a = actionDefinition === null || actionDefinition === void 0 ? void 0 : actionDefinition.serverAction) !== null && _a !== void 0 ? _a : false;
|
|
1345
|
-
this.restrictedOnField = (_b = actionDefinition.fieldRestrictedCode) !== null && _b !== void 0 ? _b : null;
|
|
1346
|
-
if (this.restrictedOnField) {
|
|
1347
|
-
this.restrictedOnValue = (_c = actionDefinition.valueRestricted) !== null && _c !== void 0 ? _c : null;
|
|
1348
|
-
this.restrictedOnOperator = actionDefinition.operatorRestricted || null;
|
|
1349
|
-
}
|
|
1350
|
-
}
|
|
1351
|
-
formStateChange(state) {
|
|
1352
|
-
if (state) {
|
|
1353
|
-
this._formState = state;
|
|
1354
|
-
this._visible = this._absoluteVisible && this.viewOnState(state);
|
|
1355
|
-
this._disabled = this._absoluteDisabled || !this.enabledOnState(state);
|
|
1356
|
-
}
|
|
1357
|
-
}
|
|
1358
|
-
}
|
|
1359
|
-
|
|
1360
|
-
class TableRecordData {
|
|
1361
|
-
constructor(recordReceived, recordDefinition, selectionFieldName = null) {
|
|
1362
|
-
this.recordId = null;
|
|
1363
|
-
this.selected = false;
|
|
1364
|
-
this.recordData = {};
|
|
1365
|
-
const { tableRecordId, recordData } = recordReceived;
|
|
1366
|
-
this.recordId = tableRecordId;
|
|
1367
|
-
if (!recordDefinition || recordDefinition.length === 0 || !recordData || recordData.length === 0) {
|
|
1368
|
-
return;
|
|
1369
|
-
}
|
|
1370
|
-
const fieldNames = recordDefinition.map(column => column.fieldCode);
|
|
1371
|
-
if (Array.isArray(recordData)) {
|
|
1372
|
-
const rawRecordData = recordData.filter(fieldData => fieldData.fieldCode && fieldNames.includes(fieldData.fieldCode));
|
|
1373
|
-
rawRecordData.forEach(fieldData => {
|
|
1374
|
-
const { fieldCode, fieldValue } = fieldData;
|
|
1375
|
-
const fieldDef = recordDefinition.find(column => column.fieldCode === fieldCode);
|
|
1376
|
-
this.recordData[fieldCode] = fieldValue !== null && fieldValue !== void 0 ? fieldValue : '';
|
|
1377
|
-
if (fieldCode === selectionFieldName) {
|
|
1378
|
-
this.selected = fieldValue;
|
|
1379
|
-
}
|
|
1380
|
-
});
|
|
1381
|
-
}
|
|
1382
|
-
else {
|
|
1383
|
-
const fields = Object.keys(recordData);
|
|
1384
|
-
fields.forEach(fieldCode => {
|
|
1385
|
-
const fieldValue = recordData[fieldCode];
|
|
1386
|
-
const fieldDef = recordDefinition.find(column => column.fieldCode === fieldCode);
|
|
1387
|
-
this.recordData[fieldCode] = fieldValue !== null && fieldValue !== void 0 ? fieldValue : '';
|
|
1388
|
-
});
|
|
1389
|
-
}
|
|
1390
|
-
}
|
|
1391
|
-
toggleSelect() { this.selected = !this.selected; }
|
|
1392
|
-
select() { this.selected = true; }
|
|
1393
|
-
unselect() { this.selected = false; }
|
|
1394
|
-
get recordIdKey() {
|
|
1395
|
-
return (typeof this.recordId === 'object')
|
|
1396
|
-
? JSON.stringify(this.recordId) : this.recordId;
|
|
1397
|
-
}
|
|
1398
|
-
getFieldValue(fieldCode) {
|
|
1399
|
-
return (fieldCode && this.recordData) ? this.recordData[fieldCode] : null;
|
|
1400
|
-
}
|
|
1401
|
-
hasPattern(words, columnObj) {
|
|
1402
|
-
if (!words || words.length === 0) {
|
|
1403
|
-
return true;
|
|
1404
|
-
}
|
|
1405
|
-
for (const word of words) {
|
|
1406
|
-
let wordIsPresent = false;
|
|
1407
|
-
for (const fieldCode in this.recordData) {
|
|
1408
|
-
const columnDef = columnObj === null || columnObj === void 0 ? void 0 : columnObj[fieldCode];
|
|
1409
|
-
if ((columnDef === null || columnDef === void 0 ? void 0 : columnDef.searchable) && this.recordData.hasOwnProperty(fieldCode)) {
|
|
1410
|
-
const term = word.toUpperCase();
|
|
1411
|
-
let fieldValue;
|
|
1412
|
-
if (columnDef.fieldType.toUpperCase().includes('DATE')) {
|
|
1413
|
-
fieldValue = this.recordData[fieldCode].substring(0, 16);
|
|
1414
|
-
}
|
|
1415
|
-
else {
|
|
1416
|
-
fieldValue = this.recordData[fieldCode];
|
|
1417
|
-
}
|
|
1418
|
-
if (fieldValue.toString().toUpperCase().includes(term)) {
|
|
1419
|
-
wordIsPresent = true;
|
|
1420
|
-
break;
|
|
1421
|
-
}
|
|
1422
|
-
}
|
|
1423
|
-
}
|
|
1424
|
-
if (!wordIsPresent) {
|
|
1425
|
-
return false;
|
|
1426
|
-
}
|
|
1427
|
-
}
|
|
1428
|
-
return true;
|
|
1429
|
-
}
|
|
1430
|
-
hasCondition(columnFilters) {
|
|
1431
|
-
if (!columnFilters || columnFilters.length === 0) {
|
|
1432
|
-
return true;
|
|
1433
|
-
}
|
|
1434
|
-
for (const condition of columnFilters) {
|
|
1435
|
-
const { fieldCode, operator, values } = condition;
|
|
1436
|
-
if (this.recordData.hasOwnProperty(fieldCode)) {
|
|
1437
|
-
const fieldValue = this.recordData[fieldCode];
|
|
1438
|
-
const stringValue = fieldValue.toString().toUpperCase();
|
|
1439
|
-
if (operator === operators.G && fieldValue <= values[0]) {
|
|
1440
|
-
return false;
|
|
1441
|
-
}
|
|
1442
|
-
if (operator === operators.L && fieldValue >= values[0]) {
|
|
1443
|
-
return false;
|
|
1444
|
-
}
|
|
1445
|
-
if (operator === operators.GE && fieldValue < values[0]) {
|
|
1446
|
-
return false;
|
|
1447
|
-
}
|
|
1448
|
-
if (operator === operators.LE && fieldValue > values[0]) {
|
|
1449
|
-
return false;
|
|
1450
|
-
}
|
|
1451
|
-
if (operator === operators.IN && !values.includes(fieldValue)) {
|
|
1452
|
-
return false;
|
|
1453
|
-
}
|
|
1454
|
-
if (operator === operators.EQ) {
|
|
1455
|
-
return fieldValue === values[0];
|
|
1456
|
-
}
|
|
1457
|
-
if (operator === operators.NEQ && fieldValue === values[0]) {
|
|
1458
|
-
return false;
|
|
1459
|
-
}
|
|
1460
|
-
if (operator === operators.HAS && !stringValue.includes(values[0].toString().toUpperCase())) {
|
|
1461
|
-
return false;
|
|
1462
|
-
}
|
|
1463
|
-
if (operator === operators.NOTHAS && stringValue.includes(values[0].toString().toUpperCase())) {
|
|
1464
|
-
return false;
|
|
1465
|
-
}
|
|
1466
|
-
if (operator === operators.BETWEEN && (fieldValue < values[0] || fieldValue > values[1])) {
|
|
1467
|
-
return false;
|
|
1468
|
-
}
|
|
1469
|
-
}
|
|
1470
|
-
}
|
|
1471
|
-
return true;
|
|
1472
|
-
}
|
|
1473
|
-
}
|
|
1474
|
-
|
|
1475
|
-
const TABLE_SORT_ASCENDING = 'asc';
|
|
1476
|
-
const TABLE_SORT_DESCENDING = 'desc';
|
|
1477
|
-
const attrs = {
|
|
1478
|
-
allSelected: { name: 'allSelected', propagate: 'allSelected' },
|
|
1479
|
-
tableCode: { name: 'tableCode', propagate: 'code' },
|
|
1480
|
-
clientPaging: { name: 'clientPaging', propagate: null },
|
|
1481
|
-
globalSearch: { name: 'globalSearch', propagate: 'globalSearch' },
|
|
1482
|
-
globalFilterString: { name: 'globalFilterString', propagate: 'globalFilterString' },
|
|
1483
|
-
sorting: { name: 'sorting', propagate: null },
|
|
1484
|
-
recordsPerPage: { name: 'recordsPerPage', propagate: 'recordsPerPage' },
|
|
1485
|
-
layout: { name: 'layout', propagate: 'layout' },
|
|
1486
|
-
columns: { name: 'columns', propagate: 'columns' },
|
|
1487
|
-
selectedRecords: { name: 'selectedRecords', propagate: 'selectedRecords' },
|
|
1488
|
-
currentPage: { name: 'currentPage', propagate: 'currentPage' },
|
|
1489
|
-
totalRecordsNumber: { name: 'totalRecordsNumber', propagate: 'totalRecordsNumber' },
|
|
1490
|
-
visibleRecords: { name: 'visibleRecords', propagate: 'visibleRecords' },
|
|
1491
|
-
};
|
|
1492
|
-
class RecordTable extends FormElement {
|
|
1493
|
-
constructor(tableReceived, formConfig) {
|
|
1494
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
1495
|
-
super(tableReceived, formConfig);
|
|
1496
|
-
this._inlineActionTrigger = new Subject();
|
|
1497
|
-
this._globalActionTrigger = new Subject();
|
|
1498
|
-
this._recordSelectionTrigger = new Subject();
|
|
1499
|
-
this._selectionActionTrigger = new Subject();
|
|
1500
|
-
this._getDataTrigger = new Subject();
|
|
1501
|
-
this._tableColumnObj = {};
|
|
1502
|
-
this._actionsObj = {};
|
|
1503
|
-
// Mecanismos de filtrado nueva versión
|
|
1504
|
-
this.globalFilterString = '';
|
|
1505
|
-
this.globalFilterStrings = [];
|
|
1506
|
-
this.layout = null;
|
|
1507
|
-
this.tableRecordObj = {};
|
|
1508
|
-
this.visibleRecords = null;
|
|
1509
|
-
this.allSelected = false;
|
|
1510
|
-
this.tableCode = '';
|
|
1511
|
-
this.recordsPerPage = 10;
|
|
1512
|
-
this.totalRecordsNumber = 0;
|
|
1513
|
-
this.recordsNumber = 0;
|
|
1514
|
-
this.clientPaging = true;
|
|
1515
|
-
this.propagationCustomAttributes = (_c = (_b = (_a = this._formConfig) === null || _a === void 0 ? void 0 : _a.propagationCustomAttributes) === null || _b === void 0 ? void 0 : _b.tables) !== null && _c !== void 0 ? _c : [];
|
|
1516
|
-
this.elementType = elementTypes.table;
|
|
1517
|
-
this.waiting = false;
|
|
1518
|
-
this.currentPage = 1;
|
|
1519
|
-
this.totalPages = 1;
|
|
1520
|
-
this.requestedPage = 1;
|
|
1521
|
-
this.columns = [];
|
|
1522
|
-
this._tableColumnObj = {};
|
|
1523
|
-
this._actions = [];
|
|
1524
|
-
this._actionsObj = {};
|
|
1525
|
-
this.tableRecords = [];
|
|
1526
|
-
this.globalSearch = false;
|
|
1527
|
-
this.restrictedId = null;
|
|
1528
|
-
this.tableTitle = tableReceived.tableTitle;
|
|
1529
|
-
this._appendPages = (_d = tableReceived === null || tableReceived === void 0 ? void 0 : tableReceived.append) !== null && _d !== void 0 ? _d : false;
|
|
1530
|
-
this.selectable = (_e = tableReceived === null || tableReceived === void 0 ? void 0 : tableReceived.selectable) !== null && _e !== void 0 ? _e : false;
|
|
1531
|
-
this.selectionBackend = (_f = tableReceived === null || tableReceived === void 0 ? void 0 : tableReceived.selectionBackend) !== null && _f !== void 0 ? _f : false;
|
|
1532
|
-
this.sortable = (_g = tableReceived === null || tableReceived === void 0 ? void 0 : tableReceived.sortable) !== null && _g !== void 0 ? _g : false;
|
|
1533
|
-
this.setAttr(attrs.allSelected, false);
|
|
1534
|
-
this.setAttr(attrs.tableCode, tableReceived.tableCode);
|
|
1535
|
-
this.setAttr(attrs.clientPaging, (_h = tableReceived === null || tableReceived === void 0 ? void 0 : tableReceived.clientPaging) !== null && _h !== void 0 ? _h : true);
|
|
1536
|
-
this.setAttr(attrs.globalSearch, (_j = tableReceived === null || tableReceived === void 0 ? void 0 : tableReceived.simpleFilter) !== null && _j !== void 0 ? _j : false);
|
|
1537
|
-
this.setAttr(attrs.globalFilterString, '');
|
|
1538
|
-
this.setAttr(attrs.sorting, { columnName: '', direction: '' });
|
|
1539
|
-
this.setAttr(attrs.recordsPerPage, formConfig.defaultRecordsPerPage);
|
|
1540
|
-
this.setAttr(attrs.layout, '');
|
|
1541
|
-
if (tableReceived.fields) {
|
|
1542
|
-
const columns = [];
|
|
1543
|
-
for (const columnReceived of tableReceived.fields) {
|
|
1544
|
-
const columnEnriched = Object.assign(Object.assign({}, columnReceived), { visibleStates: this.visibleStates, enabledStates: this.enabledStates });
|
|
1545
|
-
const columnDefinition = new RecordTableColumn(columnEnriched, this._formConfig);
|
|
1546
|
-
columns.push(columnDefinition);
|
|
1547
|
-
this._tableColumnObj[columnDefinition.fieldCode] = columnDefinition;
|
|
1548
|
-
}
|
|
1549
|
-
this.setAttr(attrs.columns, columns);
|
|
1550
|
-
}
|
|
1551
|
-
if (tableReceived.actions) {
|
|
1552
|
-
const tableActions = tableReceived.actions.map(objDef => {
|
|
1553
|
-
let visibleStates = objDef.visibleStates;
|
|
1554
|
-
let enabledStates = objDef.enabledStates;
|
|
1555
|
-
if (!visibleStates) {
|
|
1556
|
-
visibleStates = (objDef.actionModes || '').split(',')
|
|
1557
|
-
.map(state => state.trim())
|
|
1558
|
-
.filter(state => state.length > 0);
|
|
1559
|
-
enabledStates = (objDef.actionModes || '').split(',')
|
|
1560
|
-
.map(state => state.trim())
|
|
1561
|
-
.filter(state => state.length > 0);
|
|
1562
|
-
}
|
|
1563
|
-
return Object.assign(Object.assign({}, objDef), { visibleStates, enabledStates });
|
|
1564
|
-
});
|
|
1565
|
-
for (const actionReceived of tableActions) {
|
|
1566
|
-
const inlineAction = new TableAction(actionReceived, this._formConfig);
|
|
1567
|
-
this._actions.push(inlineAction);
|
|
1568
|
-
this._actionsObj[inlineAction.actionCode] = inlineAction;
|
|
1569
|
-
}
|
|
1570
|
-
}
|
|
1571
|
-
this.selectionField = (this.selectable) ? tableReceived === null || tableReceived === void 0 ? void 0 : tableReceived.selectionField : null;
|
|
1572
|
-
// Filtros predefinidos en el formulario
|
|
1573
|
-
if (tableReceived.filters) {
|
|
1574
|
-
for (let index = 0; index < tableReceived.filters.length; index++) {
|
|
1575
|
-
this.addFilterDefinition(tableReceived.filters[index].fieldCode, tableReceived.filters[index]);
|
|
1576
|
-
}
|
|
1577
|
-
}
|
|
1578
|
-
}
|
|
1579
|
-
get columnNames() { return Object.keys(this._tableColumnObj); }
|
|
1580
|
-
get inlineActionTrigger() { return this._inlineActionTrigger; }
|
|
1581
|
-
get globalActionTrigger() { return this._globalActionTrigger; }
|
|
1582
|
-
get selectionActionTrigger() { return this._selectionActionTrigger; }
|
|
1583
|
-
get recordSelectionTrigger() { return this._recordSelectionTrigger; }
|
|
1584
|
-
get getDataTrigger() { return this._getDataTrigger; }
|
|
1585
|
-
getLayout() { return this.layout; }
|
|
1586
|
-
setLayout(layout) { this.setAttr(attrs.layout, layout); }
|
|
1587
|
-
hasActions() { return (this._actions.length > 0); }
|
|
1588
|
-
getSelectedRecords() { return this.tableRecords.filter(rec => rec.selected).map(rec => rec.recordId); }
|
|
1589
|
-
activateGlobalSearch() { this.globalSearch = true; }
|
|
1590
|
-
inactivateGlobalSearch() { this.globalSearch = false; }
|
|
1591
|
-
columnDefinition(fieldCode) { return this._tableColumnObj[fieldCode]; }
|
|
1592
|
-
putOnWait() { this.waiting = true; }
|
|
1593
|
-
freeWaiting() { this.waiting = false; }
|
|
1594
|
-
setWidget(widget) { this.widget = widget; }
|
|
1595
|
-
notifyGlobalAction(actionCode) {
|
|
1596
|
-
const tableEvent = {
|
|
1597
|
-
tableCode: this.tableCode,
|
|
1598
|
-
actionCode,
|
|
1599
|
-
actionDetail: null
|
|
1600
|
-
};
|
|
1601
|
-
this._globalActionTrigger.next(tableEvent);
|
|
1602
|
-
}
|
|
1603
|
-
notifyInlineAction(tableActionEvent) {
|
|
1604
|
-
const tableEvent = {
|
|
1605
|
-
tableCode: this.tableCode,
|
|
1606
|
-
actionCode: tableActionEvent.actionCode,
|
|
1607
|
-
actionDetail: {
|
|
1608
|
-
recordId: tableActionEvent.recordId,
|
|
1609
|
-
recordData: tableActionEvent.recordData
|
|
1610
|
-
}
|
|
1611
|
-
};
|
|
1612
|
-
this._inlineActionTrigger.next(tableEvent);
|
|
1613
|
-
}
|
|
1614
|
-
notifyRecordSelection(recordId) {
|
|
1615
|
-
var _a;
|
|
1616
|
-
const record = this.getTableRecord(recordId);
|
|
1617
|
-
if (!record) {
|
|
1618
|
-
return;
|
|
1619
|
-
}
|
|
1620
|
-
record.toggleSelect();
|
|
1621
|
-
this.requestedPage = (_a = this.currentPage) !== null && _a !== void 0 ? _a : 1;
|
|
1622
|
-
const tableEvent = {
|
|
1623
|
-
tableCode: this.tableCode,
|
|
1624
|
-
actionCode: null,
|
|
1625
|
-
actionDetail: {
|
|
1626
|
-
recordId: record.recordId,
|
|
1627
|
-
recordData: record.recordData
|
|
1628
|
-
}
|
|
1629
|
-
};
|
|
1630
|
-
this.recordSelectionTrigger.next(tableEvent);
|
|
1631
|
-
}
|
|
1632
|
-
notifySelectionAction(actionCode) {
|
|
1633
|
-
const tableEvent = {
|
|
1634
|
-
tableCode: this.tableCode,
|
|
1635
|
-
actionCode,
|
|
1636
|
-
actionDetail: {
|
|
1637
|
-
selectedRecords: this.selectedRecords
|
|
1638
|
-
}
|
|
1639
|
-
};
|
|
1640
|
-
this._selectionActionTrigger.next(tableEvent);
|
|
1641
|
-
}
|
|
1642
|
-
notifyGetDataAction(requestedPage = null) {
|
|
1643
|
-
this.updateVisibleRecords();
|
|
1644
|
-
this.requestedPage = requestedPage || this.currentPage || 1;
|
|
1645
|
-
const tableEvent = {
|
|
1646
|
-
tableCode: this.tableCode,
|
|
1647
|
-
actionCode: null,
|
|
1648
|
-
actionDetail: null,
|
|
1649
|
-
};
|
|
1650
|
-
this._getDataTrigger.next(tableEvent);
|
|
1651
|
-
return null;
|
|
1652
|
-
}
|
|
1653
|
-
clean() {
|
|
1654
|
-
this.tableRecords = [];
|
|
1655
|
-
this.unSelectAll();
|
|
1656
|
-
this.tableRecordObj = {};
|
|
1657
|
-
this.updateVisibleRecords();
|
|
1658
|
-
}
|
|
1659
|
-
selectAll() {
|
|
1660
|
-
this.setAttr(attrs.allSelected, true);
|
|
1661
|
-
this.tableRecords.forEach(record => record.select());
|
|
1662
|
-
this.setAttr(attrs.selectedRecords, this.getSelectedRecords());
|
|
1663
|
-
return true;
|
|
1664
|
-
}
|
|
1665
|
-
unSelectAll() {
|
|
1666
|
-
this.setAttr(attrs.allSelected, false);
|
|
1667
|
-
this.tableRecords.forEach(record => record.unselect());
|
|
1668
|
-
this.setAttr(attrs.selectedRecords, this.getSelectedRecords());
|
|
1669
|
-
return true;
|
|
1670
|
-
}
|
|
1671
|
-
setTableRecords(tableRecords, append) {
|
|
1672
|
-
if (!append) {
|
|
1673
|
-
this.tableRecords = [];
|
|
1674
|
-
this.setAttr(attrs.allSelected, false);
|
|
1675
|
-
this.tableRecords.forEach(record => record.unselect());
|
|
1676
|
-
this.setAttr(attrs.selectedRecords, []);
|
|
1677
|
-
this.tableRecordObj = {};
|
|
1678
|
-
}
|
|
1679
|
-
const newRecordsObj = Object.assign({}, this.tableRecordObj);
|
|
1680
|
-
const newRecords = [...this.tableRecords];
|
|
1681
|
-
for (const tableRecord of tableRecords) {
|
|
1682
|
-
const recordReceived = new TableRecordData(tableRecord, this.columns, this.selectionField);
|
|
1683
|
-
const recordIdKey = recordReceived.recordIdKey;
|
|
1684
|
-
newRecords.push(recordReceived);
|
|
1685
|
-
newRecordsObj[recordIdKey] = recordReceived;
|
|
1686
|
-
}
|
|
1687
|
-
this.tableRecords = newRecords;
|
|
1688
|
-
this.setAttr(attrs.selectedRecords, this.getSelectedRecords());
|
|
1689
|
-
this.tableRecordObj = newRecordsObj;
|
|
1690
|
-
this.updateVisibleRecords();
|
|
1691
|
-
}
|
|
1692
|
-
appendRecords(records) { this.setTableRecords(records, true); }
|
|
1693
|
-
replaceRecords(records) { this.setTableRecords(records, false); }
|
|
1694
|
-
setTableAppend(append) { this._appendPages = append; }
|
|
1695
|
-
changePage(requestedPage) {
|
|
1696
|
-
if (this.clientPaging) {
|
|
1697
|
-
this.setAttr(attrs.currentPage, requestedPage);
|
|
1698
|
-
this.updateVisibleRecords();
|
|
1699
|
-
}
|
|
1700
|
-
else {
|
|
1701
|
-
this.notifyGetDataAction(requestedPage);
|
|
1702
|
-
}
|
|
1703
|
-
}
|
|
1704
|
-
updateVisibleRecords() {
|
|
1705
|
-
let visibleRecords;
|
|
1706
|
-
if (this.clientPaging) {
|
|
1707
|
-
let filteredRecords = this.getFilteredRecords();
|
|
1708
|
-
this.setAttr(attrs.totalRecordsNumber, filteredRecords.length);
|
|
1709
|
-
const sliceNumber1 = (this.currentPage - 1) * this.recordsPerPage;
|
|
1710
|
-
const sliceNumber2 = (this.currentPage - 1) * this.recordsPerPage + this.recordsPerPage;
|
|
1711
|
-
visibleRecords = filteredRecords.slice(sliceNumber1, sliceNumber2);
|
|
1712
|
-
const recordsLastPage = this.totalRecordsNumber % this.recordsPerPage;
|
|
1713
|
-
const totalPages = Math.trunc(this.totalRecordsNumber / this.recordsPerPage + (recordsLastPage ? 1 : 0));
|
|
1714
|
-
if (this.currentPage > totalPages) {
|
|
1715
|
-
this.currentPage = totalPages || 1;
|
|
1716
|
-
}
|
|
1717
|
-
}
|
|
1718
|
-
else {
|
|
1719
|
-
visibleRecords = this.tableRecords;
|
|
1720
|
-
}
|
|
1721
|
-
this.setAttr(attrs.visibleRecords, visibleRecords);
|
|
1722
|
-
}
|
|
1723
|
-
updateFromServer(tableReceived) {
|
|
1724
|
-
this.requestedPage = 1;
|
|
1725
|
-
const { visible = true, totalPages = 1, recordsNumber, currentPage = 1, recordsPerPage, totalRecordsNumber, sortingColumn, sortingDirection, tableRecords, actions, fields, } = tableReceived;
|
|
1726
|
-
this.visible = visible;
|
|
1727
|
-
if (actions) {
|
|
1728
|
-
Object.keys(actions).forEach(actionCode => {
|
|
1729
|
-
var _a, _b, _c, _d;
|
|
1730
|
-
const tblAction = this.getAction(actionCode);
|
|
1731
|
-
const actionReceived = actions[actionCode];
|
|
1732
|
-
if (actionReceived.visible === true || actionReceived.visible === false) {
|
|
1733
|
-
(actionReceived.visible === true) && tblAction.show();
|
|
1734
|
-
(actionReceived.visible === false) && tblAction.hide();
|
|
1735
|
-
}
|
|
1736
|
-
if (actionReceived.enabled === true || actionReceived.enabled === false) {
|
|
1737
|
-
(actionReceived.enabled === true) && tblAction.enable();
|
|
1738
|
-
(actionReceived.enabled === false) && tblAction.disable();
|
|
1739
|
-
}
|
|
1740
|
-
if (actionReceived.showOnStates) {
|
|
1741
|
-
(_a = actionReceived.showOnStates) === null || _a === void 0 ? void 0 : _a.forEach(newState => {
|
|
1742
|
-
tblAction.addVisibleState(newState);
|
|
1743
|
-
});
|
|
1744
|
-
}
|
|
1745
|
-
if (actionReceived.hideOnStates) {
|
|
1746
|
-
(_b = actionReceived.hideOnStates) === null || _b === void 0 ? void 0 : _b.forEach(newState => {
|
|
1747
|
-
tblAction.removeVisibleState(newState);
|
|
1748
|
-
});
|
|
1749
|
-
}
|
|
1750
|
-
if (actionReceived.enableOnStates) {
|
|
1751
|
-
(_c = actionReceived.enableOnStates) === null || _c === void 0 ? void 0 : _c.forEach(newState => {
|
|
1752
|
-
tblAction.addEnabledState(newState);
|
|
1753
|
-
});
|
|
1754
|
-
}
|
|
1755
|
-
if (actionReceived.disableOnStates) {
|
|
1756
|
-
(_d = actionReceived.disableOnStates) === null || _d === void 0 ? void 0 : _d.forEach(newState => {
|
|
1757
|
-
tblAction.removeEnabledState(newState);
|
|
1758
|
-
});
|
|
1759
|
-
}
|
|
1760
|
-
});
|
|
1761
|
-
}
|
|
1762
|
-
if (fields) {
|
|
1763
|
-
Object.keys(fields).forEach(fieldCode => {
|
|
1764
|
-
const tblField = this.columnDefinition(fieldCode);
|
|
1765
|
-
const fieldReceived = fields[fieldCode];
|
|
1766
|
-
if (fieldReceived.visible === true || fieldReceived.visible === false) {
|
|
1767
|
-
(fieldReceived.visible === true) && tblField.show();
|
|
1768
|
-
(fieldReceived.visible === false) && tblField.hide();
|
|
1769
|
-
}
|
|
1770
|
-
});
|
|
1771
|
-
}
|
|
1772
|
-
if (tableRecords) {
|
|
1773
|
-
this.totalPages = totalPages;
|
|
1774
|
-
this.recordsNumber = recordsNumber;
|
|
1775
|
-
this.setAttr(attrs.currentPage, +currentPage);
|
|
1776
|
-
this.setAttr(attrs.recordsPerPage, +recordsPerPage);
|
|
1777
|
-
this.setAttr(attrs.totalRecordsNumber, (this.clientPaging) ? tableRecords.length : +totalRecordsNumber);
|
|
1778
|
-
this.setAttr(attrs.sorting, {
|
|
1779
|
-
columnName: sortingColumn || '',
|
|
1780
|
-
direction: sortingDirection || ''
|
|
1781
|
-
});
|
|
1782
|
-
if (!this._appendPages) {
|
|
1783
|
-
this.replaceRecords(tableRecords);
|
|
1784
|
-
}
|
|
1785
|
-
else {
|
|
1786
|
-
this.appendRecords(tableRecords);
|
|
1787
|
-
}
|
|
1788
|
-
}
|
|
1789
|
-
this.waiting = false;
|
|
1790
|
-
this.updateVisibleRecords();
|
|
1791
|
-
}
|
|
1792
|
-
getTableRecord(recordId) {
|
|
1793
|
-
const recordIdKey = (typeof recordId === 'object') ? JSON.stringify(recordId) : recordId;
|
|
1794
|
-
return (this.tableRecordObj && recordId && this.tableRecordObj[recordId])
|
|
1795
|
-
? this.tableRecordObj[recordId] : null;
|
|
1796
|
-
}
|
|
1797
|
-
getAction(actionCode) {
|
|
1798
|
-
return (this._actionsObj && actionCode && this._actionsObj[actionCode])
|
|
1799
|
-
? this._actionsObj[actionCode] : null;
|
|
1800
|
-
}
|
|
1801
|
-
getActions(actionClass = this._formConfig.tableActions.inline, actionTypes = null) {
|
|
1802
|
-
return this._actions.filter(actionDef => {
|
|
1803
|
-
const typeIncluded = (actionTypes) ? actionTypes.includes(actionDef.actionType) : true;
|
|
1804
|
-
return actionDef.actionClass === actionClass && typeIncluded;
|
|
1805
|
-
});
|
|
1806
|
-
}
|
|
1807
|
-
// Filtros
|
|
1808
|
-
setFilterById(id) {
|
|
1809
|
-
if (this.restrictedId === id) {
|
|
1810
|
-
return;
|
|
1811
|
-
}
|
|
1812
|
-
this.restrictedId = id;
|
|
1813
|
-
this.updateVisibleRecords();
|
|
1814
|
-
}
|
|
1815
|
-
cleanIdFilter() {
|
|
1816
|
-
if (this.restrictedId === null) {
|
|
1817
|
-
return;
|
|
1818
|
-
}
|
|
1819
|
-
this.restrictedId = null;
|
|
1820
|
-
this.updateVisibleRecords();
|
|
1821
|
-
}
|
|
1822
|
-
setGlobalFilterString(text, notifyComponent = true) {
|
|
1823
|
-
var _a;
|
|
1824
|
-
this.globalFilterStrings = (_a = text.split(' ').filter(t => t && t.trim().length > 0).map(t => t.trim())) !== null && _a !== void 0 ? _a : [];
|
|
1825
|
-
if (this.clientPaging) {
|
|
1826
|
-
this.changePage(1);
|
|
1827
|
-
}
|
|
1828
|
-
if (notifyComponent) {
|
|
1829
|
-
this.setAttr(attrs.globalFilterString, text.trim());
|
|
1830
|
-
}
|
|
1831
|
-
}
|
|
1832
|
-
addFilterDefinition(columnName, filterDefinition) {
|
|
1833
|
-
const tableColumn = this.columnDefinition(columnName);
|
|
1834
|
-
tableColumn && tableColumn.addFilterDefinition(filterDefinition);
|
|
1835
|
-
}
|
|
1836
|
-
getFilteredRecords() {
|
|
1837
|
-
let filteredRecords = this.tableRecords;
|
|
1838
|
-
if (this.restrictedId) {
|
|
1839
|
-
filteredRecords = filteredRecords.filter(record => record.recordId === this.restrictedId);
|
|
1840
|
-
}
|
|
1841
|
-
if (this.globalFilterStrings.length > 0) {
|
|
1842
|
-
filteredRecords = filteredRecords.filter(record => record.hasPattern(this.globalFilterStrings, this._tableColumnObj));
|
|
1843
|
-
}
|
|
1844
|
-
const columnFilters = this.columns.filter(column => column.filter).map(column => column.filter);
|
|
1845
|
-
if (columnFilters.length > 0) {
|
|
1846
|
-
filteredRecords = filteredRecords.filter(record => record.hasCondition(columnFilters));
|
|
1847
|
-
}
|
|
1848
|
-
return filteredRecords;
|
|
1849
|
-
}
|
|
1850
|
-
getColumnFilter(columnName) {
|
|
1851
|
-
var _a;
|
|
1852
|
-
const tableColumn = this.columnDefinition(columnName);
|
|
1853
|
-
return (_a = tableColumn === null || tableColumn === void 0 ? void 0 : tableColumn.filter) !== null && _a !== void 0 ? _a : null;
|
|
1854
|
-
}
|
|
1855
|
-
addColumnFilter(columnName, columnValues, operator = null) {
|
|
1856
|
-
var _a;
|
|
1857
|
-
const tableColumn = this.columnDefinition(columnName);
|
|
1858
|
-
const columnFilterDefinition = (_a = tableColumn === null || tableColumn === void 0 ? void 0 : tableColumn.filterDefinition) !== null && _a !== void 0 ? _a : null;
|
|
1859
|
-
if (!columnFilterDefinition) {
|
|
1860
|
-
return;
|
|
1861
|
-
}
|
|
1862
|
-
tableColumn && tableColumn.addFilter(columnValues, operator);
|
|
1863
|
-
this.updateVisibleRecords();
|
|
1864
|
-
}
|
|
1865
|
-
removeColumnFilter(columnName) {
|
|
1866
|
-
const tableColumn = this.columnDefinition(columnName);
|
|
1867
|
-
tableColumn && tableColumn.removeFilter();
|
|
1868
|
-
this.updateVisibleRecords();
|
|
1869
|
-
}
|
|
1870
|
-
get currentFilter() {
|
|
1871
|
-
const compactFilter = {
|
|
1872
|
-
simpleFilterWords: this.globalFilterStrings,
|
|
1873
|
-
advancedFilter: [],
|
|
1874
|
-
};
|
|
1875
|
-
const columnFilters = this.columns.filter(column => column.filter).map(column => column.filter);
|
|
1876
|
-
for (let index = 0; index < columnFilters.length; index++) {
|
|
1877
|
-
const columnFilter = columnFilters[index];
|
|
1878
|
-
compactFilter.advancedFilter.push({
|
|
1879
|
-
fieldCode: columnFilter === null || columnFilter === void 0 ? void 0 : columnFilter.fieldCode,
|
|
1880
|
-
operator: columnFilter === null || columnFilter === void 0 ? void 0 : columnFilter.operator,
|
|
1881
|
-
fieldValue1: columnFilter === null || columnFilter === void 0 ? void 0 : columnFilter.values[0],
|
|
1882
|
-
fieldValue2: columnFilter === null || columnFilter === void 0 ? void 0 : columnFilter.values[1],
|
|
1883
|
-
});
|
|
1884
|
-
}
|
|
1885
|
-
return compactFilter;
|
|
1886
|
-
}
|
|
1887
|
-
// Ordenamiento de registros local
|
|
1888
|
-
sort(columnName, direction) {
|
|
1889
|
-
this.setRequiredOrder(columnName, direction);
|
|
1890
|
-
if (this.clientPaging) {
|
|
1891
|
-
this.localSortData();
|
|
1892
|
-
}
|
|
1893
|
-
else {
|
|
1894
|
-
this.notifyGetDataAction();
|
|
1895
|
-
}
|
|
1896
|
-
}
|
|
1897
|
-
setRequiredOrder(columnField, direction = null) {
|
|
1898
|
-
this.setAttr(attrs.sorting, {
|
|
1899
|
-
columnName: columnField,
|
|
1900
|
-
direction: (direction === 'ascend') ? TABLE_SORT_ASCENDING : TABLE_SORT_DESCENDING,
|
|
1901
|
-
});
|
|
1902
|
-
}
|
|
1903
|
-
localSortData() {
|
|
1904
|
-
if (!this.sorting.columnName || !this.sorting.direction) {
|
|
1905
|
-
return;
|
|
1906
|
-
}
|
|
1907
|
-
this.tableRecords.sort((a, b) => this.recordCompare(a, b, this.sorting.columnName, this.sorting.direction));
|
|
1908
|
-
//this.unSelectAll();
|
|
1909
|
-
this.updateVisibleRecords();
|
|
1910
|
-
}
|
|
1911
|
-
recordCompare(recordA, recordB, columnCompare, direction) {
|
|
1912
|
-
const recordAValue = recordA.getFieldValue(columnCompare);
|
|
1913
|
-
const recordBValue = recordB.getFieldValue(columnCompare);
|
|
1914
|
-
const recordAColumn = isNaN(recordAValue) ? recordAValue.toLocaleLowerCase() : +recordAValue;
|
|
1915
|
-
const recordBColumn = isNaN(recordBValue) ? recordBValue.toLocaleLowerCase() : +recordBValue;
|
|
1916
|
-
let result = 0;
|
|
1917
|
-
if (recordAColumn < recordBColumn) {
|
|
1918
|
-
result = -1;
|
|
1919
|
-
}
|
|
1920
|
-
else if (recordAColumn > recordBColumn) {
|
|
1921
|
-
result = 1;
|
|
1922
|
-
}
|
|
1923
|
-
return direction === TABLE_SORT_ASCENDING ? result : -result;
|
|
1924
|
-
}
|
|
1925
|
-
formStateChangeCustomSubscribe(form, formChangeSubject) {
|
|
1926
|
-
var _a, _b;
|
|
1927
|
-
(_a = this.columns) === null || _a === void 0 ? void 0 : _a.forEach(column => {
|
|
1928
|
-
column === null || column === void 0 ? void 0 : column.connectWithParentForm(form, formChangeSubject);
|
|
1929
|
-
});
|
|
1930
|
-
(_b = this._actions) === null || _b === void 0 ? void 0 : _b.forEach(action => {
|
|
1931
|
-
action === null || action === void 0 ? void 0 : action.connectWithParentForm(form, formChangeSubject);
|
|
1932
|
-
});
|
|
1933
|
-
}
|
|
1934
|
-
}
|
|
1935
|
-
|
|
1936
|
-
class RecordFormSubSection extends FormPiecePropagate {
|
|
1937
|
-
constructor(subsectionReceived, formObject, formConfig) {
|
|
1938
|
-
var _a, _b, _c;
|
|
1939
|
-
super(subsectionReceived, formConfig);
|
|
1940
|
-
this._customRender = null;
|
|
1941
|
-
this.subsectionId = null;
|
|
1942
|
-
this.subsectionCode = null;
|
|
1943
|
-
this.subsectionTitle = null;
|
|
1944
|
-
this.subSectionElements = [];
|
|
1945
|
-
this.subSectionFields = [];
|
|
1946
|
-
this.subSectionTables = [];
|
|
1947
|
-
this.subSectionActions = [];
|
|
1948
|
-
this.elementsArray = {};
|
|
1949
|
-
this.active = false;
|
|
1950
|
-
this.propagationCustomAttributes = (_c = (_b = (_a = this._formConfig) === null || _a === void 0 ? void 0 : _a.propagationCustomAttributes) === null || _b === void 0 ? void 0 : _b.subsections) !== null && _c !== void 0 ? _c : [];
|
|
1951
|
-
if (!subsectionReceived) {
|
|
1952
|
-
return;
|
|
1953
|
-
}
|
|
1954
|
-
this.subsectionId = (subsectionReceived.subsectionId) ? subsectionReceived.subsectionId.toString() : '';
|
|
1955
|
-
this.subsectionCode = (subsectionReceived.subsectionCode) ? subsectionReceived.subsectionCode : '';
|
|
1956
|
-
this.subsectionTitle = (subsectionReceived.subsectionTitle) ? subsectionReceived.subsectionTitle : '';
|
|
1957
|
-
if (subsectionReceived.elements) {
|
|
1958
|
-
for (const receivedElement of subsectionReceived.elements) {
|
|
1959
|
-
let elementObject = null;
|
|
1960
|
-
let arrayToAdd = [];
|
|
1961
|
-
const { type, code } = receivedElement;
|
|
1962
|
-
switch (type) {
|
|
1963
|
-
case elementTypes.field:
|
|
1964
|
-
elementObject = formObject.getField(code);
|
|
1965
|
-
arrayToAdd = this.subSectionFields;
|
|
1966
|
-
break;
|
|
1967
|
-
case elementTypes.table:
|
|
1968
|
-
elementObject = formObject.getTable(code);
|
|
1969
|
-
arrayToAdd = this.subSectionTables;
|
|
1970
|
-
break;
|
|
1971
|
-
case elementTypes.action:
|
|
1972
|
-
elementObject = formObject.getAction(code);
|
|
1973
|
-
arrayToAdd = this.subSectionActions;
|
|
1974
|
-
break;
|
|
1975
|
-
}
|
|
1976
|
-
if (elementObject) {
|
|
1977
|
-
elementObject.elementType = type;
|
|
1978
|
-
arrayToAdd.push(elementObject);
|
|
1979
|
-
this.subSectionElements.push(elementObject);
|
|
1980
|
-
this.elementsArray[code] = elementObject;
|
|
1981
|
-
}
|
|
1982
|
-
}
|
|
1983
|
-
}
|
|
1984
|
-
}
|
|
1985
|
-
get customRender() { return this._customRender; }
|
|
1986
|
-
set customRender(customRenderName) { this._customRender = customRenderName; }
|
|
1987
|
-
getField(name) {
|
|
1988
|
-
return this.subSectionFields.find(fld => fld.name === name);
|
|
1989
|
-
}
|
|
1990
|
-
getFields() {
|
|
1991
|
-
return this.subSectionFields;
|
|
1992
|
-
}
|
|
1993
|
-
getFieldNames() {
|
|
1994
|
-
return this.subSectionFields.map(field => field.code);
|
|
1995
|
-
}
|
|
1996
|
-
getActions() {
|
|
1997
|
-
return this.subSectionActions;
|
|
1998
|
-
}
|
|
1999
|
-
getActionNames() {
|
|
2000
|
-
return this.subSectionActions.map(action => action.actionCode);
|
|
2001
|
-
}
|
|
2002
|
-
activate() {
|
|
2003
|
-
if (!this.active) {
|
|
2004
|
-
this.active = true;
|
|
2005
|
-
// this.subsectionCode && this._activation.next(this.subsectionCode);
|
|
2006
|
-
}
|
|
2007
|
-
}
|
|
2008
|
-
inactivate() {
|
|
2009
|
-
if (this.active) {
|
|
2010
|
-
this.active = false;
|
|
2011
|
-
// this.subsectionCode && this._inactivation.next(this.subsectionCode);
|
|
2012
|
-
}
|
|
2013
|
-
}
|
|
2014
|
-
}
|
|
2015
|
-
|
|
2016
|
-
const ACTIVE$1 = 'active';
|
|
2017
|
-
class RecordFormSection extends FormPiecePropagate {
|
|
2018
|
-
constructor(sectionReceived, formObject, formConfig) {
|
|
2019
|
-
var _a, _b, _c;
|
|
2020
|
-
super(sectionReceived, formConfig);
|
|
2021
|
-
this._activation = new Subject();
|
|
2022
|
-
this._inactivation = new Subject();
|
|
2023
|
-
this.active = false;
|
|
2024
|
-
this.sectionId = null;
|
|
2025
|
-
this.sectionCode = null;
|
|
2026
|
-
this.sectionTitle = null;
|
|
2027
|
-
this.subSections = [];
|
|
2028
|
-
this._exclusiveSubSectionsByAttr = {};
|
|
2029
|
-
this.propagationCustomAttributes = (_c = (_b = (_a = this._formConfig) === null || _a === void 0 ? void 0 : _a.propagationCustomAttributes) === null || _b === void 0 ? void 0 : _b.sections) !== null && _c !== void 0 ? _c : [];
|
|
2030
|
-
if (!sectionReceived) {
|
|
2031
|
-
return;
|
|
2032
|
-
}
|
|
2033
|
-
this.sectionId = (sectionReceived.sectionId) ? sectionReceived.sectionId.toString() : '';
|
|
2034
|
-
this.sectionCode = (sectionReceived.sectionCode) ? sectionReceived.sectionCode : '';
|
|
2035
|
-
this.sectionTitle = (sectionReceived.sectionTitle) ? sectionReceived.sectionTitle : '';
|
|
2036
|
-
this.subSections = [];
|
|
2037
|
-
this.subSectionsObj = {};
|
|
2038
|
-
if (sectionReceived.subsections) {
|
|
2039
|
-
const subsections = sectionReceived.subsections.map(subSecDef => {
|
|
2040
|
-
var _a;
|
|
2041
|
-
const visibleStates = (_a = subSecDef.visibleStates) !== null && _a !== void 0 ? _a : [];
|
|
2042
|
-
if (subSecDef.elements && Array.isArray(subSecDef.elements)) {
|
|
2043
|
-
subSecDef.elements = subSecDef.elements.map(elm => ({ code: elm.elementCode, type: elm.elementTypeName }));
|
|
2044
|
-
}
|
|
2045
|
-
return Object.assign(Object.assign({}, subSecDef), { visibleStates });
|
|
2046
|
-
});
|
|
2047
|
-
for (const subsectionReceived of subsections) {
|
|
2048
|
-
const subSectionToAdd = new RecordFormSubSection(subsectionReceived, formObject, formConfig);
|
|
2049
|
-
const subsectionCode = subSectionToAdd.subsectionCode;
|
|
2050
|
-
if (subsectionCode) {
|
|
2051
|
-
this.subSections.push(subSectionToAdd);
|
|
2052
|
-
this.subSectionsObj[subsectionCode] = subSectionToAdd;
|
|
2053
|
-
}
|
|
2054
|
-
}
|
|
2055
|
-
}
|
|
2056
|
-
}
|
|
2057
|
-
get code() { return this.sectionCode; }
|
|
2058
|
-
get activation() { return this._activation; }
|
|
2059
|
-
get inactivation() { return this._inactivation; }
|
|
2060
|
-
activate() {
|
|
2061
|
-
if (!this.active) {
|
|
2062
|
-
this.active = true;
|
|
2063
|
-
this.sectionCode && this._activation.next(this.sectionCode);
|
|
2064
|
-
}
|
|
2065
|
-
}
|
|
2066
|
-
inactivate() {
|
|
2067
|
-
if (this.active) {
|
|
2068
|
-
this.active = false;
|
|
2069
|
-
this.sectionCode && this._inactivation.next(this.sectionCode);
|
|
2070
|
-
}
|
|
2071
|
-
}
|
|
2072
|
-
get title() { return this.sectionTitle; }
|
|
2073
|
-
set title(title) { this.sectionTitle = title; }
|
|
2074
|
-
getVisibleSubsections(state) {
|
|
2075
|
-
return this.subSections.filter(subSection => subSection.visible);
|
|
2076
|
-
}
|
|
2077
|
-
getSubsection(subSectionCode) {
|
|
2078
|
-
return (this.subSectionsObj && this.subSectionsObj[subSectionCode])
|
|
2079
|
-
? this.subSectionsObj[subSectionCode] : null;
|
|
2080
|
-
}
|
|
2081
|
-
activateSubSection(subSectionCode) {
|
|
2082
|
-
if (subSectionCode === this._exclusiveSubSectionsByAttr[ACTIVE$1]) {
|
|
2083
|
-
return;
|
|
2084
|
-
}
|
|
2085
|
-
const subSection = (this.subSectionsObj && this.subSectionsObj[subSectionCode])
|
|
2086
|
-
? this.subSectionsObj[subSectionCode] : null;
|
|
2087
|
-
if (subSection) {
|
|
2088
|
-
subSection === null || subSection === void 0 ? void 0 : subSection.activate();
|
|
2089
|
-
this._exclusiveSubSectionsByAttr[ACTIVE$1] = subSectionCode;
|
|
2090
|
-
}
|
|
2091
|
-
}
|
|
2092
|
-
getFields() {
|
|
2093
|
-
var _a;
|
|
2094
|
-
let fieldsArray = [];
|
|
2095
|
-
if (this.subSections && this.subSections.length > 0) {
|
|
2096
|
-
for (const subSection of this.subSections) {
|
|
2097
|
-
const subsectionFields = (_a = subSection.getFields()) !== null && _a !== void 0 ? _a : [];
|
|
2098
|
-
if ((subsectionFields === null || subsectionFields === void 0 ? void 0 : subsectionFields.length) > 0) {
|
|
2099
|
-
fieldsArray = fieldsArray.concat(subsectionFields);
|
|
2100
|
-
}
|
|
2101
|
-
}
|
|
2102
|
-
}
|
|
2103
|
-
return fieldsArray;
|
|
2104
|
-
}
|
|
2105
|
-
getActions() {
|
|
2106
|
-
var _a;
|
|
2107
|
-
let actionArray = [];
|
|
2108
|
-
if (this.subSections && this.subSections.length > 0) {
|
|
2109
|
-
for (const subSection of this.subSections) {
|
|
2110
|
-
const subSectionActions = (_a = subSection.getActions()) !== null && _a !== void 0 ? _a : [];
|
|
2111
|
-
if ((subSectionActions === null || subSectionActions === void 0 ? void 0 : subSectionActions.length) > 0) {
|
|
2112
|
-
actionArray = actionArray.concat(subSectionActions);
|
|
2113
|
-
}
|
|
2114
|
-
}
|
|
2115
|
-
}
|
|
2116
|
-
return actionArray;
|
|
2117
|
-
}
|
|
2118
|
-
getActionNames() {
|
|
2119
|
-
let actionArray = [];
|
|
2120
|
-
if (this.subSections && this.subSections.length > 0) {
|
|
2121
|
-
for (const subSection of this.subSections) {
|
|
2122
|
-
actionArray = actionArray.concat(subSection.getActionNames());
|
|
2123
|
-
}
|
|
2124
|
-
}
|
|
2125
|
-
return actionArray;
|
|
2126
|
-
}
|
|
2127
|
-
getFieldNames() {
|
|
2128
|
-
let fieldsArray = [];
|
|
2129
|
-
if (this.subSections && this.subSections.length > 0) {
|
|
2130
|
-
for (const subSection of this.subSections) {
|
|
2131
|
-
fieldsArray = fieldsArray.concat(subSection.getFieldNames());
|
|
2132
|
-
}
|
|
2133
|
-
}
|
|
2134
|
-
return fieldsArray;
|
|
2135
|
-
}
|
|
2136
|
-
getField(name) {
|
|
2137
|
-
let field = null;
|
|
2138
|
-
if (this.subSections && this.subSections.length > 0) {
|
|
2139
|
-
for (const subSection of this.subSections) {
|
|
2140
|
-
field = subSection.getField(name);
|
|
2141
|
-
if (field) {
|
|
2142
|
-
return field;
|
|
2143
|
-
}
|
|
2144
|
-
}
|
|
2145
|
-
}
|
|
2146
|
-
return null;
|
|
2147
|
-
}
|
|
2148
|
-
formStateChangeCustomSubscribe(form, formChangeSubject) {
|
|
2149
|
-
var _a;
|
|
2150
|
-
(_a = this.subSections) === null || _a === void 0 ? void 0 : _a.forEach(subsection => {
|
|
2151
|
-
subsection === null || subsection === void 0 ? void 0 : subsection.connectWithParentForm(form, formChangeSubject);
|
|
2152
|
-
});
|
|
2153
|
-
}
|
|
2154
|
-
}
|
|
2155
|
-
|
|
2156
|
-
const ACTIVE = 'active';
|
|
2157
|
-
const SHOW = 'show';
|
|
2158
|
-
const HIDE = 'hide';
|
|
2159
|
-
const ENABLE = 'enable';
|
|
2160
|
-
const DISABLE = 'disable';
|
|
2161
|
-
const CLEAN = 'clean';
|
|
2162
|
-
const alwaysVisible = 'ALWAYS';
|
|
2163
|
-
const neverVisible = 'NONE';
|
|
2164
|
-
const onStatesVisible = 'ONSTATES';
|
|
2165
|
-
class FormStructureAndData {
|
|
2166
|
-
constructor() {
|
|
2167
|
-
this._stateChange = new Subject();
|
|
2168
|
-
this.name = '';
|
|
2169
|
-
this.title = '';
|
|
2170
|
-
this.subject = null;
|
|
2171
|
-
this.fields = {};
|
|
2172
|
-
this.actions = {};
|
|
2173
|
-
this.tables = {};
|
|
2174
|
-
this.sections = {};
|
|
2175
|
-
this._immutableData = {};
|
|
2176
|
-
this._extraInfo = {};
|
|
2177
|
-
this._exclusiveSectionsByAttr = {};
|
|
2178
|
-
this.customAttributes = {};
|
|
2179
|
-
this.state = '';
|
|
2180
|
-
this.actionArray = [];
|
|
2181
|
-
this.fieldArray = [];
|
|
2182
|
-
this.tableArray = [];
|
|
2183
|
-
this.sectionArray = [];
|
|
2184
|
-
this.stateFlow = {
|
|
2185
|
-
defaultState: '',
|
|
2186
|
-
states: [],
|
|
2187
|
-
stateDescriptions: [],
|
|
2188
|
-
transitions: [],
|
|
2189
|
-
};
|
|
2190
|
-
}
|
|
2191
|
-
setConfig(formConfig) {
|
|
2192
|
-
this.formConfig = formConfig;
|
|
2193
|
-
}
|
|
2194
|
-
cleanForm() {
|
|
2195
|
-
this.actionArray = [];
|
|
2196
|
-
this.fieldArray = [];
|
|
2197
|
-
this.tableArray = [];
|
|
2198
|
-
this.sectionArray = [];
|
|
2199
|
-
this.stateFlow = {
|
|
2200
|
-
defaultState: '',
|
|
2201
|
-
states: [],
|
|
2202
|
-
stateDescriptions: [],
|
|
2203
|
-
transitions: [],
|
|
2204
|
-
};
|
|
2205
|
-
}
|
|
2206
|
-
loadDefinition(definitionReceived) {
|
|
2207
|
-
var _a, _b;
|
|
2208
|
-
this.state = '';
|
|
2209
|
-
let allStates = [];
|
|
2210
|
-
this.cleanForm();
|
|
2211
|
-
if (!definitionReceived) {
|
|
2212
|
-
return;
|
|
2213
|
-
}
|
|
2214
|
-
this.name = (_a = this.name) !== null && _a !== void 0 ? _a : (_b = definitionReceived === null || definitionReceived === void 0 ? void 0 : definitionReceived.form) === null || _b === void 0 ? void 0 : _b.formCode;
|
|
2215
|
-
this.title = (definitionReceived.form && definitionReceived.form.formTitle)
|
|
2216
|
-
? definitionReceived.form.formTitle : '';
|
|
2217
|
-
allStates = definitionReceived === null || definitionReceived === void 0 ? void 0 : definitionReceived.states;
|
|
2218
|
-
this.setStateFlow(definitionReceived === null || definitionReceived === void 0 ? void 0 : definitionReceived.states, definitionReceived === null || definitionReceived === void 0 ? void 0 : definitionReceived.transitions, definitionReceived === null || definitionReceived === void 0 ? void 0 : definitionReceived.defaultState, definitionReceived === null || definitionReceived === void 0 ? void 0 : definitionReceived.stateDescriptions);
|
|
2219
|
-
this.immutableData = definitionReceived.immutableData;
|
|
2220
|
-
this.extraInfo = definitionReceived.extraInfo;
|
|
2221
|
-
this.customAttributes = {};
|
|
2222
|
-
if (definitionReceived === null || definitionReceived === void 0 ? void 0 : definitionReceived.customAttributes) {
|
|
2223
|
-
this.setCustomAttributes(definitionReceived === null || definitionReceived === void 0 ? void 0 : definitionReceived.customAttributes);
|
|
2224
|
-
}
|
|
2225
|
-
if (definitionReceived.actions) {
|
|
2226
|
-
const formActions = definitionReceived.actions.map(objDef => {
|
|
2227
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
2228
|
-
let visibleStates = (_e = (_a = objDef.visibleStates) !== null && _a !== void 0 ? _a : ((_d = (_c = (_b = objDef.actionModes) === null || _b === void 0 ? void 0 : _b.split(',')) === null || _c === void 0 ? void 0 : _c.map(state => state.trim())) === null || _d === void 0 ? void 0 : _d.filter(state => state))) !== null && _e !== void 0 ? _e : [];
|
|
2229
|
-
let enabledStates = (_g = (_f = objDef.enabledStates) !== null && _f !== void 0 ? _f : objDef.editableStates) !== null && _g !== void 0 ? _g : [];
|
|
2230
|
-
if (!Array.isArray(visibleStates) && typeof visibleStates === 'string') {
|
|
2231
|
-
visibleStates = (visibleStates === neverVisible) ? [] : allStates;
|
|
2232
|
-
}
|
|
2233
|
-
if (!Array.isArray(enabledStates) && typeof enabledStates === 'string') {
|
|
2234
|
-
enabledStates = (enabledStates === neverVisible) ? [] : visibleStates;
|
|
2235
|
-
}
|
|
2236
|
-
enabledStates = enabledStates.filter(state => visibleStates.includes(state));
|
|
2237
|
-
return Object.assign(Object.assign({}, objDef), { visibleStates, enabledStates });
|
|
2238
|
-
});
|
|
2239
|
-
for (const actionReceived of formActions) {
|
|
2240
|
-
const globalAction = new FormAction(actionReceived, this.formConfig);
|
|
2241
|
-
const globalActionCode = globalAction.actionCode;
|
|
2242
|
-
if (globalActionCode) {
|
|
2243
|
-
this.actionArray.push(globalAction);
|
|
2244
|
-
this.actions[globalActionCode] = globalAction;
|
|
2245
|
-
}
|
|
2246
|
-
}
|
|
2247
|
-
}
|
|
2248
|
-
if (definitionReceived.fields) {
|
|
2249
|
-
const formFields = definitionReceived.fields.map(objDef => {
|
|
2250
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
2251
|
-
let visibleStates = (_e = (_a = objDef.visibleStates) !== null && _a !== void 0 ? _a : ((_d = (_c = (_b = objDef.fieldModes) === null || _b === void 0 ? void 0 : _b.split(',')) === null || _c === void 0 ? void 0 : _c.map(state => state.trim())) === null || _d === void 0 ? void 0 : _d.filter(state => state))) !== null && _e !== void 0 ? _e : [];
|
|
2252
|
-
let enabledStates = (_g = (_f = objDef.enabledStates) !== null && _f !== void 0 ? _f : objDef.editableStates) !== null && _g !== void 0 ? _g : [];
|
|
2253
|
-
if (!Array.isArray(visibleStates) && typeof visibleStates === 'string') {
|
|
2254
|
-
visibleStates = (visibleStates === neverVisible) ? [] : allStates;
|
|
2255
|
-
}
|
|
2256
|
-
if (!Array.isArray(enabledStates) && typeof enabledStates === 'string') {
|
|
2257
|
-
enabledStates = (enabledStates === neverVisible) ? [] : visibleStates;
|
|
2258
|
-
}
|
|
2259
|
-
enabledStates = enabledStates.filter(state => visibleStates.includes(state));
|
|
2260
|
-
return Object.assign(Object.assign({}, objDef), { visibleStates, enabledStates });
|
|
2261
|
-
});
|
|
2262
|
-
for (const fieldReceived of formFields) {
|
|
2263
|
-
const fieldToAdd = new FieldDescriptor(fieldReceived, this.formConfig);
|
|
2264
|
-
const fieldCode = fieldToAdd.code;
|
|
2265
|
-
if (fieldCode) {
|
|
2266
|
-
this.fieldArray.push(fieldToAdd);
|
|
2267
|
-
this.fields[fieldCode] = fieldToAdd;
|
|
2268
|
-
}
|
|
2269
|
-
}
|
|
2270
|
-
}
|
|
2271
|
-
if (definitionReceived.tables) {
|
|
2272
|
-
const tables = definitionReceived.tables.map(objDef => {
|
|
2273
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
2274
|
-
let visibleStates = (_e = (_a = objDef.visibleStates) !== null && _a !== void 0 ? _a : ((_d = (_c = (_b = objDef.tableModes) === null || _b === void 0 ? void 0 : _b.split(',')) === null || _c === void 0 ? void 0 : _c.map(state => state.trim())) === null || _d === void 0 ? void 0 : _d.filter(state => state))) !== null && _e !== void 0 ? _e : [];
|
|
2275
|
-
let enabledStates = (_g = (_f = objDef.enabledStates) !== null && _f !== void 0 ? _f : objDef.editableStates) !== null && _g !== void 0 ? _g : [];
|
|
2276
|
-
if (!Array.isArray(visibleStates) && typeof visibleStates === 'string') {
|
|
2277
|
-
visibleStates = (visibleStates === neverVisible) ? [] : allStates;
|
|
2278
|
-
}
|
|
2279
|
-
if (!Array.isArray(enabledStates) && typeof enabledStates === 'string') {
|
|
2280
|
-
enabledStates = (enabledStates === neverVisible) ? [] : visibleStates;
|
|
2281
|
-
}
|
|
2282
|
-
enabledStates = enabledStates.filter(state => visibleStates.includes(state));
|
|
2283
|
-
return Object.assign(Object.assign({}, objDef), { visibleStates, enabledStates });
|
|
2284
|
-
});
|
|
2285
|
-
for (const tableReceived of tables) {
|
|
2286
|
-
const tableToAdd = new RecordTable(tableReceived, this.formConfig);
|
|
2287
|
-
const tableCode = tableToAdd.tableCode;
|
|
2288
|
-
if (tableCode) {
|
|
2289
|
-
this.tableArray.push(tableToAdd);
|
|
2290
|
-
this.tables[tableCode] = tableToAdd;
|
|
2291
|
-
}
|
|
2292
|
-
}
|
|
2293
|
-
}
|
|
2294
|
-
if (definitionReceived.sections) {
|
|
2295
|
-
const formSections = definitionReceived.sections.map(objDef => {
|
|
2296
|
-
var _a, _b, _c, _d, _e;
|
|
2297
|
-
let visibleStates = (_e = (_a = objDef.visibleStates) !== null && _a !== void 0 ? _a : ((_d = (_c = (_b = objDef.sectionModes) === null || _b === void 0 ? void 0 : _b.split(',')) === null || _c === void 0 ? void 0 : _c.map(state => state.trim())) === null || _d === void 0 ? void 0 : _d.filter(state => state))) !== null && _e !== void 0 ? _e : [];
|
|
2298
|
-
if (!Array.isArray(visibleStates) && typeof visibleStates === 'string') {
|
|
2299
|
-
visibleStates = (visibleStates === neverVisible) ? [] : allStates;
|
|
2300
|
-
}
|
|
2301
|
-
return Object.assign(Object.assign({}, objDef), { visibleStates });
|
|
2302
|
-
});
|
|
2303
|
-
for (const sectionReceived of formSections) {
|
|
2304
|
-
const sectionToAdd = new RecordFormSection(sectionReceived, this, this.formConfig);
|
|
2305
|
-
const sectionCode = sectionToAdd.sectionCode;
|
|
2306
|
-
if (sectionCode) {
|
|
2307
|
-
this.sectionArray.push(sectionToAdd);
|
|
2308
|
-
this.sections[sectionCode] = sectionToAdd;
|
|
2309
|
-
}
|
|
2310
|
-
}
|
|
2311
|
-
}
|
|
2312
|
-
}
|
|
2313
|
-
// Estados
|
|
2314
|
-
get defaultState() { return this.stateFlow.defaultState; }
|
|
2315
|
-
get states() { return this.stateFlow.states; }
|
|
2316
|
-
get stateDescriptions() { return this.stateFlow.stateDescriptions; }
|
|
2317
|
-
supportState(state = '') { var _a; return (!!state && ((_a = this.stateFlow.states) === null || _a === void 0 ? void 0 : _a.includes(state))); }
|
|
2318
|
-
getNextStates() {
|
|
2319
|
-
return this.stateFlow.transitions.filter(trns => trns.source === this.state)
|
|
2320
|
-
.map(trns => trns.destination);
|
|
2321
|
-
}
|
|
2322
|
-
changeState(newState) {
|
|
2323
|
-
const currentState = this.state;
|
|
2324
|
-
if (!newState || !this.supportState(newState) || currentState === newState) {
|
|
2325
|
-
return false;
|
|
2326
|
-
}
|
|
2327
|
-
if (!this.state) {
|
|
2328
|
-
this.state = newState;
|
|
2329
|
-
}
|
|
2330
|
-
else {
|
|
2331
|
-
const transitionToChange = this.stateFlow.transitions.find(trns => trns.source === this.state && trns.destination === newState);
|
|
2332
|
-
if (transitionToChange) {
|
|
2333
|
-
this.state = newState;
|
|
2334
|
-
}
|
|
2335
|
-
}
|
|
2336
|
-
this._stateChange.next({ state: this.state });
|
|
2337
|
-
return (this.state === newState);
|
|
2338
|
-
}
|
|
2339
|
-
get stateChange() { return this._stateChange; }
|
|
2340
|
-
setStateFlow(states, transitions, defaultState, stateDescriptions = []) {
|
|
2341
|
-
this.stateFlow.states = states;
|
|
2342
|
-
this.stateFlow.stateDescriptions = stateDescriptions;
|
|
2343
|
-
this.stateFlow.defaultState = defaultState || this.stateFlow.states[0];
|
|
2344
|
-
this.stateFlow.transitions = transitions.map(transition => {
|
|
2345
|
-
const name = transition.name;
|
|
2346
|
-
const source = (this.stateFlow.states.includes(transition.source)) ? transition.source : '';
|
|
2347
|
-
const destination = (this.stateFlow.states.includes(transition.destination)) ? transition.destination : '';
|
|
2348
|
-
return { name, source, destination };
|
|
2349
|
-
}).filter(item => item.name && item.source && item.destination);
|
|
2350
|
-
}
|
|
2351
|
-
// immutable Data
|
|
2352
|
-
getImmutableElement(name) { var _a, _b, _c; return (_c = (_b = (_a = this._immutableData) === null || _a === void 0 ? void 0 : _a[name]) === null || _b === void 0 ? void 0 : _b.value) !== null && _c !== void 0 ? _c : null; }
|
|
2353
|
-
set immutableData(immutableData) { Object.assign(this._immutableData, immutableData); }
|
|
2354
|
-
get immutableData() { return JSON.parse(JSON.stringify(this._immutableData)); }
|
|
2355
|
-
// extra Info
|
|
2356
|
-
getExtraInfo(name) { var _a, _b, _c; return (_c = (_b = (_a = this._extraInfo) === null || _a === void 0 ? void 0 : _a[name]) === null || _b === void 0 ? void 0 : _b.value) !== null && _c !== void 0 ? _c : null; }
|
|
2357
|
-
set extraInfo(extraInfo) { Object.assign(this._extraInfo, extraInfo); }
|
|
2358
|
-
get extraInfo() { return JSON.parse(JSON.stringify(this._extraInfo)); }
|
|
2359
|
-
// Custom Attributes
|
|
2360
|
-
getCustomAttribute(name) { var _a, _b; return (_b = (_a = this.customAttributes) === null || _a === void 0 ? void 0 : _a[name]) !== null && _b !== void 0 ? _b : null; }
|
|
2361
|
-
setCustomAttribute(name, value) {
|
|
2362
|
-
if (name) {
|
|
2363
|
-
this.customAttributes[name] = value;
|
|
2364
|
-
}
|
|
2365
|
-
}
|
|
2366
|
-
setCustomAttributes(attributes) {
|
|
2367
|
-
if (attributes && typeof attributes === 'object') {
|
|
2368
|
-
Object.entries(attributes).forEach(([name, value]) => {
|
|
2369
|
-
this.setCustomAttribute(name, value);
|
|
2370
|
-
});
|
|
2371
|
-
}
|
|
2372
|
-
return this;
|
|
2373
|
-
}
|
|
2374
|
-
// Fields
|
|
2375
|
-
get fieldNames() { return this.getFieldNames(); }
|
|
2376
|
-
getFields() { return this.fieldArray; }
|
|
2377
|
-
getFieldNames() { return this.fieldArray.map(field => field.code); }
|
|
2378
|
-
getField(code) { var _a; return (code && ((_a = this.fields) === null || _a === void 0 ? void 0 : _a[code])) ? this.fields[code] : null; }
|
|
2379
|
-
enableField(code) { var _a; (_a = this.getField(code)) === null || _a === void 0 ? void 0 : _a.enable(); }
|
|
2380
|
-
disableField(code) { var _a; (_a = this.getField(code)) === null || _a === void 0 ? void 0 : _a.disable(); }
|
|
2381
|
-
getFieldValue(code) { var _a; return (_a = this.getField(code)) === null || _a === void 0 ? void 0 : _a.value; }
|
|
2382
|
-
getFieldOptionText(code) { var _a; return (_a = this.getField(code)) === null || _a === void 0 ? void 0 : _a.optionText; }
|
|
2383
|
-
getFieldOptions(code) { var _a, _b; return (_b = (_a = this.getField(code)) === null || _a === void 0 ? void 0 : _a.options) !== null && _b !== void 0 ? _b : null; }
|
|
2384
|
-
setFieldValue(code, value) { var _a; (_a = this.getField(code)) === null || _a === void 0 ? void 0 : _a.setValue(value); }
|
|
2385
|
-
setFieldError(code, errorCode, message, type = 'error') { var _a; (_a = this.getField(code)) === null || _a === void 0 ? void 0 : _a.setError(errorCode, message, type); }
|
|
2386
|
-
setFieldIntrinsicErrorMessage(code, message) { var _a; (_a = this.getField(code)) === null || _a === void 0 ? void 0 : _a.setIntrinsicErrorMessage(message); }
|
|
2387
|
-
setFieldRequired(inputCodes, required) {
|
|
2388
|
-
var _a;
|
|
2389
|
-
const codes = this.getFieldSet(null, inputCodes !== null && inputCodes !== void 0 ? inputCodes : null);
|
|
2390
|
-
for (const code of codes) {
|
|
2391
|
-
try {
|
|
2392
|
-
const field = (_a = this.getField(code)) !== null && _a !== void 0 ? _a : null;
|
|
2393
|
-
field && (field.required = required);
|
|
2394
|
-
}
|
|
2395
|
-
catch (e) {
|
|
2396
|
-
console.log(`Error modificando campo ${code}: ${e}`);
|
|
2397
|
-
}
|
|
2398
|
-
}
|
|
2399
|
-
}
|
|
2400
|
-
setFieldErrorMessage(code, message) { var _a; (_a = this.getField(code)) === null || _a === void 0 ? void 0 : _a.setErrorMessage(message); }
|
|
2401
|
-
setFieldOptions(code, optionsArray, idAttribute, nameAttribute) {
|
|
2402
|
-
const field = this.getField(code);
|
|
2403
|
-
if (field && optionsArray) {
|
|
2404
|
-
const fieldOptions = optionsArray.map(item => ({
|
|
2405
|
-
fieldOptionId: item[idAttribute],
|
|
2406
|
-
fieldOptionValue: item[nameAttribute]
|
|
2407
|
-
}));
|
|
2408
|
-
field.setFieldOptions(fieldOptions);
|
|
2409
|
-
}
|
|
2410
|
-
}
|
|
2411
|
-
getFieldSet(filter, inputCodes, secCode, subCode) {
|
|
2412
|
-
var _a, _b, _c, _d, _e;
|
|
2413
|
-
let codes = [];
|
|
2414
|
-
if (inputCodes) {
|
|
2415
|
-
if (typeof inputCodes === 'string') {
|
|
2416
|
-
codes = [inputCodes];
|
|
2417
|
-
}
|
|
2418
|
-
else if (Array.isArray(inputCodes) && inputCodes.length > 0) {
|
|
2419
|
-
codes = inputCodes !== null && inputCodes !== void 0 ? inputCodes : [];
|
|
2420
|
-
}
|
|
2421
|
-
}
|
|
2422
|
-
else if (secCode && !subCode) {
|
|
2423
|
-
codes = (_b = (_a = this.getSection(secCode)) === null || _a === void 0 ? void 0 : _a.getFieldNames()) !== null && _b !== void 0 ? _b : [];
|
|
2424
|
-
}
|
|
2425
|
-
else if (secCode && subCode) {
|
|
2426
|
-
codes = (_d = (_c = this.getSubSection(secCode, subCode)) === null || _c === void 0 ? void 0 : _c.getFieldNames()) !== null && _d !== void 0 ? _d : [];
|
|
2427
|
-
}
|
|
2428
|
-
else {
|
|
2429
|
-
codes = (_e = this.getFieldNames()) !== null && _e !== void 0 ? _e : [];
|
|
2430
|
-
}
|
|
2431
|
-
return (filter) ? codes.filter(fld => filter(this.getField(fld))) : codes;
|
|
2432
|
-
}
|
|
2433
|
-
applyOnFields(processFunc, inputCodes, secCode, subCode) {
|
|
2434
|
-
if (!processFunc) {
|
|
2435
|
-
return 0;
|
|
2436
|
-
}
|
|
2437
|
-
const codes = this.getFieldSet(null, inputCodes !== null && inputCodes !== void 0 ? inputCodes : null, secCode, subCode);
|
|
2438
|
-
let processedFields = 0;
|
|
2439
|
-
for (const code of codes) {
|
|
2440
|
-
const field = this.getField(code);
|
|
2441
|
-
if (field) {
|
|
2442
|
-
try {
|
|
2443
|
-
processFunc(field);
|
|
2444
|
-
processedFields += 1;
|
|
2445
|
-
}
|
|
2446
|
-
catch (e) {
|
|
2447
|
-
console.log(`Error procesando funcion en campo ${field}: ${e}`);
|
|
2448
|
-
}
|
|
2449
|
-
}
|
|
2450
|
-
}
|
|
2451
|
-
return processedFields;
|
|
2452
|
-
}
|
|
2453
|
-
applyProcessToAllFields(processFunc) {
|
|
2454
|
-
return this.applyOnFields(processFunc);
|
|
2455
|
-
}
|
|
2456
|
-
enableFields(codes, secCode, subCode) {
|
|
2457
|
-
return this.applyOnFields(fld => fld === null || fld === void 0 ? void 0 : fld.enable(), codes, secCode, subCode);
|
|
2458
|
-
}
|
|
2459
|
-
showFields(codes, secCode, subCode) {
|
|
2460
|
-
return this.applyOnFields(fld => fld === null || fld === void 0 ? void 0 : fld.show(), codes, secCode, subCode);
|
|
2461
|
-
}
|
|
2462
|
-
hideFields(codes, secCode, subCode) {
|
|
2463
|
-
return this.applyOnFields(fld => fld === null || fld === void 0 ? void 0 : fld.hide(), codes, secCode, subCode);
|
|
2464
|
-
}
|
|
2465
|
-
showLabelFields(codes, secCode, subCode) {
|
|
2466
|
-
return this.applyOnFields(fld => fld === null || fld === void 0 ? void 0 : fld.showLablel(), codes, secCode, subCode);
|
|
2467
|
-
}
|
|
2468
|
-
hideLabelFields(codes, secCode, subCode) {
|
|
2469
|
-
return this.applyOnFields(fld => fld === null || fld === void 0 ? void 0 : fld.hideLabel(), codes, secCode, subCode);
|
|
2470
|
-
}
|
|
2471
|
-
disableFields(codes, secCode, subCode) {
|
|
2472
|
-
return this.applyOnFields(fld => fld === null || fld === void 0 ? void 0 : fld.disable(), codes, secCode, subCode);
|
|
2473
|
-
}
|
|
2474
|
-
cleanFields(codes, secCode, subCode) {
|
|
2475
|
-
return this.applyOnFields(fld => fld === null || fld === void 0 ? void 0 : fld.clean(), codes, secCode, subCode);
|
|
2476
|
-
}
|
|
2477
|
-
tagFieldsWithError(message, codes, secCode, subCode) {
|
|
2478
|
-
return this.applyOnFields(fld => fld === null || fld === void 0 ? void 0 : fld.setErrorMessage(message), codes, secCode, subCode);
|
|
2479
|
-
}
|
|
2480
|
-
cleanErrorFields(codes, secCode, subCode) {
|
|
2481
|
-
return this.tagFieldsWithError('', codes, secCode, subCode);
|
|
2482
|
-
}
|
|
2483
|
-
tagEmptyRequiredFields(message, codes = null, secCode, subCode) {
|
|
2484
|
-
return this.tagFieldsWithError(message, this.getRequiredEmptyFields(codes, secCode, subCode)) > 0;
|
|
2485
|
-
}
|
|
2486
|
-
getRequiredFields(codes, secCode, subCode) {
|
|
2487
|
-
return this.getFieldSet(fld => fld === null || fld === void 0 ? void 0 : fld.required, codes !== null && codes !== void 0 ? codes : null, secCode, subCode);
|
|
2488
|
-
}
|
|
2489
|
-
getRequiredEmptyFields(codes, secCode, subCode, onlyVisible) {
|
|
2490
|
-
if (onlyVisible) {
|
|
2491
|
-
return this.getFieldSet(fld => (fld === null || fld === void 0 ? void 0 : fld.required) && (fld === null || fld === void 0 ? void 0 : fld.visible) && (fld === null || fld === void 0 ? void 0 : fld.empty), codes !== null && codes !== void 0 ? codes : null, secCode, subCode);
|
|
2492
|
-
}
|
|
2493
|
-
return this.getFieldSet(fld => (fld === null || fld === void 0 ? void 0 : fld.required) && (fld === null || fld === void 0 ? void 0 : fld.empty), codes !== null && codes !== void 0 ? codes : null, secCode, subCode);
|
|
2494
|
-
}
|
|
2495
|
-
getChangedFields(codes, secCode, subCode) {
|
|
2496
|
-
return this.getFieldSet(fld => !(fld === null || fld === void 0 ? void 0 : fld.outputOnly) && (fld === null || fld === void 0 ? void 0 : fld.hasChanged), codes !== null && codes !== void 0 ? codes : null, secCode, subCode);
|
|
2497
|
-
}
|
|
2498
|
-
getFieldsWithValidationIssues(codes, secCode, subCode, onlyVisible) {
|
|
2499
|
-
if (onlyVisible) {
|
|
2500
|
-
return this.getFieldSet(fld => ((fld === null || fld === void 0 ? void 0 : fld.hasError()) && (fld === null || fld === void 0 ? void 0 : fld.visible)), codes !== null && codes !== void 0 ? codes : null, secCode, subCode);
|
|
2501
|
-
}
|
|
2502
|
-
return this.getFieldSet(fld => fld === null || fld === void 0 ? void 0 : fld.hasError(), codes !== null && codes !== void 0 ? codes : null, secCode, subCode);
|
|
2503
|
-
}
|
|
2504
|
-
getFieldsValues(inputCodes, secCode, subCode) {
|
|
2505
|
-
var _a, _b, _c;
|
|
2506
|
-
const codes = this.getFieldSet(null, inputCodes !== null && inputCodes !== void 0 ? inputCodes : null, secCode, subCode);
|
|
2507
|
-
const resultObject = {};
|
|
2508
|
-
for (let index = 0; index < codes.length; index++) {
|
|
2509
|
-
const code = codes[index];
|
|
2510
|
-
if (code) {
|
|
2511
|
-
resultObject[code] = (_c = (_b = (_a = this.fields) === null || _a === void 0 ? void 0 : _a[code]) === null || _b === void 0 ? void 0 : _b.getValue()) !== null && _c !== void 0 ? _c : null;
|
|
2512
|
-
}
|
|
2513
|
-
}
|
|
2514
|
-
return resultObject;
|
|
2515
|
-
}
|
|
2516
|
-
// Acciones
|
|
2517
|
-
getActions() { return this.actionArray; }
|
|
2518
|
-
getAction(code) { var _a; return (code && ((_a = this.actions) === null || _a === void 0 ? void 0 : _a[code])) ? this.actions[code] : null; }
|
|
2519
|
-
showActions(codes) { return this.execOnActions(codes, SHOW); }
|
|
2520
|
-
hideActions(codes) { return this.execOnActions(codes, HIDE); }
|
|
2521
|
-
enableActions(codes) { return this.execOnActions(codes, ENABLE); }
|
|
2522
|
-
disableActions(codes) { return this.execOnActions(codes, DISABLE); }
|
|
2523
|
-
enableAction(code) { return this.enableActions(code); }
|
|
2524
|
-
disableAction(code) { return this.disableActions(code); }
|
|
2525
|
-
showAction(code) { return this.showActions(code); }
|
|
2526
|
-
hideAction(code) { return this.hideActions(code); }
|
|
2527
|
-
getHeaderActions() { return this.getActionsByAttribute('location', HEADER$1); }
|
|
2528
|
-
getActionsByAttribute(name, value) {
|
|
2529
|
-
return this.actionArray.filter(actionItem => actionItem.matchAttribute(name, value));
|
|
2530
|
-
}
|
|
2531
|
-
execOnActions(codes, functionName) {
|
|
2532
|
-
const actionCodes = (Array.isArray(codes)) ? codes : (codes ? [codes] : []);
|
|
2533
|
-
if (!functionName || actionCodes.length === 0) {
|
|
2534
|
-
return;
|
|
2535
|
-
}
|
|
2536
|
-
actionCodes.forEach(code => {
|
|
2537
|
-
var _a;
|
|
2538
|
-
const action = this.getAction(code);
|
|
2539
|
-
(_a = action === null || action === void 0 ? void 0 : action[functionName]) === null || _a === void 0 ? void 0 : _a.call(action);
|
|
2540
|
-
});
|
|
2541
|
-
}
|
|
2542
|
-
// Tablas
|
|
2543
|
-
getTables() { return this.tableArray; }
|
|
2544
|
-
getTable(code) { var _a; return (code && ((_a = this.tables) === null || _a === void 0 ? void 0 : _a[code])) ? this.tables[code] : null; }
|
|
2545
|
-
getTableRecord(code, id) { var _a; return (_a = this.getTable(code)) === null || _a === void 0 ? void 0 : _a.getTableRecord(id); }
|
|
2546
|
-
enableTables(codes) { return this.execOnTables(codes, ENABLE); }
|
|
2547
|
-
disableTables(codes) { return this.execOnTables(codes, DISABLE); }
|
|
2548
|
-
showTables(codes) { return this.execOnTables(codes, SHOW); }
|
|
2549
|
-
hideTables(codes) { return this.execOnTables(codes, HIDE); }
|
|
2550
|
-
cleanTables(codes) { return this.execOnTables(codes, CLEAN); }
|
|
2551
|
-
showTable(code) { return this.showTables(code); }
|
|
2552
|
-
hideTable(code) { return this.hideTables(code); }
|
|
2553
|
-
cleanTable(code) { var _a; return (_a = this.getTable(code)) === null || _a === void 0 ? void 0 : _a.clean(); }
|
|
2554
|
-
execOnTables(codes, functionName) {
|
|
2555
|
-
const tableCodes = (Array.isArray(codes)) ? codes : (codes ? [codes] : []);
|
|
2556
|
-
if (!functionName || tableCodes.length === 0) {
|
|
2557
|
-
return;
|
|
2558
|
-
}
|
|
2559
|
-
tableCodes.forEach(code => {
|
|
2560
|
-
var _a;
|
|
2561
|
-
const table = this.getTable(code);
|
|
2562
|
-
(_a = table === null || table === void 0 ? void 0 : table[functionName]) === null || _a === void 0 ? void 0 : _a.call(table);
|
|
2563
|
-
});
|
|
2564
|
-
}
|
|
2565
|
-
// Secciones
|
|
2566
|
-
getSections() { return this.sectionArray; }
|
|
2567
|
-
getSectionsTitles() { var _a; return (_a = this.getSections()) === null || _a === void 0 ? void 0 : _a.filter(sec => sec === null || sec === void 0 ? void 0 : sec.title).map(sec => { var _a; return (_a = sec === null || sec === void 0 ? void 0 : sec.title) !== null && _a !== void 0 ? _a : ''; }); }
|
|
2568
|
-
numSections() { return this.sectionArray.length; }
|
|
2569
|
-
getSectionsByAttribute(name, value) { return this.sectionArray.filter(item => item.matchAttribute(name, value)); }
|
|
2570
|
-
get sectionTitles() { return this.getSectionsTitles(); }
|
|
2571
|
-
get visibleSections() { return this.sectionArray.filter(sec => sec.absoluteVisible); }
|
|
2572
|
-
getSection(code) { var _a; return (code && ((_a = this.sections) === null || _a === void 0 ? void 0 : _a[code])) ? this.sections[code] : null; }
|
|
2573
|
-
showSections(codes) { this.execOnSections(codes, SHOW); }
|
|
2574
|
-
hideSections(codes) { this.execOnSections(codes, HIDE); }
|
|
2575
|
-
showSection(code) { return this.showSections(code); }
|
|
2576
|
-
hideSection(code) { return this.hideSections(code); }
|
|
2577
|
-
activeSection() { return this._exclusiveSectionsByAttr[ACTIVE]; }
|
|
2578
|
-
getSubSection(code, subCode) { var _a, _b; return (_b = (_a = this.getSection(code)) === null || _a === void 0 ? void 0 : _a.getSubsection(subCode)) !== null && _b !== void 0 ? _b : null; }
|
|
2579
|
-
showSubSections(code, subCodes) { return this.execOnSubSections(code, subCodes, SHOW); }
|
|
2580
|
-
showSubSection(code, subCode) { return this.showSubSections(code, subCode); }
|
|
2581
|
-
hideSubSection(code, subCode) { return this.hideSubSections(code, subCode); }
|
|
2582
|
-
hideSubSections(code, subCodes) { return this.execOnSubSections(code, subCodes, HIDE); }
|
|
2583
|
-
getSectionActions(code) { var _a, _b; return (_b = (_a = this.getSection(code)) === null || _a === void 0 ? void 0 : _a.getActions()) !== null && _b !== void 0 ? _b : null; }
|
|
2584
|
-
getSectionActionNames(code) { var _a, _b; return (_b = (_a = this.getSection(code)) === null || _a === void 0 ? void 0 : _a.getActionNames()) !== null && _b !== void 0 ? _b : null; }
|
|
2585
|
-
activateSection(code) {
|
|
2586
|
-
var _a, _b;
|
|
2587
|
-
if (code === this._exclusiveSectionsByAttr[ACTIVE]) {
|
|
2588
|
-
return;
|
|
2589
|
-
}
|
|
2590
|
-
(_a = this.getSection(this.activeSection())) === null || _a === void 0 ? void 0 : _a.inactivate();
|
|
2591
|
-
(_b = this.getSection(code)) === null || _b === void 0 ? void 0 : _b.activate();
|
|
2592
|
-
this._exclusiveSectionsByAttr[ACTIVE] = code;
|
|
2593
|
-
}
|
|
2594
|
-
execOnSections(codes, functionName) {
|
|
2595
|
-
const sectionCodes = (Array.isArray(codes)) ? codes : (codes ? [codes] : []);
|
|
2596
|
-
if (!functionName || sectionCodes.length === 0) {
|
|
2597
|
-
return;
|
|
2598
|
-
}
|
|
2599
|
-
sectionCodes.forEach(code => {
|
|
2600
|
-
var _a;
|
|
2601
|
-
const section = this.getSection(code);
|
|
2602
|
-
(_a = section === null || section === void 0 ? void 0 : section[functionName]) === null || _a === void 0 ? void 0 : _a.call(section);
|
|
2603
|
-
});
|
|
2604
|
-
}
|
|
2605
|
-
execOnSubSections(code, subNames, functionName) {
|
|
2606
|
-
var _a;
|
|
2607
|
-
const subCodes = (Array.isArray(subNames)) ? subNames : (subNames ? [subNames] : []);
|
|
2608
|
-
const section = this.getSection(code);
|
|
2609
|
-
if (!functionName || !section || subCodes.length === 0) {
|
|
2610
|
-
return;
|
|
2611
|
-
}
|
|
2612
|
-
for (const subCode of subCodes) {
|
|
2613
|
-
const subSection = this.getSubSection(code, subCode);
|
|
2614
|
-
(_a = subSection === null || subSection === void 0 ? void 0 : subSection[functionName]) === null || _a === void 0 ? void 0 : _a.call(subSection);
|
|
2615
|
-
}
|
|
2616
|
-
}
|
|
2617
|
-
/**
|
|
2618
|
-
* Métodos propios de gestión del formulario
|
|
2619
|
-
*/
|
|
2620
|
-
cleanData() {
|
|
2621
|
-
for (const field of this.fieldArray) {
|
|
2622
|
-
field.setValue(field.defaultValue);
|
|
2623
|
-
}
|
|
2624
|
-
for (const table of this.tableArray) {
|
|
2625
|
-
table.clean();
|
|
2626
|
-
}
|
|
2627
|
-
}
|
|
2628
|
-
getPayload() {
|
|
2629
|
-
const formData = { fields: [], tables: [] };
|
|
2630
|
-
formData.fields = this.getFields().filter(fld => !(fld === null || fld === void 0 ? void 0 : fld.outputOnly))
|
|
2631
|
-
.map(fld => {
|
|
2632
|
-
const fieldPayload = {
|
|
2633
|
-
fieldCode: fld === null || fld === void 0 ? void 0 : fld.code,
|
|
2634
|
-
fieldValue: fld === null || fld === void 0 ? void 0 : fld.value,
|
|
2635
|
-
editable: !(fld === null || fld === void 0 ? void 0 : fld.absoluteDisabled),
|
|
2636
|
-
visible: fld === null || fld === void 0 ? void 0 : fld.absoluteVisible,
|
|
2637
|
-
required: fld === null || fld === void 0 ? void 0 : fld.required,
|
|
2638
|
-
fieldOptions: '',
|
|
2639
|
-
};
|
|
2640
|
-
return fieldPayload;
|
|
2641
|
-
});
|
|
2642
|
-
formData.tables = this.getTables().map(tbl => {
|
|
2643
|
-
const tablePayload = {
|
|
2644
|
-
tableCode: tbl.tableCode,
|
|
2645
|
-
visible: tbl.absoluteVisible,
|
|
2646
|
-
currentPage: tbl.currentPage,
|
|
2647
|
-
requestedPage: tbl.requestedPage,
|
|
2648
|
-
recordsPerPage: tbl.recordsPerPage,
|
|
2649
|
-
currentFilter: tbl.currentFilter,
|
|
2650
|
-
sortingColumn: tbl.sorting.columnName,
|
|
2651
|
-
sortingDirection: tbl.sorting.direction,
|
|
2652
|
-
};
|
|
2653
|
-
return tablePayload;
|
|
2654
|
-
});
|
|
2655
|
-
return formData;
|
|
2656
|
-
}
|
|
2657
|
-
/**
|
|
2658
|
-
* @deprecated Use subject
|
|
2659
|
-
*/
|
|
2660
|
-
get formSubject() { return this.subject; }
|
|
2661
|
-
/**
|
|
2662
|
-
* @deprecated Use subject
|
|
2663
|
-
*/
|
|
2664
|
-
set formSubject(subject) { this.subject = subject; }
|
|
2665
|
-
/**
|
|
2666
|
-
* @deprecated Use states
|
|
2667
|
-
*/
|
|
2668
|
-
getStates() { return this.states; }
|
|
2669
|
-
/**
|
|
2670
|
-
* @deprecated Use state
|
|
2671
|
-
*/
|
|
2672
|
-
getCurrentState() { return this.state; }
|
|
2673
|
-
/**
|
|
2674
|
-
* @deprecated Use title
|
|
2675
|
-
*/
|
|
2676
|
-
getTitle() { return this.title; }
|
|
2677
|
-
/**
|
|
2678
|
-
* @deprecated Use title
|
|
2679
|
-
*/
|
|
2680
|
-
setTitle(title) { this.title = title; }
|
|
2681
|
-
/**
|
|
2682
|
-
* @deprecated Use supportState
|
|
2683
|
-
*/
|
|
2684
|
-
supportMode(state) { return this.supportState(state); }
|
|
2685
|
-
/**
|
|
2686
|
-
* @deprecated Use enableFields
|
|
2687
|
-
*/
|
|
2688
|
-
enableEditFields(codes, secCode, subCode) {
|
|
2689
|
-
return this.enableFields(codes, secCode, subCode);
|
|
2690
|
-
}
|
|
2691
|
-
/**
|
|
2692
|
-
* @deprecated Use disableFields
|
|
2693
|
-
*/
|
|
2694
|
-
disableEditFields(codes, secCode, subCode) {
|
|
2695
|
-
return this.disableFields(codes, secCode, subCode);
|
|
2696
|
-
}
|
|
2697
|
-
/**
|
|
2698
|
-
* @deprecated Use getField
|
|
2699
|
-
*/
|
|
2700
|
-
getFieldObject(code) { return this.getField(code); }
|
|
2701
|
-
/**
|
|
2702
|
-
* @deprecated Use getAction
|
|
2703
|
-
*/
|
|
2704
|
-
getActionObject(code) { return this.getAction(code); }
|
|
2705
|
-
/**
|
|
2706
|
-
* @deprecated Use getTable
|
|
2707
|
-
*/
|
|
2708
|
-
getTableObject(code) { return this.getTable(code); }
|
|
2709
|
-
/**
|
|
2710
|
-
* @deprecated Use getSection
|
|
2711
|
-
*/
|
|
2712
|
-
getSectionObject(code) { return this.getSection(code); }
|
|
2713
|
-
/**
|
|
2714
|
-
* @deprecated Use changeState
|
|
2715
|
-
*/
|
|
2716
|
-
changeFormMode(state) { return this.changeState(state); }
|
|
2717
|
-
/**
|
|
2718
|
-
* @deprecated Use subject
|
|
2719
|
-
*/
|
|
2720
|
-
getFormSubject() { return this.subject; }
|
|
2721
|
-
/**
|
|
2722
|
-
* @deprecated Use subject
|
|
2723
|
-
*/
|
|
2724
|
-
getSubject() { var _a; return (_a = this.subject) !== null && _a !== void 0 ? _a : ''; }
|
|
2725
|
-
/**
|
|
2726
|
-
* @deprecated Use subject
|
|
2727
|
-
*/
|
|
2728
|
-
getformSubject() { var _a; return (_a = this.subject) !== null && _a !== void 0 ? _a : ''; }
|
|
2729
|
-
}
|
|
2730
|
-
|
|
2731
|
-
class LibFormManagerService {
|
|
2732
|
-
constructor() {
|
|
2733
|
-
this.cleanStack();
|
|
2734
|
-
}
|
|
2735
|
-
// Métodos virtuales para las aplicaciones
|
|
2736
|
-
getFormDefinition(formCode) { }
|
|
2737
|
-
execServerAction(actionDetail) { }
|
|
2738
|
-
goToForm(formCode, token, subject) { }
|
|
2739
|
-
loadStack() {
|
|
2740
|
-
return __awaiter(this, void 0, void 0, function* () { });
|
|
2741
|
-
}
|
|
2742
|
-
saveStack() { }
|
|
2743
|
-
cleanStack() { this.pageStack = []; }
|
|
2744
|
-
resetPageStack() { this.cleanStack(); }
|
|
2745
|
-
findFormInStack(token) {
|
|
2746
|
-
const index = this.pageStack.findIndex(item => (item === null || item === void 0 ? void 0 : item.token) === token);
|
|
2747
|
-
const data = (index >= 0) ? this.pageStack[index] : null;
|
|
2748
|
-
return { index, data };
|
|
2749
|
-
}
|
|
2750
|
-
replaceItem(token, formInfo) {
|
|
2751
|
-
var _a, _b, _c, _d;
|
|
2752
|
-
if (!token || !formInfo) {
|
|
2753
|
-
return;
|
|
2754
|
-
}
|
|
2755
|
-
const { index, data: storedForm } = this.findFormInStack(token);
|
|
2756
|
-
let updatedForm = null;
|
|
2757
|
-
if (index >= 0) {
|
|
2758
|
-
updatedForm = Object.assign({}, storedForm);
|
|
2759
|
-
updatedForm.subject = (_a = formInfo === null || formInfo === void 0 ? void 0 : formInfo.subject) !== null && _a !== void 0 ? _a : storedForm.subject;
|
|
2760
|
-
updatedForm.state = (_b = formInfo === null || formInfo === void 0 ? void 0 : formInfo.state) !== null && _b !== void 0 ? _b : storedForm.state;
|
|
2761
|
-
updatedForm.fields = (_c = storedForm === null || storedForm === void 0 ? void 0 : storedForm.fields) !== null && _c !== void 0 ? _c : {};
|
|
2762
|
-
updatedForm.extra = (_d = storedForm === null || storedForm === void 0 ? void 0 : storedForm.extra) !== null && _d !== void 0 ? _d : {};
|
|
2763
|
-
if (formInfo.fields) {
|
|
2764
|
-
Object.assign(updatedForm.fields, formInfo.fields);
|
|
2765
|
-
}
|
|
2766
|
-
if (formInfo.extra) {
|
|
2767
|
-
Object.assign(updatedForm.extra, formInfo.extra);
|
|
2768
|
-
}
|
|
2769
|
-
this.pageStack[index] = updatedForm;
|
|
2770
|
-
this.saveStack();
|
|
2771
|
-
}
|
|
2772
|
-
}
|
|
2773
|
-
stack(origin, target) {
|
|
2774
|
-
const token = nanoid(6);
|
|
2775
|
-
this.replaceItem(target.originToken, origin);
|
|
2776
|
-
this.pageStack.push(Object.assign({ token }, target));
|
|
2777
|
-
this.saveStack();
|
|
2778
|
-
return token;
|
|
2779
|
-
}
|
|
2780
|
-
unstack(token = null) {
|
|
2781
|
-
let index = (token) ? this.findFormInStack(token).index : this.pageStack.length - 2;
|
|
2782
|
-
let formInfo = null;
|
|
2783
|
-
if (index >= 0) {
|
|
2784
|
-
formInfo = this.pageStack[index];
|
|
2785
|
-
this.pageStack.splice(index + 1);
|
|
2786
|
-
this.saveStack();
|
|
2787
|
-
}
|
|
2788
|
-
return formInfo;
|
|
2789
|
-
}
|
|
2790
|
-
getFormInfo(token) {
|
|
2791
|
-
var _a, _b;
|
|
2792
|
-
const { data } = this.findFormInStack(token);
|
|
2793
|
-
return {
|
|
2794
|
-
token: data === null || data === void 0 ? void 0 : data.token,
|
|
2795
|
-
subject: data === null || data === void 0 ? void 0 : data.subject,
|
|
2796
|
-
state: data === null || data === void 0 ? void 0 : data.state,
|
|
2797
|
-
originToken: data === null || data === void 0 ? void 0 : data.originToken,
|
|
2798
|
-
fields: (_a = data === null || data === void 0 ? void 0 : data.fields) !== null && _a !== void 0 ? _a : {},
|
|
2799
|
-
extra: (_b = data === null || data === void 0 ? void 0 : data.extra) !== null && _b !== void 0 ? _b : {}
|
|
2800
|
-
};
|
|
2801
|
-
}
|
|
2802
|
-
openForm(origin, target) {
|
|
2803
|
-
var _a;
|
|
2804
|
-
(!origin) && this.cleanStack();
|
|
2805
|
-
target.originToken = (_a = origin === null || origin === void 0 ? void 0 : origin.token) !== null && _a !== void 0 ? _a : null;
|
|
2806
|
-
const token = this.stack(origin, target);
|
|
2807
|
-
this.goToForm(target.name, token, target.subject);
|
|
2808
|
-
}
|
|
2809
|
-
backTo(targetToken = null) {
|
|
2810
|
-
const formInfo = this.unstack(targetToken);
|
|
2811
|
-
formInfo && formInfo.name && this.goToForm(formInfo.name, formInfo.token, formInfo.subject);
|
|
2812
|
-
}
|
|
2813
|
-
}
|
|
2814
|
-
|
|
2815
|
-
class LibEventManagerService {
|
|
2816
|
-
constructor(eventSet) {
|
|
2817
|
-
this.eventSubjects = {};
|
|
2818
|
-
this.eventSubjectParams = {};
|
|
2819
|
-
eventSet.forEach((event) => { this.addEventName(event); });
|
|
2820
|
-
}
|
|
2821
|
-
addEventName(event, rebuild = false) {
|
|
2822
|
-
const eventObject = (typeof event === 'string') ? { name: event } : event;
|
|
2823
|
-
const { name, type, initialValue, windowTime, timestampProvider } = eventObject;
|
|
2824
|
-
const currentSubject = this.eventSubjects[name];
|
|
2825
|
-
if (rebuild || !currentSubject) {
|
|
2826
|
-
if (type === 'behaviour') {
|
|
2827
|
-
const newEventSubject = new BehaviorSubject(initialValue);
|
|
2828
|
-
this.eventSubjects[name] = newEventSubject;
|
|
2829
|
-
}
|
|
2830
|
-
else if (type === 'subject') {
|
|
2831
|
-
const newEventSubject = new Subject();
|
|
2832
|
-
this.eventSubjects[name] = newEventSubject;
|
|
2833
|
-
}
|
|
2834
|
-
else {
|
|
2835
|
-
const newEventSubject = new ReplaySubject(initialValue, windowTime, timestampProvider);
|
|
2836
|
-
this.eventSubjects[name] = newEventSubject;
|
|
2837
|
-
}
|
|
2838
|
-
this.eventSubjectParams[name] = { name: name, windowTime, timestampProvider };
|
|
2839
|
-
}
|
|
2840
|
-
}
|
|
2841
|
-
resetSubject(eventClassName) {
|
|
2842
|
-
const { name, windowTime, timestampProvider } = this.eventSubjectParams[eventClassName];
|
|
2843
|
-
return this.addEventName({ name, windowTime, timestampProvider });
|
|
2844
|
-
}
|
|
2845
|
-
getEventNames() { return Object.keys(this.eventSubjects); }
|
|
2846
|
-
getSubject(eventClassName) { return eventClassName ? this.eventSubjects[eventClassName] : null; }
|
|
2847
|
-
subscribe(eventClassName, callback) { return this.getSubject(eventClassName).subscribe(callback); }
|
|
2848
|
-
next(eventClassName, data) {
|
|
2849
|
-
const subject = this.getSubject(eventClassName);
|
|
2850
|
-
if (!subject) {
|
|
2851
|
-
console.log(`No se encontró subject ${eventClassName}`);
|
|
2852
|
-
}
|
|
2853
|
-
subject.next(data);
|
|
2854
|
-
}
|
|
2855
|
-
}
|
|
2856
|
-
|
|
2857
|
-
class LibFileManagementService {
|
|
2858
|
-
openFile(fileBase64Data, fileName, fileType) { }
|
|
2859
|
-
saveFileFromURL(fileUrl, fileName = null, fileType = null) { }
|
|
2860
|
-
saveFile(fileBase64Data, fileName, fileType) { }
|
|
2861
|
-
printPdfFile(pdfBufferData) { }
|
|
2862
|
-
}
|
|
2863
|
-
|
|
2864
|
-
const PAYLOAD_VERSION = 'TUAINEXCHANGE_1.0';
|
|
2865
|
-
const INLINE_ACTION = 'INLINE';
|
|
2866
|
-
const GLOBAL_ACTION = 'GLOBAL';
|
|
2867
|
-
const GET_DATA_ACTION = 'GETDATA';
|
|
2868
|
-
const SUBJECT = 'subject';
|
|
2869
|
-
const TOKEN = 'token';
|
|
2870
|
-
class BasicFormComponent extends FormStructureAndData {
|
|
2871
|
-
constructor(formManagerService, _eventManager, fileMgmtServices) {
|
|
2872
|
-
super();
|
|
2873
|
-
this.formManagerService = formManagerService;
|
|
2874
|
-
this._eventManager = _eventManager;
|
|
2875
|
-
this.fileMgmtServices = fileMgmtServices;
|
|
2876
|
-
this._controlToken = null;
|
|
2877
|
-
this._originToken = null;
|
|
2878
|
-
this._formRoute = null;
|
|
2879
|
-
this._definitionObtained = false;
|
|
2880
|
-
this._notifyFormActivity = true;
|
|
2881
|
-
// Eventos de acciones y campos
|
|
2882
|
-
this._formChangeState = [];
|
|
2883
|
-
this._formSectionsCanDeactivate = {};
|
|
2884
|
-
this._formSectionsActivate = {};
|
|
2885
|
-
this._formSectionsInactivate = {};
|
|
2886
|
-
this._formActionsStart = {};
|
|
2887
|
-
this._formActionsFinish = {};
|
|
2888
|
-
this._fieldInputValidation = {};
|
|
2889
|
-
this._fieldValidationsStart = {};
|
|
2890
|
-
this._fieldValidationsFinish = {};
|
|
2891
|
-
// Callback de acciones de tablas
|
|
2892
|
-
this._tableSelectionsStart = {};
|
|
2893
|
-
this._tableSelectionsFinish = {};
|
|
2894
|
-
this._tableActionsStart = {};
|
|
2895
|
-
this._tableActionsFinish = {};
|
|
2896
|
-
this._tableGetDataStart = {};
|
|
2897
|
-
this._tableGetDataFinish = {};
|
|
2898
|
-
// Errores en procesos
|
|
2899
|
-
this._actionServerError = [];
|
|
2900
|
-
this._fieldServerError = [];
|
|
2901
|
-
this._tableServerError = [];
|
|
2902
|
-
// Datos complementarios del formulario
|
|
2903
|
-
this.inputDataFields = {};
|
|
2904
|
-
this.extraData = {};
|
|
2905
|
-
this.enabledSections = [];
|
|
2906
|
-
// Gestión de error
|
|
2907
|
-
this._errorType = '';
|
|
2908
|
-
this.errorCode = '';
|
|
2909
|
-
this.errorFullCode = '';
|
|
2910
|
-
this.errorName = '';
|
|
2911
|
-
this.errorMessage = '';
|
|
2912
|
-
this.errorDetail = '';
|
|
2913
|
-
// Control de estado
|
|
2914
|
-
this.visible = false;
|
|
2915
|
-
this.busy = false;
|
|
2916
|
-
this._eventEmiter = this._eventManager;
|
|
2917
|
-
this.cleanStart();
|
|
2918
|
-
this.customPreProcessing();
|
|
2919
|
-
}
|
|
2920
|
-
cleanStart() {
|
|
2921
|
-
this._errorType = '';
|
|
2922
|
-
this.errorCode = '';
|
|
2923
|
-
this.errorFullCode = '';
|
|
2924
|
-
this.errorName = '';
|
|
2925
|
-
this.errorMessage = '';
|
|
2926
|
-
this.errorDetail = '';
|
|
2927
|
-
this.cleanForm();
|
|
2928
|
-
this._controlToken = null;
|
|
2929
|
-
this.inputDataFields = {};
|
|
2930
|
-
this._definitionObtained = false;
|
|
2931
|
-
// Se limpian los manejadores de eventos
|
|
2932
|
-
this.visible = false;
|
|
2933
|
-
this.busy = false;
|
|
2934
|
-
this._formChangeState = [];
|
|
2935
|
-
this._formSectionsCanDeactivate = {};
|
|
2936
|
-
this._formSectionsActivate = {};
|
|
2937
|
-
this._formSectionsInactivate = {};
|
|
2938
|
-
this._formActionsStart = {};
|
|
2939
|
-
this._formActionsFinish = {};
|
|
2940
|
-
this._fieldInputValidation = {};
|
|
2941
|
-
this._fieldValidationsStart = {};
|
|
2942
|
-
this._fieldValidationsFinish = {};
|
|
2943
|
-
this._tableSelectionsStart = {};
|
|
2944
|
-
this._tableSelectionsFinish = {};
|
|
2945
|
-
this._tableActionsStart = {};
|
|
2946
|
-
this._tableActionsFinish = {};
|
|
2947
|
-
this._tableGetDataStart = {};
|
|
2948
|
-
this._tableGetDataFinish = {};
|
|
2949
|
-
this._actionServerError = [];
|
|
2950
|
-
this._fieldServerError = [];
|
|
2951
|
-
this._tableServerError = [];
|
|
2952
|
-
this.onActionServerError(() => this.displayActionServerError());
|
|
2953
|
-
this.onValidationServerError(() => this.displayValidationServerError());
|
|
2954
|
-
this.onTableServerError(() => this.displayTableServerError());
|
|
2955
|
-
}
|
|
2956
|
-
get formVisible() { return this.visible; }
|
|
2957
|
-
get form() { return this; }
|
|
2958
|
-
// Métodos virtuales
|
|
2959
|
-
customPreProcessing() { }
|
|
2960
|
-
start() { }
|
|
2961
|
-
customFormStart() { }
|
|
2962
|
-
displayActionServerError() { }
|
|
2963
|
-
displayValidationServerError() { }
|
|
2964
|
-
displayTableServerError() { }
|
|
2965
|
-
showFieldInfo(code, detail) { }
|
|
2966
|
-
showModalDialog(title, body, options, callback, params) { }
|
|
2967
|
-
openUploadDialog(title, body, options, callback, params) { }
|
|
2968
|
-
subscribeAppEvent(eventName, callback) {
|
|
2969
|
-
this._eventEmiter.subscribe(eventName, callback);
|
|
2970
|
-
}
|
|
2971
|
-
openForm(name, data = null, backData = null, cleanStack = false) {
|
|
2972
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
2973
|
-
let origin = null;
|
|
2974
|
-
if (!cleanStack) {
|
|
2975
|
-
origin = Object.assign(Object.assign({}, backData), { name: this.name, url: this._formRoute, token: this._controlToken });
|
|
2976
|
-
origin.subject = (_a = origin === null || origin === void 0 ? void 0 : origin.subject) !== null && _a !== void 0 ? _a : this.subject;
|
|
2977
|
-
origin.state = (_b = origin === null || origin === void 0 ? void 0 : origin.state) !== null && _b !== void 0 ? _b : this.state;
|
|
2978
|
-
origin.fields = (_c = origin === null || origin === void 0 ? void 0 : origin.fields) !== null && _c !== void 0 ? _c : {};
|
|
2979
|
-
origin.extra = (_d = origin === null || origin === void 0 ? void 0 : origin.extra) !== null && _d !== void 0 ? _d : {};
|
|
2980
|
-
}
|
|
2981
|
-
const target = Object.assign(Object.assign({}, data), { name });
|
|
2982
|
-
target.subject = (_e = target === null || target === void 0 ? void 0 : target.subject) !== null && _e !== void 0 ? _e : null;
|
|
2983
|
-
target.state = (_f = target === null || target === void 0 ? void 0 : target.state) !== null && _f !== void 0 ? _f : null;
|
|
2984
|
-
target.fields = (_g = target === null || target === void 0 ? void 0 : target.fields) !== null && _g !== void 0 ? _g : {};
|
|
2985
|
-
target.extra = (_h = target === null || target === void 0 ? void 0 : target.extra) !== null && _h !== void 0 ? _h : {};
|
|
2986
|
-
this.formManagerService.openForm(origin, target);
|
|
2987
|
-
}
|
|
2988
|
-
enableActivityNotification() { this._notifyFormActivity = true; }
|
|
2989
|
-
disableActivityNotification() { this._notifyFormActivity = false; }
|
|
2990
|
-
canGoBack() { return this._originToken !== null; }
|
|
2991
|
-
goBack() { return this.formManagerService.backTo(); }
|
|
2992
|
-
goBackForm() { return this.goBack(); }
|
|
2993
|
-
getOriginDetail() { var _a, _b; return (_a = this.formManagerService) === null || _a === void 0 ? void 0 : _a.getFormInfo((_b = this._originToken) !== null && _b !== void 0 ? _b : ''); }
|
|
2994
|
-
setError(errorType, errorMessage, errorDetail) {
|
|
2995
|
-
this._errorType = errorType || '';
|
|
2996
|
-
this.errorMessage = errorMessage || '';
|
|
2997
|
-
this.errorDetail = errorDetail || '';
|
|
2998
|
-
}
|
|
2999
|
-
resetError() {
|
|
3000
|
-
this.errorCode = NO_ERROR;
|
|
3001
|
-
this.errorFullCode = '';
|
|
3002
|
-
this.errorName = '';
|
|
3003
|
-
this.errorMessage = '';
|
|
3004
|
-
this.errorDetail = '';
|
|
3005
|
-
}
|
|
3006
|
-
getErrorType() { return this._errorType; }
|
|
3007
|
-
getErrorMessage() { return this.errorMessage; }
|
|
3008
|
-
getErrorDetail() { return this.errorDetail; }
|
|
3009
|
-
getErrorName() { return this.errorName; }
|
|
3010
|
-
getErrorFullCode() { return this.errorFullCode; }
|
|
3011
|
-
getErrorCode() { return this.errorCode; }
|
|
3012
|
-
getFormParameter(name) {
|
|
3013
|
-
var _a, _b;
|
|
3014
|
-
return (name) ? ((_b = (_a = this.extraData) === null || _a === void 0 ? void 0 : _a[name]) !== null && _b !== void 0 ? _b : null) : null;
|
|
3015
|
-
}
|
|
3016
|
-
preocessInputParams(params) {
|
|
3017
|
-
var _a, _b, _c, _d;
|
|
3018
|
-
this._controlToken = (_a = params === null || params === void 0 ? void 0 : params[TOKEN]) !== null && _a !== void 0 ? _a : null;
|
|
3019
|
-
this.subject = (_b = params === null || params === void 0 ? void 0 : params[SUBJECT]) !== null && _b !== void 0 ? _b : null;
|
|
3020
|
-
const tokenInfo = (this._controlToken) ? this.formManagerService.getFormInfo(this._controlToken) : {};
|
|
3021
|
-
const { token, subject, state, fields, extra, originToken } = tokenInfo;
|
|
3022
|
-
if (token && this._controlToken === token) {
|
|
3023
|
-
this.subject = (_d = (_c = this.subject) !== null && _c !== void 0 ? _c : subject) !== null && _d !== void 0 ? _d : null;
|
|
3024
|
-
this.inputDataFields = fields;
|
|
3025
|
-
this.extraData = extra;
|
|
3026
|
-
this._originToken = originToken;
|
|
3027
|
-
return state;
|
|
3028
|
-
}
|
|
3029
|
-
return null;
|
|
3030
|
-
}
|
|
3031
|
-
subscribeSectionActivation() {
|
|
3032
|
-
const formSections = this.sections;
|
|
3033
|
-
const sectionNames = Object.keys(formSections);
|
|
3034
|
-
for (let index = 0; index < sectionNames.length; index++) {
|
|
3035
|
-
const sectionName = sectionNames[index];
|
|
3036
|
-
const section = formSections[sectionName];
|
|
3037
|
-
section.activation.subscribe((code) => this.launchSectionActivation(code));
|
|
3038
|
-
section.inactivation.subscribe((code) => this.launchSectionInactivation(code));
|
|
3039
|
-
// Adicionalmente se le pide a la sección se subscriba al cambio de estado del formulario
|
|
3040
|
-
section.connectWithParentForm(this, this.stateChange);
|
|
3041
|
-
}
|
|
3042
|
-
}
|
|
3043
|
-
subscribeFieldsSubjects() {
|
|
3044
|
-
const formFields = this.getFields();
|
|
3045
|
-
if (Array.isArray(formFields)) {
|
|
3046
|
-
formFields.forEach(field => {
|
|
3047
|
-
field.editionFinish.subscribe(event => {
|
|
3048
|
-
const { code, intrinsicValidation } = event;
|
|
3049
|
-
this.startFieldValidation(code, intrinsicValidation);
|
|
3050
|
-
});
|
|
3051
|
-
field.editionPartial.subscribe(event => {
|
|
3052
|
-
const { code, intrinsicValidation } = event;
|
|
3053
|
-
this.startFieldInputValidation(code, intrinsicValidation);
|
|
3054
|
-
});
|
|
3055
|
-
field.detailRequest.subscribe(event => this.showFieldInfo(event.code, event.detail));
|
|
3056
|
-
// Adicionalmente se le pide al campo se subscriba al cambio de estado del formulario
|
|
3057
|
-
field.connectWithParentForm(this, this.stateChange);
|
|
3058
|
-
});
|
|
3059
|
-
}
|
|
3060
|
-
}
|
|
3061
|
-
subscribeActionSubjects() {
|
|
3062
|
-
const formActions = this.getActions();
|
|
3063
|
-
if (Array.isArray(formActions)) {
|
|
3064
|
-
formActions.forEach(action => {
|
|
3065
|
-
action.actionActivated.subscribe(code => this.startAction(code));
|
|
3066
|
-
// Adicionalmente se le pide a la acción se subscriba al cambio de estado del formulario
|
|
3067
|
-
action.connectWithParentForm(this, this.stateChange);
|
|
3068
|
-
});
|
|
3069
|
-
}
|
|
3070
|
-
}
|
|
3071
|
-
subscribeTableSubjects() {
|
|
3072
|
-
const formTables = this.getTables();
|
|
3073
|
-
if (Array.isArray(formTables)) {
|
|
3074
|
-
formTables.forEach(table => {
|
|
3075
|
-
table.inlineActionTrigger.subscribe(event => this.startTableAction(event));
|
|
3076
|
-
table.globalActionTrigger.subscribe(event => this.startTableGlobalAction(event));
|
|
3077
|
-
table.recordSelectionTrigger.subscribe(event => this.startTableRecordSelection(event));
|
|
3078
|
-
table.selectionActionTrigger.subscribe(event => this.startTableSelectionAction(event));
|
|
3079
|
-
table.getDataTrigger.subscribe(event => this.startTableGetData(event));
|
|
3080
|
-
// Adicionalmente se le pide a la tabla se subscriba al cambio de estado del formulario
|
|
3081
|
-
table.connectWithParentForm(this, this.stateChange);
|
|
3082
|
-
});
|
|
3083
|
-
}
|
|
3084
|
-
}
|
|
3085
|
-
formInit(params, forceReload = false) {
|
|
3086
|
-
var _a, _b;
|
|
3087
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
3088
|
-
let initialState = this.preocessInputParams(params);
|
|
3089
|
-
if (!this.name) {
|
|
3090
|
-
return;
|
|
3091
|
-
}
|
|
3092
|
-
if (forceReload || !this._definitionObtained) {
|
|
3093
|
-
this.busy = true;
|
|
3094
|
-
const formDefinition = yield this.formManagerService.getFormDefinition(this.name);
|
|
3095
|
-
this.busy = false;
|
|
3096
|
-
this.loadDefinition(formDefinition);
|
|
3097
|
-
this._definitionObtained = true;
|
|
3098
|
-
}
|
|
3099
|
-
else {
|
|
3100
|
-
this.cleanData();
|
|
3101
|
-
}
|
|
3102
|
-
if (!this.supportState(initialState !== null && initialState !== void 0 ? initialState : '')) {
|
|
3103
|
-
initialState = (_a = this.defaultState) !== null && _a !== void 0 ? _a : null;
|
|
3104
|
-
}
|
|
3105
|
-
const inputFieldNames = Object.keys(this.inputDataFields);
|
|
3106
|
-
for (let index = 0; index < inputFieldNames.length; index++) {
|
|
3107
|
-
const code = inputFieldNames[index];
|
|
3108
|
-
const fieldValue = this.inputDataFields[code];
|
|
3109
|
-
this.setFieldValue(code, fieldValue);
|
|
3110
|
-
}
|
|
3111
|
-
this.subscribeSectionActivation();
|
|
3112
|
-
this.subscribeFieldsSubjects();
|
|
3113
|
-
this.subscribeActionSubjects();
|
|
3114
|
-
this.subscribeTableSubjects();
|
|
3115
|
-
// Se define el estado inicial y se solicita la acción inicial
|
|
3116
|
-
this.changeState(initialState || this.defaultState);
|
|
3117
|
-
const recordResponse = yield this.requestFormAction(formActions.getData);
|
|
3118
|
-
this.checkErrorRecordReceived(recordResponse);
|
|
3119
|
-
this.visible = true;
|
|
3120
|
-
this.enabledSections = (_b = this.visibleSections) !== null && _b !== void 0 ? _b : [];
|
|
3121
|
-
this.start();
|
|
3122
|
-
this.customFormStart();
|
|
3123
|
-
});
|
|
3124
|
-
}
|
|
3125
|
-
changeState(state) {
|
|
3126
|
-
var _a;
|
|
3127
|
-
const stateChanged = (_a = super.changeState(state !== null && state !== void 0 ? state : '')) !== null && _a !== void 0 ? _a : false;
|
|
3128
|
-
if (stateChanged) {
|
|
3129
|
-
const clientActionMethods = this._formChangeState;
|
|
3130
|
-
if (clientActionMethods && clientActionMethods.length > 0) {
|
|
3131
|
-
for (const callback of clientActionMethods) {
|
|
3132
|
-
callback(state);
|
|
3133
|
-
}
|
|
3134
|
-
}
|
|
3135
|
-
}
|
|
3136
|
-
return stateChanged;
|
|
3137
|
-
}
|
|
3138
|
-
checkErrorRecordReceived(recordResponse) {
|
|
3139
|
-
const { error } = recordResponse !== null && recordResponse !== void 0 ? recordResponse : {};
|
|
3140
|
-
if (!error) {
|
|
3141
|
-
return false;
|
|
3142
|
-
}
|
|
3143
|
-
this.errorCode = recordResponse.errorCode;
|
|
3144
|
-
this.errorFullCode = recordResponse.errorFullCode;
|
|
3145
|
-
this.errorName = recordResponse.errorName;
|
|
3146
|
-
this.errorMessage = recordResponse.errorMessage;
|
|
3147
|
-
this.errorDetail = recordResponse.errorDetail;
|
|
3148
|
-
return true;
|
|
3149
|
-
}
|
|
3150
|
-
errorOccured() {
|
|
3151
|
-
return (this.errorCode !== NO_ERROR);
|
|
3152
|
-
}
|
|
3153
|
-
/**
|
|
3154
|
-
* Soporte manejo de eventos de formulario
|
|
3155
|
-
*/
|
|
3156
|
-
requestFormAction(actionCode, actionSubject = {}) {
|
|
3157
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
3158
|
-
const actionDetail = {
|
|
3159
|
-
formCode: this.name,
|
|
3160
|
-
formSubject: this.subject,
|
|
3161
|
-
currentMode: this.state,
|
|
3162
|
-
actionCode,
|
|
3163
|
-
actionSubject,
|
|
3164
|
-
version: PAYLOAD_VERSION,
|
|
3165
|
-
formData: this.getPayload(),
|
|
3166
|
-
immutableData: this.immutableData,
|
|
3167
|
-
};
|
|
3168
|
-
this.errorCode = NO_ERROR;
|
|
3169
|
-
this.errorFullCode = '';
|
|
3170
|
-
this.errorName = '';
|
|
3171
|
-
this.errorMessage = '';
|
|
3172
|
-
this.errorDetail = '';
|
|
3173
|
-
this.busy = true;
|
|
3174
|
-
const formActionResponse = yield this.formManagerService.execServerAction(actionDetail);
|
|
3175
|
-
if (!formActionResponse) {
|
|
3176
|
-
return null;
|
|
3177
|
-
}
|
|
3178
|
-
this.busy = false;
|
|
3179
|
-
if (formActionResponse.hasError()) {
|
|
3180
|
-
const error = formActionResponse.error;
|
|
3181
|
-
this.errorCode = error.errorCode;
|
|
3182
|
-
this.errorFullCode = error.errorFullCode;
|
|
3183
|
-
this.errorName = error.errorName;
|
|
3184
|
-
this.errorMessage = error.errorMessage;
|
|
3185
|
-
this.errorDetail = error.errorDetail;
|
|
3186
|
-
}
|
|
3187
|
-
const formResponseData = formActionResponse.getData();
|
|
3188
|
-
this.updateFormWithServerData(formResponseData);
|
|
3189
|
-
return formResponseData;
|
|
3190
|
-
});
|
|
3191
|
-
}
|
|
3192
|
-
updateFormWithServerData(formContent) {
|
|
3193
|
-
const { currentMode, formSubject, actions, fields, recordTables, returnedFile, immutableData, extraInfo, } = formContent;
|
|
3194
|
-
currentMode && this.changeState(currentMode);
|
|
3195
|
-
if (formSubject) {
|
|
3196
|
-
this.subject = formSubject;
|
|
3197
|
-
}
|
|
3198
|
-
if (actions && actions.length > 0) {
|
|
3199
|
-
for (const changedAction of actions) {
|
|
3200
|
-
const actionObject = this.getAction(changedAction.actionCode);
|
|
3201
|
-
if (actionObject) {
|
|
3202
|
-
actionObject.updateFromServer(changedAction);
|
|
3203
|
-
}
|
|
3204
|
-
}
|
|
3205
|
-
}
|
|
3206
|
-
if (fields && fields.length > 0) {
|
|
3207
|
-
for (const changedField of fields) {
|
|
3208
|
-
const fieldObject = this.getField(changedField.fieldCode);
|
|
3209
|
-
if (fieldObject) {
|
|
3210
|
-
fieldObject.updateFromServer(changedField);
|
|
3211
|
-
}
|
|
3212
|
-
}
|
|
3213
|
-
}
|
|
3214
|
-
if (recordTables && recordTables.length > 0) {
|
|
3215
|
-
for (const changedTable of recordTables) {
|
|
3216
|
-
const tableObject = this.getTable(changedTable.tableCode);
|
|
3217
|
-
if (tableObject) {
|
|
3218
|
-
tableObject.updateFromServer(changedTable);
|
|
3219
|
-
}
|
|
3220
|
-
}
|
|
3221
|
-
}
|
|
3222
|
-
if (returnedFile && returnedFile.file) {
|
|
3223
|
-
this.fileMgmtServices.saveFile(returnedFile.file, returnedFile.name, returnedFile.type);
|
|
3224
|
-
}
|
|
3225
|
-
this.immutableData = immutableData;
|
|
3226
|
-
this.extraInfo = extraInfo;
|
|
3227
|
-
}
|
|
3228
|
-
/**
|
|
3229
|
-
* Manejo de event handlers para errores Server del formulario
|
|
3230
|
-
*/
|
|
3231
|
-
cleanActionServerError() { this._actionServerError = []; }
|
|
3232
|
-
cleanFieldServerError() { this._fieldServerError = []; }
|
|
3233
|
-
cleanTableServerError() { this._tableServerError = []; }
|
|
3234
|
-
onActionServerError(callback, properties = null) { this._actionServerError.push({ callback, properties }); }
|
|
3235
|
-
onValidationServerError(callback, properties = null) { this._fieldServerError.push({ callback, properties }); }
|
|
3236
|
-
onTableServerError(callback, properties = null) { this._tableServerError.push({ callback, properties }); }
|
|
3237
|
-
/**
|
|
3238
|
-
* Manejo de event handlers para acciones sobre el formulario
|
|
3239
|
-
*/
|
|
3240
|
-
onFormChange(callback) {
|
|
3241
|
-
this._formChangeState.push(callback);
|
|
3242
|
-
}
|
|
3243
|
-
onSectionCanDeactivate(codes, callback, properties = null) {
|
|
3244
|
-
const sectionSet = (Array.isArray(codes)) ? codes : (codes ? [codes] : []);
|
|
3245
|
-
sectionSet.forEach((sectionName) => {
|
|
3246
|
-
if (!this._formSectionsCanDeactivate[sectionName]) {
|
|
3247
|
-
this._formSectionsCanDeactivate[sectionName] = [];
|
|
3248
|
-
}
|
|
3249
|
-
this._formSectionsCanDeactivate[sectionName].push({ callback, properties });
|
|
3250
|
-
});
|
|
3251
|
-
}
|
|
3252
|
-
onSectionActivation(codes, callback, properties = null) {
|
|
3253
|
-
const sectionSet = (Array.isArray(codes)) ? codes : (codes ? [codes] : []);
|
|
3254
|
-
sectionSet.forEach((sectionName) => {
|
|
3255
|
-
if (!this._formSectionsActivate[sectionName]) {
|
|
3256
|
-
this._formSectionsActivate[sectionName] = [];
|
|
3257
|
-
}
|
|
3258
|
-
this._formSectionsActivate[sectionName].push({ callback, properties });
|
|
3259
|
-
});
|
|
3260
|
-
}
|
|
3261
|
-
onSectionInactivation(codes, callback, properties = null) {
|
|
3262
|
-
const sectionSet = (Array.isArray(codes)) ? codes : (codes ? [codes] : []);
|
|
3263
|
-
sectionSet.forEach((sectionName) => {
|
|
3264
|
-
if (!this._formSectionsInactivate[sectionName]) {
|
|
3265
|
-
this._formSectionsInactivate[sectionName] = [];
|
|
3266
|
-
}
|
|
3267
|
-
this._formSectionsInactivate[sectionName].push({ callback, properties });
|
|
3268
|
-
});
|
|
3269
|
-
}
|
|
3270
|
-
onActionStart(codes, callback, properties = null) {
|
|
3271
|
-
const actionSet = (Array.isArray(codes)) ? codes : (codes ? [codes] : []);
|
|
3272
|
-
actionSet.forEach((actionName) => {
|
|
3273
|
-
if (!this._formActionsStart[actionName]) {
|
|
3274
|
-
this._formActionsStart[actionName] = [];
|
|
3275
|
-
}
|
|
3276
|
-
this._formActionsStart[actionName].push({ callback, properties });
|
|
3277
|
-
});
|
|
3278
|
-
}
|
|
3279
|
-
onActionFinish(codes, callback, properties = null) {
|
|
3280
|
-
const actionSet = (Array.isArray(codes)) ? codes : (codes ? [codes] : []);
|
|
3281
|
-
actionSet.forEach((actionName) => {
|
|
3282
|
-
if (!this._formActionsFinish[actionName]) {
|
|
3283
|
-
this._formActionsFinish[actionName] = [];
|
|
3284
|
-
}
|
|
3285
|
-
this._formActionsFinish[actionName].push({ callback, properties });
|
|
3286
|
-
});
|
|
3287
|
-
}
|
|
3288
|
-
verifySectionActivation(code) {
|
|
3289
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
3290
|
-
const sectionObject = this.getSection(code);
|
|
3291
|
-
if (!sectionObject) {
|
|
3292
|
-
return false;
|
|
3293
|
-
}
|
|
3294
|
-
const clientSectionMethods = this._formSectionsCanDeactivate[code];
|
|
3295
|
-
if (clientSectionMethods) {
|
|
3296
|
-
for (const clientSectionMethod of clientSectionMethods) {
|
|
3297
|
-
const { callback, properties } = clientSectionMethod;
|
|
3298
|
-
const canActivate = callback(sectionObject);
|
|
3299
|
-
if (canActivate === false) {
|
|
3300
|
-
return false;
|
|
3301
|
-
}
|
|
3302
|
-
}
|
|
3303
|
-
}
|
|
3304
|
-
return true;
|
|
3305
|
-
});
|
|
3306
|
-
}
|
|
3307
|
-
launchSectionActivation(code) {
|
|
3308
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
3309
|
-
this.notifyFormActivity();
|
|
3310
|
-
const sectionObject = this.getSection(code);
|
|
3311
|
-
if (!sectionObject) {
|
|
3312
|
-
return;
|
|
3313
|
-
}
|
|
3314
|
-
const clientSectionMethods = this._formSectionsActivate[code];
|
|
3315
|
-
if (clientSectionMethods) {
|
|
3316
|
-
for (const clientSectionMethod of clientSectionMethods) {
|
|
3317
|
-
const { callback, properties } = clientSectionMethod;
|
|
3318
|
-
callback(sectionObject);
|
|
3319
|
-
}
|
|
3320
|
-
}
|
|
3321
|
-
});
|
|
3322
|
-
}
|
|
3323
|
-
launchSectionInactivation(code) {
|
|
3324
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
3325
|
-
this.notifyFormActivity();
|
|
3326
|
-
const sectionObject = this.getSection(code);
|
|
3327
|
-
if (!sectionObject) {
|
|
3328
|
-
return;
|
|
3329
|
-
}
|
|
3330
|
-
const clientSectionMethods = this._formSectionsInactivate[code];
|
|
3331
|
-
if (clientSectionMethods) {
|
|
3332
|
-
for (const clientSectionMethod of clientSectionMethods) {
|
|
3333
|
-
const { callback, properties } = clientSectionMethod;
|
|
3334
|
-
callback(sectionObject);
|
|
3335
|
-
}
|
|
3336
|
-
}
|
|
3337
|
-
});
|
|
3338
|
-
}
|
|
3339
|
-
startAction(code) {
|
|
3340
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
3341
|
-
this.notifyFormActivity();
|
|
3342
|
-
const actionObject = this.getAction(code);
|
|
3343
|
-
if (!actionObject) {
|
|
3344
|
-
return;
|
|
3345
|
-
}
|
|
3346
|
-
this.resetError();
|
|
3347
|
-
actionObject.start();
|
|
3348
|
-
const clientActionMethods = this._formActionsStart[code];
|
|
3349
|
-
if (clientActionMethods) {
|
|
3350
|
-
const clientActionPromises = [];
|
|
3351
|
-
for (const clientActionMethod of clientActionMethods) {
|
|
3352
|
-
const { callback, properties } = clientActionMethod;
|
|
3353
|
-
const continueActionPromise = callback(actionObject);
|
|
3354
|
-
clientActionPromises.push(continueActionPromise);
|
|
3355
|
-
}
|
|
3356
|
-
const clientActionResults = yield Promise.all(clientActionPromises);
|
|
3357
|
-
const continueAction = clientActionResults.reduce((total, curr) => (total && (curr !== false)), true);
|
|
3358
|
-
if (!continueAction) {
|
|
3359
|
-
actionObject.stop();
|
|
3360
|
-
return;
|
|
3361
|
-
}
|
|
3362
|
-
}
|
|
3363
|
-
this.startServerAction(actionObject);
|
|
3364
|
-
});
|
|
3365
|
-
}
|
|
3366
|
-
startServerAction(actionInput) {
|
|
3367
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
3368
|
-
const action = (typeof actionInput === 'string')
|
|
3369
|
-
? this.getAction(actionInput) : actionInput;
|
|
3370
|
-
if (!action) {
|
|
3371
|
-
return;
|
|
3372
|
-
}
|
|
3373
|
-
let serverError = false;
|
|
3374
|
-
let actionResult = null;
|
|
3375
|
-
if (action.backend) {
|
|
3376
|
-
actionResult = yield this.requestFormAction(action.actionCode);
|
|
3377
|
-
}
|
|
3378
|
-
yield this.finishAction(action, actionResult, serverError);
|
|
3379
|
-
serverError = !!this.errorOccured();
|
|
3380
|
-
if (!serverError) {
|
|
3381
|
-
action.newState && this.changeState(action.newState);
|
|
3382
|
-
}
|
|
3383
|
-
else {
|
|
3384
|
-
for (let index = 0; index < this._actionServerError.length; index++) {
|
|
3385
|
-
const { callback, properties } = this._actionServerError[index];
|
|
3386
|
-
callback(action);
|
|
3387
|
-
}
|
|
3388
|
-
}
|
|
3389
|
-
action.stop();
|
|
3390
|
-
});
|
|
3391
|
-
}
|
|
3392
|
-
finishAction(action, actionResult, serverError = false) {
|
|
3393
|
-
var _a;
|
|
3394
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
3395
|
-
const finishActionMethods = this._formActionsFinish[action.actionCode];
|
|
3396
|
-
if (finishActionMethods) {
|
|
3397
|
-
const clientActionPromises = [];
|
|
3398
|
-
for (const clientActionMethod of finishActionMethods) {
|
|
3399
|
-
const { callback, properties } = clientActionMethod;
|
|
3400
|
-
const continueOnError = (_a = properties === null || properties === void 0 ? void 0 : properties.continueOnError) !== null && _a !== void 0 ? _a : false;
|
|
3401
|
-
if (callback && (!serverError || continueOnError)) {
|
|
3402
|
-
clientActionPromises.push(callback(action, actionResult));
|
|
3403
|
-
}
|
|
3404
|
-
}
|
|
3405
|
-
yield Promise.all(clientActionPromises);
|
|
3406
|
-
}
|
|
3407
|
-
});
|
|
3408
|
-
}
|
|
3409
|
-
completeGlobalAction(action) {
|
|
3410
|
-
return this.startServerAction(action);
|
|
3411
|
-
}
|
|
3412
|
-
/**
|
|
3413
|
-
* Manejadores de eventos para validaciones sobre campos
|
|
3414
|
-
*/
|
|
3415
|
-
onFieldInput(codes, callback, properties = null) {
|
|
3416
|
-
const fieldSet = (Array.isArray(codes)) ? codes : (codes ? [codes] : []);
|
|
3417
|
-
fieldSet.forEach((code) => {
|
|
3418
|
-
if (!this._fieldInputValidation[code]) {
|
|
3419
|
-
this._fieldInputValidation[code] = [];
|
|
3420
|
-
}
|
|
3421
|
-
this._fieldInputValidation[code].push({ callback, properties });
|
|
3422
|
-
});
|
|
3423
|
-
}
|
|
3424
|
-
onFieldValidationStart(codes, callback, properties = null) {
|
|
3425
|
-
const fieldSet = (Array.isArray(codes)) ? codes : (codes ? [codes] : []);
|
|
3426
|
-
fieldSet.forEach((code) => {
|
|
3427
|
-
if (!this._fieldValidationsStart[code]) {
|
|
3428
|
-
this._fieldValidationsStart[code] = [];
|
|
3429
|
-
}
|
|
3430
|
-
this._fieldValidationsStart[code].push({ callback, properties });
|
|
3431
|
-
});
|
|
3432
|
-
}
|
|
3433
|
-
onFieldValidationFinish(codes, callback, properties = null) {
|
|
3434
|
-
const fieldSet = (Array.isArray(codes)) ? codes : (codes ? [codes] : []);
|
|
3435
|
-
fieldSet.forEach((code) => {
|
|
3436
|
-
if (!this._fieldValidationsFinish[code]) {
|
|
3437
|
-
this._fieldValidationsFinish[code] = [];
|
|
3438
|
-
}
|
|
3439
|
-
this._fieldValidationsFinish[code].push({ callback, properties });
|
|
3440
|
-
});
|
|
3441
|
-
}
|
|
3442
|
-
startFieldInputValidation(code, intrinsicValidation = true) {
|
|
3443
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
3444
|
-
this.notifyFormActivity();
|
|
3445
|
-
const fieldToValidate = this.getField(code);
|
|
3446
|
-
if (!fieldToValidate) {
|
|
3447
|
-
return false;
|
|
3448
|
-
}
|
|
3449
|
-
const validationCallbacks = this._fieldInputValidation[code];
|
|
3450
|
-
if (validationCallbacks) {
|
|
3451
|
-
const clientValidationPromises = [];
|
|
3452
|
-
for (const validationMethod of validationCallbacks) {
|
|
3453
|
-
const { callback, properties } = validationMethod;
|
|
3454
|
-
const continueValidationPromise = callback(fieldToValidate);
|
|
3455
|
-
clientValidationPromises.push(continueValidationPromise);
|
|
3456
|
-
}
|
|
3457
|
-
yield Promise.all(clientValidationPromises);
|
|
3458
|
-
}
|
|
3459
|
-
return true;
|
|
3460
|
-
});
|
|
3461
|
-
}
|
|
3462
|
-
startFieldValidation(code, intrinsicValidation = true) {
|
|
3463
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
3464
|
-
this.notifyFormActivity();
|
|
3465
|
-
const fieldToValidate = this.getField(code);
|
|
3466
|
-
if (!fieldToValidate) {
|
|
3467
|
-
return;
|
|
3468
|
-
}
|
|
3469
|
-
const validationCallbacks = this._fieldValidationsStart[code];
|
|
3470
|
-
if (validationCallbacks) {
|
|
3471
|
-
const clientValidationPromises = [];
|
|
3472
|
-
for (const validationMethod of validationCallbacks) {
|
|
3473
|
-
const { callback, properties } = validationMethod;
|
|
3474
|
-
const clientValidationPromise = callback(fieldToValidate);
|
|
3475
|
-
clientValidationPromises.push(clientValidationPromise);
|
|
3476
|
-
}
|
|
3477
|
-
const clientValidationResults = yield Promise.all(clientValidationPromises);
|
|
3478
|
-
const continueValidation = clientValidationResults.reduce((total, curr) => (total && (curr !== false)), true);
|
|
3479
|
-
if (!continueValidation) {
|
|
3480
|
-
return;
|
|
3481
|
-
}
|
|
3482
|
-
}
|
|
3483
|
-
if (intrinsicValidation) {
|
|
3484
|
-
this.startServerFieldValidation(fieldToValidate);
|
|
3485
|
-
}
|
|
3486
|
-
});
|
|
3487
|
-
}
|
|
3488
|
-
startServerFieldValidation(inputField) {
|
|
3489
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
3490
|
-
const fieldObj = (typeof inputField === 'string')
|
|
3491
|
-
? this.getField(inputField) : inputField;
|
|
3492
|
-
let serverError = false;
|
|
3493
|
-
let validationResult = true;
|
|
3494
|
-
if (!fieldObj) {
|
|
3495
|
-
return;
|
|
3496
|
-
}
|
|
3497
|
-
if (fieldObj.backend) {
|
|
3498
|
-
fieldObj.validating = true;
|
|
3499
|
-
validationResult = yield this
|
|
3500
|
-
.requestFormAction(formActions.validate, fieldObj.code);
|
|
3501
|
-
serverError = !!this.errorOccured();
|
|
3502
|
-
}
|
|
3503
|
-
if (serverError) {
|
|
3504
|
-
fieldObj === null || fieldObj === void 0 ? void 0 : fieldObj.setErrorCode(this.errorCode);
|
|
3505
|
-
fieldObj === null || fieldObj === void 0 ? void 0 : fieldObj.setErrorMessage(this.errorMessage);
|
|
3506
|
-
for (let index = 0; index < this._fieldServerError.length; index++) {
|
|
3507
|
-
const { callback, properties } = this._fieldServerError[index];
|
|
3508
|
-
callback(fieldObj);
|
|
3509
|
-
}
|
|
3510
|
-
}
|
|
3511
|
-
yield this.finishFieldValidation(fieldObj, validationResult, serverError);
|
|
3512
|
-
fieldObj.validating = false;
|
|
3513
|
-
});
|
|
3514
|
-
}
|
|
3515
|
-
finishFieldValidation(fieldObject, validationResult, serverError = false) {
|
|
3516
|
-
var _a;
|
|
3517
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
3518
|
-
const validationCallbacks = this._fieldValidationsFinish[fieldObject.code];
|
|
3519
|
-
if (validationCallbacks) {
|
|
3520
|
-
const clientActionPromises = [];
|
|
3521
|
-
for (const validationMethod of validationCallbacks) {
|
|
3522
|
-
const { callback, properties } = validationMethod;
|
|
3523
|
-
const continueOnError = (_a = properties === null || properties === void 0 ? void 0 : properties.continueOnError) !== null && _a !== void 0 ? _a : false;
|
|
3524
|
-
if (!serverError || continueOnError) {
|
|
3525
|
-
clientActionPromises.push(callback(fieldObject, validationResult));
|
|
3526
|
-
}
|
|
3527
|
-
}
|
|
3528
|
-
yield Promise.all(clientActionPromises);
|
|
3529
|
-
}
|
|
3530
|
-
});
|
|
3531
|
-
}
|
|
3532
|
-
continueFieldValidation(code) {
|
|
3533
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
3534
|
-
return this.startServerFieldValidation(code);
|
|
3535
|
-
});
|
|
3536
|
-
}
|
|
3537
|
-
/**
|
|
3538
|
-
* Manejadores de eventos para acciones sobre Tablas
|
|
3539
|
-
*/
|
|
3540
|
-
onTableActionStart(code, actionCode, callback, properties = null) {
|
|
3541
|
-
const tableObject = this.getTable(code);
|
|
3542
|
-
if (!tableObject) {
|
|
3543
|
-
return;
|
|
3544
|
-
}
|
|
3545
|
-
const inlineActionObject = tableObject.getAction(actionCode);
|
|
3546
|
-
if (!inlineActionObject) {
|
|
3547
|
-
return;
|
|
3548
|
-
}
|
|
3549
|
-
let tableEventHandlers;
|
|
3550
|
-
if (this._tableActionsStart[code]) {
|
|
3551
|
-
tableEventHandlers = this._tableActionsStart[code];
|
|
3552
|
-
}
|
|
3553
|
-
else {
|
|
3554
|
-
tableEventHandlers = {};
|
|
3555
|
-
this._tableActionsStart[code] = tableEventHandlers;
|
|
3556
|
-
}
|
|
3557
|
-
if (!tableEventHandlers[actionCode]) {
|
|
3558
|
-
tableEventHandlers[actionCode] = [];
|
|
3559
|
-
}
|
|
3560
|
-
tableEventHandlers[actionCode].push({ callback, properties });
|
|
3561
|
-
}
|
|
3562
|
-
onTableActionFinish(code, actionCode, callback, properties = null) {
|
|
3563
|
-
const tableObject = this.getTable(code);
|
|
3564
|
-
if (!tableObject) {
|
|
3565
|
-
return;
|
|
3566
|
-
}
|
|
3567
|
-
const inlineActionObject = tableObject.getAction(actionCode);
|
|
3568
|
-
if (!inlineActionObject) {
|
|
3569
|
-
return;
|
|
3570
|
-
}
|
|
3571
|
-
let tableEventHandlers;
|
|
3572
|
-
if (this._tableActionsFinish[code]) {
|
|
3573
|
-
tableEventHandlers = this._tableActionsFinish[code];
|
|
3574
|
-
}
|
|
3575
|
-
else {
|
|
3576
|
-
tableEventHandlers = {};
|
|
3577
|
-
this._tableActionsFinish[code] = tableEventHandlers;
|
|
3578
|
-
}
|
|
3579
|
-
if (!tableEventHandlers[actionCode]) {
|
|
3580
|
-
tableEventHandlers[actionCode] = [];
|
|
3581
|
-
}
|
|
3582
|
-
tableEventHandlers[actionCode].push({ callback, properties });
|
|
3583
|
-
}
|
|
3584
|
-
onTableSelectionStart(code, callback, properties = null) {
|
|
3585
|
-
const tableObject = this.getTable(code);
|
|
3586
|
-
if (!tableObject) {
|
|
3587
|
-
return;
|
|
3588
|
-
}
|
|
3589
|
-
let tableEventHandlers;
|
|
3590
|
-
if (this._tableSelectionsStart[code]) {
|
|
3591
|
-
tableEventHandlers = this._tableSelectionsStart[code];
|
|
3592
|
-
}
|
|
3593
|
-
else {
|
|
3594
|
-
tableEventHandlers = [];
|
|
3595
|
-
this._tableSelectionsStart[code] = tableEventHandlers;
|
|
3596
|
-
}
|
|
3597
|
-
tableEventHandlers.push({ callback, properties });
|
|
3598
|
-
}
|
|
3599
|
-
onTableSelectionFinish(code, callback, properties = null) {
|
|
3600
|
-
const tableObject = this.getTable(code);
|
|
3601
|
-
if (!tableObject) {
|
|
3602
|
-
return;
|
|
3603
|
-
}
|
|
3604
|
-
let tableEventHandlers;
|
|
3605
|
-
if (this._tableSelectionsFinish[code]) {
|
|
3606
|
-
tableEventHandlers = this._tableSelectionsFinish[code];
|
|
3607
|
-
}
|
|
3608
|
-
else {
|
|
3609
|
-
tableEventHandlers = [];
|
|
3610
|
-
this._tableSelectionsFinish[code] = tableEventHandlers;
|
|
3611
|
-
}
|
|
3612
|
-
tableEventHandlers.push({ callback, properties });
|
|
3613
|
-
}
|
|
3614
|
-
onTableGetDataStart(code, callback, properties = null) {
|
|
3615
|
-
const tableObject = this.getTable(code);
|
|
3616
|
-
if (!tableObject) {
|
|
3617
|
-
return;
|
|
3618
|
-
}
|
|
3619
|
-
let tableEventHandlers;
|
|
3620
|
-
if (this._tableGetDataStart[code]) {
|
|
3621
|
-
tableEventHandlers = this._tableGetDataStart[code];
|
|
3622
|
-
}
|
|
3623
|
-
else {
|
|
3624
|
-
tableEventHandlers = [];
|
|
3625
|
-
this._tableGetDataStart[code] = tableEventHandlers;
|
|
3626
|
-
}
|
|
3627
|
-
tableEventHandlers.push({ callback, properties });
|
|
3628
|
-
}
|
|
3629
|
-
onTableGetDataFinish(code, callback, properties = null) {
|
|
3630
|
-
const tableObject = this.getTable(code);
|
|
3631
|
-
if (!tableObject) {
|
|
3632
|
-
return;
|
|
3633
|
-
}
|
|
3634
|
-
let tableEventHandlers;
|
|
3635
|
-
if (this._tableGetDataFinish[code]) {
|
|
3636
|
-
tableEventHandlers = this._tableGetDataFinish[code];
|
|
3637
|
-
}
|
|
3638
|
-
else {
|
|
3639
|
-
tableEventHandlers = {};
|
|
3640
|
-
this._tableGetDataFinish[code] = tableEventHandlers;
|
|
3641
|
-
}
|
|
3642
|
-
tableEventHandlers[GET_DATA_ACTION] = { callback, properties };
|
|
3643
|
-
}
|
|
3644
|
-
startTableGlobalAction(tableActionEvent) {
|
|
3645
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
3646
|
-
this.notifyFormActivity();
|
|
3647
|
-
const { tableCode, actionCode } = tableActionEvent;
|
|
3648
|
-
const tableObject = this.getTable(tableCode);
|
|
3649
|
-
if (!tableObject || !actionCode) {
|
|
3650
|
-
return;
|
|
3651
|
-
}
|
|
3652
|
-
this.resetError();
|
|
3653
|
-
const action = tableObject.getAction(actionCode);
|
|
3654
|
-
if (!action) {
|
|
3655
|
-
return;
|
|
3656
|
-
}
|
|
3657
|
-
const tableActionDetail = {
|
|
3658
|
-
tableObject,
|
|
3659
|
-
action,
|
|
3660
|
-
tableCode,
|
|
3661
|
-
actionCode,
|
|
3662
|
-
};
|
|
3663
|
-
const tableEventHandlers = this._tableActionsStart[tableCode];
|
|
3664
|
-
const tableActionMethods = (tableEventHandlers) ? tableEventHandlers[actionCode] : null;
|
|
3665
|
-
if (tableActionMethods) {
|
|
3666
|
-
const clientActionPromises = [];
|
|
3667
|
-
for (const tableActionMethod of tableActionMethods) {
|
|
3668
|
-
const { callback, properties } = tableActionMethod;
|
|
3669
|
-
const clientActionPromise = callback(tableActionDetail);
|
|
3670
|
-
clientActionPromises.push(clientActionPromise);
|
|
3671
|
-
}
|
|
3672
|
-
const clientActionResults = yield Promise.all(clientActionPromises);
|
|
3673
|
-
const continueAction = clientActionResults.reduce((total, curr) => (total && (curr !== false)), true);
|
|
3674
|
-
if (!continueAction) {
|
|
3675
|
-
return;
|
|
3676
|
-
}
|
|
3677
|
-
}
|
|
3678
|
-
this.startTableServerGlobalAction(tableActionDetail);
|
|
3679
|
-
});
|
|
3680
|
-
}
|
|
3681
|
-
startTableServerGlobalAction(tableActionDetail) {
|
|
3682
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
3683
|
-
const { tableObject, action, tableCode, actionCode } = tableActionDetail;
|
|
3684
|
-
if (!tableObject || !action) {
|
|
3685
|
-
return;
|
|
3686
|
-
}
|
|
3687
|
-
tableObject.putOnWait();
|
|
3688
|
-
let serverError = false;
|
|
3689
|
-
let actionResult = null;
|
|
3690
|
-
if (action.backend) {
|
|
3691
|
-
const actionSubject = {
|
|
3692
|
-
tableCode,
|
|
3693
|
-
actionType: GLOBAL_ACTION,
|
|
3694
|
-
actionCode
|
|
3695
|
-
};
|
|
3696
|
-
actionResult = yield this
|
|
3697
|
-
.requestFormAction(formActions.tableAction, actionSubject);
|
|
3698
|
-
serverError = !!this.errorOccured();
|
|
3699
|
-
}
|
|
3700
|
-
yield this.finishTableGlobalAction(tableActionDetail, actionResult, serverError);
|
|
3701
|
-
if (!serverError) {
|
|
3702
|
-
action.newState && this.changeState(action.newState);
|
|
3703
|
-
}
|
|
3704
|
-
else {
|
|
3705
|
-
for (let index = 0; index < this._tableServerError.length; index++) {
|
|
3706
|
-
const { callback, properties } = this._tableServerError[index];
|
|
3707
|
-
callback(tableObject);
|
|
3708
|
-
}
|
|
3709
|
-
}
|
|
3710
|
-
tableObject.freeWaiting();
|
|
3711
|
-
});
|
|
3712
|
-
}
|
|
3713
|
-
finishTableGlobalAction(tableActionDetail, actionResult, serverError = false) {
|
|
3714
|
-
var _a;
|
|
3715
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
3716
|
-
const { tableCode, actionCode } = tableActionDetail;
|
|
3717
|
-
const tableEventHandlers = this._tableActionsFinish[tableCode];
|
|
3718
|
-
const tableActionMethods = (tableEventHandlers) ? tableEventHandlers[actionCode] : null;
|
|
3719
|
-
if (tableActionMethods) {
|
|
3720
|
-
const clientActionPromises = [];
|
|
3721
|
-
for (const tableActionMethod of tableActionMethods) {
|
|
3722
|
-
const { callback, properties } = tableActionMethod;
|
|
3723
|
-
const continueOnError = (_a = properties === null || properties === void 0 ? void 0 : properties.continueOnError) !== null && _a !== void 0 ? _a : false;
|
|
3724
|
-
if (!serverError || continueOnError) {
|
|
3725
|
-
clientActionPromises.push(callback(tableActionDetail, actionResult));
|
|
3726
|
-
}
|
|
3727
|
-
}
|
|
3728
|
-
yield Promise.all(clientActionPromises);
|
|
3729
|
-
}
|
|
3730
|
-
});
|
|
3731
|
-
}
|
|
3732
|
-
startTableAction(tableActionEvent) {
|
|
3733
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
3734
|
-
this.notifyFormActivity();
|
|
3735
|
-
const { tableCode, actionCode, actionDetail } = tableActionEvent;
|
|
3736
|
-
const tableObject = this.getTable(tableCode);
|
|
3737
|
-
if (!tableObject || !actionCode) {
|
|
3738
|
-
return;
|
|
3739
|
-
}
|
|
3740
|
-
this.resetError();
|
|
3741
|
-
const { recordId, recordData } = actionDetail;
|
|
3742
|
-
const action = tableObject.getAction(actionCode);
|
|
3743
|
-
if (!action) {
|
|
3744
|
-
return;
|
|
3745
|
-
}
|
|
3746
|
-
const tableActionDetail = {
|
|
3747
|
-
tableObject,
|
|
3748
|
-
action,
|
|
3749
|
-
tableCode,
|
|
3750
|
-
actionCode,
|
|
3751
|
-
recordId,
|
|
3752
|
-
recordData
|
|
3753
|
-
};
|
|
3754
|
-
const tableEventHandlers = this._tableActionsStart[tableCode];
|
|
3755
|
-
const tableActionMethods = (tableEventHandlers) ? tableEventHandlers[actionCode] : null;
|
|
3756
|
-
if (tableActionMethods) {
|
|
3757
|
-
const clientActionPromises = [];
|
|
3758
|
-
for (const tableActionMethod of tableActionMethods) {
|
|
3759
|
-
const { callback, properties } = tableActionMethod;
|
|
3760
|
-
const clientActionPromise = callback(tableActionDetail);
|
|
3761
|
-
clientActionPromises.push(clientActionPromise);
|
|
3762
|
-
}
|
|
3763
|
-
const clientActionResults = yield Promise.all(clientActionPromises);
|
|
3764
|
-
const continueAction = clientActionResults.reduce((total, curr) => (total && (curr !== false)), true);
|
|
3765
|
-
if (!continueAction) {
|
|
3766
|
-
return;
|
|
3767
|
-
}
|
|
3768
|
-
}
|
|
3769
|
-
this.startTableServerAction(tableActionDetail);
|
|
3770
|
-
});
|
|
3771
|
-
}
|
|
3772
|
-
startTableServerAction(tableActionDetail) {
|
|
3773
|
-
var _a;
|
|
3774
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
3775
|
-
const { tableObject, action, tableCode, actionCode, recordId, recordData } = tableActionDetail;
|
|
3776
|
-
if (!tableObject || !action) {
|
|
3777
|
-
return;
|
|
3778
|
-
}
|
|
3779
|
-
tableObject.putOnWait();
|
|
3780
|
-
let serverError = false;
|
|
3781
|
-
let actionResult = null;
|
|
3782
|
-
if (action.backend) {
|
|
3783
|
-
const actionSubject = {
|
|
3784
|
-
tableCode,
|
|
3785
|
-
actionType: (_a = this.formConfig) === null || _a === void 0 ? void 0 : _a.tableActions.inline,
|
|
3786
|
-
actionCode,
|
|
3787
|
-
tableRecordId: recordId,
|
|
3788
|
-
tableRecordData: recordData
|
|
3789
|
-
};
|
|
3790
|
-
actionResult = yield this
|
|
3791
|
-
.requestFormAction(formActions.tableAction, actionSubject);
|
|
3792
|
-
serverError = !!this.errorOccured();
|
|
3793
|
-
}
|
|
3794
|
-
yield this.finishTableAction(tableActionDetail, actionResult, serverError);
|
|
3795
|
-
if (!serverError) {
|
|
3796
|
-
action.newState && this.changeState(action.newState);
|
|
3797
|
-
}
|
|
3798
|
-
else {
|
|
3799
|
-
this.displayTableServerError();
|
|
3800
|
-
}
|
|
3801
|
-
tableObject.freeWaiting();
|
|
3802
|
-
});
|
|
3803
|
-
}
|
|
3804
|
-
completeInlineAction(tableAction) {
|
|
3805
|
-
return this.startTableServerAction(tableAction);
|
|
3806
|
-
}
|
|
3807
|
-
finishTableAction(tableActionDetail, actionResult, serverError = false) {
|
|
3808
|
-
var _a;
|
|
3809
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
3810
|
-
const { tableCode, actionCode } = tableActionDetail;
|
|
3811
|
-
const tableEventHandlers = this._tableActionsFinish[tableCode];
|
|
3812
|
-
const tableActionMethods = (tableEventHandlers) ? tableEventHandlers[actionCode] : null;
|
|
3813
|
-
if (tableActionMethods) {
|
|
3814
|
-
const clientActionPromises = [];
|
|
3815
|
-
for (const tableActionMethod of tableActionMethods) {
|
|
3816
|
-
const { callback, properties } = tableActionMethod;
|
|
3817
|
-
const continueOnError = (_a = properties === null || properties === void 0 ? void 0 : properties.continueOnError) !== null && _a !== void 0 ? _a : false;
|
|
3818
|
-
if (!serverError || continueOnError) {
|
|
3819
|
-
clientActionPromises.push(callback(tableActionDetail, actionResult));
|
|
3820
|
-
}
|
|
3821
|
-
}
|
|
3822
|
-
yield Promise.all(clientActionPromises);
|
|
3823
|
-
}
|
|
3824
|
-
});
|
|
3825
|
-
}
|
|
3826
|
-
startTableRecordSelection(tableActionEvent) {
|
|
3827
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
3828
|
-
this.notifyFormActivity();
|
|
3829
|
-
const { tableCode, actionDetail } = tableActionEvent;
|
|
3830
|
-
const tableObject = this.getTable(tableCode);
|
|
3831
|
-
if (!tableObject) {
|
|
3832
|
-
return;
|
|
3833
|
-
}
|
|
3834
|
-
this.resetError();
|
|
3835
|
-
const { recordId, recordData } = actionDetail;
|
|
3836
|
-
const tableSelectionDetail = {
|
|
3837
|
-
tableObject,
|
|
3838
|
-
tableCode,
|
|
3839
|
-
recordId,
|
|
3840
|
-
recordData
|
|
3841
|
-
};
|
|
3842
|
-
const tableEventHandlers = this._tableSelectionsStart[tableCode];
|
|
3843
|
-
if (tableEventHandlers) {
|
|
3844
|
-
const clientActionPromises = [];
|
|
3845
|
-
for (const tableSelectionMethod of tableEventHandlers) {
|
|
3846
|
-
const { callback, properties } = tableSelectionMethod;
|
|
3847
|
-
const clientActionPromise = callback(tableSelectionDetail);
|
|
3848
|
-
clientActionPromises.push(clientActionPromise);
|
|
3849
|
-
}
|
|
3850
|
-
const clientActionResults = yield Promise.all(clientActionPromises);
|
|
3851
|
-
const continueAction = clientActionResults.reduce((total, curr) => (total && (curr !== false)), true);
|
|
3852
|
-
if (!continueAction) {
|
|
3853
|
-
return;
|
|
3854
|
-
}
|
|
3855
|
-
}
|
|
3856
|
-
this.startTableServerRecordSelection(tableSelectionDetail);
|
|
3857
|
-
});
|
|
3858
|
-
}
|
|
3859
|
-
startTableServerRecordSelection(tableSelectionDetail) {
|
|
3860
|
-
var _a;
|
|
3861
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
3862
|
-
const { tableObject, tableCode, recordId, recordData } = tableSelectionDetail;
|
|
3863
|
-
if (!tableObject) {
|
|
3864
|
-
return;
|
|
3865
|
-
}
|
|
3866
|
-
tableObject.putOnWait();
|
|
3867
|
-
let serverError = false;
|
|
3868
|
-
let actionResult = null;
|
|
3869
|
-
if (tableObject.selectionBackend) {
|
|
3870
|
-
const actionSubject = {
|
|
3871
|
-
tableCode,
|
|
3872
|
-
actionType: (_a = this.formConfig) === null || _a === void 0 ? void 0 : _a.tableActions.rowSelection,
|
|
3873
|
-
actionCode: null,
|
|
3874
|
-
tableRecordId: recordId,
|
|
3875
|
-
tableRecordData: recordData
|
|
3876
|
-
};
|
|
3877
|
-
actionResult = yield this
|
|
3878
|
-
.requestFormAction(formActions.tableAction, actionSubject);
|
|
3879
|
-
serverError = !!this.errorOccured();
|
|
3880
|
-
}
|
|
3881
|
-
yield this.finishTableRecordSelection(tableSelectionDetail, actionResult, serverError);
|
|
3882
|
-
if (serverError) {
|
|
3883
|
-
this.displayTableServerError();
|
|
3884
|
-
}
|
|
3885
|
-
tableObject.freeWaiting();
|
|
3886
|
-
});
|
|
3887
|
-
}
|
|
3888
|
-
finishTableRecordSelection(tableSelectionDetail, actionResult, serverError = false) {
|
|
3889
|
-
var _a;
|
|
3890
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
3891
|
-
const { tableCode } = tableSelectionDetail;
|
|
3892
|
-
const tableEventHandlers = this._tableSelectionsFinish[tableCode];
|
|
3893
|
-
if (tableEventHandlers) {
|
|
3894
|
-
const clientActionPromises = [];
|
|
3895
|
-
for (const tableSelectionMethod of tableEventHandlers) {
|
|
3896
|
-
const { callback, properties } = tableSelectionMethod;
|
|
3897
|
-
const continueOnError = (_a = properties === null || properties === void 0 ? void 0 : properties.continueOnError) !== null && _a !== void 0 ? _a : false;
|
|
3898
|
-
if (!serverError || continueOnError) {
|
|
3899
|
-
clientActionPromises.push(callback(tableSelectionDetail, actionResult));
|
|
3900
|
-
}
|
|
3901
|
-
}
|
|
3902
|
-
yield Promise.all(clientActionPromises);
|
|
3903
|
-
}
|
|
3904
|
-
});
|
|
3905
|
-
}
|
|
3906
|
-
startTableSelectionAction(tableActionEvent) {
|
|
3907
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
3908
|
-
this.notifyFormActivity();
|
|
3909
|
-
const { tableCode, actionCode, actionDetail } = tableActionEvent;
|
|
3910
|
-
const tableObject = this.getTable(tableCode);
|
|
3911
|
-
if (!tableObject || !actionCode) {
|
|
3912
|
-
return;
|
|
3913
|
-
}
|
|
3914
|
-
this.resetError();
|
|
3915
|
-
const { selectedRecords } = actionDetail;
|
|
3916
|
-
const action = tableObject.getAction(actionCode);
|
|
3917
|
-
if (!action) {
|
|
3918
|
-
return;
|
|
3919
|
-
}
|
|
3920
|
-
const tableActionDetail = {
|
|
3921
|
-
tableObject,
|
|
3922
|
-
action,
|
|
3923
|
-
tableCode,
|
|
3924
|
-
actionCode,
|
|
3925
|
-
selectedRecords
|
|
3926
|
-
};
|
|
3927
|
-
const tableEventHandlers = this._tableActionsStart[tableCode];
|
|
3928
|
-
const tableActionMethods = (tableEventHandlers) ? tableEventHandlers[actionCode] : null;
|
|
3929
|
-
if (tableActionMethods) {
|
|
3930
|
-
const clientActionPromises = [];
|
|
3931
|
-
for (const tableActionMethod of tableActionMethods) {
|
|
3932
|
-
const { callback, properties } = tableActionMethod;
|
|
3933
|
-
const clientActionPromise = callback(tableActionDetail);
|
|
3934
|
-
clientActionPromises.push(clientActionPromise);
|
|
3935
|
-
}
|
|
3936
|
-
const clientActionResults = yield Promise.all(clientActionPromises);
|
|
3937
|
-
const continueAction = clientActionResults.reduce((total, curr) => (total && (curr !== false)), true);
|
|
3938
|
-
if (!continueAction) {
|
|
3939
|
-
return;
|
|
3940
|
-
}
|
|
3941
|
-
}
|
|
3942
|
-
this.startTableServerSelectionAction(tableActionDetail);
|
|
3943
|
-
});
|
|
3944
|
-
}
|
|
3945
|
-
startTableServerSelectionAction(tableActionDetail) {
|
|
3946
|
-
var _a;
|
|
3947
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
3948
|
-
const { tableObject, action, tableCode, actionCode, selectedRecords } = tableActionDetail;
|
|
3949
|
-
if (!tableObject || !action) {
|
|
3950
|
-
return;
|
|
3951
|
-
}
|
|
3952
|
-
tableObject.putOnWait();
|
|
3953
|
-
let serverError = false;
|
|
3954
|
-
let actionResult = null;
|
|
3955
|
-
if (action.backend) {
|
|
3956
|
-
const actionSubject = {
|
|
3957
|
-
tableCode,
|
|
3958
|
-
actionType: (_a = this.formConfig) === null || _a === void 0 ? void 0 : _a.tableActions.selection,
|
|
3959
|
-
actionCode,
|
|
3960
|
-
selectedRecords
|
|
3961
|
-
};
|
|
3962
|
-
actionResult = yield this
|
|
3963
|
-
.requestFormAction(formActions.tableAction, actionSubject);
|
|
3964
|
-
serverError = !!this.errorOccured();
|
|
3965
|
-
}
|
|
3966
|
-
yield this.finishTableSelectionAction(tableActionDetail, actionResult, serverError);
|
|
3967
|
-
if (!serverError) {
|
|
3968
|
-
action.newState && this.changeState(action.newState);
|
|
3969
|
-
}
|
|
3970
|
-
else {
|
|
3971
|
-
this.displayTableServerError();
|
|
3972
|
-
}
|
|
3973
|
-
tableObject.freeWaiting();
|
|
3974
|
-
});
|
|
3975
|
-
}
|
|
3976
|
-
finishTableSelectionAction(tableActionDetail, actionResult, serverError = false) {
|
|
3977
|
-
var _a;
|
|
3978
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
3979
|
-
const { tableCode, actionCode } = tableActionDetail;
|
|
3980
|
-
const tableEventHandlers = this._tableActionsFinish[tableCode];
|
|
3981
|
-
const tableActionMethods = (tableEventHandlers) ? tableEventHandlers[actionCode] : null;
|
|
3982
|
-
if (tableActionMethods) {
|
|
3983
|
-
const clientActionPromises = [];
|
|
3984
|
-
for (const tableActionMethod of tableActionMethods) {
|
|
3985
|
-
const { callback, properties } = tableActionMethod;
|
|
3986
|
-
const continueOnError = (_a = properties === null || properties === void 0 ? void 0 : properties.continueOnError) !== null && _a !== void 0 ? _a : false;
|
|
3987
|
-
if (!serverError || continueOnError) {
|
|
3988
|
-
clientActionPromises.push(callback(tableActionDetail, actionResult));
|
|
3989
|
-
}
|
|
3990
|
-
}
|
|
3991
|
-
yield Promise.all(clientActionPromises);
|
|
3992
|
-
}
|
|
3993
|
-
});
|
|
3994
|
-
}
|
|
3995
|
-
startTableGetData(tableActionEvent) {
|
|
3996
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
3997
|
-
this.notifyFormActivity();
|
|
3998
|
-
const { tableCode } = tableActionEvent;
|
|
3999
|
-
const tableObject = this.getTable(tableCode);
|
|
4000
|
-
const tableActionDetail = {
|
|
4001
|
-
tableObject,
|
|
4002
|
-
tableCode
|
|
4003
|
-
};
|
|
4004
|
-
this.resetError();
|
|
4005
|
-
const tableEventHandlers = this._tableGetDataStart[tableCode];
|
|
4006
|
-
if (tableEventHandlers) {
|
|
4007
|
-
const clientActionPromises = [];
|
|
4008
|
-
for (const tableActionMethod of tableEventHandlers) {
|
|
4009
|
-
const { callback, properties } = tableActionMethod;
|
|
4010
|
-
const clientActionPromise = callback(tableActionDetail);
|
|
4011
|
-
clientActionPromises.push(clientActionPromise);
|
|
4012
|
-
}
|
|
4013
|
-
const clientActionResults = yield Promise.all(clientActionPromises);
|
|
4014
|
-
const continueAction = clientActionResults.reduce((total, curr) => (total && (curr !== false)), true);
|
|
4015
|
-
if (!continueAction) {
|
|
4016
|
-
return;
|
|
4017
|
-
}
|
|
4018
|
-
}
|
|
4019
|
-
this.startTableServerGetData(tableActionDetail);
|
|
4020
|
-
});
|
|
4021
|
-
}
|
|
4022
|
-
startTableServerGetData(tableActionDetail) {
|
|
4023
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
4024
|
-
const { tableObject, tableCode } = tableActionDetail;
|
|
4025
|
-
tableObject.putOnWait();
|
|
4026
|
-
let serverError = false;
|
|
4027
|
-
const actionSubject = { tableCode };
|
|
4028
|
-
const actionResult = yield this
|
|
4029
|
-
.requestFormAction(formActions.getTableData, actionSubject);
|
|
4030
|
-
serverError = !!this.errorOccured();
|
|
4031
|
-
yield this.finishTableGetData(tableActionDetail, actionResult, serverError);
|
|
4032
|
-
if (serverError) {
|
|
4033
|
-
this.displayTableServerError();
|
|
4034
|
-
}
|
|
4035
|
-
tableObject.freeWaiting();
|
|
4036
|
-
});
|
|
4037
|
-
}
|
|
4038
|
-
finishTableGetData(tableActionDetail, actionResult, serverError = false) {
|
|
4039
|
-
var _a;
|
|
4040
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
4041
|
-
const { tableCode, tableActionCode } = tableActionDetail;
|
|
4042
|
-
const tableEventHandlers = this._tableActionsFinish[tableCode];
|
|
4043
|
-
const tableActionMethods = (tableEventHandlers) ? tableEventHandlers[tableActionCode] : null;
|
|
4044
|
-
if (tableActionMethods) {
|
|
4045
|
-
const clientActionPromises = [];
|
|
4046
|
-
for (const tableActionMethod of tableActionMethods) {
|
|
4047
|
-
const { callback, properties } = tableActionMethod;
|
|
4048
|
-
const continueOnError = (_a = properties === null || properties === void 0 ? void 0 : properties.continueOnError) !== null && _a !== void 0 ? _a : false;
|
|
4049
|
-
if (!serverError || continueOnError) {
|
|
4050
|
-
clientActionPromises.push(callback(tableActionDetail, actionResult));
|
|
4051
|
-
}
|
|
4052
|
-
}
|
|
4053
|
-
yield Promise.all(clientActionPromises);
|
|
4054
|
-
}
|
|
4055
|
-
});
|
|
4056
|
-
}
|
|
4057
|
-
checkSectionRequiredFields(sectionCode, reqFieldMessage) {
|
|
4058
|
-
var _a;
|
|
4059
|
-
this.cleanErrorFields(null, sectionCode);
|
|
4060
|
-
const requiredFieldMessage = reqFieldMessage !== null && reqFieldMessage !== void 0 ? reqFieldMessage : (_a = this.formConfig) === null || _a === void 0 ? void 0 : _a.formStandardErrors.requiredField;
|
|
4061
|
-
const numErrors = this.tagFieldsWithError(requiredFieldMessage, this.getRequiredEmptyFields(null, sectionCode));
|
|
4062
|
-
return (numErrors === 0);
|
|
4063
|
-
}
|
|
4064
|
-
validateSectionConsistency(sectionCode, reqFieldMessage) {
|
|
4065
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
4066
|
-
this.resetError();
|
|
4067
|
-
const completeFields = this.checkSectionRequiredFields(sectionCode, reqFieldMessage);
|
|
4068
|
-
if (!completeFields) {
|
|
4069
|
-
this.setError((_a = this.formConfig) === null || _a === void 0 ? void 0 : _a.formStandardErrors.typeWarning, (_b = this.formConfig) === null || _b === void 0 ? void 0 : _b.formStandardErrors.validationTitle, (_c = this.formConfig) === null || _c === void 0 ? void 0 : _c.formStandardErrors.requiredFields);
|
|
4070
|
-
return false;
|
|
4071
|
-
}
|
|
4072
|
-
let validationError = false;
|
|
4073
|
-
const requiredEmptyFields = (_d = this.getRequiredEmptyFields(null, sectionCode)) !== null && _d !== void 0 ? _d : [];
|
|
4074
|
-
if ((requiredEmptyFields === null || requiredEmptyFields === void 0 ? void 0 : requiredEmptyFields.length) > 0) {
|
|
4075
|
-
validationError = true;
|
|
4076
|
-
this.setError((_e = this.formConfig) === null || _e === void 0 ? void 0 : _e.formStandardErrors.typeWarning, (_f = this.formConfig) === null || _f === void 0 ? void 0 : _f.formStandardErrors.validationTitle, (_g = this.formConfig) === null || _g === void 0 ? void 0 : _g.formStandardErrors.requiredFields);
|
|
4077
|
-
this.tagFieldsWithError((_h = this.formConfig) === null || _h === void 0 ? void 0 : _h.formStandardErrors.requiredField, requiredEmptyFields);
|
|
4078
|
-
for (const code of requiredEmptyFields) {
|
|
4079
|
-
const requiredEmptyField = this.getField(code);
|
|
4080
|
-
requiredEmptyField === null || requiredEmptyField === void 0 ? void 0 : requiredEmptyField.focus();
|
|
4081
|
-
break;
|
|
4082
|
-
}
|
|
4083
|
-
}
|
|
4084
|
-
const validationIssueFields = (_j = this.getFieldsWithValidationIssues(null, sectionCode)) !== null && _j !== void 0 ? _j : [];
|
|
4085
|
-
if (!validationError && validationIssueFields.length > 0) {
|
|
4086
|
-
validationError = true;
|
|
4087
|
-
this.setError((_k = this.formConfig) === null || _k === void 0 ? void 0 : _k.formStandardErrors.typeWarning, (_l = this.formConfig) === null || _l === void 0 ? void 0 : _l.formStandardErrors.validationTitle, (_m = this.formConfig) === null || _m === void 0 ? void 0 : _m.formStandardErrors.validationFields);
|
|
4088
|
-
for (const code of validationIssueFields) {
|
|
4089
|
-
const validationIssueField = this.getField(code);
|
|
4090
|
-
if (validationIssueField) {
|
|
4091
|
-
validationIssueField.focus();
|
|
4092
|
-
}
|
|
4093
|
-
break;
|
|
4094
|
-
}
|
|
4095
|
-
}
|
|
4096
|
-
return validationError;
|
|
4097
|
-
}
|
|
4098
|
-
copyTableRecordToFields(tableObj, mappingTable = null) {
|
|
4099
|
-
var _a, _b;
|
|
4100
|
-
const tableObject = this.getTable(tableObj.tableCode);
|
|
4101
|
-
const tableRecord = tableObject === null || tableObject === void 0 ? void 0 : tableObject.getTableRecord(tableObj.recordId);
|
|
4102
|
-
const columnNames = tableObject === null || tableObject === void 0 ? void 0 : tableObject.columnNames;
|
|
4103
|
-
if (tableRecord && columnNames) {
|
|
4104
|
-
for (const columnName of columnNames) {
|
|
4105
|
-
const columnValue = (_a = tableRecord.getFieldValue(columnName)) !== null && _a !== void 0 ? _a : '';
|
|
4106
|
-
const code = (_b = mappingTable === null || mappingTable === void 0 ? void 0 : mappingTable[columnName]) !== null && _b !== void 0 ? _b : columnName;
|
|
4107
|
-
const field = code ? this.getField(code) : null;
|
|
4108
|
-
if (field) {
|
|
4109
|
-
field.setValue(columnValue);
|
|
4110
|
-
field.hasChanged = false;
|
|
4111
|
-
}
|
|
4112
|
-
}
|
|
4113
|
-
return true;
|
|
4114
|
-
}
|
|
4115
|
-
return false;
|
|
4116
|
-
}
|
|
4117
|
-
notifyFormActivity() {
|
|
4118
|
-
if (this._notifyFormActivity) {
|
|
4119
|
-
this._eventEmiter.next('formActivity', { code: this.formCode });
|
|
4120
|
-
}
|
|
4121
|
-
}
|
|
4122
|
-
/**
|
|
4123
|
-
* Métodos Legacy de compatibilidad hacia atrás
|
|
4124
|
-
*/
|
|
4125
|
-
/**
|
|
4126
|
-
* @deprecated Use name
|
|
4127
|
-
*/
|
|
4128
|
-
get formCode() { var _a; return (_a = this.name) !== null && _a !== void 0 ? _a : ''; }
|
|
4129
|
-
/**
|
|
4130
|
-
* @deprecated Use name
|
|
4131
|
-
*/
|
|
4132
|
-
set formCode(name) { this.name = name; }
|
|
4133
|
-
/**
|
|
4134
|
-
* @deprecated Use busy
|
|
4135
|
-
*/
|
|
4136
|
-
get inServerProcess() { return this.busy; }
|
|
4137
|
-
/**
|
|
4138
|
-
* @deprecated Use state
|
|
4139
|
-
*/
|
|
4140
|
-
get currentState() { var _a; return (_a = this.state) !== null && _a !== void 0 ? _a : ''; }
|
|
4141
|
-
/**
|
|
4142
|
-
* @deprecated Use changeState
|
|
4143
|
-
*/
|
|
4144
|
-
set currentState(state) { this === null || this === void 0 ? void 0 : this.changeState(state); }
|
|
4145
|
-
/**
|
|
4146
|
-
* @deprecated Use onSectionActivation
|
|
4147
|
-
*/
|
|
4148
|
-
get formRoute() { var _a; return (_a = this._formRoute) !== null && _a !== void 0 ? _a : ''; }
|
|
4149
|
-
/**
|
|
4150
|
-
* @deprecated Use onSectionActivation
|
|
4151
|
-
*/
|
|
4152
|
-
set formRoute(route) { this._formRoute = route; }
|
|
4153
|
-
/**
|
|
4154
|
-
* @deprecated Use onSectionActivation
|
|
4155
|
-
*/
|
|
4156
|
-
addSectionActivation(codes, callback, properties = null) {
|
|
4157
|
-
return this.onSectionActivation(codes, callback, properties);
|
|
4158
|
-
}
|
|
4159
|
-
/**
|
|
4160
|
-
* @deprecated Use onSectionInactivation
|
|
4161
|
-
*/
|
|
4162
|
-
addSectionInactivation(codes, callback, properties = null) {
|
|
4163
|
-
return this.onSectionInactivation(codes, callback, properties);
|
|
4164
|
-
}
|
|
4165
|
-
/**
|
|
4166
|
-
* @deprecated Use onActionStart
|
|
4167
|
-
*/
|
|
4168
|
-
addActionMethodStart(codes, callback, properties = null) {
|
|
4169
|
-
return this.onActionStart(codes, callback, properties);
|
|
4170
|
-
}
|
|
4171
|
-
/**
|
|
4172
|
-
* @deprecated Use onActionFinish
|
|
4173
|
-
*/
|
|
4174
|
-
addActionMethodFinish(codes, callback, properties = null) {
|
|
4175
|
-
return this.onActionFinish(codes, callback, properties);
|
|
4176
|
-
}
|
|
4177
|
-
/**
|
|
4178
|
-
* @deprecated Use onFieldInput
|
|
4179
|
-
*/
|
|
4180
|
-
addFieldInputValidation(codes, callback, properties = null) {
|
|
4181
|
-
return this.onFieldInput(codes, callback, properties);
|
|
4182
|
-
}
|
|
4183
|
-
/**
|
|
4184
|
-
* @deprecated Use onFieldValidationStart
|
|
4185
|
-
*/
|
|
4186
|
-
addFieldValidationStart(codes, callback, properties = null) {
|
|
4187
|
-
return this.onFieldValidationStart(codes, callback, properties);
|
|
4188
|
-
}
|
|
4189
|
-
/**
|
|
4190
|
-
* @deprecated Use onFieldValidationFinish
|
|
4191
|
-
*/
|
|
4192
|
-
addFieldValidationFinish(codes, callback, properties = null) {
|
|
4193
|
-
return this.onFieldValidationFinish(codes, callback, properties);
|
|
4194
|
-
}
|
|
4195
|
-
/**
|
|
4196
|
-
* @deprecated Use onTableActionStart
|
|
4197
|
-
*/
|
|
4198
|
-
addTableActionStart(code, actionCode, callback, properties = null) {
|
|
4199
|
-
return this.onTableActionStart(code, actionCode, callback, properties);
|
|
4200
|
-
}
|
|
4201
|
-
/**
|
|
4202
|
-
* @deprecated Use onTableActionFinish
|
|
4203
|
-
*/
|
|
4204
|
-
addTableActionFinish(code, actionCode, callback, properties = null) {
|
|
4205
|
-
return this.onTableActionFinish(code, actionCode, callback, properties);
|
|
4206
|
-
}
|
|
4207
|
-
/**
|
|
4208
|
-
* @deprecated Use onTableSelectionStart
|
|
4209
|
-
*/
|
|
4210
|
-
addTableSelectionStart(code, callback, properties = null) {
|
|
4211
|
-
return this.onTableSelectionStart(code, callback, properties);
|
|
4212
|
-
}
|
|
4213
|
-
/**
|
|
4214
|
-
* @deprecated Use onTableSelectionFinish
|
|
4215
|
-
*/
|
|
4216
|
-
addTableSelectionFinish(code, callback, properties = null) {
|
|
4217
|
-
return this.onTableSelectionFinish(code, callback, properties);
|
|
4218
|
-
}
|
|
4219
|
-
/**
|
|
4220
|
-
* @deprecated Use onTableGetDataStart
|
|
4221
|
-
*/
|
|
4222
|
-
addTableGetDataStart(code, callback, properties = null) {
|
|
4223
|
-
return this.onTableGetDataStart(code, callback, properties);
|
|
4224
|
-
}
|
|
4225
|
-
/**
|
|
4226
|
-
* @deprecated Use onTableGetDataFinish
|
|
4227
|
-
*/
|
|
4228
|
-
addTableGetDataFinish(code, callback, properties = null) {
|
|
4229
|
-
return this.onTableGetDataFinish(code, callback, properties);
|
|
4230
|
-
}
|
|
4231
|
-
}
|
|
4232
|
-
BasicFormComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: BasicFormComponent, deps: [{ token: LibFormManagerService }, { token: LibEventManagerService }, { token: LibFileManagementService }], target: i0.ɵɵFactoryTarget.Component });
|
|
4233
|
-
BasicFormComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.6", type: BasicFormComponent, selector: "ng-component", usesInheritance: true, ngImport: i0, template: `<ng-content></ng-content>`, isInline: true });
|
|
4234
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: BasicFormComponent, decorators: [{
|
|
4235
|
-
type: Component,
|
|
4236
|
-
args: [{
|
|
4237
|
-
template: `<ng-content></ng-content>`
|
|
4238
|
-
}]
|
|
4239
|
-
}], ctorParameters: function () { return [{ type: LibFormManagerService }, { type: LibEventManagerService }, { type: LibFileManagementService }]; } });
|
|
4240
|
-
|
|
4241
|
-
const COMPONENTS = [
|
|
4242
|
-
BasicFormComponent,
|
|
4243
|
-
ActionComponent,
|
|
4244
|
-
FieldComponent,
|
|
4245
|
-
ElementComponent,
|
|
4246
|
-
FormErrorComponent,
|
|
4247
|
-
FormHeaderComponent,
|
|
4248
|
-
SectionComponent,
|
|
4249
|
-
SubSectionComponent,
|
|
4250
|
-
LibTableRecordActionComponent,
|
|
4251
|
-
LibTableRecordFieldComponent,
|
|
4252
|
-
LibTableComponent
|
|
4253
|
-
];
|
|
4254
|
-
class TuainNgFormsLibModule {
|
|
4255
|
-
}
|
|
4256
|
-
TuainNgFormsLibModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: TuainNgFormsLibModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
4257
|
-
TuainNgFormsLibModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "14.2.6", ngImport: i0, type: TuainNgFormsLibModule, declarations: [BasicFormComponent,
|
|
4258
|
-
ActionComponent,
|
|
4259
|
-
FieldComponent,
|
|
4260
|
-
ElementComponent,
|
|
4261
|
-
FormErrorComponent,
|
|
4262
|
-
FormHeaderComponent,
|
|
4263
|
-
SectionComponent,
|
|
4264
|
-
SubSectionComponent,
|
|
4265
|
-
LibTableRecordActionComponent,
|
|
4266
|
-
LibTableRecordFieldComponent,
|
|
4267
|
-
LibTableComponent], imports: [CommonModule,
|
|
4268
|
-
RouterModule,
|
|
4269
|
-
FormsModule], exports: [BasicFormComponent,
|
|
4270
|
-
ActionComponent,
|
|
4271
|
-
FieldComponent,
|
|
4272
|
-
ElementComponent,
|
|
4273
|
-
FormErrorComponent,
|
|
4274
|
-
FormHeaderComponent,
|
|
4275
|
-
SectionComponent,
|
|
4276
|
-
SubSectionComponent,
|
|
4277
|
-
LibTableRecordActionComponent,
|
|
4278
|
-
LibTableRecordFieldComponent,
|
|
4279
|
-
LibTableComponent] });
|
|
4280
|
-
TuainNgFormsLibModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: TuainNgFormsLibModule, imports: [CommonModule,
|
|
4281
|
-
RouterModule,
|
|
4282
|
-
FormsModule] });
|
|
4283
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: TuainNgFormsLibModule, decorators: [{
|
|
4284
|
-
type: NgModule,
|
|
4285
|
-
args: [{
|
|
4286
|
-
declarations: COMPONENTS,
|
|
4287
|
-
imports: [
|
|
4288
|
-
CommonModule,
|
|
4289
|
-
RouterModule,
|
|
4290
|
-
FormsModule,
|
|
4291
|
-
],
|
|
4292
|
-
exports: COMPONENTS
|
|
4293
|
-
}]
|
|
4294
|
-
}] });
|
|
4295
|
-
|
|
4296
|
-
/*
|
|
4297
|
-
* Public API Surface of tuain-ng-forms-lib
|
|
4298
|
-
*/
|
|
4299
|
-
|
|
4300
|
-
/**
|
|
4301
|
-
* Generated bundle index. Do not edit.
|
|
4302
|
-
*/
|
|
4303
|
-
|
|
4304
|
-
export { ActionComponent, BasicFormComponent, ElementComponent, FieldComponent, FormErrorComponent, FormHeaderComponent, LibEventManagerService, LibFileManagementService, LibFormManagerService, LibTableComponent, LibTableRecordActionComponent, LibTableRecordFieldComponent, SectionComponent, SubSectionComponent, TuainNgFormsLibModule };
|
|
4305
|
-
//# sourceMappingURL=tuain-ng-forms-lib.mjs.map
|