@sap-ux/preview-middleware 0.17.33 → 0.17.34

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.
@@ -60,6 +60,14 @@ sap.ui.define([
60
60
  this.options = options;
61
61
  this.enablementValidators = enablementValidators;
62
62
  }
63
+ async addSettingsActionId(table, tableMapKey) {
64
+ if (this.options.includeServiceAction) {
65
+ const actions = await this.context.actionService.get(table.getId());
66
+ const actionsIds = await getActionId(table);
67
+ const changeColumnAction = actionsIds.find(actionId => actions.findIndex(action => action.id === actionId) > -1);
68
+ this.tableMap[tableMapKey].changeColumnActionId = changeColumnAction;
69
+ }
70
+ }
63
71
  async initialize() {
64
72
  const version = await getUi5Version();
65
73
  if (isLowerThanMinimalUi5Version(version, {
@@ -74,26 +82,20 @@ sap.ui.define([
74
82
  const tabKey = Object.keys(iconTabBarfilterMap).find(key => table.getId().endsWith(key));
75
83
  const section = getParentContainer(table, 'sap.uxap.ObjectPageSection');
76
84
  if (section) {
77
- this.collectChildrenInSection(section, table);
85
+ await this.collectChildrenInSection(section, table);
78
86
  } else if (this.iconTabBar && tabKey) {
79
87
  const label = `'${ iconTabBarfilterMap[tabKey] }' table`;
80
88
  const child = this.createChild(label, table);
81
89
  this.children.push(child);
82
- this.tableMap[`${ this.children.length - 1 }`] = {
90
+ const tableMapKey = `${ this.children.length - 1 }`;
91
+ this.tableMap[tableMapKey] = {
83
92
  table,
84
93
  iconTabBarFilterKey: tabKey,
85
94
  tableUpdateEventAttachedOnce: false
86
95
  };
96
+ await this.addSettingsActionId(table, tableMapKey);
87
97
  } else {
88
- this.processTable(table);
89
- }
90
- if (this.options.includeServiceAction) {
91
- const actions = await this.context.actionService.get(table.getId());
92
- const actionsIds = await getActionId(table);
93
- const changeColumnAction = actionsIds.find(actionId => actions.findIndex(action => action.id === actionId) > -1);
94
- Object.keys(this.tableMap).forEach(key => {
95
- this.tableMap[key].changeColumnActionId = changeColumnAction;
96
- });
98
+ await this.processTable(table);
97
99
  }
98
100
  }
99
101
  if (this.children.length > 0) {
@@ -147,13 +149,13 @@ sap.ui.define([
147
149
  }
148
150
  return iconTabBarFilterMap;
149
151
  }
150
- collectChildrenInSection(section, table) {
152
+ async collectChildrenInSection(section, table) {
151
153
  const layout = getParentContainer(table, 'sap.uxap.ObjectPageLayout');
152
154
  const subSections = section.getSubSections();
153
155
  const subSection = getParentContainer(table, 'sap.uxap.ObjectPageSubSection');
154
156
  if (subSection) {
155
157
  if (subSections?.length === 1) {
156
- this.processTable(table, {
158
+ await this.processTable(table, {
157
159
  section,
158
160
  subSection: subSections[0],
159
161
  layout
@@ -183,10 +185,11 @@ sap.ui.define([
183
185
  },
184
186
  tableUpdateEventAttachedOnce: false
185
187
  };
188
+ await this.addSettingsActionId(table, tableMapIndex);
186
189
  }
187
190
  }
188
191
  }
189
- processTable(table, sectionInfo) {
192
+ async processTable(table, sectionInfo) {
190
193
  if ([
191
194
  SMART_TABLE_TYPE,
192
195
  M_TABLE_TYPE,
@@ -199,11 +202,13 @@ sap.ui.define([
199
202
  const child = this.createChild(label, table);
200
203
  this.children.push(child);
201
204
  }
202
- this.tableMap[`${ this.children.length - 1 }`] = {
205
+ const tableMapKey = `${ this.children.length - 1 }`;
206
+ this.tableMap[tableMapKey] = {
203
207
  table,
204
208
  sectionInfo: sectionInfo,
205
209
  tableUpdateEventAttachedOnce: false
206
210
  };
211
+ await this.addSettingsActionId(table, tableMapKey);
207
212
  }
208
213
  selectOverlay(table) {
209
214
  const controlOverlay = OverlayUtil.getClosestOverlayFor(table);
@@ -91,6 +91,23 @@ export abstract class TableQuickActionDefinitionBase extends QuickActionDefiniti
91
91
  super(type, NESTED_QUICK_ACTION_KIND, defaultTextKey, context, enablementValidators);
92
92
  }
93
93
 
94
+ /**
95
+ * Adds action id to the table map entry, if the service actions are needed.
96
+ * @param table - table element
97
+ * @param tableMapKey - map key
98
+ */
99
+ protected async addSettingsActionId(table: UI5Element, tableMapKey: string): Promise<void> {
100
+ if (this.options.includeServiceAction) {
101
+ const actions = await this.context.actionService.get(table.getId());
102
+ const actionsIds = await getActionId(table);
103
+
104
+ const changeColumnAction = actionsIds.find(
105
+ (actionId) => actions.findIndex((action) => action.id === actionId) > -1
106
+ );
107
+ this.tableMap[tableMapKey].changeColumnActionId = changeColumnAction;
108
+ }
109
+ }
110
+
94
111
  /**
95
112
  * Initializes action object instance
96
113
  */
@@ -110,32 +127,20 @@ export abstract class TableQuickActionDefinitionBase extends QuickActionDefiniti
110
127
  const tabKey = Object.keys(iconTabBarfilterMap).find((key) => table.getId().endsWith(key));
111
128
  const section = getParentContainer<ObjectPageSection>(table, 'sap.uxap.ObjectPageSection');
112
129
  if (section) {
113
- this.collectChildrenInSection(section, table);
130
+ await this.collectChildrenInSection(section, table);
114
131
  } else if (this.iconTabBar && tabKey) {
115
132
  const label = `'${iconTabBarfilterMap[tabKey]}' table`;
116
133
  const child = this.createChild(label, table);
117
134
  this.children.push(child);
118
- this.tableMap[`${this.children.length - 1}`] = {
135
+ const tableMapKey = `${this.children.length - 1}`;
136
+ this.tableMap[tableMapKey] = {
119
137
  table,
120
138
  iconTabBarFilterKey: tabKey,
121
139
  tableUpdateEventAttachedOnce: false
122
140
  };
141
+ await this.addSettingsActionId(table, tableMapKey);
123
142
  } else {
124
- this.processTable(table);
125
- }
126
-
127
- // add action id to the table map, if the service actions are needed.
128
- if (this.options.includeServiceAction) {
129
- const actions = await this.context.actionService.get(table.getId());
130
- const actionsIds = await getActionId(table);
131
-
132
- const changeColumnAction = actionsIds.find(
133
- (actionId) => actions.findIndex((action) => action.id === actionId) > -1
134
- );
135
- Object.keys(this.tableMap).forEach((key) => {
136
- // Update the changeColumnActionId for each entry
137
- this.tableMap[key].changeColumnActionId = changeColumnAction;
138
- });
143
+ await this.processTable(table);
139
144
  }
140
145
  }
141
146
  if (this.children.length > 0) {
@@ -219,13 +224,13 @@ export abstract class TableQuickActionDefinitionBase extends QuickActionDefiniti
219
224
  * @param section - object page section
220
225
  * @param table - table element
221
226
  */
222
- private collectChildrenInSection(section: ObjectPageSection, table: UI5Element): void {
227
+ private async collectChildrenInSection(section: ObjectPageSection, table: UI5Element): Promise<void> {
223
228
  const layout = getParentContainer<ObjectPageLayout>(table, 'sap.uxap.ObjectPageLayout');
224
229
  const subSections = section.getSubSections();
225
230
  const subSection = getParentContainer<ObjectPageSubSection>(table, 'sap.uxap.ObjectPageSubSection');
226
231
  if (subSection) {
227
232
  if (subSections?.length === 1) {
228
- this.processTable(table, { section, subSection: subSections[0], layout });
233
+ await this.processTable(table, { section, subSection: subSections[0], layout });
229
234
  } else if (subSections.length > 1) {
230
235
  const existingChildIdx = this.children.findIndex(
231
236
  (val) => val.label === `'${section.getTitle()}' section`
@@ -253,6 +258,7 @@ export abstract class TableQuickActionDefinitionBase extends QuickActionDefiniti
253
258
  sectionInfo: { section, subSection, layout },
254
259
  tableUpdateEventAttachedOnce: false
255
260
  };
261
+ await this.addSettingsActionId(table, tableMapIndex);
256
262
  }
257
263
  }
258
264
  }
@@ -262,10 +268,10 @@ export abstract class TableQuickActionDefinitionBase extends QuickActionDefiniti
262
268
  * @param table - table element
263
269
  * @param sectionInfo - section info object
264
270
  */
265
- private processTable(
271
+ private async processTable(
266
272
  table: UI5Element,
267
273
  sectionInfo?: { section: ObjectPageSection; subSection: ObjectPageSubSection; layout?: ObjectPageLayout }
268
- ): void {
274
+ ): Promise<void> {
269
275
  if (
270
276
  [
271
277
  SMART_TABLE_TYPE,
@@ -281,11 +287,13 @@ export abstract class TableQuickActionDefinitionBase extends QuickActionDefiniti
281
287
  this.children.push(child);
282
288
  }
283
289
 
284
- this.tableMap[`${this.children.length - 1}`] = {
290
+ const tableMapKey = `${this.children.length - 1}`;
291
+ this.tableMap[tableMapKey] = {
285
292
  table,
286
293
  sectionInfo: sectionInfo,
287
294
  tableUpdateEventAttachedOnce: false
288
295
  };
296
+ await this.addSettingsActionId(table, tableMapKey);
289
297
  }
290
298
 
291
299
  /**
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.17.33",
12
+ "version": "0.17.34",
13
13
  "license": "Apache-2.0",
14
14
  "author": "@SAP/ux-tools-team",
15
15
  "main": "dist/index.js",
@@ -48,11 +48,11 @@
48
48
  "supertest": "6.3.3",
49
49
  "@sap-ux-private/playwright": "0.1.0",
50
50
  "dotenv": "16.3.1",
51
- "@private/preview-middleware-client": "npm:@sap-ux-private/preview-middleware-client@0.11.62",
52
51
  "@sap-ux/axios-extension": "1.18.5",
53
- "@sap-ux/store": "1.0.0",
52
+ "@private/preview-middleware-client": "npm:@sap-ux-private/preview-middleware-client@0.11.63",
54
53
  "@sap-ux/ui5-info": "0.8.3",
55
- "@sap-ux/i18n": "0.2.1"
54
+ "@sap-ux/i18n": "0.2.1",
55
+ "@sap-ux/store": "1.0.0"
56
56
  },
57
57
  "peerDependencies": {
58
58
  "express": "4"