tuain-ng-forms-lib 14.4.91 → 14.4.95

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.
@@ -8,15 +8,32 @@ import { CommonModule } from '@angular/common';
8
8
  import { RouterModule } from '@angular/router';
9
9
  import { FormsModule } from '@angular/forms';
10
10
 
11
+ const CUSTOM_ATTRIBUTES = 'customAttributes';
11
12
  class PieceComponent {
12
13
  constructor() {
13
14
  this.visible = true;
14
15
  this.disabled = false;
16
+ this.customAttributes = {};
15
17
  }
16
18
  defaultProcessAttributeChange(attribute, value) {
17
- attribute && (this[attribute] = value);
19
+ if (!attribute || attribute.trim() === '') {
20
+ return false;
21
+ }
22
+ const attributeParts = attribute.split('.');
23
+ if ((attributeParts === null || attributeParts === void 0 ? void 0 : attributeParts.length) > 1) {
24
+ const [attributeType, subAttribute] = attributeParts;
25
+ if (attributeType === CUSTOM_ATTRIBUTES) {
26
+ this.customAttributes[subAttribute] = value;
27
+ this.customAttributeChange(subAttribute, value);
28
+ }
29
+ }
30
+ else {
31
+ this[attribute] = value;
32
+ }
33
+ return true;
18
34
  }
19
35
  customProcessAttributeChange(attribute, value) { }
36
+ customAttributeChange(subAttribute, value) { }
20
37
  }
21
38
  PieceComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.6", ngImport: i0, type: PieceComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
22
39
  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 });
@@ -160,8 +177,9 @@ class FieldComponent extends ElementComponent {
160
177
  this.focus();
161
178
  }
162
179
  else {
163
- this[attribute] = value;
180
+ return super.defaultProcessAttributeChange(attribute, value);
164
181
  }
182
+ return true;
165
183
  }
166
184
  updateValue() { var _a; this.value = (_a = this.field) === null || _a === void 0 ? void 0 : _a.value; }
167
185
  onInputChange() { setTimeout(() => { var _a; return (_a = this.field) === null || _a === void 0 ? void 0 : _a.notifyEditionPartial(); }, 50); }
@@ -445,15 +463,11 @@ class LibTableComponent extends ElementComponent {
445
463
  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'); }
446
464
  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); }
