@sap-ux/preview-middleware 0.13.9 → 0.13.10
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/base/flp.d.ts +11 -0
- package/dist/base/flp.js +30 -15
- package/dist/client/adp/api-handler.js +141 -141
- package/dist/client/adp/command-executor.js +54 -54
- package/dist/client/adp/control-utils.js +44 -44
- package/dist/client/adp/controllers/AddFragment.controller.js +206 -206
- package/dist/client/adp/controllers/BaseDialog.controller.js +57 -57
- package/dist/client/adp/controllers/ControllerExtension.controller.js +179 -179
- package/dist/client/adp/controllers/ExtensionPoint.controller.js +100 -100
- package/dist/client/adp/init-dialogs.js +74 -74
- package/dist/client/adp/ui5-version-utils.js +63 -63
- package/dist/client/adp/utils.js +33 -33
- package/dist/client/cpe/changes/flex-change.js +51 -51
- package/dist/client/cpe/changes/index.js +10 -10
- package/dist/client/cpe/changes/validator.js +35 -35
- package/dist/client/cpe/documentation.js +164 -164
- package/dist/client/cpe/logger.js +30 -30
- package/dist/client/cpe/outline/nodes.js +84 -84
- package/dist/client/cpe/outline/utils.js +37 -37
- package/dist/client/cpe/types.js +4 -4
- package/dist/client/cpe/ui5-utils.js +49 -49
- package/dist/client/cpe/utils.js +48 -48
- package/dist/client/flp/WorkspaceConnector.js +84 -84
- package/dist/client/flp/common.js +28 -28
- package/dist/client/flp/enableFakeConnector.js +77 -77
- package/dist/client/flp/init.js +220 -220
- package/dist/client/flp/initConnectors.js +33 -33
- package/dist/client/flp/initRta.js +178 -178
- package/package.json +1 -1
package/dist/base/flp.d.ts
CHANGED
|
@@ -121,6 +121,17 @@ export declare class FlpSandbox {
|
|
|
121
121
|
* Create required routes for flex.
|
|
122
122
|
*/
|
|
123
123
|
private createFlexHandler;
|
|
124
|
+
/**
|
|
125
|
+
* Send a response with the given content type, status and body.
|
|
126
|
+
* Ensure compliance with common APIs in express and connect.
|
|
127
|
+
*
|
|
128
|
+
* @param res the response object
|
|
129
|
+
* @param contentType the content type
|
|
130
|
+
* @param status the response status
|
|
131
|
+
* @param body the response body
|
|
132
|
+
* @private
|
|
133
|
+
*/
|
|
134
|
+
private sendResponse;
|
|
124
135
|
/**
|
|
125
136
|
* Add routes for html and scripts required for a local test FLP.
|
|
126
137
|
*
|
package/dist/base/flp.js
CHANGED
|
@@ -222,7 +222,7 @@ class FlpSandbox {
|
|
|
222
222
|
scenario,
|
|
223
223
|
livereloadPort
|
|
224
224
|
});
|
|
225
|
-
|
|
225
|
+
this.sendResponse(res, 'text/html', 200, html);
|
|
226
226
|
});
|
|
227
227
|
let path = (0, path_1.dirname)(editor.path);
|
|
228
228
|
if (!path.endsWith('/')) {
|
|
@@ -232,7 +232,7 @@ class FlpSandbox {
|
|
|
232
232
|
}
|
|
233
233
|
this.router.get(previewUrl, (_req, res) => {
|
|
234
234
|
const html = this.generateSandboxForEditor(rta, editor).replace('</body>', `</body>\n<!-- livereload disabled for editor </body>-->`);
|
|
235
|
-
|
|
235
|
+
this.sendResponse(res, 'text/html', 200, html);
|
|
236
236
|
});
|
|
237
237
|
}
|
|
238
238
|
}
|
|
@@ -251,7 +251,7 @@ class FlpSandbox {
|
|
|
251
251
|
}
|
|
252
252
|
const template = (0, fs_1.readFileSync)((0, path_1.join)(__dirname, '../../templates/flp/sandbox.html'), 'utf-8');
|
|
253
253
|
const html = (0, ejs_1.render)(template, this.templateConfig);
|
|
254
|
-
|
|
254
|
+
this.sendResponse(res, 'text/html', 200, html);
|
|
255
255
|
})));
|
|
256
256
|
}
|
|
257
257
|
/**
|
|
@@ -324,39 +324,54 @@ class FlpSandbox {
|
|
|
324
324
|
const api = `${PREVIEW_URL.api}/changes`;
|
|
325
325
|
this.router.use(api, (0, express_1.json)());
|
|
326
326
|
this.router.get(api, ((_req, res) => __awaiter(this, void 0, void 0, function* () {
|
|
327
|
-
res.
|
|
328
|
-
.contentType('application/json')
|
|
329
|
-
.send(yield (0, flex_1.readChanges)(this.project, this.logger));
|
|
327
|
+
this.sendResponse(res, 'application/json', 200, JSON.stringify(yield (0, flex_1.readChanges)(this.project, this.logger)));
|
|
330
328
|
})));
|
|
331
329
|
this.router.post(api, ((req, res) => __awaiter(this, void 0, void 0, function* () {
|
|
332
330
|
try {
|
|
333
331
|
const { success, message } = (0, flex_1.writeChange)(req.body, this.utils.getProject().getSourcePath(), this.logger);
|
|
334
332
|
if (success) {
|
|
335
|
-
|
|
333
|
+
this.sendResponse(res, 'text/plain', 200, message !== null && message !== void 0 ? message : '');
|
|
336
334
|
}
|
|
337
335
|
else {
|
|
338
|
-
|
|
336
|
+
this.sendResponse(res, 'text/plain', 400, 'INVALID_DATA');
|
|
339
337
|
}
|
|
340
338
|
}
|
|
341
339
|
catch (error) {
|
|
342
|
-
|
|
340
|
+
this.sendResponse(res, 'text/plain', 500, error.message);
|
|
343
341
|
}
|
|
344
342
|
})));
|
|
345
343
|
this.router.delete(api, ((req, res) => __awaiter(this, void 0, void 0, function* () {
|
|
346
344
|
try {
|
|
347
345
|
const { success, message } = (0, flex_1.deleteChange)(req.body, this.utils.getProject().getSourcePath(), this.logger);
|
|
348
346
|
if (success) {
|
|
349
|
-
|
|
347
|
+
this.sendResponse(res, 'text/plain', 200, message !== null && message !== void 0 ? message : '');
|
|
350
348
|
}
|
|
351
349
|
else {
|
|
352
|
-
|
|
350
|
+
this.sendResponse(res, 'text/plain', 400, 'INVALID_DATA');
|
|
353
351
|
}
|
|
354
352
|
}
|
|
355
353
|
catch (error) {
|
|
356
|
-
|
|
354
|
+
this.sendResponse(res, 'text/plain', 500, error.message);
|
|
357
355
|
}
|
|
358
356
|
})));
|
|
359
357
|
}
|
|
358
|
+
/**
|
|
359
|
+
* Send a response with the given content type, status and body.
|
|
360
|
+
* Ensure compliance with common APIs in express and connect.
|
|
361
|
+
*
|
|
362
|
+
* @param res the response object
|
|
363
|
+
* @param contentType the content type
|
|
364
|
+
* @param status the response status
|
|
365
|
+
* @param body the response body
|
|
366
|
+
* @private
|
|
367
|
+
*/
|
|
368
|
+
sendResponse(res, contentType, status, body) {
|
|
369
|
+
res.writeHead(status, {
|
|
370
|
+
'Content-Type': contentType
|
|
371
|
+
});
|
|
372
|
+
res.write(body);
|
|
373
|
+
res.end();
|
|
374
|
+
}
|
|
360
375
|
/**
|
|
361
376
|
* Add routes for html and scripts required for a local test FLP.
|
|
362
377
|
*
|
|
@@ -387,7 +402,7 @@ class FlpSandbox {
|
|
|
387
402
|
initPath: `${ns}${config.init.replace('.js', '')}`
|
|
388
403
|
};
|
|
389
404
|
const html = (0, ejs_1.render)(htmlTemplate, templateConfig);
|
|
390
|
-
|
|
405
|
+
this.sendResponse(res, 'text/html', 200, html);
|
|
391
406
|
}
|
|
392
407
|
})));
|
|
393
408
|
if (testConfig.init !== undefined) {
|
|
@@ -406,8 +421,8 @@ class FlpSandbox {
|
|
|
406
421
|
else {
|
|
407
422
|
const testFiles = yield this.project.byGlob(config.pattern);
|
|
408
423
|
const templateConfig = { tests: (0, test_1.generateImportList)(ns, testFiles) };
|
|
409
|
-
const
|
|
410
|
-
|
|
424
|
+
const js = (0, ejs_1.render)(initTemplate, templateConfig);
|
|
425
|
+
this.sendResponse(res, 'application/javascript', 200, js);
|
|
411
426
|
}
|
|
412
427
|
})));
|
|
413
428
|
}
|
|
@@ -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,56 +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
|
|
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;
|
|
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;
|
|
55
55
|
});
|
|
56
56
|
//# 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
|