@sap-ux/preview-middleware 0.16.160 → 0.16.163

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 (78) hide show
  1. package/dist/base/flex.js +28 -7
  2. package/dist/client/adp/api-handler.js +164 -142
  3. package/dist/client/adp/api-handler.ts +31 -0
  4. package/dist/client/adp/command-executor.js +75 -75
  5. package/dist/client/adp/control-utils.js +44 -44
  6. package/dist/client/adp/controllers/BaseDialog.controller.js +187 -187
  7. package/dist/client/adp/controllers/BaseDialog.controller.ts +1 -2
  8. package/dist/client/adp/controllers/ControllerExtension.controller.js +213 -213
  9. package/dist/client/adp/controllers/ExtensionPoint.controller.js +138 -138
  10. package/dist/client/adp/controllers/FileExistsDialog.controller.js +71 -0
  11. package/dist/client/adp/controllers/FileExistsDialog.controller.ts +92 -0
  12. package/dist/client/adp/dialog-factory.js +122 -113
  13. package/dist/client/adp/dialog-factory.ts +15 -7
  14. package/dist/client/adp/init-dialogs.js +100 -100
  15. package/dist/client/adp/quick-actions/common/add-controller-to-page.js +55 -55
  16. package/dist/client/adp/quick-actions/common/add-new-annotation-file.js +118 -0
  17. package/dist/client/adp/quick-actions/common/add-new-annotation-file.ts +141 -0
  18. package/dist/client/adp/quick-actions/common/create-page-action.js +50 -50
  19. package/dist/client/adp/quick-actions/common/op-add-custom-section.js +36 -36
  20. package/dist/client/adp/quick-actions/common/op-add-header-field.js +48 -48
  21. package/dist/client/adp/quick-actions/common/utils.js +18 -18
  22. package/dist/client/adp/quick-actions/control-types.js +21 -21
  23. package/dist/client/adp/quick-actions/dialog-enablement-validator.js +24 -24
  24. package/dist/client/adp/quick-actions/enablement-validator.js +4 -4
  25. package/dist/client/adp/quick-actions/fe-v2/change-table-columns.js +101 -101
  26. package/dist/client/adp/quick-actions/fe-v2/create-table-action.js +70 -70
  27. package/dist/client/adp/quick-actions/fe-v2/create-table-custom-column.js +96 -96
  28. package/dist/client/adp/quick-actions/fe-v2/lr-enable-semantic-date-range-filter-bar.js +60 -60
  29. package/dist/client/adp/quick-actions/fe-v2/lr-enable-table-filtering.js +77 -77
  30. package/dist/client/adp/quick-actions/fe-v2/lr-toggle-clear-filter-bar.js +57 -57
  31. package/dist/client/adp/quick-actions/fe-v2/op-enable-empty-row-mode.js +93 -93
  32. package/dist/client/adp/quick-actions/fe-v2/registry.js +73 -72
  33. package/dist/client/adp/quick-actions/fe-v2/registry.ts +5 -2
  34. package/dist/client/adp/quick-actions/fe-v2/utils.js +95 -95
  35. package/dist/client/adp/quick-actions/fe-v4/change-table-columns.js +49 -49
  36. package/dist/client/adp/quick-actions/fe-v4/create-table-action.js +47 -47
  37. package/dist/client/adp/quick-actions/fe-v4/create-table-custom-column.js +46 -46
  38. package/dist/client/adp/quick-actions/fe-v4/lr-enable-semantic-date-range-filter-bar.js +55 -55
  39. package/dist/client/adp/quick-actions/fe-v4/lr-enable-table-filtering.js +82 -82
  40. package/dist/client/adp/quick-actions/fe-v4/lr-toggle-clear-filter-bar.js +52 -52
  41. package/dist/client/adp/quick-actions/fe-v4/op-enable-empty-row-mode.js +89 -89
  42. package/dist/client/adp/quick-actions/fe-v4/registry.js +57 -56
  43. package/dist/client/adp/quick-actions/fe-v4/registry.ts +5 -2
  44. package/dist/client/adp/quick-actions/fe-v4/utils.js +47 -47
  45. package/dist/client/adp/quick-actions/load.js +44 -44
  46. package/dist/client/adp/quick-actions/quick-action-base.js +53 -53
  47. package/dist/client/adp/ui/FileExistsDialog.fragment.xml +33 -0
  48. package/dist/client/adp/utils.js +160 -160
  49. package/dist/client/cpe/changes/index.js +10 -10
  50. package/dist/client/cpe/changes/service.js +8 -3
  51. package/dist/client/cpe/changes/service.ts +14 -3
  52. package/dist/client/cpe/changes/validator.js +34 -34
  53. package/dist/client/cpe/documentation.js +164 -164
  54. package/dist/client/cpe/feature-service.js +36 -36
  55. package/dist/client/cpe/logger.js +30 -30
  56. package/dist/client/cpe/outline/editable.js +37 -37
  57. package/dist/client/cpe/outline/nodes.js +222 -217
  58. package/dist/client/cpe/outline/nodes.ts +64 -58
  59. package/dist/client/cpe/quick-actions/quick-action-definition.js +4 -4
  60. package/dist/client/cpe/quick-actions/registry.js +143 -143
  61. package/dist/client/cpe/quick-actions/utils.js +92 -92
  62. package/dist/client/cpe/types.js +4 -4
  63. package/dist/client/cpe/ui5-utils.js +33 -33
  64. package/dist/client/cpe/utils.js +138 -138
  65. package/dist/client/flp/WorkspaceConnector.js +86 -86
  66. package/dist/client/flp/common.js +28 -28
  67. package/dist/client/flp/enableFakeConnector.js +83 -83
  68. package/dist/client/flp/initConnectors.js +30 -30
  69. package/dist/client/flp/initRta.js +178 -178
  70. package/dist/client/i18n.js +56 -56
  71. package/dist/client/messagebundle.properties +9 -0
  72. package/dist/client/tsconfig.tsbuildinfo +1 -0
  73. package/dist/client/utils/application.js +32 -32
  74. package/dist/client/utils/core.js +68 -68
  75. package/dist/client/utils/error.js +19 -19
  76. package/dist/client/utils/fe-v4.js +118 -118
  77. package/dist/client/utils/version.js +102 -102
  78. package/package.json +4 -4
