@smartbit4all/ng-client 3.0.26 → 3.0.27

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.
@@ -2908,6 +2908,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImpor
2908
2908
 
2909
2909
  class SmartFormService {
2910
2910
  constructor() {
2911
+ this.emptyKey = '#empt%@*y';
2911
2912
  this.group = {};
2912
2913
  }
2913
2914
  getSmartFormWidgetByKey(key) {
@@ -3097,12 +3098,7 @@ class SmartFormService {
3097
3098
  value: value[valueSetData.keyProperty],
3098
3099
  };
3099
3100
  });
3100
- widget.valueList?.unshift({
3101
- key: '',
3102
- label: '',
3103
- type: SmartFormWidgetType.ITEM,
3104
- value: undefined,
3105
- });
3101
+ this.addEmptyItemToValueList(widget);
3106
3102
  }
3107
3103
  else if (widget.selection.type === SelectionDefinition.TypeEnum.Object &&
3108
3104
  !widget.selection.mapping.length) {
@@ -3115,12 +3111,7 @@ class SmartFormService {
3115
3111
  value: value,
3116
3112
  };
3117
3113
  });
3118
- widget.valueList?.unshift({
3119
- key: '',
3120
- label: '',
3121
- type: SmartFormWidgetType.ITEM,
3122
- value: undefined,
3123
- });
3114
+ this.addEmptyItemToValueList(widget);
3124
3115
  }
3125
3116
  }
3126
3117
  }
@@ -3300,6 +3291,7 @@ class SmartFormService {
3300
3291
  name: 'required',
3301
3292
  },
3302
3293
  ];
3294
+ this.removeEmptyItemFromValueList(widget);
3303
3295
  }
3304
3296
  }
3305
3297
  if (widget.type !== SmartFormWidgetType.INDICATOR &&
@@ -3327,6 +3319,27 @@ class SmartFormService {
3327
3319
  this.applyComponentConstraints(this.smartForm.widgets, this.smartForm.componentModel?.constraints);
3328
3320
  }
3329
3321
  }
3322
+ addEmptyItemToValueList(widget) {
3323
+ if (widget.type == SmartFormWidgetType.SELECT ||
3324
+ widget.type == SmartFormWidgetType.SELECT_MULTIPLE) {
3325
+ widget.valueList?.unshift({
3326
+ key: this.emptyKey,
3327
+ label: '',
3328
+ type: SmartFormWidgetType.ITEM,
3329
+ value: undefined,
3330
+ });
3331
+ }
3332
+ }
3333
+ removeEmptyItemFromValueList(widget) {
3334
+ if ('valueList' in widget) {
3335
+ if (widget.valueList?.length) {
3336
+ let firstItem = widget.valueList[0];
3337
+ if (firstItem?.key === this.emptyKey) {
3338
+ widget.valueList.shift();
3339
+ }
3340
+ }
3341
+ }
3342
+ }
3330
3343
  filterWidgetsByVisibility(widgets) {
3331
3344
  return widgets.filter((widget) => widget.isVisible === undefined ? true : widget.isVisible);
3332
3345
  }