tuain-ng-forms-lib 14.4.96 → 14.5.25
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/esm2020/lib/classes/forms/action.mjs +40 -4
- package/esm2020/lib/classes/forms/element.mjs +1 -9
- package/esm2020/lib/classes/forms/field.mjs +19 -28
- package/esm2020/lib/classes/forms/form.mjs +2 -2
- package/esm2020/lib/classes/forms/piece-propagate.mjs +3 -2
- package/esm2020/lib/classes/forms/piece.mjs +6 -4
- package/esm2020/lib/classes/forms/section.mjs +3 -3
- package/esm2020/lib/classes/forms/table/action.mjs +9 -4
- package/esm2020/lib/classes/forms/table/table.mjs +4 -4
- package/esm2020/lib/components/elements/action.component.mjs +2 -24
- package/esm2020/lib/components/elements/field.component.mjs +14 -1
- package/esm2020/lib/components/elements/layout/element.component.mjs +5 -5
- package/esm2020/lib/components/elements/layout/form-header.component.mjs +2 -9
- package/esm2020/lib/components/elements/layout/piece.component.mjs +2 -1
- package/esm2020/lib/components/elements/layout/section.component.mjs +5 -5
- package/esm2020/lib/components/elements/layout/sub-section.component.mjs +5 -5
- package/esm2020/lib/components/elements/tables/table-record-action.component.mjs +17 -9
- package/esm2020/lib/components/forms/basic-form.mjs +12 -8
- package/esm2020/lib/services/file-manager.service.mjs +2 -1
- package/fesm2015/tuain-ng-forms-lib.mjs +148 -118
- package/fesm2015/tuain-ng-forms-lib.mjs.map +1 -1
- package/fesm2020/tuain-ng-forms-lib.mjs +134 -109
- package/fesm2020/tuain-ng-forms-lib.mjs.map +1 -1
- package/lib/classes/forms/action.d.ts +9 -6
- package/lib/classes/forms/element.d.ts +0 -8
- package/lib/classes/forms/field.d.ts +2 -11
- package/lib/classes/forms/piece.d.ts +3 -2
- package/lib/classes/forms/section.d.ts +1 -1
- package/lib/classes/forms/table/action.d.ts +4 -4
- package/lib/classes/forms/table/table.d.ts +1 -1
- package/lib/components/elements/action.component.d.ts +1 -6
- package/lib/components/elements/layout/element.component.d.ts +1 -2
- package/lib/components/elements/layout/form-header.component.d.ts +1 -4
- package/lib/components/elements/layout/piece.component.d.ts +2 -0
- package/lib/components/elements/layout/section.component.d.ts +1 -2
- package/lib/components/elements/layout/sub-section.component.d.ts +1 -2
- package/lib/components/elements/tables/table-record-action.component.d.ts +3 -1
- package/lib/components/forms/basic-form.d.ts +2 -2
- package/lib/services/file-manager.service.d.ts +1 -0
- package/package.json +1 -1
|
@@ -14,6 +14,7 @@ class PieceComponent {
|
|
|
14
14
|
this.disabled = false;
|
|
15
15
|
this.customAttributes = {};
|
|
16
16
|
}
|
|
17
|
+
setForm(form) { this.form = form; }
|
|
17
18
|
defaultProcessAttributeChange(attribute, value) {
|
|
18
19
|
if (!attribute || attribute.trim() === '') {
|
|
19
20
|
return false;
|
|
@@ -45,10 +46,12 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.6", ngImpor
|
|
|
45
46
|
}] });
|
|
46
47
|
|
|
47
48
|
class ElementComponent extends PieceComponent {
|
|
48
|
-
start() {
|
|
49
|
+
start() {
|
|
50
|
+
this.setForm(this.element?._form);
|
|
51
|
+
}
|
|
49
52
|
}
|
|
50
53
|
ElementComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: ElementComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
51
|
-
ElementComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.6", type: ElementComponent, selector: "lib-element", inputs: { element: "element"
|
|
54
|
+
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 });
|
|
52
55
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: ElementComponent, decorators: [{
|
|
53
56
|
type: Component,
|
|
54
57
|
args: [{
|
|
@@ -57,8 +60,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.6", ngImpor
|
|
|
57
60
|
}]
|
|
58
61
|
}], propDecorators: { element: [{
|
|
59
62
|
type: Input
|
|
60
|
-
}], form: [{
|
|
61
|
-
type: Input
|
|
62
63
|
}] } });
|
|
63
64
|
|
|
64
65
|
class ActionComponent extends ElementComponent {
|
|
@@ -66,8 +67,6 @@ class ActionComponent extends ElementComponent {
|
|
|
66
67
|
super(...arguments);
|
|
67
68
|
this.inProgress = false;
|
|
68
69
|
this.action = null;
|
|
69
|
-
this.style = 'primary';
|
|
70
|
-
this.showLabel = true;
|
|
71
70
|
}
|
|
72
71
|
ngOnInit() {
|
|
73
72
|
if (!this.action) {
|
|
@@ -96,21 +95,9 @@ class ActionComponent extends ElementComponent {
|
|
|
96
95
|
this.action.notifyActivation();
|
|
97
96
|
}
|
|
98
97
|
}
|
|
99
|
-
visibleOnRestriction() {
|
|
100
|
-
if (!this.action?.restrictedOnField) {
|
|
101
|
-
return true;
|
|
102
|
-
}
|
|
103
|
-
if ((this.action?.restrictedOnOperator === '=='
|
|
104
|
-
&& this.relatedField === this.action?.restrictedOnValue)
|
|
105
|
-
|| (this.action?.restrictedOnOperator === '!='
|
|
106
|
-
&& this.relatedField !== this.action?.restrictedOnValue)) {
|
|
107
|
-
return true;
|
|
108
|
-
}
|
|
109
|
-
return false;
|
|
110
|
-
}
|
|
111
98
|
}
|
|
112
99
|
ActionComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: ActionComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
113
|
-
ActionComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.6", type: ActionComponent, selector: "lib-action", inputs: { action: "action"
|
|
100
|
+
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 });
|
|
114
101
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: ActionComponent, decorators: [{
|
|
115
102
|
type: Component,
|
|
116
103
|
args: [{
|
|
@@ -119,14 +106,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.6", ngImpor
|
|
|
119
106
|
}]
|
|
120
107
|
}], propDecorators: { action: [{
|
|
121
108
|
type: Input
|
|
122
|
-
}], busy: [{
|
|
123
|
-
type: Input
|
|
124
|
-
}], relatedField: [{
|
|
125
|
-
type: Input
|
|
126
|
-
}], style: [{
|
|
127
|
-
type: Input
|
|
128
|
-
}], showLabel: [{
|
|
129
|
-
type: Input
|
|
130
109
|
}] } });
|
|
131
110
|
|
|
132
111
|
const VALUE = 'value';
|
|
@@ -147,6 +126,7 @@ class FieldComponent extends ElementComponent {
|
|
|
147
126
|
}
|
|
148
127
|
this.formConfig = this.field?._formConfig;
|
|
149
128
|
const mapping = Object.entries(this.formConfig?.fieldPropagateAttributes);
|
|
129
|
+
const customAttributesMapping = this.formConfig?.propagationCustomAttributes.fields ?? [];
|
|
150
130
|
for (let index = 0; index < mapping.length; index++) {
|
|
151
131
|
const fieldAttr = mapping[index]?.[0];
|
|
152
132
|
const componentAttr = mapping[index]?.[1]?.toString() ?? '';
|
|
@@ -156,6 +136,18 @@ class FieldComponent extends ElementComponent {
|
|
|
156
136
|
this.customProcessAttributeChange(componentAttr, value);
|
|
157
137
|
}
|
|
158
138
|
}
|
|
139
|
+
// Atributos personalizados
|
|
140
|
+
for (let index = 0; index < customAttributesMapping.length; index++) {
|
|
141
|
+
const customAttribute = customAttributesMapping[index];
|
|
142
|
+
if (customAttribute) {
|
|
143
|
+
const value = this.field?.getCustomAttribute(customAttribute);
|
|
144
|
+
const fullName = `customAttributes.${customAttribute}`;
|
|
145
|
+
if (value) {
|
|
146
|
+
this.defaultProcessAttributeChange(fullName, value);
|
|
147
|
+
this.customProcessAttributeChange(fullName, value);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
159
151
|
// Subscripción a cambios en atributos
|
|
160
152
|
this.field?.attributeChange.subscribe(event => {
|
|
161
153
|
const { name: componentAttr, value } = event;
|
|
@@ -227,7 +219,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.6", ngImpor
|
|
|
227
219
|
|
|
228
220
|
class FormHeaderComponent {
|
|
229
221
|
constructor() {
|
|
230
|
-
this.canGoBack = false;
|
|
231
222
|
this.goBackEvent = new EventEmitter();
|
|
232
223
|
}
|
|
233
224
|
goBackForm() {
|
|
@@ -235,7 +226,7 @@ class FormHeaderComponent {
|
|
|
235
226
|
}
|
|
236
227
|
}
|
|
237
228
|
FormHeaderComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: FormHeaderComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
238
|
-
FormHeaderComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.6", type: FormHeaderComponent, selector: "lib-form-header", inputs: { form: "form"
|
|
229
|
+
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 });
|
|
239
230
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: FormHeaderComponent, decorators: [{
|
|
240
231
|
type: Component,
|
|
241
232
|
args: [{
|
|
@@ -244,12 +235,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.6", ngImpor
|
|
|
244
235
|
}]
|
|
245
236
|
}], propDecorators: { form: [{
|
|
246
237
|
type: Input
|
|
247
|
-
}], canGoBack: [{
|
|
248
|
-
type: Input
|
|
249
|
-
}], showTitle: [{
|
|
250
|
-
type: Input
|
|
251
|
-
}], headerActions: [{
|
|
252
|
-
type: Input
|
|
253
238
|
}], goBackEvent: [{
|
|
254
239
|
type: Output
|
|
255
240
|
}] } });
|
|
@@ -272,10 +257,12 @@ class SectionComponent extends PieceComponent {
|
|
|
272
257
|
});
|
|
273
258
|
this.start();
|
|
274
259
|
}
|
|
275
|
-
start() {
|
|
260
|
+
start() {
|
|
261
|
+
this.setForm(this.section?._form);
|
|
262
|
+
}
|
|
276
263
|
}
|
|
277
264
|
SectionComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: SectionComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
278
|
-
SectionComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.6", type: SectionComponent, selector: "lib-section", inputs: { section: "section"
|
|
265
|
+
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 });
|
|
279
266
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: SectionComponent, decorators: [{
|
|
280
267
|
type: Component,
|
|
281
268
|
args: [{
|
|
@@ -284,8 +271,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.6", ngImpor
|
|
|
284
271
|
}]
|
|
285
272
|
}], propDecorators: { section: [{
|
|
286
273
|
type: Input
|
|
287
|
-
}], form: [{
|
|
288
|
-
type: Input
|
|
289
274
|
}] } });
|
|
290
275
|
|
|
291
276
|
class SubSectionComponent extends PieceComponent {
|
|
@@ -306,10 +291,12 @@ class SubSectionComponent extends PieceComponent {
|
|
|
306
291
|
});
|
|
307
292
|
this.start();
|
|
308
293
|
}
|
|
309
|
-
start() {
|
|
294
|
+
start() {
|
|
295
|
+
this.setForm(this.subSection?._form);
|
|
296
|
+
}
|
|
310
297
|
}
|
|
311
298
|
SubSectionComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: SubSectionComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
312
|
-
SubSectionComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.6", type: SubSectionComponent, selector: "lib-subsection", inputs: { subSection: "subSection"
|
|
299
|
+
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 });
|
|
313
300
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: SubSectionComponent, decorators: [{
|
|
314
301
|
type: Component,
|
|
315
302
|
args: [{
|
|
@@ -318,14 +305,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.6", ngImpor
|
|
|
318
305
|
}]
|
|
319
306
|
}], propDecorators: { subSection: [{
|
|
320
307
|
type: Input
|
|
321
|
-
}], form: [{
|
|
322
|
-
type: Input
|
|
323
308
|
}] } });
|
|
324
309
|
|
|
325
310
|
const INLINE_ACTION$1 = 'INLINE';
|
|
326
311
|
class LibTableRecordActionComponent extends PieceComponent {
|
|
327
312
|
constructor() {
|
|
328
313
|
super(...arguments);
|
|
314
|
+
this.isVisible = true;
|
|
329
315
|
this.actionSelected = new EventEmitter();
|
|
330
316
|
}
|
|
331
317
|
ngOnInit() {
|
|
@@ -337,18 +323,25 @@ class LibTableRecordActionComponent extends PieceComponent {
|
|
|
337
323
|
this.defaultProcessAttributeChange(attrName, attributeValue);
|
|
338
324
|
this.customProcessAttributeChange(attrName, attributeValue);
|
|
339
325
|
}
|
|
340
|
-
// Subscripción a cambios en atributos
|
|
341
|
-
this.action?.attributeChange.subscribe(event => {
|
|
342
|
-
const { name: attrName, value } = event;
|
|
343
|
-
this.defaultProcessAttributeChange(attrName, value);
|
|
344
|
-
this.customProcessAttributeChange(attrName, value);
|
|
345
|
-
});
|
|
346
326
|
this.start();
|
|
347
327
|
}
|
|
348
|
-
start() {
|
|
328
|
+
start() {
|
|
329
|
+
if (this.action && this.action.restrictedOnField && this.recordData) {
|
|
330
|
+
const relatedField = this.recordData[this.action.restrictedOnField];
|
|
331
|
+
if (relatedField) {
|
|
332
|
+
const fieldValue = relatedField;
|
|
333
|
+
const restrictionOper = this.action.restrictedOnOperator;
|
|
334
|
+
const restrictionValue = this.action.restrictedOnValue;
|
|
335
|
+
if ((restrictionOper === '==' && fieldValue !== restrictionValue)
|
|
336
|
+
|| (restrictionOper === '!=' && fieldValue === restrictionValue)) {
|
|
337
|
+
this.isVisible = false;
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
}
|
|
349
342
|
onActivate() {
|
|
350
343
|
const tableEvent = {
|
|
351
|
-
actionCode: this.action
|
|
344
|
+
actionCode: this.action?.actionCode ?? '',
|
|
352
345
|
recordId: this.recordId,
|
|
353
346
|
recordData: this.recordData,
|
|
354
347
|
};
|
|
@@ -522,6 +515,7 @@ class FormPiece {
|
|
|
522
515
|
this._absoluteDisabled = false;
|
|
523
516
|
this.visibleStates = null;
|
|
524
517
|
this.enabledStates = null;
|
|
518
|
+
this._form = null;
|
|
525
519
|
this._visible = true;
|
|
526
520
|
this._disabled = false;
|
|
527
521
|
this.customAttributes = {};
|
|
@@ -596,7 +590,7 @@ class FormPiece {
|
|
|
596
590
|
set disabled(disabled) { this.enabled = !disabled; }
|
|
597
591
|
enable() { this.enabled = true; }
|
|
598
592
|
disable() { this.enabled = false; }
|
|
599
|
-
formStateChangeCustomSubscribe(formChangeSubject) { }
|
|
593
|
+
formStateChangeCustomSubscribe(form, formChangeSubject) { }
|
|
600
594
|
formStateChange(state) {
|
|
601
595
|
if (state) {
|
|
602
596
|
this._formState = state;
|
|
@@ -604,8 +598,9 @@ class FormPiece {
|
|
|
604
598
|
this._disabled = this._absoluteDisabled || !this.enabledOnState(state);
|
|
605
599
|
}
|
|
606
600
|
}
|
|
607
|
-
|
|
608
|
-
this.
|
|
601
|
+
connectWithParentForm(form, formChangeSubject) {
|
|
602
|
+
this._form = form;
|
|
603
|
+
this.formStateChangeCustomSubscribe(form, formChangeSubject);
|
|
609
604
|
formChangeSubject.subscribe(event => this.formStateChange(event?.state));
|
|
610
605
|
}
|
|
611
606
|
}
|
|
@@ -625,7 +620,8 @@ class FormPiecePropagate extends FormPiece {
|
|
|
625
620
|
setCustomAttribute(name, value) {
|
|
626
621
|
super.setCustomAttribute(name, value);
|
|
627
622
|
if (this.propagationCustomAttributes?.includes(name)) {
|
|
628
|
-
|
|
623
|
+
const fullName = `customAttributes.${name}`;
|
|
624
|
+
this.propagateAttribute(fullName, value);
|
|
629
625
|
}
|
|
630
626
|
}
|
|
631
627
|
setVisibility(visible, forced = null) {
|
|
@@ -659,14 +655,6 @@ class FormElement extends FormPiecePropagate {
|
|
|
659
655
|
isField() { return this.elementType === elementTypes.field; }
|
|
660
656
|
isAction() { return this.elementType === elementTypes.action; }
|
|
661
657
|
isTable() { return this.elementType === elementTypes.table; }
|
|
662
|
-
/**
|
|
663
|
-
* @deprecated Utilizar viewOnState
|
|
664
|
-
*/
|
|
665
|
-
supportState(state) { return this.viewOnState(state); }
|
|
666
|
-
/**
|
|
667
|
-
* @deprecated Utilizar viewOnState
|
|
668
|
-
*/
|
|
669
|
-
supportMode(state) { return this.viewOnState(state); }
|
|
670
658
|
}
|
|
671
659
|
|
|
672
660
|
const HEADER = 'HEADER';
|
|
@@ -675,6 +663,9 @@ class FormAction extends FormElement {
|
|
|
675
663
|
super(actionDefinition, formConfig);
|
|
676
664
|
this._actionActivated = new Subject();
|
|
677
665
|
this.inProgress = false;
|
|
666
|
+
this.restrictedOnField = null;
|
|
667
|
+
this.restrictedOnOperator = null;
|
|
668
|
+
this.restrictedOnValue = null;
|
|
678
669
|
this.propagationCustomAttributes = this._formConfig?.propagationCustomAttributes?.actions ?? [];
|
|
679
670
|
this.elementType = elementTypes.action;
|
|
680
671
|
this.actionCode = actionDefinition.actionCode ? actionDefinition.actionCode.toString() : '';
|
|
@@ -683,11 +674,44 @@ class FormAction extends FormElement {
|
|
|
683
674
|
this.setCustomAttribute('location', actionDefinition.position || HEADER);
|
|
684
675
|
this.backend = actionDefinition?.serverAction ?? false;
|
|
685
676
|
this.newState = actionDefinition?.newState;
|
|
686
|
-
this.restrictedOnField = actionDefinition.fieldRestrictedCode
|
|
687
|
-
this.
|
|
688
|
-
|
|
677
|
+
this.restrictedOnField = actionDefinition.fieldRestrictedCode?.toString() ?? null;
|
|
678
|
+
if (this.restrictedOnField) {
|
|
679
|
+
this.restrictedOnOperator = actionDefinition.operatorRestricted || '';
|
|
680
|
+
this.restrictedOnValue = actionDefinition.valueRestricted ?? '';
|
|
681
|
+
}
|
|
689
682
|
this.customValidation = () => true;
|
|
690
683
|
}
|
|
684
|
+
connectWithParentForm(form, formChangeSubject) {
|
|
685
|
+
super.connectWithParentForm(form, formChangeSubject);
|
|
686
|
+
if (this.restrictedOnField) {
|
|
687
|
+
const relatedField = this._form.fields?.[this.restrictedOnField];
|
|
688
|
+
if (relatedField) {
|
|
689
|
+
relatedField.editionFinish.subscribe(event => this.updateRestrictedVisibility());
|
|
690
|
+
relatedField.editionPartial.subscribe(event => this.updateRestrictedVisibility());
|
|
691
|
+
}
|
|
692
|
+
}
|
|
693
|
+
}
|
|
694
|
+
updateRestrictedVisibility() {
|
|
695
|
+
const lastVisible = this._visible;
|
|
696
|
+
const newVisible = this._absoluteVisible && this.viewOnState(this._formState);
|
|
697
|
+
if (lastVisible !== newVisible) {
|
|
698
|
+
this.setVisibility(newVisible);
|
|
699
|
+
}
|
|
700
|
+
}
|
|
701
|
+
viewOnState(state) {
|
|
702
|
+
const actionVisible = (this.visibleStates && state) ? this.visibleStates.includes(state) : false;
|
|
703
|
+
if (actionVisible && this._form && this.restrictedOnField) {
|
|
704
|
+
const relatedField = this._form.fields?.[this.restrictedOnField];
|
|
705
|
+
if (relatedField) {
|
|
706
|
+
const fieldValue = relatedField.value;
|
|
707
|
+
if ((this.restrictedOnOperator === '==' && fieldValue !== this.restrictedOnValue)
|
|
708
|
+
|| (this.restrictedOnOperator === '!=' && fieldValue === this.restrictedOnValue)) {
|
|
709
|
+
return false;
|
|
710
|
+
}
|
|
711
|
+
}
|
|
712
|
+
}
|
|
713
|
+
return actionVisible;
|
|
714
|
+
}
|
|
691
715
|
get actionActivated() { return this._actionActivated; }
|
|
692
716
|
start() { this.inProgress = true; }
|
|
693
717
|
stop() { this.inProgress = false; }
|
|
@@ -722,13 +746,13 @@ const attrs$1 = {
|
|
|
722
746
|
_defaultValue: { name: '_defaultValue', propagate: 'defaultValue' },
|
|
723
747
|
_defaultEditable: { name: '_defaultEditable', propagate: 'defaultEditable' },
|
|
724
748
|
_fieldAlignment: { name: '_fieldAlignment', propagate: 'alignment' },
|
|
725
|
-
|
|
749
|
+
fieldCode: { name: 'fieldCode', propagate: 'code' },
|
|
726
750
|
_fieldInfo: { name: '_fieldInfo', propagate: 'info' },
|
|
727
751
|
_fieldRequired: { name: '_fieldRequired', propagate: 'required' },
|
|
728
752
|
_fieldTitle: { name: '_fieldTitle', propagate: 'title' },
|
|
729
753
|
_fieldType: { name: '_fieldType', propagate: 'type' },
|
|
730
754
|
_fieldFormat: { name: '_fieldFormat', propagate: 'format' },
|
|
731
|
-
|
|
755
|
+
fieldOptions: { name: 'fieldOptions', propagate: 'options' },
|
|
732
756
|
_focus: { name: '_focus', propagate: 'focus' },
|
|
733
757
|
_hasChanged: { name: '_hasChanged', propagate: 'hasChanged' },
|
|
734
758
|
_intrinsicErrorMessage: { name: '_intrinsicErrorMessage', propagate: null },
|
|
@@ -752,7 +776,6 @@ class FieldDescriptor extends FormElement {
|
|
|
752
776
|
this._errorType = '';
|
|
753
777
|
this._errorCode = '';
|
|
754
778
|
this._errorMessage = '';
|
|
755
|
-
this._fieldCode = '';
|
|
756
779
|
this._intrinsicErrorMessage = '';
|
|
757
780
|
this._maxLength = 0;
|
|
758
781
|
this._minLength = 0;
|
|
@@ -769,15 +792,16 @@ class FieldDescriptor extends FormElement {
|
|
|
769
792
|
this._fieldTitle = '';
|
|
770
793
|
this._fieldType = '';
|
|
771
794
|
this._fieldFormat = null;
|
|
772
|
-
this._fieldOptions = null;
|
|
773
795
|
this._hasChanged = false;
|
|
774
796
|
this._outputOnly = false;
|
|
775
797
|
this._tooltipText = '';
|
|
798
|
+
this.fieldCode = '';
|
|
799
|
+
this.fieldOptions = null;
|
|
776
800
|
this.propagationCustomAttributes = this._formConfig?.propagationCustomAttributes?.fields ?? [];
|
|
777
801
|
this.elementType = elementTypes.field;
|
|
778
802
|
const fld = (inputFieldReceived) ? inputFieldReceived : {};
|
|
779
|
-
this.setAttr(attrs$1.
|
|
780
|
-
this.title = fld.fieldTitle ?? this.
|
|
803
|
+
this.setAttr(attrs$1.fieldCode, fld.fieldCode);
|
|
804
|
+
this.title = fld.fieldTitle ?? this.fieldCode;
|
|
781
805
|
this.type = fld.fieldTypeCode;
|
|
782
806
|
this.captureType = fld.captureType ?? DEFAULT_CAPTURE_TYPE;
|
|
783
807
|
const defaultValue = fld.defaultValue ?? null;
|
|
@@ -820,8 +844,7 @@ class FieldDescriptor extends FormElement {
|
|
|
820
844
|
get backend() { return this._validateOnServer; }
|
|
821
845
|
get captureType() { return this._captureType; }
|
|
822
846
|
set captureType(captureType) { this.setAttr(attrs$1._captureType, captureType); }
|
|
823
|
-
get code() { return this.
|
|
824
|
-
get fieldCode() { return this._fieldCode; }
|
|
847
|
+
get code() { return this.fieldCode; }
|
|
825
848
|
get defaultValue() { return this._defaultValue; }
|
|
826
849
|
set defaultValue(defaultValue) { this.setAttr(attrs$1._defaultValue, defaultValue); }
|
|
827
850
|
get defaultEditable() { return this._defaultEditable; }
|
|
@@ -886,9 +909,9 @@ class FieldDescriptor extends FormElement {
|
|
|
886
909
|
}
|
|
887
910
|
this.setAttr(attrs$1._minValue, minValue);
|
|
888
911
|
}
|
|
889
|
-
get name() { return this.
|
|
912
|
+
get name() { return this.fieldCode; }
|
|
890
913
|
get options() {
|
|
891
|
-
return this.
|
|
914
|
+
return this.fieldOptions?.map(option => {
|
|
892
915
|
const optionCopy = { ...option };
|
|
893
916
|
return optionCopy;
|
|
894
917
|
}) ?? null;
|
|
@@ -908,25 +931,25 @@ class FieldDescriptor extends FormElement {
|
|
|
908
931
|
});
|
|
909
932
|
fieldOptions = (fieldOptions && Array.isArray(fieldOptions)
|
|
910
933
|
&& fieldOptions.length > 0) ? fieldOptions : [];
|
|
911
|
-
this.setAttr(attrs$1.
|
|
934
|
+
this.setAttr(attrs$1.fieldOptions, fieldOptions);
|
|
912
935
|
if (this._value) {
|
|
913
936
|
if (this._fieldType === this._formConfig.fieldTypes.array && Array.isArray(this._value)) {
|
|
914
|
-
const fieldValue = this._value?.filter(item => this.
|
|
937
|
+
const fieldValue = this._value?.filter(item => this.fieldOptions?.find(opt => opt.fieldOptionId === item));
|
|
915
938
|
this.setAttr(attrs$1._value, fieldValue);
|
|
916
939
|
}
|
|
917
940
|
else {
|
|
918
|
-
const valInOptions = this.
|
|
941
|
+
const valInOptions = this.fieldOptions?.find(item => item.fieldOptionId === this._value);
|
|
919
942
|
if (!valInOptions) {
|
|
920
943
|
this._setValue('');
|
|
921
944
|
}
|
|
922
945
|
}
|
|
923
946
|
}
|
|
924
|
-
if (this._fieldRequired && this.
|
|
925
|
-
this._setValue(this.
|
|
947
|
+
if (this._fieldRequired && this.fieldOptions?.length === 1 && this._value !== this.fieldOptions?.[0].fieldOptionId) {
|
|
948
|
+
this._setValue(this.fieldOptions?.[0].fieldOptionId);
|
|
926
949
|
this.notifyEditionFinish();
|
|
927
950
|
}
|
|
928
951
|
}
|
|
929
|
-
get optionText() { return this.
|
|
952
|
+
get optionText() { return this.fieldOptions?.find(item => item.fieldOptionId === this._value)?.fieldOptionValue ?? null; }
|
|
930
953
|
get outputOnly() { return this._outputOnly; }
|
|
931
954
|
set outputOnly(outputOnly) { this.setAttr(attrs$1._outputOnly, outputOnly); }
|
|
932
955
|
get required() { return this._fieldRequired; }
|
|
@@ -950,14 +973,6 @@ class FieldDescriptor extends FormElement {
|
|
|
950
973
|
set value(newValue) { this._setValue(newValue); }
|
|
951
974
|
get visibleLabel() { return this._visibleLabel; }
|
|
952
975
|
set visibleLabel(visibleLabel) { this.setAttr(attrs$1._visibleLabel, visibleLabel); }
|
|
953
|
-
/**
|
|
954
|
-
* @deprecated Use options
|
|
955
|
-
*/
|
|
956
|
-
get fieldOptions() { return this._fieldOptions; }
|
|
957
|
-
/**
|
|
958
|
-
* @deprecated Use options
|
|
959
|
-
*/
|
|
960
|
-
set fieldOptions(options) { this.options = options; }
|
|
961
976
|
/**
|
|
962
977
|
* @deprecated Use value
|
|
963
978
|
*/
|
|
@@ -1033,7 +1048,7 @@ class FieldDescriptor extends FormElement {
|
|
|
1033
1048
|
setVisibleLabel(visibleLabel) { this.visibleLabel = visibleLabel; }
|
|
1034
1049
|
notifyEditionPartial() {
|
|
1035
1050
|
this.resetError();
|
|
1036
|
-
this._editionPartial.next({ code: this.
|
|
1051
|
+
this._editionPartial.next({ code: this.fieldCode, intrinsicValidation: true });
|
|
1037
1052
|
}
|
|
1038
1053
|
notifyEditionFinish() {
|
|
1039
1054
|
const fieldValue = this.value;
|
|
@@ -1069,10 +1084,10 @@ class FieldDescriptor extends FormElement {
|
|
|
1069
1084
|
intrinsicValidation = false;
|
|
1070
1085
|
this.setError('99', `Longitud de ${this._fieldTitle} debe ser de al menos ${this._minLength}`);
|
|
1071
1086
|
}
|
|
1072
|
-
this._editionFinish.next({ code: this.
|
|
1087
|
+
this._editionFinish.next({ code: this.fieldCode, intrinsicValidation });
|
|
1073
1088
|
}
|
|
1074
1089
|
notifyEditionDetailRequest(detail) {
|
|
1075
|
-
const detailEvent = { code: this.
|
|
1090
|
+
const detailEvent = { code: this.fieldCode, detail };
|
|
1076
1091
|
this._detailRequest.next(detailEvent);
|
|
1077
1092
|
}
|
|
1078
1093
|
setError(code, message, type = DEFAULT_ERROR_TYPE) {
|
|
@@ -1219,6 +1234,9 @@ class RecordTableColumn extends FormPiece {
|
|
|
1219
1234
|
class TableAction extends FormPiece {
|
|
1220
1235
|
constructor(actionDefinition, formConfig) {
|
|
1221
1236
|
super(actionDefinition, formConfig);
|
|
1237
|
+
this.restrictedOnField = null;
|
|
1238
|
+
this.restrictedOnValue = null;
|
|
1239
|
+
this.restrictedOnOperator = null;
|
|
1222
1240
|
this.actionCode = actionDefinition.actionCode;
|
|
1223
1241
|
this.actionTitle = actionDefinition.actionTitle;
|
|
1224
1242
|
this.iconName = actionDefinition.iconName || this.actionCode;
|
|
@@ -1227,9 +1245,11 @@ class TableAction extends FormPiece {
|
|
|
1227
1245
|
this.newState = actionDefinition.newState;
|
|
1228
1246
|
this.stateField = actionDefinition.stateField || '';
|
|
1229
1247
|
this.backend = actionDefinition?.serverAction ?? false;
|
|
1230
|
-
this.restrictedOnField = actionDefinition.fieldRestrictedCode
|
|
1231
|
-
this.
|
|
1232
|
-
|
|
1248
|
+
this.restrictedOnField = actionDefinition.fieldRestrictedCode ?? null;
|
|
1249
|
+
if (this.restrictedOnField) {
|
|
1250
|
+
this.restrictedOnValue = actionDefinition.valueRestricted ?? null;
|
|
1251
|
+
this.restrictedOnOperator = actionDefinition.operatorRestricted || null;
|
|
1252
|
+
}
|
|
1233
1253
|
}
|
|
1234
1254
|
}
|
|
1235
1255
|
|
|
@@ -1748,12 +1768,12 @@ class RecordTable extends FormElement {
|
|
|
1748
1768
|
}
|
|
1749
1769
|
return direction === TABLE_SORT_ASCENDING ? result : -result;
|
|
1750
1770
|
}
|
|
1751
|
-
formStateChangeCustomSubscribe(formChangeSubject) {
|
|
1771
|
+
formStateChangeCustomSubscribe(form, formChangeSubject) {
|
|
1752
1772
|
this.columns?.forEach(column => {
|
|
1753
|
-
column?.
|
|
1773
|
+
column?.connectWithParentForm(form, formChangeSubject);
|
|
1754
1774
|
});
|
|
1755
1775
|
this._actions?.forEach(action => {
|
|
1756
|
-
action?.
|
|
1776
|
+
action?.connectWithParentForm(form, formChangeSubject);
|
|
1757
1777
|
});
|
|
1758
1778
|
}
|
|
1759
1779
|
}
|
|
@@ -1965,9 +1985,9 @@ class RecordFormSection extends FormPiecePropagate {
|
|
|
1965
1985
|
}
|
|
1966
1986
|
return null;
|
|
1967
1987
|
}
|
|
1968
|
-
formStateChangeCustomSubscribe(formChangeSubject) {
|
|
1988
|
+
formStateChangeCustomSubscribe(form, formChangeSubject) {
|
|
1969
1989
|
this.subSections?.forEach(subsection => {
|
|
1970
|
-
subsection?.
|
|
1990
|
+
subsection?.connectWithParentForm(form, formChangeSubject);
|
|
1971
1991
|
});
|
|
1972
1992
|
}
|
|
1973
1993
|
}
|
|
@@ -2254,7 +2274,7 @@ class FormStructureAndData {
|
|
|
2254
2274
|
return this.getFieldSet(fld => fld?.required && fld?.empty, codes ?? null, secCode, subCode);
|
|
2255
2275
|
}
|
|
2256
2276
|
getChangedFields(codes, secCode, subCode) {
|
|
2257
|
-
return this.getFieldSet(fld => !fld?.outputOnly && fld?.hasChanged
|
|
2277
|
+
return this.getFieldSet(fld => !fld?.outputOnly && fld?.hasChanged, codes ?? null, secCode, subCode);
|
|
2258
2278
|
}
|
|
2259
2279
|
getFieldsWithValidationIssues(codes, secCode, subCode) {
|
|
2260
2280
|
return this.getFieldSet(fld => fld?.hasError(), codes ?? null, secCode, subCode);
|
|
@@ -2498,6 +2518,7 @@ class LibFileManagementService {
|
|
|
2498
2518
|
openFile(fileBase64Data, fileName, fileType) { }
|
|
2499
2519
|
saveFileFromURL(fileUrl, fullFileName = null) { }
|
|
2500
2520
|
saveFile(fileBase64Data, fileName, fileType) { }
|
|
2521
|
+
printPdfFile(pdfBufferData) { }
|
|
2501
2522
|
}
|
|
2502
2523
|
|
|
2503
2524
|
const PAYLOAD_VERSION = 'TUAINEXCHANGE_1.0';
|
|
@@ -2790,11 +2811,11 @@ class BasicFormComponent {
|
|
|
2790
2811
|
this.onTableServerError(() => this.displayTableServerError());
|
|
2791
2812
|
}
|
|
2792
2813
|
get formVisible() { return this.visible; }
|
|
2793
|
-
get
|
|
2814
|
+
get form() { return this; }
|
|
2794
2815
|
get formCode() { return this.name ?? ''; }
|
|
2795
2816
|
set formCode(name) { this.name = name; }
|
|
2796
2817
|
get inServerProcess() { return this.busy; }
|
|
2797
|
-
get
|
|
2818
|
+
get formStructure() { return this._formStructure; }
|
|
2798
2819
|
get state() { return this._formStructure?.state ?? null; }
|
|
2799
2820
|
get currentState() { return this._formStructure?.state ?? ''; }
|
|
2800
2821
|
set currentState(state) { this?.changeState(state); }
|
|
@@ -2918,7 +2939,7 @@ class BasicFormComponent {
|
|
|
2918
2939
|
section.activation.subscribe((code) => this.launchSectionActivation(code));
|
|
2919
2940
|
section.inactivation.subscribe((code) => this.launchSectionInactivation(code));
|
|
2920
2941
|
// Adicionalmente se le pide a la sección se subscriba al cambio de estado del formulario
|
|
2921
|
-
section.
|
|
2942
|
+
section.connectWithParentForm(this, this._formStructure?.stateChange);
|
|
2922
2943
|
}
|
|
2923
2944
|
}
|
|
2924
2945
|
subscribeFieldsSubjects() {
|
|
@@ -2935,7 +2956,7 @@ class BasicFormComponent {
|
|
|
2935
2956
|
});
|
|
2936
2957
|
field.detailRequest.subscribe(event => this.showFieldInfo(event.code, event.detail));
|
|
2937
2958
|
// Adicionalmente se le pide al campo se subscriba al cambio de estado del formulario
|
|
2938
|
-
field.
|
|
2959
|
+
field.connectWithParentForm(this, this._formStructure?.stateChange);
|
|
2939
2960
|
});
|
|
2940
2961
|
}
|
|
2941
2962
|
}
|
|
@@ -2945,7 +2966,7 @@ class BasicFormComponent {
|
|
|
2945
2966
|
formActions.forEach(action => {
|
|
2946
2967
|
action.actionActivated.subscribe(code => this.startAction(code));
|
|
2947
2968
|
// Adicionalmente se le pide a la acción se subscriba al cambio de estado del formulario
|
|
2948
|
-
action.
|
|
2969
|
+
action.connectWithParentForm(this, this._formStructure?.stateChange);
|
|
2949
2970
|
});
|
|
2950
2971
|
}
|
|
2951
2972
|
}
|
|
@@ -2959,7 +2980,7 @@ class BasicFormComponent {
|
|
|
2959
2980
|
table.selectionActionTrigger.subscribe(event => this.startTableSelectionAction(event));
|
|
2960
2981
|
table.getDataTrigger.subscribe(event => this.startTableGetData(event));
|
|
2961
2982
|
// Adicionalmente se le pide a la tabla se subscriba al cambio de estado del formulario
|
|
2962
|
-
table.
|
|
2983
|
+
table.connectWithParentForm(this, this._formStructure?.stateChange);
|
|
2963
2984
|
});
|
|
2964
2985
|
}
|
|
2965
2986
|
}
|
|
@@ -3925,7 +3946,11 @@ class BasicFormComponent {
|
|
|
3925
3946
|
for (const columnName of columnNames) {
|
|
3926
3947
|
const columnValue = tableRecord.getFieldValue(columnName) ?? '';
|
|
3927
3948
|
const code = mappingTable?.[columnName] ?? columnName;
|
|
3928
|
-
this.
|
|
3949
|
+
const field = code ? this.getField(code) : null;
|
|
3950
|
+
if (field) {
|
|
3951
|
+
field.setValue(columnValue);
|
|
3952
|
+
field.hasChanged = false;
|
|
3953
|
+
}
|
|
3929
3954
|
}
|
|
3930
3955
|
return true;
|
|
3931
3956
|
}
|