@sap-ux/fe-fpm-writer 0.18.9 → 0.19.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/index.d.ts CHANGED
@@ -4,8 +4,8 @@ export { CustomAction, TargetControl } from './action/types';
4
4
  export { generateCustomAction } from './action';
5
5
  export { CustomTableColumn } from './column/types';
6
6
  export { generateCustomColumn } from './column';
7
- export { CustomSection } from './section/types';
8
- export { generateCustomSection } from './section';
7
+ export { CustomSection, CustomSubSection } from './section/types';
8
+ export { generateCustomSection, generateCustomSubSection } from './section';
9
9
  export { CustomView } from './view/types';
10
10
  export { generateCustomView } from './view';
11
11
  export { enableFPM, FPMConfig } from './app';
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.generateControllerExtension = exports.ControllerExtensionPageType = exports.generateBuildingBlock = exports.BuildingBlockType = exports.validateVersion = exports.validateBasePath = exports.enableFPM = exports.generateCustomView = exports.generateCustomSection = exports.generateCustomColumn = exports.generateCustomAction = exports.TargetControl = exports.generateListReport = exports.generateObjectPage = exports.generateCustomPage = void 0;
3
+ exports.generateControllerExtension = exports.ControllerExtensionPageType = exports.generateBuildingBlock = exports.BuildingBlockType = exports.validateVersion = exports.validateBasePath = exports.enableFPM = exports.generateCustomView = exports.generateCustomSubSection = exports.generateCustomSection = exports.generateCustomColumn = 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; } });
@@ -13,6 +13,7 @@ var column_1 = require("./column");
13
13
  Object.defineProperty(exports, "generateCustomColumn", { enumerable: true, get: function () { return column_1.generateCustomColumn; } });
14
14
  var section_1 = require("./section");
15
15
  Object.defineProperty(exports, "generateCustomSection", { enumerable: true, get: function () { return section_1.generateCustomSection; } });
16
+ Object.defineProperty(exports, "generateCustomSubSection", { enumerable: true, get: function () { return section_1.generateCustomSubSection; } });
16
17
  var view_1 = require("./view");
17
18
  Object.defineProperty(exports, "generateCustomView", { enumerable: true, get: function () { return view_1.generateCustomView; } });
18
19
  var app_1 = require("./app");
@@ -1,12 +1,13 @@
1
1
  import type { Editor } from 'mem-fs-editor';
2
- import type { CustomSection } from './types';
2
+ import type { CustomSection, CustomSubSection } from './types';
3
3
  /**
4
4
  * Get the template folder for the given UI5 version.
5
5
  *
6
+ * @param folderName template folder name.
6
7
  * @param ui5Version required UI5 version.
7
8
  * @returns path to the template folder containing the manifest.json ejs template
8
9
  */
9
- export declare function getManifestRoot(ui5Version?: string): string;
10
+ export declare function getManifestRoot(folderName: string, ui5Version?: string): string;
10
11
  /**
11
12
  * Add a custom section to an existing UI5 application.
12
13
  *
@@ -16,4 +17,13 @@ export declare function getManifestRoot(ui5Version?: string): string;
16
17
  * @returns {Promise<Editor>} the updated mem-fs editor instance
17
18
  */
18
19
  export declare function generateCustomSection(basePath: string, customSection: CustomSection, fs?: Editor): Editor;
20
+ /**
21
+ * Add a custom sub section to an existing UI5 application.
22
+ *
23
+ * @param {string} basePath - the base path
24
+ * @param {CustomSubSection} customSubSection - the custom sub section configuration
25
+ * @param {Editor} [fs] - the mem-fs editor instance
26
+ * @returns {Promise<Editor>} the updated mem-fs editor instance
27
+ */
28
+ export declare function generateCustomSubSection(basePath: string, customSubSection: CustomSubSection, fs?: Editor): Editor;
19
29
  //# sourceMappingURL=index.d.ts.map
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.generateCustomSection = exports.getManifestRoot = void 0;
3
+ exports.generateCustomSubSection = exports.generateCustomSection = exports.getManifestRoot = void 0;
4
4
  const mem_fs_1 = require("mem-fs");
5
5
  const mem_fs_editor_1 = require("mem-fs-editor");
6
6
  const path_1 = require("path");
