@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,305 @@
1
+ import OverlayUtil from 'sap/ui/dt/OverlayUtil';
2
+ import FlexCommand from 'sap/ui/rta/command/FlexCommand';
3
+ import UI5Element from 'sap/ui/core/Element';
4
+ import type IconTabBar from 'sap/m/IconTabBar';
5
+ import type IconTabFilter from 'sap/m/IconTabFilter';
6
+ import type Table from 'sap/m/Table';
7
+ import type SmartTable from 'sap/ui/comp/smarttable/SmartTable';
8
+
9
+ import type { NestedQuickAction, NestedQuickActionChild } from '@sap-ux-private/control-property-editor-common';
10
+ import { NESTED_QUICK_ACTION_KIND } from '@sap-ux-private/control-property-editor-common';
11
+
12
+ import { QuickActionContext, NestedQuickActionDefinition } from '../../../cpe/quick-actions/quick-action-definition';
13
+ import { getParentContainer, getRelevantControlFromActivePage } from '../../../cpe/quick-actions/utils';
14
+ import { getControlById, isA, isManagedObject } from '../../../utils/core';
15
+ import { getUi5Version, isLowerThanMinimalUi5Version } from '../../../utils/version';
16
+ import ObjectPageSection from 'sap/uxap/ObjectPageSection';
17
+ import ObjectPageSubSection from 'sap/uxap/ObjectPageSubSection';
18
+ import TreeTable from 'sap/ui/table/TreeTable';
19
+ import ObjectPageLayout from 'sap/uxap/ObjectPageLayout';
20
+ import ManagedObject from 'sap/ui/base/ManagedObject';
21
+
22
+ export const CHANGE_TABLE_COLUMNS = 'change-table-columns';
23
+ const SMART_TABLE_ACTION_ID = 'CTX_COMP_VARIANT_CONTENT';
24
+ const M_TABLE_ACTION_ID = 'CTX_ADD_ELEMENTS_AS_CHILD';
25
+ const SETTINGS_ID = 'CTX_SETTINGS';
26
+ const ICON_TAB_BAR_TYPE = 'sap.m.IconTabBar';
27
+ const SMART_TABLE_TYPE = 'sap.ui.comp.smarttable.SmartTable';
28
+ const M_TABLE_TYPE = 'sap.m.Table';
29
+ // maintain order if action id
30
+ const CONTROL_TYPES = [SMART_TABLE_TYPE, M_TABLE_TYPE, 'sap.ui.table.TreeTable', 'sap.ui.table.Table'];
31
+
32
+ async function getActionId(table: UI5Element): Promise<string[]> {
33
+ const { major, minor } = await getUi5Version();
34
+
35
+ if (isA(SMART_TABLE_TYPE, table)) {
36
+ if (major === 1 && minor === 96) {
37
+ return [SETTINGS_ID];
38
+ } else {
39
+ return [SMART_TABLE_ACTION_ID];
40
+ }
41
+ }
42
+
43
+ return [M_TABLE_ACTION_ID, SETTINGS_ID];
44
+ }
45
+
46
+ export class ChangeTableColumnsQuickAction implements NestedQuickActionDefinition {
47
+ readonly kind = NESTED_QUICK_ACTION_KIND;
48
+ readonly type = CHANGE_TABLE_COLUMNS;
49
+ public get id(): string {
50
+ return `${this.context.key}-${this.type}`;
51
+ }
52
+ isActive = false;
53
+ isClearButtonEnabled = false;
54
+ children: NestedQuickActionChild[] = [];
55
+ tableMap: Record<
56
+ string,
57
+ {
58
+ table: UI5Element;
59
+ tableUpdateEventAttachedOnce: boolean;
60
+ iconTabBarFilterKey?: string;
61
+ changeColumnActionId: string;
62
+ sectionInfo?: {
63
+ section: ObjectPageSection;
64
+ subSection: ObjectPageSubSection;
65
+ layout?: ObjectPageLayout;
66
+ };
67
+ }
68
+ > = {};
69
+ private iconTabBar: IconTabBar | undefined;
70
+ constructor(private context: QuickActionContext) {}
71
+
72
+ async initialize(): Promise<void> {
73
+ // No action found in control design time for version < 1.96
74
+ const version = await getUi5Version();
75
+ if (isLowerThanMinimalUi5Version(version, { major: 1, minor: 96 })) {
76
+ this.isActive = false;
77
+ return;
78
+ }
79
+ const iconTabBarfilterMap = this.buildIconTabBarFilterMap();
80
+ for (const table of getRelevantControlFromActivePage(
81
+ this.context.controlIndex,
82
+ this.context.view,
83
+ CONTROL_TYPES
84
+ )) {
85
+ const actions = await this.context.actionService.get(table.getId());
86
+ const actionsIds = await getActionId(table);
87
+ const changeColumnAction = actionsIds.find(
88
+ (actionId) => actions.findIndex((action) => action.id === actionId) > -1
89
+ );
90
+ const tabKey = Object.keys(iconTabBarfilterMap).find((key) => table.getId().endsWith(key));
91
+ if (changeColumnAction) {
92
+ const section = getParentContainer<ObjectPageSection>(table, 'sap.uxap.ObjectPageSection');
93
+ if (section) {
94
+ this.collectChildrenInSection(section, table, changeColumnAction);
95
+ } else if (this.iconTabBar && tabKey) {
96
+ this.children.push({
97
+ label: `'${iconTabBarfilterMap[tabKey]}' table`,
98
+ children: []
99
+ });
100
+ this.tableMap[`${this.children.length - 1}`] = {
101
+ table,
102
+ iconTabBarFilterKey: tabKey,
103
+ changeColumnActionId: changeColumnAction,
104
+ tableUpdateEventAttachedOnce: false
105
+ };
106
+ } else {
107
+ this.processTable(table, changeColumnAction);
108
+ }
109
+ }
110
+ }
111
+ if (this.children.length > 0) {
112
+ this.isActive = true;
113
+ }
114
+ }
115
+
116
+ private getTableLabel(table: UI5Element): string {
117
+ if (isA<SmartTable>(SMART_TABLE_TYPE, table)) {
118
+ const header = table.getHeader();
119
+ if (header) {
120
+ return `'${header}' table`;
121
+ }
122
+ }
123
+ if (isA<Table>(M_TABLE_TYPE, table)) {
124
+ const tilte = table?.getHeaderToolbar()?.getTitleControl()?.getText();
125
+ if (tilte) {
126
+ return `'${tilte}' table`;
127
+ }
128
+ }
129
+
130
+ return 'Unnamed table';
131
+ }
132
+
133
+ private buildIconTabBarFilterMap(): { [key: string]: string } {
134
+ const iconTabBarfilterMap: { [key: string]: string } = {};
135
+
136
+ // Assumption only a tab bar control per page.
137
+ const tabBar = getRelevantControlFromActivePage(this.context.controlIndex, this.context.view, [
138
+ ICON_TAB_BAR_TYPE
139
+ ])[0];
140
+ if (tabBar) {
141
+ const control = getControlById(tabBar.getId());
142
+ if (isA<IconTabBar>(ICON_TAB_BAR_TYPE, control)) {
143
+ this.iconTabBar = control;
144
+ for (const item of control.getItems()) {
145
+ if (isManagedObject(item) && isA<IconTabFilter>('sap.m.IconTabFilter', item)) {
146
+ iconTabBarfilterMap[item.getKey()] = item.getText();
147
+ }
148
+ }
149
+ }
150
+ }
151
+
152
+ return iconTabBarfilterMap;
153
+ }
154
+
155
+ private collectChildrenInSection(section: ObjectPageSection, table: UI5Element, changeColumnAction: string): void {
156
+ const layout = getParentContainer<ObjectPageLayout>(table, 'sap.uxap.ObjectPageLayout');
157
+ const subSections = section.getSubSections();
158
+ const subSection = getParentContainer<ObjectPageSubSection>(table, 'sap.uxap.ObjectPageSubSection');
159
+ if (subSection) {
160
+ if (subSections?.length === 1) {
161
+ this.processTable(table, changeColumnAction, { section, subSection: subSections[0], layout });
162
+ } else if (subSections.length > 1) {
163
+ const sectionChild = this.children.find((val) => val.label === `${section.getTitle()} section`);
164
+ let tableMapIndex = `${this.children.length - 1}`;
165
+ if (!sectionChild) {
166
+ tableMapIndex = `${tableMapIndex}/0`;
167
+ this.children.push({
168
+ label: `'${section?.getTitle()}' section`,
169
+ children: [
170
+ {
171
+ label: this.getTableLabel(table),
172
+ children: []
173
+ }
174
+ ]
175
+ });
176
+ } else {
177
+ tableMapIndex = `${tableMapIndex}/${sectionChild.children.length - 1}`;
178
+ sectionChild.children.push({
179
+ label: this.getTableLabel(table),
180
+ children: []
181
+ });
182
+ }
183
+
184
+ this.tableMap[tableMapIndex] = {
185
+ table,
186
+ changeColumnActionId: changeColumnAction,
187
+ sectionInfo: { section, subSection, layout },
188
+ tableUpdateEventAttachedOnce: false
189
+ };
190
+ }
191
+ }
192
+ }
193
+
194
+ private processTable(
195
+ table: UI5Element,
196
+ changeColumnActionId: string,
197
+ sectionInfo?: { section: ObjectPageSection; subSection: ObjectPageSubSection; layout?: ObjectPageLayout }
198
+ ): void {
199
+ if (isA<SmartTable>(SMART_TABLE_TYPE, table) || isA<TreeTable>('sap.ui.table.TreeTable', table)) {
200
+ this.children.push({
201
+ label: this.getTableLabel(table),
202
+ children: []
203
+ });
204
+ }
205
+ if (isA<Table>(M_TABLE_TYPE, table)) {
206
+ this.children.push({
207
+ label: this.getTableLabel(table),
208
+ children: []
209
+ });
210
+ }
211
+ this.tableMap[`${this.children.length - 1}`] = {
212
+ table,
213
+ changeColumnActionId,
214
+ sectionInfo: sectionInfo,
215
+ tableUpdateEventAttachedOnce: false
216
+ };
217
+ }
218
+
219
+ getActionObject(): NestedQuickAction {
220
+ return {
221
+ kind: NESTED_QUICK_ACTION_KIND,
222
+ id: this.id,
223
+ enabled: this.isActive,
224
+ title:
225
+ this.context.resourceBundle.getText('V2_QUICK_ACTION_CHANGE_TABLE_COLUMNS') ?? 'Change table columns',
226
+ children: this.children
227
+ };
228
+ }
229
+
230
+ private selectOverlay(table: UI5Element): void {
231
+ const controlOverlay = OverlayUtil.getClosestOverlayFor(table);
232
+ if (controlOverlay) {
233
+ controlOverlay.setSelected(true);
234
+ }
235
+ }
236
+
237
+ async execute(path: string): Promise<FlexCommand[]> {
238
+ const { table, iconTabBarFilterKey, changeColumnActionId, sectionInfo } = this.tableMap[path];
239
+ if (!table) {
240
+ return [];
241
+ }
242
+
243
+ if (sectionInfo) {
244
+ const { layout, section, subSection } = sectionInfo;
245
+ layout?.setSelectedSection(section);
246
+ section.setSelectedSubSection(subSection);
247
+ this.selectOverlay(table);
248
+ } else {
249
+ getControlById(table.getId())?.getDomRef()?.scrollIntoView();
250
+ this.selectOverlay(table);
251
+ }
252
+
253
+ if (this.iconTabBar && iconTabBarFilterKey) {
254
+ this.iconTabBar.setSelectedKey(iconTabBarFilterKey);
255
+ }
256
+
257
+ const executeAction = async () => await this.context.actionService.execute(table.getId(), changeColumnActionId);
258
+ if (isA<SmartTable>(SMART_TABLE_TYPE, table)) {
259
+ await executeAction();
260
+ } else if (isA<Table>(M_TABLE_TYPE, table)) {
261
+ // if table is busy, i.e. lazy loading, then we subscribe to 'updateFinished' event and call action service when loading is done
262
+ // to avoid reopening the dialog after close
263
+ if (this.isTableLoaded(table)) {
264
+ await executeAction();
265
+ } else {
266
+ table.attachEventOnce('updateFinished', executeAction, this);
267
+ }
268
+ }
269
+
270
+ return [];
271
+ }
272
+
273
+ private isAbsoluteAggregationBinding(element: ManagedObject, aggregationName: string): boolean {
274
+ const mBindingInfo = element.getBindingInfo(aggregationName);
275
+ const path = mBindingInfo?.path;
276
+ if (!path) {
277
+ return false;
278
+ }
279
+ return path.indexOf('/') === 0;
280
+ }
281
+
282
+ /**
283
+ * Checks if table is loaded and has binding context available.
284
+ * This is needed to properly render change columns dialog.
285
+ * 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}.
286
+ *
287
+ * @param element - Table control.
288
+ * @returns True if binding context is available.
289
+ */
290
+ private isTableLoaded(element: ManagedObject): boolean {
291
+ const aggregationName = 'items';
292
+ if (this.isAbsoluteAggregationBinding(element, aggregationName)) {
293
+ const bindingInfo = element.getBindingInfo(aggregationName);
294
+ // check to be default model binding otherwise return undefined
295
+ if (typeof bindingInfo.model === 'string' && bindingInfo.model !== '') {
296
+ return false;
297
+ }
298
+ return bindingInfo.path !== undefined;
299
+ } else {
300
+ // here we explicitly request the default models binding context
301
+ const bindingContext = element.getBindingContext();
302
+ return !!bindingContext;
303
+ }
304
+ }
305
+ }
@@ -0,0 +1,67 @@
1
+ 'use strict';
2
+ sap.ui.define([
3
+ 'sap/ui/rta/command/CommandFactory',
4
+ 'open/ux/preview/client/thirdparty/@sap-ux-private/control-property-editor-common',
5
+ '../../../cpe/quick-actions/utils',
6
+ '../../../utils/core'
7
+ ], function (CommandFactory, ___sap_ux_private_control_property_editor_common, _____cpe_quick_actions_utils, _____utils_core) {
8
+ 'use strict';
9
+ const SIMPLE_QUICK_ACTION_KIND = ___sap_ux_private_control_property_editor_common['SIMPLE_QUICK_ACTION_KIND'];
10
+ const pageHasControlId = _____cpe_quick_actions_utils['pageHasControlId'];
11
+ const getControlById = _____utils_core['getControlById'];
12
+ const ENABLE_CLEAR_FILTER_BAR_TYPE = 'enable-clear-filter-bar';
13
+ const PROPERTY_NAME = 'showClearOnFB';
14
+ const CONTROL_TYPE = 'sap.ui.comp.smartfilterbar.SmartFilterBar';
15
+ class ToggleClearFilterBarQuickAction {
16
+ kind = SIMPLE_QUICK_ACTION_KIND;
17
+ type = ENABLE_CLEAR_FILTER_BAR_TYPE;
18
+ get id() {
19
+ return `${ this.context.key }-${ this.type }`;
20
+ }
21
+ get isActive() {
22
+ return !!this.filterBar;
23
+ }
24
+ isClearButtonEnabled = false;
25
+ constructor(context) {
26
+ this.context = context;
27
+ }
28
+ initialize() {
29
+ const controls = this.context.controlIndex[CONTROL_TYPE] ?? [];
30
+ for (const control of controls) {
31
+ const isActionApplicable = pageHasControlId(this.context.view, control.controlId);
32
+ const modifiedControl = getControlById(control.controlId);
33
+ if (isActionApplicable && modifiedControl) {
34
+ this.isClearButtonEnabled = modifiedControl.getShowClearOnFB();
35
+ this.filterBar = modifiedControl;
36
+ }
37
+ }
38
+ }
39
+ getActionObject() {
40
+ const key = this.isClearButtonEnabled ? 'V2_QUICK_ACTION_LR_DISABLE_CLEAR_FILTER_BAR' : 'V2_QUICK_ACTION_LR_ENABLE_CLEAR_FILTER_BAR';
41
+ return {
42
+ kind: SIMPLE_QUICK_ACTION_KIND,
43
+ id: this.id,
44
+ enabled: this.isActive,
45
+ title: this.context.resourceBundle.getText(key)
46
+ };
47
+ }
48
+ async execute() {
49
+ if (this.filterBar) {
50
+ const {flexSettings} = this.context;
51
+ const modifiedValue = {
52
+ generator: flexSettings.generator,
53
+ propertyName: PROPERTY_NAME,
54
+ newValue: !this.isClearButtonEnabled
55
+ };
56
+ const command = await CommandFactory.getCommandFor(this.filterBar, 'Property', modifiedValue, null, flexSettings);
57
+ this.isClearButtonEnabled = !this.isClearButtonEnabled;
58
+ return [command];
59
+ }
60
+ return [];
61
+ }
62
+ }
63
+ var __exports = { __esModule: true };
64
+ __exports.ENABLE_CLEAR_FILTER_BAR_TYPE = ENABLE_CLEAR_FILTER_BAR_TYPE;
65
+ __exports.ToggleClearFilterBarQuickAction = ToggleClearFilterBarQuickAction;
66
+ return __exports;
67
+ });
@@ -0,0 +1,84 @@
1
+ import FlexCommand from 'sap/ui/rta/command/FlexCommand';
2
+ import CommandFactory from 'sap/ui/rta/command/CommandFactory';
3
+ import type FilterBar from 'sap/ui/comp/filterbar/FilterBar';
4
+
5
+ import { SIMPLE_QUICK_ACTION_KIND, SimpleQuickAction } from '@sap-ux-private/control-property-editor-common';
6
+
7
+ import { QuickActionContext, SimpleQuickActionDefinition } from '../../../cpe/quick-actions/quick-action-definition';
8
+
9
+ import { pageHasControlId } from '../../../cpe/quick-actions/utils';
10
+ import { getControlById } from '../../../utils/core';
11
+
12
+ export const ENABLE_CLEAR_FILTER_BAR_TYPE = 'enable-clear-filter-bar';
13
+ const PROPERTY_NAME = 'showClearOnFB';
14
+
15
+ const CONTROL_TYPE = 'sap.ui.comp.smartfilterbar.SmartFilterBar';
16
+
17
+ /**
18
+ * Quick Action for toggling the visibility of "clear filter bar" button in List Report page.
19
+ */
20
+ export class ToggleClearFilterBarQuickAction implements SimpleQuickActionDefinition {
21
+ readonly kind = SIMPLE_QUICK_ACTION_KIND;
22
+ readonly type = ENABLE_CLEAR_FILTER_BAR_TYPE;
23
+
24
+ public get id(): string {
25
+ return `${this.context.key}-${this.type}`;
26
+ }
27
+
28
+ public get isActive(): boolean {
29
+ return !!this.filterBar;
30
+ }
31
+
32
+ private isClearButtonEnabled = false;
33
+ private filterBar: FilterBar | undefined;
34
+ constructor(private context: QuickActionContext) {}
35
+
36
+ initialize(): void {
37
+ const controls = this.context.controlIndex[CONTROL_TYPE] ?? [];
38
+ for (const control of controls) {
39
+ const isActionApplicable = pageHasControlId(this.context.view, control.controlId);
40
+ const modifiedControl = getControlById<FilterBar>(control.controlId);
41
+ if (isActionApplicable && modifiedControl) {
42
+ this.isClearButtonEnabled = modifiedControl.getShowClearOnFB();
43
+ this.filterBar = modifiedControl;
44
+ }
45
+ }
46
+ }
47
+
48
+ getActionObject(): SimpleQuickAction {
49
+ const key = this.isClearButtonEnabled
50
+ ? 'V2_QUICK_ACTION_LR_DISABLE_CLEAR_FILTER_BAR'
51
+ : 'V2_QUICK_ACTION_LR_ENABLE_CLEAR_FILTER_BAR';
52
+ return {
53
+ kind: SIMPLE_QUICK_ACTION_KIND,
54
+ id: this.id,
55
+ enabled: this.isActive,
56
+ title: this.context.resourceBundle.getText(key)
57
+ };
58
+ }
59
+
60
+ async execute(): Promise<FlexCommand[]> {
61
+ if (this.filterBar) {
62
+ const { flexSettings } = this.context;
63
+
64
+ const modifiedValue = {
65
+ generator: flexSettings.generator,
66
+ propertyName: PROPERTY_NAME,
67
+ newValue: !this.isClearButtonEnabled
68
+ };
69
+
70
+ const command = await CommandFactory.getCommandFor<FlexCommand>(
71
+ this.filterBar,
72
+ 'Property',
73
+ modifiedValue,
74
+ null,
75
+ flexSettings
76
+ );
77
+
78
+ this.isClearButtonEnabled = !this.isClearButtonEnabled;
79
+ return [command];
80
+ }
81
+
82
+ return [];
83
+ }
84
+ }
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+
3
+ sap.ui.define(["sap/ui/core/mvc/XMLView", "../../../cpe/quick-actions/registry", "../common/add-controller-to-page", "./lr-toggle-clear-filter-bar", "./change-table-columns", "../common/op-add-header-field"], function (XMLView, _____cpe_quick_actions_registry, ___common_add_controller_to_page, ___lr_toggle_clear_filter_bar, ___change_table_columns, ___common_op_add_header_field) {
4
+ "use strict";
5
+
6
+ const QuickActionDefinitionRegistry = _____cpe_quick_actions_registry["QuickActionDefinitionRegistry"];
7
+ const AddControllerToPageQuickAction = ___common_add_controller_to_page["AddControllerToPageQuickAction"];
8
+ const ToggleClearFilterBarQuickAction = ___lr_toggle_clear_filter_bar["ToggleClearFilterBarQuickAction"];
9
+ const ChangeTableColumnsQuickAction = ___change_table_columns["ChangeTableColumnsQuickAction"];
10
+ const AddHeaderFieldQuickAction = ___common_op_add_header_field["AddHeaderFieldQuickAction"];
11
+ const OBJECT_PAGE_TYPE = 'sap.suite.ui.generic.template.ObjectPage.view.Details';
12
+ const LIST_REPORT_TYPE = 'sap.suite.ui.generic.template.ListReport.view.ListReport';
13
+
14
+ /**
15
+ * Quick Action provider for SAP Fiori Elements V2 applications.
16
+ */
17
+ class FEV2QuickActionRegistry extends QuickActionDefinitionRegistry {
18
+ PAGE_NAME_MAP = {
19
+ [LIST_REPORT_TYPE]: 'listReport',
20
+ [OBJECT_PAGE_TYPE]: 'objectPage'
21
+ };
22
+ getDefinitions(context) {
23
+ const activePages = this.getActivePageContent(context.controlIndex);
24
+ const definitionGroups = [];
25
+ for (let index = 0; index < activePages.length; index++) {
26
+ const {
27
+ name,
28
+ view
29
+ } = activePages[index];
30
+ if (name === 'listReport') {
31
+ definitionGroups.push({
32
+ title: 'LIST REPORT',
33
+ definitions: [ToggleClearFilterBarQuickAction, AddControllerToPageQuickAction, ChangeTableColumnsQuickAction],
34
+ view,
35
+ key: name + index
36
+ });
37
+ } else if (name === 'objectPage') {
38
+ definitionGroups.push({
39
+ title: 'OBJECT PAGE',
40
+ definitions: [AddControllerToPageQuickAction, ChangeTableColumnsQuickAction, AddHeaderFieldQuickAction],
41
+ view,
42
+ key: name + index
43
+ });
44
+ }
45
+ }
46
+ return definitionGroups;
47
+ }
48
+ getComponentContainerFromPage(page) {
49
+ if (page instanceof XMLView) {
50
+ return page.getContent()[0];
51
+ }
52
+ return undefined;
53
+ }
54
+ }
55
+ return FEV2QuickActionRegistry;
56
+ });
57
+ //# sourceMappingURL=registry.js.map
@@ -0,0 +1,69 @@
1
+ import XMLView from 'sap/ui/core/mvc/XMLView';
2
+
3
+ import type {
4
+ QuickActionActivationContext,
5
+ QuickActionDefinitionGroup
6
+ } from '../../../cpe/quick-actions/quick-action-definition';
7
+ import { QuickActionDefinitionRegistry } from '../../../cpe/quick-actions/registry';
8
+
9
+ import { AddControllerToPageQuickAction } from '../common/add-controller-to-page';
10
+
11
+ import { ToggleClearFilterBarQuickAction } from './lr-toggle-clear-filter-bar';
12
+ import { ChangeTableColumnsQuickAction } from './change-table-columns';
13
+ import { AddHeaderFieldQuickAction } from '../common/op-add-header-field';
14
+ import Control from 'sap/ui/core/Control';
15
+
16
+ type PageName = 'listReport' | 'objectPage';
17
+
18
+ const OBJECT_PAGE_TYPE = 'sap.suite.ui.generic.template.ObjectPage.view.Details';
19
+ const LIST_REPORT_TYPE = 'sap.suite.ui.generic.template.ListReport.view.ListReport';
20
+
21
+ /**
22
+ * Quick Action provider for SAP Fiori Elements V2 applications.
23
+ */
24
+ export default class FEV2QuickActionRegistry extends QuickActionDefinitionRegistry<PageName> {
25
+ PAGE_NAME_MAP: Record<string, PageName> = {
26
+ [LIST_REPORT_TYPE]: 'listReport',
27
+ [OBJECT_PAGE_TYPE]: 'objectPage'
28
+ };
29
+ getDefinitions(context: QuickActionActivationContext): QuickActionDefinitionGroup[] {
30
+ const activePages = this.getActivePageContent(context.controlIndex);
31
+
32
+ const definitionGroups: QuickActionDefinitionGroup[] = [];
33
+ for (let index = 0; index < activePages.length; index++) {
34
+ const { name, view } = activePages[index];
35
+ if (name === 'listReport') {
36
+ definitionGroups.push({
37
+ title: 'LIST REPORT',
38
+ definitions: [
39
+ ToggleClearFilterBarQuickAction,
40
+ AddControllerToPageQuickAction,
41
+ ChangeTableColumnsQuickAction
42
+ ],
43
+ view,
44
+ key: name + index
45
+ });
46
+ } else if (name === 'objectPage') {
47
+ definitionGroups.push({
48
+ title: 'OBJECT PAGE',
49
+ definitions: [
50
+ AddControllerToPageQuickAction,
51
+ ChangeTableColumnsQuickAction,
52
+ AddHeaderFieldQuickAction
53
+ ],
54
+ view,
55
+ key: name + index
56
+ });
57
+ }
58
+ }
59
+ return definitionGroups;
60
+ }
61
+
62
+ protected getComponentContainerFromPage(page: Control): Control | undefined {
63
+ if (page instanceof XMLView) {
64
+ return page.getContent()[0];
65
+ }
66
+ return undefined;
67
+ }
68
+
69
+ }
@@ -0,0 +1,84 @@
1
+ 'use strict';
2
+ sap.ui.define([
3
+ 'sap/ui/dt/OverlayUtil',
4
+ 'sap/ui/fl/apply/api/FlexRuntimeInfoAPI',
5
+ 'open/ux/preview/client/thirdparty/@sap-ux-private/control-property-editor-common',
6
+ '../../../cpe/quick-actions/utils',
7
+ '../../../utils/core'
8
+ ], function (OverlayUtil, FlexRuntimeInfoAPI, ___sap_ux_private_control_property_editor_common, _____cpe_quick_actions_utils, _____utils_core) {
9
+ 'use strict';
10
+ const NESTED_QUICK_ACTION_KIND = ___sap_ux_private_control_property_editor_common['NESTED_QUICK_ACTION_KIND'];
11
+ const getRelevantControlFromActivePage = _____cpe_quick_actions_utils['getRelevantControlFromActivePage'];
12
+ const getControlById = _____utils_core['getControlById'];
13
+ const CHANGE_TABLE_COLUMNS = 'change-table-columns';
14
+ const ACTION_ID = 'CTX_SETTINGS0';
15
+ const CONTROL_TYPE = 'sap.ui.mdc.Table';
16
+ class ChangeTableColumnsQuickAction {
17
+ kind = NESTED_QUICK_ACTION_KIND;
18
+ type = CHANGE_TABLE_COLUMNS;
19
+ get id() {
20
+ return `${ this.context.key }-${ this.type }`;
21
+ }
22
+ isActive = false;
23
+ isClearButtonEnabled = false;
24
+ children = [];
25
+ tableMap = {};
26
+ constructor(context) {
27
+ this.context = context;
28
+ }
29
+ async initialize() {
30
+ let index = 0;
31
+ for (const smartTable of getRelevantControlFromActivePage(this.context.controlIndex, this.context.view, [CONTROL_TYPE])) {
32
+ const hasVariantManagement = FlexRuntimeInfoAPI.hasVariantManagement({ element: smartTable });
33
+ if (!hasVariantManagement) {
34
+ continue;
35
+ }
36
+ const actions = await this.context.actionService.get(smartTable.getId());
37
+ const changeColumnAction = actions.find(action => action.id === ACTION_ID);
38
+ if (changeColumnAction) {
39
+ this.children.push({
40
+ label: `'${ smartTable.getHeader() }' table`,
41
+ children: []
42
+ });
43
+ this.tableMap[`${ this.children.length - 1 }`] = index;
44
+ index++;
45
+ }
46
+ }
47
+ if (this.children.length > 0) {
48
+ this.isActive = true;
49
+ }
50
+ }
51
+ getActionObject() {
52
+ return {
53
+ kind: NESTED_QUICK_ACTION_KIND,
54
+ id: this.id,
55
+ enabled: this.isActive,
56
+ title: this.context.resourceBundle.getText('V4_QUICK_ACTION_CHANGE_TABLE_COLUMNS'),
57
+ children: this.children
58
+ };
59
+ }
60
+ async execute(path) {
61
+ const index = this.tableMap[path];
62
+ const smartTables = getRelevantControlFromActivePage(this.context.controlIndex, this.context.view, [CONTROL_TYPE]);
63
+ for (let i = 0; i < smartTables.length; i++) {
64
+ if (i === index) {
65
+ const section = getControlById(smartTables[i].getId());
66
+ const controlOverlay = OverlayUtil.getClosestOverlayFor(section);
67
+ if (controlOverlay) {
68
+ controlOverlay.setSelected(true);
69
+ }
70
+ const hasVariantManagement = FlexRuntimeInfoAPI.hasVariantManagement({ element: smartTables[i] });
71
+ if (!hasVariantManagement) {
72
+ continue;
73
+ }
74
+ await this.context.actionService.execute(smartTables[i].getId(), ACTION_ID);
75
+ }
76
+ }
77
+ return [];
78
+ }
79
+ }
80
+ var __exports = { __esModule: true };
81
+ __exports.CHANGE_TABLE_COLUMNS = CHANGE_TABLE_COLUMNS;
82
+ __exports.ChangeTableColumnsQuickAction = ChangeTableColumnsQuickAction;
83
+ return __exports;
84
+ });