tuain-ng-forms-lib 17.3.0 → 17.3.2

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.
@@ -28,12 +28,12 @@ class FormPiece {
28
28
  this._visibleForced = false;
29
29
  this.setVisibleStates(pieceDefinition.visibleStates);
30
30
  this.setEnabledStates(pieceDefinition.enabledStates);
31
- this.enabled = !pieceDefinition?.disabled ?? false;
31
+ this.enabled = !pieceDefinition?.disabled;
32
32
  this.setVisibility(pieceDefinition?.visible ?? true);
33
33
  this.customAttributes = pieceDefinition?.customAttributes ?? {};
34
34
  if (pieceDefinition?.customAttributes) {
35
35
  Object.keys(pieceDefinition?.customAttributes)
36
- ?.forEach(attr => this.customAttributes[attr] = pieceDefinition?.customAttributes[attr]);
36
+ ?.forEach(attr => this.customAttributes[attr] = pieceDefinition?.customAttributes?.[attr]);
37
37
  }
38
38
  }
39
39
  getCustomAttribute(name) { return this.customAttributes?.[name] ?? null; }
@@ -148,7 +148,6 @@ class FormPiece {
148
148
  const VISIBLE = 'visible';
149
149
  const DISABLED = 'disabled';
150
150
  class FormPiecePropagate extends FormPiece {
151
- propagationCustomAttributes = [];
152
151
  _attributeChange;
153
152
  constructor(pieceDefinition, formConfig) {
154
153
  super(pieceDefinition, formConfig);
@@ -160,10 +159,8 @@ class FormPiecePropagate extends FormPiece {
160
159
  }
161
160
  setCustomAttribute(name, value) {
162
161
  super.setCustomAttribute(name, value);
163
- if (this.propagationCustomAttributes?.includes(name)) {
164
- const fullName = `customAttributes.${name}`;
165
- this.propagateAttribute(fullName, value);
166
- }
162
+ const fullName = `customAttributes.${name}`;
163
+ this.propagateAttribute(fullName, value);
167
164
  }
168
165
  setVisibility(visible, forced = null) {
169
166
  super.setVisibility(visible, forced);
@@ -339,7 +336,6 @@ class FieldDescriptor extends FormElement {
339
336
  _customEmpty = null;
340
337
  constructor(inputFieldReceived, formConfig) {
341
338
  super(inputFieldReceived, formConfig);
342
- this.propagationCustomAttributes = this._formConfig?.propagationCustomAttributes?.fields ?? [];
343
339
  this.elementType = ElementType.Field;
344
340
  const fld = (inputFieldReceived) ? inputFieldReceived : {};
345
341
  this.setAttr(attrs$2.fieldCode, fld.fieldCode);
@@ -755,7 +751,6 @@ class FormAction extends FormElement {
755
751
  _restrictedOnValue = null;
756
752
  constructor(actionDefinition, formConfig) {
757
753
  super(actionDefinition, formConfig);
758
- this.propagationCustomAttributes = this._formConfig?.propagationCustomAttributes?.actions ?? [];
759
754
  this.elementType = ElementType.Action;
760
755
  this.setAttr(attrs$1.actionCode, actionDefinition.actionCode ? actionDefinition.actionCode.toString() : '');
761
756
  this.setAttr(attrs$1.actionName, actionDefinition.actionTitle);
@@ -856,7 +851,6 @@ class RecordFormSubSection extends FormPiecePropagate {
856
851
  _active = false;
857
852
  constructor(subsectionReceived, formObject, formConfig) {
858
853
  super(subsectionReceived, formConfig);
859
- this.propagationCustomAttributes = this._formConfig?.propagationCustomAttributes?.subsections ?? [];
860
854
  if (!subsectionReceived) {
861
855
  return;
862
856
  }
@@ -951,7 +945,6 @@ class RecordFormSection extends FormPiecePropagate {
951
945
  _exclusiveSubSectionsByAttr = {};
952
946
  constructor(sectionReceived, formObject, formConfig) {
953
947
  super(sectionReceived, formConfig);
954
- this.propagationCustomAttributes = this._formConfig?.propagationCustomAttributes?.sections ?? [];
955
948
  if (!sectionReceived) {
956
949
  return;
957
950
  }
@@ -1380,7 +1373,6 @@ class RecordTable extends FormElement {
1380
1373
  _sortable;
1381
1374
  constructor(tableReceived, formConfig) {
1382
1375
  super(tableReceived, formConfig);
1383
- this.propagationCustomAttributes = this._formConfig?.propagationCustomAttributes?.tables ?? [];
1384
1376
  this.elementType = ElementType.Table;
1385
1377
  this._waiting = false;
1386
1378
  this._currentPage = 1;
@@ -2470,10 +2462,8 @@ class PieceComponent {
2470
2462
  }
2471
2463
  customAttributeChange(subAttribute, value) { }
2472
2464
  updateCustomAttribute(attrName, attrValue) {
2473
- this.customAttributes.update(oldCustomAttr => {
2474
- oldCustomAttr[attrName] = attrValue;
2475
- return oldCustomAttr;
2476
- });
2465
+ this.customAttributes.update(old => ({ ...old, [attrName]: attrValue }));
2466
+ this.customAttributeChange(attrName, attrValue);
2477
2467
  this.customAttributeChange(attrName, attrValue);
2478
2468
  }
2479
2469
  replaceCustomAttributes(customAttributes) {