@@ -14,16 +14,17 @@ const semver_1 = require("semver");
14
14
  /**
15
15
  * Get the template folder for the given UI5 version.
16
16
  *
17
+ * @param folderName template folder name.
17
18
  * @param ui5Version required UI5 version.
18
19
  * @returns path to the template folder containing the manifest.json ejs template
19
20
  */
20
- function getManifestRoot(ui5Version) {
21
+ function getManifestRoot(folderName, ui5Version) {
21
22
  const minVersion = (0, semver_1.coerce)(ui5Version);
22
23
  if (!minVersion || (0, semver_1.gte)(minVersion, '1.86.0')) {
23
- return (0, templates_1.getTemplatePath)('/section/1.86');
24
+ return (0, templates_1.getTemplatePath)(`/${folderName}/1.86`);
24
25
  }
25
26
  else {
26
- return (0, templates_1.getTemplatePath)('/section/1.85');
27
+ return (0, templates_1.getTemplatePath)(`/${folderName}/1.85`);
27
28
  }
28
29
  }
29
30
  exports.getManifestRoot = getManifestRoot;
@@ -60,14 +61,15 @@ function enhanceConfig(fs, data, manifestPath, manifest) {
60
61
  return config;
61
62
  }
62
63
  /**
63
- * Add a custom section to an existing UI5 application.
64
+ * Add a custom section or sub section to an existing UI5 application.
64
65
  *
65
66
  * @param {string} basePath - the base path
66
67
  * @param {CustomSection} customSection - the custom section configuration
68
+ * @param {string} manifestTemplateRoot - path to the template folder containing the manifest.json ejs template
67
69
  * @param {Editor} [fs] - the mem-fs editor instance
68
70
  * @returns {Promise<Editor>} the updated mem-fs editor instance
69
71
  */
70
- function generateCustomSection(basePath, customSection, fs) {
72
+ function generate(basePath, customSection, manifestTemplateRoot, fs) {
71
73
  (0, validate_1.validateVersion)(customSection.minUI5Version);
72
74
  if (!fs) {
73
75
  fs = (0, mem_fs_editor_1.create)((0, mem_fs_1.create)());
@@ -78,8 +80,7 @@ function generateCustomSection(basePath, customSection, fs) {
78
80
  // merge with defaults
79
81
  const completeSection = enhanceConfig(fs, customSection, manifestPath, manifest);
80
82
  // enhance manifest with section definition
81
- const manifestRoot = getManifestRoot(customSection.minUI5Version);
82
- const filledTemplate = (0, ejs_1.render)(fs.read((0, path_1.join)(manifestRoot, `manifest.json`)), completeSection, {});
83
+ const filledTemplate = (0, ejs_1.render)(fs.read((0, path_1.join)(manifestTemplateRoot, `manifest.json`)), completeSection, {});
83
84
  (0, file_1.extendJSON)(fs, {
84
85
  filepath: manifestPath,
85
86
  content: filledTemplate,
@@ -92,5 +93,30 @@ function generateCustomSection(basePath, customSection, fs) {
92
93
  }
93
94
  return fs;
94
95
  }
96
+ /**
97
+ * Add a custom section to an existing UI5 application.
98
+ *
99
+ * @param {string} basePath - the base path
100
+ * @param {CustomSection} customSection - the custom section configuration
101
+ * @param {Editor} [fs] - the mem-fs editor instance
102
+ * @returns {Promise<Editor>} the updated mem-fs editor instance
103
+ */
104
+ function generateCustomSection(basePath, customSection, fs) {
105
+ const manifestRoot = getManifestRoot('section', customSection.minUI5Version);
106
+ return generate(basePath, customSection, manifestRoot, fs);
107
+ }
95
108
  exports.generateCustomSection = generateCustomSection;
109
+ /**
110
+ * Add a custom sub section to an existing UI5 application.
111
+ *
112
+ * @param {string} basePath - the base path
113
+ * @param {CustomSubSection} customSubSection - the custom sub section configuration
114
+ * @param {Editor} [fs] - the mem-fs editor instance
115
+ * @returns {Promise<Editor>} the updated mem-fs editor instance
116
+ */
117
+ function generateCustomSubSection(basePath, customSubSection, fs) {
118
+ const manifestRoot = getManifestRoot('subsection', customSubSection.minUI5Version);
119
+ return generate(basePath, customSubSection, manifestRoot, fs);
120
+ }
121
+ exports.generateCustomSubSection = generateCustomSubSection;
96
122
  //# sourceMappingURL=index.js.map
@@ -20,8 +20,14 @@ export interface CustomSection extends CustomElement, EventHandler {
20
20
  export interface CustomSectionDependencies {
21
21
  [key: string]: string;
22
22
  }
23
- export interface InternalCustomSection extends CustomSection, InternalCustomElement {
23
+ export interface InternalCustomSection extends CustomSection, CustomSubSection, InternalCustomElement {
24
24
  content: string;
25
25
  dependencies?: CustomSectionDependencies;
26
26
  }
27
+ export interface CustomSubSection extends CustomSection {
28
+ /**
29
+ * Id of parent section.
30
+ */
31
+ parentSection: string;
32
+ }
27
33
  //# sourceMappingURL=types.d.ts.map
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.9",
4
+ "version": "0.19.1",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "https://github.com/SAP/open-ux-tools.git",
@@ -29,7 +29,7 @@
29
29
  "xpath": "0.0.32"
30
30
  },
31
31
  "devDependencies": {
32
- "@sap-ux/project-access": "1.3.1",
32
+ "@sap-ux/project-access": "1.5.0",
33
33
  "@types/ejs": "3.1.0",
34
34
  "@types/mem-fs": "1.1.2",
35
35
  "@types/mem-fs-editor": "7.0.1",
@@ -4,7 +4,7 @@ sap.ui.define([
4
4
  'use strict';
5
5
 
6
6
  return {
7
- <%- (typeof eventHandlerFnName !== 'undefined' && eventHandlerFnName) || 'onPress' %>: function(oEvent) {
7
+ <%- eventHandlerFnName %>: function(oEvent) {
8
8
  MessageToast.show("Custom handler invoked.");
9
9
  }
10
10
  };
@@ -8,6 +8,6 @@ import MessageToast from 'sap/m/MessageToast';
8
8
  * @param this reference to the 'this' that the event handler is bound to.
9
9
  * @param <%- parameters.name %> <%- parameters.description %>
10
10
  */
11
- export function <%- (typeof eventHandlerFnName !== 'undefined' && eventHandlerFnName) || 'onPress' %>(this: ExtensionAPI, <%- parameters.name %>: <%- parameters.importType %>) {
11
+ export function <%- eventHandlerFnName %>(this: ExtensionAPI, <%- parameters.name %>: <%- parameters.importType %>) {
12
12
  MessageToast.show("Custom handler invoked.");
13
13
  }
@@ -0,0 +1,37 @@
1
+ {
2
+ "sap.ui5": {
3
+ "routing": {
4
+ "targets": {
5
+ "<%- target %>": {
6
+ "options": {
7
+ "settings": {
8
+ "content": {
9
+ "body": {
10
+ "sections": {
11
+ "<%- parentSection %>": {
12
+ "subSections": {
13
+ "<%- name %>": {
14
+ "name": "<%- ns %>.<%- name %>",
15
+ "type": "XMLFragment",
16
+ "position": {
17
+ <% if (position.placement) { %>
18
+ "placement": "<%- position.placement %>",
19
+ <% } %>
20
+ <% if (position.anchor) { %>
21
+ "anchor": "<%- position.anchor %>"
22
+ <% } %>
23
+ },
24
+ "title": "<%- title %>"
25
+ }
26
+ }
27
+ }
28
+ }
29
+ }
30
+ }
31
+ }
32
+ }
33
+ }
34
+ }
35
+ }
36
+ }
37
+ }
@@ -0,0 +1,36 @@
1
+ {
2
+ "sap.ui5": {
3
+ "routing": {
4
+ "targets": {
5
+ "<%- target %>": {
6
+ "options": {
7
+ "settings": {
8
+ "content": {
9
+ "body": {
10
+ "sections": {
11
+ "<%- parentSection %>": {
12
+ "subSections": {
13
+ "<%- name %>": {
14
+ "template": "<%- ns %>.<%- name %>",
15
+ "position": {
16
+ <% if (position.placement) { %>
17
+ "placement": "<%- position.placement %>",
18
+ <% } %>
19
+ <% if (position.anchor) { %>
20
+ "anchor": "<%- position.anchor %>"
21
+ <% } %>
22
+ },
23
+ "title": "<%- title %>"
24
+ }
25
+ }
26
+ }
27
+ }
28
+ }
29
+ }
30
+ }
31
+ }
32
+ }
33
+ }
34
+ }
35
+ }
36
+ }