@sap-ux/preview-middleware 0.16.58 → 0.16.60
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.
- package/dist/client/adp/controllers/AddFragment.controller.js +3 -2
- package/dist/client/adp/controllers/AddFragment.controller.ts +2 -2
- package/dist/client/adp/controllers/ControllerExtension.controller.js +3 -18
- package/dist/client/adp/controllers/ControllerExtension.controller.ts +2 -24
- package/dist/client/adp/init-dialogs.js +22 -7
- package/dist/client/adp/init-dialogs.ts +31 -8
- package/dist/client/adp/init.js +19 -40
- package/dist/client/adp/init.ts +17 -56
- package/dist/client/adp/quick-actions/common/add-controller-to-page.js +70 -0
- package/dist/client/adp/quick-actions/common/add-controller-to-page.ts +71 -0
- package/dist/client/adp/quick-actions/common/op-add-header-field.js +59 -0
- package/dist/client/adp/quick-actions/common/op-add-header-field.ts +71 -0
- package/dist/client/adp/quick-actions/fe-v2/change-table-columns.js +261 -0
- package/dist/client/adp/quick-actions/fe-v2/change-table-columns.ts +305 -0
- package/dist/client/adp/quick-actions/fe-v2/lr-toggle-clear-filter-bar.js +67 -0
- package/dist/client/adp/quick-actions/fe-v2/lr-toggle-clear-filter-bar.ts +84 -0
- package/dist/client/adp/quick-actions/fe-v2/registry.js +57 -0
- package/dist/client/adp/quick-actions/fe-v2/registry.ts +69 -0
- package/dist/client/adp/quick-actions/fe-v4/change-table-columns.js +84 -0
- package/dist/client/adp/quick-actions/fe-v4/change-table-columns.ts +90 -0
- package/dist/client/adp/quick-actions/fe-v4/lr-toggle-clear-filter-bar.js +88 -0
- package/dist/client/adp/quick-actions/fe-v4/lr-toggle-clear-filter-bar.ts +97 -0
- package/dist/client/adp/quick-actions/fe-v4/registry.js +51 -0
- package/dist/client/adp/quick-actions/fe-v4/registry.ts +58 -0
- package/dist/client/adp/quick-actions/fe-v4/utils.js +54 -0
- package/dist/client/adp/quick-actions/fe-v4/utils.ts +47 -0
- package/dist/client/adp/quick-actions/load.js +46 -0
- package/dist/client/adp/quick-actions/load.ts +23 -0
- package/dist/client/adp/utils.js +97 -1
- package/dist/client/adp/utils.ts +83 -0
- package/dist/client/cpe/changes/service.js +2 -2
- package/dist/client/cpe/changes/service.ts +2 -2
- package/dist/client/cpe/control-data.js +3 -3
- package/dist/client/cpe/control-data.ts +8 -7
- package/dist/client/cpe/init.js +14 -8
- package/dist/client/cpe/init.ts +25 -11
- package/dist/client/cpe/outline/{utils.js → editable.js} +3 -30
- package/dist/client/cpe/outline/{utils.ts → editable.ts} +1 -29
- package/dist/client/cpe/outline/nodes.js +27 -9
- package/dist/client/cpe/outline/nodes.ts +33 -8
- package/dist/client/cpe/outline/service.js +60 -0
- package/dist/client/cpe/outline/service.ts +73 -0
- package/dist/client/cpe/quick-actions/quick-action-definition.js +6 -0
- package/dist/client/cpe/quick-actions/quick-action-definition.ts +115 -0
- package/dist/client/cpe/quick-actions/quick-action-service.js +101 -0
- package/dist/client/cpe/quick-actions/quick-action-service.ts +142 -0
- package/dist/client/cpe/quick-actions/registry.js +145 -0
- package/dist/client/cpe/quick-actions/registry.ts +156 -0
- package/dist/client/cpe/quick-actions/utils.js +94 -0
- package/dist/client/cpe/quick-actions/utils.ts +114 -0
- package/dist/client/cpe/rta-service.ts +1 -0
- package/dist/client/cpe/selection.js +3 -3
- package/dist/client/cpe/selection.ts +1 -1
- package/dist/client/cpe/types.ts +7 -3
- package/dist/client/cpe/ui5-utils.js +1 -17
- package/dist/client/cpe/ui5-utils.ts +0 -17
- package/dist/client/cpe/utils.js +50 -1
- package/dist/client/cpe/utils.ts +54 -0
- package/dist/client/i18n.js +43 -0
- package/dist/client/i18n.ts +34 -0
- package/dist/client/manifest.json +1 -1
- package/dist/client/messagebundle.properties +17 -0
- package/dist/client/thirdparty/@sap-ux-private/control-property-editor-common.js +6 -1
- package/dist/client/utils/application.js +34 -0
- package/dist/client/utils/application.ts +27 -0
- package/dist/client/utils/core.js +70 -0
- package/dist/client/utils/core.ts +61 -0
- package/package.json +4 -4
- package/dist/client/cpe/outline/index.js +0 -40
- package/dist/client/cpe/outline/index.ts +0 -37
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
sap.ui.define([
|
|
3
|
+
'sap/base/Log',
|
|
4
|
+
'open/ux/preview/client/thirdparty/@sap-ux-private/control-property-editor-common',
|
|
5
|
+
'../../utils/error',
|
|
6
|
+
'../../i18n',
|
|
7
|
+
'./nodes'
|
|
8
|
+
], function (Log, ___sap_ux_private_control_property_editor_common, ____utils_error, ____i18n, ___nodes) {
|
|
9
|
+
'use strict';
|
|
10
|
+
const outlineChanged = ___sap_ux_private_control_property_editor_common['outlineChanged'];
|
|
11
|
+
const SCENARIO = ___sap_ux_private_control_property_editor_common['SCENARIO'];
|
|
12
|
+
const showMessage = ___sap_ux_private_control_property_editor_common['showMessage'];
|
|
13
|
+
const getError = ____utils_error['getError'];
|
|
14
|
+
const getTextBundle = ____i18n['getTextBundle'];
|
|
15
|
+
const transformNodes = ___nodes['transformNodes'];
|
|
16
|
+
const OUTLINE_CHANGE_EVENT = 'OUTLINE_CHANGED';
|
|
17
|
+
class OutlineService extends EventTarget {
|
|
18
|
+
constructor(rta) {
|
|
19
|
+
super();
|
|
20
|
+
this.rta = rta;
|
|
21
|
+
}
|
|
22
|
+
async init(sendAction) {
|
|
23
|
+
const outline = await this.rta.getService('outline');
|
|
24
|
+
const scenario = this.rta.getFlexSettings().scenario;
|
|
25
|
+
const resourceBundle = await getTextBundle();
|
|
26
|
+
const key = 'ADP_REUSE_COMPONENTS_MESSAGE';
|
|
27
|
+
const message = resourceBundle.getText(key) ?? key;
|
|
28
|
+
let hasSentWarning = false;
|
|
29
|
+
const reuseComponentsIds = new Set();
|
|
30
|
+
const syncOutline = async () => {
|
|
31
|
+
try {
|
|
32
|
+
const viewNodes = await outline.get();
|
|
33
|
+
const controlIndex = {};
|
|
34
|
+
const outlineNodes = await transformNodes(viewNodes, scenario, reuseComponentsIds, controlIndex);
|
|
35
|
+
const event = new CustomEvent(OUTLINE_CHANGE_EVENT, { detail: { controlIndex } });
|
|
36
|
+
this.dispatchEvent(event);
|
|
37
|
+
sendAction(outlineChanged(outlineNodes));
|
|
38
|
+
if (reuseComponentsIds.size > 0 && scenario === SCENARIO.AdaptationProject && !hasSentWarning) {
|
|
39
|
+
sendAction(showMessage({
|
|
40
|
+
message,
|
|
41
|
+
shouldHideIframe: false
|
|
42
|
+
}));
|
|
43
|
+
hasSentWarning = true;
|
|
44
|
+
}
|
|
45
|
+
} catch (error) {
|
|
46
|
+
Log.error('Outline sync failed!', getError(error));
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
await syncOutline();
|
|
50
|
+
outline.attachEvent('update', syncOutline);
|
|
51
|
+
}
|
|
52
|
+
onOutlineChange(handler) {
|
|
53
|
+
this.addEventListener(OUTLINE_CHANGE_EVENT, handler);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
var __exports = { __esModule: true };
|
|
57
|
+
__exports.OUTLINE_CHANGE_EVENT = OUTLINE_CHANGE_EVENT;
|
|
58
|
+
__exports.OutlineService = OutlineService;
|
|
59
|
+
return __exports;
|
|
60
|
+
});
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import Log from 'sap/base/Log';
|
|
2
|
+
import type RuntimeAuthoring from 'sap/ui/rta/RuntimeAuthoring';
|
|
3
|
+
import type RTAOutlineService from 'sap/ui/rta/command/OutlineService';
|
|
4
|
+
|
|
5
|
+
import type { ExternalAction } from '@sap-ux-private/control-property-editor-common';
|
|
6
|
+
import { outlineChanged, SCENARIO, showMessage } from '@sap-ux-private/control-property-editor-common';
|
|
7
|
+
|
|
8
|
+
import { getError } from '../../utils/error';
|
|
9
|
+
import { getTextBundle } from '../../i18n';
|
|
10
|
+
import { ControlTreeIndex } from '../types';
|
|
11
|
+
import { transformNodes } from './nodes';
|
|
12
|
+
|
|
13
|
+
export const OUTLINE_CHANGE_EVENT = 'OUTLINE_CHANGED';
|
|
14
|
+
|
|
15
|
+
export interface OutlineChangedEventDetail {
|
|
16
|
+
controlIndex: ControlTreeIndex;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* A Class of WorkspaceConnectorService
|
|
20
|
+
*/
|
|
21
|
+
export class OutlineService extends EventTarget {
|
|
22
|
+
constructor(private rta: RuntimeAuthoring) {
|
|
23
|
+
super();
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Initializes connector service.
|
|
28
|
+
*
|
|
29
|
+
* @param sendAction action sender function
|
|
30
|
+
*/
|
|
31
|
+
public async init(sendAction: (action: ExternalAction) => void): Promise<void> {
|
|
32
|
+
const outline = await this.rta.getService<RTAOutlineService>('outline');
|
|
33
|
+
const scenario = this.rta.getFlexSettings().scenario;
|
|
34
|
+
const resourceBundle = await getTextBundle();
|
|
35
|
+
const key = 'ADP_REUSE_COMPONENTS_MESSAGE';
|
|
36
|
+
const message = resourceBundle.getText(key) ?? key;
|
|
37
|
+
let hasSentWarning = false;
|
|
38
|
+
const reuseComponentsIds = new Set<string>();
|
|
39
|
+
const syncOutline = async () => {
|
|
40
|
+
try {
|
|
41
|
+
const viewNodes = await outline.get();
|
|
42
|
+
const controlIndex: ControlTreeIndex = {};
|
|
43
|
+
const outlineNodes = await transformNodes(viewNodes, scenario, reuseComponentsIds, controlIndex);
|
|
44
|
+
|
|
45
|
+
const event = new CustomEvent(OUTLINE_CHANGE_EVENT, {
|
|
46
|
+
detail: {
|
|
47
|
+
controlIndex
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
this.dispatchEvent(event);
|
|
52
|
+
sendAction(outlineChanged(outlineNodes));
|
|
53
|
+
if (reuseComponentsIds.size > 0 && scenario === SCENARIO.AdaptationProject && !hasSentWarning) {
|
|
54
|
+
sendAction(
|
|
55
|
+
showMessage({
|
|
56
|
+
message,
|
|
57
|
+
shouldHideIframe: false
|
|
58
|
+
})
|
|
59
|
+
);
|
|
60
|
+
hasSentWarning = true;
|
|
61
|
+
}
|
|
62
|
+
} catch (error) {
|
|
63
|
+
Log.error('Outline sync failed!', getError(error));
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
await syncOutline();
|
|
67
|
+
outline.attachEvent('update', syncOutline);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
public onOutlineChange(handler: (event: CustomEvent<OutlineChangedEventDetail>) => void | Promise<void>): void {
|
|
71
|
+
this.addEventListener(OUTLINE_CHANGE_EVENT, handler as EventListener);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import type FlexCommand from 'sap/ui/rta/command/FlexCommand';
|
|
2
|
+
import type RuntimeAuthoring from 'sap/ui/rta/RuntimeAuthoring';
|
|
3
|
+
import type { FlexSettings, Manifest } from 'sap/ui/rta/RuntimeAuthoring';
|
|
4
|
+
import type { ActionService } from 'sap/ui/rta/service/Action';
|
|
5
|
+
import type XMLView from 'sap/ui/core/mvc/XMLView';
|
|
6
|
+
|
|
7
|
+
import type {
|
|
8
|
+
NestedQuickAction,
|
|
9
|
+
SimpleQuickAction,
|
|
10
|
+
NESTED_QUICK_ACTION_KIND,
|
|
11
|
+
SIMPLE_QUICK_ACTION_KIND
|
|
12
|
+
} from '@sap-ux-private/control-property-editor-common';
|
|
13
|
+
|
|
14
|
+
import type { TextBundle } from '../../i18n';
|
|
15
|
+
import type { ControlTreeIndex } from '../types';
|
|
16
|
+
|
|
17
|
+
export interface QuickActionActivationContext {
|
|
18
|
+
controlIndex: ControlTreeIndex;
|
|
19
|
+
actionService: ActionService;
|
|
20
|
+
manifest: Manifest;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface QuickActionContext {
|
|
24
|
+
controlIndex: ControlTreeIndex;
|
|
25
|
+
actionService: ActionService;
|
|
26
|
+
resourceBundle: TextBundle;
|
|
27
|
+
view: XMLView;
|
|
28
|
+
key: string;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* RTA should not be used directly by quick actions.
|
|
32
|
+
*
|
|
33
|
+
* Currently it is only used for actions opening ADP dialogs,
|
|
34
|
+
* but this should be removed in the future.
|
|
35
|
+
*
|
|
36
|
+
* @deprecated
|
|
37
|
+
*/
|
|
38
|
+
rta: RuntimeAuthoring;
|
|
39
|
+
flexSettings: FlexSettings;
|
|
40
|
+
manifest: Manifest;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export type QuickActionActivationData = {
|
|
44
|
+
isActive: boolean;
|
|
45
|
+
title: string;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
interface QuickActionDefinitionBase {
|
|
49
|
+
/**
|
|
50
|
+
* Used to identify between different Quick Action definitions.
|
|
51
|
+
*/
|
|
52
|
+
readonly type: string;
|
|
53
|
+
/**
|
|
54
|
+
* Used to identify Quick Action instances.
|
|
55
|
+
* All currently loaded actions must have unique ids.
|
|
56
|
+
*/
|
|
57
|
+
readonly id: string;
|
|
58
|
+
/**
|
|
59
|
+
* Most actions have side effects that already triggers Quick Action reload,
|
|
60
|
+
* however if that is not the case this property should be set to "true" to force Quick Action reload after the action is executed.
|
|
61
|
+
*/
|
|
62
|
+
readonly forceRefreshAfterExecution?: boolean;
|
|
63
|
+
/**
|
|
64
|
+
* Indicates that the Quick Action is applicable to the given context and should be displayed.
|
|
65
|
+
*/
|
|
66
|
+
isActive: boolean;
|
|
67
|
+
/**
|
|
68
|
+
* Initializes the action and checks if it should be enabled in current context.
|
|
69
|
+
*/
|
|
70
|
+
initialize: () => void | Promise<void>;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export interface SimpleQuickActionDefinition extends QuickActionDefinitionBase {
|
|
74
|
+
readonly kind: typeof SIMPLE_QUICK_ACTION_KIND;
|
|
75
|
+
/**
|
|
76
|
+
* Creates a UI representation object for the action.
|
|
77
|
+
*
|
|
78
|
+
* @returns UI representation object for the action.
|
|
79
|
+
*/
|
|
80
|
+
getActionObject: () => SimpleQuickAction;
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Executes the Quick Action.
|
|
84
|
+
*/
|
|
85
|
+
execute: () => FlexCommand[] | Promise<FlexCommand[]>;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export interface NestedQuickActionDefinition extends QuickActionDefinitionBase {
|
|
89
|
+
readonly kind: typeof NESTED_QUICK_ACTION_KIND;
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Creates a UI representation object for the action.
|
|
93
|
+
*
|
|
94
|
+
* @returns UI representation object for the action.
|
|
95
|
+
*/
|
|
96
|
+
getActionObject: () => NestedQuickAction;
|
|
97
|
+
/**
|
|
98
|
+
* Executes the Quick Action.
|
|
99
|
+
*
|
|
100
|
+
* @param path - Path to the specific child action that needs to be executed (e.g '0/1').
|
|
101
|
+
*/
|
|
102
|
+
execute: (path: string) => FlexCommand[] | Promise<FlexCommand[]>;
|
|
103
|
+
}
|
|
104
|
+
export type QuickActionDefinition = SimpleQuickActionDefinition | NestedQuickActionDefinition;
|
|
105
|
+
|
|
106
|
+
export interface QuickActionDefinitionConstructor<T extends QuickActionDefinition> {
|
|
107
|
+
new (context: QuickActionContext): T;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export interface QuickActionDefinitionGroup {
|
|
111
|
+
title: string;
|
|
112
|
+
definitions: QuickActionDefinitionConstructor<QuickActionDefinition>[];
|
|
113
|
+
view: XMLView;
|
|
114
|
+
key: string;
|
|
115
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
sap.ui.define([
|
|
3
|
+
'sap/base/Log',
|
|
4
|
+
'open/ux/preview/client/thirdparty/@sap-ux-private/control-property-editor-common',
|
|
5
|
+
'../../i18n'
|
|
6
|
+
], function (Log, ___sap_ux_private_control_property_editor_common, ____i18n) {
|
|
7
|
+
'use strict';
|
|
8
|
+
const executeQuickAction = ___sap_ux_private_control_property_editor_common['executeQuickAction'];
|
|
9
|
+
const quickActionListChanged = ___sap_ux_private_control_property_editor_common['quickActionListChanged'];
|
|
10
|
+
const SIMPLE_QUICK_ACTION_KIND = ___sap_ux_private_control_property_editor_common['SIMPLE_QUICK_ACTION_KIND'];
|
|
11
|
+
const NESTED_QUICK_ACTION_KIND = ___sap_ux_private_control_property_editor_common['NESTED_QUICK_ACTION_KIND'];
|
|
12
|
+
const updateQuickAction = ___sap_ux_private_control_property_editor_common['updateQuickAction'];
|
|
13
|
+
const getTextBundle = ____i18n['getTextBundle'];
|
|
14
|
+
class QuickActionService {
|
|
15
|
+
sendAction = () => {
|
|
16
|
+
};
|
|
17
|
+
actions = [];
|
|
18
|
+
constructor(rta, outlineService, registries) {
|
|
19
|
+
this.rta = rta;
|
|
20
|
+
this.outlineService = outlineService;
|
|
21
|
+
this.registries = registries;
|
|
22
|
+
}
|
|
23
|
+
async init(sendAction, subscribe) {
|
|
24
|
+
this.sendAction = sendAction;
|
|
25
|
+
this.actionService = await this.rta.getService('action');
|
|
26
|
+
this.texts = await getTextBundle();
|
|
27
|
+
subscribe(async action => {
|
|
28
|
+
if (executeQuickAction.match(action)) {
|
|
29
|
+
const actionInstance = this.actions.filter(quickActionDefinition => quickActionDefinition.id === action.payload.id).pop();
|
|
30
|
+
if (!actionInstance) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
const commands = await this.executeAction(actionInstance, action.payload);
|
|
34
|
+
for (const command of commands) {
|
|
35
|
+
await this.rta.getCommandStack().pushAndExecute(command);
|
|
36
|
+
}
|
|
37
|
+
if (actionInstance.forceRefreshAfterExecution) {
|
|
38
|
+
this.sendAction(updateQuickAction(actionInstance.getActionObject()));
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
this.outlineService.onOutlineChange(async event => {
|
|
43
|
+
await this.reloadQuickActions(event.detail.controlIndex);
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
async reloadQuickActions(controlIndex) {
|
|
47
|
+
const context = {
|
|
48
|
+
controlIndex,
|
|
49
|
+
manifest: this.rta.getRootControlInstance().getManifest(),
|
|
50
|
+
actionService: this.actionService
|
|
51
|
+
};
|
|
52
|
+
const groups = [];
|
|
53
|
+
for (const registry of this.registries) {
|
|
54
|
+
for (const {title, definitions, view, key} of registry.getDefinitions(context)) {
|
|
55
|
+
const group = {
|
|
56
|
+
title,
|
|
57
|
+
actions: []
|
|
58
|
+
};
|
|
59
|
+
const actionContext = {
|
|
60
|
+
...context,
|
|
61
|
+
view,
|
|
62
|
+
key,
|
|
63
|
+
rta: this.rta,
|
|
64
|
+
flexSettings: this.rta.getFlexSettings(),
|
|
65
|
+
resourceBundle: this.texts
|
|
66
|
+
};
|
|
67
|
+
for (const Definition of definitions) {
|
|
68
|
+
try {
|
|
69
|
+
const instance = new Definition(actionContext);
|
|
70
|
+
await instance.initialize();
|
|
71
|
+
this.addAction(group, instance);
|
|
72
|
+
} catch {
|
|
73
|
+
Log.warning(`Failed to initialize ${ Definition.name } quick action.`);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
groups.push(group);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
this.sendAction(quickActionListChanged(groups));
|
|
80
|
+
}
|
|
81
|
+
addAction(group, instance) {
|
|
82
|
+
if (instance.isActive) {
|
|
83
|
+
const quickAction = instance.getActionObject();
|
|
84
|
+
group.actions.push(quickAction);
|
|
85
|
+
this.actions.push(instance);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
executeAction(actionInstance, payload) {
|
|
89
|
+
if (payload.kind === SIMPLE_QUICK_ACTION_KIND && actionInstance.kind === SIMPLE_QUICK_ACTION_KIND) {
|
|
90
|
+
return actionInstance.execute();
|
|
91
|
+
}
|
|
92
|
+
if (payload.kind === NESTED_QUICK_ACTION_KIND && actionInstance.kind === NESTED_QUICK_ACTION_KIND) {
|
|
93
|
+
return actionInstance.execute(payload.path);
|
|
94
|
+
}
|
|
95
|
+
return Promise.resolve([]);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
var __exports = { __esModule: true };
|
|
99
|
+
__exports.QuickActionService = QuickActionService;
|
|
100
|
+
return __exports;
|
|
101
|
+
});
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import RuntimeAuthoring from 'sap/ui/rta/RuntimeAuthoring';
|
|
2
|
+
import { ActionService } from 'sap/ui/rta/service/Action';
|
|
3
|
+
import Log from 'sap/base/Log';
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
executeQuickAction,
|
|
7
|
+
ExternalAction,
|
|
8
|
+
quickActionListChanged,
|
|
9
|
+
SIMPLE_QUICK_ACTION_KIND,
|
|
10
|
+
NESTED_QUICK_ACTION_KIND,
|
|
11
|
+
QuickActionExecutionPayload,
|
|
12
|
+
QuickActionGroup,
|
|
13
|
+
updateQuickAction
|
|
14
|
+
} from '@sap-ux-private/control-property-editor-common';
|
|
15
|
+
|
|
16
|
+
import { ActionSenderFunction, ControlTreeIndex, Service, SubscribeFunction } from '../types';
|
|
17
|
+
|
|
18
|
+
import { QuickActionActivationContext, QuickActionContext, QuickActionDefinition } from './quick-action-definition';
|
|
19
|
+
import { QuickActionDefinitionRegistry } from './registry';
|
|
20
|
+
import { OutlineService } from '../outline/service';
|
|
21
|
+
import { getTextBundle, TextBundle } from '../../i18n';
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Service providing Quick Actions.
|
|
25
|
+
*/
|
|
26
|
+
export class QuickActionService implements Service {
|
|
27
|
+
private sendAction: ActionSenderFunction = () => {};
|
|
28
|
+
private actions: QuickActionDefinition[] = [];
|
|
29
|
+
|
|
30
|
+
private actionService: ActionService;
|
|
31
|
+
private texts: TextBundle;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Qucik action service constructor.zrf
|
|
35
|
+
*
|
|
36
|
+
* @param rta - RTA object.
|
|
37
|
+
* @param outlineService - Outline service instance.
|
|
38
|
+
* @param registries - Quick action registries.
|
|
39
|
+
*/
|
|
40
|
+
constructor(
|
|
41
|
+
private readonly rta: RuntimeAuthoring,
|
|
42
|
+
private readonly outlineService: OutlineService,
|
|
43
|
+
private readonly registries: QuickActionDefinitionRegistry<string>[]
|
|
44
|
+
) {}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Initialize selection service.
|
|
48
|
+
*
|
|
49
|
+
* @param sendAction - Action sender function.
|
|
50
|
+
* @param subscribe - Subscriber function.
|
|
51
|
+
*/
|
|
52
|
+
public async init(sendAction: ActionSenderFunction, subscribe: SubscribeFunction): Promise<void> {
|
|
53
|
+
this.sendAction = sendAction;
|
|
54
|
+
this.actionService = await this.rta.getService('action');
|
|
55
|
+
this.texts = await getTextBundle();
|
|
56
|
+
|
|
57
|
+
subscribe(async (action: ExternalAction): Promise<void> => {
|
|
58
|
+
if (executeQuickAction.match(action)) {
|
|
59
|
+
const actionInstance = this.actions
|
|
60
|
+
.filter((quickActionDefinition) => quickActionDefinition.id === action.payload.id)
|
|
61
|
+
.pop();
|
|
62
|
+
if (!actionInstance) {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
const commands = await this.executeAction(actionInstance, action.payload);
|
|
66
|
+
|
|
67
|
+
for (const command of commands) {
|
|
68
|
+
await this.rta.getCommandStack().pushAndExecute(command);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (actionInstance.forceRefreshAfterExecution) {
|
|
72
|
+
this.sendAction(updateQuickAction(actionInstance.getActionObject()));
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
this.outlineService.onOutlineChange(async (event) => {
|
|
78
|
+
await this.reloadQuickActions(event.detail.controlIndex);
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Prepares a list of currently applicable Quick Actions and sends them to the UI.
|
|
84
|
+
*
|
|
85
|
+
* @param controlIndex - Control tree index.
|
|
86
|
+
*/
|
|
87
|
+
public async reloadQuickActions(controlIndex: ControlTreeIndex): Promise<void> {
|
|
88
|
+
const context: QuickActionActivationContext = {
|
|
89
|
+
controlIndex,
|
|
90
|
+
manifest: this.rta.getRootControlInstance().getManifest(),
|
|
91
|
+
actionService: this.actionService
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
const groups: QuickActionGroup[] = [];
|
|
95
|
+
for (const registry of this.registries) {
|
|
96
|
+
for (const { title, definitions, view, key } of registry.getDefinitions(context)) {
|
|
97
|
+
const group: QuickActionGroup = {
|
|
98
|
+
title,
|
|
99
|
+
actions: []
|
|
100
|
+
};
|
|
101
|
+
const actionContext: QuickActionContext = {
|
|
102
|
+
...context,
|
|
103
|
+
view,
|
|
104
|
+
key,
|
|
105
|
+
rta: this.rta,
|
|
106
|
+
flexSettings: this.rta.getFlexSettings(),
|
|
107
|
+
resourceBundle: this.texts
|
|
108
|
+
};
|
|
109
|
+
for (const Definition of definitions) {
|
|
110
|
+
try {
|
|
111
|
+
const instance = new Definition(actionContext);
|
|
112
|
+
await instance.initialize();
|
|
113
|
+
this.addAction(group, instance);
|
|
114
|
+
} catch {
|
|
115
|
+
Log.warning(`Failed to initialize ${Definition.name} quick action.`);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
groups.push(group);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
this.sendAction(quickActionListChanged(groups));
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
private addAction(group: QuickActionGroup, instance: QuickActionDefinition): void {
|
|
126
|
+
if (instance.isActive) {
|
|
127
|
+
const quickAction = instance.getActionObject();
|
|
128
|
+
group.actions.push(quickAction);
|
|
129
|
+
this.actions.push(instance);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
private executeAction(actionInstance: QuickActionDefinition, payload: QuickActionExecutionPayload) {
|
|
134
|
+
if (payload.kind === SIMPLE_QUICK_ACTION_KIND && actionInstance.kind === SIMPLE_QUICK_ACTION_KIND) {
|
|
135
|
+
return actionInstance.execute();
|
|
136
|
+
}
|
|
137
|
+
if (payload.kind === NESTED_QUICK_ACTION_KIND && actionInstance.kind === NESTED_QUICK_ACTION_KIND) {
|
|
138
|
+
return actionInstance.execute(payload.path);
|
|
139
|
+
}
|
|
140
|
+
return Promise.resolve([]);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
sap.ui.define(["sap/m/NavContainer", "sap/f/FlexibleColumnLayout", "sap/f/library", "sap/base/Log", "../../utils/core", "../utils"], function (NavContainer, FlexibleColumnLayout, sap_f_library, Log, ____utils_core, ___utils) {
|
|
4
|
+
"use strict";
|
|
5
|
+
|
|
6
|
+
const LayoutType = sap_f_library["LayoutType"];
|
|
7
|
+
const getControlById = ____utils_core["getControlById"];
|
|
8
|
+
const getRootControlFromComponentContainer = ___utils["getRootControlFromComponentContainer"];
|
|
9
|
+
const NAV_CONTAINER_CONTROL_TYPE = 'sap.m.NavContainer';
|
|
10
|
+
const FLEXIBLE_COLUMN_LAYOUT_CONTROL_TYPE = 'sap.f.FlexibleColumnLayout';
|
|
11
|
+
/**
|
|
12
|
+
* Base class for Quick Action definition providers.
|
|
13
|
+
*
|
|
14
|
+
*/
|
|
15
|
+
class QuickActionDefinitionRegistry {
|
|
16
|
+
/**
|
|
17
|
+
* Mapping of page view name to page type name.
|
|
18
|
+
*/
|
|
19
|
+
PAGE_NAME_MAP = {};
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Provides a list of Quick Action definitions that are applicable for the given context.
|
|
23
|
+
*
|
|
24
|
+
* @param _context - Activation context.
|
|
25
|
+
*/
|
|
26
|
+
getDefinitions(_context) {
|
|
27
|
+
throw new Error('Not implemented!');
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Finds component container from the page control.
|
|
32
|
+
*
|
|
33
|
+
* @param page - Page control provided by containers.
|
|
34
|
+
* @returns ComponentContainer control.
|
|
35
|
+
*/
|
|
36
|
+
getComponentContainerFromPage(page) {
|
|
37
|
+
return page;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Returns a list of Active pages based on the provided control index.
|
|
42
|
+
*
|
|
43
|
+
* @param controlIndex - Control tree index.
|
|
44
|
+
* @returns A list of Active pages.
|
|
45
|
+
*/
|
|
46
|
+
getActivePageContent(controlIndex) {
|
|
47
|
+
const views = this.getActiveViews(controlIndex);
|
|
48
|
+
const pages = [];
|
|
49
|
+
for (const view of views) {
|
|
50
|
+
const name = view.getViewName();
|
|
51
|
+
const pageName = this.PAGE_NAME_MAP[name];
|
|
52
|
+
if (pageName) {
|
|
53
|
+
pages.push({
|
|
54
|
+
name: pageName,
|
|
55
|
+
view
|
|
56
|
+
});
|
|
57
|
+
} else {
|
|
58
|
+
Log.warning(`Could not find matching page for view of type "${name}".`);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return pages;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Get all the root views of currently active pages.
|
|
66
|
+
*
|
|
67
|
+
* @param controlIndex - Control index.
|
|
68
|
+
* @returns List of page root views.
|
|
69
|
+
*/
|
|
70
|
+
getActiveViews(controlIndex) {
|
|
71
|
+
const pages = this.getActivePages(controlIndex);
|
|
72
|
+
const views = [];
|
|
73
|
+
for (const page of pages) {
|
|
74
|
+
if (page) {
|
|
75
|
+
const container = this.getComponentContainerFromPage(page);
|
|
76
|
+
if (container) {
|
|
77
|
+
const rootControl = getRootControlFromComponentContainer(container);
|
|
78
|
+
if (rootControl) {
|
|
79
|
+
views.push(rootControl);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return views;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Finds active page controls from the control tree index.
|
|
89
|
+
*
|
|
90
|
+
* @param controlIndex - Control tree index.
|
|
91
|
+
* @returns A list of page controls.
|
|
92
|
+
*/
|
|
93
|
+
getActivePages(controlIndex) {
|
|
94
|
+
const navContainerNode = controlIndex[NAV_CONTAINER_CONTROL_TYPE]?.[0];
|
|
95
|
+
if (navContainerNode) {
|
|
96
|
+
const control = getControlById(navContainerNode.controlId);
|
|
97
|
+
if (control instanceof NavContainer) {
|
|
98
|
+
return [control.getCurrentPage()];
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
const flexibleLayoutNode = controlIndex[FLEXIBLE_COLUMN_LAYOUT_CONTROL_TYPE]?.[0];
|
|
102
|
+
if (flexibleLayoutNode) {
|
|
103
|
+
const control = getControlById(flexibleLayoutNode.controlId);
|
|
104
|
+
if (control instanceof FlexibleColumnLayout) {
|
|
105
|
+
return this.getVisibleFlexibleColumnLayoutPages(control);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
return [];
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Finds the visible Flexible Column Layout pages.
|
|
113
|
+
*
|
|
114
|
+
* @param control - Flexible Column Layout control.
|
|
115
|
+
* @returns A list of visible pages.
|
|
116
|
+
*/
|
|
117
|
+
|
|
118
|
+
getVisibleFlexibleColumnLayoutPages(control) {
|
|
119
|
+
const layout = control.getLayout();
|
|
120
|
+
switch (layout) {
|
|
121
|
+
case LayoutType.OneColumn:
|
|
122
|
+
return [control.getCurrentBeginColumnPage()];
|
|
123
|
+
case LayoutType.MidColumnFullScreen:
|
|
124
|
+
return [control.getCurrentMidColumnPage()];
|
|
125
|
+
case LayoutType.EndColumnFullScreen:
|
|
126
|
+
return [control.getCurrentEndColumnPage()];
|
|
127
|
+
case LayoutType.ThreeColumnsBeginExpandedEndHidden:
|
|
128
|
+
case LayoutType.ThreeColumnsMidExpanded:
|
|
129
|
+
case LayoutType.ThreeColumnsMidExpandedEndHidden:
|
|
130
|
+
case LayoutType.ThreeColumnsEndExpanded:
|
|
131
|
+
return [control.getCurrentBeginColumnPage(), control.getCurrentMidColumnPage(), control.getCurrentEndColumnPage()];
|
|
132
|
+
case LayoutType.TwoColumnsMidExpanded:
|
|
133
|
+
case LayoutType.TwoColumnsBeginExpanded:
|
|
134
|
+
return [control.getCurrentBeginColumnPage(), control.getCurrentMidColumnPage()];
|
|
135
|
+
}
|
|
136
|
+
return [];
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
var __exports = {
|
|
140
|
+
__esModule: true
|
|
141
|
+
};
|
|
142
|
+
__exports.QuickActionDefinitionRegistry = QuickActionDefinitionRegistry;
|
|
143
|
+
return __exports;
|
|
144
|
+
});
|
|
145
|
+
//# sourceMappingURL=registry.js.map
|