tuain-ng-forms-lib 14.4.95 → 14.5.10

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.
Files changed (35) hide show
  1. package/esm2020/lib/classes/forms/action.mjs +23 -4
  2. package/esm2020/lib/classes/forms/element.mjs +1 -9
  3. package/esm2020/lib/classes/forms/field.mjs +19 -28
  4. package/esm2020/lib/classes/forms/form.mjs +2 -2
  5. package/esm2020/lib/classes/forms/piece.mjs +6 -4
  6. package/esm2020/lib/classes/forms/section.mjs +3 -3
  7. package/esm2020/lib/classes/forms/table/action.mjs +28 -4
  8. package/esm2020/lib/classes/forms/table/table.mjs +4 -4
  9. package/esm2020/lib/components/elements/action.component.mjs +2 -24
  10. package/esm2020/lib/components/elements/layout/element.component.mjs +5 -5
  11. package/esm2020/lib/components/elements/layout/form-header.component.mjs +2 -9
  12. package/esm2020/lib/components/elements/layout/piece.component.mjs +2 -1
  13. package/esm2020/lib/components/elements/layout/section.component.mjs +5 -5
  14. package/esm2020/lib/components/elements/layout/sub-section.component.mjs +5 -5
  15. package/esm2020/lib/components/elements/tables/table-record-action.component.mjs +4 -2
  16. package/esm2020/lib/components/forms/basic-form.mjs +31 -11
  17. package/fesm2015/tuain-ng-forms-lib.mjs +137 -109
  18. package/fesm2015/tuain-ng-forms-lib.mjs.map +1 -1
  19. package/fesm2020/tuain-ng-forms-lib.mjs +126 -104
  20. package/fesm2020/tuain-ng-forms-lib.mjs.map +1 -1
  21. package/lib/classes/forms/action.d.ts +7 -6
  22. package/lib/classes/forms/element.d.ts +0 -8
  23. package/lib/classes/forms/field.d.ts +2 -11
  24. package/lib/classes/forms/piece.d.ts +3 -2
  25. package/lib/classes/forms/section.d.ts +1 -1
  26. package/lib/classes/forms/table/action.d.ts +7 -4
  27. package/lib/classes/forms/table/table.d.ts +1 -1
  28. package/lib/components/elements/action.component.d.ts +1 -6
  29. package/lib/components/elements/layout/element.component.d.ts +1 -2
  30. package/lib/components/elements/layout/form-header.component.d.ts +1 -4
  31. package/lib/components/elements/layout/piece.component.d.ts +2 -0
  32. package/lib/components/elements/layout/section.component.d.ts +1 -2
  33. package/lib/components/elements/layout/sub-section.component.d.ts +1 -2
  34. package/lib/components/forms/basic-form.d.ts +5 -3
  35. package/package.json +1 -1
@@ -15,6 +15,7 @@ class PieceComponent {
15
15
  this.disabled = false;
16
16
  this.customAttributes = {};
17
17
  }
18
+ setForm(form) { this.form = form; }
18
19
  defaultProcessAttributeChange(attribute, value) {
19
20
  if (!attribute || attribute.trim() === '') {
20
21
  return false;
@@ -46,10 +47,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.6", ngImpor
46
47
  }] });
47
48
 
48
49
  class ElementComponent extends PieceComponent {
49
- start() { }
50
+ start() {
51
+ var _a;
52
+ this.setForm((_a = this.element) === null || _a === void 0 ? void 0 : _a._form);
53
+ }
50
54
  }
51
55
  ElementComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: ElementComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
52
- ElementComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.6", type: ElementComponent, selector: "lib-element", inputs: { element: "element", form: "form" }, usesInheritance: true, ngImport: i0, template: `<ng-content></ng-content>`, isInline: true });
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 });
53
57
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: ElementComponent, decorators: [{
54
58
  type: Component,
55
59
  args: [{
@@ -58,8 +62,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.6", ngImpor
58
62
  }]
59
63
  }], propDecorators: { element: [{
60
64
  type: Input
61
- }], form: [{
62
- type: Input
63
65
  }] } });
64
66
 
