@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.
- 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/tsconfig.tsbuildinfo +1 -0
- 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 +3 -3
- package/dist/client/cpe/outline/index.js +0 -40
- package/dist/client/cpe/outline/index.ts +0 -37
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import NavContainer from 'sap/m/NavContainer';
|
|
2
|
+
import FlexibleColumnLayout from 'sap/f/FlexibleColumnLayout';
|
|
3
|
+
import { LayoutType } from 'sap/f/library';
|
|
4
|
+
import Control from 'sap/ui/core/Control';
|
|
5
|
+
import XMLView from 'sap/ui/core/mvc/XMLView';
|
|
6
|
+
import Log from 'sap/base/Log';
|
|
7
|
+
|
|
8
|
+
import { QuickActionActivationContext, QuickActionDefinitionGroup } from './quick-action-definition';
|
|
9
|
+
|
|
10
|
+
import type { ControlTreeIndex } from '../types';
|
|
11
|
+
import { getControlById } from '../../utils/core';
|
|
12
|
+
import { getRootControlFromComponentContainer } from '../utils';
|
|
13
|
+
|
|
14
|
+
const NAV_CONTAINER_CONTROL_TYPE = 'sap.m.NavContainer';
|
|
15
|
+
const FLEXIBLE_COLUMN_LAYOUT_CONTROL_TYPE = 'sap.f.FlexibleColumnLayout';
|
|
16
|
+
|
|
17
|
+
export interface ActivePage<T extends string> {
|
|
18
|
+
name: T;
|
|
19
|
+
view: XMLView;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Base class for Quick Action definition providers.
|
|
24
|
+
*
|
|
25
|
+
*/
|
|
26
|
+
export abstract class QuickActionDefinitionRegistry<T extends string> {
|
|
27
|
+
/**
|
|
28
|
+
* Mapping of page view name to page type name.
|
|
29
|
+
*/
|
|
30
|
+
PAGE_NAME_MAP: Record<string, T> = {};
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Provides a list of Quick Action definitions that are applicable for the given context.
|
|
34
|
+
*
|
|
35
|
+
* @param _context - Activation context.
|
|
36
|
+
*/
|
|
37
|
+
getDefinitions(_context: QuickActionActivationContext): QuickActionDefinitionGroup[] {
|
|
38
|
+
throw new Error('Not implemented!');
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Finds component container from the page control.
|
|
43
|
+
*
|
|
44
|
+
* @param page - Page control provided by containers.
|
|
45
|
+
* @returns ComponentContainer control.
|
|
46
|
+
*/
|
|
47
|
+
protected getComponentContainerFromPage(page: Control): Control | undefined {
|
|
48
|
+
return page;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Returns a list of Active pages based on the provided control index.
|
|
53
|
+
*
|
|
54
|
+
* @param controlIndex - Control tree index.
|
|
55
|
+
* @returns A list of Active pages.
|
|
56
|
+
*/
|
|
57
|
+
protected getActivePageContent(controlIndex: ControlTreeIndex): ActivePage<T>[] {
|
|
58
|
+
const views = this.getActiveViews(controlIndex);
|
|
59
|
+
const pages: ActivePage<T>[] = [];
|
|
60
|
+
for (const view of views) {
|
|
61
|
+
const name = view.getViewName();
|
|
62
|
+
const pageName = this.PAGE_NAME_MAP[name];
|
|
63
|
+
if (pageName) {
|
|
64
|
+
pages.push({
|
|
65
|
+
name: pageName,
|
|
66
|
+
view
|
|
67
|
+
});
|
|
68
|
+
} else {
|
|
69
|
+
Log.warning(`Could not find matching page for view of type "${name}".`);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return pages;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Get all the root views of currently active pages.
|
|
77
|
+
*
|
|
78
|
+
* @param controlIndex - Control index.
|
|
79
|
+
* @returns List of page root views.
|
|
80
|
+
*/
|
|
81
|
+
private getActiveViews(controlIndex: ControlTreeIndex): XMLView[] {
|
|
82
|
+
const pages = this.getActivePages(controlIndex);
|
|
83
|
+
const views: XMLView[] = [];
|
|
84
|
+
|
|
85
|
+
for (const page of pages) {
|
|
86
|
+
if (page) {
|
|
87
|
+
const container = this.getComponentContainerFromPage(page);
|
|
88
|
+
if (container) {
|
|
89
|
+
const rootControl = getRootControlFromComponentContainer(container);
|
|
90
|
+
if (rootControl) {
|
|
91
|
+
views.push(rootControl);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return views;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Finds active page controls from the control tree index.
|
|
101
|
+
*
|
|
102
|
+
* @param controlIndex - Control tree index.
|
|
103
|
+
* @returns A list of page controls.
|
|
104
|
+
*/
|
|
105
|
+
private getActivePages(controlIndex: ControlTreeIndex): (Control | undefined)[] {
|
|
106
|
+
const navContainerNode = controlIndex[NAV_CONTAINER_CONTROL_TYPE]?.[0];
|
|
107
|
+
if (navContainerNode) {
|
|
108
|
+
const control = getControlById(navContainerNode.controlId);
|
|
109
|
+
if (control instanceof NavContainer) {
|
|
110
|
+
return [control.getCurrentPage()];
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
const flexibleLayoutNode = controlIndex[FLEXIBLE_COLUMN_LAYOUT_CONTROL_TYPE]?.[0];
|
|
115
|
+
if (flexibleLayoutNode) {
|
|
116
|
+
const control = getControlById(flexibleLayoutNode.controlId);
|
|
117
|
+
if (control instanceof FlexibleColumnLayout) {
|
|
118
|
+
return this.getVisibleFlexibleColumnLayoutPages(control);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
return [];
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Finds the visible Flexible Column Layout pages.
|
|
127
|
+
*
|
|
128
|
+
* @param control - Flexible Column Layout control.
|
|
129
|
+
* @returns A list of visible pages.
|
|
130
|
+
*/
|
|
131
|
+
|
|
132
|
+
private getVisibleFlexibleColumnLayoutPages(control: FlexibleColumnLayout): (Control | undefined)[] {
|
|
133
|
+
const layout = control.getLayout();
|
|
134
|
+
switch (layout) {
|
|
135
|
+
case LayoutType.OneColumn:
|
|
136
|
+
return [control.getCurrentBeginColumnPage()];
|
|
137
|
+
case LayoutType.MidColumnFullScreen:
|
|
138
|
+
return [control.getCurrentMidColumnPage()];
|
|
139
|
+
case LayoutType.EndColumnFullScreen:
|
|
140
|
+
return [control.getCurrentEndColumnPage()];
|
|
141
|
+
case LayoutType.ThreeColumnsBeginExpandedEndHidden:
|
|
142
|
+
case LayoutType.ThreeColumnsMidExpanded:
|
|
143
|
+
case LayoutType.ThreeColumnsMidExpandedEndHidden:
|
|
144
|
+
case LayoutType.ThreeColumnsEndExpanded:
|
|
145
|
+
return [
|
|
146
|
+
control.getCurrentBeginColumnPage(),
|
|
147
|
+
control.getCurrentMidColumnPage(),
|
|
148
|
+
control.getCurrentEndColumnPage()
|
|
149
|
+
];
|
|
150
|
+
case LayoutType.TwoColumnsMidExpanded:
|
|
151
|
+
case LayoutType.TwoColumnsBeginExpanded:
|
|
152
|
+
return [control.getCurrentBeginColumnPage(), control.getCurrentMidColumnPage()];
|
|
153
|
+
}
|
|
154
|
+
return [];
|
|
155
|
+
}
|
|
156
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
sap.ui.define(["../../utils/core"], function (____utils_core) {
|
|
4
|
+
"use strict";
|
|
5
|
+
|
|
6
|
+
const getControlById = ____utils_core["getControlById"];
|
|
7
|
+
const isA = ____utils_core["isA"];
|
|
8
|
+
/**
|
|
9
|
+
* Checks if control is visible in the page.
|
|
10
|
+
*
|
|
11
|
+
* @param page - Page control.
|
|
12
|
+
* @param controlId - UI5 control id.
|
|
13
|
+
* @returns True if control is visible in the page.
|
|
14
|
+
*/
|
|
15
|
+
function pageHasControlId(page, controlId) {
|
|
16
|
+
const controlDomElement = getControlById(controlId)?.getDomRef();
|
|
17
|
+
return !!controlDomElement && !!page?.getDomRef()?.contains(controlDomElement);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Checks if control is a child element of the rootControl.
|
|
22
|
+
*
|
|
23
|
+
* @param control - UI5 Control to be tested.
|
|
24
|
+
* @param rootControl - UI5 root control.
|
|
25
|
+
* @returns True if control is the child of the specified rootControl.
|
|
26
|
+
*/
|
|
27
|
+
function isDescendantOfPage(control, rootControl) {
|
|
28
|
+
let currentControl = control;
|
|
29
|
+
while (currentControl) {
|
|
30
|
+
if (currentControl === rootControl) {
|
|
31
|
+
return true;
|
|
32
|
+
}
|
|
33
|
+
// if parent is a reusable component, use oContainer to find the parent
|
|
34
|
+
if (isA('sap.ui.core.Component', currentControl) && currentControl?.oContainer) {
|
|
35
|
+
currentControl = currentControl.oContainer.getParent();
|
|
36
|
+
} else {
|
|
37
|
+
currentControl = currentControl.getParent();
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Find all controls in page that match the provided types.
|
|
45
|
+
*
|
|
46
|
+
* @param controlIndex - Control tree index.
|
|
47
|
+
* @param activePage - Active page control.
|
|
48
|
+
* @param controlTypes - Relevant control types.
|
|
49
|
+
* @returns A list of UI5 controls.
|
|
50
|
+
*/
|
|
51
|
+
function getRelevantControlFromActivePage(controlIndex, activePage, controlTypes) {
|
|
52
|
+
const relevantControls = [];
|
|
53
|
+
for (const type of controlTypes) {
|
|
54
|
+
const controls = controlIndex[type] ?? [];
|
|
55
|
+
for (const control of controls) {
|
|
56
|
+
const ui5Control = getControlById(control.controlId);
|
|
57
|
+
const parent = ui5Control?.getParent();
|
|
58
|
+
const isActionApplicable = isDescendantOfPage(parent, activePage);
|
|
59
|
+
if (isActionApplicable && ui5Control) {
|
|
60
|
+
// if parent control added, discard adding child control.
|
|
61
|
+
// Relevant for cases where wrapper exists eg: sap.m.Table exist in sap.ui.comp.smarttable.SmartTable
|
|
62
|
+
const parentFound = relevantControls.findIndex(relevantControl => relevantControl.getId() === ui5Control.getParent()?.getId());
|
|
63
|
+
if (parentFound === -1) {
|
|
64
|
+
relevantControls.push(ui5Control);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return relevantControls;
|
|
70
|
+
}
|
|
71
|
+
function getParentContainer(control, type) {
|
|
72
|
+
let currentControl = control;
|
|
73
|
+
while (currentControl) {
|
|
74
|
+
if (isA(type, currentControl)) {
|
|
75
|
+
return currentControl;
|
|
76
|
+
}
|
|
77
|
+
// if parent is a reusable component, use oContainer to find the parent
|
|
78
|
+
if (isA('sap.ui.core.Component', currentControl) && currentControl?.oContainer) {
|
|
79
|
+
currentControl = currentControl.oContainer.getParent();
|
|
80
|
+
} else {
|
|
81
|
+
currentControl = currentControl.getParent();
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return undefined;
|
|
85
|
+
}
|
|
86
|
+
var __exports = {
|
|
87
|
+
__esModule: true
|
|
88
|
+
};
|
|
89
|
+
__exports.pageHasControlId = pageHasControlId;
|
|
90
|
+
__exports.getRelevantControlFromActivePage = getRelevantControlFromActivePage;
|
|
91
|
+
__exports.getParentContainer = getParentContainer;
|
|
92
|
+
return __exports;
|
|
93
|
+
});
|
|
94
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import UI5Element from 'sap/ui/core/Element';
|
|
2
|
+
import Control from 'sap/ui/core/Control';
|
|
3
|
+
import ManagedObject from 'sap/ui/base/ManagedObject';
|
|
4
|
+
import { FEAppPage } from 'sap/ui/rta/RuntimeAuthoring';
|
|
5
|
+
|
|
6
|
+
import { getControlById, isA } from '../../utils/core';
|
|
7
|
+
|
|
8
|
+
import type { ControlTreeIndex } from '../types';
|
|
9
|
+
import Component from 'sap/ui/core/Component';
|
|
10
|
+
|
|
11
|
+
export interface FEAppPageInfo {
|
|
12
|
+
page: FEAppPage;
|
|
13
|
+
isInvisible: boolean;
|
|
14
|
+
}
|
|
15
|
+
export interface FEAppPagesMap {
|
|
16
|
+
[key: string]: FEAppPageInfo[];
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Checks if control is visible in the page.
|
|
21
|
+
*
|
|
22
|
+
* @param page - Page control.
|
|
23
|
+
* @param controlId - UI5 control id.
|
|
24
|
+
* @returns True if control is visible in the page.
|
|
25
|
+
*/
|
|
26
|
+
export function pageHasControlId(page: Control, controlId: string): boolean {
|
|
27
|
+
const controlDomElement = getControlById(controlId)?.getDomRef();
|
|
28
|
+
return !!controlDomElement && !!page?.getDomRef()?.contains(controlDomElement);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Checks if control is a child element of the rootControl.
|
|
34
|
+
*
|
|
35
|
+
* @param control - UI5 Control to be tested.
|
|
36
|
+
* @param rootControl - UI5 root control.
|
|
37
|
+
* @returns True if control is the child of the specified rootControl.
|
|
38
|
+
*/
|
|
39
|
+
function isDescendantOfPage(control: ManagedObject | null | undefined, rootControl: ManagedObject) {
|
|
40
|
+
let currentControl = control;
|
|
41
|
+
while (currentControl) {
|
|
42
|
+
if (currentControl === rootControl) {
|
|
43
|
+
return true;
|
|
44
|
+
}
|
|
45
|
+
// if parent is a reusable component, use oContainer to find the parent
|
|
46
|
+
if (
|
|
47
|
+
isA<Component>('sap.ui.core.Component', currentControl) &&
|
|
48
|
+
(currentControl as unknown as { oContainer: Control })?.oContainer
|
|
49
|
+
) {
|
|
50
|
+
currentControl = (currentControl as unknown as { oContainer: Control }).oContainer.getParent();
|
|
51
|
+
} else {
|
|
52
|
+
currentControl = currentControl.getParent();
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Find all controls in page that match the provided types.
|
|
60
|
+
*
|
|
61
|
+
* @param controlIndex - Control tree index.
|
|
62
|
+
* @param activePage - Active page control.
|
|
63
|
+
* @param controlTypes - Relevant control types.
|
|
64
|
+
* @returns A list of UI5 controls.
|
|
65
|
+
*/
|
|
66
|
+
export function getRelevantControlFromActivePage(
|
|
67
|
+
controlIndex: ControlTreeIndex,
|
|
68
|
+
activePage: Control,
|
|
69
|
+
controlTypes: string[]
|
|
70
|
+
): UI5Element[] {
|
|
71
|
+
const relevantControls: UI5Element[] = [];
|
|
72
|
+
for (const type of controlTypes) {
|
|
73
|
+
const controls = controlIndex[type] ?? [];
|
|
74
|
+
for (const control of controls) {
|
|
75
|
+
const ui5Control = getControlById(control.controlId);
|
|
76
|
+
const parent = ui5Control?.getParent();
|
|
77
|
+
const isActionApplicable = isDescendantOfPage(parent, activePage);
|
|
78
|
+
|
|
79
|
+
if (isActionApplicable && ui5Control) {
|
|
80
|
+
// if parent control added, discard adding child control.
|
|
81
|
+
// Relevant for cases where wrapper exists eg: sap.m.Table exist in sap.ui.comp.smarttable.SmartTable
|
|
82
|
+
const parentFound = relevantControls.findIndex(
|
|
83
|
+
(relevantControl) => relevantControl.getId() === ui5Control.getParent()?.getId()
|
|
84
|
+
);
|
|
85
|
+
if (parentFound === -1) {
|
|
86
|
+
relevantControls.push(ui5Control);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return relevantControls;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export function getParentContainer<T extends ManagedObject>(
|
|
95
|
+
control: ManagedObject | null | undefined,
|
|
96
|
+
type: string
|
|
97
|
+
): T | undefined {
|
|
98
|
+
let currentControl = control;
|
|
99
|
+
while (currentControl) {
|
|
100
|
+
if (isA<T>(type, currentControl)) {
|
|
101
|
+
return currentControl;
|
|
102
|
+
}
|
|
103
|
+
// if parent is a reusable component, use oContainer to find the parent
|
|
104
|
+
if (
|
|
105
|
+
isA<Component>('sap.ui.core.Component', currentControl) &&
|
|
106
|
+
(currentControl as unknown as { oContainer: Control })?.oContainer
|
|
107
|
+
) {
|
|
108
|
+
currentControl = (currentControl as unknown as { oContainer: Control }).oContainer.getParent();
|
|
109
|
+
} else {
|
|
110
|
+
currentControl = currentControl.getParent();
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
return undefined;
|
|
114
|
+
}
|
|
@@ -7,9 +7,9 @@ sap.ui.define([
|
|
|
7
7
|
'./documentation',
|
|
8
8
|
'sap/ui/dt/OverlayRegistry',
|
|
9
9
|
'sap/ui/dt/OverlayUtil',
|
|
10
|
-
'
|
|
10
|
+
'../utils/core',
|
|
11
11
|
'../utils/error'
|
|
12
|
-
], function (___sap_ux_private_control_property_editor_common, ___control_data, ___utils, Log, ___documentation, OverlayRegistry, OverlayUtil,
|
|
12
|
+
], function (___sap_ux_private_control_property_editor_common, ___control_data, ___utils, Log, ___documentation, OverlayRegistry, OverlayUtil, ___utils_core, ___utils_error) {
|
|
13
13
|
'use strict';
|
|
14
14
|
const controlSelected = ___sap_ux_private_control_property_editor_common['controlSelected'];
|
|
15
15
|
const propertyChanged = ___sap_ux_private_control_property_editor_common['propertyChanged'];
|
|
@@ -18,7 +18,7 @@ sap.ui.define([
|
|
|
18
18
|
const buildControlData = ___control_data['buildControlData'];
|
|
19
19
|
const getRuntimeControl = ___utils['getRuntimeControl'];
|
|
20
20
|
const getDocumentation = ___documentation['getDocumentation'];
|
|
21
|
-
const getComponent =
|
|
21
|
+
const getComponent = ___utils_core['getComponent'];
|
|
22
22
|
const getError = ___utils_error['getError'];
|
|
23
23
|
function propertyChangeId(controlId, propertyName) {
|
|
24
24
|
return [
|
|
@@ -19,7 +19,7 @@ import Log from 'sap/base/Log';
|
|
|
19
19
|
import { getDocumentation } from './documentation';
|
|
20
20
|
import OverlayRegistry from 'sap/ui/dt/OverlayRegistry';
|
|
21
21
|
import OverlayUtil from 'sap/ui/dt/OverlayUtil';
|
|
22
|
-
import { getComponent } from '
|
|
22
|
+
import { getComponent } from '../utils/core';
|
|
23
23
|
import { getError } from '../utils/error';
|
|
24
24
|
|
|
25
25
|
export interface PropertyChangeParams {
|
package/dist/client/cpe/types.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ExternalAction } from '@sap-ux-private/control-property-editor-common';
|
|
1
|
+
import type { ExternalAction, OutlineNode } from '@sap-ux-private/control-property-editor-common';
|
|
2
2
|
import type RuntimeAuthoring from 'sap/ui/rta/RuntimeAuthoring';
|
|
3
3
|
|
|
4
4
|
export interface UI5AdaptationOptions {
|
|
@@ -10,7 +10,7 @@ export type PropertyValue = boolean | object | number | string;
|
|
|
10
10
|
|
|
11
11
|
export interface UI5ControlProperty {
|
|
12
12
|
defaultValue: unknown;
|
|
13
|
-
enumValues:
|
|
13
|
+
enumValues: Record<string,string> | undefined;
|
|
14
14
|
isArray: boolean;
|
|
15
15
|
isDeprecated: boolean;
|
|
16
16
|
isEnabled: boolean;
|
|
@@ -35,8 +35,12 @@ export interface UI5ControlData {
|
|
|
35
35
|
export type ActionHandler = (action: ExternalAction) => Promise<void>;
|
|
36
36
|
export type ActionSenderFunction = (action: ExternalAction) => void;
|
|
37
37
|
export type SubscribeFunction = (handler: ActionHandler) => void;
|
|
38
|
+
export type UnSubscribeFunction = (handler: ActionHandler) => void;
|
|
38
39
|
|
|
39
40
|
export interface Service {
|
|
40
|
-
init(sendAction: ActionSenderFunction, subscribe: SubscribeFunction): void
|
|
41
|
+
init(sendAction: ActionSenderFunction, subscribe: SubscribeFunction): void | Promise<void>;
|
|
41
42
|
}
|
|
42
43
|
|
|
44
|
+
export interface ControlTreeIndex {
|
|
45
|
+
[controlType: string]: OutlineNode[]
|
|
46
|
+
}
|
|
@@ -1,23 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
sap.ui.define(["sap/ui/core/
|
|
3
|
+
sap.ui.define(["sap/ui/core/IconPool"], function (IconPool) {
|
|
4
4
|
"use strict";
|
|
5
5
|
|
|
6
|
-
/**
|
|
7
|
-
* Gets Component by id.
|
|
8
|
-
*
|
|
9
|
-
* @param id - unique identifier for control
|
|
10
|
-
* @returns Component | undefined
|
|
11
|
-
*/
|
|
12
|
-
function getComponent(id) {
|
|
13
|
-
if (Component?.get) {
|
|
14
|
-
return Component.get(id);
|
|
15
|
-
} else {
|
|
16
|
-
// Older version must be still supported until maintenance period.
|
|
17
|
-
return sap.ui.getCore().getComponent(id); // NOSONAR
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
6
|
/**
|
|
22
7
|
* Get ui5 icons.
|
|
23
8
|
*
|
|
@@ -44,7 +29,6 @@ sap.ui.define(["sap/ui/core/Component", "sap/ui/core/IconPool"], function (Compo
|
|
|
44
29
|
var __exports = {
|
|
45
30
|
__esModule: true
|
|
46
31
|
};
|
|
47
|
-
__exports.getComponent = getComponent;
|
|
48
32
|
__exports.getIcons = getIcons;
|
|
49
33
|
return __exports;
|
|
50
34
|
});
|
|
@@ -1,23 +1,6 @@
|
|
|
1
1
|
import type { IconDetails } from '@sap-ux-private/control-property-editor-common';
|
|
2
|
-
import Component from 'sap/ui/core/Component';
|
|
3
|
-
import type { ID } from 'sap/ui/core/library';
|
|
4
2
|
import IconPool from 'sap/ui/core/IconPool';
|
|
5
3
|
|
|
6
|
-
/**
|
|
7
|
-
* Gets Component by id.
|
|
8
|
-
*
|
|
9
|
-
* @param id - unique identifier for control
|
|
10
|
-
* @returns Component | undefined
|
|
11
|
-
*/
|
|
12
|
-
export function getComponent<T extends Component>(id: ID): T | undefined {
|
|
13
|
-
if (Component?.get) {
|
|
14
|
-
return Component.get(id) as T;
|
|
15
|
-
} else {
|
|
16
|
-
// Older version must be still supported until maintenance period.
|
|
17
|
-
return sap.ui.getCore().getComponent(id) as T; // NOSONAR
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
4
|
/**
|
|
22
5
|
* Get ui5 icons.
|
|
23
6
|
*
|
package/dist/client/cpe/utils.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
sap.ui.define([], function () {
|
|
3
|
+
sap.ui.define(["sap/ui/core/ComponentContainer", "sap/ui/core/mvc/XMLView", "sap/ui/core/UIComponent", "../utils/core", "../utils/version"], function (ComponentContainer, XMLView, UIComponent, ___utils_core, ___utils_version) {
|
|
4
4
|
"use strict";
|
|
5
5
|
|
|
6
|
+
const getComponent = ___utils_core["getComponent"];
|
|
7
|
+
const isLowerThanMinimalUi5Version = ___utils_version["isLowerThanMinimalUi5Version"];
|
|
6
8
|
/**
|
|
7
9
|
* Get runtime control.
|
|
8
10
|
*
|
|
@@ -40,11 +42,58 @@ sap.ui.define([], function () {
|
|
|
40
42
|
});
|
|
41
43
|
});
|
|
42
44
|
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Function that checks if control is reuse component
|
|
48
|
+
*
|
|
49
|
+
* @param controlId id control
|
|
50
|
+
* @param ui5VersionInfo UI5 version information
|
|
51
|
+
* @returns boolean if control is from reused component view
|
|
52
|
+
*/
|
|
53
|
+
function isReuseComponent(controlId, ui5VersionInfo) {
|
|
54
|
+
if (isLowerThanMinimalUi5Version(ui5VersionInfo, {
|
|
55
|
+
major: 1,
|
|
56
|
+
minor: 115
|
|
57
|
+
})) {
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
const component = getComponent(controlId);
|
|
61
|
+
if (!component) {
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
64
|
+
const manifest = component.getManifest();
|
|
65
|
+
if (!manifest) {
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
return manifest['sap.app']?.type === 'component';
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Gets the root view of component for the provided ComponentContainer control.
|
|
73
|
+
*
|
|
74
|
+
* @param container ComponentContainer control.
|
|
75
|
+
* @returns XMLView which is the root control of the component if it exists.
|
|
76
|
+
*/
|
|
77
|
+
function getRootControlFromComponentContainer(container) {
|
|
78
|
+
if (container instanceof ComponentContainer) {
|
|
79
|
+
const componentId = container.getComponent();
|
|
80
|
+
const component = getComponent(componentId);
|
|
81
|
+
if (component instanceof UIComponent) {
|
|
82
|
+
const rootControl = component.getRootControl();
|
|
83
|
+
if (rootControl instanceof XMLView) {
|
|
84
|
+
return rootControl;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
return undefined;
|
|
89
|
+
}
|
|
43
90
|
var __exports = {
|
|
44
91
|
__esModule: true
|
|
45
92
|
};
|
|
46
93
|
__exports.getRuntimeControl = getRuntimeControl;
|
|
47
94
|
__exports.getLibrary = getLibrary;
|
|
95
|
+
__exports.isReuseComponent = isReuseComponent;
|
|
96
|
+
__exports.getRootControlFromComponentContainer = getRootControlFromComponentContainer;
|
|
48
97
|
return __exports;
|
|
49
98
|
});
|
|
50
99
|
//# sourceMappingURL=utils.js.map
|
package/dist/client/cpe/utils.ts
CHANGED
|
@@ -2,6 +2,14 @@ import type ManagedObject from 'sap/ui/base/ManagedObject';
|
|
|
2
2
|
import type Control from 'sap/ui/core/Control';
|
|
3
3
|
import type ElementOverlay from 'sap/ui/dt/ElementOverlay';
|
|
4
4
|
import DataType from 'sap/ui/base/DataType';
|
|
5
|
+
import type { Manifest } from 'sap/ui/rta/RuntimeAuthoring';
|
|
6
|
+
import ComponentContainer from 'sap/ui/core/ComponentContainer';
|
|
7
|
+
import XMLView from 'sap/ui/core/mvc/XMLView';
|
|
8
|
+
import UIComponent from 'sap/ui/core/UIComponent';
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
import { getComponent } from '../utils/core';
|
|
12
|
+
import { isLowerThanMinimalUi5Version, Ui5VersionInfo } from '../utils/version';
|
|
5
13
|
|
|
6
14
|
export interface PropertiesInfo {
|
|
7
15
|
defaultValue: string;
|
|
@@ -14,6 +22,7 @@ export interface Properties {
|
|
|
14
22
|
[key: string]: PropertiesInfo;
|
|
15
23
|
}
|
|
16
24
|
|
|
25
|
+
|
|
17
26
|
export interface ManagedObjectMetadataProperties {
|
|
18
27
|
name: string;
|
|
19
28
|
defaultValue: string | null;
|
|
@@ -60,3 +69,48 @@ export async function getLibrary(controlName: string): Promise<string> {
|
|
|
60
69
|
});
|
|
61
70
|
});
|
|
62
71
|
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Function that checks if control is reuse component
|
|
75
|
+
*
|
|
76
|
+
* @param controlId id control
|
|
77
|
+
* @param ui5VersionInfo UI5 version information
|
|
78
|
+
* @returns boolean if control is from reused component view
|
|
79
|
+
*/
|
|
80
|
+
export function isReuseComponent(controlId: string, ui5VersionInfo: Ui5VersionInfo): boolean {
|
|
81
|
+
if (isLowerThanMinimalUi5Version(ui5VersionInfo, { major: 1, minor: 115 })) {
|
|
82
|
+
return false;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const component = getComponent(controlId);
|
|
86
|
+
if (!component) {
|
|
87
|
+
return false;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const manifest = component.getManifest() as Manifest;
|
|
91
|
+
if (!manifest) {
|
|
92
|
+
return false;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
return manifest['sap.app']?.type === 'component';
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Gets the root view of component for the provided ComponentContainer control.
|
|
100
|
+
*
|
|
101
|
+
* @param container ComponentContainer control.
|
|
102
|
+
* @returns XMLView which is the root control of the component if it exists.
|
|
103
|
+
*/
|
|
104
|
+
export function getRootControlFromComponentContainer(container: Control): XMLView | undefined {
|
|
105
|
+
if (container instanceof ComponentContainer) {
|
|
106
|
+
const componentId = container.getComponent();
|
|
107
|
+
const component = getComponent(componentId);
|
|
108
|
+
if (component instanceof UIComponent) {
|
|
109
|
+
const rootControl = component.getRootControl();
|
|
110
|
+
if (rootControl instanceof XMLView) {
|
|
111
|
+
return rootControl;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
return undefined;
|
|
116
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
sap.ui.define(["sap/base/i18n/ResourceBundle"], function (ResourceBundle) {
|
|
4
|
+
"use strict";
|
|
5
|
+
|
|
6
|
+
const BUNDLE_CACHE = {};
|
|
7
|
+
async function getResourceBundle(key) {
|
|
8
|
+
const cachedBundle = BUNDLE_CACHE[key];
|
|
9
|
+
if (cachedBundle) {
|
|
10
|
+
return cachedBundle;
|
|
11
|
+
}
|
|
12
|
+
const bundle = await ResourceBundle.create({
|
|
13
|
+
bundleUrl: '/preview/client/messagebundle.properties',
|
|
14
|
+
url: '/preview/client/messagebundle.properties',
|
|
15
|
+
supportedLocales: [''],
|
|
16
|
+
locale: '',
|
|
17
|
+
async: true
|
|
18
|
+
});
|
|
19
|
+
BUNDLE_CACHE[key] = bundle;
|
|
20
|
+
return bundle;
|
|
21
|
+
}
|
|
22
|
+
class TextBundle {
|
|
23
|
+
constructor(bundle) {
|
|
24
|
+
this.bundle = bundle;
|
|
25
|
+
}
|
|
26
|
+
getText(key, args) {
|
|
27
|
+
return this.bundle.getText(key, args) ?? key;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
async function getTextBundle() {
|
|
31
|
+
let key = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'open.ux.preview.client';
|
|
32
|
+
const bundle = await getResourceBundle(key);
|
|
33
|
+
return new TextBundle(bundle);
|
|
34
|
+
}
|
|
35
|
+
var __exports = {
|
|
36
|
+
__esModule: true
|
|
37
|
+
};
|
|
38
|
+
__exports.getResourceBundle = getResourceBundle;
|
|
39
|
+
__exports.TextBundle = TextBundle;
|
|
40
|
+
__exports.getTextBundle = getTextBundle;
|
|
41
|
+
return __exports;
|
|
42
|
+
});
|
|
43
|
+
//# sourceMappingURL=i18n.js.map
|