@sap-ux/preview-middleware 0.11.35 → 0.12.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.
Files changed (50) hide show
  1. package/dist/base/flp.d.ts +8 -2
  2. package/dist/base/flp.js +28 -19
  3. package/dist/client/adp/api-handler.js +141 -141
  4. package/dist/client/adp/command-executor.js +54 -41
  5. package/dist/client/adp/command-executor.ts +18 -4
  6. package/dist/client/adp/control-utils.js +44 -44
  7. package/dist/client/adp/controllers/AddFragment.controller.js +206 -203
  8. package/dist/client/adp/controllers/AddFragment.controller.ts +11 -5
  9. package/dist/client/adp/controllers/BaseDialog.controller.js +57 -57
  10. package/dist/client/adp/controllers/BaseDialog.controller.ts +8 -2
  11. package/dist/client/adp/controllers/ControllerExtension.controller.js +174 -173
  12. package/dist/client/adp/controllers/ControllerExtension.controller.ts +10 -6
  13. package/dist/client/adp/controllers/ExtensionPoint.controller.js +100 -100
  14. package/dist/client/adp/controllers/ExtensionPoint.controller.ts +8 -6
  15. package/dist/client/adp/init-dialogs.js +74 -73
  16. package/dist/client/adp/init-dialogs.ts +13 -8
  17. package/dist/client/adp/init.js +23 -7
  18. package/dist/client/adp/init.ts +14 -6
  19. package/dist/client/adp/ui/AddFragment.fragment.xml +69 -0
  20. package/dist/client/adp/ui/ControllerExtension.fragment.xml +51 -0
  21. package/dist/client/adp/ui/ExtensionPoint.fragment.xml +51 -0
  22. package/dist/client/adp/ui5-version-utils.js +63 -63
  23. package/dist/client/adp/utils.js +33 -33
  24. package/dist/client/cpe/changes/flex-change.js +51 -51
  25. package/dist/client/cpe/changes/index.js +10 -10
  26. package/dist/client/cpe/changes/validator.js +35 -35
  27. package/dist/client/cpe/documentation.js +164 -164
  28. package/dist/client/cpe/logger.js +30 -30
  29. package/dist/client/cpe/outline/nodes.js +84 -84
  30. package/dist/client/cpe/outline/utils.js +37 -37
  31. package/dist/client/cpe/types.js +4 -4
  32. package/dist/client/cpe/ui5-utils.js +49 -49
  33. package/dist/client/cpe/utils.js +48 -48
  34. package/dist/client/flp/WorkspaceConnector.js +69 -77
  35. package/dist/client/flp/WorkspaceConnector.ts +5 -25
  36. package/dist/client/flp/common.js +30 -0
  37. package/dist/client/flp/common.ts +26 -0
  38. package/dist/client/flp/enableFakeConnector.js +79 -0
  39. package/dist/client/flp/enableFakeConnector.ts +93 -0
  40. package/dist/client/flp/init.js +212 -204
  41. package/dist/client/flp/init.ts +27 -11
  42. package/dist/client/flp/initConnectors.js +35 -0
  43. package/dist/client/flp/initConnectors.ts +30 -0
  44. package/dist/client/flp/initRta.js +180 -0
  45. package/dist/client/flp/initRta.ts +193 -0
  46. package/package.json +4 -3
  47. package/templates/flp/sandbox.html +7 -1
  48. package/dist/client/adp/ui/AddFragment.view.xml +0 -68
  49. package/dist/client/adp/ui/ControllerExtension.view.xml +0 -49
  50. package/dist/client/adp/ui/ExtensionPoint.view.xml +0 -49
