@sap-ux/preview-middleware 0.16.58 → 0.16.59

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.
Files changed (71) hide show
  1. package/dist/client/adp/controllers/AddFragment.controller.js +3 -2
  2. package/dist/client/adp/controllers/AddFragment.controller.ts +2 -2
  3. package/dist/client/adp/controllers/ControllerExtension.controller.js +3 -18
  4. package/dist/client/adp/controllers/ControllerExtension.controller.ts +2 -24
  5. package/dist/client/adp/init-dialogs.js +22 -7
  6. package/dist/client/adp/init-dialogs.ts +31 -8
  7. package/dist/client/adp/init.js +19 -40
  8. package/dist/client/adp/init.ts +17 -56
  9. package/dist/client/adp/quick-actions/common/add-controller-to-page.js +70 -0
  10. package/dist/client/adp/quick-actions/common/add-controller-to-page.ts +71 -0
  11. package/dist/client/adp/quick-actions/common/op-add-header-field.js +59 -0
  12. package/dist/client/adp/quick-actions/common/op-add-header-field.ts +71 -0
  13. package/dist/client/adp/quick-actions/fe-v2/change-table-columns.js +261 -0
  14. package/dist/client/adp/quick-actions/fe-v2/change-table-columns.ts +305 -0
  15. package/dist/client/adp/quick-actions/fe-v2/lr-toggle-clear-filter-bar.js +67 -0
  16. package/dist/client/adp/quick-actions/fe-v2/lr-toggle-clear-filter-bar.ts +84 -0
  17. package/dist/client/adp/quick-actions/fe-v2/registry.js +57 -0
  18. package/dist/client/adp/quick-actions/fe-v2/registry.ts +69 -0
  19. package/dist/client/adp/quick-actions/fe-v4/change-table-columns.js +84 -0
  20. package/dist/client/adp/quick-actions/fe-v4/change-table-columns.ts +90 -0
  21. package/dist/client/adp/quick-actions/fe-v4/lr-toggle-clear-filter-bar.js +88 -0
  22. package/dist/client/adp/quick-actions/fe-v4/lr-toggle-clear-filter-bar.ts +97 -0
  23. package/dist/client/adp/quick-actions/fe-v4/registry.js +51 -0
  24. package/dist/client/adp/quick-actions/fe-v4/registry.ts +58 -0
  25. package/dist/client/adp/quick-actions/fe-v4/utils.js +54 -0
  26. package/dist/client/adp/quick-actions/fe-v4/utils.ts +47 -0
  27. package/dist/client/adp/quick-actions/load.js +46 -0
  28. package/dist/client/adp/quick-actions/load.ts +23 -0
  29. package/dist/client/adp/utils.js +97 -1
  30. package/dist/client/adp/utils.ts +83 -0
  31. package/dist/client/cpe/changes/service.js +2 -2
  32. package/dist/client/cpe/changes/service.ts +2 -2
  33. package/dist/client/cpe/control-data.js +3 -3
  34. package/dist/client/cpe/control-data.ts +8 -7
  35. package/dist/client/cpe/init.js +14 -8
  36. package/dist/client/cpe/init.ts +25 -11
  37. package/dist/client/cpe/outline/{utils.js → editable.js} +3 -30
  38. package/dist/client/cpe/outline/{utils.ts → editable.ts} +1 -29
  39. package/dist/client/cpe/outline/nodes.js +27 -9
  40. package/dist/client/cpe/outline/nodes.ts +33 -8
  41. package/dist/client/cpe/outline/service.js +60 -0
  42. package/dist/client/cpe/outline/service.ts +73 -0
  43. package/dist/client/cpe/quick-actions/quick-action-definition.js +6 -0
  44. package/dist/client/cpe/quick-actions/quick-action-definition.ts +115 -0
  45. package/dist/client/cpe/quick-actions/quick-action-service.js +101 -0
  46. package/dist/client/cpe/quick-actions/quick-action-service.ts +142 -0
  47. package/dist/client/cpe/quick-actions/registry.js +145 -0
  48. package/dist/client/cpe/quick-actions/registry.ts +156 -0
  49. package/dist/client/cpe/quick-actions/utils.js +94 -0
  50. package/dist/client/cpe/quick-actions/utils.ts +114 -0
  51. package/dist/client/cpe/rta-service.ts +1 -0
  52. package/dist/client/cpe/selection.js +3 -3
  53. package/dist/client/cpe/selection.ts +1 -1
  54. package/dist/client/cpe/types.ts +7 -3
  55. package/dist/client/cpe/ui5-utils.js +1 -17
  56. package/dist/client/cpe/ui5-utils.ts +0 -17
  57. package/dist/client/cpe/utils.js +50 -1
  58. package/dist/client/cpe/utils.ts +54 -0
  59. package/dist/client/i18n.js +43 -0
  60. package/dist/client/i18n.ts +34 -0
  61. package/dist/client/manifest.json +1 -1
  62. package/dist/client/messagebundle.properties +17 -0
  63. package/dist/client/thirdparty/@sap-ux-private/control-property-editor-common.js +6 -1
  64. package/dist/client/tsconfig.tsbuildinfo +1 -0
  65. package/dist/client/utils/application.js +34 -0
  66. package/dist/client/utils/application.ts +27 -0
  67. package/dist/client/utils/core.js +70 -0
  68. package/dist/client/utils/core.ts +61 -0
  69. package/package.json +3 -3
  70. package/dist/client/cpe/outline/index.js +0 -40
  71. package/dist/client/cpe/outline/index.ts +0 -37
