@sap-ux/fe-fpm-writer 0.7.0 → 0.8.0

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.
@@ -16,7 +16,8 @@ export declare function setCommonDefaults<T extends CustomElement & Partial<Inte
16
16
  * @param {string} [eventHandler] - event handler path
17
17
  * if value is passed then "Button" control with 'press' event would be generated
18
18
  * if value is not passed then "Text" control would be generated
19
+ * @param {boolean} isController - controls if `controller` should be added to handler path
19
20
  * @returns default content for fragment
20
21
  */
21
- export declare function getDefaultFragmentContent(text: string, eventHandler?: string): string;
22
+ export declare function getDefaultFragmentContent(text: string, eventHandler?: string, isController?: boolean): string;
22
23
  //# sourceMappingURL=defaults.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"defaults.d.ts","sourceRoot":"","sources":["../../src/common/defaults.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,qBAAqB,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAG9E,eAAO,MAAM,UAAU,yBAAyB,CAAC;AACjD;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,SAAS,aAAa,GAAG,OAAO,CAAC,qBAAqB,CAAC,EACtF,MAAM,EAAE,CAAC,EACT,YAAY,EAAE,MAAM,EACpB,QAAQ,EAAE,QAAQ,GACnB,qBAAqB,GAAG,CAAC,CAa3B;AAED;;;;;;;;GAQG;AACH,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM,GAAG,MAAM,CAWrF"}