@@ -20,6 +20,7 @@ export interface CustomConnector {
20
20
  export interface FlexConnector {
21
21
  connector: string;
22
22
  layers: string[];
23
+ url?: string;
23
24
  }
24
25
  /**
25
26
  * Internal structure used to fill the sandbox.html template
@@ -108,9 +109,14 @@ export declare class FlpSandbox {
108
109
  */
109
110
  private addRoutesForAdditionalApps;
110
111
  /**
111
- * Create required routes for flex.
112
+ * Retrieves the configuration settings for UI5 flexibility services.
112
113
  *
113
- * @returns template configuration for flex.
114
+ * @returns An array of flexibility service configurations, each specifying a connector
115
+ * and its options, such as the layers it applies to and its service URL, if applicable.
116
+ */
117
+ private getFlexSettings;
118
+ /**
119
+ * Create required routes for flex.
114
120
  */
115
121
  private createFlexHandler;
116
122
  /**
package/dist/base/flp.js CHANGED
@@ -120,7 +120,8 @@ class FlpSandbox {
120
120
  var _a, _b, _c, _d, _e, _f, _g;
121
121
  var _h;
122
122
  return __awaiter(this, void 0, void 0, function* () {
123
- const flex = this.createFlexHandler();
123
+ this.createFlexHandler();
124
+ const flex = this.getFlexSettings();
124
125
  const supportedThemes = (_b = (_a = manifest['sap.ui5']) === null || _a === void 0 ? void 0 : _a.supportedThemes) !== null && _b !== void 0 ? _b : [DEFAULT_THEME];
125
126
  const ui5Theme = (_c = this.config.theme) !== null && _c !== void 0 ? _c : (supportedThemes.includes(DEFAULT_THEME) ? DEFAULT_THEME : supportedThemes[0]);
126
127
  this.templateConfig = {
@@ -271,12 +272,30 @@ class FlpSandbox {
271
272
  }
272
273
  }
273
274
  /**
274
- * Create required routes for flex.
275
+ * Retrieves the configuration settings for UI5 flexibility services.
275
276
  *
276
- * @returns template configuration for flex.
277
+ * @returns An array of flexibility service configurations, each specifying a connector
278
+ * and its options, such as the layers it applies to and its service URL, if applicable.
279
+ */
280
+ getFlexSettings() {
281
+ const localConnectorPath = 'custom.connectors.WorkspaceConnector';
282
+ return [
283
+ { connector: 'LrepConnector', layers: [], url: '/sap/bc/lrep' },
284
+ {
285
+ applyConnector: localConnectorPath,
286
+ writeConnector: localConnectorPath,
287
+ custom: true
288
+ },
289
+ {
290
+ connector: 'LocalStorageConnector',
291
+ layers: ['CUSTOMER', 'USER']
292
+ }
293
+ ];
294
+ }
295
+ /**
296
+ * Create required routes for flex.
277
297
  */
278
298
  createFlexHandler() {
279
- const workspaceConnectorPath = 'open/ux/preview/client/flp/WorkspaceConnector';
280
299
  const api = `${PREVIEW_URL.api}/changes`;
281
300
  this.router.use(api, (0, express_1.json)());
282
301
  this.router.get(api, ((_req, res) => __awaiter(this, void 0, void 0, function* () {
@@ -312,17 +331,6 @@ class FlpSandbox {
312
331
  res.status(500).send(error.message);
313
332
  }
314
333
  })));
315
- return [
316
- {
317
- applyConnector: workspaceConnectorPath,
318
- writeConnector: workspaceConnectorPath,
319
- custom: true
320
- },
321
- {
322
- connector: 'LocalStorageConnector',
323
- layers: ['CUSTOMER', 'USER']
324
- }
325
- ];
326
334
  }
327
335
  /**
328
336
  * Add an application to the local FLP preview.
@@ -344,9 +352,7 @@ class FlpSandbox {
344
352
  additionalInformation: `SAPUI5.Component=${(_f = app.componentId) !== null && _f !== void 0 ? _f : id}`,
345
353
  applicationType: 'URL',
346
354
  url: app.target,
347
- applicationDependencies: {
348
- manifest: true
349
- }
355
+ applicationDependencies: { manifest: true }
350
356
  };
351
357
  }
352
358
  /**
@@ -424,7 +430,10 @@ function initAdp(rootProject, config, flp, util, logger) {
424
430
  (_a = editor.pluginScript) !== null && _a !== void 0 ? _a : (editor.pluginScript = 'open/ux/preview/client/adp/init');
425
431
  }
426
432
  }
427
- yield flp.init(adp.descriptor.manifest, adp.descriptor.name, adp.resources);
433
+ const descriptor = adp.descriptor;
434
+ descriptor.asyncHints.requests = [];
435
+ const { name, manifest } = descriptor;
436
+ yield flp.init(manifest, name, adp.resources);
428
437
  flp.router.use(adp.descriptor.url, adp.proxy.bind(adp));
429
438
  adp.addApis(flp.router);
430
439
  }
@@ -1,143 +1,143 @@
1
- "use strict";
2
-
3
- sap.ui.define([], function () {
4
- "use strict";
5
-
6
- var ApiEndpoints = /*#__PURE__*/function (ApiEndpoints) {
7
- ApiEndpoints["CHANGES"] = "/preview/api/changes";
8
- ApiEndpoints["FRAGMENT"] = "/adp/api/fragment";
9
- ApiEndpoints["CONTROLLER"] = "/adp/api/controller";
10
- ApiEndpoints["CODE_EXT"] = "/adp/api/code_ext";
11
- ApiEndpoints["MANIFEST_APP_DESCRIPTOR"] = "/manifest.appdescr_variant";
12
- return ApiEndpoints;
13
- }(ApiEndpoints || {});
14
- var RequestMethod = /*#__PURE__*/function (RequestMethod) {
15
- RequestMethod["GET"] = "GET";
16
- RequestMethod["PUT"] = "PUT";
17
- RequestMethod["POST"] = "POST";
18
- RequestMethod["PATCH"] = "PATCH";
19
- RequestMethod["DELETE"] = "DELETE";
20
- return RequestMethod;
21
- }(RequestMethod || {});
22
- /**
23
- * Requests a given endpoint
24
- *
25
- * @param endpoint API Endpoint
26
- * @param method RequestMethod
27
- * @param data Data to be sent to the server
28
- * @returns Data from the server request
29
- */
30
- async function request(endpoint, method, data) {
31
- const config = {
32
- method,
33
- body: JSON.stringify(data),
34
- headers: {
35
- 'content-type': 'application/json'
36
- }
37
- };
38
- try {
39
- const response = await fetch(endpoint, config);
40
- if (!response.ok) {
41
- const errorData = await response.json();
42
- const message = errorData?.message ?? '';
43
- throw new Error(`Request failed, status: ${response.status}. ${message}`.trim());
44
- }
45
- switch (method) {
46
- case RequestMethod.GET:
47
- return response.json();
48
- case RequestMethod.POST:
49
- /**
50
- * Since POST usually creates something
51
- * and returns nothing (or a message) we just parse the text from res.send(msg)
52
- */
53
- return response.text();
54
- default:
55
- return response.json();
56
- }
57
- } catch (e) {
58
- throw new Error(e.message);
59
- }
60
- }
61
-
62
- /**
63
- * Retrieves all XML fragments from the project's workspace
64
- *
65
- * @returns Generic Promise<T>
66
- */
67
- async function getFragments() {
68
- return request(ApiEndpoints.FRAGMENT, RequestMethod.GET);
69
- }
70
-
71
- /**
72
- * Writes an XML fragment to the project's workspace
73
- *
74
- * @param data Data to be send to the server
75
- * @returns Generic Promise<T>
76
- */
77
- async function writeFragment(data) {
78
- return request(ApiEndpoints.FRAGMENT, RequestMethod.POST, data);
79
- }
80
-
81
- /**
82
- * Retrieves manifest.appdescr_variant from the project's workspace
83
- *
84
- * @returns Generic Promise<T>
85
- */
86
- async function getManifestAppdescr() {
87
- return request(ApiEndpoints.MANIFEST_APP_DESCRIPTOR, RequestMethod.GET);
88
- }
89
-
90
- /**
91
- * Retrieves all controller extensions from the project's workspace
92
- *
93
- * @returns Generic Promise<T>
94
- */
95
- async function readControllers() {
96
- return request(ApiEndpoints.CONTROLLER, RequestMethod.GET);
97
- }
98
-
99
- /**
100
- * Writes a Controller to the project's workspace
101
- *
102
- * @param data Data to be send to the server
103
- * @returns Generic Promise<T>
104
- */
105
- async function writeController(data) {
106
- return request(ApiEndpoints.CONTROLLER, RequestMethod.POST, data);
107
- }
108
-
109
- /**
110
- * Checks for existing controller in the project's workspace
111
- *
112
- * @param controllerName Name of the controller
113
- * @returns {CodeExtResponse} Returns path to existing controller if found
114
- */
115
- async function getExistingController(controllerName) {
116
- return request(`${ApiEndpoints.CODE_EXT}/${controllerName}`, RequestMethod.GET);
117
- }
118
-
119
- /**
120
- * Writes a change object to the project's workspace
121
- *
122
- * @param data Data to be send to the server
123
- * @returns Generic Promise<T>
124
- */
125
- async function writeChange(data) {
126
- return request(ApiEndpoints.CHANGES, RequestMethod.POST, data);
127
- }
128
- var __exports = {
129
- __esModule: true
130
- };
131
- __exports.ApiEndpoints = ApiEndpoints;
132
- __exports.RequestMethod = RequestMethod;
133
- __exports.request = request;
134
- __exports.getFragments = getFragments;
135
- __exports.writeFragment = writeFragment;
136
- __exports.getManifestAppdescr = getManifestAppdescr;
137
- __exports.readControllers = readControllers;
138
- __exports.writeController = writeController;
139
- __exports.getExistingController = getExistingController;
140
- __exports.writeChange = writeChange;
141
- return __exports;
1
+ "use strict";
2
+
3
+ sap.ui.define([], function () {
4
+ "use strict";
5
+
6
+ var ApiEndpoints = /*#__PURE__*/function (ApiEndpoints) {
7
+ ApiEndpoints["CHANGES"] = "/preview/api/changes";
8
+ ApiEndpoints["FRAGMENT"] = "/adp/api/fragment";
9
+ ApiEndpoints["CONTROLLER"] = "/adp/api/controller";
10
+ ApiEndpoints["CODE_EXT"] = "/adp/api/code_ext";
11
+ ApiEndpoints["MANIFEST_APP_DESCRIPTOR"] = "/manifest.appdescr_variant";
12
+ return ApiEndpoints;
13
+ }(ApiEndpoints || {});
14
+ var RequestMethod = /*#__PURE__*/function (RequestMethod) {
15
+ RequestMethod["GET"] = "GET";
16
+ RequestMethod["PUT"] = "PUT";
17
+ RequestMethod["POST"] = "POST";
18
+ RequestMethod["PATCH"] = "PATCH";
19
+ RequestMethod["DELETE"] = "DELETE";
20
+ return RequestMethod;
21
+ }(RequestMethod || {});
22
+ /**
23
+ * Requests a given endpoint
24
+ *
25
+ * @param endpoint API Endpoint
26
+ * @param method RequestMethod
27
+ * @param data Data to be sent to the server
28
+ * @returns Data from the server request
29
+ */
30
+ async function request(endpoint, method, data) {
31
+ const config = {
32
+ method,
33
+ body: JSON.stringify(data),
34
+ headers: {
35
+ 'content-type': 'application/json'
36
+ }
37
+ };
38
+ try {
39
+ const response = await fetch(endpoint, config);
40
+ if (!response.ok) {
41
+ const errorData = await response.json();
42
+ const message = errorData?.message ?? '';
43
+ throw new Error(`Request failed, status: ${response.status}. ${message}`.trim());
44
+ }
45
+ switch (method) {
46
+ case RequestMethod.GET:
47
+ return response.json();
48
+ case RequestMethod.POST:
49
+ /**
50
+ * Since POST usually creates something
51
+ * and returns nothing (or a message) we just parse the text from res.send(msg)
52
+ */
53
+ return response.text();
54
+ default:
55
+ return response.json();
56
+ }
57
+ } catch (e) {
58
+ throw new Error(e.message);
59
+ }
60
+ }
61
+
62
+ /**
63
+ * Retrieves all XML fragments from the project's workspace
64
+ *
65
+ * @returns Generic Promise<T>
66
+ */
67
+ async function getFragments() {
68
+ return request(ApiEndpoints.FRAGMENT, RequestMethod.GET);
69
+ }
70
+
71
+ /**
72
+ * Writes an XML fragment to the project's workspace
73
+ *
74
+ * @param data Data to be send to the server
75
+ * @returns Generic Promise<T>
76
+ */
77
+ async function writeFragment(data) {
78
+ return request(ApiEndpoints.FRAGMENT, RequestMethod.POST, data);
79
+ }
80
+
81
+ /**
82
+ * Retrieves manifest.appdescr_variant from the project's workspace
83
+ *
84
+ * @returns Generic Promise<T>
85
+ */
86
+ async function getManifestAppdescr() {
87
+ return request(ApiEndpoints.MANIFEST_APP_DESCRIPTOR, RequestMethod.GET);
88
+ }
89
+
90
+ /**
91
+ * Retrieves all controller extensions from the project's workspace
92
+ *
93
+ * @returns Generic Promise<T>
94
+ */
95
+ async function readControllers() {
96
+ return request(ApiEndpoints.CONTROLLER, RequestMethod.GET);
97
+ }
98
+
99
+ /**
100
+ * Writes a Controller to the project's workspace
101
+ *
102
+ * @param data Data to be send to the server
103
+ * @returns Generic Promise<T>
104
+ */
105
+ async function writeController(data) {
106
+ return request(ApiEndpoints.CONTROLLER, RequestMethod.POST, data);
107
+ }
108
+
109
+ /**
110
+ * Checks for existing controller in the project's workspace
111
+ *
112
+ * @param controllerName Name of the controller
113
+ * @returns {CodeExtResponse} Returns path to existing controller if found
114
+ */
115
+ async function getExistingController(controllerName) {
116
+ return request(`${ApiEndpoints.CODE_EXT}/${controllerName}`, RequestMethod.GET);
117
+ }
118
+
119
+ /**
120
+ * Writes a change object to the project's workspace
121
+ *
122
+ * @param data Data to be send to the server
123
+ * @returns Generic Promise<T>
124
+ */
125
+ async function writeChange(data) {
126
+ return request(ApiEndpoints.CHANGES, RequestMethod.POST, data);
127
+ }
128
+ var __exports = {
129
+ __esModule: true
130
+ };
131
+ __exports.ApiEndpoints = ApiEndpoints;
132
+ __exports.RequestMethod = RequestMethod;
133
+ __exports.request = request;
134
+ __exports.getFragments = getFragments;
135
+ __exports.writeFragment = writeFragment;
136
+ __exports.getManifestAppdescr = getManifestAppdescr;
137
+ __exports.readControllers = readControllers;
138
+ __exports.writeController = writeController;
139
+ __exports.getExistingController = getExistingController;
140
+ __exports.writeChange = writeChange;
141
+ return __exports;
142
142
  });
143
143
  //# sourceMappingURL=api-handler.js.map
@@ -1,43 +1,56 @@
1
- "use strict";
2
-
3
- sap.ui.define(["sap/m/MessageToast", "sap/ui/rta/command/CommandFactory"], function (MessageToast, CommandFactory) {
4
- "use strict";
5
-
6
- /**
7
- * Class responsible for handling rta calls
8
- */
9
- class CommandExecutor {
10
- /**
11
- *
12
- * @param rta Runtime Authoring
13
- */
14
- constructor(rta) {
15
- this.rta = rta;
16
- }
17
-
18
- /**
19
- * Generates command based on given values and executes it
20
- *
21
- * @param runtimeControl Managed object
22
- * @param commandName Command name
23
- * @param modifiedValue Modified value/s
24
- * @param designMetadata Design time metadata
25
- * @param flexSettings Additional flex settings
26
- */
27
- async generateAndExecuteCommand(runtimeControl, commandName, modifiedValue, designMetadata, flexSettings) {
28
- try {
29
- const command = await CommandFactory.getCommandFor(runtimeControl, commandName, modifiedValue, designMetadata, flexSettings);
30
-
31
- /**
32
- * The change will have pending state and will only be saved to the workspace when the user clicks save icon
33
- */
34
- await this.rta.getCommandStack().pushAndExecute(command);
35
- } catch (e) {
36
- MessageToast.show(e.message);
37
- throw new Error(e.message);
38
- }
39
- }
40
- }
41
- return CommandExecutor;
1
+ "use strict";
2
+
3
+ sap.ui.define(["sap/m/MessageToast", "sap/ui/rta/command/CommandFactory"], function (MessageToast, CommandFactory) {
4
+ "use strict";
5
+
6
+ /**
7
+ * Class responsible for handling rta calls
8
+ */
9
+ class CommandExecutor {
10
+ /**
11
+ *
12
+ * @param rta Runtime Authoring
13
+ */
14
+ constructor(rta) {
15
+ this.rta = rta;
16
+ }
17
+
18
+ /**
19
+ * Generates command based on given values
20
+ *
21
+ * @param runtimeControl Managed object
22
+ * @param commandName Command name
23
+ * @param modifiedValue Modified value/s
24
+ * @param designMetadata Design time metadata
25
+ * @param flexSettings Additional flex settings
26
+ */
27
+ async getCommand(runtimeControl, commandName, modifiedValue, designMetadata, flexSettings) {
28
+ try {
29
+ return await CommandFactory.getCommandFor(runtimeControl, commandName, modifiedValue, designMetadata, flexSettings);
30
+ } catch (e) {
31
+ const errorMsg = `Could not get command for '${commandName}'. ${e.message}`;
32
+ MessageToast.show(errorMsg);
33
+ throw new Error(errorMsg);
34
+ }
35
+ }
36
+
37
+ /**
38
+ * Pushed and executes the provided command
39
+ *
40
+ * @param command Command
41
+ */
42
+ async pushAndExecuteCommand(command) {
43
+ try {
44
+ /**
45
+ * The change will have pending state and will only be saved to the workspace when the user clicks save icon
46
+ */
47
+ await this.rta.getCommandStack().pushAndExecute(command);
48
+ } catch (e) {
49
+ MessageToast.show(e.message);
50
+ throw new Error(e.message);
51
+ }
52
+ }
53
+ }
54
+ return CommandExecutor;
42
55
  });
43
56
  //# sourceMappingURL=command-executor.js.map
@@ -4,6 +4,7 @@ import CommandFactory from 'sap/ui/rta/command/CommandFactory';
4
4
  import type RuntimeAuthoring from 'sap/ui/rta/RuntimeAuthoring';
5
5
  import type { FlexSettings } from 'sap/ui/rta/RuntimeAuthoring';
6
6
  import type DesignTimeMetadata from 'sap/ui/dt/DesignTimeMetadata';
7
+ import type FlexCommand from 'sap/ui/rta/command/FlexCommand';
7
8
 
8
9
  type CommandNames = 'addXML';
9
10
 
@@ -18,7 +19,7 @@ export default class CommandExecutor {
18
19
  constructor(private readonly rta: RuntimeAuthoring) {}
19
20
 
20
21
  /**
21
- * Generates command based on given values and executes it
22
+ * Generates command based on given values
22
23
  *
23
24
  * @param runtimeControl Managed object
24
25
  * @param commandName Command name
@@ -26,22 +27,35 @@ export default class CommandExecutor {
26
27
  * @param designMetadata Design time metadata
27
28
  * @param flexSettings Additional flex settings
28
29
  */
29
- public async generateAndExecuteCommand(
30
+ public async getCommand(
30
31
  runtimeControl: ManagedObject,
31
32
  commandName: CommandNames,
32
33
  modifiedValue: object,
33
34
  designMetadata: DesignTimeMetadata,
34
35
  flexSettings: FlexSettings
35
- ): Promise<void> {
36
+ ): Promise<FlexCommand> {
36
37
  try {
37
- const command = await CommandFactory.getCommandFor(
38
+ return await CommandFactory.getCommandFor(
38
39
  runtimeControl,
39
40
  commandName,
40
41
  modifiedValue,
41
42
  designMetadata,
42
43
  flexSettings
43
44
  );
45
+ } catch (e) {
46
+ const errorMsg = `Could not get command for '${commandName}'. ${e.message}`;
47
+ MessageToast.show(errorMsg);
48
+ throw new Error(errorMsg);
49
+ }
50
+ }
44
51
 
52
+ /**
53
+ * Pushed and executes the provided command
54
+ *
55
+ * @param command Command
56
+ */
57
+ public async pushAndExecuteCommand(command: FlexCommand): Promise<void> {
58
+ try {
45
59
  /**
46
60
  * The change will have pending state and will only be saved to the workspace when the user clicks save icon
47
61
  */
@@ -1,46 +1,46 @@
1
- "use strict";
2
-
3
- sap.ui.define([], function () {
4
- "use strict";
5
-
6
- /**
7
- * Handles calling control specific functions for retrieving control data
8
- */
9
- class ControlUtils {
10
- /**
11
- * Returns ManagedObject runtime control
12
- *
13
- * @param overlayControl Overlay
14
- * @returns {ManagedObject} Managed Object instance
15
- */
16
- static getRuntimeControl(overlayControl) {
17
- let runtimeControl;
18
- if (overlayControl.getElementInstance) {
19
- runtimeControl = overlayControl.getElementInstance();
20
- } else {
21
- runtimeControl = overlayControl.getElement();
22
- }
23
- return runtimeControl;
24
- }
25
-
26
- /**
27
- * Returns control aggregation names in an array
28
- *
29
- * @param control Managed Object runtime control
30
- * @param name Aggregation name
31
- * @returns Array of control aggregations
32
- */
33
- static getControlAggregationByName(control, name) {
34
- let result = [];
35
- const aggregation = (control ? control.getMetadata().getAllAggregations() : {})[name];
36
- if (aggregation) {
37
- // This executes a _sGetter function that can vary from control to control (_sGetter can be: getContent, getItems, etc)
38
- const names = aggregation._sGetter && control[aggregation._sGetter]() || [];
39
- result = Array.isArray(names) ? names : [names];
40
- }
41
- return result;
42
- }
43
- }
44
- return ControlUtils;
1
+ "use strict";
2
+
3
+ sap.ui.define([], function () {
4
+ "use strict";
5
+
6
+ /**
7
+ * Handles calling control specific functions for retrieving control data
8
+ */
9
+ class ControlUtils {
10
+ /**
11
+ * Returns ManagedObject runtime control
12
+ *
13
+ * @param overlayControl Overlay
14
+ * @returns {ManagedObject} Managed Object instance
15
+ */
16
+ static getRuntimeControl(overlayControl) {
17
+ let runtimeControl;
18
+ if (overlayControl.getElementInstance) {
19
+ runtimeControl = overlayControl.getElementInstance();
20
+ } else {
21
+ runtimeControl = overlayControl.getElement();
22
+ }
23
+ return runtimeControl;
24
+ }
25
+
26
+ /**
27
+ * Returns control aggregation names in an array
28
+ *
29
+ * @param control Managed Object runtime control
30
+ * @param name Aggregation name
31
+ * @returns Array of control aggregations
32
+ */
33
+ static getControlAggregationByName(control, name) {
34
+ let result = [];
35
+ const aggregation = (control ? control.getMetadata().getAllAggregations() : {})[name];
36
+ if (aggregation) {
37
+ // This executes a _sGetter function that can vary from control to control (_sGetter can be: getContent, getItems, etc)
38
+ const names = aggregation._sGetter && control[aggregation._sGetter]() || [];
39
+ result = Array.isArray(names) ? names : [names];
40
+ }
41
+ return result;
42
+ }
43
+ }
44
+ return ControlUtils;
45
45
  });
46
46
  //# sourceMappingURL=control-utils.js.map