@sap-ux/preview-middleware 0.19.31 → 0.19.32
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/add-fragment.js +46 -46
- package/dist/client/adp/api-handler.js +155 -155
- package/dist/client/adp/command-executor.js +75 -75
- package/dist/client/adp/control-utils.js +44 -44
- package/dist/client/adp/controllers/ControllerExtension.controller.js +210 -210
- package/dist/client/adp/controllers/ExtensionPoint.controller.js +139 -139
- package/dist/client/adp/controllers/FileExistsDialog.controller.js +66 -66
- package/dist/client/adp/dialog-factory.js +135 -135
- package/dist/client/adp/init-dialogs.js +163 -163
- package/dist/client/adp/quick-actions/add-new-subpage-quick-action-base.js +96 -96
- package/dist/client/adp/quick-actions/common/add-controller-to-page.js +60 -60
- package/dist/client/adp/quick-actions/common/create-page-action.js +54 -54
- package/dist/client/adp/quick-actions/common/op-add-custom-section.js +39 -39
- package/dist/client/adp/quick-actions/common/op-add-header-field.js +67 -67
- package/dist/client/adp/quick-actions/common/utils.js +18 -18
- package/dist/client/adp/quick-actions/control-types.js +23 -23
- package/dist/client/adp/quick-actions/dialog-enablement-validator.js +24 -24
- package/dist/client/adp/quick-actions/enablement-validator.js +4 -4
- package/dist/client/adp/quick-actions/fe-v2/add-new-subpage.js +81 -81
- package/dist/client/adp/quick-actions/fe-v2/change-table-actions.js +67 -67
- package/dist/client/adp/quick-actions/fe-v2/change-table-columns.js +101 -101
- package/dist/client/adp/quick-actions/fe-v2/create-table-action.js +107 -107
- package/dist/client/adp/quick-actions/fe-v2/create-table-custom-column.js +99 -99
- package/dist/client/adp/quick-actions/fe-v2/lr-enable-semantic-date-range-filter-bar.js +78 -78
- package/dist/client/adp/quick-actions/fe-v2/lr-enable-table-filtering.js +77 -77
- package/dist/client/adp/quick-actions/fe-v2/lr-enable-variant-management.js +69 -69
- package/dist/client/adp/quick-actions/fe-v2/lr-toggle-clear-filter-bar.js +59 -59
- package/dist/client/adp/quick-actions/fe-v2/op-enable-empty-row-mode.js +93 -93
- package/dist/client/adp/quick-actions/fe-v2/op-enable-variant-management.js +84 -84
- package/dist/client/adp/quick-actions/fe-v2/registry.js +77 -77
- package/dist/client/adp/quick-actions/fe-v2/utils.js +116 -116
- package/dist/client/adp/quick-actions/fe-v4/add-new-subpage.js +138 -138
- package/dist/client/adp/quick-actions/fe-v4/change-table-actions.js +79 -79
- package/dist/client/adp/quick-actions/fe-v4/change-table-columns.js +75 -75
- package/dist/client/adp/quick-actions/fe-v4/create-table-action.js +53 -53
- package/dist/client/adp/quick-actions/fe-v4/create-table-custom-column.js +49 -49
- package/dist/client/adp/quick-actions/fe-v4/enable-variant-management.js +81 -81
- package/dist/client/adp/quick-actions/fe-v4/lr-enable-semantic-date-range-filter-bar.js +56 -56
- package/dist/client/adp/quick-actions/fe-v4/lr-enable-table-filtering.js +84 -84
- package/dist/client/adp/quick-actions/fe-v4/lr-toggle-clear-filter-bar.js +53 -53
- package/dist/client/adp/quick-actions/fe-v4/op-enable-empty-row-mode.js +89 -89
- package/dist/client/adp/quick-actions/fe-v4/registry.js +60 -60
- package/dist/client/adp/quick-actions/fe-v4/utils.js +72 -72
- package/dist/client/adp/quick-actions/load.js +44 -44
- package/dist/client/adp/quick-actions/quick-action-base.js +64 -64
- package/dist/client/adp/utils.js +218 -218
- package/dist/client/cpe/additional-change-info/add-xml-additional-info.js +75 -75
- package/dist/client/cpe/changes/index.js +10 -10
- package/dist/client/cpe/changes/validator.js +39 -39
- package/dist/client/cpe/documentation.js +164 -164
- package/dist/client/cpe/feature-service.js +36 -36
- package/dist/client/cpe/logger.js +30 -30
- package/dist/client/cpe/outline/editable.js +37 -37
- package/dist/client/cpe/outline/nodes.js +203 -203
- package/dist/client/cpe/quick-actions/quick-action-definition.js +4 -4
- package/dist/client/cpe/quick-actions/registry.js +143 -143
- package/dist/client/cpe/quick-actions/utils.js +92 -92
- package/dist/client/cpe/types.js +4 -4
- package/dist/client/cpe/ui5-utils.js +33 -33
- package/dist/client/cpe/utils.js +111 -111
- package/dist/client/flp/WorkspaceConnector.js +92 -92
- package/dist/client/flp/common.js +28 -28
- package/dist/client/flp/enableFakeConnector.js +89 -89
- package/dist/client/flp/homepage/Component.js +14 -14
- package/dist/client/flp/initCdm.js +117 -117
- package/dist/client/flp/initConnectors.js +28 -28
- package/dist/client/flp/initRta.js +178 -178
- package/dist/client/i18n.js +56 -56
- package/dist/client/utils/additional-change-info.js +41 -41
- package/dist/client/utils/application.js +32 -32
- package/dist/client/utils/core.js +84 -84
- package/dist/client/utils/error.js +19 -19
- package/dist/client/utils/fe-v2.js +56 -56
- package/dist/client/utils/fe-v4.js +140 -140
- package/dist/client/utils/version.js +104 -104
- package/package.json +6 -6
|
@@ -1,66 +1,66 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
sap.ui.define(["./dialog-enablement-validator"], function (___dialog_enablement_validator) {
|
|
4
|
-
"use strict";
|
|
5
|
-
|
|
6
|
-
const DIALOG_ENABLEMENT_VALIDATOR = ___dialog_enablement_validator["DIALOG_ENABLEMENT_VALIDATOR"];
|
|
7
|
-
/**
|
|
8
|
-
* Base class for all quick actions.
|
|
9
|
-
*/
|
|
10
|
-
class QuickActionDefinitionBase {
|
|
11
|
-
get id() {
|
|
12
|
-
return `${this.context.key}-${this.type}`;
|
|
13
|
-
}
|
|
14
|
-
getTelemetryIdentifier() {
|
|
15
|
-
let update = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
16
|
-
if (update === true) {
|
|
17
|
-
this.telemetryIdentifier = new Date().toISOString();
|
|
18
|
-
}
|
|
19
|
-
return this.telemetryIdentifier;
|
|
20
|
-
}
|
|
21
|
-
get quickActionSteps() {
|
|
22
|
-
return this.enablementValidators.find(item => item === DIALOG_ENABLEMENT_VALIDATOR) ? 2 : 1;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Quick Actions tooltip.
|
|
27
|
-
*/
|
|
28
|
-
get tooltip() {
|
|
29
|
-
if (this.validationResult) {
|
|
30
|
-
const validationErrors = this.validationResult.filter(result => result?.type === 'error');
|
|
31
|
-
if (validationErrors.length > 0) {
|
|
32
|
-
const error = validationErrors[0];
|
|
33
|
-
return error.message;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
return undefined;
|
|
37
|
-
}
|
|
38
|
-
get isDisabled() {
|
|
39
|
-
if (this.validationResult === undefined) {
|
|
40
|
-
return false;
|
|
41
|
-
}
|
|
42
|
-
const validationErrors = this.validationResult.filter(result => result?.type === 'error');
|
|
43
|
-
return validationErrors.length > 0;
|
|
44
|
-
}
|
|
45
|
-
get textKey() {
|
|
46
|
-
return this.defaultTextKey;
|
|
47
|
-
}
|
|
48
|
-
constructor(type, kind, defaultTextKey, context) {
|
|
49
|
-
let enablementValidators = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : [];
|
|
50
|
-
this.type = type;
|
|
51
|
-
this.kind = kind;
|
|
52
|
-
this.defaultTextKey = defaultTextKey;
|
|
53
|
-
this.context = context;
|
|
54
|
-
this.enablementValidators = enablementValidators;
|
|
55
|
-
}
|
|
56
|
-
async runEnablementValidators() {
|
|
57
|
-
this.validationResult = await Promise.all(this.enablementValidators.map(async validator => await validator.run()));
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
var __exports = {
|
|
61
|
-
__esModule: true
|
|
62
|
-
};
|
|
63
|
-
__exports.QuickActionDefinitionBase = QuickActionDefinitionBase;
|
|
64
|
-
return __exports;
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
sap.ui.define(["./dialog-enablement-validator"], function (___dialog_enablement_validator) {
|
|
4
|
+
"use strict";
|
|
5
|
+
|
|
6
|
+
const DIALOG_ENABLEMENT_VALIDATOR = ___dialog_enablement_validator["DIALOG_ENABLEMENT_VALIDATOR"];
|
|
7
|
+
/**
|
|
8
|
+
* Base class for all quick actions.
|
|
9
|
+
*/
|
|
10
|
+
class QuickActionDefinitionBase {
|
|
11
|
+
get id() {
|
|
12
|
+
return `${this.context.key}-${this.type}`;
|
|
13
|
+
}
|
|
14
|
+
getTelemetryIdentifier() {
|
|
15
|
+
let update = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
16
|
+
if (update === true) {
|
|
17
|
+
this.telemetryIdentifier = new Date().toISOString();
|
|
18
|
+
}
|
|
19
|
+
return this.telemetryIdentifier;
|
|
20
|
+
}
|
|
21
|
+
get quickActionSteps() {
|
|
22
|
+
return this.enablementValidators.find(item => item === DIALOG_ENABLEMENT_VALIDATOR) ? 2 : 1;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Quick Actions tooltip.
|
|
27
|
+
*/
|
|
28
|
+
get tooltip() {
|
|
29
|
+
if (this.validationResult) {
|
|
30
|
+
const validationErrors = this.validationResult.filter(result => result?.type === 'error');
|
|
31
|
+
if (validationErrors.length > 0) {
|
|
32
|
+
const error = validationErrors[0];
|
|
33
|
+
return error.message;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return undefined;
|
|
37
|
+
}
|
|
38
|
+
get isDisabled() {
|
|
39
|
+
if (this.validationResult === undefined) {
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
const validationErrors = this.validationResult.filter(result => result?.type === 'error');
|
|
43
|
+
return validationErrors.length > 0;
|
|
44
|
+
}
|
|
45
|
+
get textKey() {
|
|
46
|
+
return this.defaultTextKey;
|
|
47
|
+
}
|
|
48
|
+
constructor(type, kind, defaultTextKey, context) {
|
|
49
|
+
let enablementValidators = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : [];
|
|
50
|
+
this.type = type;
|
|
51
|
+
this.kind = kind;
|
|
52
|
+
this.defaultTextKey = defaultTextKey;
|
|
53
|
+
this.context = context;
|
|
54
|
+
this.enablementValidators = enablementValidators;
|
|
55
|
+
}
|
|
56
|
+
async runEnablementValidators() {
|
|
57
|
+
this.validationResult = await Promise.all(this.enablementValidators.map(async validator => await validator.run()));
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
var __exports = {
|
|
61
|
+
__esModule: true
|
|
62
|
+
};
|
|
63
|
+
__exports.QuickActionDefinitionBase = QuickActionDefinitionBase;
|
|
64
|
+
return __exports;
|
|
65
65
|
});
|
|
66
66
|
//# sourceMappingURL=quick-action-base.js.map
|
package/dist/client/adp/utils.js
CHANGED
|
@@ -1,220 +1,220 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
sap.ui.define(["sap/m/MessageToast", "sap/ui/core/Element", "sap/base/Log", "sap/ui/fl/Utils", "../utils/core", "../utils/error", "../utils/version"], function (MessageToast, Element, Log, FlexUtils, ___utils_core, ___utils_error, ___utils_version) {
|
|
4
|
-
"use strict";
|
|
5
|
-
|
|
6
|
-
function __ui5_require_async(path) {
|
|
7
|
-
return new Promise(function (resolve, reject) {
|
|
8
|
-
sap.ui.require([path], function (module) {
|
|
9
|
-
if (!(module && module.__esModule)) {
|
|
10
|
-
module = module === null || !(typeof module === "object" && path.endsWith("/library")) ? {
|
|
11
|
-
default: module
|
|
12
|
-
} : module;
|
|
13
|
-
Object.defineProperty(module, "__esModule", {
|
|
14
|
-
value: true
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
resolve(module);
|
|
18
|
-
}, function (err) {
|
|
19
|
-
reject(err);
|
|
20
|
-
});
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
const getControlById = ___utils_core["getControlById"];
|
|
24
|
-
const getError = ___utils_error["getError"];
|
|
25
|
-
const isLowerThanMinimalUi5Version = ___utils_version["isLowerThanMinimalUi5Version"];
|
|
26
|
-
let reuseComponentChecker;
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Resets the reuse component checker.
|
|
30
|
-
*/
|
|
31
|
-
function resetReuseComponentChecker() {
|
|
32
|
-
reuseComponentChecker = undefined;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Defers the resolution of the promise, stores resolve/reject functions so that they can be accessed at a later stage.
|
|
37
|
-
*
|
|
38
|
-
* @description A Deferred object contains an unresolved promise along with the functions to resolve or reject that promise.
|
|
39
|
-
*
|
|
40
|
-
* @returns {Deferred} Deferred object
|
|
41
|
-
*/
|
|
42
|
-
function createDeferred() {
|
|
43
|
-
let resolve = null;
|
|
44
|
-
let reject = null;
|
|
45
|
-
const promise = new Promise((res, rej) => {
|
|
46
|
-
resolve = res;
|
|
47
|
-
reject = rej;
|
|
48
|
-
});
|
|
49
|
-
if (resolve === null || reject === null) {
|
|
50
|
-
throw new Error('Failed to initialize resolve and reject functions.');
|
|
51
|
-
}
|
|
52
|
-
return {
|
|
53
|
-
promise,
|
|
54
|
-
resolve,
|
|
55
|
-
reject
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* Checks if the fragment name associated with a command matches the specified fragment name.
|
|
61
|
-
*
|
|
62
|
-
* @param {FlexCommand} command - The command object containing the prepared change to be examined.
|
|
63
|
-
* @param {string} fragmentName - The name of the fragment to match against the command's change.
|
|
64
|
-
* @returns {boolean} Returns true if the command's change contains a fragment path that matches
|
|
65
|
-
* the specified fragment name; otherwise, returns false.
|
|
66
|
-
*/
|
|
67
|
-
function matchesFragmentName(command, fragmentName) {
|
|
68
|
-
if (typeof command.getPreparedChange !== 'function') {
|
|
69
|
-
return false;
|
|
70
|
-
}
|
|
71
|
-
const change = command.getPreparedChange().getDefinition();
|
|
72
|
-
return change.content?.fragmentPath?.includes(`${fragmentName}.fragment.xml`) || false;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* Displays a message to the user indicating that an XML fragment will be created upon saving a change.
|
|
77
|
-
*
|
|
78
|
-
* @param {string} message - The message to be shown in the message toast.
|
|
79
|
-
* @param {number} duration - The duration during which message toast will be active.
|
|
80
|
-
*/
|
|
81
|
-
function notifyUser(message) {
|
|
82
|
-
let duration = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 5000;
|
|
83
|
-
MessageToast.show(message, {
|
|
84
|
-
duration
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* Check if element is sync view
|
|
90
|
-
*
|
|
91
|
-
* @param element Design time Element
|
|
92
|
-
* @returns boolean if element is sync view or not
|
|
93
|
-
*/
|
|
94
|
-
function isSyncView(element) {
|
|
95
|
-
return element?.getMetadata()?.getName()?.includes('XMLView') && element?.oAsyncState === undefined;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
* Get Ids for all sync views
|
|
100
|
-
*
|
|
101
|
-
* @param ui5VersionInfo UI5 Version Information
|
|
102
|
-
*
|
|
103
|
-
* @returns array of Ids for application sync views
|
|
104
|
-
*/
|
|
105
|
-
async function getAllSyncViewsIds(ui5VersionInfo) {
|
|
106
|
-
const syncViewIds = [];
|
|
107
|
-
try {
|
|
108
|
-
if (isLowerThanMinimalUi5Version(ui5VersionInfo, {
|
|
109
|
-
major: 1,
|
|
110
|
-
minor: 120
|
|
111
|
-
})) {
|
|
112
|
-
const elements = Element.registry.filter(() => true);
|
|
113
|
-
elements.forEach(ui5Element => {
|
|
114
|
-
if (isSyncView(ui5Element)) {
|
|
115
|
-
syncViewIds.push(ui5Element.getId());
|
|
116
|
-
}
|
|
117
|
-
});
|
|
118
|
-
} else {
|
|
119
|
-
const ElementRegistry = (await __ui5_require_async('sap/ui/core/ElementRegistry')).default;
|
|
120
|
-
const elements = ElementRegistry.all();
|
|
121
|
-
Object.entries(elements).forEach(_ref => {
|
|
122
|
-
let [key, ui5Element] = _ref;
|
|
123
|
-
if (isSyncView(ui5Element)) {
|
|
124
|
-
syncViewIds.push(key);
|
|
125
|
-
}
|
|
126
|
-
});
|
|
127
|
-
}
|
|
128
|
-
} catch (error) {
|
|
129
|
-
Log.error('Could not get application sync views', getError(error));
|
|
130
|
-
}
|
|
131
|
-
return syncViewIds;
|
|
132
|
-
}
|
|
133
|
-
/**
|
|
134
|
-
* Gets controller name and view ID for the given UI5 control.
|
|
135
|
-
*
|
|
136
|
-
* @param control UI5 control.
|
|
137
|
-
* @returns The controller name and view ID.
|
|
138
|
-
*/
|
|
139
|
-
|
|
140
|
-
function getControllerInfoForControl(control) {
|
|
141
|
-
const view = FlexUtils.getViewForControl(control);
|
|
142
|
-
const controllerName = view.getController().getMetadata().getName();
|
|
143
|
-
const viewId = view.getId();
|
|
144
|
-
return {
|
|
145
|
-
controllerName,
|
|
146
|
-
viewId
|
|
147
|
-
};
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
/**
|
|
151
|
-
* Gets controller name and view ID for the given overlay control.
|
|
152
|
-
*
|
|
153
|
-
* @param overlayControl The overlay control.
|
|
154
|
-
* @returns The controller name and view ID.
|
|
155
|
-
*/
|
|
156
|
-
|
|
157
|
-
function getControllerInfo(overlayControl) {
|
|
158
|
-
const control = overlayControl.getElement();
|
|
159
|
-
return getControllerInfoForControl(control);
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
/**
|
|
163
|
-
* Gets the reuse component checker function.
|
|
164
|
-
*
|
|
165
|
-
* @param ui5VersionInfo UI5 version information.
|
|
166
|
-
* @returns The reuse component checker function.
|
|
167
|
-
*/
|
|
168
|
-
async function getReuseComponentChecker(ui5VersionInfo) {
|
|
169
|
-
if (reuseComponentChecker) {
|
|
170
|
-
return reuseComponentChecker;
|
|
171
|
-
}
|
|
172
|
-
let reuseComponentApi;
|
|
173
|
-
if (!isLowerThanMinimalUi5Version(ui5VersionInfo, {
|
|
174
|
-
major: 1,
|
|
175
|
-
minor: 134
|
|
176
|
-
})) {
|
|
177
|
-
reuseComponentApi = (await __ui5_require_async('sap/ui/rta/util/isReuseComponent')).default;
|
|
178
|
-
}
|
|
179
|
-
reuseComponentChecker = function isReuseComponent(controlId) {
|
|
180
|
-
const ui5Control = getControlById(controlId);
|
|
181
|
-
if (!ui5Control) {
|
|
182
|
-
return false;
|
|
183
|
-
}
|
|
184
|
-
const component = FlexUtils.getComponentForControl(ui5Control);
|
|
185
|
-
if (reuseComponentApi) {
|
|
186
|
-
return reuseComponentApi(component);
|
|
187
|
-
}
|
|
188
|
-
if (!component) {
|
|
189
|
-
return false;
|
|
190
|
-
}
|
|
191
|
-
const appComponent = FlexUtils.getAppComponentForControl(component);
|
|
192
|
-
if (!appComponent) {
|
|
193
|
-
return false;
|
|
194
|
-
}
|
|
195
|
-
const manifest = component.getManifest();
|
|
196
|
-
const appManifest = appComponent.getManifest();
|
|
197
|
-
const componentName = manifest?.['sap.app']?.id;
|
|
198
|
-
|
|
199
|
-
// Look for component name in component usages of app component manifest
|
|
200
|
-
const componentUsages = appManifest?.['sap.ui5']?.componentUsages;
|
|
201
|
-
return Object.values(componentUsages || {}).some(componentUsage => {
|
|
202
|
-
return componentUsage.name === componentName;
|
|
203
|
-
});
|
|
204
|
-
};
|
|
205
|
-
return reuseComponentChecker;
|
|
206
|
-
}
|
|
207
|
-
var __exports = {
|
|
208
|
-
__esModule: true
|
|
209
|
-
};
|
|
210
|
-
__exports.resetReuseComponentChecker = resetReuseComponentChecker;
|
|
211
|
-
__exports.createDeferred = createDeferred;
|
|
212
|
-
__exports.matchesFragmentName = matchesFragmentName;
|
|
213
|
-
__exports.notifyUser = notifyUser;
|
|
214
|
-
__exports.getAllSyncViewsIds = getAllSyncViewsIds;
|
|
215
|
-
__exports.getControllerInfoForControl = getControllerInfoForControl;
|
|
216
|
-
__exports.getControllerInfo = getControllerInfo;
|
|
217
|
-
__exports.getReuseComponentChecker = getReuseComponentChecker;
|
|
218
|
-
return __exports;
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
sap.ui.define(["sap/m/MessageToast", "sap/ui/core/Element", "sap/base/Log", "sap/ui/fl/Utils", "../utils/core", "../utils/error", "../utils/version"], function (MessageToast, Element, Log, FlexUtils, ___utils_core, ___utils_error, ___utils_version) {
|
|
4
|
+
"use strict";
|
|
5
|
+
|
|
6
|
+
function __ui5_require_async(path) {
|
|
7
|
+
return new Promise(function (resolve, reject) {
|
|
8
|
+
sap.ui.require([path], function (module) {
|
|
9
|
+
if (!(module && module.__esModule)) {
|
|
10
|
+
module = module === null || !(typeof module === "object" && path.endsWith("/library")) ? {
|
|
11
|
+
default: module
|
|
12
|
+
} : module;
|
|
13
|
+
Object.defineProperty(module, "__esModule", {
|
|
14
|
+
value: true
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
resolve(module);
|
|
18
|
+
}, function (err) {
|
|
19
|
+
reject(err);
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
const getControlById = ___utils_core["getControlById"];
|
|
24
|
+
const getError = ___utils_error["getError"];
|
|
25
|
+
const isLowerThanMinimalUi5Version = ___utils_version["isLowerThanMinimalUi5Version"];
|
|
26
|
+
let reuseComponentChecker;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Resets the reuse component checker.
|
|
30
|
+
*/
|
|
31
|
+
function resetReuseComponentChecker() {
|
|
32
|
+
reuseComponentChecker = undefined;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Defers the resolution of the promise, stores resolve/reject functions so that they can be accessed at a later stage.
|
|
37
|
+
*
|
|
38
|
+
* @description A Deferred object contains an unresolved promise along with the functions to resolve or reject that promise.
|
|
39
|
+
*
|
|
40
|
+
* @returns {Deferred} Deferred object
|
|
41
|
+
*/
|
|
42
|
+
function createDeferred() {
|
|
43
|
+
let resolve = null;
|
|
44
|
+
let reject = null;
|
|
45
|
+
const promise = new Promise((res, rej) => {
|
|
46
|
+
resolve = res;
|
|
47
|
+
reject = rej;
|
|
48
|
+
});
|
|
49
|
+
if (resolve === null || reject === null) {
|
|
50
|
+
throw new Error('Failed to initialize resolve and reject functions.');
|
|
51
|
+
}
|
|
52
|
+
return {
|
|
53
|
+
promise,
|
|
54
|
+
resolve,
|
|
55
|
+
reject
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Checks if the fragment name associated with a command matches the specified fragment name.
|
|
61
|
+
*
|
|
62
|
+
* @param {FlexCommand} command - The command object containing the prepared change to be examined.
|
|
63
|
+
* @param {string} fragmentName - The name of the fragment to match against the command's change.
|
|
64
|
+
* @returns {boolean} Returns true if the command's change contains a fragment path that matches
|
|
65
|
+
* the specified fragment name; otherwise, returns false.
|
|
66
|
+
*/
|
|
67
|
+
function matchesFragmentName(command, fragmentName) {
|
|
68
|
+
if (typeof command.getPreparedChange !== 'function') {
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
const change = command.getPreparedChange().getDefinition();
|
|
72
|
+
return change.content?.fragmentPath?.includes(`${fragmentName}.fragment.xml`) || false;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Displays a message to the user indicating that an XML fragment will be created upon saving a change.
|
|
77
|
+
*
|
|
78
|
+
* @param {string} message - The message to be shown in the message toast.
|
|
79
|
+
* @param {number} duration - The duration during which message toast will be active.
|
|
80
|
+
*/
|
|
81
|
+
function notifyUser(message) {
|
|
82
|
+
let duration = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 5000;
|
|
83
|
+
MessageToast.show(message, {
|
|
84
|
+
duration
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Check if element is sync view
|
|
90
|
+
*
|
|
91
|
+
* @param element Design time Element
|
|
92
|
+
* @returns boolean if element is sync view or not
|
|
93
|
+
*/
|
|
94
|
+
function isSyncView(element) {
|
|
95
|
+
return element?.getMetadata()?.getName()?.includes('XMLView') && element?.oAsyncState === undefined;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Get Ids for all sync views
|
|
100
|
+
*
|
|
101
|
+
* @param ui5VersionInfo UI5 Version Information
|
|
102
|
+
*
|
|
103
|
+
* @returns array of Ids for application sync views
|
|
104
|
+
*/
|
|
105
|
+
async function getAllSyncViewsIds(ui5VersionInfo) {
|
|
106
|
+
const syncViewIds = [];
|
|
107
|
+
try {
|
|
108
|
+
if (isLowerThanMinimalUi5Version(ui5VersionInfo, {
|
|
109
|
+
major: 1,
|
|
110
|
+
minor: 120
|
|
111
|
+
})) {
|
|
112
|
+
const elements = Element.registry.filter(() => true);
|
|
113
|
+
elements.forEach(ui5Element => {
|
|
114
|
+
if (isSyncView(ui5Element)) {
|
|
115
|
+
syncViewIds.push(ui5Element.getId());
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
} else {
|
|
119
|
+
const ElementRegistry = (await __ui5_require_async('sap/ui/core/ElementRegistry')).default;
|
|
120
|
+
const elements = ElementRegistry.all();
|
|
121
|
+
Object.entries(elements).forEach(_ref => {
|
|
122
|
+
let [key, ui5Element] = _ref;
|
|
123
|
+
if (isSyncView(ui5Element)) {
|
|
124
|
+
syncViewIds.push(key);
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
} catch (error) {
|
|
129
|
+
Log.error('Could not get application sync views', getError(error));
|
|
130
|
+
}
|
|
131
|
+
return syncViewIds;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Gets controller name and view ID for the given UI5 control.
|
|
135
|
+
*
|
|
136
|
+
* @param control UI5 control.
|
|
137
|
+
* @returns The controller name and view ID.
|
|
138
|
+
*/
|
|
139
|
+
|
|
140
|
+
function getControllerInfoForControl(control) {
|
|
141
|
+
const view = FlexUtils.getViewForControl(control);
|
|
142
|
+
const controllerName = view.getController().getMetadata().getName();
|
|
143
|
+
const viewId = view.getId();
|
|
144
|
+
return {
|
|
145
|
+
controllerName,
|
|
146
|
+
viewId
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Gets controller name and view ID for the given overlay control.
|
|
152
|
+
*
|
|
153
|
+
* @param overlayControl The overlay control.
|
|
154
|
+
* @returns The controller name and view ID.
|
|
155
|
+
*/
|
|
156
|
+
|
|
157
|
+
function getControllerInfo(overlayControl) {
|
|
158
|
+
const control = overlayControl.getElement();
|
|
159
|
+
return getControllerInfoForControl(control);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Gets the reuse component checker function.
|
|
164
|
+
*
|
|
165
|
+
* @param ui5VersionInfo UI5 version information.
|
|
166
|
+
* @returns The reuse component checker function.
|
|
167
|
+
*/
|
|
168
|
+
async function getReuseComponentChecker(ui5VersionInfo) {
|
|
169
|
+
if (reuseComponentChecker) {
|
|
170
|
+
return reuseComponentChecker;
|
|
171
|
+
}
|
|
172
|
+
let reuseComponentApi;
|
|
173
|
+
if (!isLowerThanMinimalUi5Version(ui5VersionInfo, {
|
|
174
|
+
major: 1,
|
|
175
|
+
minor: 134
|
|
176
|
+
})) {
|
|
177
|
+
reuseComponentApi = (await __ui5_require_async('sap/ui/rta/util/isReuseComponent')).default;
|
|
178
|
+
}
|
|
179
|
+
reuseComponentChecker = function isReuseComponent(controlId) {
|
|
180
|
+
const ui5Control = getControlById(controlId);
|
|
181
|
+
if (!ui5Control) {
|
|
182
|
+
return false;
|
|
183
|
+
}
|
|
184
|
+
const component = FlexUtils.getComponentForControl(ui5Control);
|
|
185
|
+
if (reuseComponentApi) {
|
|
186
|
+
return reuseComponentApi(component);
|
|
187
|
+
}
|
|
188
|
+
if (!component) {
|
|
189
|
+
return false;
|
|
190
|
+
}
|
|
191
|
+
const appComponent = FlexUtils.getAppComponentForControl(component);
|
|
192
|
+
if (!appComponent) {
|
|
193
|
+
return false;
|
|
194
|
+
}
|
|
195
|
+
const manifest = component.getManifest();
|
|
196
|
+
const appManifest = appComponent.getManifest();
|
|
197
|
+
const componentName = manifest?.['sap.app']?.id;
|
|
198
|
+
|
|
199
|
+
// Look for component name in component usages of app component manifest
|
|
200
|
+
const componentUsages = appManifest?.['sap.ui5']?.componentUsages;
|
|
201
|
+
return Object.values(componentUsages || {}).some(componentUsage => {
|
|
202
|
+
return componentUsage.name === componentName;
|
|
203
|
+
});
|
|
204
|
+
};
|
|
205
|
+
return reuseComponentChecker;
|
|
206
|
+
}
|
|
207
|
+
var __exports = {
|
|
208
|
+
__esModule: true
|
|
209
|
+
};
|
|
210
|
+
__exports.resetReuseComponentChecker = resetReuseComponentChecker;
|
|
211
|
+
__exports.createDeferred = createDeferred;
|
|
212
|
+
__exports.matchesFragmentName = matchesFragmentName;
|
|
213
|
+
__exports.notifyUser = notifyUser;
|
|
214
|
+
__exports.getAllSyncViewsIds = getAllSyncViewsIds;
|
|
215
|
+
__exports.getControllerInfoForControl = getControllerInfoForControl;
|
|
216
|
+
__exports.getControllerInfo = getControllerInfo;
|
|
217
|
+
__exports.getReuseComponentChecker = getReuseComponentChecker;
|
|
218
|
+
return __exports;
|
|
219
219
|
});
|
|
220
220
|
//# sourceMappingURL=utils.js.map
|