@@ -0,0 +1,59 @@
1
+ 'use strict';
2
+ sap.ui.define([
3
+ 'sap/ui/dt/OverlayRegistry',
4
+ 'open/ux/preview/client/thirdparty/@sap-ux-private/control-property-editor-common',
5
+ '../../../adp/init-dialogs',
6
+ '../../../cpe/quick-actions/utils',
7
+ '../../../utils/core'
8
+ ], function (OverlayRegistry, ___sap_ux_private_control_property_editor_common, _____adp_init_dialogs, _____cpe_quick_actions_utils, _____utils_core) {
9
+ 'use strict';
10
+ const SIMPLE_QUICK_ACTION_KIND = ___sap_ux_private_control_property_editor_common['SIMPLE_QUICK_ACTION_KIND'];
11
+ const DialogNames = _____adp_init_dialogs['DialogNames'];
12
+ const handler = _____adp_init_dialogs['handler'];
13
+ const getRelevantControlFromActivePage = _____cpe_quick_actions_utils['getRelevantControlFromActivePage'];
14
+ const isA = _____utils_core['isA'];
15
+ const OP_ADD_HEADER_FIELD_TYPE = 'op-add-header-field';
16
+ const CONTROL_TYPES = ['sap.uxap.ObjectPageLayout'];
17
+ class AddHeaderFieldQuickAction {
18
+ kind = SIMPLE_QUICK_ACTION_KIND;
19
+ type = OP_ADD_HEADER_FIELD_TYPE;
20
+ get id() {
21
+ return `${ this.context.key }-${ this.type }`;
22
+ }
23
+ isActive = false;
24
+ constructor(context) {
25
+ this.context = context;
26
+ }
27
+ initialize() {
28
+ for (const control of getRelevantControlFromActivePage(this.context.controlIndex, this.context.view, CONTROL_TYPES)) {
29
+ this.isActive = true;
30
+ this.control = control;
31
+ break;
32
+ }
33
+ }
34
+ getActionObject() {
35
+ return {
36
+ kind: SIMPLE_QUICK_ACTION_KIND,
37
+ id: this.id,
38
+ enabled: this.isActive,
39
+ title: this.context.resourceBundle.getText('QUICK_ACTION_OP_ADD_HEADER_FIELD')
40
+ };
41
+ }
42
+ async execute() {
43
+ const objectPageLayout = getRelevantControlFromActivePage(this.context.controlIndex, this.context.view, CONTROL_TYPES)[0];
44
+ const headerContent = objectPageLayout.getHeaderContent();
45
+ if (headerContent.length === 1 && isA('sap.m.FlexBox', headerContent[0])) {
46
+ const overlay = OverlayRegistry.getOverlay(headerContent[0]) || [];
47
+ await handler(overlay, this.context.rta, DialogNames.ADD_FRAGMENT, undefined, 'items');
48
+ } else if (this.control) {
49
+ const overlay = OverlayRegistry.getOverlay(this.control) || [];
50
+ await handler(overlay, this.context.rta, DialogNames.ADD_FRAGMENT, undefined, 'headerContent');
51
+ }
52
+ return [];
53
+ }
54
+ }
55
+ var __exports = { __esModule: true };
56
+ __exports.OP_ADD_HEADER_FIELD_TYPE = OP_ADD_HEADER_FIELD_TYPE;
57
+ __exports.AddHeaderFieldQuickAction = AddHeaderFieldQuickAction;
58
+ return __exports;
59
+ });
@@ -0,0 +1,71 @@
1
+ import OverlayRegistry from 'sap/ui/dt/OverlayRegistry';
2
+ import FlexCommand from 'sap/ui/rta/command/FlexCommand';
3
+ import UI5Element from 'sap/ui/core/Element';
4
+ import ObjectPageLayout from 'sap/uxap/ObjectPageLayout';
5
+ import FlexBox from 'sap/m/FlexBox';
6
+
7
+ import { SIMPLE_QUICK_ACTION_KIND, SimpleQuickAction } from '@sap-ux-private/control-property-editor-common';
8
+
9
+ import { DialogNames, handler } from '../../../adp/init-dialogs';
10
+
11
+ import { getRelevantControlFromActivePage } from '../../../cpe/quick-actions/utils';
12
+ import { QuickActionContext, SimpleQuickActionDefinition } from '../../../cpe/quick-actions/quick-action-definition';
13
+ import { isA } from '../../../utils/core';
14
+ export const OP_ADD_HEADER_FIELD_TYPE = 'op-add-header-field';
15
+ const CONTROL_TYPES = ['sap.uxap.ObjectPageLayout'];
16
+
17
+ /**
18
+ * Quick Action for adding a Header Field to an Object Page.
19
+ */
20
+ export class AddHeaderFieldQuickAction implements SimpleQuickActionDefinition {
21
+ readonly kind = SIMPLE_QUICK_ACTION_KIND;
22
+ readonly type = OP_ADD_HEADER_FIELD_TYPE;
23
+ public get id(): string {
24
+ return `${this.context.key}-${this.type}`;
25
+ }
26
+
27
+ isActive = false;
28
+ private control: UI5Element | undefined;
29
+ constructor(private context: QuickActionContext) {}
30
+
31
+ initialize(): void {
32
+ for (const control of getRelevantControlFromActivePage(
33
+ this.context.controlIndex,
34
+ this.context.view,
35
+ CONTROL_TYPES
36
+ )) {
37
+ this.isActive = true;
38
+ this.control = control;
39
+ break;
40
+ }
41
+ }
42
+
43
+ getActionObject(): SimpleQuickAction {
44
+ return {
45
+ kind: SIMPLE_QUICK_ACTION_KIND,
46
+ id: this.id,
47
+ enabled: this.isActive,
48
+ title: this.context.resourceBundle.getText('QUICK_ACTION_OP_ADD_HEADER_FIELD')
49
+ };
50
+ }
51
+
52
+ async execute(): Promise<FlexCommand[]> {
53
+ const objectPageLayout = getRelevantControlFromActivePage(
54
+ this.context.controlIndex,
55
+ this.context.view,
56
+ CONTROL_TYPES
57
+ )[0] as ObjectPageLayout;
58
+
59
+ const headerContent = objectPageLayout.getHeaderContent();
60
+
61
+ // check if only flex box exist in the headerContent.
62
+ if (headerContent.length === 1 && isA<FlexBox>('sap.m.FlexBox', headerContent[0])) {
63
+ const overlay = OverlayRegistry.getOverlay(headerContent[0]) || [];
64
+ await handler(overlay, this.context.rta, DialogNames.ADD_FRAGMENT, undefined, 'items');
65
+ } else if (this.control) {
66
+ const overlay = OverlayRegistry.getOverlay(this.control) || [];
67
+ await handler(overlay, this.context.rta, DialogNames.ADD_FRAGMENT, undefined, 'headerContent');
68
+ }
69
+ return [];
70
+ }
71
+ }
@@ -0,0 +1,261 @@
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();
33
+ 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
+ }
39
+ }
40
+ return [
41
+ M_TABLE_ACTION_ID,
42
+ SETTINGS_ID
43
+ ];
44
+ }
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
+ }
255
+ }
256
+ }
257
+ var __exports = { __esModule: true };
258
+ __exports.CHANGE_TABLE_COLUMNS = CHANGE_TABLE_COLUMNS;
259
+ __exports.ChangeTableColumnsQuickAction = ChangeTableColumnsQuickAction;
260
+ return __exports;
261
+ });