65
67
  class ActionComponent extends ElementComponent {
@@ -67,8 +69,6 @@ class ActionComponent extends ElementComponent {
67
69
  super(...arguments);
68
70
  this.inProgress = false;
69
71
  this.action = null;
70
- this.style = 'primary';
71
- this.showLabel = true;
72
72
  }
73
73
  ngOnInit() {
74
74
  var _a, _b, _c, _d, _e, _f, _g, _h, _j;
@@ -99,22 +99,9 @@ class ActionComponent extends ElementComponent {
99
99
  this.action.notifyActivation();
100
100
  }
101
101
  }
102
- visibleOnRestriction() {
103
- var _a, _b, _c, _d, _e;
104
- if (!((_a = this.action) === null || _a === void 0 ? void 0 : _a.restrictedOnField)) {
105
- return true;
106
- }
107
- if ((((_b = this.action) === null || _b === void 0 ? void 0 : _b.restrictedOnOperator) === '=='
108
- && this.relatedField === ((_c = this.action) === null || _c === void 0 ? void 0 : _c.restrictedOnValue))
109
- || (((_d = this.action) === null || _d === void 0 ? void 0 : _d.restrictedOnOperator) === '!='
110
- && this.relatedField !== ((_e = this.action) === null || _e === void 0 ? void 0 : _e.restrictedOnValue))) {
111
- return true;
112
- }
113
- return false;
114
- }
115
102
  }
116
103
  ActionComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: ActionComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
117
- ActionComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.6", type: ActionComponent, selector: "lib-action", inputs: { action: "action", busy: "busy", relatedField: "relatedField", style: "style", showLabel: "showLabel" }, usesInheritance: true, ngImport: i0, template: `<ng-content></ng-content>`, isInline: true });
104
+ 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 });
118
105
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: ActionComponent, decorators: [{
119
106
  type: Component,
120
107
  args: [{
@@ -123,14 +110,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.6", ngImpor
123
110
  }]
124
111
  }], propDecorators: { action: [{
125
112
  type: Input
126
- }], busy: [{
127
- type: Input
128
- }], relatedField: [{
129
- type: Input
130
- }], style: [{
131
- type: Input
132
- }], showLabel: [{
133
- type: Input
134
113
  }] } });
135
114
 
136
115
  const VALUE = 'value';
@@ -233,7 +212,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.6", ngImpor
233
212
 
234
213
  class FormHeaderComponent {
235
214
  constructor() {
236
- this.canGoBack = false;
237
215
  this.goBackEvent = new EventEmitter();
238
216
  }
239
217
  goBackForm() {
@@ -241,7 +219,7 @@ class FormHeaderComponent {
241
219
  }
242
220
  }
243
221
  FormHeaderComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: FormHeaderComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
244
- FormHeaderComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.6", type: FormHeaderComponent, selector: "lib-form-header", inputs: { form: "form", canGoBack: "canGoBack", showTitle: "showTitle", headerActions: "headerActions" }, outputs: { goBackEvent: "goBackEvent" }, ngImport: i0, template: `<ng-content></ng-content>`, isInline: true });
222
+ 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 });
245
223
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: FormHeaderComponent, decorators: [{
246
224
  type: Component,
247
225
  args: [{
@@ -250,12 +228,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.6", ngImpor
250
228
  }]
251
229
  }], propDecorators: { form: [{
252
230
  type: Input
253
- }], canGoBack: [{
254
- type: Input
255
- }], showTitle: [{
256
- type: Input
257
- }], headerActions: [{
258
- type: Input
259
231
  }], goBackEvent: [{
260
232
  type: Output
261
233
  }] } });
@@ -279,10 +251,13 @@ class SectionComponent extends PieceComponent {
279
251
  });
280
252
  this.start();
281
253
  }
282
- start() { }
254
+ start() {
255
+ var _a;
256
+ this.setForm((_a = this.section) === null || _a === void 0 ? void 0 : _a._form);
257
+ }
283
258
  }
284
259
  SectionComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: SectionComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
285
- SectionComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.6", type: SectionComponent, selector: "lib-section", inputs: { section: "section", form: "form" }, usesInheritance: true, ngImport: i0, template: `<ng-content></ng-content>`, isInline: true });
260
+ 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 });
286
261
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: SectionComponent, decorators: [{
287
262
  type: Component,
288
263
  args: [{
@@ -291,8 +266,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.6", ngImpor
291
266
  }]
292
267
  }], propDecorators: { section: [{
293
268
  type: Input
294
- }], form: [{
295
- type: Input
296
269
  }] } });
297
270
 
298
271
  class SubSectionComponent extends PieceComponent {
@@ -314,10 +287,13 @@ class SubSectionComponent extends PieceComponent {
314
287
  });
315
288
  this.start();
316
289
  }
317
- start() { }
290
+ start() {
291
+ var _a;
292
+ this.setForm((_a = this.subSection) === null || _a === void 0 ? void 0 : _a._form);
293
+ }
318
294
  }
319
295
  SubSectionComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: SubSectionComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
320
- SubSectionComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.6", type: SubSectionComponent, selector: "lib-subsection", inputs: { subSection: "subSection", form: "form" }, usesInheritance: true, ngImport: i0, template: `<ng-content></ng-content>`, isInline: true });
296
+ 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 });
321
297
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: SubSectionComponent, decorators: [{
322
298
  type: Component,
323
299
  args: [{
@@ -326,8 +302,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.6", ngImpor
326
302
  }]
327
303
  }], propDecorators: { subSection: [{
328
304
  type: Input
329
- }], form: [{
330
- type: Input
331
305
  }] } });
