@sap-ux/fe-fpm-writer 0.39.21 → 0.39.23
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/action/index.js +4 -0
- package/dist/action/types.d.ts +1 -0
- package/dist/action-menu/index.d.ts +12 -0
- package/dist/action-menu/index.js +79 -0
- package/dist/action-menu/types.d.ts +28 -0
- package/dist/action-menu/types.js +11 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +12 -8
- package/package.json +3 -3
- package/templates/action/manifest.action-menu.json +10 -0
package/dist/action/index.js
CHANGED
|
@@ -104,6 +104,10 @@ async function generateCustomAction(basePath, actionConfig, fs) {
|
|
|
104
104
|
// enhance manifest with action definition and controller reference
|
|
105
105
|
const actions = enhanceManifestAndGetActionsElementReference(manifest, config.target);
|
|
106
106
|
Object.assign(actions, JSON.parse((0, ejs_1.render)(fs.read((0, templates_1.getTemplatePath)(`action/manifest.action.json`)), config, {})));
|
|
107
|
+
if (config.target.menuId) {
|
|
108
|
+
// The action should be part of the menu
|
|
109
|
+
actions[config.target.menuId].menu.push(config.name);
|
|
110
|
+
}
|
|
107
111
|
fs.writeJSON(manifestPath, manifest, undefined, (0, file_1.getJsonSpace)(fs, manifestPath, actionConfig.tabInfo));
|
|
108
112
|
return fs;
|
|
109
113
|
}
|
package/dist/action/types.d.ts
CHANGED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Editor } from 'mem-fs-editor';
|
|
2
|
+
import { type ActionMenu } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Add a custom page to an existing UI5 application.
|
|
5
|
+
*
|
|
6
|
+
* @param {string} basePath - the base path
|
|
7
|
+
* @param {ActionMenu} actionMenuConfig - the custom action configuration
|
|
8
|
+
* @param {Editor} [fs] - the memfs editor instance
|
|
9
|
+
* @returns {Promise<Editor>} the updated memfs editor instance
|
|
10
|
+
*/
|
|
11
|
+
export declare function generateActionMenu(basePath: string, actionMenuConfig: ActionMenu, fs?: Editor): Promise<Editor>;
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.generateActionMenu = generateActionMenu;
|
|
4
|
+
const mem_fs_1 = require("mem-fs");
|
|
5
|
+
const mem_fs_editor_1 = require("mem-fs-editor");
|
|
6
|
+
const ejs_1 = require("ejs");
|
|
7
|
+
const validate_1 = require("../common/validate");
|
|
8
|
+
const templates_1 = require("../templates");
|
|
9
|
+
const file_1 = require("../common/file");
|
|
10
|
+
const utils_1 = require("../common/utils");
|
|
11
|
+
const action_1 = require("../action");
|
|
12
|
+
const types_1 = require("./types");
|
|
13
|
+
/**
|
|
14
|
+
* Add a custom page to an existing UI5 application.
|
|
15
|
+
*
|
|
16
|
+
* @param {string} basePath - the base path
|
|
17
|
+
* @param {ActionMenu} actionMenuConfig - the custom action configuration
|
|
18
|
+
* @param {Editor} [fs] - the memfs editor instance
|
|
19
|
+
* @returns {Promise<Editor>} the updated memfs editor instance
|
|
20
|
+
*/
|
|
21
|
+
async function generateActionMenu(basePath, actionMenuConfig, fs) {
|
|
22
|
+
(0, validate_1.validateVersion)(actionMenuConfig.minUI5Version);
|
|
23
|
+
if (!fs) {
|
|
24
|
+
fs = (0, mem_fs_editor_1.create)((0, mem_fs_1.create)());
|
|
25
|
+
}
|
|
26
|
+
await (0, validate_1.validateBasePath)(basePath, fs);
|
|
27
|
+
const { path: manifestPath, content: manifest } = await (0, utils_1.getManifest)(basePath, fs);
|
|
28
|
+
if (actionMenuConfig.target.menuId) {
|
|
29
|
+
// add new action to existing menu
|
|
30
|
+
const actionsContainer = getExistingMenuItemsContainer(manifest, actionMenuConfig.target);
|
|
31
|
+
const actionsList = actionsContainer[actionMenuConfig.target.menuId].menu;
|
|
32
|
+
actionsList.push(...actionMenuConfig.settings.actions);
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
// enhance manifest with action menu definition
|
|
36
|
+
const actionsContainer = (0, action_1.enhanceManifestAndGetActionsElementReference)(manifest, actionMenuConfig.target);
|
|
37
|
+
Object.assign(actionsContainer, JSON.parse((0, ejs_1.render)(fs.read((0, templates_1.getTemplatePath)(`action/manifest.action-menu.json`)), actionMenuConfig, {})));
|
|
38
|
+
for (const { key, position } of actionMenuConfig.positionUpdates ?? []) {
|
|
39
|
+
if (['__proto__', 'constructor', 'prototype'].includes(key)) {
|
|
40
|
+
// Prevent prototype pollution via special property names
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
const action = actionsContainer[key];
|
|
44
|
+
if (!action) {
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
action.position = position;
|
|
48
|
+
if (!position) {
|
|
49
|
+
delete action.position;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
fs.writeJSON(manifestPath, manifest, undefined, (0, file_1.getJsonSpace)(fs, manifestPath, actionMenuConfig.tabInfo));
|
|
54
|
+
return fs;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Returns actions manifest entry for a given action menu target control.
|
|
58
|
+
*
|
|
59
|
+
* @param manifest - manifest content
|
|
60
|
+
* @param target - target control
|
|
61
|
+
* @returns - manifest node - container for a menu
|
|
62
|
+
*/
|
|
63
|
+
function getExistingMenuItemsContainer(manifest, target) {
|
|
64
|
+
const page = manifest['sap.ui5'].routing.targets[target.page];
|
|
65
|
+
if (target.control === types_1.TargetControl.header) {
|
|
66
|
+
return page.options.settings.content[target.control].actions;
|
|
67
|
+
}
|
|
68
|
+
else if (target.control === types_1.TargetControl.body && target.customSectionKey) {
|
|
69
|
+
return page.options.settings.content[target.control].sections[target.customSectionKey].actions;
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
// Custom actions for other elements are defined in: 'options/settings/controlConfiguration/<element>/actions'
|
|
73
|
+
const controlPrefix = target.navProperty ? target.navProperty + '/' : '';
|
|
74
|
+
const controlSuffix = target.qualifier ? '#' + target.qualifier : '';
|
|
75
|
+
const controlId = `${controlPrefix}${target.control}${controlSuffix}`;
|
|
76
|
+
return page.options.settings.controlConfiguration[controlId].actions;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { CustomElement, Position } from '../common/types';
|
|
2
|
+
export declare enum TargetControl {
|
|
3
|
+
header = "header",
|
|
4
|
+
body = "body",
|
|
5
|
+
section = "@com.sap.vocabularies.UI.v1.FieldGroup",
|
|
6
|
+
table = "@com.sap.vocabularies.UI.v1.LineItem"
|
|
7
|
+
}
|
|
8
|
+
export interface ActionMenuTarget {
|
|
9
|
+
page: string;
|
|
10
|
+
control: TargetControl;
|
|
11
|
+
customSectionKey?: string;
|
|
12
|
+
navProperty?: string;
|
|
13
|
+
qualifier?: string;
|
|
14
|
+
menuId?: string;
|
|
15
|
+
}
|
|
16
|
+
export interface ActionMenu extends CustomElement {
|
|
17
|
+
target: ActionMenuTarget;
|
|
18
|
+
positionUpdates?: {
|
|
19
|
+
key: string;
|
|
20
|
+
position: Position | undefined;
|
|
21
|
+
}[];
|
|
22
|
+
settings: {
|
|
23
|
+
text: string;
|
|
24
|
+
actions: string[];
|
|
25
|
+
position?: Position;
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TargetControl = void 0;
|
|
4
|
+
var TargetControl;
|
|
5
|
+
(function (TargetControl) {
|
|
6
|
+
TargetControl["header"] = "header";
|
|
7
|
+
TargetControl["body"] = "body";
|
|
8
|
+
TargetControl["section"] = "@com.sap.vocabularies.UI.v1.FieldGroup";
|
|
9
|
+
TargetControl["table"] = "@com.sap.vocabularies.UI.v1.LineItem";
|
|
10
|
+
})(TargetControl || (exports.TargetControl = TargetControl = {}));
|
|
11
|
+
//# sourceMappingURL=types.js.map
|
package/dist/index.d.ts
CHANGED
|
@@ -2,6 +2,8 @@ export { CustomPage, ObjectPage, ListReport } from './page/types';
|
|
|
2
2
|
export { generateCustomPage, generateObjectPage, generateListReport } from './page';
|
|
3
3
|
export { CustomAction, TargetControl } from './action/types';
|
|
4
4
|
export { generateCustomAction } from './action';
|
|
5
|
+
export { ActionMenu, TargetControl as ActionMenuTargetControl } from './action-menu/types';
|
|
6
|
+
export { generateActionMenu } from './action-menu';
|
|
5
7
|
export { CustomTableColumn } from './column/types';
|
|
6
8
|
export { generateCustomColumn } from './column';
|
|
7
9
|
export { CustomHeaderSection, CustomSection, CustomSubSection, RequestGroupId, DesignTime } from './section/types';
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.initI18n = exports.generateCustomField = exports.generateControllerExtension = exports.ControllerExtensionPageType = exports.PromptsAPI = exports.PromptsType = exports.getSerializedFileContent = exports.generateBuildingBlock = exports.BuildingBlockType = exports.validateVersion = exports.validateBasePath = exports.enableFPM = exports.generateCustomView = exports.generateCustomFilter = exports.generateCustomHeaderSection = exports.generateCustomSubSection = exports.generateCustomSection = exports.DesignTime = exports.RequestGroupId = exports.generateCustomColumn = exports.generateCustomAction = exports.TargetControl = exports.generateListReport = exports.generateObjectPage = exports.generateCustomPage = void 0;
|
|
3
|
+
exports.initI18n = exports.generateCustomField = exports.generateControllerExtension = exports.ControllerExtensionPageType = exports.PromptsAPI = exports.PromptsType = exports.getSerializedFileContent = exports.generateBuildingBlock = exports.BuildingBlockType = exports.validateVersion = exports.validateBasePath = exports.enableFPM = exports.generateCustomView = exports.generateCustomFilter = exports.generateCustomHeaderSection = exports.generateCustomSubSection = exports.generateCustomSection = exports.DesignTime = exports.RequestGroupId = exports.generateCustomColumn = exports.generateActionMenu = exports.ActionMenuTargetControl = exports.generateCustomAction = exports.TargetControl = exports.generateListReport = exports.generateObjectPage = exports.generateCustomPage = void 0;
|
|
4
4
|
var page_1 = require("./page");
|
|
5
5
|
Object.defineProperty(exports, "generateCustomPage", { enumerable: true, get: function () { return page_1.generateCustomPage; } });
|
|
6
6
|
Object.defineProperty(exports, "generateObjectPage", { enumerable: true, get: function () { return page_1.generateObjectPage; } });
|
|
@@ -9,11 +9,15 @@ var types_1 = require("./action/types");
|
|
|
9
9
|
Object.defineProperty(exports, "TargetControl", { enumerable: true, get: function () { return types_1.TargetControl; } });
|
|
10
10
|
var action_1 = require("./action");
|
|
11
11
|
Object.defineProperty(exports, "generateCustomAction", { enumerable: true, get: function () { return action_1.generateCustomAction; } });
|
|
12
|
+
var types_2 = require("./action-menu/types");
|
|
13
|
+
Object.defineProperty(exports, "ActionMenuTargetControl", { enumerable: true, get: function () { return types_2.TargetControl; } });
|
|
14
|
+
var action_menu_1 = require("./action-menu");
|
|
15
|
+
Object.defineProperty(exports, "generateActionMenu", { enumerable: true, get: function () { return action_menu_1.generateActionMenu; } });
|
|
12
16
|
var column_1 = require("./column");
|
|
13
17
|
Object.defineProperty(exports, "generateCustomColumn", { enumerable: true, get: function () { return column_1.generateCustomColumn; } });
|
|
14
|
-
var
|
|
15
|
-
Object.defineProperty(exports, "RequestGroupId", { enumerable: true, get: function () { return
|
|
16
|
-
Object.defineProperty(exports, "DesignTime", { enumerable: true, get: function () { return
|
|
18
|
+
var types_3 = require("./section/types");
|
|
19
|
+
Object.defineProperty(exports, "RequestGroupId", { enumerable: true, get: function () { return types_3.RequestGroupId; } });
|
|
20
|
+
Object.defineProperty(exports, "DesignTime", { enumerable: true, get: function () { return types_3.DesignTime; } });
|
|
17
21
|
var section_1 = require("./section");
|
|
18
22
|
Object.defineProperty(exports, "generateCustomSection", { enumerable: true, get: function () { return section_1.generateCustomSection; } });
|
|
19
23
|
Object.defineProperty(exports, "generateCustomSubSection", { enumerable: true, get: function () { return section_1.generateCustomSubSection; } });
|
|
@@ -27,16 +31,16 @@ Object.defineProperty(exports, "enableFPM", { enumerable: true, get: function ()
|
|
|
27
31
|
var validate_1 = require("./common/validate");
|
|
28
32
|
Object.defineProperty(exports, "validateBasePath", { enumerable: true, get: function () { return validate_1.validateBasePath; } });
|
|
29
33
|
Object.defineProperty(exports, "validateVersion", { enumerable: true, get: function () { return validate_1.validateVersion; } });
|
|
30
|
-
var
|
|
31
|
-
Object.defineProperty(exports, "BuildingBlockType", { enumerable: true, get: function () { return
|
|
34
|
+
var types_4 = require("./building-block/types");
|
|
35
|
+
Object.defineProperty(exports, "BuildingBlockType", { enumerable: true, get: function () { return types_4.BuildingBlockType; } });
|
|
32
36
|
var building_block_1 = require("./building-block");
|
|
33
37
|
Object.defineProperty(exports, "generateBuildingBlock", { enumerable: true, get: function () { return building_block_1.generateBuildingBlock; } });
|
|
34
38
|
Object.defineProperty(exports, "getSerializedFileContent", { enumerable: true, get: function () { return building_block_1.getSerializedFileContent; } });
|
|
35
39
|
var prompts_1 = require("./prompts");
|
|
36
40
|
Object.defineProperty(exports, "PromptsType", { enumerable: true, get: function () { return prompts_1.PromptsType; } });
|
|
37
41
|
Object.defineProperty(exports, "PromptsAPI", { enumerable: true, get: function () { return prompts_1.PromptsAPI; } });
|
|
38
|
-
var
|
|
39
|
-
Object.defineProperty(exports, "ControllerExtensionPageType", { enumerable: true, get: function () { return
|
|
42
|
+
var types_5 = require("./controller-extension/types");
|
|
43
|
+
Object.defineProperty(exports, "ControllerExtensionPageType", { enumerable: true, get: function () { return types_5.ControllerExtensionPageType; } });
|
|
40
44
|
var controller_extension_1 = require("./controller-extension");
|
|
41
45
|
Object.defineProperty(exports, "generateControllerExtension", { enumerable: true, get: function () { return controller_extension_1.generateControllerExtension; } });
|
|
42
46
|
var field_1 = require("./field");
|
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.39.
|
|
4
|
+
"version": "0.39.23",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "https://github.com/SAP/open-ux-tools.git",
|
|
@@ -30,8 +30,8 @@
|
|
|
30
30
|
"semver": "7.5.4",
|
|
31
31
|
"xml-formatter": "2.6.1",
|
|
32
32
|
"xpath": "0.0.33",
|
|
33
|
-
"@sap-ux/fiori-annotation-api": "0.7.
|
|
34
|
-
"@sap-ux/project-access": "1.32.
|
|
33
|
+
"@sap-ux/fiori-annotation-api": "0.7.15",
|
|
34
|
+
"@sap-ux/project-access": "1.32.10",
|
|
35
35
|
"@sap-ux/logger": "0.7.1"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"<%- name %>": {
|
|
3
|
+
"text": "<%- settings.text %>",
|
|
4
|
+
"menu": <%- JSON.stringify(settings.actions) %><%if (settings.position) {%>,
|
|
5
|
+
"position": {
|
|
6
|
+
"placement": "<%- settings.position.placement %>"<%if (settings.position.anchor !== undefined) {%>,
|
|
7
|
+
"anchor": "<%- settings.position.anchor %>"<% } %>
|
|
8
|
+
}<% } %>
|
|
9
|
+
}
|
|
10
|
+
}
|