@sap-ux/preview-middleware 0.23.48 → 0.23.50
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/command-executor.js +99 -66
- package/dist/client/adp/controllers/AddCustomFragment.controller.js +120 -102
- package/dist/client/adp/controllers/AddFragment.controller.js +189 -163
- package/dist/client/adp/controllers/AddSubpage.controller.js +146 -137
- package/dist/client/adp/controllers/AddTableColumnFragments.controller.js +230 -188
- package/dist/client/adp/controllers/BaseDialog.controller.js +187 -164
- package/dist/client/adp/controllers/ControllerExtension.controller.js +329 -253
- package/dist/client/adp/controllers/ExtensionPoint.controller.js +158 -114
- package/dist/client/adp/extension-point.js +81 -60
- package/dist/client/adp/init.js +100 -99
- package/dist/client/adp/quick-actions/common/add-new-annotation-file.js +165 -147
- package/dist/client/adp/quick-actions/enablement-validator.js +0 -4
- package/dist/client/adp/quick-actions/fe-v2/create-table-custom-column.js +105 -100
- package/dist/client/adp/quick-actions/simple-quick-action-base.js +44 -40
- package/dist/client/adp/quick-actions/table-quick-action-base.js +309 -266
- package/dist/client/adp/sync-views-utils.js +119 -83
- package/dist/client/cpe/changes/flex-change.js +64 -48
- package/dist/client/cpe/changes/service.js +492 -367
- package/dist/client/cpe/communication-service.js +41 -29
- package/dist/client/cpe/connector-service.js +87 -64
- package/dist/client/cpe/context-menu-service.js +87 -74
- package/dist/client/cpe/control-data.js +353 -263
- package/dist/client/cpe/documentation.js +183 -126
- package/dist/client/cpe/init.js +69 -75
- package/dist/client/cpe/outline/service.js +60 -45
- package/dist/client/cpe/quick-actions/quick-action-definition.js +0 -4
- package/dist/client/cpe/quick-actions/quick-action-service.js +154 -129
- package/dist/client/cpe/rta-service.js +91 -69
- package/dist/client/cpe/selection.js +239 -187
- package/dist/client/cpe/types.js +0 -4
- package/dist/client/flp/init.js +403 -296
- package/dist/client/manifest.json +7 -4
- package/dist/client/thirdparty/@sap-ux-private/control-property-editor-common.js +444 -370
- package/dist/client/utils/info-center-message.js +59 -31
- package/dist/client/utils/version.js +128 -72
- package/package.json +4 -4
|
@@ -1,196 +1,248 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
sap.ui.define(["open/ux/preview/client/thirdparty/@sap-ux-private/control-property-editor-common", "./control-data", "./utils", "sap/base/Log", "sap/ui/dt/OverlayRegistry", "sap/ui/dt/OverlayUtil", "../utils/core", "../utils/error", "./documentation"], function (___sap_ux_private_control_property_editor_common, ___control_data, ___utils, Log, OverlayRegistry, OverlayUtil, ___utils_core, ___utils_error, ___documentation) {
|
|
4
|
+
"use strict";
|
|
5
|
+
|
|
6
|
+
const changeProperty = ___sap_ux_private_control_property_editor_common["changeProperty"];
|
|
7
|
+
const controlSelected = ___sap_ux_private_control_property_editor_common["controlSelected"];
|
|
8
|
+
const propertyChanged = ___sap_ux_private_control_property_editor_common["propertyChanged"];
|
|
9
|
+
const PropertyType = ___sap_ux_private_control_property_editor_common["PropertyType"];
|
|
10
|
+
const reportTelemetry = ___sap_ux_private_control_property_editor_common["reportTelemetry"];
|
|
11
|
+
const selectControl = ___sap_ux_private_control_property_editor_common["selectControl"];
|
|
12
|
+
const buildControlData = ___control_data["buildControlData"];
|
|
13
|
+
const getOverlay = ___utils["getOverlay"];
|
|
14
|
+
const getRuntimeControl = ___utils["getRuntimeControl"];
|
|
15
|
+
const getComponent = ___utils_core["getComponent"];
|
|
16
|
+
const getControlById = ___utils_core["getControlById"];
|
|
17
|
+
const getError = ___utils_error["getError"];
|
|
18
|
+
const getDocumentation = ___documentation["getDocumentation"];
|
|
19
|
+
/**
|
|
20
|
+
* Change id is a combination of controlId and propertyName.
|
|
21
|
+
*
|
|
22
|
+
* @param controlId unique identifier for a control.
|
|
23
|
+
* @param propertyName name of the control property.
|
|
24
|
+
* @returns string
|
|
25
|
+
*/
|
|
26
|
+
function propertyChangeId(controlId, propertyName) {
|
|
27
|
+
return [controlId, propertyName].join(',');
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Return document of a property.
|
|
32
|
+
*
|
|
33
|
+
* @param property - control metadata props.
|
|
34
|
+
* @param ui5Type - ui5 type
|
|
35
|
+
* @param document - property that is ignored during design time
|
|
36
|
+
* @returns PropertiesInfo
|
|
37
|
+
*/
|
|
38
|
+
function getPropertyDocument(property, ui5Type, document) {
|
|
39
|
+
return document?.[property.name] ? document[property.name] : {
|
|
40
|
+
defaultValue: property.defaultValue ?? '-',
|
|
41
|
+
description: '',
|
|
42
|
+
propertyName: property.name,
|
|
43
|
+
type: ui5Type ?? '-',
|
|
44
|
+
propertyType: ui5Type ?? '-'
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
async function addDocumentationForProperties(control, controlData) {
|
|
48
|
+
try {
|
|
49
|
+
const controlMetadata = control.getMetadata();
|
|
50
|
+
const allProperties = controlMetadata.getAllProperties();
|
|
51
|
+
const selectedControlName = controlMetadata.getName();
|
|
52
|
+
const selContLibName = controlMetadata.getLibraryName();
|
|
53
|
+
// Add the control's properties
|
|
54
|
+
const document = await getDocumentation(selectedControlName, selContLibName);
|
|
55
|
+
controlData.properties.forEach(controlProp => {
|
|
56
|
+
if (controlProp.propertyType === PropertyType.ControlProperty) {
|
|
57
|
+
const property = allProperties[controlProp.name];
|
|
58
|
+
controlProp.documentation = getPropertyDocument(property, controlProp.ui5Type, document);
|
|
57
59
|
}
|
|
60
|
+
});
|
|
61
|
+
} catch (e) {
|
|
62
|
+
Log.error('Document loading failed', getError(e));
|
|
58
63
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
*
|
|
68
|
+
*/
|
|
69
|
+
class SelectionService {
|
|
70
|
+
appliedChangeCache = (() => new Map())();
|
|
71
|
+
activeChangeHandlers = (() => new Set())();
|
|
72
|
+
/**
|
|
73
|
+
*
|
|
74
|
+
* @param rta - rta object.
|
|
75
|
+
* @param ui5 - facade for ui5 framework methods
|
|
76
|
+
*/
|
|
77
|
+
constructor(rta, changeService) {
|
|
78
|
+
this.rta = rta;
|
|
79
|
+
this.changeService = changeService;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Initialize selection service.
|
|
84
|
+
*
|
|
85
|
+
* @param sendAction action sender function
|
|
86
|
+
* @param subscribe subscriber function
|
|
87
|
+
*/
|
|
88
|
+
init(sendAction, subscribe) {
|
|
89
|
+
const eventOrigin = new Set();
|
|
90
|
+
const onselectionChange = this.createOnSelectionChangeHandler(sendAction, eventOrigin);
|
|
91
|
+
this.rta.attachSelectionChange(event => {
|
|
92
|
+
onselectionChange(event).catch(error => Log.error('Event interrupted: ', getError(error)));
|
|
93
|
+
});
|
|
94
|
+
subscribe(async action => {
|
|
95
|
+
if (changeProperty.match(action)) {
|
|
96
|
+
this.applyControlPropertyChange(action.payload.controlId, action.payload.propertyName);
|
|
97
|
+
} else if (selectControl.match(action)) {
|
|
98
|
+
const id = action.payload;
|
|
99
|
+
const control = getControlById(id);
|
|
100
|
+
if (!control) {
|
|
101
|
+
const component = getComponent(id);
|
|
102
|
+
if (component) {
|
|
103
|
+
await this.buildProperties(component, sendAction);
|
|
104
|
+
}
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
this.currentSelection = control;
|
|
108
|
+
eventOrigin.add('outline');
|
|
109
|
+
let controlOverlay = OverlayRegistry.getOverlay(control);
|
|
110
|
+
const selectedOverlayControls = this.rta.getSelection() ?? [];
|
|
111
|
+
//remove previous selection
|
|
112
|
+
for (const selectedOverlayControl of selectedOverlayControls) {
|
|
113
|
+
selectedOverlayControl.setSelected(false); //deselect previously selected control
|
|
114
|
+
}
|
|
115
|
+
const controlRef = controlOverlay?.getDomRef?.();
|
|
116
|
+
controlRef?.scrollIntoView({
|
|
117
|
+
behavior: 'smooth',
|
|
118
|
+
block: 'center',
|
|
119
|
+
inline: 'nearest'
|
|
120
|
+
});
|
|
121
|
+
if (!controlRef) {
|
|
122
|
+
//look for closest control in order to highlight in UI the (without firing the selection event)
|
|
123
|
+
controlOverlay = OverlayUtil.getClosestOverlayFor(control);
|
|
124
|
+
}
|
|
125
|
+
if (controlOverlay?.isSelectable()) {
|
|
126
|
+
controlOverlay.setSelected(true); //highlight without firing event only if the layer is selectable
|
|
127
|
+
} else {
|
|
128
|
+
await this.buildProperties(control, sendAction);
|
|
129
|
+
}
|
|
65
130
|
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
if (changeProperty.match(action)) {
|
|
74
|
-
this.applyControlPropertyChange(action.payload.controlId, action.payload.propertyName);
|
|
75
|
-
} else if (selectControl.match(action)) {
|
|
76
|
-
const id = action.payload;
|
|
77
|
-
const control = getControlById(id);
|
|
78
|
-
if (!control) {
|
|
79
|
-
const component = getComponent(id);
|
|
80
|
-
if (component) {
|
|
81
|
-
await this.buildProperties(component, sendAction);
|
|
82
|
-
}
|
|
83
|
-
return;
|
|
84
|
-
}
|
|
85
|
-
this.currentSelection = control;
|
|
86
|
-
eventOrigin.add('outline');
|
|
87
|
-
let controlOverlay = OverlayRegistry.getOverlay(control);
|
|
88
|
-
const selectedOverlayControls = this.rta.getSelection() ?? [];
|
|
89
|
-
for (const selectedOverlayControl of selectedOverlayControls) {
|
|
90
|
-
selectedOverlayControl.setSelected(false);
|
|
91
|
-
}
|
|
92
|
-
const controlRef = controlOverlay?.getDomRef?.();
|
|
93
|
-
controlRef?.scrollIntoView({
|
|
94
|
-
behavior: 'smooth',
|
|
95
|
-
block: 'center',
|
|
96
|
-
inline: 'nearest'
|
|
97
|
-
});
|
|
98
|
-
if (!controlRef) {
|
|
99
|
-
controlOverlay = OverlayUtil.getClosestOverlayFor(control);
|
|
100
|
-
}
|
|
101
|
-
if (controlOverlay?.isSelectable()) {
|
|
102
|
-
controlOverlay.setSelected(true);
|
|
103
|
-
} else {
|
|
104
|
-
await this.buildProperties(control, sendAction);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
});
|
|
108
|
-
this.changeService.onStackChange(async event => {
|
|
109
|
-
const control = event.detail.controls.find(ctrl => ctrl === this.currentSelection);
|
|
110
|
-
if (control) {
|
|
111
|
-
const overlay = getOverlay(control);
|
|
112
|
-
await this.buildProperties(control, sendAction, overlay);
|
|
113
|
-
}
|
|
114
|
-
});
|
|
131
|
+
});
|
|
132
|
+
// rebuild config properties in panel for the selected control onStackChange event
|
|
133
|
+
this.changeService.onStackChange(async event => {
|
|
134
|
+
const control = event.detail.controls.find(ctrl => ctrl === this.currentSelection);
|
|
135
|
+
if (control) {
|
|
136
|
+
const overlay = getOverlay(control);
|
|
137
|
+
await this.buildProperties(control, sendAction, overlay);
|
|
115
138
|
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
async buildProperties(control, sendAction, overlay) {
|
|
142
|
+
const controlData = buildControlData(control, this.changeService, overlay);
|
|
143
|
+
await addDocumentationForProperties(control, controlData);
|
|
144
|
+
const action = controlSelected(controlData);
|
|
145
|
+
sendAction(action);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
*
|
|
150
|
+
* @param controlId unique identifier for a control
|
|
151
|
+
* @param propertyName name of the control property.
|
|
152
|
+
*/
|
|
153
|
+
applyControlPropertyChange(controlId, propertyName) {
|
|
154
|
+
const changeId = propertyChangeId(controlId, propertyName);
|
|
155
|
+
this.appliedChangeCache.set(changeId, Date.now());
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Create handler for onSelectionChange.
|
|
160
|
+
*
|
|
161
|
+
* @param sendAction sending action method
|
|
162
|
+
* @param eventOrigin origin of the event.
|
|
163
|
+
* @returns (event: Event) => Promise<void>
|
|
164
|
+
*/
|
|
165
|
+
createOnSelectionChangeHandler(sendAction, eventOrigin) {
|
|
166
|
+
return async event => {
|
|
167
|
+
const selection = event.getParameter('selection');
|
|
168
|
+
for (const dispose of this.activeChangeHandlers) {
|
|
169
|
+
dispose();
|
|
121
170
|
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
171
|
+
this.activeChangeHandlers.clear();
|
|
172
|
+
if (Array.isArray(selection) && selection.length === 1) {
|
|
173
|
+
const overlayControl = sap.ui.getCore().byId(selection[0].getId());
|
|
174
|
+
if (overlayControl) {
|
|
175
|
+
const runtimeControl = getRuntimeControl(overlayControl);
|
|
176
|
+
this.currentSelection = runtimeControl;
|
|
177
|
+
const controlName = runtimeControl.getMetadata().getName();
|
|
178
|
+
this.handlePropertyChanges(runtimeControl, sendAction);
|
|
179
|
+
try {
|
|
180
|
+
const isOutline = eventOrigin.has('outline');
|
|
181
|
+
const name = controlName.toLowerCase().startsWith('sap') ? controlName : 'Other Control Types';
|
|
182
|
+
if (isOutline) {
|
|
183
|
+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
184
|
+
reportTelemetry({
|
|
185
|
+
category: 'Outline Selection',
|
|
186
|
+
controlName: name
|
|
187
|
+
});
|
|
188
|
+
} else {
|
|
189
|
+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
190
|
+
reportTelemetry({
|
|
191
|
+
category: 'Overlay Selection',
|
|
192
|
+
controlName: name
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
} catch (error) {
|
|
196
|
+
const extendedError = getError(error);
|
|
197
|
+
Log.error('Failed to report telemetry', extendedError);
|
|
198
|
+
} finally {
|
|
199
|
+
await this.buildProperties(runtimeControl, sendAction, overlayControl);
|
|
200
|
+
eventOrigin.delete('outline');
|
|
201
|
+
}
|
|
202
|
+
}
|
|
125
203
|
}
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
reportTelemetry({
|
|
145
|
-
category: 'Outline Selection',
|
|
146
|
-
controlName: name
|
|
147
|
-
});
|
|
148
|
-
} else {
|
|
149
|
-
reportTelemetry({
|
|
150
|
-
category: 'Overlay Selection',
|
|
151
|
-
controlName: name
|
|
152
|
-
});
|
|
153
|
-
}
|
|
154
|
-
} catch (error) {
|
|
155
|
-
const extendedError = getError(error);
|
|
156
|
-
Log.error('Failed to report telemetry', extendedError);
|
|
157
|
-
} finally {
|
|
158
|
-
await this.buildProperties(runtimeControl, sendAction, overlayControl);
|
|
159
|
-
eventOrigin.delete('outline');
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
};
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
*
|
|
209
|
+
* @param runtimeControl sap/ui/base/ManagedObject
|
|
210
|
+
* @param sendAction send action method.
|
|
211
|
+
*/
|
|
212
|
+
handlePropertyChanges(runtimeControl, sendAction) {
|
|
213
|
+
const handler = e => {
|
|
214
|
+
const propertyName = e.getParameter('name');
|
|
215
|
+
const controlId = e.getParameter('id');
|
|
216
|
+
const changeId = propertyChangeId(controlId, propertyName);
|
|
217
|
+
const timestamp = this.appliedChangeCache.get(changeId);
|
|
218
|
+
if (timestamp) {
|
|
219
|
+
// Change originated from control property editor, we do not need to notify it
|
|
220
|
+
this.appliedChangeCache.delete(changeId);
|
|
221
|
+
return;
|
|
164
222
|
}
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
newValue
|
|
181
|
-
});
|
|
182
|
-
sendAction(change);
|
|
183
|
-
};
|
|
184
|
-
runtimeControl.attachEvent('_change', handler);
|
|
185
|
-
this.activeChangeHandlers.add(() => {
|
|
186
|
-
try {
|
|
187
|
-
runtimeControl.detachEvent('_change', handler);
|
|
188
|
-
} catch {
|
|
189
|
-
}
|
|
190
|
-
});
|
|
223
|
+
const info = runtimeControl.getBindingInfo(propertyName);
|
|
224
|
+
const newValue = info?.bindingString ?? e.getParameter('newValue');
|
|
225
|
+
const change = propertyChanged({
|
|
226
|
+
controlId,
|
|
227
|
+
propertyName,
|
|
228
|
+
newValue
|
|
229
|
+
});
|
|
230
|
+
sendAction(change);
|
|
231
|
+
};
|
|
232
|
+
runtimeControl.attachEvent('_change', handler);
|
|
233
|
+
this.activeChangeHandlers.add(() => {
|
|
234
|
+
try {
|
|
235
|
+
runtimeControl.detachEvent('_change', handler);
|
|
236
|
+
} catch {
|
|
237
|
+
// control has already been cleaned up, nothing to do here
|
|
191
238
|
}
|
|
239
|
+
});
|
|
192
240
|
}
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
}
|
|
241
|
+
}
|
|
242
|
+
var __exports = {
|
|
243
|
+
__esModule: true
|
|
244
|
+
};
|
|
245
|
+
__exports.SelectionService = SelectionService;
|
|
246
|
+
return __exports;
|
|
247
|
+
});
|
|
248
|
+
//# sourceMappingURL=selection.js.map
|