447
465
  defaultProcessAttributeChange(attribute, value) {
448
- if (!attribute) {
449
- return false;
450
- }
451
466
  try {
452
467
  if (attribute === 'visibleRecords') {
453
468
  this.updateTableData();
454
469
  }
455
- this[attribute] = value;
456
- return true;
470
+ return super.defaultProcessAttributeChange(attribute, value);
457
471
  }
458
472
  catch (_a) {
459
473
  return false;
@@ -614,6 +628,7 @@ const DISABLED = 'disabled';
614
628
  class FormPiecePropagate extends FormPiece {
615
629
  constructor(pieceDefinition, formConfig) {
616
630
  super(pieceDefinition, formConfig);
631
+ this.propagationCustomAttributes = [];
617
632
  this._attributeChange = new BehaviorSubject(null);
618
633
  }
619
634
  get attributeChange() { return this._attributeChange; }
@@ -621,6 +636,13 @@ class FormPiecePropagate extends FormPiece {
621
636
  var _a;
622
637
  (_a = this._attributeChange) === null || _a === void 0 ? void 0 : _a.next({ name, value });
623
638
  }
639
+ setCustomAttribute(name, value) {
640
+ var _a;
641
+ super.setCustomAttribute(name, value);
642
+ if ((_a = this.propagationCustomAttributes) === null || _a === void 0 ? void 0 : _a.includes(name)) {
643
+ this.propagateAttribute(name, value);
644
+ }
645
+ }
624
646
  setVisibility(visible, forced = null) {
625
647
  super.setVisibility(visible, forced);
626
648
  this.propagateAttribute(VISIBLE, this._visible);
@@ -665,20 +687,21 @@ class FormElement extends FormPiecePropagate {
665
687
  const HEADER = 'HEADER';
666
688
  class FormAction extends FormElement {
667
689
  constructor(actionDefinition, formConfig) {
668
- var _a, _b;
690
+ var _a, _b, _c, _d, _e;
669
691
  super(actionDefinition, formConfig);
670
692
  this._actionActivated = new Subject();
671
693
  this.inProgress = false;
694
+ 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 : [];
672
695
  this.elementType = elementTypes.action;
673
696
  this.actionCode = actionDefinition.actionCode ? actionDefinition.actionCode.toString() : '';
674
697
  this.actionName = actionDefinition.actionTitle;
675
698
  this.iconName = actionDefinition.iconName || this.actionCode;
676
699
  this.setCustomAttribute('location', actionDefinition.position || HEADER);
677
- this.backend = (_a = actionDefinition === null || actionDefinition === void 0 ? void 0 : actionDefinition.serverAction) !== null && _a !== void 0 ? _a : false;
700
+ this.backend = (_d = actionDefinition === null || actionDefinition === void 0 ? void 0 : actionDefinition.serverAction) !== null && _d !== void 0 ? _d : false;
678
701
  this.newState = actionDefinition === null || actionDefinition === void 0 ? void 0 : actionDefinition.newState;
679
702
  this.restrictedOnField = actionDefinition.fieldRestrictedCode ? actionDefinition.fieldRestrictedCode.toString() : '';
680
703
  this.restrictedOnOperator = actionDefinition.operatorRestricted || '';
681
- this.restrictedOnValue = (_b = actionDefinition.valueRestricted) !== null && _b !== void 0 ? _b : '';
704
+ this.restrictedOnValue = (_e = actionDefinition.valueRestricted) !== null && _e !== void 0 ? _e : '';
682
705
  this.customValidation = () => true;
683
706
  }
684
707
  get actionActivated() { return this._actionActivated; }
@@ -738,7 +761,7 @@ const attrs$1 = {
738
761
  };
739
762
  class FieldDescriptor extends FormElement {
740
763
  constructor(inputFieldReceived, formConfig) {
741
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
764
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
742
765
  super(inputFieldReceived, formConfig);
743
766
  this._editionFinish = new Subject();
744
767
  this._editionPartial = new Subject();
@@ -767,13 +790,14 @@ class FieldDescriptor extends FormElement {
767
790
  this._hasChanged = false;
768
791
  this._outputOnly = false;
769
792
  this._tooltipText = '';
793
+ 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 : [];
770
794
  this.elementType = elementTypes.field;
771
795
  const fld = (inputFieldReceived) ? inputFieldReceived : {};
772
796
  this.setAttr(attrs$1._fieldCode, fld.fieldCode);
773
- this.title = (_a = fld.fieldTitle) !== null && _a !== void 0 ? _a : this._fieldCode;
797
+ this.title = (_d = fld.fieldTitle) !== null && _d !== void 0 ? _d : this._fieldCode;
774
798
  this.type = fld.fieldTypeCode;
775
- this.captureType = (_b = fld.captureType) !== null && _b !== void 0 ? _b : DEFAULT_CAPTURE_TYPE;
776
- const defaultValue = (_c = fld.defaultValue) !== null && _c !== void 0 ? _c : null;
799
+ this.captureType = (_e = fld.captureType) !== null && _e !== void 0 ? _e : DEFAULT_CAPTURE_TYPE;
800
+ const defaultValue = (_f = fld.defaultValue) !== null && _f !== void 0 ? _f : null;
777
801
  if (this._fieldType === this._formConfig.fieldTypes.boolean) {
778
802
  this.defaultValue = defaultValue !== null && defaultValue !== void 0 ? defaultValue : false;
779
803
  }
@@ -793,19 +817,19 @@ class FieldDescriptor extends FormElement {
793
817
  fieldFormat = null;
794
818
  }
795
819
  this.format = fieldFormat;
796
- this.validateOnServer = (_d = fld.serverAction) !== null && _d !== void 0 ? _d : false;
820
+ this.validateOnServer = (_g = fld.serverAction) !== null && _g !== void 0 ? _g : false;
797
821
  this.tooltip = fld.tooltip || '';
798
822
  this.defaultEditable = this.enabled;
799
- this.required = (_e = fld.required) !== null && _e !== void 0 ? _e : false;
800
- this.outputOnly = (_f = fld.outputOnly) !== null && _f !== void 0 ? _f : false;
823
+ this.required = (_h = fld.required) !== null && _h !== void 0 ? _h : false;
824
+ this.outputOnly = (_j = fld.outputOnly) !== null && _j !== void 0 ? _j : false;
801
825
  this.maxLength = fld.maxLength || (this._captureType === 'TEXTAREA' ? BIG_MAX_LENGTH : STD_MAX_LENGTH);
802
- this.intrinsicErrorMessage = (_p = (_k = (_j = (_h = (_g = this._formConfig) === null || _g === void 0 ? void 0 : _g.fieldValidations) === null || _h === void 0 ? void 0 : _h[this._fieldType]) === null || _j === void 0 ? void 0 : _j.message) !== null && _k !== void 0 ? _k : (_o = (_m = (_l = this._formConfig) === null || _l === void 0 ? void 0 : _l.fieldValidations) === null || _m === void 0 ? void 0 : _m.DEFAULT) === null || _o === void 0 ? void 0 : _o.message) !== null && _p !== void 0 ? _p : '';
803
- this.setError(fld.errorCode, fld.errorMessage, (_q = fld.errorType) !== null && _q !== void 0 ? _q : DEFAULT_ERROR_TYPE);
804
- this.setEditable((_r = fld.editable) !== null && _r !== void 0 ? _r : true);
805
- this.visibleLabel = (_s = fld.visibleLabel) !== null && _s !== void 0 ? _s : true;
826
+ this.intrinsicErrorMessage = (_s = (_o = (_m = (_l = (_k = this._formConfig) === null || _k === void 0 ? void 0 : _k.fieldValidations) === null || _l === void 0 ? void 0 : _l[this._fieldType]) === null || _m === void 0 ? void 0 : _m.message) !== null && _o !== void 0 ? _o : (_r = (_q = (_p = this._formConfig) === null || _p === void 0 ? void 0 : _p.fieldValidations) === null || _q === void 0 ? void 0 : _q.DEFAULT) === null || _r === void 0 ? void 0 : _r.message) !== null && _s !== void 0 ? _s : '';
827
+ this.setError(fld.errorCode, fld.errorMessage, (_t = fld.errorType) !== null && _t !== void 0 ? _t : DEFAULT_ERROR_TYPE);
828
+ this.setEditable((_u = fld.editable) !== null && _u !== void 0 ? _u : true);
829
+ this.visibleLabel = (_v = fld.visibleLabel) !== null && _v !== void 0 ? _v : true;
806
830
  this.setVisibility(fld.visible);
807
831
  this.options = fld.fieldOptions;
808
- this._setValue((_u = (_t = fld.fieldValue) !== null && _t !== void 0 ? _t : this._defaultValue) !== null && _u !== void 0 ? _u : '');
832
+ this._setValue((_x = (_w = fld.fieldValue) !== null && _w !== void 0 ? _w : this._defaultValue) !== null && _x !== void 0 ? _x : '');
809
833
  }
810
834
  get alignment() { return this._fieldAlignment; }
811
835
  set alignment(alignment) { this.setAttr(attrs$1._fieldAlignment, alignment); }
@@ -1368,7 +1392,7 @@ const attrs = {
1368
1392
  };
1369
1393
  class RecordTable extends FormElement {
1370
1394
  constructor(tableReceived, formConfig) {
1371
- var _a, _b, _c, _d, _e, _f;
1395
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
1372
1396
  super(tableReceived, formConfig);
1373
1397
  this._inlineActionTrigger = new Subject();
1374
1398
  this._globalActionTrigger = new Subject();
@@ -1389,6 +1413,7 @@ class RecordTable extends FormElement {
1389
1413
  this.totalRecordsNumber = 0;
1390
1414
  this.recordsNumber = 0;
1391
1415
  this.clientPaging = true;
1416
+ 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 : [];
1392
1417
  this.elementType = elementTypes.table;
1393
1418
  this.waiting = false;
1394
1419
  this.currentPage = 1;
@@ -1402,14 +1427,14 @@ class RecordTable extends FormElement {
1402
1427
  this.globalSearch = false;
1403
1428
  this.restrictedId = null;
1404
1429
  this.tableTitle = tableReceived.tableTitle;
1405
- this._appendPages = (_a = tableReceived === null || tableReceived === void 0 ? void 0 : tableReceived.append) !== null && _a !== void 0 ? _a : false;
1406
- this.selectable = (_b = tableReceived === null || tableReceived === void 0 ? void 0 : tableReceived.selectable) !== null && _b !== void 0 ? _b : false;
1407
- this.selectionBackend = (_c = tableReceived === null || tableReceived === void 0 ? void 0 : tableReceived.selectionBackend) !== null && _c !== void 0 ? _c : false;
1408
- this.sortable = (_d = tableReceived === null || tableReceived === void 0 ? void 0 : tableReceived.sortable) !== null && _d !== void 0 ? _d : false;
1430
+ this._appendPages = (_d = tableReceived === null || tableReceived === void 0 ? void 0 : tableReceived.append) !== null && _d !== void 0 ? _d : false;
1431
+ this.selectable = (_e = tableReceived === null || tableReceived === void 0 ? void 0 : tableReceived.selectable) !== null && _e !== void 0 ? _e : false;
1432
+ this.selectionBackend = (_f = tableReceived === null || tableReceived === void 0 ? void 0 : tableReceived.selectionBackend) !== null && _f !== void 0 ? _f : false;
1433
+ this.sortable = (_g = tableReceived === null || tableReceived === void 0 ? void 0 : tableReceived.sortable) !== null && _g !== void 0 ? _g : false;
1409
1434
  this.setAttr(attrs.allSelected, false);
1410
1435
  this.setAttr(attrs.tableCode, tableReceived.tableCode);
1411
- this.setAttr(attrs.clientPaging, (_e = tableReceived === null || tableReceived === void 0 ? void 0 : tableReceived.clientPaging) !== null && _e !== void 0 ? _e : true);
1412
- this.setAttr(attrs.globalSearch, (_f = tableReceived === null || tableReceived === void 0 ? void 0 : tableReceived.simpleFilter) !== null && _f !== void 0 ? _f : false);
1436
+ this.setAttr(attrs.clientPaging, (_h = tableReceived === null || tableReceived === void 0 ? void 0 : tableReceived.clientPaging) !== null && _h !== void 0 ? _h : true);
1437
+ this.setAttr(attrs.globalSearch, (_j = tableReceived === null || tableReceived === void 0 ? void 0 : tableReceived.simpleFilter) !== null && _j !== void 0 ? _j : false);
1413
1438
  this.setAttr(attrs.globalFilterString, '');
1414
1439
  this.setAttr(attrs.sorting, { columnName: '', direction: '' });
1415
1440
  this.setAttr(attrs.recordsPerPage, formConfig.defaultRecordsPerPage);
@@ -1762,6 +1787,7 @@ class RecordTable extends FormElement {
1762
1787
 
1763
1788
  class RecordFormSubSection extends FormPiecePropagate {
1764
1789
  constructor(subsectionReceived, formObject, formConfig) {
1790
+ var _a, _b, _c;
1765
1791
  super(subsectionReceived, formConfig);
1766
1792
  this._customRender = null;
1767
1793
  this.subsectionId = null;
@@ -1773,6 +1799,7 @@ class RecordFormSubSection extends FormPiecePropagate {
1773
1799
  this.subSectionActions = [];
1774
1800
  this.elementsArray = {};
1775
1801
  this.active = false;
1802
+ 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 : [];
1776
1803
  if (!subsectionReceived) {
1777
1804
  return;
1778
1805
  }
@@ -1841,6 +1868,7 @@ class RecordFormSubSection extends FormPiecePropagate {
1841
1868
  const ACTIVE$1 = 'active';
1842
1869
  class RecordFormSection extends FormPiecePropagate {
1843
1870
  constructor(sectionReceived, formObject, formConfig) {
1871
+ var _a, _b, _c;
1844
1872
  super(sectionReceived, formConfig);
1845
1873
  this._activation = new Subject();
1846
1874
  this._inactivation = new Subject();
@@ -1850,6 +1878,7 @@ class RecordFormSection extends FormPiecePropagate {
1850
1878
  this.sectionTitle = null;
1851
1879
  this.subSections = [];
1852
1880
  this._exclusiveSubSectionsByAttr = {};
1881
+ 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 : [];
1853
1882
  if (!sectionReceived) {
1854
1883
  return;
1855
1884
  }