package/dist/base/flex.js CHANGED
@@ -14,7 +14,7 @@ const path_1 = require("path");
14
14
  */
15
15
  async function readChanges(project, logger) {
16
16
  const changes = {};
17
- const files = await project.byGlob('/**/changes/*.*');
17
+ const files = await project.byGlob('/**/changes/**/*.*');
18
18
  for (const file of files) {
19
19
  try {
20
20
  changes[`sap.ui.fl.${(0, path_1.parse)(file.getName()).name}`] = JSON.parse(await file.getString());
@@ -65,16 +65,37 @@ function deleteChange(data, webappPath, logger) {
65
65
  if (fileName) {
66
66
  const path = (0, path_1.join)(webappPath, 'changes');
67
67
  if ((0, fs_1.existsSync)(path)) {
68
- const files = (0, fs_1.readdirSync)(path);
69
- const file = files.find((element) => element.includes(fileName));
70
- if (file) {
71
- logger.debug(`Write change ${file}`);
72
- const filePath = (0, path_1.join)(path, file);
68
+ // Changes can be in subfolders of changes directory. For eg: New Annotation File Change
69
+ const files = [];
70
+ readDirectoriesRecursively(path, files);
71
+ const filePath = files.find((element) => element.includes(fileName));
72
+ if (filePath) {
73
+ const fileNameWithExt = filePath.split(path_1.sep).pop();
74
+ logger.debug(`Write change ${fileNameWithExt}`);
73
75
  (0, fs_1.unlinkSync)(filePath);
74
- return { success: true, message: `FILE_DELETED ${file}` };
76
+ return { success: true, message: `FILE_DELETED ${fileNameWithExt}` };
75
77
  }
76
78
  }
77
79
  }
78
80
  return { success: false };
79
81
  }
82
+ /**
83
+ * Recursively find all files in the given folder.
84
+ *
85
+ * @param path path to the folder.
86
+ * @param files all files in the given folder and subfolders.
87
+ */
88
+ function readDirectoriesRecursively(path, files = []) {
89
+ const items = (0, fs_1.readdirSync)(path);
90
+ items.forEach((item) => {
91
+ const fullPath = (0, path_1.join)(path, item);
92
+ const stats = (0, fs_1.statSync)(fullPath);
93
+ if (stats.isDirectory()) {
94
+ readDirectoriesRecursively(fullPath, files);
95
+ }
96
+ else if (stats.isFile()) {
97
+ files.push(fullPath);
98
+ }
99
+ });
100
+ }
80
101
  //# sourceMappingURL=flex.js.map
@@ -1,144 +1,166 @@
1
- "use strict";
2
-
3
- sap.ui.define(["../utils/error"], function (___utils_error) {
4
- "use strict";
5
-
6
- const getError = ___utils_error["getError"];
7
- var ApiEndpoints = /*#__PURE__*/function (ApiEndpoints) {
8
- ApiEndpoints["CHANGES"] = "/preview/api/changes";
9
- ApiEndpoints["FRAGMENT"] = "/adp/api/fragment";
10
- ApiEndpoints["CONTROLLER"] = "/adp/api/controller";
11
- ApiEndpoints["CODE_EXT"] = "/adp/api/code_ext";
12
- ApiEndpoints["MANIFEST_APP_DESCRIPTOR"] = "/manifest.appdescr_variant";
13
- return ApiEndpoints;
14
- }(ApiEndpoints || {});
15
- var RequestMethod = /*#__PURE__*/function (RequestMethod) {
16
- RequestMethod["GET"] = "GET";
17
- RequestMethod["PUT"] = "PUT";
18
- RequestMethod["POST"] = "POST";
19
- RequestMethod["PATCH"] = "PATCH";
20
- RequestMethod["DELETE"] = "DELETE";
21
- return RequestMethod;
22
- }(RequestMethod || {});
23
- /**
24
- * Requests a given endpoint
25
- *
26
- * @param endpoint API Endpoint
27
- * @param method RequestMethod
28
- * @param data Data to be sent to the server
29
- * @returns Data from the server request
30
- */
31
- async function request(endpoint, method, data) {
32
- const config = {
33
- method,
34
- body: JSON.stringify(data),
35
- headers: {
36
- 'content-type': 'application/json'
37
- }
38
- };
39
- try {
40
- const response = await fetch(endpoint, config);
41
- if (!response.ok) {
42
- const errorData = await response.json();
43
- const message = errorData?.message ?? '';
44
- throw new Error(`Request failed, status: ${response.status}. ${message}`.trim());
45
- }
46
- switch (method) {
47
- case RequestMethod.GET:
48
- return response.json();
49
- case RequestMethod.POST:
50
- /**
51
- * Since POST usually creates something
52
- * and returns nothing (or a message) we just parse the text from res.send(msg)
53
- */
54
- return response.text();
55
- default:
56
- return response.json();
57
- }
58
- } catch (e) {
59
- throw getError(e);
60
- }
61
- }
62
-
63
- /**
64
- * Retrieves all XML fragments from the project's workspace
65
- *
66
- * @returns Generic Promise<T>
67
- */
68
- async function getFragments() {
69
- return request(ApiEndpoints.FRAGMENT, RequestMethod.GET);
70
- }
71
-
72
- /**
73
- * Writes an XML fragment to the project's workspace
74
- *
75
- * @param data Data to be send to the server
76
- * @returns Generic Promise<T>
77
- */
78
- async function writeFragment(data) {
79
- return request(ApiEndpoints.FRAGMENT, RequestMethod.POST, data);
80
- }
81
-
82
- /**
83
- * Retrieves manifest.appdescr_variant from the project's workspace
84
- *
85
- * @returns Generic Promise<T>
86
- */
87
- async function getManifestAppdescr() {
88
- return request(ApiEndpoints.MANIFEST_APP_DESCRIPTOR, RequestMethod.GET);
89
- }
90
-
91
- /**
92
- * Retrieves all controller extensions from the project's workspace
93
- *
94
- * @returns Generic Promise<T>
95
- */
96
- async function readControllers() {
97
- return request(ApiEndpoints.CONTROLLER, RequestMethod.GET);
98
- }
99
-
100
- /**
101
- * Writes a Controller to the project's workspace
102
- *
103
- * @param data Data to be send to the server
104
- * @returns Generic Promise<T>
105
- */
106
- async function writeController(data) {
107
- return request(ApiEndpoints.CONTROLLER, RequestMethod.POST, data);
108
- }
109
-
110
- /**
111
- * Checks for existing controller in the project's workspace
112
- *
113
- * @param controllerName Name of the controller
114
- * @returns {CodeExtResponse} Returns path to existing controller if found
115
- */
116
- async function getExistingController(controllerName) {
117
- return request(`${ApiEndpoints.CODE_EXT}/${controllerName}`, RequestMethod.GET);
118
- }
119
-
120
- /**
121
- * Writes a change object to the project's workspace
122
- *
123
- * @param data Data to be send to the server
124
- * @returns Generic Promise<T>
125
- */
126
- async function writeChange(data) {
127
- return request(ApiEndpoints.CHANGES, RequestMethod.POST, data);
128
- }
129
- var __exports = {
130
- __esModule: true
131
- };
132
- __exports.ApiEndpoints = ApiEndpoints;
133
- __exports.RequestMethod = RequestMethod;
134
- __exports.request = request;
135
- __exports.getFragments = getFragments;
136
- __exports.writeFragment = writeFragment;
137
- __exports.getManifestAppdescr = getManifestAppdescr;
138
- __exports.readControllers = readControllers;
139
- __exports.writeController = writeController;
140
- __exports.getExistingController = getExistingController;
141
- __exports.writeChange = writeChange;
142
- return __exports;
1
+ "use strict";
2
+
3
+ sap.ui.define(["../utils/error"], function (___utils_error) {
4
+ "use strict";
5
+
6
+ const getError = ___utils_error["getError"];
7
+ var ApiEndpoints = /*#__PURE__*/function (ApiEndpoints) {
8
+ ApiEndpoints["CHANGES"] = "/preview/api/changes";
9
+ ApiEndpoints["FRAGMENT"] = "/adp/api/fragment";
10
+ ApiEndpoints["CONTROLLER"] = "/adp/api/controller";
11
+ ApiEndpoints["CODE_EXT"] = "/adp/api/code_ext";
12
+ ApiEndpoints["ANNOTATION_FILE"] = "/adp/api/annotation";
13
+ ApiEndpoints["MANIFEST_APP_DESCRIPTOR"] = "/manifest.appdescr_variant";
14
+ return ApiEndpoints;
15
+ }(ApiEndpoints || {});
16
+ var RequestMethod = /*#__PURE__*/function (RequestMethod) {
17
+ RequestMethod["GET"] = "GET";
18
+ RequestMethod["PUT"] = "PUT";
19
+ RequestMethod["POST"] = "POST";
20
+ RequestMethod["PATCH"] = "PATCH";
21
+ RequestMethod["DELETE"] = "DELETE";
22
+ return RequestMethod;
23
+ }(RequestMethod || {});
24
+ /**
25
+ * Requests a given endpoint
26
+ *
27
+ * @param endpoint API Endpoint
28
+ * @param method RequestMethod
29
+ * @param data Data to be sent to the server
30
+ * @returns Data from the server request
31
+ */
32
+ async function request(endpoint, method, data) {
33
+ const config = {
34
+ method,
35
+ body: JSON.stringify(data),
36
+ headers: {
37
+ 'content-type': 'application/json'
38
+ }
39
+ };
40
+ try {
41
+ const response = await fetch(endpoint, config);
42
+ if (!response.ok) {
43
+ const errorData = await response.json();
44
+ const message = errorData?.message ?? '';
45
+ throw new Error(`Request failed, status: ${response.status}. ${message}`.trim());
46
+ }
47
+ switch (method) {
48
+ case RequestMethod.GET:
49
+ return response.json();
50
+ case RequestMethod.POST:
51
+ /**
52
+ * Since POST usually creates something
53
+ * and returns nothing (or a message) we just parse the text from res.send(msg)
54
+ */
55
+ return response.text();
56
+ default:
57
+ return response.json();
58
+ }
59
+ } catch (e) {
60
+ throw getError(e);
61
+ }
62
+ }
63
+
64
+ /**
65
+ * Retrieves all XML fragments from the project's workspace
66
+ *
67
+ * @returns Generic Promise<T>
68
+ */
69
+ async function getFragments() {
70
+ return request(ApiEndpoints.FRAGMENT, RequestMethod.GET);
71
+ }
72
+
73
+ /**
74
+ * Writes an XML fragment to the project's workspace
75
+ *
76
+ * @param data Data to be send to the server
77
+ * @returns Generic Promise<T>
78
+ */
79
+ async function writeFragment(data) {
80
+ return request(ApiEndpoints.FRAGMENT, RequestMethod.POST, data);
81
+ }
82
+
83
+ /**
84
+ * Retrieves manifest.appdescr_variant from the project's workspace
85
+ *
86
+ * @returns Generic Promise<T>
87
+ */
88
+ async function getManifestAppdescr() {
89
+ return request(ApiEndpoints.MANIFEST_APP_DESCRIPTOR, RequestMethod.GET);
90
+ }
91
+
92
+ /**
93
+ * Retrieves all controller extensions from the project's workspace
94
+ *
95
+ * @returns Generic Promise<T>
96
+ */
97
+ async function readControllers() {
98
+ return request(ApiEndpoints.CONTROLLER, RequestMethod.GET);
99
+ }
100
+
101
+ /**
102
+ * Writes a Controller to the project's workspace
103
+ *
104
+ * @param data Data to be send to the server
105
+ * @returns Generic Promise<T>
106
+ */
107
+ async function writeController(data) {
108
+ return request(ApiEndpoints.CONTROLLER, RequestMethod.POST, data);
109
+ }
110
+
111
+ /**
112
+ * Writes a new annotation file to the project's workspace
113
+ *
114
+ * @param data Data to be send to the server
115
+ * @returns Generic Promise<T>
116
+ */
117
+ async function writeAnnotationFile(data) {
118
+ return request(ApiEndpoints.ANNOTATION_FILE, RequestMethod.POST, data);
119
+ }
120
+
121
+ /**
122
+ * Writes a new annotation file to the project's workspace
123
+ *
124
+ * @returns Generic Promise<DataSoruceAnnotationMap>
125
+ */
126
+ async function getDataSourceAnnotationFileMap() {
127
+ return request(ApiEndpoints.ANNOTATION_FILE, RequestMethod.GET);
128
+ }
129
+
130
+ /**
131
+ * Checks for existing controller in the project's workspace
132
+ *
133
+ * @param controllerName Name of the controller
134
+ * @returns {CodeExtResponse} Returns path to existing controller if found
135
+ */
136
+ async function getExistingController(controllerName) {
137
+ return request(`${ApiEndpoints.CODE_EXT}/${controllerName}`, RequestMethod.GET);
138
+ }
139
+
140
+ /**
141
+ * Writes a change object to the project's workspace
142
+ *
143
+ * @param data Data to be send to the server
144
+ * @returns Generic Promise<T>
145
+ */
146
+ async function writeChange(data) {
147
+ return request(ApiEndpoints.CHANGES, RequestMethod.POST, data);
148
+ }
149
+ var __exports = {
150
+ __esModule: true
151
+ };
152
+ __exports.ApiEndpoints = ApiEndpoints;
153
+ __exports.RequestMethod = RequestMethod;
154
+ __exports.request = request;
155
+ __exports.getFragments = getFragments;
156
+ __exports.writeFragment = writeFragment;
157
+ __exports.getManifestAppdescr = getManifestAppdescr;
158
+ __exports.readControllers = readControllers;
159
+ __exports.writeController = writeController;
160
+ __exports.writeAnnotationFile = writeAnnotationFile;
161
+ __exports.getDataSourceAnnotationFileMap = getDataSourceAnnotationFileMap;
162
+ __exports.getExistingController = getExistingController;
163
+ __exports.writeChange = writeChange;
164
+ return __exports;
143
165
  });
144
166
  //# sourceMappingURL=api-handler.js.map
@@ -6,6 +6,7 @@ export const enum ApiEndpoints {
6
6
  FRAGMENT = '/adp/api/fragment',
7
7
  CONTROLLER = '/adp/api/controller',
8
8
  CODE_EXT = '/adp/api/code_ext',
9
+ ANNOTATION_FILE = '/adp/api/annotation',
9
10
  MANIFEST_APP_DESCRIPTOR = '/manifest.appdescr_variant'
10
11
  }
11
12
 
@@ -33,6 +34,17 @@ export interface CodeExtResponse {
33
34
  isRunningInBAS: boolean;
34
35
  }
35
36
 
37
+ export interface AnnotationFileResponse {
38
+ annotationExistsInWS: boolean;
39
+ annotationPath: string;
40
+ annotationPathFromRoot: string;
41
+ isRunningInBAS: boolean;
42
+ }
43
+
44
+ interface DataSoruceAnnotationMap {
45
+ [key: string]: { serviceUrl: string; isRunningInBAS: boolean; annotationDetails: AnnotationFileResponse };
46
+ }
47
+
36
48
  export interface ControllersResponse {
37
49
  controllers: Controllers;
38
50
  message: string;
@@ -139,6 +151,25 @@ export async function writeController<T>(data: T): Promise<T> {
139
151
  return request<T>(ApiEndpoints.CONTROLLER, RequestMethod.POST, data);
140
152
  }
141
153
 
154
+ /**
155
+ * Writes a new annotation file to the project's workspace
156
+ *
157
+ * @param data Data to be send to the server
158
+ * @returns Generic Promise<T>
159
+ */
160
+ export async function writeAnnotationFile<T>(data: T): Promise<T> {
161
+ return request<T>(ApiEndpoints.ANNOTATION_FILE, RequestMethod.POST, data);
162
+ }
163
+
164
+ /**
165
+ * Writes a new annotation file to the project's workspace
166
+ *
167
+ * @returns Generic Promise<DataSoruceAnnotationMap>
168
+ */
169
+ export async function getDataSourceAnnotationFileMap(): Promise<DataSoruceAnnotationMap> {
170
+ return request<DataSoruceAnnotationMap>(ApiEndpoints.ANNOTATION_FILE, RequestMethod.GET);
171
+ }
172
+
142
173
  /**
143
174
  * Checks for existing controller in the project's workspace
144
175
  *
@@ -1,77 +1,77 @@
1
- "use strict";
2
-
3
- sap.ui.define(["sap/m/MessageToast", "sap/ui/rta/command/CommandFactory", "../utils/error"], function (MessageToast, CommandFactory, ___utils_error) {
4
- "use strict";
5
-
6
- const getError = ___utils_error["getError"];
7
- /**
8
- * Class responsible for handling rta calls
9
- */
10
- class CommandExecutor {
11
- /**
12
- *
13
- * @param rta Runtime Authoring
14
- */
15
- constructor(rta) {
16
- this.rta = rta;
17
- }
18
-
19
- /**
20
- * Generates command based on given values
21
- *
22
- * @param runtimeControl Managed object
23
- * @param commandName Command name
24
- * @param modifiedValue Modified value/s
25
- * @param designMetadata Design time metadata
26
- * @param flexSettings Additional flex settings
27
- */
28
- async getCommand(runtimeControl, commandName, modifiedValue, designMetadata, flexSettings) {
29
- try {
30
- return await CommandFactory.getCommandFor(runtimeControl, commandName, modifiedValue, designMetadata, flexSettings);
31
- } catch (e) {
32
- const error = getError(e);
33
- const msgToastErrorMsg = `Could not get command for '${commandName}'. ${error.message}`;
34
- error.message = msgToastErrorMsg;
35
- MessageToast.show(msgToastErrorMsg);
36
- throw error;
37
- }
38
- }
39
-
40
- /**
41
- * Creates composite command without nested commands
42
- *
43
- * @param runtimeControl Managed object
44
- */
45
- async createCompositeCommand(runtimeControl) {
46
- try {
47
- return await CommandFactory.getCommandFor(runtimeControl, 'composite');
48
- } catch (e) {
49
- const error = getError(e);
50
- const msgToastErrorMsg = `Could not get composite command'. ${error.message}`;
51
- error.message = msgToastErrorMsg;
52
- MessageToast.show(msgToastErrorMsg);
53
- throw error;
54
- }
55
- }
56
-
57
- /**
58
- * Pushed and executes the provided command
59
- *
60
- * @param command Command
61
- */
62
- async pushAndExecuteCommand(command) {
63
- try {
64
- /**
65
- * The change will have pending state and will only be saved to the workspace when the user clicks save icon
66
- */
67
- await this.rta.getCommandStack().pushAndExecute(command);
68
- } catch (e) {
69
- const error = getError(e);
70
- MessageToast.show(error.message);
71
- throw error;
72
- }
73
- }
74
- }
75
- return CommandExecutor;
1
+ "use strict";
2
+
3
+ sap.ui.define(["sap/m/MessageToast", "sap/ui/rta/command/CommandFactory", "../utils/error"], function (MessageToast, CommandFactory, ___utils_error) {
4
+ "use strict";
5
+
6
+ const getError = ___utils_error["getError"];
7
+ /**
8
+ * Class responsible for handling rta calls
9
+ */
10
+ class CommandExecutor {
11
+ /**
12
+ *
13
+ * @param rta Runtime Authoring
14
+ */
15
+ constructor(rta) {
16
+ this.rta = rta;
17
+ }
18
+
19
+ /**
20
+ * Generates command based on given values
21
+ *
22
+ * @param runtimeControl Managed object
23
+ * @param commandName Command name
24
+ * @param modifiedValue Modified value/s
25
+ * @param designMetadata Design time metadata
26
+ * @param flexSettings Additional flex settings
27
+ */
28
+ async getCommand(runtimeControl, commandName, modifiedValue, designMetadata, flexSettings) {
29
+ try {
30
+ return await CommandFactory.getCommandFor(runtimeControl, commandName, modifiedValue, designMetadata, flexSettings);
31
+ } catch (e) {
32
+ const error = getError(e);
33
+ const msgToastErrorMsg = `Could not get command for '${commandName}'. ${error.message}`;
34
+ error.message = msgToastErrorMsg;
35
+ MessageToast.show(msgToastErrorMsg);
36
+ throw error;
37
+ }
38
+ }
39
+
40
+ /**
41
+ * Creates composite command without nested commands
42
+ *
43
+ * @param runtimeControl Managed object
44
+ */
45
+ async createCompositeCommand(runtimeControl) {
46
+ try {
47
+ return await CommandFactory.getCommandFor(runtimeControl, 'composite');
48
+ } catch (e) {
49
+ const error = getError(e);
50
+ const msgToastErrorMsg = `Could not get composite command'. ${error.message}`;
51
+ error.message = msgToastErrorMsg;
52
+ MessageToast.show(msgToastErrorMsg);
53
+ throw error;
54
+ }
55
+ }
56
+
57
+ /**
58
+ * Pushed and executes the provided command
59
+ *
60
+ * @param command Command
61
+ */
62
+ async pushAndExecuteCommand(command) {
63
+ try {
64
+ /**
65
+ * The change will have pending state and will only be saved to the workspace when the user clicks save icon
66
+ */
67
+ await this.rta.getCommandStack().pushAndExecute(command);
68
+ } catch (e) {
69
+ const error = getError(e);
70
+ MessageToast.show(error.message);
71
+ throw error;
72
+ }
73
+ }
74
+ }
75
+ return CommandExecutor;
76
76
  });
77
77
  //# sourceMappingURL=command-executor.js.map
@@ -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