@sap-ux/fe-fpm-writer 0.18.1 → 0.18.3
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/common/types.d.ts +1 -1
- package/dist/view/index.js +43 -14
- package/dist/view/types.d.ts +4 -0
- package/package.json +3 -3
- package/templates/view/manifest.json +7 -8
package/dist/common/types.d.ts
CHANGED
package/dist/view/index.js
CHANGED
|
@@ -9,6 +9,38 @@ const validate_1 = require("../common/validate");
|
|
|
9
9
|
const defaults_1 = require("../common/defaults");
|
|
10
10
|
const event_handler_1 = require("../common/event-handler");
|
|
11
11
|
const templates_1 = require("../templates");
|
|
12
|
+
/**
|
|
13
|
+
* Merge the new view into the list of existing views (if any).
|
|
14
|
+
*
|
|
15
|
+
* @param {CustomView & Partial<InternalCustomView>} config - config for the template, views property gets updated
|
|
16
|
+
* @param {Manifest} manifest - the application manifest
|
|
17
|
+
*/
|
|
18
|
+
function mergeViews(config, manifest) {
|
|
19
|
+
var _a, _b, _c, _d, _e;
|
|
20
|
+
const newViews = {
|
|
21
|
+
paths: [
|
|
22
|
+
{
|
|
23
|
+
'key': config.key,
|
|
24
|
+
'label': config.label,
|
|
25
|
+
'template': `${config.ns}.${config.name}`
|
|
26
|
+
}
|
|
27
|
+
]
|
|
28
|
+
};
|
|
29
|
+
const existingViews = (_e = (_d = ((_c = (_b = (_a = manifest['sap.ui5']) === null || _a === void 0 ? void 0 : _a.routing) === null || _b === void 0 ? void 0 : _b.targets) === null || _c === void 0 ? void 0 : _c[config.target]).options) === null || _d === void 0 ? void 0 : _d.settings) === null || _e === void 0 ? void 0 : _e.views;
|
|
30
|
+
if (existingViews === null || existingViews === void 0 ? void 0 : existingViews.paths) {
|
|
31
|
+
const index = existingViews.paths.findIndex((entry) => entry.key === newViews.paths[0].key);
|
|
32
|
+
if (index > -1) {
|
|
33
|
+
existingViews.paths[index] = newViews.paths[0];
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
existingViews.paths.push(newViews.paths[0]);
|
|
37
|
+
}
|
|
38
|
+
config.views = existingViews;
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
config.views = newViews;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
12
44
|
/**
|
|
13
45
|
* Enhances the provided custom view configuration with default data.
|
|
14
46
|
*
|
|
@@ -19,19 +51,14 @@ const templates_1 = require("../templates");
|
|
|
19
51
|
* @returns enhanced configuration
|
|
20
52
|
*/
|
|
21
53
|
function enhanceConfig(fs, data, manifestPath, manifest) {
|
|
22
|
-
var _a, _b, _c, _d, _e;
|
|
23
54
|
const config = Object.assign({}, data);
|
|
24
55
|
defaults_1.setCommonDefaults(config, manifestPath, manifest);
|
|
25
|
-
//
|
|
56
|
+
// apply event handler
|
|
26
57
|
if (config.eventHandler) {
|
|
27
58
|
config.eventHandler = event_handler_1.applyEventHandlerConfiguration(fs, config, config.eventHandler, true, config.typescript);
|
|
28
59
|
}
|
|
29
|
-
// existing views
|
|
30
|
-
|
|
31
|
-
.options) === null || _d === void 0 ? void 0 : _d.settings) === null || _e === void 0 ? void 0 : _e.views;
|
|
32
|
-
if (existingViews) {
|
|
33
|
-
config.views = existingViews;
|
|
34
|
-
}
|
|
60
|
+
// fill config.views, merge new data into existing views
|
|
61
|
+
mergeViews(config, manifest);
|
|
35
62
|
// generate view content
|
|
36
63
|
if (typeof config.control === 'string') {
|
|
37
64
|
config.content = config.control;
|
|
@@ -63,12 +90,14 @@ function generateCustomView(basePath, customView, fs) {
|
|
|
63
90
|
const filledTemplate = ejs_1.render(fs.read(templates_1.getTemplatePath('view/manifest.json')), completeView, {});
|
|
64
91
|
fs.extendJSON(manifestPath, JSON.parse(filledTemplate));
|
|
65
92
|
// add fragment
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
fs.
|
|
93
|
+
if (customView.viewUpdate !== false) {
|
|
94
|
+
const viewPath = path_1.join(completeView.path, `${completeView.name}.fragment.xml`);
|
|
95
|
+
if (completeView.control === true) {
|
|
96
|
+
fs.copyTpl(templates_1.getTemplatePath('view/ext/CustomViewWithTable.xml'), viewPath, completeView);
|
|
97
|
+
}
|
|
98
|
+
else if (!fs.exists(viewPath)) {
|
|
99
|
+
fs.copyTpl(templates_1.getTemplatePath('common/Fragment.xml'), viewPath, completeView);
|
|
100
|
+
}
|
|
72
101
|
}
|
|
73
102
|
return fs;
|
|
74
103
|
}
|
package/dist/view/types.d.ts
CHANGED
|
@@ -17,6 +17,10 @@ export interface CustomView extends CustomElement, EventHandler {
|
|
|
17
17
|
* If set to true, a table macro control will be generated.
|
|
18
18
|
*/
|
|
19
19
|
control?: string | true;
|
|
20
|
+
/**
|
|
21
|
+
* Indicates that the view shall be created or updated
|
|
22
|
+
*/
|
|
23
|
+
viewUpdate?: boolean;
|
|
20
24
|
}
|
|
21
25
|
export interface InternalCustomView extends CustomView, InternalCustomElement {
|
|
22
26
|
content: string;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sap-ux/fe-fpm-writer",
|
|
3
3
|
"description": "SAP Fiori elements flexible programming model writer",
|
|
4
|
-
"version": "0.18.
|
|
4
|
+
"version": "0.18.3",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "https://github.com/SAP/open-ux-tools.git",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"!dist/**/*.map"
|
|
21
21
|
],
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@xmldom/xmldom": "0.8.
|
|
23
|
+
"@xmldom/xmldom": "0.8.6",
|
|
24
24
|
"ejs": "3.1.7",
|
|
25
25
|
"mem-fs": "2.1.0",
|
|
26
26
|
"mem-fs-editor": "9.4.0",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"xpath": "0.0.32"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@sap-ux/project-access": "1.0.
|
|
32
|
+
"@sap-ux/project-access": "1.0.4",
|
|
33
33
|
"@types/ejs": "3.1.0",
|
|
34
34
|
"@types/mem-fs": "1.1.2",
|
|
35
35
|
"@types/mem-fs-editor": "7.0.1",
|
|
@@ -20,17 +20,16 @@
|
|
|
20
20
|
"views": {
|
|
21
21
|
"paths": [
|
|
22
22
|
<% if (locals.views?.paths) { %>
|
|
23
|
-
<% locals.views.paths.
|
|
24
|
-
<%- JSON.stringify(
|
|
23
|
+
<% for (var i =0; i < locals.views.paths.length; i++) { %>
|
|
24
|
+
<%- JSON.stringify(locals.views.paths[i]) %>
|
|
25
|
+
<% if (i < locals.views.paths.length - 1) { %>
|
|
26
|
+
,
|
|
27
|
+
<%
|
|
28
|
+
} %>
|
|
25
29
|
<%
|
|
26
|
-
}
|
|
30
|
+
} %>
|
|
27
31
|
<%
|
|
28
32
|
} %>
|
|
29
|
-
{
|
|
30
|
-
"key": "<%- key %>",
|
|
31
|
-
"label": "<%- label %>",
|
|
32
|
-
"template": "<%- ns %>.<%- name %>"
|
|
33
|
-
}
|
|
34
33
|
]
|
|
35
34
|
}
|
|
36
35
|
}
|