@sap-ux/preview-middleware 0.19.42 → 0.20.0
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 +159 -159
- 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/generic-change.js +326 -326
- 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 +54 -54
- 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 +14 -14
- package/dist/client/tsconfig.tsbuildinfo +0 -1
|
@@ -1,328 +1,328 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
sap.ui.define(["../../utils/version", "sap/ui/core/util/reflection/JsControlTreeModifier", "sap/base/Log", "../../utils/error", "../../utils/fe-v4"], function (____utils_version, JsControlTreeModifier, Log, ____utils_error, ____utils_fe_v4) {
|
|
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 getUi5Version = ____utils_version["getUi5Version"];
|
|
24
|
-
const isLowerThanMinimalUi5Version = ____utils_version["isLowerThanMinimalUi5Version"];
|
|
25
|
-
const getError = ____utils_error["getError"];
|
|
26
|
-
const getConfigMapControlIdMap = ____utils_fe_v4["getConfigMapControlIdMap"];
|
|
27
|
-
const ADD_NEW_ANNOTATION_FILE_CHANGE = 'appdescr_app_addAnnotationsToOData';
|
|
28
|
-
const RENAME_CHANGE = 'rename';
|
|
29
|
-
const MOVE_CHANGE = 'moveControls';
|
|
30
|
-
const ADD_XML_CHANGE = 'addXML';
|
|
31
|
-
const PROPERTY_CHANGE = 'propertyChange';
|
|
32
|
-
const PROPERTY_BINDING_CHANGE = 'propertyBindingChange';
|
|
33
|
-
const MANIFEST_V4_CHANGE = 'appdescr_fe_changePageConfiguration';
|
|
34
|
-
const MANIFEST_V2_CHANGE = 'appdescr_ui_generic_app_changePageConfiguration';
|
|
35
|
-
/**
|
|
36
|
-
* Returns a shortened version of the given configuration path segments by removing excess segments,
|
|
37
|
-
* leaving only the most relevant parts for display. For example, the configuration path
|
|
38
|
-
* `controlConfiguration/com.sap.UI.v1.LineItem/tableSettings` will be shortened to
|
|
39
|
-
* `LineItem/tableSettings`.
|
|
40
|
-
*
|
|
41
|
-
* @param propertyPathSeg string[]
|
|
42
|
-
* @returns string
|
|
43
|
-
*/
|
|
44
|
-
function getCompactV4ConfigPath(propertyPathSeg) {
|
|
45
|
-
return propertyPathSeg.join('/').replace(/^controlConfiguration\/(?:([^/]+\/))?@[^/]+\.v1\./, '$1');
|
|
46
|
-
}
|
|
47
|
-
function assertProperties(properties, target) {
|
|
48
|
-
for (const property of properties) {
|
|
49
|
-
const value = target[property];
|
|
50
|
-
if (value === null || value === undefined) {
|
|
51
|
-
throw new Error(`Invalid change, missing ${property} in the change file`);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* Assert change for its validity. Throws error if no value found in saved changes.
|
|
57
|
-
*
|
|
58
|
-
* @param change Change object
|
|
59
|
-
*/
|
|
60
|
-
function assertChange(change) {
|
|
61
|
-
assertProperties(['fileName', 'selector', 'content'], change);
|
|
62
|
-
assertProperties(['id'], change.selector);
|
|
63
|
-
assertProperties(['property'], change.content);
|
|
64
|
-
}
|
|
65
|
-
function assertManifestChange(change) {
|
|
66
|
-
assertProperties(['fileName', 'content'], change);
|
|
67
|
-
assertProperties(['page', 'entityPropertyChange'], change.content);
|
|
68
|
-
assertProperties(['propertyPath', 'operation', 'propertyValue'], change.content.entityPropertyChange);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* Get FlexObject from change object based on UI5 version.
|
|
73
|
-
*
|
|
74
|
-
* @param change change object
|
|
75
|
-
* @returns FlexChange
|
|
76
|
-
*/
|
|
77
|
-
async function getFlexObject(change) {
|
|
78
|
-
if (isLowerThanMinimalUi5Version(await getUi5Version(), {
|
|
79
|
-
major: 1,
|
|
80
|
-
minor: 109
|
|
81
|
-
})) {
|
|
82
|
-
const Change = (await __ui5_require_async('sap/ui/fl/Change')).default;
|
|
83
|
-
return new Change(change);
|
|
84
|
-
}
|
|
85
|
-
const FlexObjectFactory = (await __ui5_require_async('sap/ui/fl/apply/_internal/flexObjects/FlexObjectFactory')).default;
|
|
86
|
-
return FlexObjectFactory.createFromFileContent(change);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* Get element id by change.
|
|
91
|
-
*
|
|
92
|
-
* @param change to be executed for creating change
|
|
93
|
-
* @param appComponent app component
|
|
94
|
-
* @returns element id or empty string
|
|
95
|
-
*/
|
|
96
|
-
async function getControlIdByChange(change, appComponent) {
|
|
97
|
-
const selector = typeof change.getSelector === 'function' ? change.getSelector() : undefined;
|
|
98
|
-
const changeType = change.getChangeType();
|
|
99
|
-
const layer = change.getLayer();
|
|
100
|
-
if (!selector?.id) {
|
|
101
|
-
return;
|
|
102
|
-
}
|
|
103
|
-
try {
|
|
104
|
-
let control = JsControlTreeModifier.bySelector(selector, appComponent);
|
|
105
|
-
if (!control) {
|
|
106
|
-
return selector.id;
|
|
107
|
-
}
|
|
108
|
-
const changeHandlerAPI = (await __ui5_require_async('sap/ui/fl/write/api/ChangesWriteAPI')).default;
|
|
109
|
-
if (typeof changeHandlerAPI?.getChangeHandler !== 'function') {
|
|
110
|
-
return selector.id;
|
|
111
|
-
}
|
|
112
|
-
const changeHandler = await changeHandlerAPI.getChangeHandler({
|
|
113
|
-
changeType,
|
|
114
|
-
element: control,
|
|
115
|
-
modifier: JsControlTreeModifier,
|
|
116
|
-
layer
|
|
117
|
-
});
|
|
118
|
-
if (changeHandler && typeof changeHandler.getChangeVisualizationInfo === 'function') {
|
|
119
|
-
const result = await changeHandler.getChangeVisualizationInfo(change, appComponent);
|
|
120
|
-
return JsControlTreeModifier.getControlIdBySelector(result?.affectedControls?.[0] ?? selector, appComponent);
|
|
121
|
-
}
|
|
122
|
-
return JsControlTreeModifier.getControlIdBySelector(selector, appComponent);
|
|
123
|
-
} catch (error) {
|
|
124
|
-
Log.error('Getting element ID from change has failed:', getError(error));
|
|
125
|
-
return selector.id;
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
async function getPropertyChange(change, _ref) {
|
|
129
|
-
let {
|
|
130
|
-
appComponent
|
|
131
|
-
} = _ref;
|
|
132
|
-
const propertyChange = change;
|
|
133
|
-
const flexObject = await getFlexObject(change);
|
|
134
|
-
const selectorId = await getControlIdByChange(flexObject, appComponent);
|
|
135
|
-
const changeTitle = change.selector.type ? change.selector.type.split('.').pop() : '';
|
|
136
|
-
assertChange(propertyChange);
|
|
137
|
-
if ([propertyChange.content.newValue, propertyChange.content.newBinding].every(item => item === undefined || item === null)) {
|
|
138
|
-
throw new Error('Invalid change, missing new value in the change file');
|
|
139
|
-
}
|
|
140
|
-
if (change.changeType !== PROPERTY_CHANGE && change.changeType !== PROPERTY_BINDING_CHANGE) {
|
|
141
|
-
throw new Error('Unknown Change Type');
|
|
142
|
-
}
|
|
143
|
-
return {
|
|
144
|
-
changeTitle: changeTitle,
|
|
145
|
-
controlId: selectorId,
|
|
146
|
-
changeType: 'property',
|
|
147
|
-
properties: [{
|
|
148
|
-
label: propertyChange.content.property,
|
|
149
|
-
value: propertyChange.content.newValue ?? propertyChange.content.newBinding,
|
|
150
|
-
displayValueWithIcon: true
|
|
151
|
-
}]
|
|
152
|
-
};
|
|
153
|
-
}
|
|
154
|
-
function getV2ConfigurationChange(change, _ref2) {
|
|
155
|
-
let {
|
|
156
|
-
textBundle
|
|
157
|
-
} = _ref2;
|
|
158
|
-
const {
|
|
159
|
-
entityPropertyChange,
|
|
160
|
-
parentPage
|
|
161
|
-
} = change.content;
|
|
162
|
-
const propertyPathSegments = entityPropertyChange.propertyPath.split('/');
|
|
163
|
-
const propertyName = Object.keys(entityPropertyChange.propertyValue)?.[0] ?? propertyPathSegments[propertyPathSegments.length - 1];
|
|
164
|
-
const propertyValue = entityPropertyChange.propertyValue?.[propertyName] ?? entityPropertyChange.propertyValue;
|
|
165
|
-
return {
|
|
166
|
-
changeTitle: textBundle?.getText('CONFIGURATION_CHANGE'),
|
|
167
|
-
controlId: [],
|
|
168
|
-
changeType: 'configuration',
|
|
169
|
-
subtitle: entityPropertyChange.propertyPath ?? parentPage.component,
|
|
170
|
-
properties: [{
|
|
171
|
-
label: propertyName ?? '',
|
|
172
|
-
value: propertyValue,
|
|
173
|
-
displayValueWithIcon: true
|
|
174
|
-
}]
|
|
175
|
-
};
|
|
176
|
-
}
|
|
177
|
-
function getV4ConfigurationChange(change, _ref3) {
|
|
178
|
-
let {
|
|
179
|
-
configPropertyControlIdMap,
|
|
180
|
-
textBundle
|
|
181
|
-
} = _ref3;
|
|
182
|
-
assertManifestChange(change);
|
|
183
|
-
if ([change.content.entityPropertyChange.propertyValue].every(item => item === undefined || item === null)) {
|
|
184
|
-
throw new Error('Invalid change, missing property value on change file');
|
|
185
|
-
}
|
|
186
|
-
const propertyPathSegments = change.content.entityPropertyChange.propertyPath.split('/');
|
|
187
|
-
const propertyName = propertyPathSegments.pop();
|
|
188
|
-
if (!propertyName) {
|
|
189
|
-
throw new Error('No property name found');
|
|
190
|
-
}
|
|
191
|
-
const configMapKey = getConfigMapControlIdMap(change.content.page, propertyPathSegments);
|
|
192
|
-
const controlIds = configPropertyControlIdMap?.get(configMapKey) || [];
|
|
193
|
-
let value = change.content.entityPropertyChange.propertyValue;
|
|
194
|
-
const properties = typeof value === 'object' ? [{
|
|
195
|
-
label: propertyName,
|
|
196
|
-
displayValueWithIcon: true
|
|
197
|
-
}, ...Object.keys(value).map(key => {
|
|
198
|
-
if (typeof value[key] === 'object') {
|
|
199
|
-
return undefined;
|
|
200
|
-
}
|
|
201
|
-
return {
|
|
202
|
-
label: key,
|
|
203
|
-
value: value[key],
|
|
204
|
-
displayValueWithIcon: true
|
|
205
|
-
};
|
|
206
|
-
}).filter(item => !!item)] : [{
|
|
207
|
-
label: propertyName,
|
|
208
|
-
value,
|
|
209
|
-
displayValueWithIcon: true
|
|
210
|
-
}];
|
|
211
|
-
return {
|
|
212
|
-
changeTitle: textBundle?.getText('CONFIGURATION_CHANGE'),
|
|
213
|
-
controlId: controlIds,
|
|
214
|
-
changeType: 'configuration',
|
|
215
|
-
subtitle: getCompactV4ConfigPath(propertyPathSegments),
|
|
216
|
-
properties
|
|
217
|
-
};
|
|
218
|
-
}
|
|
219
|
-
const GENERIC_CHANGE_HANDLER = {
|
|
220
|
-
[ADD_NEW_ANNOTATION_FILE_CHANGE]: (annotationFileChange, _ref4) => {
|
|
221
|
-
let {
|
|
222
|
-
textBundle
|
|
223
|
-
} = _ref4;
|
|
224
|
-
const dataSourceId = annotationFileChange.content.dataSourceId;
|
|
225
|
-
const sourceKey = Object.keys(annotationFileChange.content.dataSource)[0];
|
|
226
|
-
return {
|
|
227
|
-
changeTitle: textBundle?.getText('ADD_NEW_ANNOTATION_FILE'),
|
|
228
|
-
changeType: 'configuration',
|
|
229
|
-
properties: [{
|
|
230
|
-
label: textBundle?.getText('SERVICE_NAME'),
|
|
231
|
-
value: dataSourceId
|
|
232
|
-
}, {
|
|
233
|
-
label: textBundle?.getText('ANNOTATION_FILE_URI'),
|
|
234
|
-
value: annotationFileChange.content.dataSource[sourceKey].uri
|
|
235
|
-
}]
|
|
236
|
-
};
|
|
237
|
-
},
|
|
238
|
-
[RENAME_CHANGE]: (renameChange, _ref5) => {
|
|
239
|
-
let {
|
|
240
|
-
textBundle
|
|
241
|
-
} = _ref5;
|
|
242
|
-
const selectorId = renameChange.selector.id;
|
|
243
|
-
return {
|
|
244
|
-
changeTitle: textBundle?.getText('RENAME_CHANGE'),
|
|
245
|
-
controlId: selectorId,
|
|
246
|
-
properties: [{
|
|
247
|
-
label: textBundle?.getText('SELECTOR_ID'),
|
|
248
|
-
value: selectorId
|
|
249
|
-
}, {
|
|
250
|
-
label: textBundle?.getText('NEW_VALUE'),
|
|
251
|
-
value: renameChange.texts.newText.value
|
|
252
|
-
}, {
|
|
253
|
-
label: textBundle?.getText('TEXT_TYPE'),
|
|
254
|
-
value: renameChange.texts.newText.type
|
|
255
|
-
}]
|
|
256
|
-
};
|
|
257
|
-
},
|
|
258
|
-
[MOVE_CHANGE]: (moveChange, _ref6) => {
|
|
259
|
-
let {
|
|
260
|
-
textBundle
|
|
261
|
-
} = _ref6;
|
|
262
|
-
const movedControlId = moveChange.content.movedElements[0].selector.id;
|
|
263
|
-
return {
|
|
264
|
-
changeTitle: textBundle?.getText('MOVE_CONTROLS_CHANGE'),
|
|
265
|
-
controlId: movedControlId,
|
|
266
|
-
properties: [{
|
|
267
|
-
label: textBundle?.getText('TARGET_CONTROL_ID'),
|
|
268
|
-
value: moveChange.content.target.selector.id
|
|
269
|
-
}, {
|
|
270
|
-
label: textBundle?.getText('MOVE_FROM_INDEX'),
|
|
271
|
-
value: String(moveChange.content.movedElements[0].sourceIndex)
|
|
272
|
-
}, {
|
|
273
|
-
label: textBundle?.getText('MOVE_TO_INDEX'),
|
|
274
|
-
value: String(moveChange.content.movedElements[0].targetIndex)
|
|
275
|
-
}, {
|
|
276
|
-
label: textBundle?.getText('MOVED_CONTROL_ID'),
|
|
277
|
-
value: movedControlId
|
|
278
|
-
}]
|
|
279
|
-
};
|
|
280
|
-
},
|
|
281
|
-
[ADD_XML_CHANGE]: (addXmlChange, _ref7) => {
|
|
282
|
-
let {
|
|
283
|
-
textBundle
|
|
284
|
-
} = _ref7;
|
|
285
|
-
return {
|
|
286
|
-
changeTitle: textBundle?.getText('ADD_XML_CHANGE'),
|
|
287
|
-
controlId: addXmlChange.selector.id,
|
|
288
|
-
properties: [{
|
|
289
|
-
label: textBundle?.getText('AGGREGATION'),
|
|
290
|
-
value: addXmlChange.content.targetAggregation
|
|
291
|
-
}, {
|
|
292
|
-
label: textBundle?.getText('FRAGMENT_PATH'),
|
|
293
|
-
value: addXmlChange.content.fragmentPath
|
|
294
|
-
}]
|
|
295
|
-
};
|
|
296
|
-
},
|
|
297
|
-
[PROPERTY_CHANGE]: async (change, handlerOptions) => {
|
|
298
|
-
return getPropertyChange(change, handlerOptions);
|
|
299
|
-
},
|
|
300
|
-
[PROPERTY_BINDING_CHANGE]: async (change, handlerOptions) => {
|
|
301
|
-
return getPropertyChange(change, handlerOptions);
|
|
302
|
-
},
|
|
303
|
-
[MANIFEST_V4_CHANGE]: (change, handlerOptions) => {
|
|
304
|
-
return getV4ConfigurationChange(change, handlerOptions);
|
|
305
|
-
},
|
|
306
|
-
[MANIFEST_V2_CHANGE]: (change, handlerOptions) => {
|
|
307
|
-
return getV2ConfigurationChange(change, handlerOptions);
|
|
308
|
-
}
|
|
309
|
-
};
|
|
310
|
-
var __exports = {
|
|
311
|
-
__esModule: true
|
|
312
|
-
};
|
|
313
|
-
__exports.ADD_NEW_ANNOTATION_FILE_CHANGE = ADD_NEW_ANNOTATION_FILE_CHANGE;
|
|
314
|
-
__exports.RENAME_CHANGE = RENAME_CHANGE;
|
|
315
|
-
__exports.MOVE_CHANGE = MOVE_CHANGE;
|
|
316
|
-
__exports.ADD_XML_CHANGE = ADD_XML_CHANGE;
|
|
317
|
-
__exports.PROPERTY_CHANGE = PROPERTY_CHANGE;
|
|
318
|
-
__exports.PROPERTY_BINDING_CHANGE = PROPERTY_BINDING_CHANGE;
|
|
319
|
-
__exports.MANIFEST_V4_CHANGE = MANIFEST_V4_CHANGE;
|
|
320
|
-
__exports.MANIFEST_V2_CHANGE = MANIFEST_V2_CHANGE;
|
|
321
|
-
__exports.assertProperties = assertProperties;
|
|
322
|
-
__exports.assertChange = assertChange;
|
|
323
|
-
__exports.getFlexObject = getFlexObject;
|
|
324
|
-
__exports.getControlIdByChange = getControlIdByChange;
|
|
325
|
-
__exports.GENERIC_CHANGE_HANDLER = GENERIC_CHANGE_HANDLER;
|
|
326
|
-
return __exports;
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
sap.ui.define(["../../utils/version", "sap/ui/core/util/reflection/JsControlTreeModifier", "sap/base/Log", "../../utils/error", "../../utils/fe-v4"], function (____utils_version, JsControlTreeModifier, Log, ____utils_error, ____utils_fe_v4) {
|
|
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 getUi5Version = ____utils_version["getUi5Version"];
|
|
24
|
+
const isLowerThanMinimalUi5Version = ____utils_version["isLowerThanMinimalUi5Version"];
|
|
25
|
+
const getError = ____utils_error["getError"];
|
|
26
|
+
const getConfigMapControlIdMap = ____utils_fe_v4["getConfigMapControlIdMap"];
|
|
27
|
+
const ADD_NEW_ANNOTATION_FILE_CHANGE = 'appdescr_app_addAnnotationsToOData';
|
|
28
|
+
const RENAME_CHANGE = 'rename';
|
|
29
|
+
const MOVE_CHANGE = 'moveControls';
|
|
30
|
+
const ADD_XML_CHANGE = 'addXML';
|
|
31
|
+
const PROPERTY_CHANGE = 'propertyChange';
|
|
32
|
+
const PROPERTY_BINDING_CHANGE = 'propertyBindingChange';
|
|
33
|
+
const MANIFEST_V4_CHANGE = 'appdescr_fe_changePageConfiguration';
|
|
34
|
+
const MANIFEST_V2_CHANGE = 'appdescr_ui_generic_app_changePageConfiguration';
|
|
35
|
+
/**
|
|
36
|
+
* Returns a shortened version of the given configuration path segments by removing excess segments,
|
|
37
|
+
* leaving only the most relevant parts for display. For example, the configuration path
|
|
38
|
+
* `controlConfiguration/com.sap.UI.v1.LineItem/tableSettings` will be shortened to
|
|
39
|
+
* `LineItem/tableSettings`.
|
|
40
|
+
*
|
|
41
|
+
* @param propertyPathSeg string[]
|
|
42
|
+
* @returns string
|
|
43
|
+
*/
|
|
44
|
+
function getCompactV4ConfigPath(propertyPathSeg) {
|
|
45
|
+
return propertyPathSeg.join('/').replace(/^controlConfiguration\/(?:([^/]+\/))?@[^/]+\.v1\./, '$1');
|
|
46
|
+
}
|
|
47
|
+
function assertProperties(properties, target) {
|
|
48
|
+
for (const property of properties) {
|
|
49
|
+
const value = target[property];
|
|
50
|
+
if (value === null || value === undefined) {
|
|
51
|
+
throw new Error(`Invalid change, missing ${property} in the change file`);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Assert change for its validity. Throws error if no value found in saved changes.
|
|
57
|
+
*
|
|
58
|
+
* @param change Change object
|
|
59
|
+
*/
|
|
60
|
+
function assertChange(change) {
|
|
61
|
+
assertProperties(['fileName', 'selector', 'content'], change);
|
|
62
|
+
assertProperties(['id'], change.selector);
|
|
63
|
+
assertProperties(['property'], change.content);
|
|
64
|
+
}
|
|
65
|
+
function assertManifestChange(change) {
|
|
66
|
+
assertProperties(['fileName', 'content'], change);
|
|
67
|
+
assertProperties(['page', 'entityPropertyChange'], change.content);
|
|
68
|
+
assertProperties(['propertyPath', 'operation', 'propertyValue'], change.content.entityPropertyChange);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Get FlexObject from change object based on UI5 version.
|
|
73
|
+
*
|
|
74
|
+
* @param change change object
|
|
75
|
+
* @returns FlexChange
|
|
76
|
+
*/
|
|
77
|
+
async function getFlexObject(change) {
|
|
78
|
+
if (isLowerThanMinimalUi5Version(await getUi5Version(), {
|
|
79
|
+
major: 1,
|
|
80
|
+
minor: 109
|
|
81
|
+
})) {
|
|
82
|
+
const Change = (await __ui5_require_async('sap/ui/fl/Change')).default;
|
|
83
|
+
return new Change(change);
|
|
84
|
+
}
|
|
85
|
+
const FlexObjectFactory = (await __ui5_require_async('sap/ui/fl/apply/_internal/flexObjects/FlexObjectFactory')).default;
|
|
86
|
+
return FlexObjectFactory.createFromFileContent(change);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Get element id by change.
|
|
91
|
+
*
|
|
92
|
+
* @param change to be executed for creating change
|
|
93
|
+
* @param appComponent app component
|
|
94
|
+
* @returns element id or empty string
|
|
95
|
+
*/
|
|
96
|
+
async function getControlIdByChange(change, appComponent) {
|
|
97
|
+
const selector = typeof change.getSelector === 'function' ? change.getSelector() : undefined;
|
|
98
|
+
const changeType = change.getChangeType();
|
|
99
|
+
const layer = change.getLayer();
|
|
100
|
+
if (!selector?.id) {
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
try {
|
|
104
|
+
let control = JsControlTreeModifier.bySelector(selector, appComponent);
|
|
105
|
+
if (!control) {
|
|
106
|
+
return selector.id;
|
|
107
|
+
}
|
|
108
|
+
const changeHandlerAPI = (await __ui5_require_async('sap/ui/fl/write/api/ChangesWriteAPI')).default;
|
|
109
|
+
if (typeof changeHandlerAPI?.getChangeHandler !== 'function') {
|
|
110
|
+
return selector.id;
|
|
111
|
+
}
|
|
112
|
+
const changeHandler = await changeHandlerAPI.getChangeHandler({
|
|
113
|
+
changeType,
|
|
114
|
+
element: control,
|
|
115
|
+
modifier: JsControlTreeModifier,
|
|
116
|
+
layer
|
|
117
|
+
});
|
|
118
|
+
if (changeHandler && typeof changeHandler.getChangeVisualizationInfo === 'function') {
|
|
119
|
+
const result = await changeHandler.getChangeVisualizationInfo(change, appComponent);
|
|
120
|
+
return JsControlTreeModifier.getControlIdBySelector(result?.affectedControls?.[0] ?? selector, appComponent);
|
|
121
|
+
}
|
|
122
|
+
return JsControlTreeModifier.getControlIdBySelector(selector, appComponent);
|
|
123
|
+
} catch (error) {
|
|
124
|
+
Log.error('Getting element ID from change has failed:', getError(error));
|
|
125
|
+
return selector.id;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
async function getPropertyChange(change, _ref) {
|
|
129
|
+
let {
|
|
130
|
+
appComponent
|
|
131
|
+
} = _ref;
|
|
132
|
+
const propertyChange = change;
|
|
133
|
+
const flexObject = await getFlexObject(change);
|
|
134
|
+
const selectorId = await getControlIdByChange(flexObject, appComponent);
|
|
135
|
+
const changeTitle = change.selector.type ? change.selector.type.split('.').pop() : '';
|
|
136
|
+
assertChange(propertyChange);
|
|
137
|
+
if ([propertyChange.content.newValue, propertyChange.content.newBinding].every(item => item === undefined || item === null)) {
|
|
138
|
+
throw new Error('Invalid change, missing new value in the change file');
|
|
139
|
+
}
|
|
140
|
+
if (change.changeType !== PROPERTY_CHANGE && change.changeType !== PROPERTY_BINDING_CHANGE) {
|
|
141
|
+
throw new Error('Unknown Change Type');
|
|
142
|
+
}
|
|
143
|
+
return {
|
|
144
|
+
changeTitle: changeTitle,
|
|
145
|
+
controlId: selectorId,
|
|
146
|
+
changeType: 'property',
|
|
147
|
+
properties: [{
|
|
148
|
+
label: propertyChange.content.property,
|
|
149
|
+
value: propertyChange.content.newValue ?? propertyChange.content.newBinding,
|
|
150
|
+
displayValueWithIcon: true
|
|
151
|
+
}]
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
function getV2ConfigurationChange(change, _ref2) {
|
|
155
|
+
let {
|
|
156
|
+
textBundle
|
|
157
|
+
} = _ref2;
|
|
158
|
+
const {
|
|
159
|
+
entityPropertyChange,
|
|
160
|
+
parentPage
|
|
161
|
+
} = change.content;
|
|
162
|
+
const propertyPathSegments = entityPropertyChange.propertyPath.split('/');
|
|
163
|
+
const propertyName = Object.keys(entityPropertyChange.propertyValue)?.[0] ?? propertyPathSegments[propertyPathSegments.length - 1];
|
|
164
|
+
const propertyValue = entityPropertyChange.propertyValue?.[propertyName] ?? entityPropertyChange.propertyValue;
|
|
165
|
+
return {
|
|
166
|
+
changeTitle: textBundle?.getText('CONFIGURATION_CHANGE'),
|
|
167
|
+
controlId: [],
|
|
168
|
+
changeType: 'configuration',
|
|
169
|
+
subtitle: entityPropertyChange.propertyPath ?? parentPage.component,
|
|
170
|
+
properties: [{
|
|
171
|
+
label: propertyName ?? '',
|
|
172
|
+
value: propertyValue,
|
|
173
|
+
displayValueWithIcon: true
|
|
174
|
+
}]
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
function getV4ConfigurationChange(change, _ref3) {
|
|
178
|
+
let {
|
|
179
|
+
configPropertyControlIdMap,
|
|
180
|
+
textBundle
|
|
181
|
+
} = _ref3;
|
|
182
|
+
assertManifestChange(change);
|
|
183
|
+
if ([change.content.entityPropertyChange.propertyValue].every(item => item === undefined || item === null)) {
|
|
184
|
+
throw new Error('Invalid change, missing property value on change file');
|
|
185
|
+
}
|
|
186
|
+
const propertyPathSegments = change.content.entityPropertyChange.propertyPath.split('/');
|
|
187
|
+
const propertyName = propertyPathSegments.pop();
|
|
188
|
+
if (!propertyName) {
|
|
189
|
+
throw new Error('No property name found');
|
|
190
|
+
}
|
|
191
|
+
const configMapKey = getConfigMapControlIdMap(change.content.page, propertyPathSegments);
|
|
192
|
+
const controlIds = configPropertyControlIdMap?.get(configMapKey) || [];
|
|
193
|
+
let value = change.content.entityPropertyChange.propertyValue;
|
|
194
|
+
const properties = typeof value === 'object' ? [{
|
|
195
|
+
label: propertyName,
|
|
196
|
+
displayValueWithIcon: true
|
|
197
|
+
}, ...Object.keys(value).map(key => {
|
|
198
|
+
if (typeof value[key] === 'object') {
|
|
199
|
+
return undefined;
|
|
200
|
+
}
|
|
201
|
+
return {
|
|
202
|
+
label: key,
|
|
203
|
+
value: value[key],
|
|
204
|
+
displayValueWithIcon: true
|
|
205
|
+
};
|
|
206
|
+
}).filter(item => !!item)] : [{
|
|
207
|
+
label: propertyName,
|
|
208
|
+
value,
|
|
209
|
+
displayValueWithIcon: true
|
|
210
|
+
}];
|
|
211
|
+
return {
|
|
212
|
+
changeTitle: textBundle?.getText('CONFIGURATION_CHANGE'),
|
|
213
|
+
controlId: controlIds,
|
|
214
|
+
changeType: 'configuration',
|
|
215
|
+
subtitle: getCompactV4ConfigPath(propertyPathSegments),
|
|
216
|
+
properties
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
const GENERIC_CHANGE_HANDLER = {
|
|
220
|
+
[ADD_NEW_ANNOTATION_FILE_CHANGE]: (annotationFileChange, _ref4) => {
|
|
221
|
+
let {
|
|
222
|
+
textBundle
|
|
223
|
+
} = _ref4;
|
|
224
|
+
const dataSourceId = annotationFileChange.content.dataSourceId;
|
|
225
|
+
const sourceKey = Object.keys(annotationFileChange.content.dataSource)[0];
|
|
226
|
+
return {
|
|
227
|
+
changeTitle: textBundle?.getText('ADD_NEW_ANNOTATION_FILE'),
|
|
228
|
+
changeType: 'configuration',
|
|
229
|
+
properties: [{
|
|
230
|
+
label: textBundle?.getText('SERVICE_NAME'),
|
|
231
|
+
value: dataSourceId
|
|
232
|
+
}, {
|
|
233
|
+
label: textBundle?.getText('ANNOTATION_FILE_URI'),
|
|
234
|
+
value: annotationFileChange.content.dataSource[sourceKey].uri
|
|
235
|
+
}]
|
|
236
|
+
};
|
|
237
|
+
},
|
|
238
|
+
[RENAME_CHANGE]: (renameChange, _ref5) => {
|
|
239
|
+
let {
|
|
240
|
+
textBundle
|
|
241
|
+
} = _ref5;
|
|
242
|
+
const selectorId = renameChange.selector.id;
|
|
243
|
+
return {
|
|
244
|
+
changeTitle: textBundle?.getText('RENAME_CHANGE'),
|
|
245
|
+
controlId: selectorId,
|
|
246
|
+
properties: [{
|
|
247
|
+
label: textBundle?.getText('SELECTOR_ID'),
|
|
248
|
+
value: selectorId
|
|
249
|
+
}, {
|
|
250
|
+
label: textBundle?.getText('NEW_VALUE'),
|
|
251
|
+
value: renameChange.texts.newText.value
|
|
252
|
+
}, {
|
|
253
|
+
label: textBundle?.getText('TEXT_TYPE'),
|
|
254
|
+
value: renameChange.texts.newText.type
|
|
255
|
+
}]
|
|
256
|
+
};
|
|
257
|
+
},
|
|
258
|
+
[MOVE_CHANGE]: (moveChange, _ref6) => {
|
|
259
|
+
let {
|
|
260
|
+
textBundle
|
|
261
|
+
} = _ref6;
|
|
262
|
+
const movedControlId = moveChange.content.movedElements[0].selector.id;
|
|
263
|
+
return {
|
|
264
|
+
changeTitle: textBundle?.getText('MOVE_CONTROLS_CHANGE'),
|
|
265
|
+
controlId: movedControlId,
|
|
266
|
+
properties: [{
|
|
267
|
+
label: textBundle?.getText('TARGET_CONTROL_ID'),
|
|
268
|
+
value: moveChange.content.target.selector.id
|
|
269
|
+
}, {
|
|
270
|
+
label: textBundle?.getText('MOVE_FROM_INDEX'),
|
|
271
|
+
value: String(moveChange.content.movedElements[0].sourceIndex)
|
|
272
|
+
}, {
|
|
273
|
+
label: textBundle?.getText('MOVE_TO_INDEX'),
|
|
274
|
+
value: String(moveChange.content.movedElements[0].targetIndex)
|
|
275
|
+
}, {
|
|
276
|
+
label: textBundle?.getText('MOVED_CONTROL_ID'),
|
|
277
|
+
value: movedControlId
|
|
278
|
+
}]
|
|
279
|
+
};
|
|
280
|
+
},
|
|
281
|
+
[ADD_XML_CHANGE]: (addXmlChange, _ref7) => {
|
|
282
|
+
let {
|
|
283
|
+
textBundle
|
|
284
|
+
} = _ref7;
|
|
285
|
+
return {
|
|
286
|
+
changeTitle: textBundle?.getText('ADD_XML_CHANGE'),
|
|
287
|
+
controlId: addXmlChange.selector.id,
|
|
288
|
+
properties: [{
|
|
289
|
+
label: textBundle?.getText('AGGREGATION'),
|
|
290
|
+
value: addXmlChange.content.targetAggregation
|
|
291
|
+
}, {
|
|
292
|
+
label: textBundle?.getText('FRAGMENT_PATH'),
|
|
293
|
+
value: addXmlChange.content.fragmentPath
|
|
294
|
+
}]
|
|
295
|
+
};
|
|
296
|
+
},
|
|
297
|
+
[PROPERTY_CHANGE]: async (change, handlerOptions) => {
|
|
298
|
+
return getPropertyChange(change, handlerOptions);
|
|
299
|
+
},
|
|
300
|
+
[PROPERTY_BINDING_CHANGE]: async (change, handlerOptions) => {
|
|
301
|
+
return getPropertyChange(change, handlerOptions);
|
|
302
|
+
},
|
|
303
|
+
[MANIFEST_V4_CHANGE]: (change, handlerOptions) => {
|
|
304
|
+
return getV4ConfigurationChange(change, handlerOptions);
|
|
305
|
+
},
|
|
306
|
+
[MANIFEST_V2_CHANGE]: (change, handlerOptions) => {
|
|
307
|
+
return getV2ConfigurationChange(change, handlerOptions);
|
|
308
|
+
}
|
|
309
|
+
};
|
|
310
|
+
var __exports = {
|
|
311
|
+
__esModule: true
|
|
312
|
+
};
|
|
313
|
+
__exports.ADD_NEW_ANNOTATION_FILE_CHANGE = ADD_NEW_ANNOTATION_FILE_CHANGE;
|
|
314
|
+
__exports.RENAME_CHANGE = RENAME_CHANGE;
|
|
315
|
+
__exports.MOVE_CHANGE = MOVE_CHANGE;
|
|
316
|
+
__exports.ADD_XML_CHANGE = ADD_XML_CHANGE;
|
|
317
|
+
__exports.PROPERTY_CHANGE = PROPERTY_CHANGE;
|
|
318
|
+
__exports.PROPERTY_BINDING_CHANGE = PROPERTY_BINDING_CHANGE;
|
|
319
|
+
__exports.MANIFEST_V4_CHANGE = MANIFEST_V4_CHANGE;
|
|
320
|
+
__exports.MANIFEST_V2_CHANGE = MANIFEST_V2_CHANGE;
|
|
321
|
+
__exports.assertProperties = assertProperties;
|
|
322
|
+
__exports.assertChange = assertChange;
|
|
323
|
+
__exports.getFlexObject = getFlexObject;
|
|
324
|
+
__exports.getControlIdByChange = getControlIdByChange;
|
|
325
|
+
__exports.GENERIC_CHANGE_HANDLER = GENERIC_CHANGE_HANDLER;
|
|
326
|
+
return __exports;
|
|
327
327
|
});
|
|
328
328
|
//# sourceMappingURL=generic-change.js.map
|