@sap-ux/preview-middleware 0.16.7 → 0.16.9
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/init-dialogs.js +36 -19
- package/dist/client/adp/init-dialogs.ts +39 -14
- package/dist/client/adp/init.js +1 -1
- package/dist/client/adp/init.ts +2 -1
- package/dist/client/cpe/outline/index.js +11 -1
- package/dist/client/cpe/outline/index.ts +9 -4
- package/dist/client/cpe/outline/nodes.js +27 -6
- package/dist/client/cpe/outline/nodes.ts +40 -9
- package/dist/client/cpe/outline/utils.js +24 -1
- package/dist/client/cpe/outline/utils.ts +27 -0
- package/package.json +3 -3
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
sap.ui.define(["sap/ui/core/Fragment", "sap/ui/fl/Utils", "./controllers/AddFragment.controller", "./controllers/ControllerExtension.controller", "./controllers/ExtensionPoint.controller"], function (Fragment, FlUtils, __AddFragment, __ControllerExtension, __ExtensionPoint) {
|
|
3
|
+
sap.ui.define(["sap/ui/core/Fragment", "sap/ui/fl/Utils", "./controllers/AddFragment.controller", "./controllers/ControllerExtension.controller", "./controllers/ExtensionPoint.controller", "../cpe/outline/utils"], function (Fragment, FlUtils, __AddFragment, __ControllerExtension, __ExtensionPoint, ___cpe_outline_utils) {
|
|
4
4
|
"use strict";
|
|
5
5
|
|
|
6
6
|
function _interopRequireDefault(obj) {
|
|
@@ -9,6 +9,7 @@ sap.ui.define(["sap/ui/core/Fragment", "sap/ui/fl/Utils", "./controllers/AddFrag
|
|
|
9
9
|
const AddFragment = _interopRequireDefault(__AddFragment);
|
|
10
10
|
const ControllerExtension = _interopRequireDefault(__ControllerExtension);
|
|
11
11
|
const ExtensionPoint = _interopRequireDefault(__ExtensionPoint);
|
|
12
|
+
const isReuseComponent = ___cpe_outline_utils["isReuseComponent"];
|
|
12
13
|
var DialogNames = /*#__PURE__*/function (DialogNames) {
|
|
13
14
|
DialogNames["ADD_FRAGMENT"] = "AddFragment";
|
|
14
15
|
DialogNames["CONTROLLER_EXTENSION"] = "ControllerExtension";
|
|
@@ -16,31 +17,45 @@ sap.ui.define(["sap/ui/core/Fragment", "sap/ui/fl/Utils", "./controllers/AddFrag
|
|
|
16
17
|
return DialogNames;
|
|
17
18
|
}(DialogNames || {});
|
|
18
19
|
/**
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
20
|
+
* Handler for enablement of Extend With Controller context menu entry
|
|
21
|
+
*
|
|
22
|
+
* @param overlays Control overlays
|
|
23
|
+
* @param syncViewsIds Runtime Authoring
|
|
24
|
+
* @param minorUI5Version minor UI5 version
|
|
25
|
+
*
|
|
26
|
+
* @returns boolean whether menu item is enabled or not
|
|
27
|
+
*/
|
|
28
|
+
const isControllerExtensionEnabled = (overlays, syncViewsIds, minorUI5Version) => {
|
|
29
|
+
if (overlays.length === 0 || overlays.length > 1) {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
27
32
|
const clickedControlId = FlUtils.getViewForControl(overlays[0].getElement()).getId();
|
|
28
|
-
|
|
33
|
+
const isClickedControlReuseComponent = isReuseComponent(clickedControlId, minorUI5Version);
|
|
34
|
+
return !syncViewsIds.includes(clickedControlId) && !isClickedControlReuseComponent;
|
|
29
35
|
};
|
|
30
36
|
|
|
31
37
|
/**
|
|
32
38
|
* Determines whether the fragment command should be enabled based on the provided overlays.
|
|
33
39
|
*
|
|
34
40
|
* @param {ElementOverlay[]} overlays - An array of ElementOverlay objects representing the UI overlays.
|
|
41
|
+
* @param minorUI5Version minor UI5 version
|
|
35
42
|
* @returns {boolean} True if the fragment command is enabled, false otherwise.
|
|
36
43
|
*/
|
|
37
|
-
const isFragmentCommandEnabled = overlays => {
|
|
38
|
-
if (overlays.length === 0) {
|
|
44
|
+
const isFragmentCommandEnabled = (overlays, minorUI5Version) => {
|
|
45
|
+
if (overlays.length === 0 || overlays.length > 1) {
|
|
39
46
|
return false;
|
|
40
47
|
}
|
|
41
48
|
const control = overlays[0].getElement();
|
|
42
|
-
|
|
43
|
-
|
|
49
|
+
return hasStableId(control) && !isReuseComponent(control.getId(), minorUI5Version);
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Determines whether control has stable id
|
|
54
|
+
* @param {ManagedObject} control - ManagedObject object representing the UI control.
|
|
55
|
+
* @returns {boolean} True if control has stable Id, false otherwise
|
|
56
|
+
*/
|
|
57
|
+
const hasStableId = control => {
|
|
58
|
+
return FlUtils.checkControlId(control);
|
|
44
59
|
};
|
|
45
60
|
|
|
46
61
|
/**
|
|
@@ -50,7 +65,8 @@ sap.ui.define(["sap/ui/core/Fragment", "sap/ui/fl/Utils", "./controllers/AddFrag
|
|
|
50
65
|
* @returns {string} The text of the Add Fragment context menu item.
|
|
51
66
|
*/
|
|
52
67
|
const getAddFragmentItemText = overlay => {
|
|
53
|
-
|
|
68
|
+
const control = overlay.getElement();
|
|
69
|
+
if (control && !hasStableId(control)) {
|
|
54
70
|
return 'Add: Fragment (Unavailable due to unstable ID of the control or its parent control)';
|
|
55
71
|
}
|
|
56
72
|
return 'Add: Fragment';
|
|
@@ -91,22 +107,23 @@ sap.ui.define(["sap/ui/core/Fragment", "sap/ui/fl/Utils", "./controllers/AddFrag
|
|
|
91
107
|
*
|
|
92
108
|
* @param rta Runtime Authoring
|
|
93
109
|
* @param syncViewsIds Ids of all application sync views
|
|
110
|
+
* @param minorUI5Version minor UI5 version
|
|
94
111
|
*/
|
|
95
|
-
const initDialogs = (rta, syncViewsIds) => {
|
|
112
|
+
const initDialogs = (rta, syncViewsIds, minorUI5Version) => {
|
|
96
113
|
const contextMenu = rta.getDefaultPlugins().contextMenu;
|
|
97
114
|
contextMenu.addMenuItem({
|
|
98
115
|
id: 'ADD_FRAGMENT',
|
|
99
116
|
text: getAddFragmentItemText,
|
|
100
117
|
handler: async overlays => await handler(overlays[0], rta, DialogNames.ADD_FRAGMENT),
|
|
101
|
-
|
|
102
|
-
|
|
118
|
+
icon: 'sap-icon://attachment-html',
|
|
119
|
+
enabled: overlays => isFragmentCommandEnabled(overlays, minorUI5Version)
|
|
103
120
|
});
|
|
104
121
|
contextMenu.addMenuItem({
|
|
105
122
|
id: 'EXTEND_CONTROLLER',
|
|
106
123
|
text: 'Extend With Controller',
|
|
107
124
|
handler: async overlays => await handler(overlays[0], rta, DialogNames.CONTROLLER_EXTENSION),
|
|
108
125
|
icon: 'sap-icon://create-form',
|
|
109
|
-
enabled: overlays => isControllerExtensionEnabled(overlays, syncViewsIds)
|
|
126
|
+
enabled: overlays => isControllerExtensionEnabled(overlays, syncViewsIds, minorUI5Version)
|
|
110
127
|
});
|
|
111
128
|
};
|
|
112
129
|
var __exports = {
|
|
@@ -18,6 +18,8 @@ import AddFragment from './controllers/AddFragment.controller';
|
|
|
18
18
|
import ControllerExtension from './controllers/ControllerExtension.controller';
|
|
19
19
|
import { ExtensionPointData } from './extension-point';
|
|
20
20
|
import ExtensionPoint from './controllers/ExtensionPoint.controller';
|
|
21
|
+
import ManagedObject from 'sap/ui/base/ManagedObject';
|
|
22
|
+
import { isReuseComponent } from '../cpe/outline/utils';
|
|
21
23
|
|
|
22
24
|
export const enum DialogNames {
|
|
23
25
|
ADD_FRAGMENT = 'AddFragment',
|
|
@@ -27,33 +29,54 @@ export const enum DialogNames {
|
|
|
27
29
|
|
|
28
30
|
type Controller = AddFragment | ControllerExtension | ExtensionPoint;
|
|
29
31
|
|
|
30
|
-
|
|
32
|
+
/**
|
|
31
33
|
* Handler for enablement of Extend With Controller context menu entry
|
|
32
34
|
*
|
|
33
35
|
* @param overlays Control overlays
|
|
34
36
|
* @param syncViewsIds Runtime Authoring
|
|
37
|
+
* @param minorUI5Version minor UI5 version
|
|
35
38
|
*
|
|
36
|
-
* @returns boolean
|
|
39
|
+
* @returns boolean whether menu item is enabled or not
|
|
37
40
|
*/
|
|
38
|
-
export const isControllerExtensionEnabled = (
|
|
41
|
+
export const isControllerExtensionEnabled = (
|
|
42
|
+
overlays: ElementOverlay[],
|
|
43
|
+
syncViewsIds: string[],
|
|
44
|
+
minorUI5Version: number
|
|
45
|
+
): boolean => {
|
|
46
|
+
if (overlays.length === 0 || overlays.length > 1) {
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
|
|
39
50
|
const clickedControlId = FlUtils.getViewForControl(overlays[0].getElement()).getId();
|
|
51
|
+
const isClickedControlReuseComponent = isReuseComponent(clickedControlId, minorUI5Version);
|
|
40
52
|
|
|
41
|
-
return
|
|
53
|
+
return !syncViewsIds.includes(clickedControlId) && !isClickedControlReuseComponent;
|
|
42
54
|
};
|
|
43
55
|
|
|
44
56
|
/**
|
|
45
57
|
* Determines whether the fragment command should be enabled based on the provided overlays.
|
|
46
58
|
*
|
|
47
59
|
* @param {ElementOverlay[]} overlays - An array of ElementOverlay objects representing the UI overlays.
|
|
60
|
+
* @param minorUI5Version minor UI5 version
|
|
48
61
|
* @returns {boolean} True if the fragment command is enabled, false otherwise.
|
|
49
62
|
*/
|
|
50
|
-
export const isFragmentCommandEnabled = (overlays: ElementOverlay[]): boolean => {
|
|
51
|
-
if (overlays.length === 0) {
|
|
63
|
+
export const isFragmentCommandEnabled = (overlays: ElementOverlay[], minorUI5Version: number): boolean => {
|
|
64
|
+
if (overlays.length === 0 || overlays.length > 1) {
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
52
67
|
|
|
53
68
|
const control = overlays[0].getElement();
|
|
54
|
-
const hasStableId = FlUtils.checkControlId(control);
|
|
55
69
|
|
|
56
|
-
return hasStableId &&
|
|
70
|
+
return hasStableId(control) && !isReuseComponent(control.getId(), minorUI5Version);
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Determines whether control has stable id
|
|
75
|
+
* @param {ManagedObject} control - ManagedObject object representing the UI control.
|
|
76
|
+
* @returns {boolean} True if control has stable Id, false otherwise
|
|
77
|
+
*/
|
|
78
|
+
const hasStableId = (control: ManagedObject): boolean => {
|
|
79
|
+
return FlUtils.checkControlId(control);
|
|
57
80
|
};
|
|
58
81
|
|
|
59
82
|
/**
|
|
@@ -63,7 +86,8 @@ export const isFragmentCommandEnabled = (overlays: ElementOverlay[]): boolean =>
|
|
|
63
86
|
* @returns {string} The text of the Add Fragment context menu item.
|
|
64
87
|
*/
|
|
65
88
|
export const getAddFragmentItemText = (overlay: ElementOverlay) => {
|
|
66
|
-
|
|
89
|
+
const control = overlay.getElement();
|
|
90
|
+
if (control && !hasStableId(control)) {
|
|
67
91
|
return 'Add: Fragment (Unavailable due to unstable ID of the control or its parent control)';
|
|
68
92
|
}
|
|
69
93
|
|
|
@@ -119,16 +143,17 @@ export async function handler(
|
|
|
119
143
|
*
|
|
120
144
|
* @param rta Runtime Authoring
|
|
121
145
|
* @param syncViewsIds Ids of all application sync views
|
|
146
|
+
* @param minorUI5Version minor UI5 version
|
|
122
147
|
*/
|
|
123
|
-
export const initDialogs = (rta: RuntimeAuthoring, syncViewsIds: string[]): void => {
|
|
148
|
+
export const initDialogs = (rta: RuntimeAuthoring, syncViewsIds: string[], minorUI5Version: number): void => {
|
|
124
149
|
const contextMenu = rta.getDefaultPlugins().contextMenu;
|
|
125
150
|
|
|
126
151
|
contextMenu.addMenuItem({
|
|
127
152
|
id: 'ADD_FRAGMENT',
|
|
128
153
|
text: getAddFragmentItemText,
|
|
129
154
|
handler: async (overlays: UI5Element[]) => await handler(overlays[0], rta, DialogNames.ADD_FRAGMENT),
|
|
130
|
-
|
|
131
|
-
|
|
155
|
+
icon: 'sap-icon://attachment-html',
|
|
156
|
+
enabled: (overlays: ElementOverlay[]) => isFragmentCommandEnabled(overlays, minorUI5Version)
|
|
132
157
|
});
|
|
133
158
|
|
|
134
159
|
contextMenu.addMenuItem({
|
|
@@ -136,6 +161,6 @@ export const initDialogs = (rta: RuntimeAuthoring, syncViewsIds: string[]): void
|
|
|
136
161
|
text: 'Extend With Controller',
|
|
137
162
|
handler: async (overlays: UI5Element[]) => await handler(overlays[0], rta, DialogNames.CONTROLLER_EXTENSION),
|
|
138
163
|
icon: 'sap-icon://create-form',
|
|
139
|
-
enabled: (overlays: ElementOverlay[]) => isControllerExtensionEnabled(overlays, syncViewsIds)
|
|
164
|
+
enabled: (overlays: ElementOverlay[]) => isControllerExtensionEnabled(overlays, syncViewsIds, minorUI5Version)
|
|
140
165
|
});
|
|
141
|
-
};
|
|
166
|
+
};
|
package/dist/client/adp/init.js
CHANGED
|
@@ -54,7 +54,7 @@ sap.ui.define([
|
|
|
54
54
|
}
|
|
55
55
|
});
|
|
56
56
|
const syncViewsIds = await getAllSyncViewsIds(minor);
|
|
57
|
-
initDialogs(rta, syncViewsIds);
|
|
57
|
+
initDialogs(rta, syncViewsIds, minor);
|
|
58
58
|
if (minor > 77) {
|
|
59
59
|
const ExtensionPointService = (await __ui5_require_async('open/ux/preview/client/adp/extension-point')).default;
|
|
60
60
|
const extPointService = new ExtensionPointService(rta);
|
package/dist/client/adp/init.ts
CHANGED
|
@@ -46,7 +46,7 @@ export default async function (rta: RuntimeAuthoring) {
|
|
|
46
46
|
);
|
|
47
47
|
|
|
48
48
|
const syncViewsIds = await getAllSyncViewsIds(minor);
|
|
49
|
-
initDialogs(rta, syncViewsIds);
|
|
49
|
+
initDialogs(rta, syncViewsIds, minor);
|
|
50
50
|
|
|
51
51
|
if (minor > 77) {
|
|
52
52
|
const ExtensionPointService = (await import('open/ux/preview/client/adp/extension-point')).default;
|
|
@@ -62,6 +62,7 @@ export default async function (rta: RuntimeAuthoring) {
|
|
|
62
62
|
|
|
63
63
|
return;
|
|
64
64
|
}
|
|
65
|
+
|
|
65
66
|
if (syncViewsIds.length > 0) {
|
|
66
67
|
sendAction(
|
|
67
68
|
showMessage({
|
|
@@ -7,16 +7,26 @@ sap.ui.define([
|
|
|
7
7
|
], function (___sap_ux_private_control_property_editor_common, ___nodes, Log, ___error_utils) {
|
|
8
8
|
'use strict';
|
|
9
9
|
const outlineChanged = ___sap_ux_private_control_property_editor_common['outlineChanged'];
|
|
10
|
+
const showMessage = ___sap_ux_private_control_property_editor_common['showMessage'];
|
|
10
11
|
const transformNodes = ___nodes['transformNodes'];
|
|
11
12
|
const getError = ___error_utils['getError'];
|
|
12
13
|
async function initOutline(rta, sendAction) {
|
|
13
14
|
const outline = await rta.getService('outline');
|
|
14
15
|
const scenario = rta.getFlexSettings().scenario;
|
|
16
|
+
let hasSentWarning = false;
|
|
17
|
+
const reuseComponentsIds = new Set();
|
|
15
18
|
async function syncOutline() {
|
|
16
19
|
try {
|
|
17
20
|
const viewNodes = await outline.get();
|
|
18
|
-
const outlineNodes = await transformNodes(viewNodes, scenario);
|
|
21
|
+
const outlineNodes = await transformNodes(viewNodes, scenario, reuseComponentsIds);
|
|
19
22
|
sendAction(outlineChanged(outlineNodes));
|
|
23
|
+
if (reuseComponentsIds.size > 0 && scenario === 'ADAPTATION_PROJECT' && !hasSentWarning) {
|
|
24
|
+
sendAction(showMessage({
|
|
25
|
+
message: 'Have in mind that reuse components are detected for some views in this application and controller extensions and adding fragments are not supported for such views. Controller extension and adding fragment functionality on these views will be disabled.',
|
|
26
|
+
shouldHideIframe: false
|
|
27
|
+
}));
|
|
28
|
+
hasSentWarning = true;
|
|
29
|
+
}
|
|
20
30
|
} catch (error) {
|
|
21
31
|
Log.error('Outline sync failed!', getError(error));
|
|
22
32
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ExternalAction } from '@sap-ux-private/control-property-editor-common';
|
|
2
|
-
import { outlineChanged } from '@sap-ux-private/control-property-editor-common';
|
|
2
|
+
import { outlineChanged, showMessage } from '@sap-ux-private/control-property-editor-common';
|
|
3
3
|
|
|
4
4
|
import type RuntimeAuthoring from 'sap/ui/rta/RuntimeAuthoring';
|
|
5
5
|
import type OutlineService from 'sap/ui/rta/command/OutlineService';
|
|
@@ -16,13 +16,18 @@ import { getError } from '../error-utils';
|
|
|
16
16
|
export async function initOutline(rta: RuntimeAuthoring, sendAction: (action: ExternalAction) => void): Promise<void> {
|
|
17
17
|
const outline = await rta.getService<OutlineService>('outline');
|
|
18
18
|
const scenario = rta.getFlexSettings().scenario;
|
|
19
|
-
|
|
19
|
+
let hasSentWarning = false;
|
|
20
|
+
const reuseComponentsIds = new Set<string>();
|
|
20
21
|
async function syncOutline() {
|
|
21
22
|
try {
|
|
22
23
|
const viewNodes = await outline.get();
|
|
23
|
-
const outlineNodes = await transformNodes(viewNodes, scenario);
|
|
24
|
-
|
|
24
|
+
const outlineNodes = await transformNodes(viewNodes, scenario, reuseComponentsIds);
|
|
25
25
|
sendAction(outlineChanged(outlineNodes));
|
|
26
|
+
if(reuseComponentsIds.size > 0 && scenario === 'ADAPTATION_PROJECT' && !hasSentWarning) {
|
|
27
|
+
sendAction(showMessage({ message: 'Have in mind that reuse components are detected for some views in this application and controller extensions and adding fragments are not supported for such views. Controller extension and adding fragment functionality on these views will be disabled.', shouldHideIframe: false}));
|
|
28
|
+
hasSentWarning = true;
|
|
29
|
+
}
|
|
30
|
+
|
|
26
31
|
} catch (error) {
|
|
27
32
|
Log.error('Outline sync failed!', getError(error));
|
|
28
33
|
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
sap.ui.define(["./utils"], function (___utils) {
|
|
3
|
+
sap.ui.define(["./utils", "sap/ui/VersionInfo"], function (___utils, VersionInfo) {
|
|
4
4
|
"use strict";
|
|
5
5
|
|
|
6
6
|
const isEditable = ___utils["isEditable"];
|
|
7
|
+
const isReuseComponent = ___utils["isReuseComponent"];
|
|
7
8
|
/**
|
|
8
9
|
* Retrieves additional data for a given control ID.
|
|
9
10
|
*
|
|
@@ -68,12 +69,17 @@ sap.ui.define(["./utils"], function (___utils) {
|
|
|
68
69
|
*
|
|
69
70
|
* @param input outline view node
|
|
70
71
|
* @param scenario type of project
|
|
71
|
-
* @param
|
|
72
|
+
* @param reuseComponentsIds ids of reuse components that are filled when outline nodes are transformed
|
|
72
73
|
* @returns {Promise<OutlineNode[]>} transformed outline tree nodes
|
|
73
74
|
*/
|
|
74
|
-
async function transformNodes(input, scenario) {
|
|
75
|
+
async function transformNodes(input, scenario, reuseComponentsIds) {
|
|
75
76
|
const stack = [...input];
|
|
76
77
|
const items = [];
|
|
78
|
+
const {
|
|
79
|
+
version
|
|
80
|
+
} = await VersionInfo.load();
|
|
81
|
+
const versionParts = version.split('.');
|
|
82
|
+
const minor = parseInt(versionParts[1], 10);
|
|
77
83
|
while (stack.length) {
|
|
78
84
|
const current = stack.shift();
|
|
79
85
|
const editable = isEditable(current?.id);
|
|
@@ -85,7 +91,7 @@ sap.ui.define(["./utils"], function (___utils) {
|
|
|
85
91
|
text
|
|
86
92
|
} = getAdditionalData(current.id);
|
|
87
93
|
const technicalName = current.technicalName.split('.').slice(-1)[0];
|
|
88
|
-
const transformedChildren = isAdp ? await handleDuplicateNodes(children, scenario) : await transformNodes(children, scenario);
|
|
94
|
+
const transformedChildren = isAdp ? await handleDuplicateNodes(children, scenario, reuseComponentsIds) : await transformNodes(children, scenario, reuseComponentsIds);
|
|
89
95
|
const node = {
|
|
90
96
|
controlId: current.id,
|
|
91
97
|
controlType: current.technicalName,
|
|
@@ -94,6 +100,7 @@ sap.ui.define(["./utils"], function (___utils) {
|
|
|
94
100
|
visible: current.visible ?? true,
|
|
95
101
|
children: transformedChildren
|
|
96
102
|
};
|
|
103
|
+
fillReuseComponents(reuseComponentsIds, current, scenario, minor);
|
|
97
104
|
items.push(node);
|
|
98
105
|
}
|
|
99
106
|
if (isAdp && isExtPoint) {
|
|
@@ -121,15 +128,29 @@ sap.ui.define(["./utils"], function (___utils) {
|
|
|
121
128
|
return items;
|
|
122
129
|
}
|
|
123
130
|
|
|
131
|
+
/**
|
|
132
|
+
* Fill reuse components ids.
|
|
133
|
+
*
|
|
134
|
+
* @param reuseComponentsIds ids of reuse components that are filled when outline nodes are transformed
|
|
135
|
+
* @param node view node
|
|
136
|
+
* @param scenario type of project
|
|
137
|
+
* @param minorUI5Version miner UI5 version
|
|
138
|
+
*/
|
|
139
|
+
function fillReuseComponents(reuseComponentsIds, node, scenario, minorUI5Version) {
|
|
140
|
+
if (scenario === 'ADAPTATION_PROJECT' && node?.component && isReuseComponent(node.id, minorUI5Version)) {
|
|
141
|
+
reuseComponentsIds.add(node.id);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
124
144
|
/**
|
|
125
145
|
* Handles duplicate nodes that are retrieved from extension point default content and created controls,
|
|
126
146
|
* if they exist under an extension point these controls are removed from the children array
|
|
127
147
|
*
|
|
128
148
|
* @param children outline view node children
|
|
129
149
|
* @param scenario type of project
|
|
150
|
+
* @param reuseComponentsIds ids of reuse components that are filled when outline nodes are transformed
|
|
130
151
|
* @returns transformed outline tree nodes
|
|
131
152
|
*/
|
|
132
|
-
async function handleDuplicateNodes(children, scenario) {
|
|
153
|
+
async function handleDuplicateNodes(children, scenario, reuseComponentsIds) {
|
|
133
154
|
const extPointIDs = new Set();
|
|
134
155
|
children.forEach(child => {
|
|
135
156
|
if (child.type === 'extensionPoint') {
|
|
@@ -141,7 +162,7 @@ sap.ui.define(["./utils"], function (___utils) {
|
|
|
141
162
|
}
|
|
142
163
|
});
|
|
143
164
|
const uniqueChildren = children.filter(child => !extPointIDs.has(child.id));
|
|
144
|
-
return transformNodes(uniqueChildren, scenario);
|
|
165
|
+
return transformNodes(uniqueChildren, scenario, reuseComponentsIds);
|
|
145
166
|
}
|
|
146
167
|
var __exports = {
|
|
147
168
|
__esModule: true
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import type { OutlineNode } from '@sap-ux-private/control-property-editor-common';
|
|
2
|
-
|
|
3
2
|
import type { OutlineViewNode } from 'sap/ui/rta/command/OutlineService';
|
|
4
3
|
import type { Scenario } from 'sap/ui/fl/Scenario';
|
|
5
|
-
|
|
6
|
-
import
|
|
4
|
+
import { isEditable, isReuseComponent } from './utils';
|
|
5
|
+
import VersionInfo from 'sap/ui/VersionInfo';
|
|
7
6
|
|
|
8
7
|
interface AdditionalData {
|
|
9
8
|
text?: string;
|
|
@@ -78,12 +77,19 @@ function addChildToExtensionPoint(id: string, children: OutlineNode[]) {
|
|
|
78
77
|
*
|
|
79
78
|
* @param input outline view node
|
|
80
79
|
* @param scenario type of project
|
|
81
|
-
* @param
|
|
80
|
+
* @param reuseComponentsIds ids of reuse components that are filled when outline nodes are transformed
|
|
82
81
|
* @returns {Promise<OutlineNode[]>} transformed outline tree nodes
|
|
83
82
|
*/
|
|
84
|
-
export async function transformNodes(
|
|
83
|
+
export async function transformNodes(
|
|
84
|
+
input: OutlineViewNode[],
|
|
85
|
+
scenario: Scenario,
|
|
86
|
+
reuseComponentsIds: Set<string>
|
|
87
|
+
): Promise<OutlineNode[]> {
|
|
85
88
|
const stack = [...input];
|
|
86
89
|
const items: OutlineNode[] = [];
|
|
90
|
+
const { version } = (await VersionInfo.load()) as { version: string };
|
|
91
|
+
const versionParts = version.split('.');
|
|
92
|
+
const minor = parseInt(versionParts[1], 10);
|
|
87
93
|
while (stack.length) {
|
|
88
94
|
const current = stack.shift();
|
|
89
95
|
const editable = isEditable(current?.id);
|
|
@@ -96,8 +102,8 @@ export async function transformNodes(input: OutlineViewNode[], scenario: Scenari
|
|
|
96
102
|
const technicalName = current.technicalName.split('.').slice(-1)[0];
|
|
97
103
|
|
|
98
104
|
const transformedChildren = isAdp
|
|
99
|
-
? await handleDuplicateNodes(children, scenario)
|
|
100
|
-
: await transformNodes(children, scenario);
|
|
105
|
+
? await handleDuplicateNodes(children, scenario, reuseComponentsIds)
|
|
106
|
+
: await transformNodes(children, scenario, reuseComponentsIds);
|
|
101
107
|
|
|
102
108
|
const node: OutlineNode = {
|
|
103
109
|
controlId: current.id,
|
|
@@ -108,6 +114,8 @@ export async function transformNodes(input: OutlineViewNode[], scenario: Scenari
|
|
|
108
114
|
children: transformedChildren
|
|
109
115
|
};
|
|
110
116
|
|
|
117
|
+
fillReuseComponents(reuseComponentsIds, current, scenario, minor);
|
|
118
|
+
|
|
111
119
|
items.push(node);
|
|
112
120
|
}
|
|
113
121
|
|
|
@@ -136,15 +144,38 @@ export async function transformNodes(input: OutlineViewNode[], scenario: Scenari
|
|
|
136
144
|
return items;
|
|
137
145
|
}
|
|
138
146
|
|
|
147
|
+
/**
|
|
148
|
+
* Fill reuse components ids.
|
|
149
|
+
*
|
|
150
|
+
* @param reuseComponentsIds ids of reuse components that are filled when outline nodes are transformed
|
|
151
|
+
* @param node view node
|
|
152
|
+
* @param scenario type of project
|
|
153
|
+
* @param minorUI5Version miner UI5 version
|
|
154
|
+
*/
|
|
155
|
+
function fillReuseComponents(
|
|
156
|
+
reuseComponentsIds: Set<string>,
|
|
157
|
+
node: OutlineViewNode,
|
|
158
|
+
scenario: Scenario,
|
|
159
|
+
minorUI5Version: number
|
|
160
|
+
): void {
|
|
161
|
+
if (scenario === 'ADAPTATION_PROJECT' && node?.component && isReuseComponent(node.id, minorUI5Version)) {
|
|
162
|
+
reuseComponentsIds.add(node.id);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
139
165
|
/**
|
|
140
166
|
* Handles duplicate nodes that are retrieved from extension point default content and created controls,
|
|
141
167
|
* if they exist under an extension point these controls are removed from the children array
|
|
142
168
|
*
|
|
143
169
|
* @param children outline view node children
|
|
144
170
|
* @param scenario type of project
|
|
171
|
+
* @param reuseComponentsIds ids of reuse components that are filled when outline nodes are transformed
|
|
145
172
|
* @returns transformed outline tree nodes
|
|
146
173
|
*/
|
|
147
|
-
export async function handleDuplicateNodes(
|
|
174
|
+
export async function handleDuplicateNodes(
|
|
175
|
+
children: OutlineViewNode[],
|
|
176
|
+
scenario: Scenario,
|
|
177
|
+
reuseComponentsIds: Set<string>
|
|
178
|
+
): Promise<OutlineNode[]> {
|
|
148
179
|
const extPointIDs = new Set<string>();
|
|
149
180
|
|
|
150
181
|
children.forEach((child: OutlineViewNode) => {
|
|
@@ -156,5 +187,5 @@ export async function handleDuplicateNodes(children: OutlineViewNode[], scenario
|
|
|
156
187
|
|
|
157
188
|
const uniqueChildren = children.filter((child) => !extPointIDs.has(child.id));
|
|
158
189
|
|
|
159
|
-
return transformNodes(uniqueChildren, scenario);
|
|
190
|
+
return transformNodes(uniqueChildren, scenario, reuseComponentsIds);
|
|
160
191
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
sap.ui.define(["../control-data", "../utils", "sap/ui/dt/OverlayUtil", "sap/ui/dt/OverlayRegistry", "../ui5-utils"], function (___control_data, ___utils, OverlayUtil, OverlayRegistry, ___ui5_utils) {
|
|
3
|
+
sap.ui.define(["../control-data", "../utils", "sap/ui/dt/OverlayUtil", "sap/ui/dt/OverlayRegistry", "../ui5-utils", "sap/ui/core/Component"], function (___control_data, ___utils, OverlayUtil, OverlayRegistry, ___ui5_utils, Component) {
|
|
4
4
|
"use strict";
|
|
5
5
|
|
|
6
6
|
const buildControlData = ___control_data["buildControlData"];
|
|
@@ -30,10 +30,33 @@ sap.ui.define(["../control-data", "../utils", "sap/ui/dt/OverlayUtil", "sap/ui/d
|
|
|
30
30
|
}
|
|
31
31
|
return editable;
|
|
32
32
|
};
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Function that checks if control is reuse component
|
|
36
|
+
*
|
|
37
|
+
* @param controlId id control
|
|
38
|
+
* @param minorUI5Version minor UI5 version
|
|
39
|
+
* @returns boolean if control is from reused component view
|
|
40
|
+
*/
|
|
41
|
+
const isReuseComponent = (controlId, minorUI5Version) => {
|
|
42
|
+
if (minorUI5Version <= 114) {
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
const component = Component.getComponentById(controlId);
|
|
46
|
+
if (!component) {
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
const manifest = component.getManifest();
|
|
50
|
+
if (!manifest) {
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
return manifest['sap.app']?.type === 'component';
|
|
54
|
+
};
|
|
33
55
|
var __exports = {
|
|
34
56
|
__esModule: true
|
|
35
57
|
};
|
|
36
58
|
__exports.isEditable = isEditable;
|
|
59
|
+
__exports.isReuseComponent = isReuseComponent;
|
|
37
60
|
return __exports;
|
|
38
61
|
});
|
|
39
62
|
//# sourceMappingURL=utils.js.map
|
|
@@ -3,6 +3,8 @@ import { getRuntimeControl } from '../utils';
|
|
|
3
3
|
import OverlayUtil from 'sap/ui/dt/OverlayUtil';
|
|
4
4
|
import OverlayRegistry from 'sap/ui/dt/OverlayRegistry';
|
|
5
5
|
import { getComponent } from '../ui5-utils';
|
|
6
|
+
import Component from 'sap/ui/core/Component';
|
|
7
|
+
import { Manifest } from 'sap/ui/rta/RuntimeAuthoring';
|
|
6
8
|
|
|
7
9
|
export const isEditable = (id = ''): boolean => {
|
|
8
10
|
let editable = false;
|
|
@@ -27,3 +29,28 @@ export const isEditable = (id = ''): boolean => {
|
|
|
27
29
|
}
|
|
28
30
|
return editable;
|
|
29
31
|
};
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Function that checks if control is reuse component
|
|
35
|
+
*
|
|
36
|
+
* @param controlId id control
|
|
37
|
+
* @param minorUI5Version minor UI5 version
|
|
38
|
+
* @returns boolean if control is from reused component view
|
|
39
|
+
*/
|
|
40
|
+
export const isReuseComponent = (controlId: string, minorUI5Version: number): boolean => {
|
|
41
|
+
if(minorUI5Version <= 114) {
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const component = Component.getComponentById(controlId);
|
|
46
|
+
if (!component) {
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const manifest = component.getManifest() as Manifest;
|
|
51
|
+
if(!manifest) {
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return manifest['sap.app']?.type === 'component';
|
|
56
|
+
};
|
package/package.json
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"bugs": {
|
|
10
10
|
"url": "https://github.com/SAP/open-ux-tools/issues?q=is%3Aopen+is%3Aissue+label%3Abug+label%3Apreview-middleware"
|
|
11
11
|
},
|
|
12
|
-
"version": "0.16.
|
|
12
|
+
"version": "0.16.9",
|
|
13
13
|
"license": "Apache-2.0",
|
|
14
14
|
"author": "@SAP/ux-tools-team",
|
|
15
15
|
"main": "dist/index.js",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"@sap-ux/logger": "0.6.0",
|
|
29
29
|
"@sap-ux/btp-utils": "0.15.0",
|
|
30
30
|
"@sap-ux/adp-tooling": "0.12.5",
|
|
31
|
-
"@sap-ux/control-property-editor-sources": "npm:@sap-ux/control-property-editor@0.4.
|
|
31
|
+
"@sap-ux/control-property-editor-sources": "npm:@sap-ux/control-property-editor@0.4.25",
|
|
32
32
|
"@sap-ux/project-access": "1.25.1"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
@@ -45,8 +45,8 @@
|
|
|
45
45
|
"supertest": "6.3.3",
|
|
46
46
|
"@sap-ux-private/playwright": "0.1.0",
|
|
47
47
|
"dotenv": "16.3.1",
|
|
48
|
-
"@private/preview-middleware-client": "npm:@sap-ux-private/preview-middleware-client@0.10.1",
|
|
49
48
|
"@sap-ux/axios-extension": "1.15.1",
|
|
49
|
+
"@private/preview-middleware-client": "npm:@sap-ux-private/preview-middleware-client@0.10.2",
|
|
50
50
|
"@sap-ux/store": "0.7.0",
|
|
51
51
|
"@sap-ux/ui5-info": "0.6.0",
|
|
52
52
|
"@sap-ux/i18n": "0.1.0"
|