332
306
 
333
307
  const INLINE_ACTION$1 = 'INLINE';
@@ -354,7 +328,10 @@ class LibTableRecordActionComponent extends PieceComponent {
354
328
  });
355
329
  this.start();
356
330
  }
357
- start() { }
331
+ start() {
332
+ var _a;
333
+ (_a = this.action) === null || _a === void 0 ? void 0 : _a.setRecodData(this.recordData);
334
+ }
358
335
  onActivate() {
359
336
  const tableEvent = {
360
337
  actionCode: this.action.actionCode,
@@ -534,6 +511,7 @@ class FormPiece {
534
511
  this._absoluteDisabled = false;
535
512
  this.visibleStates = null;
536
513
  this.enabledStates = null;
514
+ this._form = null;
537
515
  this._visible = true;
538
516
  this._disabled = false;
539
517
  this.customAttributes = {};
@@ -609,7 +587,7 @@ class FormPiece {
609
587
  set disabled(disabled) { this.enabled = !disabled; }
610
588
  enable() { this.enabled = true; }
611
589
  disable() { this.enabled = false; }
612
- formStateChangeCustomSubscribe(formChangeSubject) { }
590
+ formStateChangeCustomSubscribe(form, formChangeSubject) { }
613
591
  formStateChange(state) {
614
592
  if (state) {
615
593
  this._formState = state;
@@ -617,8 +595,9 @@ class FormPiece {
617
595
  this._disabled = this._absoluteDisabled || !this.enabledOnState(state);
618
596
  }
619
597
  }
620
- subscribeFormStateChange(formChangeSubject) {
621
- this.formStateChangeCustomSubscribe(formChangeSubject);
598
+ connectWithParentForm(form, formChangeSubject) {
599
+ this._form = form;
600
+ this.formStateChangeCustomSubscribe(form, formChangeSubject);
622
601
  formChangeSubject.subscribe(event => this.formStateChange(event === null || event === void 0 ? void 0 : event.state));
623
602
  }
624
603
  }
@@ -674,23 +653,18 @@ class FormElement extends FormPiecePropagate {
674
653
  isField() { return this.elementType === elementTypes.field; }
675
654
  isAction() { return this.elementType === elementTypes.action; }
676
655
  isTable() { return this.elementType === elementTypes.table; }
677
- /**
678
- * @deprecated Utilizar viewOnState
679
- */
680
- supportState(state) { return this.viewOnState(state); }
681
- /**
682
- * @deprecated Utilizar viewOnState
683
- */
684
- supportMode(state) { return this.viewOnState(state); }
685
656
  }
686
657
 
687
658
  const HEADER = 'HEADER';
688
659
  class FormAction extends FormElement {
689
660
  constructor(actionDefinition, formConfig) {
690
- var _a, _b, _c, _d, _e;
661
+ var _a, _b, _c, _d, _e, _f, _g;
691
662
  super(actionDefinition, formConfig);
692
663
  this._actionActivated = new Subject();
693
664
  this.inProgress = false;
665
+ this.restrictedOnField = null;
666
+ this.restrictedOnOperator = null;
667
+ this.restrictedOnValue = null;
694
668
  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 : [];
695
669
  this.elementType = elementTypes.action;
696
670
  this.actionCode = actionDefinition.actionCode ? actionDefinition.actionCode.toString() : '';
@@ -699,11 +673,28 @@ class FormAction extends FormElement {
699
673
  this.setCustomAttribute('location', actionDefinition.position || HEADER);
700
674
  this.backend = (_d = actionDefinition === null || actionDefinition === void 0 ? void 0 : actionDefinition.serverAction) !== null && _d !== void 0 ? _d : false;
701
675
  this.newState = actionDefinition === null || actionDefinition === void 0 ? void 0 : actionDefinition.newState;
702
- this.restrictedOnField = actionDefinition.fieldRestrictedCode ? actionDefinition.fieldRestrictedCode.toString() : '';
703
- this.restrictedOnOperator = actionDefinition.operatorRestricted || '';
704
- this.restrictedOnValue = (_e = actionDefinition.valueRestricted) !== null && _e !== void 0 ? _e : '';
676
+ this.restrictedOnField = (_f = (_e = actionDefinition.fieldRestrictedCode) === null || _e === void 0 ? void 0 : _e.toString()) !== null && _f !== void 0 ? _f : null;
677
+ if (this.restrictedOnField) {
678
+ this.restrictedOnOperator = actionDefinition.operatorRestricted || '';
679
+ this.restrictedOnValue = (_g = actionDefinition.valueRestricted) !== null && _g !== void 0 ? _g : '';
680
+ }
705
681
  this.customValidation = () => true;
706
682
  }
683
+ viewOnState(state) {
684
+ var _a;
685
+ const actionVisible = (this.visibleStates && state) ? this.visibleStates.includes(state) : false;
686
+ if (actionVisible && this._form && this.restrictedOnField) {
687
+ const relatedField = (_a = this._form.fields) === null || _a === void 0 ? void 0 : _a[this.restrictedOnField];
688
+ if (relatedField) {
689
+ const fieldValue = relatedField.value;
690
+ if ((this.restrictedOnOperator === '==' && fieldValue !== this.restrictedOnValue)
691
+ || (this.restrictedOnOperator === '!=' && fieldValue === this.restrictedOnValue)) {
692
+ return false;
693
+ }
694
+ }
695
+ }
696
+ return actionVisible;
697
+ }
707
698
  get actionActivated() { return this._actionActivated; }
708
699
  start() { this.inProgress = true; }
709
700
  stop() { this.inProgress = false; }
@@ -738,13 +729,13 @@ const attrs$1 = {
738
729
  _defaultValue: { name: '_defaultValue', propagate: 'defaultValue' },
739
730
  _defaultEditable: { name: '_defaultEditable', propagate: 'defaultEditable' },
740
731
  _fieldAlignment: { name: '_fieldAlignment', propagate: 'alignment' },
741
- _fieldCode: { name: '_fieldCode', propagate: 'code' },
732
+ fieldCode: { name: 'fieldCode', propagate: 'code' },
742
733
  _fieldInfo: { name: '_fieldInfo', propagate: 'info' },
743
734
  _fieldRequired: { name: '_fieldRequired', propagate: 'required' },
744
735
  _fieldTitle: { name: '_fieldTitle', propagate: 'title' },
745
736
  _fieldType: { name: '_fieldType', propagate: 'type' },
746
737
  _fieldFormat: { name: '_fieldFormat', propagate: 'format' },
747
- _fieldOptions: { name: '_fieldOptions', propagate: 'options' },
738
+ fieldOptions: { name: 'fieldOptions', propagate: 'options' },
748
739
  _focus: { name: '_focus', propagate: 'focus' },
749
740
  _hasChanged: { name: '_hasChanged', propagate: 'hasChanged' },
750
741
  _intrinsicErrorMessage: { name: '_intrinsicErrorMessage', propagate: null },
@@ -769,7 +760,6 @@ class FieldDescriptor extends FormElement {
769
760
  this._errorType = '';
770
761
  this._errorCode = '';
771
762
  this._errorMessage = '';
772
- this._fieldCode = '';
773
763
  this._intrinsicErrorMessage = '';
774
764
  this._maxLength = 0;
775
765
  this._minLength = 0;
@@ -786,15 +776,16 @@ class FieldDescriptor extends FormElement {
786
776
  this._fieldTitle = '';
787
777
  this._fieldType = '';
788
778
  this._fieldFormat = null;
789
- this._fieldOptions = null;
790
779
  this._hasChanged = false;
791
780
  this._outputOnly = false;
792
781
  this._tooltipText = '';
782
+ this.fieldCode = '';
783
+ this.fieldOptions = null;
793
784
  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 : [];
794
785
  this.elementType = elementTypes.field;
795
786
  const fld = (inputFieldReceived) ? inputFieldReceived : {};
796
- this.setAttr(attrs$1._fieldCode, fld.fieldCode);
797
- this.title = (_d = fld.fieldTitle) !== null && _d !== void 0 ? _d : this._fieldCode;
787
+ this.setAttr(attrs$1.fieldCode, fld.fieldCode);
788
+ this.title = (_d = fld.fieldTitle) !== null && _d !== void 0 ? _d : this.fieldCode;
798
789
  this.type = fld.fieldTypeCode;
799
790
  this.captureType = (_e = fld.captureType) !== null && _e !== void 0 ? _e : DEFAULT_CAPTURE_TYPE;
800
791
  const defaultValue = (_f = fld.defaultValue) !== null && _f !== void 0 ? _f : null;
@@ -836,8 +827,7 @@ class FieldDescriptor extends FormElement {
836
827
  get backend() { return this._validateOnServer; }
837
828
  get captureType() { return this._captureType; }
838
829
  set captureType(captureType) { this.setAttr(attrs$1._captureType, captureType); }
839
- get code() { return this._fieldCode; }
840
- get fieldCode() { return this._fieldCode; }
830
+ get code() { return this.fieldCode; }
841
831
  get defaultValue() { return this._defaultValue; }
842
832
  set defaultValue(defaultValue) { this.setAttr(attrs$1._defaultValue, defaultValue); }
843
833
  get defaultEditable() { return this._defaultEditable; }
@@ -902,10 +892,10 @@ class FieldDescriptor extends FormElement {
902
892
  }
903
893
  this.setAttr(attrs$1._minValue, minValue);
904
894
  }
905
- get name() { return this._fieldCode; }
895
+ get name() { return this.fieldCode; }
906
896
  get options() {
907
897
  var _a, _b;
908
- return (_b = (_a = this._fieldOptions) === null || _a === void 0 ? void 0 : _a.map(option => {
898
+ return (_b = (_a = this.fieldOptions) === null || _a === void 0 ? void 0 : _a.map(option => {
909
899
  const optionCopy = Object.assign({}, option);
910
900
  return optionCopy;
911
901
  })) !== null && _b !== void 0 ? _b : null;
@@ -926,25 +916,25 @@ class FieldDescriptor extends FormElement {
926
916
  });
927
917
  fieldOptions = (fieldOptions && Array.isArray(fieldOptions)
928
918
  && fieldOptions.length > 0) ? fieldOptions : [];
929
- this.setAttr(attrs$1._fieldOptions, fieldOptions);
919
+ this.setAttr(attrs$1.fieldOptions, fieldOptions);
930
920
  if (this._value) {
931
921
  if (this._fieldType === this._formConfig.fieldTypes.array && Array.isArray(this._value)) {
932
- 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); });
922
+ 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); });
933
923
  this.setAttr(attrs$1._value, fieldValue);
934
924
  }
935
925
  else {
936
- const valInOptions = (_b = this._fieldOptions) === null || _b === void 0 ? void 0 : _b.find(item => item.fieldOptionId === this._value);
926
+ const valInOptions = (_b = this.fieldOptions) === null || _b === void 0 ? void 0 : _b.find(item => item.fieldOptionId === this._value);
937
927
  if (!valInOptions) {
938
928
  this._setValue('');
939
929
  }
940
930
  }
941
931
  }
942
- 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)) {
943
- this._setValue((_e = this._fieldOptions) === null || _e === void 0 ? void 0 : _e[0].fieldOptionId);
932
+ 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)) {
933
+ this._setValue((_e = this.fieldOptions) === null || _e === void 0 ? void 0 : _e[0].fieldOptionId);
944
934
  this.notifyEditionFinish();
945
935
  }
946
936
  }
947
- 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; }
937
+ 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; }
948
938
  get outputOnly() { return this._outputOnly; }
949
939
  set outputOnly(outputOnly) { this.setAttr(attrs$1._outputOnly, outputOnly); }
950
940
  get required() { return this._fieldRequired; }
@@ -968,14 +958,6 @@ class FieldDescriptor extends FormElement {
968
958
  set value(newValue) { this._setValue(newValue); }
969
959
  get visibleLabel() { return this._visibleLabel; }
970
960
  set visibleLabel(visibleLabel) { this.setAttr(attrs$1._visibleLabel, visibleLabel); }
971
- /**
972
- * @deprecated Use options
973
- */
974
- get fieldOptions() { return this._fieldOptions; }
975
- /**
976
- * @deprecated Use options
977
- */
978
- set fieldOptions(options) { this.options = options; }
979
961
  /**
980
962
  * @deprecated Use value
981
963
  */
@@ -1051,7 +1033,7 @@ class FieldDescriptor extends FormElement {
1051
1033
  setVisibleLabel(visibleLabel) { this.visibleLabel = visibleLabel; }
1052
1034
  notifyEditionPartial() {
1053
1035
  this.resetError();
1054
- this._editionPartial.next({ code: this._fieldCode, intrinsicValidation: true });
1036
+ this._editionPartial.next({ code: this.fieldCode, intrinsicValidation: true });
1055
1037
  }
1056
1038
  notifyEditionFinish() {
1057
1039
  var _a, _b, _c, _d, _e;
@@ -1088,10 +1070,10 @@ class FieldDescriptor extends FormElement {
1088
1070
  intrinsicValidation = false;
1089
1071
  this.setError('99', `Longitud de ${this._fieldTitle} debe ser de al menos ${this._minLength}`);
1090
1072
  }
1091
- this._editionFinish.next({ code: this._fieldCode, intrinsicValidation });
1073
+ this._editionFinish.next({ code: this.fieldCode, intrinsicValidation });
1092
1074
  }
1093
1075
  notifyEditionDetailRequest(detail) {
1094
- const detailEvent = { code: this._fieldCode, detail };
1076
+ const detailEvent = { code: this.fieldCode, detail };
1095
1077
  this._detailRequest.next(detailEvent);
1096
1078
  }
1097
1079
  setError(code, message, type = DEFAULT_ERROR_TYPE) {
@@ -1242,8 +1224,11 @@ class RecordTableColumn extends FormPiece {
1242
1224
 
1243
1225
  class TableAction extends FormPiece {
1244
1226
  constructor(actionDefinition, formConfig) {
1245
- var _a, _b;
1227
+ var _a, _b, _c;
1246
1228
  super(actionDefinition, formConfig);
1229
+ this.restrictedOnField = null;
1230
+ this.restrictedOnValue = null;
1231
+ this.restrictedOnOperator = null;
1247
1232
  this.actionCode = actionDefinition.actionCode;
1248
1233
  this.actionTitle = actionDefinition.actionTitle;
1249
1234
  this.iconName = actionDefinition.iconName || this.actionCode;
@@ -1252,9 +1237,31 @@ class TableAction extends FormPiece {
1252
1237
  this.newState = actionDefinition.newState;
1253
1238
  this.stateField = actionDefinition.stateField || '';
1254
1239
  this.backend = (_a = actionDefinition === null || actionDefinition === void 0 ? void 0 : actionDefinition.serverAction) !== null && _a !== void 0 ? _a : false;
1255
- this.restrictedOnField = actionDefinition.fieldRestrictedCode || '';
1256
- this.restrictedOnValue = (_b = actionDefinition.valueRestricted) !== null && _b !== void 0 ? _b : '';
1257
- this.restrictedOnOperator = actionDefinition.operatorRestricted || '';
1240
+ this.restrictedOnField = (_b = actionDefinition.fieldRestrictedCode) !== null && _b !== void 0 ? _b : null;
1241
+ if (this.restrictedOnField) {
1242
+ this.restrictedOnValue = (_c = actionDefinition.valueRestricted) !== null && _c !== void 0 ? _c : null;
1243
+ this.restrictedOnOperator = actionDefinition.operatorRestricted || null;
1244
+ }
1245
+ }
1246
+ viewOnState(state) {
1247
+ var _a;
1248
+ const actionVisible = (this.visibleStates && state) ? this.visibleStates.includes(state) : false;
1249
+ if (actionVisible && this._form && this.restrictedOnField) {
1250
+ // Aqui se debe cambiar el campo por la columna del registro!!!!!
1251
+ // const relatedField = this._form.fields?.[this.restrictedOnField];
1252
+ const relatedField = (_a = this.recordData) === null || _a === void 0 ? void 0 : _a[this.restrictedOnField];
1253
+ if (relatedField) {
1254
+ const fieldValue = relatedField.value;
1255
+ if ((this.restrictedOnOperator === '==' && fieldValue !== this.restrictedOnValue)
1256
+ || (this.restrictedOnOperator === '!=' && fieldValue === this.restrictedOnValue)) {
1257
+ return false;
1258
+ }
1259
+ }
1260
+ }
1261
+ return actionVisible;
1262
+ }
1263
+ setRecodData(recordData) {
1264
+ this.recordData = recordData;
1258
1265
  }
1259
1266
  }
1260
1267
 
@@ -1774,13 +1781,13 @@ class RecordTable extends FormElement {
1774
1781
  }
1775
1782
  return direction === TABLE_SORT_ASCENDING ? result : -result;
1776
1783
  }
1777
- formStateChangeCustomSubscribe(formChangeSubject) {
1784
+ formStateChangeCustomSubscribe(form, formChangeSubject) {
1778
1785
  var _a, _b;
1779
1786
  (_a = this.columns) === null || _a === void 0 ? void 0 : _a.forEach(column => {
1780
- column === null || column === void 0 ? void 0 : column.subscribeFormStateChange(formChangeSubject);
1787
+ column === null || column === void 0 ? void 0 : column.connectWithParentForm(form, formChangeSubject);
1781
1788
  });
1782
1789
  (_b = this._actions) === null || _b === void 0 ? void 0 : _b.forEach(action => {
1783
- action === null || action === void 0 ? void 0 : action.subscribeFormStateChange(formChangeSubject);
1790
+ action === null || action === void 0 ? void 0 : action.connectWithParentForm(form, formChangeSubject);
1784
1791
  });
1785
1792
  }
1786
1793
  }
@@ -1997,10 +2004,10 @@ class RecordFormSection extends FormPiecePropagate {
1997
2004
  }
1998
2005
  return null;
1999
2006
  }
2000
- formStateChangeCustomSubscribe(formChangeSubject) {
2007
+ formStateChangeCustomSubscribe(form, formChangeSubject) {
2001
2008
  var _a;
2002
2009
  (_a = this.subSections) === null || _a === void 0 ? void 0 : _a.forEach(subsection => {
2003
- subsection === null || subsection === void 0 ? void 0 : subsection.subscribeFormStateChange(formChangeSubject);
2010
+ subsection === null || subsection === void 0 ? void 0 : subsection.connectWithParentForm(form, formChangeSubject);
2004
2011
  });
2005
2012
  }
2006
2013
  }
@@ -2291,7 +2298,7 @@ class FormStructureAndData {
2291
2298
  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);
2292
2299
  }
2293
2300
  getChangedFields(codes, secCode, subCode) {
2294
- 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);
2301
+ 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);
2295
2302
  }
2296
2303
  getFieldsWithValidationIssues(codes, secCode, subCode) {
2297
2304
  return this.getFieldSet(fld => fld === null || fld === void 0 ? void 0 : fld.hasError(), codes !== null && codes !== void 0 ? codes : null, secCode, subCode);
@@ -2565,6 +2572,7 @@ class BasicFormComponent {
2565
2572
  this._formRoute = null;
2566
2573
  this._definitionObtained = false;
2567
2574
  // Eventos de acciones y campos
2575
+ this._formChangeState = [];
2568
2576
  this._formSectionsCanDeactivate = {};
2569
2577
  this._formSectionsActivate = {};
2570
2578
  this._formSectionsInactivate = {};
@@ -2607,7 +2615,6 @@ class BasicFormComponent {
2607
2615
  cleanData() { var _a; return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.cleanData(); }
2608
2616
  getCurrentState() { var _a; return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.getCurrentState(); }
2609
2617
  supportState(state) { var _a, _b; return (_b = (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.supportState(state !== null && state !== void 0 ? state : '')) !== null && _b !== void 0 ? _b : false; }
2610
- changeState(state) { var _a, _b; return (_b = (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.changeState(state)) !== null && _b !== void 0 ? _b : false; }
2611
2618
  getStates() { var _a; return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.states; }
2612
2619
  getImmutableElement(name) { var _a; return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.getImmutableElement(name); }
2613
2620
  getExtraInfo(name) { var _a; return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.getExtraInfo(name); }
@@ -2868,6 +2875,7 @@ class BasicFormComponent {
2868
2875
  // Se limpian los manejadores de eventos
2869
2876
  this.visible = false;
2870
2877
  this.busy = false;
2878
+ this._formChangeState = [];
2871
2879
  this._formSectionsCanDeactivate = {};
2872
2880
  this._formSectionsActivate = {};
2873
2881
  this._formSectionsInactivate = {};
@@ -2890,14 +2898,14 @@ class BasicFormComponent {
2890
2898
  this.onTableServerError(() => this.displayTableServerError());
2891
2899
  }
2892
2900
  get formVisible() { return this.visible; }
2893
- get formManager() { return this; }
2901
+ get form() { return this; }
2894
2902
  get formCode() { var _a; return (_a = this.name) !== null && _a !== void 0 ? _a : ''; }
2895
2903
  set formCode(name) { this.name = name; }
2896
2904
  get inServerProcess() { return this.busy; }
2897
- get form() { return this._formStructure; }
2905
+ get formStructure() { return this._formStructure; }
2898
2906
  get state() { var _a, _b; return (_b = (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.state) !== null && _b !== void 0 ? _b : null; }
2899
2907
  get currentState() { var _a, _b; return (_b = (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.state) !== null && _b !== void 0 ? _b : ''; }
2900
- set currentState(state) { var _a; (_a = this === null || this === void 0 ? void 0 : this._formStructure) === null || _a === void 0 ? void 0 : _a.changeState(state); }
2908
+ set currentState(state) { this === null || this === void 0 ? void 0 : this.changeState(state); }
2901
2909
  get immutableData() { var _a; return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.immutableData; }
2902
2910
  get extraInfo() { var _a; return (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.extraInfo; }
2903
2911
  get visibleSections() { var _a, _b; return (_b = (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.visibleSections) !== null && _b !== void 0 ? _b : null; }
@@ -3022,7 +3030,7 @@ class BasicFormComponent {
3022
3030
  section.activation.subscribe((code) => this.launchSectionActivation(code));
3023
3031
  section.inactivation.subscribe((code) => this.launchSectionInactivation(code));
3024
3032
  // Adicionalmente se le pide a la sección se subscriba al cambio de estado del formulario
3025
- section.subscribeFormStateChange((_b = this._formStructure) === null || _b === void 0 ? void 0 : _b.stateChange);
3033
+ section.connectWithParentForm(this, (_b = this._formStructure) === null || _b === void 0 ? void 0 : _b.stateChange);
3026
3034
  }
3027
3035
  }
3028
3036
  subscribeFieldsSubjects() {
@@ -3041,7 +3049,7 @@ class BasicFormComponent {
3041
3049
  });
3042
3050
  field.detailRequest.subscribe(event => this.showFieldInfo(event.code, event.detail));
3043
3051
  // Adicionalmente se le pide al campo se subscriba al cambio de estado del formulario
3044
- field.subscribeFormStateChange((_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.stateChange);
3052
+ field.connectWithParentForm(this, (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.stateChange);
3045
3053
  });
3046
3054
  }
3047
3055
  }
@@ -3053,7 +3061,7 @@ class BasicFormComponent {
3053
3061
  var _a;
3054
3062
  action.actionActivated.subscribe(code => this.startAction(code));
3055
3063
  // Adicionalmente se le pide a la acción se subscriba al cambio de estado del formulario
3056
- action.subscribeFormStateChange((_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.stateChange);
3064
+ action.connectWithParentForm(this, (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.stateChange);
3057
3065
  });
3058
3066
  }
3059
3067
  }
@@ -3069,12 +3077,12 @@ class BasicFormComponent {
3069
3077
  table.selectionActionTrigger.subscribe(event => this.startTableSelectionAction(event));
3070
3078
  table.getDataTrigger.subscribe(event => this.startTableGetData(event));
3071
3079
  // Adicionalmente se le pide a la tabla se subscriba al cambio de estado del formulario
3072
- table.subscribeFormStateChange((_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.stateChange);
3080
+ table.connectWithParentForm(this, (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.stateChange);
3073
3081
  });
3074
3082
  }
3075
3083
  }
3076
3084
  formInit(params, forceReload = false) {
3077
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
3085
+ var _a, _b, _c, _d, _e, _f, _g, _h;
3078
3086
  return __awaiter(this, void 0, void 0, function* () {
3079
3087
  let initialState = this.preocessInputParams(params);
3080
3088
  if (!this.name) {
@@ -3107,15 +3115,28 @@ class BasicFormComponent {
3107
3115
  this.subscribeActionSubjects();
3108
3116
  this.subscribeTableSubjects();
3109
3117
  // Se define el estado inicial y se solicita la acción inicial
3110
- (_f = this._formStructure) === null || _f === void 0 ? void 0 : _f.changeState(initialState || ((_g = this._formStructure) === null || _g === void 0 ? void 0 : _g.defaultState));
3118
+ this.changeState(initialState || ((_f = this._formStructure) === null || _f === void 0 ? void 0 : _f.defaultState));
3111
3119
  const recordResponse = yield this.requestFormAction(formActions.getData);
3112
3120
  this.checkErrorRecordReceived(recordResponse);
3113
3121
  this.visible = true;
3114
- this.enabledSections = (_j = (_h = this._formStructure) === null || _h === void 0 ? void 0 : _h.visibleSections) !== null && _j !== void 0 ? _j : [];
3122
+ this.enabledSections = (_h = (_g = this._formStructure) === null || _g === void 0 ? void 0 : _g.visibleSections) !== null && _h !== void 0 ? _h : [];
3115
3123
  this.start();
3116
3124
  this.customFormStart();
3117
3125
  });
3118
3126
  }
3127
+ changeState(state) {
3128
+ var _a, _b;
3129
+ const stateChanged = (_b = (_a = this._formStructure) === null || _a === void 0 ? void 0 : _a.changeState(state !== null && state !== void 0 ? state : '')) !== null && _b !== void 0 ? _b : false;
3130
+ if (stateChanged) {
3131
+ const clientActionMethods = this._formChangeState;
3132
+ if (clientActionMethods && clientActionMethods.length > 0) {
3133
+ for (const callback of clientActionMethods) {
3134
+ callback(state);
3135
+ }
3136
+ }
3137
+ }
3138
+ return stateChanged;
3139
+ }
3119
3140
  checkErrorRecordReceived(recordResponse) {
3120
3141
  const { error } = recordResponse;
3121
3142
  if (!error) {
@@ -3230,6 +3251,9 @@ class BasicFormComponent {
3230
3251
  /**
3231
3252
  * Manejo de event handlers para acciones sobre el formulario
3232
3253
  */
3254
+ onFormChange(callback) {
3255
+ this._formChangeState.push(callback);
3256
+ }
3233
3257
  onSectionCanDeactivate(codes, callback, properties = null) {
3234
3258
  const sectionSet = (Array.isArray(codes)) ? codes : (codes ? [codes] : []);
3235
3259
  sectionSet.forEach((sectionName) => {
@@ -4094,7 +4118,11 @@ class BasicFormComponent {
4094
4118
  for (const columnName of columnNames) {
4095
4119
  const columnValue = (_a = tableRecord.getFieldValue(columnName)) !== null && _a !== void 0 ? _a : '';
4096
4120
  const code = (_b = mappingTable === null || mappingTable === void 0 ? void 0 : mappingTable[columnName]) !== null && _b !== void 0 ? _b : columnName;
4097
- this.setFieldValue(code, columnValue);
4121
+ const field = code ? this.getField(code) : null;
4122
+ if (field) {
4123
+ field.setValue(columnValue);
4124
+ field.hasChanged = false;
4125
+ }
4098
4126
  }
4099
4127
  return true;
4100
4128
  }