@smartbit4all/ng-client 3.0.10 → 3.0.11

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.
@@ -3048,35 +3048,7 @@ class SmartFormService {
3048
3048
  widget.showLabel = true;
3049
3049
  }
3050
3050
  }
3051
- if (widget.type === SmartFormWidgetType.SELECT ||
3052
- widget.type === SmartFormWidgetType.TEXT_FIELD) {
3053
- if (widget.selection && smartForm.componentModel.valueSets) {
3054
- if (widget.selection.type === SelectionDefinition.TypeEnum.Property &&
3055
- !widget.selection.mapping.length) {
3056
- let valueSetData = smartForm.componentModel.valueSets[widget.selection.valueSetName].valueSetData;
3057
- widget.valueList = valueSetData.values.map((value) => {
3058
- return {
3059
- key: value[valueSetData.keyProperty],
3060
- label: value[widget.selection?.displayProperty ?? 'displayValue'],
3061
- type: SmartFormWidgetType.ITEM,
3062
- value: value[valueSetData.keyProperty],
3063
- };
3064
- });
3065
- }
3066
- else if (widget.selection.type === SelectionDefinition.TypeEnum.Object &&
3067
- !widget.selection.mapping.length) {
3068
- let valueSetData = smartForm.componentModel.valueSets[widget.selection.valueSetName].valueSetData;
3069
- widget.valueList = valueSetData.values.map((value, index) => {
3070
- return {
3071
- key: `${index}`,
3072
- label: value[widget.selection?.displayProperty ?? 'displayValue'],
3073
- type: SmartFormWidgetType.ITEM,
3074
- value: value,
3075
- };
3076
- });
3077
- }
3078
- }
3079
- }
3051
+ this.copyFromValueSetToValuesList(widget, smartForm.componentModel.valueSets);
3080
3052
  if (widget &&
3081
3053
  widget.type === SmartFormWidgetType.CHECK_BOX &&
3082
3054
  widget.valueList.length === 1) {
@@ -3092,17 +3064,54 @@ class SmartFormService {
3092
3064
  let splittedKeys = key.split('.');
3093
3065
  splittedKeys.splice(splittedKeys.length - 1, 1);
3094
3066
  widget = this.findSmartFormWidgetByKey(smartForm.widgets, splittedKeys.join('.'));
3095
- if (widget && widget.type === SmartFormWidgetType.CHECK_BOX_2 && widget.valueList) {
3096
- widget.valueList = widget.valueList.map((item) => {
3097
- let value = this.getValueDeeply(data, `${widget?.key}.${item.key}`);
3098
- item.value = value;
3099
- return item;
3100
- });
3067
+ if (widget && widget.type === SmartFormWidgetType.CHECK_BOX_2) {
3068
+ this.copyFromValueSetToValuesList(widget, smartForm.componentModel.valueSets);
3069
+ if (widget.valueList) {
3070
+ widget.valueList = widget.valueList.map((item) => {
3071
+ let value = this.getValueDeeply(data, `${widget?.key}.${item.key}`);
3072
+ item.value = value;
3073
+ return item;
3074
+ });
3075
+ }
3101
3076
  }
3102
3077
  }
3103
3078
  }
3104
3079
  }
3105
3080
  }
3081
+ copyFromValueSetToValuesList(widget, valueSets) {
3082
+ if (widget.type === SmartFormWidgetType.SELECT ||
3083
+ widget.type === SmartFormWidgetType.SELECT_MULTIPLE ||
3084
+ widget.type === SmartFormWidgetType.RADIO_BUTTON ||
3085
+ widget.type === SmartFormWidgetType.CHECK_BOX ||
3086
+ widget.type === SmartFormWidgetType.TEXT_FIELD) {
3087
+ if (widget.selection && valueSets) {
3088
+ if (widget.selection.type === SelectionDefinition.TypeEnum.Property &&
3089
+ !widget.selection.mapping.length) {
3090
+ let valueSetData = valueSets[widget.selection.valueSetName].valueSetData;
3091
+ widget.valueList = valueSetData.values.map((value) => {
3092
+ return {
3093
+ key: value[valueSetData.keyProperty],
3094
+ label: value[widget.selection?.displayProperty ?? 'displayValue'],
3095
+ type: SmartFormWidgetType.ITEM,
3096
+ value: value[valueSetData.keyProperty],
3097
+ };
3098
+ });
3099
+ }
3100
+ else if (widget.selection.type === SelectionDefinition.TypeEnum.Object &&
3101
+ !widget.selection.mapping.length) {
3102
+ let valueSetData = valueSets[widget.selection.valueSetName].valueSetData;
3103
+ widget.valueList = valueSetData.values.map((value, index) => {
3104
+ return {
3105
+ key: `${index}`,
3106
+ label: value[widget.selection?.displayProperty ?? 'displayValue'],
3107
+ type: SmartFormWidgetType.ITEM,
3108
+ value: value,
3109
+ };
3110
+ });
3111
+ }
3112
+ }
3113
+ }
3114
+ }
3106
3115
  toFormGroup() {
3107
3116
  this.createFormControls(this.smartForm.widgets);
3108
3117
  let formGroup = new FormGroup(this.group);