@sap-ux/preview-middleware 0.11.4 → 0.11.5

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.
@@ -29,6 +29,20 @@ sap.ui.define(["sap/m/MessageToast", "sap/ui/model/json/JSONModel", "sap/ui/dt/O
29
29
  this.getView()?.setModel(this.model);
30
30
  this.dialog.open();
31
31
  },
32
+ specialIndexHandling: function _specialIndexHandling(specialIndexAggregation) {
33
+ const overlay = OverlayRegistry.getOverlay(this.runtimeControl);
34
+ const aggregations = overlay.getDesignTimeMetadata().getData().aggregations;
35
+ if (specialIndexAggregation in aggregations && 'specialIndexHandling' in aggregations[specialIndexAggregation]) {
36
+ const controlType = this.runtimeControl.getMetadata().getName();
37
+ this.model.setProperty('/indexHandlingFlag', false);
38
+ this.model.setProperty('/specialIndexHandlingIcon', true);
39
+ this.model.setProperty('/iconTooltip', `Index is defined by special logic of ${controlType} and can't be set here`);
40
+ } else {
41
+ this.model.setProperty('/indexHandlingFlag', true);
42
+ this.model.setProperty('/specialIndexHandlingIcon', false);
43
+ this.model.setProperty('/specialIndexHandlingIconPressed', false);
44
+ }
45
+ },
32
46
  onAggregationChanged: function _onAggregationChanged(event) {
33
47
  const source = event.getSource();
34
48
  const selectedKey = source.getSelectedKey();
@@ -43,6 +57,7 @@ sap.ui.define(["sap/m/MessageToast", "sap/ui/model/json/JSONModel", "sap/ui/dt/O
43
57
  newSelectedControlChildren = newSelectedControlChildren.map(key => {
44
58
  return parseInt(key);
45
59
  });
60
+ this.specialIndexHandling(selectedItemText);
46
61
  const updatedIndexArray = this.fillIndexArray(newSelectedControlChildren);
47
62
  this.model.setProperty('/index', updatedIndexArray);
48
63
  this.model.setProperty('/selectedIndex', updatedIndexArray.length - 1);
@@ -105,11 +120,13 @@ sap.ui.define(["sap/m/MessageToast", "sap/ui/model/json/JSONModel", "sap/ui/dt/O
105
120
  obj.key = 'default';
106
121
  this.model.setProperty('/selectedAggregation/key', obj.key);
107
122
  this.model.setProperty('/selectedAggregation/value', obj.value);
123
+ this.specialIndexHandling(obj.value);
108
124
  }
109
125
  });
110
126
  } else {
111
127
  this.model.setProperty('/selectedAggregation/key', controlAggregation[0].key);
112
128
  this.model.setProperty('/selectedAggregation/value', controlAggregation[0].value);
129
+ this.specialIndexHandling(controlAggregation[0].value);
113
130
  }
114
131
  try {
115
132
  const {
@@ -59,6 +59,28 @@ export default class AddFragment extends BaseDialog {
59
59
  this.dialog.open();
60
60
  }
61
61
 
62
+ /**
63
+ * Handles the index field whenever a specific aggregation is chosen
64
+ *
65
+ * @param specialIndexAggregation string | number
66
+ */
67
+ private specialIndexHandling(specialIndexAggregation: string | number): void {
68
+ const overlay = OverlayRegistry.getOverlay(this.runtimeControl as UI5Element);
69
+ const aggregations = overlay.getDesignTimeMetadata().getData().aggregations;
70
+
71
+ if(specialIndexAggregation in aggregations && 'specialIndexHandling' in aggregations[specialIndexAggregation]) {
72
+ const controlType = this.runtimeControl.getMetadata().getName();
73
+ this.model.setProperty('/indexHandlingFlag', false);
74
+ this.model.setProperty('/specialIndexHandlingIcon', true);
75
+ this.model.setProperty('/iconTooltip', `Index is defined by special logic of ${controlType} and can't be set here`);
76
+
77
+ } else {
78
+ this.model.setProperty('/indexHandlingFlag', true);
79
+ this.model.setProperty('/specialIndexHandlingIcon', false);
80
+ this.model.setProperty('/specialIndexHandlingIconPressed', false);
81
+ }
82
+ }
83
+
62
84
  /**
63
85
  * Handles the change in aggregations
64
86
  *
@@ -85,6 +107,8 @@ export default class AddFragment extends BaseDialog {
85
107
  newSelectedControlChildren = newSelectedControlChildren.map((key) => {
86
108
  return parseInt(key);
87
109
  });
110
+
111
+ this.specialIndexHandling(selectedItemText);
88
112
 
89
113
  const updatedIndexArray: { key: number; value: number }[] = this.fillIndexArray(newSelectedControlChildren);
90
114
 
@@ -178,11 +202,13 @@ export default class AddFragment extends BaseDialog {
178
202
  obj.key = 'default';
179
203
  this.model.setProperty('/selectedAggregation/key', obj.key);
180
204
  this.model.setProperty('/selectedAggregation/value', obj.value);
205
+ this.specialIndexHandling(obj.value);
181
206
  }
182
207
  });
183
208
  } else {
184
209
  this.model.setProperty('/selectedAggregation/key', controlAggregation[0].key);
185
210
  this.model.setProperty('/selectedAggregation/value', controlAggregation[0].value);
211
+ this.specialIndexHandling(controlAggregation[0].value);
186
212
  }
187
213
 
188
214
  try {
@@ -23,14 +23,23 @@
23
23
  <core:Item key="{key}" text="{value}" />
24
24
  </ComboBox>
25
25
  <Label text="Index" />
26
- <ComboBox
27
- selectedKey='{/selectedIndex}'
28
- items="{
29
- path: '/index',
30
- sorter: { path: 'text' }
31
- }">
32
- <core:Item key="{key}" text="{value}" />
33
- </ComboBox>
26
+ <HBox alignItems="Center">
27
+ <ComboBox
28
+ enabled="{/indexHandlingFlag}"
29
+ selectedKey='{/selectedIndex}'
30
+ items="{
31
+ path: '/index',
32
+ sorter: { path: 'text' }
33
+ }">
34
+ <core:Item key="{key}" text="{value}" />
35
+ </ComboBox>
36
+ <core:Icon
37
+ useIconTooltip="false"
38
+ visible="{/specialIndexHandlingIcon}"
39
+ src="sap-icon://message-information"
40
+ class= "sapUiTinyMarginBegin"
41
+ tooltip="{/iconTooltip}" />
42
+ </HBox>
34
43
  <Label text="Fragment Name" />
35
44
  <Input
36
45
  description=".fragment.xml"
package/package.json CHANGED
@@ -9,7 +9,7 @@
9
9
  "bugs": {
10
10
  "url": "https://github.com/SAP/open-ux-tools/issues?q=is%3Aopen+is%3Aissue+label%3Abug+label%3Apreview-middleware"
11
11
  },
12
- "version": "0.11.4",
12
+ "version": "0.11.5",
13
13
  "license": "Apache-2.0",
14
14
  "author": "@SAP/ux-tools-team",
15
15
  "main": "dist/index.js",
@@ -23,9 +23,9 @@
23
23
  ],
24
24
  "dependencies": {
25
25
  "ejs": "3.1.9",
26
- "@sap-ux/logger": "0.4.0",
27
26
  "@sap-ux/control-property-editor-sources": "npm:@sap-ux/control-property-editor@0.4.3",
28
- "@sap-ux/adp-tooling": "0.7.1"
27
+ "@sap-ux/adp-tooling": "0.7.1",
28
+ "@sap-ux/logger": "0.4.0"
29
29
  },
30
30
  "devDependencies": {
31
31
  "@types/ejs": "3.1.2",
@@ -36,7 +36,7 @@
36
36
  "npm-run-all": "4.1.5",
37
37
  "nock": "13.2.1",
38
38
  "supertest": "6.3.3",
39
- "@private/preview-middleware-client": "npm:@sap-ux-private/preview-middleware-client@0.8.2",
39
+ "@private/preview-middleware-client": "npm:@sap-ux-private/preview-middleware-client@0.8.3",
40
40
  "@sap-ux/project-access": "1.15.5",
41
41
  "@sap-ux/store": "0.4.0"
42
42
  },