1
+ {"version":3,"file":"defaults.d.ts","sourceRoot":"","sources":["../../src/common/defaults.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,qBAAqB,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAG9E,eAAO,MAAM,UAAU,yBAAyB,CAAC;AACjD;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,SAAS,aAAa,GAAG,OAAO,CAAC,qBAAqB,CAAC,EACtF,MAAM,EAAE,CAAC,EACT,YAAY,EAAE,MAAM,EACpB,QAAQ,EAAE,QAAQ,GACnB,qBAAqB,GAAG,CAAC,CAa3B;AAED;;;;;;;;;GASG;AACH,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM,EAAE,YAAY,UAAQ,GAAG,MAAM,CAW3G"}
@@ -30,14 +30,15 @@ exports.setCommonDefaults = setCommonDefaults;
30
30
  * @param {string} [eventHandler] - event handler path
31
31
  * if value is passed then "Button" control with 'press' event would be generated
32
32
  * if value is not passed then "Text" control would be generated
33
+ * @param {boolean} isController - controls if `controller` should be added to handler path
33
34
  * @returns default content for fragment
34
35
  */
35
- function getDefaultFragmentContent(text, eventHandler) {
36
+ function getDefaultFragmentContent(text, eventHandler, isController = false) {
36
37
  let content;
37
38
  if (eventHandler) {
38
39
  const parts = eventHandler.split('.');
39
40
  const method = parts.pop();
40
- const handler = parts.join('/');
41
+ const handler = `${parts.join('/')}${isController ? '.controller' : ''}`;
41
42
  content = `<Button core:require="{ handler: '${handler}'}" text="${text}" press="handler.${method}" />`;
42
43
  }
43
44
  else {
@@ -1 +1 @@
1
- {"version":3,"file":"defaults.js","sourceRoot":"","sources":["../../src/common/defaults.ts"],"names":[],"mappings":";;;AACA,+BAAqC;AAExB,QAAA,UAAU,GAAG,sBAAsB,CAAC;AACjD;;;;;;;GAOG;AACH,SAAgB,iBAAiB,CAC7B,MAAS,EACT,YAAoB,EACpB,QAAkB;IAElB,6BAA6B;IAC7B,MAAM,SAAS,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACjC,MAAM,CAAC,IAAI,GAAG,SAAS,CAAC,WAAW,EAAE,GAAG,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;IAEjE,oCAAoC;IACpC,MAAM,CAAC,MAAM,GAAG,MAAM,CAA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to the manifest that is used to generate the custom extension content (e.g. view, fragment, controoler).
14
+ * Target folder relative to the manifest that is used to generate the custom extension content (e.g. view, fragment, controller).
15
15
  * If undefined then `ext/${id}` is used.
16
16
  */
17
17
  folder?: string;
@@ -50,4 +50,48 @@ export declare type Position = {
50
50
  export interface Ui5RoutingTarget<T> extends ManifestNamespace.Target {
51
51
  options?: T;
52
52
  }
53
+ export interface ViewVariant {
54
+ /**
55
+ * The key entry is used for initializing the corresponding IconTabBar item.
56
+ */
57
+ key: string;
58
+ /**
59
+ * The annotationPath of a specific variant.
60
+ */
61
+ annotationPath: string;
62
+ /**
63
+ * View title, is shown in the tab item.
64
+ */
65
+ label?: string;
66
+ /**
67
+ * If you switch from an app with only a single table to an app with multiple tables, you can keep the previously defined variant on one tab.
68
+ */
69
+ keepPreviousPersonalization?: boolean;
70
+ /**
71
+ * The template being used for the custom view.
72
+ */
73
+ template?: string;
74
+ }
75
+ export interface Views {
76
+ /**
77
+ * The paths section contains a set of entries that point to the variants defined in the annotations.
78
+ */
79
+ paths?: Array<ViewVariant>;
80
+ /**
81
+ * Determines whether the count is displayed in the tabs (default setting: false).
82
+ */
83
+ showCounts?: boolean;
84
+ }
85
+ export interface Ui5TargetSettings {
86
+ settings?: {
87
+ /**
88
+ * Represents the entity set that defines either the aggregation or the root object of the component.
89
+ */
90
+ entitySet?: string;
91
+ /**
92
+ * By default, the list report displays only one table. You can define multiple views of a table, and add a chart, if required.
93
+ */
94
+ views?: Views;
95
+ };
96
+ }
53
97
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/common/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAE5D,oBAAY,QAAQ,GAAG,iBAAiB,CAAC,0CAA0C,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CAAE,CAAC;AAEjH;;GAEG;AAC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;CACd;AAED;;GAEG;AACH,oBAAY,QAAQ,GAAG;IACnB;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,SAAS,EAAE,SAAS,CAAC;CACxB,CAAC;AAEF,MAAM,WAAW,gBAAgB,CAAC,CAAC,CAAE,SAAQ,iBAAiB,CAAC,MAAM;IACjE,OAAO,CAAC,EAAE,CAAC,CAAC;CACf;AAED,MAAM,WAAW,WAAW;IACxB;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC;IACZ;;OAEG;IACH,cAAc,EAAE,MAAM,CAAC;IACvB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,2BAA2B,CAAC,EAAE,OAAO,CAAC;IACtC;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,KAAK;IAClB;;OAEG;IACH,KAAK,CAAC,EAAE,KAAK,CAAC,WAAW,CAAC,CAAC;IAC3B;;OAEG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;CACxB;AAED,MAAM,WAAW,iBAAiB;IAC9B,QAAQ,CAAC,EAAE;QACP;;WAEG;QACH,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB;;WAEG;QACH,KAAK,CAAC,EAAE,KAAK,CAAC;KACjB,CAAC;CACL"}
package/dist/index.d.ts CHANGED
@@ -6,6 +6,8 @@ export { CustomTableColumn } from './column/types';
6
6
  export { generateCustomColumn } from './column';
7
7
  export { CustomSection } from './section/types';
8
8
  export { generateCustomSection } from './section';
9
+ export { CustomView } from './view/types';
10
+ export { generateCustomView } from './view';
9
11
  export { enableFPM, FPMConfig } from './app';
10
12
  export { validateBasePath, validateVersion } from './common/validate';
11
13
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1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GED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.validateVersion = exports.validateBasePath = exports.enableFPM = exports.generateCustomSection = exports.generateCustomColumn = exports.generateCustomAction = exports.TargetControl = exports.generateCustomPage = void 0;
3
+ exports.validateVersion = exports.validateBasePath = exports.enableFPM = exports.generateCustomView = exports.generateCustomSection = exports.generateCustomColumn = exports.generateCustomAction = exports.TargetControl = 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
  var types_1 = require("./action/types");
@@ -11,6 +11,8 @@ var column_1 = require("./column");
11
11
  Object.defineProperty(exports, "generateCustomColumn", { enumerable: true, get: function () { return column_1.generateCustomColumn; } });
12
12
  var section_1 = require("./section");
13
13
  Object.defineProperty(exports, "generateCustomSection", { enumerable: true, get: function () { return section_1.generateCustomSection; } });
14
+ var view_1 = require("./view");
15
+ Object.defineProperty(exports, "generateCustomView", { enumerable: true, get: function () { return view_1.generateCustomView; } });
14
16
  var app_1 = require("./app");
15
17
  Object.defineProperty(exports, "enableFPM", { enumerable: true, get: function () { return app_1.enableFPM; } });
16
18
  var validate_1 = require("./common/validate");
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AACA,+BAA4C;AAAnC,0GAAA,kBAAkB,OAAA;AAE3B,wCAA6D;AAAtC,sGAAA,aAAa,OAAA;AACpC,mCAAgD;AAAvC,8GAAA,oBAAoB,OAAA;AAG7B,mCAAgD;AAAvC,8GAAA,oBAAoB,OAAA;AAG7B,qCAAkD;AAAzC,gHAAA,qBAAqB,OAAA;AAE9B,6BAA6C;AAApC,gGAAA,SAAS,OAAA;AAElB,8CAAsE;AAA7D,4GAAA,gBAAgB,OAAA;AAAE,2GAAA,eAAe,OAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AACA,+BAA4C;AAAnC,0GAAA,kBAAkB,OAAA;AAE3B,wCAA6D;AAAtC,sGAAA,aAAa,OAAA;AACpC,mCAAgD;AAAvC,8GAAA,oBAAoB,OAAA;AAG7B,mCAAgD;AAAvC,8GAAA,oBAAoB,OAAA;AAG7B,qCAAkD;AAAzC,gHAAA,qBAAqB,OAAA;AAG9B,+BAA4C;AAAnC,0GAAA,kBAAkB,OAAA;AAE3B,6BAA6C;AAApC,gGAAA,SAAS,OAAA;AAElB,8CAAsE;AAA7D,4GAAA,gBAAgB,OAAA;AAAE,2GAAA,eAAe,OAAA"}
@@ -0,0 +1,12 @@
1
+ import type { Editor } from 'mem-fs-editor';
2
+ import type { CustomView } from './types';
3
+ /**
4
+ * Add a custom view to an existing UI5 application.
5
+ *
6
+ * @param {string} basePath - the base path
7
+ * @param {CustomView} customView - the custom view configuration
8
+ * @param {Editor} [fs] - the mem-fs editor instance
9
+ * @returns {Promise<Editor>} the updated mem-fs editor instance
10
+ */
11
+ export declare function generateCustomView(basePath: string, customView: CustomView, fs?: Editor): Editor;
12
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/view/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAE5C,OAAO,KAAK,EAAE,UAAU,EAAsB,MAAM,SAAS,CAAC;AAyC9D;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAoChG"}
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.generateCustomView = void 0;
4
+ const mem_fs_1 = require("mem-fs");
5
+ const mem_fs_editor_1 = require("mem-fs-editor");
6
+ const path_1 = require("path");
7
+ const ejs_1 = require("ejs");
8
+ const validate_1 = require("../common/validate");
9
+ const defaults_1 = require("../common/defaults");
10
+ /**
11
+ * Enhances the provided custom view configuration with default data.
12
+ *
13
+ * @param {CustomView} data - a custom view configuration object
14
+ * @param {string} manifestPath - path to the project's manifest.json
15
+ * @param {Manifest} manifest - the application manifest
16
+ * @returns enhanced configuration
17
+ */
18
+ function enhanceConfig(data, manifestPath, manifest) {
19
+ var _a, _b, _c, _d, _e;
20
+ const config = Object.assign({}, data);
21
+ defaults_1.setCommonDefaults(config, manifestPath, manifest);
22
+ // set default event handler if it is to be created
23
+ if (config.eventHandler === true) {
24
+ config.eventHandler = `${config.ns}.${config.name}.onPress`;
25
+ }
26
+ // existing views
27
+ 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[data.target])
28
+ .options) === null || _d === void 0 ? void 0 : _d.settings) === null || _e === void 0 ? void 0 : _e.views;
29
+ if (existingViews) {
30
+ config.views = existingViews;
31
+ }
32
+ // generate view content
33
+ if (typeof config.control === 'string') {
34
+ config.content = config.control;
35
+ }
36
+ else {
37
+ config.content = defaults_1.getDefaultFragmentContent(config.name, config.eventHandler, true);
38
+ }
39
+ return config;
40
+ }
41
+ /**
42
+ * Add a custom view to an existing UI5 application.
43
+ *
44
+ * @param {string} basePath - the base path
45
+ * @param {CustomView} customView - the custom view configuration
46
+ * @param {Editor} [fs] - the mem-fs editor instance
47
+ * @returns {Promise<Editor>} the updated mem-fs editor instance
48
+ */
49
+ function generateCustomView(basePath, customView, fs) {
50
+ validate_1.validateVersion(customView.ui5Version);
51
+ if (!fs) {
52
+ fs = mem_fs_editor_1.create(mem_fs_1.create());
53
+ }
54
+ validate_1.validateBasePath(basePath, fs);
55
+ const manifestPath = path_1.join(basePath, 'webapp/manifest.json');
56
+ const manifest = fs.readJSON(manifestPath);
57
+ const root = path_1.join(__dirname, '../../templates');
58
+ // merge with defaults
59
+ const completeView = enhanceConfig(customView, manifestPath, manifest);
60
+ // add event handler if requested
61
+ if (completeView.eventHandler) {
62
+ const controllerPath = path_1.join(completeView.path, `${completeView.name}.controller.js`);
63
+ if (!fs.exists(controllerPath)) {
64
+ fs.copyTpl(path_1.join(root, 'common/EventHandler.js'), controllerPath, completeView);
65
+ }
66
+ }
67
+ // enhance manifest with view definition
68
+ const filledTemplate = ejs_1.render(fs.read(path_1.join(root, 'view', `manifest.json`)), completeView);
69
+ fs.extendJSON(manifestPath, JSON.parse(filledTemplate));
70
+ // add fragment
71
+ const viewPath = path_1.join(completeView.path, `${completeView.name}.fragment.xml`);
72
+ if (completeView.control === true) {
73
+ fs.copyTpl(path_1.join(root, 'view/ext/CustomViewWithTable.xml'), viewPath, completeView);
74
+ }
75
+ else if (!fs.exists(viewPath)) {
76
+ fs.copyTpl(path_1.join(root, 'common/Fragment.xml'), viewPath, completeView);
77
+ }
78
+ return fs;
79
+ }
80
+ exports.generateCustomView = generateCustomView;
81
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/view/index.ts"],"names":[],"mappings":";;;AAAA,mCAAiD;AAEjD,iDAAuC;AAEvC,+BAA4B;AAC5B,6BAA6B;AAC7B,iDAAuE;AAEvE,iDAAkF;AAElF;;;;;;;GAOG;AACH,SAAS,aAAa,CAAC,IAAgB,EAAE,YAAoB,EAAE,QAAkB;;IAC7E,MAAM,MAAM,qBAAkD,IAAI,CAAE,CAAC;IACrE,4BAAiB,CAAC,MAAM,EAAE,YAAY,EAAE,QAAQ,CAAC,CAAC;IAElD,mDAAmD;IACnD,IAAI,MAAM,CAAC,YAAY,KAAK,IAAI,EAAE;QAC9B,MAAM,CAAC,YAAY,GAAG,GAAG,MAAM,CAAC,EAAE,IAAI,MAAM,CAAC,IAAI,UAAU,CAAC;KAC/D;IAED,iBAAiB;IACjB,MAA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,gBAAgB,CAAC,CAAC;QACrF,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC,cAAc,CAAC,EAAE;YAC5B,EAAE,CAAC,OAAO,CAAC,WAAI,CAAC,IAAI,EAAE,wBAAwB,CAAC,EAAE,cAAc,EAAE,YAAY,CAAC,CAAC;SAClF;KACJ;IAED,wCAAwC;IACxC,MAAM,cAAc,GAAG,YAAM,CAAC,EAAE,CAAC,IAAI,CAAC,WAAI,CAAC,IAAI,EAAE,MAAM,EAAE,eAAe,CAAC,CAAC,EAAE,YAAY,CAAC,CAAC;IAC1F,EAAE,CAAC,UAAU,CAAC,YAAY,EAAE,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC,CAAC;IAExD,eAAe;IACf,MAAM,QAAQ,GAAG,WAAI,CAAC,YAAY,CAAC,IAAI,EAAE,GAAG,YAAY,CAAC,IAAI,eAAe,CAAC,CAAC;IAC9E,IAAI,YAAY,CAAC,OAAO,KAAK,IAAI,EAAE;QAC/B,EAAE,CAAC,OAAO,CAAC,WAAI,CAAC,IAAI,EAAE,kCAAkC,CAAC,EAAE,QAAQ,EAAE,YAAY,CAAC,CAAC;KACtF;SAAM,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE;QAC7B,EAAE,CAAC,OAAO,CAAC,WAAI,CAAC,IAAI,EAAE,qBAAqB,CAAC,EAAE,QAAQ,EAAE,YAAY,CAAC,CAAC;KACzE;IAED,OAAO,EAAE,CAAC;AACd,CAAC;AApCD,gDAoCC"}
@@ -0,0 +1,31 @@
1
+ import type { CustomElement, InternalCustomElement, Views } from '../common/types';
2
+ export interface CustomView extends CustomElement {
3
+ /**
4
+ * Name of the routing target.
5
+ */
6
+ target: string;
7
+ /**
8
+ * View title, is shown in the tab item.
9
+ */
10
+ label: string;
11
+ /**
12
+ * Unique tab identifier.
13
+ */
14
+ key: string;
15
+ /**
16
+ * If set to true, a new controller is created and linked to the action.
17
+ * If an existing event handler is to be used then its id needs to be provided as string.
18
+ */
19
+ eventHandler?: string | true;
20
+ /**
21
+ * Optional control XML that will be generated into the fragment of the view.
22
+ * If set to true, a table macro control will be generated.
23
+ */
24
+ control?: string | true;
25
+ }
26
+ export interface InternalCustomView extends CustomView, InternalCustomElement {
27
+ content: string;
28
+ existingEventHandler: boolean;
29
+ views: Views;
30
+ }
31
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/view/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,qBAAqB,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAEnF,MAAM,WAAW,UAAW,SAAQ,aAAa;IAC7C;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IAEd;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC;IAEZ;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAE7B;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B;AAED,MAAM,WAAW,kBAAmB,SAAQ,UAAU,EAAE,qBAAqB;IACzE,OAAO,EAAE,MAAM,CAAC;IAChB,oBAAoB,EAAE,OAAO,CAAC;IAC9B,KAAK,EAAE,KAAK,CAAC;CAChB"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/view/types.ts"],"names":[],"mappings":""}
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.7.0",
4
+ "version": "0.8.0",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "https://github.com/SAP/open-ux-tools.git",
@@ -0,0 +1,3 @@
1
+ <core:FragmentDefinition xmlns="sap.m" xmlns:core="sap.ui.core" xmlns:macros="sap.fe.macros" xmlns:u="sap.ui.unified">
2
+ <macros:Table id="<%- name %>" metaPath="@com.sap.vocabularies.UI.v1.LineItem" displayMode="true" />
3
+ </core:FragmentDefinition>
@@ -0,0 +1,42 @@
1
+ {
2
+ "sap.ui5": {
3
+ <% if (locals.eventHandler ) { %>
4
+ "extends": {
5
+ "extensions": {
6
+ "sap.ui.controllerExtensions": {
7
+ "sap.fe.templates.ListReport.ListReportController": {
8
+ "controllerName": "<%- ns %>.<%- name %>"
9
+ }
10
+ }
11
+ }
12
+ },
13
+ <%
14
+ } %>
15
+ "routing": {
16
+ "targets": {
17
+ "<%- target %>": {
18
+ "options": {
19
+ "settings": {
20
+ "views": {
21
+ "paths": [
22
+ <% if (locals.views?.paths) { %>
23
+ <% locals.views.paths.forEach ( (path) => { %>
24
+ <%- JSON.stringify(path) %>,
25
+ <%
26
+ } ) %>
27
+ <%
28
+ } %>
29
+ {
30
+ "key": "<%- key %>",
31
+ "label": "<%- label %>",
32
+ "template": "<%- ns %>.<%- name %>"
33
+ }
34
+ ]
35
+ }
36
+ }
37
+ }
38
+ }
39
+ }
40
+ }
41
+ }
42
+ }