@sap-ux/fe-fpm-writer 0.11.0 → 0.13.1
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 -7
- package/dist/action/types.d.ts +2 -7
- package/dist/building-block/index.d.ts +12 -0
- package/dist/building-block/index.js +157 -0
- package/dist/building-block/types.d.ts +351 -0
- package/dist/building-block/types.js +15 -0
- package/dist/column/index.js +8 -9
- package/dist/column/types.d.ts +2 -7
- package/dist/common/event-handler.d.ts +14 -0
- package/dist/common/event-handler.js +58 -0
- package/dist/common/types.d.ts +51 -0
- package/dist/common/utils.d.ts +24 -0
- package/dist/common/utils.js +56 -0
- package/dist/common/validate.d.ts +7 -0
- package/dist/common/validate.js +11 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +5 -1
- package/dist/section/index.js +8 -12
- package/dist/section/types.d.ts +2 -7
- package/dist/view/index.js +8 -12
- package/dist/view/types.d.ts +2 -7
- package/package.json +9 -5
- package/templates/action/manifest.action.json +1 -1
- package/templates/building-block/chart/View.xml +9 -0
- package/templates/building-block/field/View.xml +8 -0
- package/templates/building-block/filter-bar/View.xml +7 -0
- package/templates/common/EventHandler.js +1 -1
- package/dist/action/index.d.ts.map +0 -1
- package/dist/action/index.js.map +0 -1
- package/dist/action/types.d.ts.map +0 -1
- package/dist/action/types.js.map +0 -1
- package/dist/app/index.d.ts.map +0 -1
- package/dist/app/index.js.map +0 -1
- package/dist/column/index.d.ts.map +0 -1
- package/dist/column/index.js.map +0 -1
- package/dist/column/types.d.ts.map +0 -1
- package/dist/column/types.js.map +0 -1
- package/dist/common/defaults.d.ts.map +0 -1
- package/dist/common/defaults.js.map +0 -1
- package/dist/common/types.d.ts.map +0 -1
- package/dist/common/types.js.map +0 -1
- package/dist/common/validate.d.ts.map +0 -1
- package/dist/common/validate.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/page/common.d.ts.map +0 -1
- package/dist/page/common.js.map +0 -1
- package/dist/page/custom.d.ts.map +0 -1
- package/dist/page/custom.js.map +0 -1
- package/dist/page/index.d.ts.map +0 -1
- package/dist/page/index.js.map +0 -1
- package/dist/page/list.d.ts.map +0 -1
- package/dist/page/list.js.map +0 -1
- package/dist/page/object.d.ts.map +0 -1
- package/dist/page/object.js.map +0 -1
- package/dist/page/types.d.ts.map +0 -1
- package/dist/page/types.js.map +0 -1
- package/dist/section/index.d.ts.map +0 -1
- package/dist/section/index.js.map +0 -1
- package/dist/section/types.d.ts.map +0 -1
- package/dist/section/types.js.map +0 -1
- package/dist/view/index.d.ts.map +0 -1
- package/dist/view/index.js.map +0 -1
- package/dist/view/types.d.ts.map +0 -1
- package/dist/view/types.js.map +0 -1
package/dist/action/index.js
CHANGED
|
@@ -8,6 +8,7 @@ const path_1 = require("path");
|
|
|
8
8
|
const ejs_1 = require("ejs");
|
|
9
9
|
const validate_1 = require("../common/validate");
|
|
10
10
|
const defaults_1 = require("../common/defaults");
|
|
11
|
+
const event_handler_1 = require("../common/event-handler");
|
|
11
12
|
/**
|
|
12
13
|
* Enhances the provided custom action configuration with default data.
|
|
13
14
|
*
|
|
@@ -74,13 +75,9 @@ function generateCustomAction(basePath, actionConfig, fs) {
|
|
|
74
75
|
const manifest = fs.readJSON(manifestPath);
|
|
75
76
|
const config = enhanceConfig(actionConfig, manifestPath, manifest);
|
|
76
77
|
const root = path_1.join(__dirname, '../../templates');
|
|
77
|
-
//
|
|
78
|
-
if (config.
|
|
79
|
-
|
|
80
|
-
if (!fs.exists(controllerPath)) {
|
|
81
|
-
fs.copyTpl(path_1.join(root, 'common/EventHandler.js'), controllerPath, config);
|
|
82
|
-
}
|
|
83
|
-
config.settings.eventHandler = `${config.ns}.${config.name}.onPress`;
|
|
78
|
+
// Apply event handler
|
|
79
|
+
if (config.eventHandler) {
|
|
80
|
+
config.eventHandler = event_handler_1.applyEventHandlerConfiguration(fs, root, config, config.eventHandler);
|
|
84
81
|
}
|
|
85
82
|
// enhance manifest with action definition and controller reference
|
|
86
83
|
const actions = enhanceManifestAndGetActionsElementReference(manifest, config.target);
|
package/dist/action/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CustomElement, InternalCustomElement, Position } from '../common/types';
|
|
1
|
+
import type { CustomElement, InternalCustomElement, Position, EventHandler } from '../common/types';
|
|
2
2
|
export declare enum TargetControl {
|
|
3
3
|
header = "header",
|
|
4
4
|
footer = "footer",
|
|
@@ -11,7 +11,7 @@ export interface CustomActionTarget {
|
|
|
11
11
|
navProperty?: string;
|
|
12
12
|
qualifier?: string;
|
|
13
13
|
}
|
|
14
|
-
export interface CustomAction extends CustomElement {
|
|
14
|
+
export interface CustomAction extends CustomElement, EventHandler {
|
|
15
15
|
target: CustomActionTarget;
|
|
16
16
|
settings: {
|
|
17
17
|
text: string;
|
|
@@ -19,11 +19,6 @@ export interface CustomAction extends CustomElement {
|
|
|
19
19
|
enabled?: string | true;
|
|
20
20
|
requiresSelection?: boolean;
|
|
21
21
|
position?: Position;
|
|
22
|
-
/**
|
|
23
|
-
* If not set (i.e. undefined) then no event handler is linked. If it is set true, a new one is created and linked to the action.
|
|
24
|
-
* If an existing event handler is to be used then its id needs to be provided as string.
|
|
25
|
-
*/
|
|
26
|
-
eventHandler?: string | true;
|
|
27
22
|
};
|
|
28
23
|
}
|
|
29
24
|
export declare type InternalCustomAction = CustomAction & InternalCustomElement;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Editor } from 'mem-fs-editor';
|
|
2
|
+
import type { BuildingBlock, BuildingBlockConfig } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Generates a building block into the provided xml view file.
|
|
5
|
+
*
|
|
6
|
+
* @param {string} basePath - the base path
|
|
7
|
+
* @param {BuildingBlockConfig} config - the building block configuration parameters
|
|
8
|
+
* @param {Editor} [fs] - the memfs editor instance
|
|
9
|
+
* @returns {Editor} the updated memfs editor instance
|
|
10
|
+
*/
|
|
11
|
+
export declare function generateBuildingBlock<T extends BuildingBlock>(basePath: string, config: BuildingBlockConfig<T>, fs?: Editor): Editor;
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
22
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
|
+
};
|
|
24
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
exports.generateBuildingBlock = void 0;
|
|
26
|
+
const mem_fs_1 = require("mem-fs");
|
|
27
|
+
const mem_fs_editor_1 = require("mem-fs-editor");
|
|
28
|
+
const ejs_1 = require("ejs");
|
|
29
|
+
const path_1 = require("path");
|
|
30
|
+
const xmldom_1 = require("@xmldom/xmldom");
|
|
31
|
+
const xpath = __importStar(require("xpath"));
|
|
32
|
+
const xml_formatter_1 = __importDefault(require("xml-formatter"));
|
|
33
|
+
const validate_1 = require("../common/validate");
|
|
34
|
+
/**
|
|
35
|
+
* Generates a building block into the provided xml view file.
|
|
36
|
+
*
|
|
37
|
+
* @param {string} basePath - the base path
|
|
38
|
+
* @param {BuildingBlockConfig} config - the building block configuration parameters
|
|
39
|
+
* @param {Editor} [fs] - the memfs editor instance
|
|
40
|
+
* @returns {Editor} the updated memfs editor instance
|
|
41
|
+
*/
|
|
42
|
+
function generateBuildingBlock(basePath, config, fs) {
|
|
43
|
+
// Validate the base and view paths
|
|
44
|
+
if (!fs) {
|
|
45
|
+
fs = mem_fs_editor_1.create(mem_fs_1.create());
|
|
46
|
+
}
|
|
47
|
+
validate_1.validateBasePath(basePath, fs);
|
|
48
|
+
if (!fs.exists(path_1.join(basePath, config.viewOrFragmentPath))) {
|
|
49
|
+
throw new Error(`Invalid view path ${config.viewOrFragmentPath}.`);
|
|
50
|
+
}
|
|
51
|
+
// Read the view xml and template files and update contents of the view xml file
|
|
52
|
+
const xmlDocument = getUI5XmlDocument(basePath, config.viewOrFragmentPath, fs);
|
|
53
|
+
const templateDocument = getTemplateDocument(config.buildingBlockData, xmlDocument, fs);
|
|
54
|
+
fs = updateViewFile(basePath, config.viewOrFragmentPath, config.aggregationPath, xmlDocument, templateDocument, fs);
|
|
55
|
+
return fs;
|
|
56
|
+
}
|
|
57
|
+
exports.generateBuildingBlock = generateBuildingBlock;
|
|
58
|
+
/**
|
|
59
|
+
* Returns the UI5 xml file document (view/fragment).
|
|
60
|
+
*
|
|
61
|
+
* @param {string} basePath - the base path
|
|
62
|
+
* @param {string} viewPath - the path of the xml view relative to the base path
|
|
63
|
+
* @param {Editor} fs - the memfs editor instance
|
|
64
|
+
* @returns {Document} the view xml file document
|
|
65
|
+
*/
|
|
66
|
+
function getUI5XmlDocument(basePath, viewPath, fs) {
|
|
67
|
+
let viewContent;
|
|
68
|
+
try {
|
|
69
|
+
viewContent = fs.read(path_1.join(basePath, viewPath));
|
|
70
|
+
}
|
|
71
|
+
catch (error) {
|
|
72
|
+
throw new Error(`Unable to read xml view file. Details: ${validate_1.getErrorMessage(error)}`);
|
|
73
|
+
}
|
|
74
|
+
const errorHandler = (level, message) => {
|
|
75
|
+
throw new Error(`Unable to parse xml view file. Details: [${level}] - ${message}`);
|
|
76
|
+
};
|
|
77
|
+
// Parse the xml view content
|
|
78
|
+
let viewDocument;
|
|
79
|
+
try {
|
|
80
|
+
viewDocument = new xmldom_1.DOMParser({ errorHandler }).parseFromString(viewContent);
|
|
81
|
+
}
|
|
82
|
+
catch (error) {
|
|
83
|
+
throw new Error(`Unable to parse xml view file. Details: ${validate_1.getErrorMessage(error)}`);
|
|
84
|
+
}
|
|
85
|
+
return viewDocument;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Returns the macros namespace from the xml document if it exists or creates a new one and returns it.
|
|
89
|
+
*
|
|
90
|
+
* @param {Document} ui5XmlDocument - the view/fragment xml file document
|
|
91
|
+
* @returns {string} the macros namespace
|
|
92
|
+
*/
|
|
93
|
+
function getOrAddMacrosNamespace(ui5XmlDocument) {
|
|
94
|
+
const namespaceMap = ui5XmlDocument.firstChild._nsMap;
|
|
95
|
+
const macrosNamespaceEntry = Object.entries(namespaceMap).find(([_, value]) => value === 'sap.fe.macros');
|
|
96
|
+
if (!macrosNamespaceEntry) {
|
|
97
|
+
ui5XmlDocument.firstChild._nsMap['macros'] = 'sap.fe.macros';
|
|
98
|
+
}
|
|
99
|
+
return macrosNamespaceEntry ? macrosNamespaceEntry[0] : 'macros';
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Returns the template xml file document.
|
|
103
|
+
*
|
|
104
|
+
* @param {BuildingBlock} buildingBlockData - the building block data
|
|
105
|
+
* @param {Document} viewDocument - the view xml file document
|
|
106
|
+
* @param {Editor} fs - the memfs editor instance
|
|
107
|
+
* @returns {Document} the template xml file document
|
|
108
|
+
*/
|
|
109
|
+
function getTemplateDocument(buildingBlockData, viewDocument, fs) {
|
|
110
|
+
const templateFolderName = buildingBlockData.buildingBlockType;
|
|
111
|
+
const templateFilePath = path_1.join(__dirname, `../../templates/building-block/${templateFolderName}/View.xml`);
|
|
112
|
+
const templateContent = ejs_1.render(fs.read(templateFilePath), {
|
|
113
|
+
macrosNamespace: getOrAddMacrosNamespace(viewDocument),
|
|
114
|
+
data: buildingBlockData
|
|
115
|
+
});
|
|
116
|
+
const errorHandler = (level, message) => {
|
|
117
|
+
throw new Error(`Unable to parse template file with building block data. Details: [${level}] - ${message}`);
|
|
118
|
+
};
|
|
119
|
+
// Parse the rendered template content
|
|
120
|
+
let templateDocument;
|
|
121
|
+
try {
|
|
122
|
+
templateDocument = new xmldom_1.DOMParser({ errorHandler }).parseFromString(templateContent);
|
|
123
|
+
}
|
|
124
|
+
catch (error) {
|
|
125
|
+
throw new Error(`Unable to parse template file with building block data. Details: ${validate_1.getErrorMessage(error)}`);
|
|
126
|
+
}
|
|
127
|
+
return templateDocument;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Updates the view file by inserting the template as a child of the element specified in the aggregated xpath.
|
|
131
|
+
*
|
|
132
|
+
* @param {string} basePath - the base path
|
|
133
|
+
* @param {string} viewPath - the path of the xml view relative to the base path
|
|
134
|
+
* @param {string} aggregationPath - the aggregation xpath
|
|
135
|
+
* @param {Document} viewDocument - the view xml document
|
|
136
|
+
* @param {Document} templateDocument - the template xml document
|
|
137
|
+
* @param {Editor} [fs] - the memfs editor instance
|
|
138
|
+
* @returns {Editor} the updated memfs editor instance
|
|
139
|
+
*/
|
|
140
|
+
function updateViewFile(basePath, viewPath, aggregationPath, viewDocument, templateDocument, fs) {
|
|
141
|
+
const xpathSelect = xpath.useNamespaces(viewDocument.firstChild._nsMap);
|
|
142
|
+
// Find target aggregated element and append template as child
|
|
143
|
+
const targetNodes = xpathSelect(aggregationPath, viewDocument);
|
|
144
|
+
if (targetNodes && targetNodes.length > 0) {
|
|
145
|
+
const targetNode = targetNodes[0];
|
|
146
|
+
const sourceNode = viewDocument.importNode(templateDocument.documentElement, true);
|
|
147
|
+
targetNode.appendChild(sourceNode);
|
|
148
|
+
// Serialize and format new view xml document
|
|
149
|
+
const newXmlContent = new xmldom_1.XMLSerializer().serializeToString(viewDocument);
|
|
150
|
+
fs.write(path_1.join(basePath, viewPath), xml_formatter_1.default(newXmlContent));
|
|
151
|
+
}
|
|
152
|
+
else {
|
|
153
|
+
throw new Error(`Aggregation control not found ${aggregationPath}.`);
|
|
154
|
+
}
|
|
155
|
+
return fs;
|
|
156
|
+
}
|
|
157
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,351 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Building block type.
|
|
3
|
+
*
|
|
4
|
+
* @enum {string}
|
|
5
|
+
*/
|
|
6
|
+
export declare enum BuildingBlockType {
|
|
7
|
+
FilterBar = "filter-bar",
|
|
8
|
+
Chart = "chart",
|
|
9
|
+
Field = "field"
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Represents a building block control.
|
|
13
|
+
*/
|
|
14
|
+
export interface BuildingBlock {
|
|
15
|
+
/**
|
|
16
|
+
* Building block type.
|
|
17
|
+
*/
|
|
18
|
+
buildingBlockType: BuildingBlockType;
|
|
19
|
+
/**
|
|
20
|
+
* Defines the path of the context used in the current page or block. This setting is defined by the framework.
|
|
21
|
+
*/
|
|
22
|
+
contextPath?: string;
|
|
23
|
+
/**
|
|
24
|
+
* ID of the building block.
|
|
25
|
+
*/
|
|
26
|
+
id: string;
|
|
27
|
+
/**
|
|
28
|
+
* Defines the relative path of the property in the metamodel, based on the current contextPath.
|
|
29
|
+
*/
|
|
30
|
+
metaPath?: string;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Represents a Chart building block control.
|
|
34
|
+
* Usually, a contextPath and metaPath is expected.
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* <macro:Chart id="Mychart" contextPath="/RootEntity" metaPath="@com.sap.vocabularies.UI.v1.Chart" />
|
|
38
|
+
* @extends {BuildingBlock}
|
|
39
|
+
*/
|
|
40
|
+
export interface Chart extends BuildingBlock {
|
|
41
|
+
/**
|
|
42
|
+
* ID of the FilterBar building block associated with the chart.
|
|
43
|
+
*/
|
|
44
|
+
filterBar?: string;
|
|
45
|
+
/**
|
|
46
|
+
* Sets the personalization of the chart
|
|
47
|
+
*/
|
|
48
|
+
personalization?: boolean | string;
|
|
49
|
+
/**
|
|
50
|
+
* Specifies the selection mode.
|
|
51
|
+
*/
|
|
52
|
+
selectionMode?: string;
|
|
53
|
+
/**
|
|
54
|
+
* An event triggered when chart selections are changed.
|
|
55
|
+
* The event contains information about the data selected/deselected and the Boolean flag that indicates
|
|
56
|
+
* whether data is selected or deselected.
|
|
57
|
+
*/
|
|
58
|
+
selectionChange?: string;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Represents a custom filter to be used inside the FilterBar.
|
|
62
|
+
* The template for the FilterField has to be provided as the default aggregation.
|
|
63
|
+
*/
|
|
64
|
+
export interface FilterField {
|
|
65
|
+
/**
|
|
66
|
+
* Reference to the key of another filter already displayed in the table to properly place this one.
|
|
67
|
+
*/
|
|
68
|
+
anchor: string;
|
|
69
|
+
/**
|
|
70
|
+
* The property name of the FilterField.
|
|
71
|
+
*/
|
|
72
|
+
key: string;
|
|
73
|
+
/**
|
|
74
|
+
* The text that will be displayed for this FilterField.
|
|
75
|
+
*/
|
|
76
|
+
label: string;
|
|
77
|
+
/**
|
|
78
|
+
* If set the search will be automatically triggered, when a filter value was changed.
|
|
79
|
+
*/
|
|
80
|
+
liveMode: boolean;
|
|
81
|
+
/**
|
|
82
|
+
* Defines where this filter should be placed relative to the defined anchor.
|
|
83
|
+
* Allowed values are `Before` and `After`.
|
|
84
|
+
*/
|
|
85
|
+
placement: 'Before' | 'After';
|
|
86
|
+
/**
|
|
87
|
+
* Parameter which sets the visibility of the FilterBar building block.
|
|
88
|
+
*/
|
|
89
|
+
visible: boolean;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Represents a Filter Bar building block control.
|
|
93
|
+
* Usually, a SelectionFields annotation is expected.
|
|
94
|
+
*
|
|
95
|
+
* @example
|
|
96
|
+
* <macro:FilterBar id="MyFilterBar" metaPath="@com.sap.vocabularies.UI.v1.SelectionFields" />
|
|
97
|
+
* @extends {BuildingBlock}
|
|
98
|
+
*/
|
|
99
|
+
export interface FilterBar extends BuildingBlock {
|
|
100
|
+
/**
|
|
101
|
+
* This event is fired after either a filter value or the visibility of a filter item has been changed.
|
|
102
|
+
* The event contains conditions that will be used as filters.
|
|
103
|
+
*/
|
|
104
|
+
filterChanged?: string;
|
|
105
|
+
/**
|
|
106
|
+
* This event is fired when the Go button is pressed or after a condition change.
|
|
107
|
+
*/
|
|
108
|
+
search?: string;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Represents the format options for a field control.
|
|
112
|
+
*/
|
|
113
|
+
export interface FieldFormatOptions {
|
|
114
|
+
/**
|
|
115
|
+
* Defines how the field value and associated text will be displayed together.
|
|
116
|
+
* Allowed values are "Value", "Description", "ValueDescription" and "DescriptionValue"
|
|
117
|
+
*/
|
|
118
|
+
displayMode?: 'Value' | 'Description' | 'ValueDescription' | 'DescriptionValue';
|
|
119
|
+
/**
|
|
120
|
+
* Defines if and how the field measure will be displayed.
|
|
121
|
+
* Allowed values are "Hidden" and "ReadOnly"
|
|
122
|
+
*/
|
|
123
|
+
measureDisplayMode?: 'Hidden' | 'ReadOnly';
|
|
124
|
+
/**
|
|
125
|
+
* Defines how the full text will be displayed.
|
|
126
|
+
* Allowed values are "InPlace" and "Popover"
|
|
127
|
+
*/
|
|
128
|
+
textExpandBehaviorDisplay?: 'InPlace' | 'Popover';
|
|
129
|
+
/**
|
|
130
|
+
* Maximum number of lines for multiline texts in edit mode.
|
|
131
|
+
*/
|
|
132
|
+
textLinesEdit?: number;
|
|
133
|
+
/**
|
|
134
|
+
* Maximum number of characters from the beginning of the text field that are shown initially.
|
|
135
|
+
*/
|
|
136
|
+
textMaxCharactersDisplay?: number;
|
|
137
|
+
/**
|
|
138
|
+
* Maximum number of lines that multiline texts in edit mode can grow to.
|
|
139
|
+
*/
|
|
140
|
+
textMaxLines?: number;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Building block for creating a field based on the metadata provided by OData V4.
|
|
144
|
+
* Usually, a DataField or DataPoint annotation is expected, but the field can also be used to display
|
|
145
|
+
* a property from the entity type.
|
|
146
|
+
*
|
|
147
|
+
* @example
|
|
148
|
+
* <macro:Field id="MyField" metaPath="MyProperty" />
|
|
149
|
+
* @extends {BuildingBlock}
|
|
150
|
+
*/
|
|
151
|
+
export interface Field extends BuildingBlock {
|
|
152
|
+
/**
|
|
153
|
+
* A set of format options that can be configured.
|
|
154
|
+
*/
|
|
155
|
+
formatOptions?: FieldFormatOptions;
|
|
156
|
+
/**
|
|
157
|
+
* An expression that allows you to control the read-only state of the field.
|
|
158
|
+
* If you do not set any expression, SAP Fiori elements hooks into the standard lifecycle
|
|
159
|
+
* to determine the current state.
|
|
160
|
+
*/
|
|
161
|
+
readOnly?: boolean;
|
|
162
|
+
/**
|
|
163
|
+
* Option to add semantic objects to a field.
|
|
164
|
+
* Valid options are either a single semantic object, a stringified array of semantic objects
|
|
165
|
+
* or a single binding expression returning either a single semantic object or an array of semantic objects
|
|
166
|
+
*/
|
|
167
|
+
semanticObject?: string;
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Building block for creating a Form based on the metadata provided by OData V4.
|
|
171
|
+
* It is designed to work based on a FieldGroup annotation but can also work if you provide a
|
|
172
|
+
* ReferenceFacet or a CollectionFacet.
|
|
173
|
+
*
|
|
174
|
+
* @example
|
|
175
|
+
* <macro:Form id="MyForm" metaPath="@com.sap.vocabularies.UI.v1.FieldGroup#GeneralInformation" />
|
|
176
|
+
* @extends {BuildingBlock}
|
|
177
|
+
*/
|
|
178
|
+
export interface Form extends BuildingBlock {
|
|
179
|
+
/**
|
|
180
|
+
* The title of the form control.
|
|
181
|
+
*/
|
|
182
|
+
title?: string;
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Building block used to create a form element containing a label and a field.
|
|
186
|
+
*
|
|
187
|
+
* @extends {BuildingBlock}
|
|
188
|
+
*/
|
|
189
|
+
export interface FormElement extends BuildingBlock {
|
|
190
|
+
/**
|
|
191
|
+
* Label shown for the field. If not set, the label from the annotations will be shown.
|
|
192
|
+
*/
|
|
193
|
+
label: string;
|
|
194
|
+
/**
|
|
195
|
+
* If set to false, the FormElement is not rendered.
|
|
196
|
+
*/
|
|
197
|
+
visible: boolean;
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Building block used to create a micro chart based on the metadata provided by OData V4.
|
|
201
|
+
*
|
|
202
|
+
* @extends {BuildingBlock}
|
|
203
|
+
*/
|
|
204
|
+
export interface MicroChart extends BuildingBlock {
|
|
205
|
+
/**
|
|
206
|
+
* Batch group ID along with which this call should be grouped.
|
|
207
|
+
*/
|
|
208
|
+
batchGroupId?: string;
|
|
209
|
+
/**
|
|
210
|
+
* Show blank space in case there is no data in the chart.
|
|
211
|
+
*/
|
|
212
|
+
hideOnNoData?: boolean;
|
|
213
|
+
/**
|
|
214
|
+
* To control the rendering of Title, Subtitle and Currency Labels. When the size is xs then we do not see
|
|
215
|
+
* the inner labels of the micro chart as well.
|
|
216
|
+
*/
|
|
217
|
+
showOnlyChart?: boolean;
|
|
218
|
+
/**
|
|
219
|
+
* Size of the micro chart control.
|
|
220
|
+
*/
|
|
221
|
+
size?: string;
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* Building block used to create a paginator control.
|
|
225
|
+
*
|
|
226
|
+
* @example
|
|
227
|
+
* <macro:Paginator id="someID" />
|
|
228
|
+
* @extends {BuildingBlock}
|
|
229
|
+
*/
|
|
230
|
+
export declare type Paginator = BuildingBlock;
|
|
231
|
+
/**
|
|
232
|
+
* Building block used to create the share functionality.
|
|
233
|
+
* Please note that the 'Share in SAP Jam' option is only available on platforms that are integrated with SAP Jam.
|
|
234
|
+
* If you are consuming this macro in an environment where the SAP Fiori launchpad is not available,
|
|
235
|
+
* then the 'Save as Tile' option is not visible.
|
|
236
|
+
*
|
|
237
|
+
* @example
|
|
238
|
+
* <macro:Share id="someID" visible="true" />
|
|
239
|
+
* @extends {BuildingBlock}
|
|
240
|
+
*/
|
|
241
|
+
export interface Share extends BuildingBlock {
|
|
242
|
+
/**
|
|
243
|
+
* If set to false, the share control is not rendered.
|
|
244
|
+
*/
|
|
245
|
+
visible: boolean;
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* Building block used to create a table based on the metadata provided by OData V4.
|
|
249
|
+
* Usually, a LineItem or PresentationVariant annotation is expected,
|
|
250
|
+
* but the table building block can also be used to display an EntitySet.
|
|
251
|
+
*
|
|
252
|
+
* @example
|
|
253
|
+
* <macro:Table id="MyTable" metaPath="@com.sap.vocabularies.UI.v1.LineItem" />
|
|
254
|
+
* @extends {BuildingBlock}
|
|
255
|
+
*/
|
|
256
|
+
export interface Table extends BuildingBlock {
|
|
257
|
+
/**
|
|
258
|
+
* An expression that allows you to control the 'busy' state of the table.
|
|
259
|
+
*/
|
|
260
|
+
busy?: boolean;
|
|
261
|
+
/**
|
|
262
|
+
* Specifies the header text that is shown in the table.
|
|
263
|
+
*/
|
|
264
|
+
enableAutoColumnWidth?: boolean;
|
|
265
|
+
/**
|
|
266
|
+
* Controls if the export functionality of the table is enabled or not.
|
|
267
|
+
* Default value is true.
|
|
268
|
+
*/
|
|
269
|
+
enableExport?: boolean;
|
|
270
|
+
/**
|
|
271
|
+
* Controls whether the table can be opened in fullscreen mode or not.
|
|
272
|
+
*/
|
|
273
|
+
enableFullScreen?: boolean;
|
|
274
|
+
/**
|
|
275
|
+
* Controls if the paste functionality of the table is enabled or not.
|
|
276
|
+
*/
|
|
277
|
+
enablePaste?: boolean;
|
|
278
|
+
/**
|
|
279
|
+
* ID of the FilterBar building block associated with the table.
|
|
280
|
+
*/
|
|
281
|
+
filterBar?: string;
|
|
282
|
+
/**
|
|
283
|
+
* Specifies the header text that is shown in the table.
|
|
284
|
+
*/
|
|
285
|
+
header?: string;
|
|
286
|
+
/**
|
|
287
|
+
* Controls if the header text should be shown or not.
|
|
288
|
+
* Default value is true.
|
|
289
|
+
*/
|
|
290
|
+
headerVisible?: boolean;
|
|
291
|
+
/**
|
|
292
|
+
* Defines whether to display the search action.
|
|
293
|
+
*/
|
|
294
|
+
isSearchable?: boolean;
|
|
295
|
+
/**
|
|
296
|
+
* Groups menu actions by key.
|
|
297
|
+
*/
|
|
298
|
+
menu?: string;
|
|
299
|
+
/**
|
|
300
|
+
* Controls which options should be enabled for the table personalization dialog.
|
|
301
|
+
* If it is set to `true`, all possible options for this kind of table are enabled.
|
|
302
|
+
* If it is set to `false`, personalization is disabled.
|
|
303
|
+
* You can also provide a more granular control for the personalization by providing a comma-separated list
|
|
304
|
+
* with the options you want to be available.
|
|
305
|
+
* Available options are: `Sort`, `Column` and `Filter`
|
|
306
|
+
*/
|
|
307
|
+
personalization?: boolean | 'Sort' | 'Column' | 'Filter';
|
|
308
|
+
/**
|
|
309
|
+
* An expression that allows you to control the 'read-only' state of the table.
|
|
310
|
+
* If you do not set any expression, SAP Fiori elements hooks into the standard lifecycle to determine
|
|
311
|
+
* the current state.
|
|
312
|
+
*/
|
|
313
|
+
readOnly?: boolean;
|
|
314
|
+
/**
|
|
315
|
+
* Defines the selection mode to be used by the table.
|
|
316
|
+
* Allowed values are `None`, `Single`, `Multi` or `Auto`
|
|
317
|
+
*/
|
|
318
|
+
selectionMode?: 'None' | 'Single' | 'Multi' | 'Auto';
|
|
319
|
+
/**
|
|
320
|
+
* Defines the type of table that will be used by the building block to render the data.
|
|
321
|
+
* Allowed values are `GridTable` and `ResponsiveTable`.
|
|
322
|
+
* Default value is `ResponsiveTable`.
|
|
323
|
+
*/
|
|
324
|
+
type?: 'GridTable' | 'ResponsiveTable';
|
|
325
|
+
/**
|
|
326
|
+
* Controls the kind of variant management that should be enabled for the table.
|
|
327
|
+
* Allowed values are `Page`, `Control` and `None`.
|
|
328
|
+
* If the table is used within a SAP Fiori elements template, the default value will be taken from
|
|
329
|
+
* the current page variant management.
|
|
330
|
+
* Otherwise it's `None`.
|
|
331
|
+
*/
|
|
332
|
+
variantManagement?: string;
|
|
333
|
+
}
|
|
334
|
+
/**
|
|
335
|
+
* Input configuration for the generate function.
|
|
336
|
+
*/
|
|
337
|
+
export interface BuildingBlockConfig<T extends BuildingBlock> {
|
|
338
|
+
/**
|
|
339
|
+
* The path of the view or fragment xml file relative to the base path.
|
|
340
|
+
*/
|
|
341
|
+
viewOrFragmentPath: string;
|
|
342
|
+
/**
|
|
343
|
+
* The aggregation xpath.
|
|
344
|
+
*/
|
|
345
|
+
aggregationPath: string;
|
|
346
|
+
/**
|
|
347
|
+
* The building block parameters.
|
|
348
|
+
*/
|
|
349
|
+
buildingBlockData: T;
|
|
350
|
+
}
|
|
351
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BuildingBlockType = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Building block type.
|
|
6
|
+
*
|
|
7
|
+
* @enum {string}
|
|
8
|
+
*/
|
|
9
|
+
var BuildingBlockType;
|
|
10
|
+
(function (BuildingBlockType) {
|
|
11
|
+
BuildingBlockType["FilterBar"] = "filter-bar";
|
|
12
|
+
BuildingBlockType["Chart"] = "chart";
|
|
13
|
+
BuildingBlockType["Field"] = "field";
|
|
14
|
+
})(BuildingBlockType = exports.BuildingBlockType || (exports.BuildingBlockType = {}));
|
|
15
|
+
//# sourceMappingURL=types.js.map
|
package/dist/column/index.js
CHANGED
|
@@ -7,6 +7,7 @@ const mem_fs_editor_1 = require("mem-fs-editor");
|
|
|
7
7
|
const path_1 = require("path");
|
|
8
8
|
const defaults_1 = require("../common/defaults");
|
|
9
9
|
const validate_1 = require("../common/validate");
|
|
10
|
+
const event_handler_1 = require("../common/event-handler");
|
|
10
11
|
/**
|
|
11
12
|
* Get the template folder for the given UI5 version.
|
|
12
13
|
*
|
|
@@ -28,18 +29,20 @@ exports.getManifestRoot = getManifestRoot;
|
|
|
28
29
|
/**
|
|
29
30
|
* Enhances the provided custom table column configuration with default data.
|
|
30
31
|
*
|
|
32
|
+
* @param {Editor} fs - the mem-fs editor instance
|
|
33
|
+
* @param {string} root - root path
|
|
31
34
|
* @param {CustomTableColumn} data - a custom column configuration object
|
|
32
35
|
* @param {string} manifestPath - path to the project's manifest.json
|
|
33
36
|
* @param {Manifest} manifest - the application manifest
|
|
34
37
|
* @returns enhanced configuration
|
|
35
38
|
*/
|
|
36
|
-
function enhanceConfig(data, manifestPath, manifest) {
|
|
39
|
+
function enhanceConfig(fs, root, data, manifestPath, manifest) {
|
|
37
40
|
// clone input and set defaults
|
|
38
41
|
const config = Object.assign({}, data);
|
|
39
42
|
defaults_1.setCommonDefaults(config, manifestPath, manifest);
|
|
40
|
-
//
|
|
41
|
-
if (config.eventHandler
|
|
42
|
-
config.eventHandler =
|
|
43
|
+
// Apply event handler
|
|
44
|
+
if (config.eventHandler) {
|
|
45
|
+
config.eventHandler = event_handler_1.applyEventHandlerConfiguration(fs, root, config, config.eventHandler);
|
|
43
46
|
}
|
|
44
47
|
// generate column content
|
|
45
48
|
const content = config.properties && config.properties.length > 0
|
|
@@ -66,11 +69,7 @@ function generateCustomColumn(basePath, customColumn, fs) {
|
|
|
66
69
|
const manifest = fs.readJSON(manifestPath);
|
|
67
70
|
const root = path_1.join(__dirname, '../../templates');
|
|
68
71
|
// merge with defaults
|
|
69
|
-
const completeColumn = enhanceConfig(customColumn, manifestPath, manifest);
|
|
70
|
-
// add event handler if requested
|
|
71
|
-
if (completeColumn.eventHandler) {
|
|
72
|
-
fs.copyTpl(path_1.join(root, 'common/EventHandler.js'), path_1.join(completeColumn.path, `${completeColumn.name}.js`), completeColumn);
|
|
73
|
-
}
|
|
72
|
+
const completeColumn = enhanceConfig(fs, root, customColumn, manifestPath, manifest);
|
|
74
73
|
// enhance manifest with column definition
|
|
75
74
|
const manifestRoot = getManifestRoot(customColumn.ui5Version);
|
|
76
75
|
const filledTemplate = ejs_1.render(fs.read(path_1.join(manifestRoot, `manifest.json`)), completeColumn);
|
package/dist/column/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CustomElement, InternalCustomElement, Position } from '../common/types';
|
|
1
|
+
import type { CustomElement, InternalCustomElement, Position, EventHandler } from '../common/types';
|
|
2
2
|
export declare enum Availability {
|
|
3
3
|
'Default' = "Default",
|
|
4
4
|
'Adaptation' = "Adaptation",
|
|
@@ -14,7 +14,7 @@ export declare type ColumnPropertiesType = string[];
|
|
|
14
14
|
* Custom Column.
|
|
15
15
|
*
|
|
16
16
|
*/
|
|
17
|
-
export interface CustomTableColumn extends CustomElement {
|
|
17
|
+
export interface CustomTableColumn extends CustomElement, EventHandler {
|
|
18
18
|
/**
|
|
19
19
|
* Name of the routing target
|
|
20
20
|
*/
|
|
@@ -31,11 +31,6 @@ export interface CustomTableColumn extends CustomElement {
|
|
|
31
31
|
* The header is shown on the table as header, as well as in the add/remove dialog.
|
|
32
32
|
*/
|
|
33
33
|
header: string;
|
|
34
|
-
/**
|
|
35
|
-
* If not set (i.e. undefined) then no event handler is linked. If it is set true, a new one is created and linked to the action.
|
|
36
|
-
* If an existing event handler is to be used then its id needs to be provided as string.
|
|
37
|
-
*/
|
|
38
|
-
eventHandler?: string | true;
|
|
39
34
|
/**
|
|
40
35
|
* Optional control XML that will be generated into the fragment of table column. If the property isn't provided then a sample control will be generated.
|
|
41
36
|
*/
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Editor } from 'mem-fs-editor';
|
|
2
|
+
import type { EventHandlerConfiguration, InternalCustomElement } from '../common/types';
|
|
3
|
+
/**
|
|
4
|
+
* Method creates or updates handler js file and update 'settings.eventHandler' entry with namespace path entry to method.
|
|
5
|
+
*
|
|
6
|
+
* @param {Editor} fs - the memfs editor instance
|
|
7
|
+
* @param {string} root - the root path
|
|
8
|
+
* @param {InternalCustomElement} config - configuration
|
|
9
|
+
* @param {EventHandlerConfiguration | true | string} [eventHandler] - eventHandler for creation
|
|
10
|
+
* @param {boolean} [controllerSuffix=false] - append controller suffix to new file
|
|
11
|
+
* @returns {string} full namespace path to method
|
|
12
|
+
*/
|
|
13
|
+
export declare function applyEventHandlerConfiguration(fs: Editor, root: string, config: Partial<InternalCustomElement>, eventHandler: EventHandlerConfiguration | true | string, controllerSuffix?: boolean): string;
|
|
14
|
+
//# sourceMappingURL=event-handler.d.ts.map
|