@sap-ux/preview-middleware 0.16.76 → 0.16.78

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.
@@ -112,12 +112,13 @@ exports.getFlpConfigWithDefaults = getFlpConfigWithDefaults;
112
112
  */
113
113
  function sanitizeConfig(config, logger) {
114
114
  if (config.rta && config.adp === undefined) {
115
- config.rta.editors = config.rta.editors.filter((editor) => {
115
+ config.rta.editors = config.rta.editors.map((editor) => {
116
116
  if (editor.developerMode) {
117
117
  logger.error('developerMode is ONLY supported for SAP UI5 adaptation projects.');
118
118
  logger.warn(`developerMode for ${editor.path} disabled`);
119
+ editor.developerMode = false;
119
120
  }
120
- return !editor.developerMode;
121
+ return editor;
121
122
  });
122
123
  }
123
124
  }
@@ -214,17 +214,31 @@ sap.ui.define([
214
214
  const currentControlName = this.runtimeControl.getMetadata().getName();
215
215
  if (currentControlName === 'sap.uxap.ObjectPageLayout' && targetAggregation === 'sections') {
216
216
  return 'OBJECT_PAGE_CUSTOM_SECTION';
217
- } else if (currentControlName === 'sap.uxap.ObjectPageLayout' && targetAggregation === 'headerContent') {
217
+ } else if (this.isCustomAction(currentControlName, targetAggregation)) {
218
+ return 'CUSTOM_ACTION';
219
+ } else if (this.isObjectPageHeaderField(currentControlName, targetAggregation)) {
218
220
  return 'OBJECT_PAGE_HEADER_FIELD';
219
- } else if (currentControlName === 'sap.m.FlexBox' && targetAggregation === 'items') {
220
- if (this.runtimeControl.getParent()?.getMetadata().getName() === 'sap.uxap.ObjectPageDynamicHeaderContent') {
221
- return 'OBJECT_PAGE_HEADER_FIELD';
222
- } else {
223
- return '';
221
+ }
222
+ return '';
223
+ },
224
+ isCustomAction: function _isCustomAction(currentControlName, targetAggregation) {
225
+ if (currentControlName === 'sap.f.DynamicPageTitle' || currentControlName === 'sap.uxap.ObjectPageHeader') {
226
+ return targetAggregation === 'actions';
227
+ } else if (currentControlName === 'sap.m.OverflowToolbar' || currentControlName === 'sap.m.Toolbar') {
228
+ return targetAggregation === 'content';
229
+ }
230
+ return false;
231
+ },
232
+ isObjectPageHeaderField: function _isObjectPageHeaderField(currentControlName, targetAggregation) {
233
+ if (currentControlName === 'sap.uxap.ObjectPageLayout') {
234
+ return targetAggregation === 'headerContent';
235
+ } else if (currentControlName === 'sap.m.FlexBox') {
236
+ const parentName = this.runtimeControl.getParent()?.getMetadata().getName();
237
+ if (parentName === 'sap.uxap.ObjectPageDynamicHeaderContent' || parentName === 'sap.uxap.ObjectPageLayout') {
238
+ return targetAggregation === 'items';
224
239
  }
225
- } else {
226
- return '';
227
240
  }
241
+ return false;
228
242
  }
229
243
  });
230
244
  return AddFragment;
@@ -316,23 +316,56 @@ export default class AddFragment extends BaseDialog<AddFragmentModel> {
316
316
  return templateName;
317
317
  }
318
318
 
319
+ /**
320
+ * Determines fragment template name based on current control name and provided target aggregation
321
+ * @param targetAggregation - target aggregation name
322
+ * @returns fragment template name or empty string
323
+ */
319
324
  private getFragmentTemplateName(targetAggregation: string): string {
320
325
  const currentControlName = this.runtimeControl.getMetadata().getName();
321
326
  if (currentControlName === 'sap.uxap.ObjectPageLayout' && targetAggregation === 'sections') {
322
327
  return 'OBJECT_PAGE_CUSTOM_SECTION';
323
- } else if (currentControlName === 'sap.uxap.ObjectPageLayout' && targetAggregation === 'headerContent') {
328
+ } else if (this.isCustomAction(currentControlName, targetAggregation)) {
329
+ return 'CUSTOM_ACTION';
330
+ } else if (this.isObjectPageHeaderField(currentControlName, targetAggregation)) {
324
331
  return 'OBJECT_PAGE_HEADER_FIELD';
325
- } else if (currentControlName === 'sap.m.FlexBox' && targetAggregation === 'items') {
326
- // in case of dynamic header make sure that there is only one flexBox in the header.
332
+ }
333
+ return '';
334
+ }
335
+
336
+ /**
337
+ * Determines conditions for custom action fragment creation
338
+ * @param currentControlName - current control name
339
+ * @param targetAggregation - target aggregation name
340
+ * @returns true if control and aggregation combination allows to create custom action fragment
341
+ */
342
+ private isCustomAction(currentControlName: string, targetAggregation: string): boolean {
343
+ if (currentControlName === 'sap.f.DynamicPageTitle' || currentControlName === 'sap.uxap.ObjectPageHeader') {
344
+ return targetAggregation === 'actions';
345
+ } else if (currentControlName === 'sap.m.OverflowToolbar' || currentControlName === 'sap.m.Toolbar') {
346
+ return targetAggregation === 'content';
347
+ }
348
+ return false;
349
+ }
350
+
351
+ /**
352
+ * Determines conditions for object page header field fragment creation
353
+ * @param currentControlName - current control name
354
+ * @param targetAggregation - target aggregation name
355
+ * @returns true if conditions allow to create object page header field fragment
356
+ */
357
+ private isObjectPageHeaderField(currentControlName: string, targetAggregation: string): boolean {
358
+ if (currentControlName === 'sap.uxap.ObjectPageLayout') {
359
+ return targetAggregation === 'headerContent';
360
+ } else if (currentControlName === 'sap.m.FlexBox') {
361
+ const parentName = this.runtimeControl.getParent()?.getMetadata().getName();
327
362
  if (
328
- this.runtimeControl.getParent()?.getMetadata().getName() === 'sap.uxap.ObjectPageDynamicHeaderContent'
363
+ parentName === 'sap.uxap.ObjectPageDynamicHeaderContent' ||
364
+ parentName === 'sap.uxap.ObjectPageLayout'
329
365
  ) {
330
- return 'OBJECT_PAGE_HEADER_FIELD';
331
- } else {
332
- return '';
366
+ return targetAggregation === 'items';
333
367
  }
334
- } else {
335
- return '';
336
368
  }
369
+ return false;
337
370
  }
338
371
  }
@@ -1,261 +1,100 @@
1
- 'use strict';
2
- sap.ui.define([
3
- 'sap/ui/dt/OverlayUtil',
4
- 'open/ux/preview/client/thirdparty/@sap-ux-private/control-property-editor-common',
5
- '../../../cpe/quick-actions/utils',
6
- '../../../utils/core',
7
- '../../../utils/version'
8
- ], function (OverlayUtil, ___sap_ux_private_control_property_editor_common, _____cpe_quick_actions_utils, _____utils_core, _____utils_version) {
9
- 'use strict';
10
- const NESTED_QUICK_ACTION_KIND = ___sap_ux_private_control_property_editor_common['NESTED_QUICK_ACTION_KIND'];
11
- const getParentContainer = _____cpe_quick_actions_utils['getParentContainer'];
12
- const getRelevantControlFromActivePage = _____cpe_quick_actions_utils['getRelevantControlFromActivePage'];
13
- const getControlById = _____utils_core['getControlById'];
14
- const isA = _____utils_core['isA'];
15
- const isManagedObject = _____utils_core['isManagedObject'];
16
- const getUi5Version = _____utils_version['getUi5Version'];
17
- const isLowerThanMinimalUi5Version = _____utils_version['isLowerThanMinimalUi5Version'];
18
- const CHANGE_TABLE_COLUMNS = 'change-table-columns';
19
- const SMART_TABLE_ACTION_ID = 'CTX_COMP_VARIANT_CONTENT';
20
- const M_TABLE_ACTION_ID = 'CTX_ADD_ELEMENTS_AS_CHILD';
21
- const SETTINGS_ID = 'CTX_SETTINGS';
22
- const ICON_TAB_BAR_TYPE = 'sap.m.IconTabBar';
23
- const SMART_TABLE_TYPE = 'sap.ui.comp.smarttable.SmartTable';
24
- const M_TABLE_TYPE = 'sap.m.Table';
25
- const CONTROL_TYPES = [
26
- SMART_TABLE_TYPE,
27
- M_TABLE_TYPE,
28
- 'sap.ui.table.TreeTable',
29
- 'sap.ui.table.Table'
30
- ];
31
- async function getActionId(table) {
32
- const {major, minor} = await getUi5Version();
1
+ "use strict";
2
+
3
+ sap.ui.define(["../../../utils/core", "./table-quick-action-base"], function (_____utils_core, ___table_quick_action_base) {
4
+ "use strict";
5
+
6
+ const getControlById = _____utils_core["getControlById"];
7
+ const isA = _____utils_core["isA"];
8
+ const TableQuickActionDefinitionBase = ___table_quick_action_base["TableQuickActionDefinitionBase"];
9
+ const CHANGE_TABLE_COLUMNS = 'change-table-columns';
10
+ const SMART_TABLE_TYPE = 'sap.ui.comp.smarttable.SmartTable';
11
+ const M_TABLE_TYPE = 'sap.m.Table';
12
+ // maintain order if action id
13
+ const CONTROL_TYPES = [SMART_TABLE_TYPE, M_TABLE_TYPE, 'sap.ui.table.TreeTable', 'sap.ui.table.Table'];
14
+ class ChangeTableColumnsQuickAction extends TableQuickActionDefinitionBase {
15
+ constructor(context) {
16
+ super(CHANGE_TABLE_COLUMNS, CONTROL_TYPES, 'V2_QUICK_ACTION_CHANGE_TABLE_COLUMNS', context, true);
17
+ }
18
+ async execute(path) {
19
+ const {
20
+ table,
21
+ iconTabBarFilterKey,
22
+ changeColumnActionId,
23
+ sectionInfo
24
+ } = this.tableMap[path];
25
+ if (!table) {
26
+ return [];
27
+ }
28
+ if (sectionInfo) {
29
+ const {
30
+ layout,
31
+ section,
32
+ subSection
33
+ } = sectionInfo;
34
+ layout?.setSelectedSection(section);
35
+ section.setSelectedSubSection(subSection);
36
+ this.selectOverlay(table);
37
+ } else {
38
+ getControlById(table.getId())?.getDomRef()?.scrollIntoView();
39
+ this.selectOverlay(table);
40
+ }
41
+ if (this.iconTabBar && iconTabBarFilterKey) {
42
+ this.iconTabBar.setSelectedKey(iconTabBarFilterKey);
43
+ }
44
+ if (changeColumnActionId) {
45
+ const executeAction = async () => await this.context.actionService.execute(table.getId(), changeColumnActionId);
33
46
  if (isA(SMART_TABLE_TYPE, table)) {
34
- if (major === 1 && minor === 96) {
35
- return [SETTINGS_ID];
36
- } else {
37
- return [SMART_TABLE_ACTION_ID];
38
- }
47
+ await executeAction();
48
+ } else if (isA(M_TABLE_TYPE, table)) {
49
+ // if table is busy, i.e. lazy loading, then we subscribe to 'updateFinished' event and call action service when loading is done
50
+ // to avoid reopening the dialog after close
51
+ if (this.isTableLoaded(table)) {
52
+ await executeAction();
53
+ } else {
54
+ table.attachEventOnce('updateFinished', executeAction, this);
55
+ }
39
56
  }
40
- return [
41
- M_TABLE_ACTION_ID,
42
- SETTINGS_ID
43
- ];
57
+ }
58
+ return [];
44
59
  }
45
- class ChangeTableColumnsQuickAction {
46
- kind = NESTED_QUICK_ACTION_KIND;
47
- type = CHANGE_TABLE_COLUMNS;
48
- get id() {
49
- return `${ this.context.key }-${ this.type }`;
50
- }
51
- isActive = false;
52
- isClearButtonEnabled = false;
53
- children = [];
54
- tableMap = {};
55
- constructor(context) {
56
- this.context = context;
57
- }
58
- async initialize() {
59
- const version = await getUi5Version();
60
- if (isLowerThanMinimalUi5Version(version, {
61
- major: 1,
62
- minor: 96
63
- })) {
64
- this.isActive = false;
65
- return;
66
- }
67
- const iconTabBarfilterMap = this.buildIconTabBarFilterMap();
68
- for (const table of getRelevantControlFromActivePage(this.context.controlIndex, this.context.view, CONTROL_TYPES)) {
69
- const actions = await this.context.actionService.get(table.getId());
70
- const actionsIds = await getActionId(table);
71
- const changeColumnAction = actionsIds.find(actionId => actions.findIndex(action => action.id === actionId) > -1);
72
- const tabKey = Object.keys(iconTabBarfilterMap).find(key => table.getId().endsWith(key));
73
- if (changeColumnAction) {
74
- const section = getParentContainer(table, 'sap.uxap.ObjectPageSection');
75
- if (section) {
76
- this.collectChildrenInSection(section, table, changeColumnAction);
77
- } else if (this.iconTabBar && tabKey) {
78
- this.children.push({
79
- label: `'${ iconTabBarfilterMap[tabKey] }' table`,
80
- children: []
81
- });
82
- this.tableMap[`${ this.children.length - 1 }`] = {
83
- table,
84
- iconTabBarFilterKey: tabKey,
85
- changeColumnActionId: changeColumnAction,
86
- tableUpdateEventAttachedOnce: false
87
- };
88
- } else {
89
- this.processTable(table, changeColumnAction);
90
- }
91
- }
92
- }
93
- if (this.children.length > 0) {
94
- this.isActive = true;
95
- }
96
- }
97
- getTableLabel(table) {
98
- if (isA(SMART_TABLE_TYPE, table)) {
99
- const header = table.getHeader();
100
- if (header) {
101
- return `'${ header }' table`;
102
- }
103
- }
104
- if (isA(M_TABLE_TYPE, table)) {
105
- const tilte = table?.getHeaderToolbar()?.getTitleControl()?.getText();
106
- if (tilte) {
107
- return `'${ tilte }' table`;
108
- }
109
- }
110
- return 'Unnamed table';
111
- }
112
- buildIconTabBarFilterMap() {
113
- const iconTabBarfilterMap = {};
114
- const tabBar = getRelevantControlFromActivePage(this.context.controlIndex, this.context.view, [ICON_TAB_BAR_TYPE])[0];
115
- if (tabBar) {
116
- const control = getControlById(tabBar.getId());
117
- if (isA(ICON_TAB_BAR_TYPE, control)) {
118
- this.iconTabBar = control;
119
- for (const item of control.getItems()) {
120
- if (isManagedObject(item) && isA('sap.m.IconTabFilter', item)) {
121
- iconTabBarfilterMap[item.getKey()] = item.getText();
122
- }
123
- }
124
- }
125
- }
126
- return iconTabBarfilterMap;
127
- }
128
- collectChildrenInSection(section, table, changeColumnAction) {
129
- const layout = getParentContainer(table, 'sap.uxap.ObjectPageLayout');
130
- const subSections = section.getSubSections();
131
- const subSection = getParentContainer(table, 'sap.uxap.ObjectPageSubSection');
132
- if (subSection) {
133
- if (subSections?.length === 1) {
134
- this.processTable(table, changeColumnAction, {
135
- section,
136
- subSection: subSections[0],
137
- layout
138
- });
139
- } else if (subSections.length > 1) {
140
- const sectionChild = this.children.find(val => val.label === `${ section.getTitle() } section`);
141
- let tableMapIndex = `${ this.children.length - 1 }`;
142
- if (!sectionChild) {
143
- tableMapIndex = `${ tableMapIndex }/0`;
144
- this.children.push({
145
- label: `'${ section?.getTitle() }' section`,
146
- children: [{
147
- label: this.getTableLabel(table),
148
- children: []
149
- }]
150
- });
151
- } else {
152
- tableMapIndex = `${ tableMapIndex }/${ sectionChild.children.length - 1 }`;
153
- sectionChild.children.push({
154
- label: this.getTableLabel(table),
155
- children: []
156
- });
157
- }
158
- this.tableMap[tableMapIndex] = {
159
- table,
160
- changeColumnActionId: changeColumnAction,
161
- sectionInfo: {
162
- section,
163
- subSection,
164
- layout
165
- },
166
- tableUpdateEventAttachedOnce: false
167
- };
168
- }
169
- }
170
- }
171
- processTable(table, changeColumnActionId, sectionInfo) {
172
- if (isA(SMART_TABLE_TYPE, table) || isA('sap.ui.table.TreeTable', table)) {
173
- this.children.push({
174
- label: this.getTableLabel(table),
175
- children: []
176
- });
177
- }
178
- if (isA(M_TABLE_TYPE, table)) {
179
- this.children.push({
180
- label: this.getTableLabel(table),
181
- children: []
182
- });
183
- }
184
- this.tableMap[`${ this.children.length - 1 }`] = {
185
- table,
186
- changeColumnActionId,
187
- sectionInfo: sectionInfo,
188
- tableUpdateEventAttachedOnce: false
189
- };
190
- }
191
- getActionObject() {
192
- return {
193
- kind: NESTED_QUICK_ACTION_KIND,
194
- id: this.id,
195
- enabled: this.isActive,
196
- title: this.context.resourceBundle.getText('V2_QUICK_ACTION_CHANGE_TABLE_COLUMNS') ?? 'Change table columns',
197
- children: this.children
198
- };
199
- }
200
- selectOverlay(table) {
201
- const controlOverlay = OverlayUtil.getClosestOverlayFor(table);
202
- if (controlOverlay) {
203
- controlOverlay.setSelected(true);
204
- }
205
- }
206
- async execute(path) {
207
- const {table, iconTabBarFilterKey, changeColumnActionId, sectionInfo} = this.tableMap[path];
208
- if (!table) {
209
- return [];
210
- }
211
- if (sectionInfo) {
212
- const {layout, section, subSection} = sectionInfo;
213
- layout?.setSelectedSection(section);
214
- section.setSelectedSubSection(subSection);
215
- this.selectOverlay(table);
216
- } else {
217
- getControlById(table.getId())?.getDomRef()?.scrollIntoView();
218
- this.selectOverlay(table);
219
- }
220
- if (this.iconTabBar && iconTabBarFilterKey) {
221
- this.iconTabBar.setSelectedKey(iconTabBarFilterKey);
222
- }
223
- const executeAction = async () => await this.context.actionService.execute(table.getId(), changeColumnActionId);
224
- if (isA(SMART_TABLE_TYPE, table)) {
225
- await executeAction();
226
- } else if (isA(M_TABLE_TYPE, table)) {
227
- if (this.isTableLoaded(table)) {
228
- await executeAction();
229
- } else {
230
- table.attachEventOnce('updateFinished', executeAction, this);
231
- }
232
- }
233
- return [];
234
- }
235
- isAbsoluteAggregationBinding(element, aggregationName) {
236
- const mBindingInfo = element.getBindingInfo(aggregationName);
237
- const path = mBindingInfo?.path;
238
- if (!path) {
239
- return false;
240
- }
241
- return path.indexOf('/') === 0;
242
- }
243
- isTableLoaded(element) {
244
- const aggregationName = 'items';
245
- if (this.isAbsoluteAggregationBinding(element, aggregationName)) {
246
- const bindingInfo = element.getBindingInfo(aggregationName);
247
- if (typeof bindingInfo.model === 'string' && bindingInfo.model !== '') {
248
- return false;
249
- }
250
- return bindingInfo.path !== undefined;
251
- } else {
252
- const bindingContext = element.getBindingContext();
253
- return !!bindingContext;
254
- }
60
+ isAbsoluteAggregationBinding(element, aggregationName) {
61
+ const mBindingInfo = element.getBindingInfo(aggregationName);
62
+ const path = mBindingInfo?.path;
63
+ if (!path) {
64
+ return false;
65
+ }
66
+ return path.indexOf('/') === 0;
67
+ }
68
+
69
+ /**
70
+ * Checks if table is loaded and has binding context available.
71
+ * This is needed to properly render change columns dialog.
72
+ * Based on {@link https://github.com/SAP/openui5/blob/rel-1.127/src/sap.ui.fl/src/sap/ui/fl/write/_internal/delegates/ODataV2ReadDelegate.js#L269-L271| ODataV2ReadDelegate.getPropertyInfo}.
73
+ *
74
+ * @param element - Table control.
75
+ * @returns True if binding context is available.
76
+ */
77
+ isTableLoaded(element) {
78
+ const aggregationName = 'items';
79
+ if (this.isAbsoluteAggregationBinding(element, aggregationName)) {
80
+ const bindingInfo = element.getBindingInfo(aggregationName);
81
+ // check to be default model binding otherwise return undefined
82
+ if (typeof bindingInfo.model === 'string' && bindingInfo.model !== '') {
83
+ return false;
255
84
  }
85
+ return bindingInfo.path !== undefined;
86
+ } else {
87
+ // here we explicitly request the default models binding context
88
+ const bindingContext = element.getBindingContext();
89
+ return !!bindingContext;
90
+ }
256
91
  }
257
- var __exports = { __esModule: true };
258
- __exports.CHANGE_TABLE_COLUMNS = CHANGE_TABLE_COLUMNS;
259
- __exports.ChangeTableColumnsQuickAction = ChangeTableColumnsQuickAction;
260
- return __exports;
261
- });
92
+ }
93
+ var __exports = {
94
+ __esModule: true
95
+ };
96
+ __exports.CHANGE_TABLE_COLUMNS = CHANGE_TABLE_COLUMNS;
97
+ __exports.ChangeTableColumnsQuickAction = ChangeTableColumnsQuickAction;
98
+ return __exports;
99
+ });
100
+ //# sourceMappingURL=change-table-columns.js.map