@sap-ux/preview-middleware 0.7.3 → 0.7.4
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/api-handler.js +33 -0
- package/dist/client/adp/api-handler.ts +36 -0
- package/dist/client/adp/controllers/AddFragment.controller.js +6 -11
- package/dist/client/adp/controllers/AddFragment.controller.ts +3 -45
- package/dist/client/adp/controllers/BaseDialog.controller.js +17 -0
- package/dist/client/adp/controllers/BaseDialog.controller.ts +51 -0
- package/dist/client/adp/controllers/ControllerExtension.controller.js +114 -0
- package/dist/client/adp/controllers/ControllerExtension.controller.ts +172 -0
- package/dist/client/adp/init-dialogs.js +10 -2
- package/dist/client/adp/init-dialogs.ts +15 -2
- package/dist/client/adp/init.ts +1 -0
- package/dist/client/adp/ui/AddFragment.view.xml +1 -1
- package/dist/client/adp/ui/ControllerExtension.view.xml +38 -0
- package/dist/client/cpe/changes/service.js +2 -3
- package/dist/client/cpe/changes/service.ts +2 -3
- package/dist/client/cpe/control-data.js +0 -1
- package/dist/client/cpe/control-data.ts +0 -1
- package/dist/client/cpe/init.js +8 -9
- package/dist/client/cpe/init.ts +5 -7
- package/dist/client/cpe/outline/index.js +2 -2
- package/dist/client/cpe/outline/index.ts +2 -8
- package/dist/client/cpe/outline/nodes.js +6 -7
- package/dist/client/cpe/outline/nodes.ts +6 -8
- package/dist/client/cpe/outline/utils.js +6 -5
- package/dist/client/cpe/outline/utils.ts +4 -4
- package/dist/client/cpe/selection.js +12 -9
- package/dist/client/cpe/selection.ts +10 -7
- package/dist/client/cpe/types.ts +1 -12
- package/dist/client/cpe/ui5-utils.js +51 -0
- package/dist/client/cpe/ui5-utils.ts +45 -0
- package/package.json +3 -3
- package/dist/client/cpe/facade.js +0 -95
- package/dist/client/cpe/facade.ts +0 -95
|
@@ -4,10 +4,13 @@ import type UI5Element from 'sap/ui/core/Element';
|
|
|
4
4
|
|
|
5
5
|
/** sap.ui.rta */
|
|
6
6
|
import type RuntimeAuthoring from 'sap/ui/rta/RuntimeAuthoring';
|
|
7
|
+
|
|
7
8
|
import AddFragment from './controllers/AddFragment.controller';
|
|
9
|
+
import ControllerExtension from './controllers/ControllerExtension.controller';
|
|
8
10
|
|
|
9
11
|
export const enum DialogNames {
|
|
10
|
-
ADD_FRAGMENT = 'AddFragment'
|
|
12
|
+
ADD_FRAGMENT = 'AddFragment',
|
|
13
|
+
CONTROLLER_EXTENSION = 'ControllerExtension'
|
|
11
14
|
}
|
|
12
15
|
|
|
13
16
|
/**
|
|
@@ -24,6 +27,13 @@ export const initDialogs = (rta: RuntimeAuthoring): void => {
|
|
|
24
27
|
handler: async (overlays: UI5Element[]) => await handler(overlays[0], rta, DialogNames.ADD_FRAGMENT),
|
|
25
28
|
icon: 'sap-icon://attachment-html'
|
|
26
29
|
});
|
|
30
|
+
|
|
31
|
+
contextMenu.addMenuItem({
|
|
32
|
+
id: 'EXTEND_CONTROLLER',
|
|
33
|
+
text: 'Extend With Controller',
|
|
34
|
+
handler: async (overlays: UI5Element[]) => await handler(overlays[0], rta, DialogNames.CONTROLLER_EXTENSION),
|
|
35
|
+
icon: 'sap-icon://create-form'
|
|
36
|
+
});
|
|
27
37
|
};
|
|
28
38
|
|
|
29
39
|
/**
|
|
@@ -34,7 +44,10 @@ export const initDialogs = (rta: RuntimeAuthoring): void => {
|
|
|
34
44
|
* @param dialogName Dialog name
|
|
35
45
|
*/
|
|
36
46
|
export async function handler(overlays: UI5Element, rta: RuntimeAuthoring, dialogName: DialogNames): Promise<void> {
|
|
37
|
-
const controller =
|
|
47
|
+
const controller =
|
|
48
|
+
dialogName === DialogNames.ADD_FRAGMENT
|
|
49
|
+
? new AddFragment(`open.ux.preview.client.adp.controllers.${dialogName}`, overlays, rta)
|
|
50
|
+
: new ControllerExtension(`open.ux.preview.client.adp.controllers.${dialogName}`, overlays, rta);
|
|
38
51
|
|
|
39
52
|
await XMLView.create({
|
|
40
53
|
viewName: `open.ux.preview.client.adp.ui.${dialogName}`,
|
package/dist/client/adp/init.ts
CHANGED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
<mvc:View xmlns:mvc="sap.ui.core.mvc"
|
|
2
|
+
xmlns="sap.m"
|
|
3
|
+
xmlns:core="sap.ui.core"
|
|
4
|
+
xmlns:f="sap.ui.layout.form">
|
|
5
|
+
<Dialog id="controllerExtensionDialog" title="Extend With Controller" contentWidth="450px" class="sapUiRTABorder">
|
|
6
|
+
<content>
|
|
7
|
+
<f:SimpleForm id="controllerExtensionDialog_Form"
|
|
8
|
+
editable="true"
|
|
9
|
+
layout="ResponsiveGridLayout"
|
|
10
|
+
labelSpanS="4"
|
|
11
|
+
singleContainerFullSize="false">
|
|
12
|
+
<f:content>
|
|
13
|
+
<Label text="Controller Name" />
|
|
14
|
+
<Input
|
|
15
|
+
description=".js"
|
|
16
|
+
value="{/newControllerName}"
|
|
17
|
+
liveChange="onControllerNameInputChange">
|
|
18
|
+
</Input>
|
|
19
|
+
</f:content>
|
|
20
|
+
</f:SimpleForm>
|
|
21
|
+
</content>
|
|
22
|
+
<beginButton>
|
|
23
|
+
<Button
|
|
24
|
+
id="createDialogBtn"
|
|
25
|
+
text="Create"
|
|
26
|
+
press="onCreateBtnPress"
|
|
27
|
+
enabled="false"
|
|
28
|
+
type="Emphasized" />
|
|
29
|
+
</beginButton>
|
|
30
|
+
<endButton>
|
|
31
|
+
<Button
|
|
32
|
+
id="closeDialogBtn"
|
|
33
|
+
text="Cancel"
|
|
34
|
+
press="handleDialogClose"
|
|
35
|
+
type="Reject" />
|
|
36
|
+
</endButton>
|
|
37
|
+
</Dialog>
|
|
38
|
+
</mvc:View>
|
|
@@ -34,9 +34,8 @@ sap.ui.define([
|
|
|
34
34
|
}
|
|
35
35
|
class ChangeService {
|
|
36
36
|
savedChanges = [];
|
|
37
|
-
constructor(options,
|
|
37
|
+
constructor(options, selectionService) {
|
|
38
38
|
this.options = options;
|
|
39
|
-
this.ui5 = ui5;
|
|
40
39
|
this.selectionService = selectionService;
|
|
41
40
|
}
|
|
42
41
|
async init(sendAction, subscribe) {
|
|
@@ -48,7 +47,7 @@ sap.ui.define([
|
|
|
48
47
|
} catch (exception) {
|
|
49
48
|
let name = '';
|
|
50
49
|
const id = action.payload.controlId || '';
|
|
51
|
-
const control =
|
|
50
|
+
const control = sap.ui.getCore().byId(id);
|
|
52
51
|
if (control) {
|
|
53
52
|
name = control.getMetadata().getName();
|
|
54
53
|
}
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
import { applyChange } from './flex-change';
|
|
15
15
|
import type { SelectionService } from '../selection';
|
|
16
16
|
|
|
17
|
-
import type { ActionSenderFunction, SubscribeFunction, UI5AdaptationOptions
|
|
17
|
+
import type { ActionSenderFunction, SubscribeFunction, UI5AdaptationOptions } from '../types';
|
|
18
18
|
import type Event from 'sap/ui/base/Event';
|
|
19
19
|
import type BaseCommand from 'sap/ui/rta/command/BaseCommand';
|
|
20
20
|
import Log from 'sap/base/Log';
|
|
@@ -93,7 +93,6 @@ export class ChangeService {
|
|
|
93
93
|
*/
|
|
94
94
|
constructor(
|
|
95
95
|
private readonly options: UI5AdaptationOptions,
|
|
96
|
-
private readonly ui5: UI5Facade,
|
|
97
96
|
private readonly selectionService: SelectionService
|
|
98
97
|
) {}
|
|
99
98
|
|
|
@@ -115,7 +114,7 @@ export class ChangeService {
|
|
|
115
114
|
// send error information
|
|
116
115
|
let name = '';
|
|
117
116
|
const id = action.payload.controlId || '';
|
|
118
|
-
const control =
|
|
117
|
+
const control = sap.ui.getCore().byId(id);
|
|
119
118
|
if (control) {
|
|
120
119
|
name = control.getMetadata().getName();
|
|
121
120
|
}
|
package/dist/client/cpe/init.js
CHANGED
|
@@ -2,36 +2,35 @@
|
|
|
2
2
|
sap.ui.define([
|
|
3
3
|
'open/ux/preview/client/thirdparty/@sap-ux-private/control-property-editor-common',
|
|
4
4
|
'./outline/index',
|
|
5
|
-
'./facade',
|
|
6
5
|
'./selection',
|
|
7
6
|
'./changes/service',
|
|
8
7
|
'./documentation',
|
|
9
8
|
'sap/base/Log',
|
|
10
|
-
'./logger'
|
|
11
|
-
|
|
9
|
+
'./logger',
|
|
10
|
+
'./ui5-utils'
|
|
11
|
+
], function (___sap_ux_private_control_property_editor_common, ___outline_index, ___selection, ___changes_service, ___documentation, Log, ___logger, ___ui5_utils) {
|
|
12
12
|
'use strict';
|
|
13
13
|
const startPostMessageCommunication = ___sap_ux_private_control_property_editor_common['startPostMessageCommunication'];
|
|
14
14
|
const iconsLoaded = ___sap_ux_private_control_property_editor_common['iconsLoaded'];
|
|
15
15
|
const enableTelemetry = ___sap_ux_private_control_property_editor_common['enableTelemetry'];
|
|
16
16
|
const initOutline = ___outline_index['initOutline'];
|
|
17
|
-
const createUi5Facade = ___facade['createUi5Facade'];
|
|
18
17
|
const SelectionService = ___selection['SelectionService'];
|
|
19
18
|
const ChangeService = ___changes_service['ChangeService'];
|
|
20
19
|
const loadDefaultLibraries = ___documentation['loadDefaultLibraries'];
|
|
21
20
|
const logger = ___logger['logger'];
|
|
21
|
+
const getIcons = ___ui5_utils['getIcons'];
|
|
22
22
|
function init(rta) {
|
|
23
23
|
Log.info('Initializing Control Property Editor');
|
|
24
24
|
const flexSettings = rta.getFlexSettings();
|
|
25
25
|
if (flexSettings.telemetry === true) {
|
|
26
26
|
enableTelemetry();
|
|
27
27
|
}
|
|
28
|
-
const ui5 = createUi5Facade();
|
|
29
28
|
const actionHandlers = [];
|
|
30
29
|
function subscribe(handler) {
|
|
31
30
|
actionHandlers.push(handler);
|
|
32
31
|
}
|
|
33
|
-
const selectionService = new SelectionService(rta
|
|
34
|
-
const changesService = new ChangeService({ rta },
|
|
32
|
+
const selectionService = new SelectionService(rta);
|
|
33
|
+
const changesService = new ChangeService({ rta }, selectionService);
|
|
35
34
|
const services = [
|
|
36
35
|
selectionService,
|
|
37
36
|
changesService
|
|
@@ -50,8 +49,8 @@ sap.ui.define([
|
|
|
50
49
|
for (const service of services) {
|
|
51
50
|
service.init(sendAction, subscribe);
|
|
52
51
|
}
|
|
53
|
-
initOutline(rta,
|
|
54
|
-
const icons =
|
|
52
|
+
initOutline(rta, sendAction).catch(error => Log.error('Error during initialization of Control Property Editor', error));
|
|
53
|
+
const icons = getIcons();
|
|
55
54
|
sendAction(iconsLoaded(icons));
|
|
56
55
|
} catch (error) {
|
|
57
56
|
Log.error('Error during initialization of Control Property Editor', error);
|
package/dist/client/cpe/init.ts
CHANGED
|
@@ -8,13 +8,12 @@ import type RuntimeAuthoring from 'sap/ui/rta/RuntimeAuthoring';
|
|
|
8
8
|
|
|
9
9
|
import type { ActionHandler, Service } from './types';
|
|
10
10
|
import { initOutline } from './outline/index';
|
|
11
|
-
import { createUi5Facade } from './facade';
|
|
12
11
|
import { SelectionService } from './selection';
|
|
13
12
|
import { ChangeService } from './changes/service';
|
|
14
13
|
import { loadDefaultLibraries } from './documentation';
|
|
15
14
|
import Log from 'sap/base/Log';
|
|
16
15
|
import { logger } from './logger';
|
|
17
|
-
|
|
16
|
+
import { getIcons } from './ui5-utils';
|
|
18
17
|
|
|
19
18
|
export default function init(rta: RuntimeAuthoring): Promise<void> {
|
|
20
19
|
Log.info('Initializing Control Property Editor');
|
|
@@ -25,7 +24,6 @@ export default function init(rta: RuntimeAuthoring): Promise<void> {
|
|
|
25
24
|
enableTelemetry();
|
|
26
25
|
}
|
|
27
26
|
|
|
28
|
-
const ui5 = createUi5Facade();
|
|
29
27
|
const actionHandlers: ActionHandler[] = [];
|
|
30
28
|
/**
|
|
31
29
|
*
|
|
@@ -35,9 +33,9 @@ export default function init(rta: RuntimeAuthoring): Promise<void> {
|
|
|
35
33
|
actionHandlers.push(handler);
|
|
36
34
|
}
|
|
37
35
|
|
|
38
|
-
const selectionService = new SelectionService(rta
|
|
36
|
+
const selectionService = new SelectionService(rta);
|
|
39
37
|
|
|
40
|
-
const changesService = new ChangeService({ rta },
|
|
38
|
+
const changesService = new ChangeService({ rta }, selectionService);
|
|
41
39
|
const services: Service[] = [selectionService, changesService];
|
|
42
40
|
try {
|
|
43
41
|
loadDefaultLibraries();
|
|
@@ -60,10 +58,10 @@ export default function init(rta: RuntimeAuthoring): Promise<void> {
|
|
|
60
58
|
}
|
|
61
59
|
// For initOutline to complete the RTA needs to already running (to access RTA provided services).
|
|
62
60
|
// That can only happen if the plugin initialization has completed.
|
|
63
|
-
initOutline(rta,
|
|
61
|
+
initOutline(rta, sendAction).catch((error) =>
|
|
64
62
|
Log.error('Error during initialization of Control Property Editor', error)
|
|
65
63
|
);
|
|
66
|
-
const icons =
|
|
64
|
+
const icons = getIcons();
|
|
67
65
|
sendAction(iconsLoaded(icons));
|
|
68
66
|
} catch (error) {
|
|
69
67
|
Log.error('Error during initialization of Control Property Editor', error);
|
|
@@ -7,12 +7,12 @@ sap.ui.define([
|
|
|
7
7
|
'use strict';
|
|
8
8
|
const outlineChanged = ___sap_ux_private_control_property_editor_common['outlineChanged'];
|
|
9
9
|
const transformNodes = ___nodes['transformNodes'];
|
|
10
|
-
async function initOutline(rta,
|
|
10
|
+
async function initOutline(rta, sendAction) {
|
|
11
11
|
const outline = await rta.getService('outline');
|
|
12
12
|
async function syncOutline() {
|
|
13
13
|
try {
|
|
14
14
|
const viewNodes = await outline.get();
|
|
15
|
-
const outlineNodes = await transformNodes(
|
|
15
|
+
const outlineNodes = await transformNodes(viewNodes);
|
|
16
16
|
sendAction(outlineChanged(outlineNodes));
|
|
17
17
|
} catch (error) {
|
|
18
18
|
Log.error('Outline sync failed!', error);
|
|
@@ -4,26 +4,20 @@ import { outlineChanged } from '@sap-ux-private/control-property-editor-common';
|
|
|
4
4
|
import type RuntimeAuthoring from 'sap/ui/rta/RuntimeAuthoring';
|
|
5
5
|
import type OutlineService from 'sap/ui/rta/command/OutlineService';
|
|
6
6
|
|
|
7
|
-
import type { UI5Facade } from '../types';
|
|
8
7
|
import { transformNodes } from './nodes';
|
|
9
8
|
import Log from 'sap/base/Log';
|
|
10
9
|
|
|
11
10
|
/**
|
|
12
11
|
*
|
|
13
12
|
* @param rta runtimeAuthoring object.
|
|
14
|
-
* @param ui5 - facade for ui5 framework methods
|
|
15
13
|
* @param sendAction send action method.
|
|
16
14
|
*/
|
|
17
|
-
export async function initOutline(
|
|
18
|
-
rta: RuntimeAuthoring,
|
|
19
|
-
ui5: UI5Facade,
|
|
20
|
-
sendAction: (action: ExternalAction) => void
|
|
21
|
-
): Promise<void> {
|
|
15
|
+
export async function initOutline(rta: RuntimeAuthoring, sendAction: (action: ExternalAction) => void): Promise<void> {
|
|
22
16
|
const outline = await rta.getService<OutlineService>('outline');
|
|
23
17
|
async function syncOutline() {
|
|
24
18
|
try {
|
|
25
19
|
const viewNodes = await outline.get();
|
|
26
|
-
const outlineNodes = await transformNodes(
|
|
20
|
+
const outlineNodes = await transformNodes(viewNodes);
|
|
27
21
|
|
|
28
22
|
sendAction(outlineChanged(outlineNodes));
|
|
29
23
|
} catch (error) {
|
|
@@ -4,8 +4,8 @@ sap.ui.define(["./utils"], function (___utils) {
|
|
|
4
4
|
"use strict";
|
|
5
5
|
|
|
6
6
|
const isEditable = ___utils["isEditable"];
|
|
7
|
-
function getAdditionalData(
|
|
8
|
-
const control =
|
|
7
|
+
function getAdditionalData(id) {
|
|
8
|
+
const control = sap.ui.getCore().byId(id);
|
|
9
9
|
if (control?.getMetadata().getProperty('text')) {
|
|
10
10
|
const text = control.getProperty('text');
|
|
11
11
|
if (typeof text === 'string' && text.trim() !== '') {
|
|
@@ -20,29 +20,28 @@ sap.ui.define(["./utils"], function (___utils) {
|
|
|
20
20
|
/**
|
|
21
21
|
* Transform node.
|
|
22
22
|
*
|
|
23
|
-
* @param ui5 - facade for ui5 framework methods
|
|
24
23
|
* @param input outline view node
|
|
25
24
|
* @param getAdditionalData gets additional data for give control id.
|
|
26
25
|
* @returns Promise<OutlineNode[]>
|
|
27
26
|
*/
|
|
28
|
-
async function transformNodes(
|
|
27
|
+
async function transformNodes(input) {
|
|
29
28
|
const stack = [...input];
|
|
30
29
|
const items = [];
|
|
31
30
|
while (stack.length) {
|
|
32
31
|
const current = stack.shift();
|
|
33
|
-
const editable = await isEditable(
|
|
32
|
+
const editable = await isEditable(current?.id);
|
|
34
33
|
if (current?.type === 'element') {
|
|
35
34
|
const children = (current.elements ?? []).flatMap(element => element.type === 'aggregation' ? element.elements ?? [] : []);
|
|
36
35
|
const {
|
|
37
36
|
text
|
|
38
|
-
} = getAdditionalData(
|
|
37
|
+
} = getAdditionalData(current.id);
|
|
39
38
|
const node = {
|
|
40
39
|
controlId: current.id,
|
|
41
40
|
controlType: current.technicalName,
|
|
42
41
|
name: text ?? current.technicalName.split('.').slice(-1)[0],
|
|
43
42
|
editable,
|
|
44
43
|
visible: current.visible ?? true,
|
|
45
|
-
children: await transformNodes(
|
|
44
|
+
children: await transformNodes(children)
|
|
46
45
|
};
|
|
47
46
|
items.push(node);
|
|
48
47
|
}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import type { OutlineNode } from '@sap-ux-private/control-property-editor-common';
|
|
2
2
|
import { isEditable } from './utils';
|
|
3
3
|
import type { OutlineViewNode } from 'sap/ui/rta/command/OutlineService';
|
|
4
|
-
import { UI5Facade } from '../types';
|
|
5
4
|
|
|
6
|
-
function getAdditionalData(
|
|
7
|
-
const control =
|
|
5
|
+
function getAdditionalData(id: string): { text?: string } {
|
|
6
|
+
const control = sap.ui.getCore().byId(id);
|
|
8
7
|
if (control?.getMetadata().getProperty('text')) {
|
|
9
8
|
const text = control.getProperty('text');
|
|
10
9
|
if (typeof text === 'string' && text.trim() !== '') {
|
|
@@ -19,22 +18,21 @@ function getAdditionalData(ui5: UI5Facade, id: string): { text?: string } {
|
|
|
19
18
|
/**
|
|
20
19
|
* Transform node.
|
|
21
20
|
*
|
|
22
|
-
* @param ui5 - facade for ui5 framework methods
|
|
23
21
|
* @param input outline view node
|
|
24
22
|
* @param getAdditionalData gets additional data for give control id.
|
|
25
23
|
* @returns Promise<OutlineNode[]>
|
|
26
24
|
*/
|
|
27
|
-
export async function transformNodes(
|
|
25
|
+
export async function transformNodes(input: OutlineViewNode[]): Promise<OutlineNode[]> {
|
|
28
26
|
const stack = [...input];
|
|
29
27
|
const items: OutlineNode[] = [];
|
|
30
28
|
while (stack.length) {
|
|
31
29
|
const current = stack.shift();
|
|
32
|
-
const editable = await isEditable(
|
|
30
|
+
const editable = await isEditable(current?.id);
|
|
33
31
|
if (current?.type === 'element') {
|
|
34
32
|
const children = (current.elements ?? []).flatMap((element: OutlineViewNode) =>
|
|
35
33
|
element.type === 'aggregation' ? element.elements ?? [] : []
|
|
36
34
|
);
|
|
37
|
-
const { text } = getAdditionalData(
|
|
35
|
+
const { text } = getAdditionalData(current.id);
|
|
38
36
|
|
|
39
37
|
const node: OutlineNode = {
|
|
40
38
|
controlId: current.id,
|
|
@@ -42,7 +40,7 @@ export async function transformNodes(ui5: UI5Facade, input: OutlineViewNode[]):
|
|
|
42
40
|
name: text ?? current.technicalName.split('.').slice(-1)[0],
|
|
43
41
|
editable,
|
|
44
42
|
visible: current.visible ?? true,
|
|
45
|
-
children: await transformNodes(
|
|
43
|
+
children: await transformNodes(children)
|
|
46
44
|
};
|
|
47
45
|
|
|
48
46
|
items.push(node);
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
sap.ui.define(["../control-data", "../utils", "sap/ui/dt/OverlayUtil", "sap/ui/dt/OverlayRegistry"], function (___control_data, ___utils, OverlayUtil, OverlayRegistry) {
|
|
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) {
|
|
4
4
|
"use strict";
|
|
5
5
|
|
|
6
6
|
const buildControlData = ___control_data["buildControlData"];
|
|
7
7
|
const getRuntimeControl = ___utils["getRuntimeControl"];
|
|
8
|
-
const
|
|
9
|
-
|
|
8
|
+
const getComponent = ___ui5_utils["getComponent"];
|
|
9
|
+
const isEditable = function () {
|
|
10
|
+
let id = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
10
11
|
let editable = false;
|
|
11
|
-
const control =
|
|
12
|
+
const control = sap.ui.getCore().byId(id);
|
|
12
13
|
if (!control) {
|
|
13
|
-
const component =
|
|
14
|
+
const component = getComponent(id);
|
|
14
15
|
if (component) {
|
|
15
16
|
return editable;
|
|
16
17
|
}
|
|
@@ -2,13 +2,13 @@ import { buildControlData } from '../control-data';
|
|
|
2
2
|
import { getRuntimeControl } from '../utils';
|
|
3
3
|
import OverlayUtil from 'sap/ui/dt/OverlayUtil';
|
|
4
4
|
import OverlayRegistry from 'sap/ui/dt/OverlayRegistry';
|
|
5
|
-
import
|
|
5
|
+
import { getComponent } from '../ui5-utils';
|
|
6
6
|
|
|
7
|
-
export const isEditable = (
|
|
7
|
+
export const isEditable = (id = ''): boolean => {
|
|
8
8
|
let editable = false;
|
|
9
|
-
const control =
|
|
9
|
+
const control = sap.ui.getCore().byId(id);
|
|
10
10
|
if (!control) {
|
|
11
|
-
const component =
|
|
11
|
+
const component = getComponent(id);
|
|
12
12
|
if (component) {
|
|
13
13
|
return editable;
|
|
14
14
|
}
|
|
@@ -4,8 +4,11 @@ sap.ui.define([
|
|
|
4
4
|
'./control-data',
|
|
5
5
|
'./utils',
|
|
6
6
|
'sap/base/Log',
|
|
7
|
-
'./documentation'
|
|
8
|
-
|
|
7
|
+
'./documentation',
|
|
8
|
+
'sap/ui/dt/OverlayRegistry',
|
|
9
|
+
'sap/ui/dt/OverlayUtil',
|
|
10
|
+
'./ui5-utils'
|
|
11
|
+
], function (___sap_ux_private_control_property_editor_common, ___control_data, ___utils, Log, ___documentation, OverlayRegistry, OverlayUtil, ___ui5_utils) {
|
|
9
12
|
'use strict';
|
|
10
13
|
const controlSelected = ___sap_ux_private_control_property_editor_common['controlSelected'];
|
|
11
14
|
const propertyChanged = ___sap_ux_private_control_property_editor_common['propertyChanged'];
|
|
@@ -14,6 +17,7 @@ sap.ui.define([
|
|
|
14
17
|
const buildControlData = ___control_data['buildControlData'];
|
|
15
18
|
const getRuntimeControl = ___utils['getRuntimeControl'];
|
|
16
19
|
const getDocumentation = ___documentation['getDocumentation'];
|
|
20
|
+
const getComponent = ___ui5_utils['getComponent'];
|
|
17
21
|
function propertyChangeId(controlId, propertyName) {
|
|
18
22
|
return [
|
|
19
23
|
controlId,
|
|
@@ -47,9 +51,8 @@ sap.ui.define([
|
|
|
47
51
|
class SelectionService {
|
|
48
52
|
appliedChangeCache = new Map();
|
|
49
53
|
activeChangeHandlers = new Set();
|
|
50
|
-
constructor(rta
|
|
54
|
+
constructor(rta) {
|
|
51
55
|
this.rta = rta;
|
|
52
|
-
this.ui5 = ui5;
|
|
53
56
|
}
|
|
54
57
|
async init(sendAction, subscribe) {
|
|
55
58
|
const eventOrigin = new Set();
|
|
@@ -60,9 +63,9 @@ sap.ui.define([
|
|
|
60
63
|
subscribe(async action => {
|
|
61
64
|
if (selectControl.match(action)) {
|
|
62
65
|
const id = action.payload;
|
|
63
|
-
const control =
|
|
66
|
+
const control = sap.ui.getCore().byId(id);
|
|
64
67
|
if (!control) {
|
|
65
|
-
const component =
|
|
68
|
+
const component = getComponent(id);
|
|
66
69
|
if (component) {
|
|
67
70
|
const controlData = buildControlData(component);
|
|
68
71
|
await addDocumentationForProperties(component, controlData);
|
|
@@ -72,13 +75,13 @@ sap.ui.define([
|
|
|
72
75
|
return;
|
|
73
76
|
}
|
|
74
77
|
eventOrigin.add('outline');
|
|
75
|
-
let controlOverlay =
|
|
78
|
+
let controlOverlay = OverlayRegistry.getOverlay(control);
|
|
76
79
|
const selectedOverlayControls = this.rta.getSelection() ?? [];
|
|
77
80
|
for (const selectedOverlayControl of selectedOverlayControls) {
|
|
78
81
|
selectedOverlayControl.setSelected(false);
|
|
79
82
|
}
|
|
80
83
|
if (!controlOverlay?.getDomRef()) {
|
|
81
|
-
controlOverlay =
|
|
84
|
+
controlOverlay = OverlayUtil.getClosestOverlayFor(control);
|
|
82
85
|
}
|
|
83
86
|
if (controlOverlay?.isSelectable()) {
|
|
84
87
|
controlOverlay.setSelected(true);
|
|
@@ -103,7 +106,7 @@ sap.ui.define([
|
|
|
103
106
|
}
|
|
104
107
|
this.activeChangeHandlers.clear();
|
|
105
108
|
if (Array.isArray(selection) && selection.length === 1) {
|
|
106
|
-
const overlayControl =
|
|
109
|
+
const overlayControl = sap.ui.getCore().byId(selection[0].getId());
|
|
107
110
|
if (overlayControl) {
|
|
108
111
|
const runtimeControl = getRuntimeControl(overlayControl);
|
|
109
112
|
const controlName = runtimeControl.getMetadata().getName();
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
} from '@sap-ux-private/control-property-editor-common';
|
|
9
9
|
import { buildControlData } from './control-data';
|
|
10
10
|
import { getRuntimeControl, ManagedObjectMetadataProperties, PropertiesInfo } from './utils';
|
|
11
|
-
import type { ActionSenderFunction, Service, SubscribeFunction
|
|
11
|
+
import type { ActionSenderFunction, Service, SubscribeFunction } from './types';
|
|
12
12
|
|
|
13
13
|
import type Event from 'sap/ui/base/Event';
|
|
14
14
|
import type ElementOverlay from 'sap/ui/dt/ElementOverlay';
|
|
@@ -17,6 +17,9 @@ import type { SelectionChangeEvent } from 'sap/ui/rta/RuntimeAuthoring';
|
|
|
17
17
|
import type RuntimeAuthoring from 'sap/ui/rta/RuntimeAuthoring';
|
|
18
18
|
import Log from 'sap/base/Log';
|
|
19
19
|
import { getDocumentation } from './documentation';
|
|
20
|
+
import OverlayRegistry from 'sap/ui/dt/OverlayRegistry';
|
|
21
|
+
import OverlayUtil from 'sap/ui/dt/OverlayUtil';
|
|
22
|
+
import { getComponent } from './ui5-utils';
|
|
20
23
|
|
|
21
24
|
export interface PropertyChangeParams {
|
|
22
25
|
name: string;
|
|
@@ -90,7 +93,7 @@ export class SelectionService implements Service {
|
|
|
90
93
|
* @param rta - rta object.
|
|
91
94
|
* @param ui5 - facade for ui5 framework methods
|
|
92
95
|
*/
|
|
93
|
-
constructor(private readonly rta: RuntimeAuthoring
|
|
96
|
+
constructor(private readonly rta: RuntimeAuthoring) {}
|
|
94
97
|
|
|
95
98
|
/**
|
|
96
99
|
* Initialize selection service.
|
|
@@ -107,9 +110,9 @@ export class SelectionService implements Service {
|
|
|
107
110
|
subscribe(async (action: ExternalAction): Promise<void> => {
|
|
108
111
|
if (selectControl.match(action)) {
|
|
109
112
|
const id = action.payload;
|
|
110
|
-
const control =
|
|
113
|
+
const control = sap.ui.getCore().byId(id);
|
|
111
114
|
if (!control) {
|
|
112
|
-
const component =
|
|
115
|
+
const component = getComponent(id);
|
|
113
116
|
if (component) {
|
|
114
117
|
const controlData = buildControlData(component);
|
|
115
118
|
|
|
@@ -121,7 +124,7 @@ export class SelectionService implements Service {
|
|
|
121
124
|
return;
|
|
122
125
|
}
|
|
123
126
|
eventOrigin.add('outline');
|
|
124
|
-
let controlOverlay =
|
|
127
|
+
let controlOverlay = OverlayRegistry.getOverlay(control);
|
|
125
128
|
const selectedOverlayControls = this.rta.getSelection() ?? [];
|
|
126
129
|
//remove previous selection
|
|
127
130
|
for (const selectedOverlayControl of selectedOverlayControls) {
|
|
@@ -130,7 +133,7 @@ export class SelectionService implements Service {
|
|
|
130
133
|
|
|
131
134
|
if (!controlOverlay?.getDomRef()) {
|
|
132
135
|
//look for closest control in order to highlight in UI the (without firing the selection event)
|
|
133
|
-
controlOverlay =
|
|
136
|
+
controlOverlay = OverlayUtil.getClosestOverlayFor(control);
|
|
134
137
|
}
|
|
135
138
|
|
|
136
139
|
if (controlOverlay?.isSelectable()) {
|
|
@@ -173,7 +176,7 @@ export class SelectionService implements Service {
|
|
|
173
176
|
}
|
|
174
177
|
this.activeChangeHandlers.clear();
|
|
175
178
|
if (Array.isArray(selection) && selection.length === 1) {
|
|
176
|
-
const overlayControl =
|
|
179
|
+
const overlayControl = sap.ui.getCore().byId(selection[0].getId()) as ElementOverlay;
|
|
177
180
|
if (overlayControl) {
|
|
178
181
|
const runtimeControl = getRuntimeControl(overlayControl);
|
|
179
182
|
const controlName = runtimeControl.getMetadata().getName();
|
package/dist/client/cpe/types.ts
CHANGED
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
import type { ExternalAction
|
|
1
|
+
import type { ExternalAction } from '@sap-ux-private/control-property-editor-common';
|
|
2
2
|
import type RuntimeAuthoring from 'sap/ui/rta/RuntimeAuthoring';
|
|
3
|
-
import type Element from 'sap/ui/core/Element';
|
|
4
|
-
import type { ID } from 'sap/ui/core/library';
|
|
5
|
-
import type ElementOverlay from 'sap/ui/dt/ElementOverlay';
|
|
6
|
-
import type Component from 'sap/ui/core/Component';
|
|
7
3
|
|
|
8
4
|
export interface UI5AdaptationOptions {
|
|
9
5
|
rta: RuntimeAuthoring;
|
|
@@ -44,10 +40,3 @@ export interface Service {
|
|
|
44
40
|
init(sendAction: ActionSenderFunction, subscribe: SubscribeFunction): void;
|
|
45
41
|
}
|
|
46
42
|
|
|
47
|
-
export interface UI5Facade {
|
|
48
|
-
getControlById: <T extends Element>(id: ID) => T | undefined;
|
|
49
|
-
getIcons: () => IconDetails[];
|
|
50
|
-
getComponent: <T extends Component>(id: ID) => T | undefined;
|
|
51
|
-
getOverlay: <T extends ElementOverlay>(control: Element) => T | undefined;
|
|
52
|
-
getClosestOverlayFor: <T extends ElementOverlay>(control: Element) => T | undefined;
|
|
53
|
-
}
|