@sap-ux/fe-fpm-writer 0.8.0 → 0.11.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.
Files changed (43) hide show
  1. package/README.md +0 -1
  2. package/dist/action/types.d.ts +1 -0
  3. package/dist/action/types.d.ts.map +1 -1
  4. package/dist/index.d.ts +2 -2
  5. package/dist/index.d.ts.map +1 -1
  6. package/dist/index.js +3 -1
  7. package/dist/index.js.map +1 -1
  8. package/dist/page/common.d.ts +52 -0
  9. package/dist/page/common.d.ts.map +1 -0
  10. package/dist/page/common.js +157 -0
  11. package/dist/page/common.js.map +1 -0
  12. package/dist/page/custom.d.ts +28 -0
  13. package/dist/page/custom.d.ts.map +1 -0
  14. package/dist/page/custom.js +82 -0
  15. package/dist/page/custom.js.map +1 -0
  16. package/dist/page/index.d.ts +6 -27
  17. package/dist/page/index.d.ts.map +1 -1
  18. package/dist/page/index.js +9 -139
  19. package/dist/page/index.js.map +1 -1
  20. package/dist/page/list.d.ts +12 -0
  21. package/dist/page/list.d.ts.map +1 -0
  22. package/dist/page/list.js +57 -0
  23. package/dist/page/list.js.map +1 -0
  24. package/dist/page/object.d.ts +12 -0
  25. package/dist/page/object.d.ts.map +1 -0
  26. package/dist/page/object.js +48 -0
  27. package/dist/page/object.js.map +1 -0
  28. package/dist/page/types.d.ts +78 -19
  29. package/dist/page/types.d.ts.map +1 -1
  30. package/package.json +1 -1
  31. package/templates/action/manifest.action.json +2 -1
  32. package/templates/page/{1.84 → custom/1.84}/ext/Controller.js +0 -0
  33. package/templates/page/{1.84 → custom/1.84}/ext/View.xml +0 -0
  34. package/templates/page/{1.84 → custom/1.84}/manifest.json +0 -0
  35. package/templates/page/{1.94 → custom/1.94}/ext/Controller.js +0 -0
  36. package/templates/page/{1.94 → custom/1.94}/ext/View.xml +0 -0
  37. package/templates/page/{1.94 → custom/1.94}/manifest.json +0 -0
  38. package/templates/page/list/manifest.json +17 -0
  39. package/templates/page/object/manifest.json +30 -0
  40. package/dist/page/defaults.d.ts +0 -12
  41. package/dist/page/defaults.d.ts.map +0 -1
  42. package/dist/page/defaults.js +0 -38
  43. package/dist/page/defaults.js.map +0 -1
package/README.md CHANGED
@@ -25,7 +25,6 @@ const fs = await generateCustomPage(
25
25
  name: 'MyCustomPage',
26
26
  entity: 'Booking',
27
27
  navigation: {
28
- sourceEntity: 'Travel',
29
28
  sourcePage: 'TravelObjectPage',
30
29
  navEntity: '_Booking'
31
30
  }
@@ -17,6 +17,7 @@ export interface CustomAction extends CustomElement {
17
17
  text: string;
18
18
  visible?: string | true;
19
19
  enabled?: string | true;
20
+ requiresSelection?: boolean;
20
21
  position?: Position;
21
22
  /**
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.
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/action/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,qBAAqB,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAEtF,oBAAY,aAAa;IACrB,MAAM,WAAW;IACjB,MAAM,WAAW;IACjB,OAAO,2CAA2C;IAClD,KAAK,yCAAyC;CACjD;AAED,MAAM,WAAW,kBAAkB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,aAAa,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,YAAa,SAAQ,aAAa;IAC/C,MAAM,EAAE,kBAAkB,CAAC;IAC3B,QAAQ,EAAE;QACN,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QACxB,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QACxB,QAAQ,CAAC,EAAE,QAAQ,CAAC;QACpB;;;WAGG;QACH,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;KAChC,CAAC;CACL;AAED,oBAAY,oBAAoB,GAAG,YAAY,GAAG,qBAAqB,CAAC"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/action/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,qBAAqB,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAEtF,oBAAY,aAAa;IACrB,MAAM,WAAW;IACjB,MAAM,WAAW;IACjB,OAAO,2CAA2C;IAClD,KAAK,yCAAyC;CACjD;AAED,MAAM,WAAW,kBAAkB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,aAAa,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,YAAa,SAAQ,aAAa;IAC/C,MAAM,EAAE,kBAAkB,CAAC;IAC3B,QAAQ,EAAE;QACN,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QACxB,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QACxB,iBAAiB,CAAC,EAAE,OAAO,CAAC;QAC5B,QAAQ,CAAC,EAAE,QAAQ,CAAC;QACpB;;;WAGG;QACH,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;KAChC,CAAC;CACL;AAED,oBAAY,oBAAoB,GAAG,YAAY,GAAG,qBAAqB,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- export { CustomPage } from './page/types';
2
- export { generateCustomPage } from './page';
1
+ export { CustomPage, ObjectPage, ListReport } from './page/types';
2
+ export { generateCustomPage, generateObjectPage, generateListReport } from './page';
3
3
  export { CustomAction, TargetControl } from './action/types';
4
4
  export { generateCustomAction } from './action';
5
5
  export { CustomTableColumn } from './column/types';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names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AE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,kBAAkB,EAAE,MAAM,QAAQ,CAAC;AAE5C,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAE7C,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC"}
package/dist/index.js CHANGED
@@ -1,8 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.validateVersion = exports.validateBasePath = exports.enableFPM = exports.generateCustomView = 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.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
+ Object.defineProperty(exports, "generateObjectPage", { enumerable: true, get: function () { return page_1.generateObjectPage; } });
7
+ Object.defineProperty(exports, "generateListReport", { enumerable: true, get: function () { return page_1.generateListReport; } });
6
8
  var types_1 = require("./action/types");
7
9
  Object.defineProperty(exports, "TargetControl", { enumerable: true, get: function () { return types_1.TargetControl; } });
8
10
  var action_1 = require("./action");
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;AAG9B,+BAA4C;AAAnC,0GAAA,kBAAkB,OAAA;AAE3B,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,+BAAoF;AAA3E,0GAAA,kBAAkB,OAAA;AAAE,0GAAA,kBAAkB,OAAA;AAAE,0GAAA,kBAAkB,OAAA;AAEnE,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,52 @@
1
+ import type { Editor } from 'mem-fs-editor';
2
+ import type { ManifestNamespace } from '@sap-ux/ui5-config';
3
+ import type { CustomPage, FCL, InternalCustomPage, InternalObjectPage, ObjectPage, Navigation, InternalListReport } from './types';
4
+ import type { Manifest } from '../common/types';
5
+ /**
6
+ * Suffix for patterns to support arbitrary paramters
7
+ */
8
+ export declare const PATTERN_SUFFIX = ":?query:";
9
+ /**
10
+ * Generates the pattern for a new route based on the input.
11
+ *
12
+ * @param routes existing routes
13
+ * @param targetEntity entity of the target
14
+ * @param nav navigation object
15
+ * @returns the generated pattern as string
16
+ */
17
+ export declare function generateRoutePattern(routes: ManifestNamespace.Route[], targetEntity: string, nav?: Navigation): string;
18
+ /**
19
+ * Generates the target property for a route based on exiting routes, configurations and the target's name.
20
+ *
21
+ * @param routes existing routes
22
+ * @param name name of the target page
23
+ * @param fcl optional flag if FCL is enabled
24
+ * @param nav navigation object
25
+ * @returns the target property of a route
26
+ */
27
+ export declare function generateRouteTarget(routes: ManifestNamespace.Route[], name: string, fcl?: boolean, nav?: Navigation): string | [string] | [ManifestNamespace.RouteTargetObject];
28
+ /**
29
+ * Create a function that can be used as JsonReplace when calling extendJson.
30
+ *
31
+ * @param config page configuration
32
+ * @returns a JsonReplacer function for the usage in ejs
33
+ */
34
+ export declare function getManifestJsonExtensionHelper(config: InternalCustomPage | InternalObjectPage | InternalListReport): (key: string, value: any) => any;
35
+ /**
36
+ * Get the configuration parameters for the flexible column layout based on the given manifest and navigation config.
37
+ *
38
+ * @param manifest existing manifest
39
+ * @param navigation navigation configuration that is to be added
40
+ * @returns fcl configuration
41
+ */
42
+ export declare function getFclConfig(manifest: Manifest, navigation?: Navigation): FCL;
43
+ /**
44
+ * Validate the input parameters for the generation of a custom or an object page.
45
+ *
46
+ * @param basePath - the base path
47
+ * @param config - the custom page configuration
48
+ * @param fs - the memfs editor instance
49
+ * @returns the updated memfs editor instance
50
+ */
51
+ export declare function validatePageConfig(basePath: string, config: CustomPage | ObjectPage, fs: Editor): Editor;
52
+ //# sourceMappingURL=common.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../src/page/common.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAE5C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAE5D,OAAO,KAAK,EACR,UAAU,EACV,GAAG,EACH,kBAAkB,EAClB,kBAAkB,EAClB,UAAU,EACV,UAAU,EACV,kBAAkB,EACrB,MAAM,SAAS,CAAC;AACjB,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAGhD;;GAEG;AACH,eAAO,MAAM,cAAc,aAAa,CAAC;AAEzC;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAChC,MAAM,EAAE,iBAAiB,CAAC,KAAK,EAAE,EACjC,YAAY,EAAE,MAAM,EACpB,GAAG,CAAC,EAAE,UAAU,GACjB,MAAM,CAyBR;AAED;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CAC/B,MAAM,EAAE,iBAAiB,CAAC,KAAK,EAAE,EACjC,IAAI,EAAE,MAAM,EACZ,GAAG,CAAC,EAAE,OAAO,EACb,GAAG,CAAC,EAAE,UAAU,GACjB,MAAM,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,iBAAiB,CAAC,iBAAiB,CAAC,CAS3D;AAED;;;;;GAKG;AACH,wBAAgB,8BAA8B,CAC1C,MAAM,EAAE,kBAAkB,GAAG,kBAAkB,GAAG,kBAAkB,GACrE,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,KAAK,GAAG,CAmBlC;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,QAAQ,EAAE,UAAU,CAAC,EAAE,UAAU,GAAG,GAAG,CAe7E;AAED;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,GAAG,UAAU,EAAE,EAAE,EAAE,MAAM,GAAG,MAAM,CA2BxG"}
@@ -0,0 +1,157 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.validatePageConfig = exports.getFclConfig = exports.getManifestJsonExtensionHelper = exports.generateRouteTarget = exports.generateRoutePattern = exports.PATTERN_SUFFIX = void 0;
4
+ const path_1 = require("path");
5
+ const validate_1 = require("../common/validate");
6
+ const defaults_1 = require("../common/defaults");
7
+ /**
8
+ * Suffix for patterns to support arbitrary paramters
9
+ */
10
+ exports.PATTERN_SUFFIX = ':?query:';
11
+ /**
12
+ * Generates the pattern for a new route based on the input.
13
+ *
14
+ * @param routes existing routes
15
+ * @param targetEntity entity of the target
16
+ * @param nav navigation object
17
+ * @returns the generated pattern as string
18
+ */
19
+ function generateRoutePattern(routes, targetEntity, nav) {
20
+ var _a;
21
+ const parts = [];
22
+ if ((nav === null || nav === void 0 ? void 0 : nav.sourcePage) && nav.navEntity) {
23
+ const sourceRoute = routes.find((route) => route.name === nav.sourcePage);
24
+ if (sourceRoute === null || sourceRoute === void 0 ? void 0 : sourceRoute.pattern) {
25
+ const basePattern = sourceRoute.pattern.replace(exports.PATTERN_SUFFIX, '');
26
+ if (basePattern) {
27
+ parts.push(basePattern);
28
+ parts.push('/');
29
+ parts.push(nav.navEntity);
30
+ }
31
+ else {
32
+ parts.push(targetEntity);
33
+ }
34
+ }
35
+ else {
36
+ throw new Error('Navigation source invalid');
37
+ }
38
+ }
39
+ else if (routes.length > 0) {
40
+ parts.push(targetEntity);
41
+ }
42
+ if (nav === null || nav === void 0 ? void 0 : nav.navKey) {
43
+ parts.push(`({${(_a = nav === null || nav === void 0 ? void 0 : nav.navEntity) !== null && _a !== void 0 ? _a : targetEntity}Key})`);
44
+ }
45
+ parts.push(exports.PATTERN_SUFFIX);
46
+ return parts.join('');
47
+ }
48
+ exports.generateRoutePattern = generateRoutePattern;
49
+ /**
50
+ * Generates the target property for a route based on exiting routes, configurations and the target's name.
51
+ *
52
+ * @param routes existing routes
53
+ * @param name name of the target page
54
+ * @param fcl optional flag if FCL is enabled
55
+ * @param nav navigation object
56
+ * @returns the target property of a route
57
+ */
58
+ function generateRouteTarget(routes, name, fcl, nav) {
59
+ var _a;
60
+ if (nav === null || nav === void 0 ? void 0 : nav.sourcePage) {
61
+ const sourceRoute = routes.find((route) => route.name === nav.sourcePage);
62
+ // FCL only supports 3 columns, therefore, show the page in fullscreen if it is the 4th level of navigation
63
+ if (fcl && ((_a = sourceRoute === null || sourceRoute === void 0 ? void 0 : sourceRoute.target) === null || _a === void 0 ? void 0 : _a.constructor) === Array && sourceRoute.target.length < 3) {
64
+ return [...sourceRoute.target, name];
65
+ }
66
+ }
67
+ return fcl ? [name] : name;
68
+ }
69
+ exports.generateRouteTarget = generateRouteTarget;
70
+ /**
71
+ * Create a function that can be used as JsonReplace when calling extendJson.
72
+ *
73
+ * @param config page configuration
74
+ * @returns a JsonReplacer function for the usage in ejs
75
+ */
76
+ function getManifestJsonExtensionHelper(config) {
77
+ return (key, value) => {
78
+ var _a;
79
+ switch (key) {
80
+ case 'routing':
81
+ value.routes = (_a = value.routes) !== null && _a !== void 0 ? _a : [];
82
+ break;
83
+ case 'routes':
84
+ const routes = value;
85
+ routes.push({
86
+ name: `${config.entity}${config.name}`,
87
+ pattern: generateRoutePattern(routes, config.entity, config.navigation),
88
+ target: generateRouteTarget(routes, `${config.entity}${config.name}`, config.fcl, config.navigation)
89
+ });
90
+ break;
91
+ default:
92
+ break;
93
+ }
94
+ return value;
95
+ };
96
+ }
97
+ exports.getManifestJsonExtensionHelper = getManifestJsonExtensionHelper;
98
+ /**
99
+ * Get the configuration parameters for the flexible column layout based on the given manifest and navigation config.
100
+ *
101
+ * @param manifest existing manifest
102
+ * @param navigation navigation configuration that is to be added
103
+ * @returns fcl configuration
104
+ */
105
+ function getFclConfig(manifest, navigation) {
106
+ var _a, _b, _c, _d, _e, _f;
107
+ const config = {};
108
+ if (((_c = (_b = (_a = manifest['sap.ui5']) === null || _a === void 0 ? void 0 : _a.routing) === null || _b === void 0 ? void 0 : _b.config) === null || _c === void 0 ? void 0 : _c.routerClass) === defaults_1.FCL_ROUTER) {
109
+ config.fcl = true;
110
+ if (navigation) {
111
+ const sourceRoute = (((_e = (_d = manifest['sap.ui5']) === null || _d === void 0 ? void 0 : _d.routing) === null || _e === void 0 ? void 0 : _e.routes) || []).find((route) => route.name === (navigation === null || navigation === void 0 ? void 0 : navigation.sourcePage));
112
+ config.controlAggregation =
113
+ ((_f = sourceRoute === null || sourceRoute === void 0 ? void 0 : sourceRoute.target) !== null && _f !== void 0 ? _f : []).length > 1 ? 'endColumnPages' : 'midColumnPages';
114
+ }
115
+ else {
116
+ config.controlAggregation = 'beginColumnPages';
117
+ }
118
+ }
119
+ return config;
120
+ }
121
+ exports.getFclConfig = getFclConfig;
122
+ /**
123
+ * Validate the input parameters for the generation of a custom or an object page.
124
+ *
125
+ * @param basePath - the base path
126
+ * @param config - the custom page configuration
127
+ * @param fs - the memfs editor instance
128
+ * @returns the updated memfs editor instance
129
+ */
130
+ function validatePageConfig(basePath, config, fs) {
131
+ // common validators
132
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
133
+ validate_1.validateBasePath(basePath, fs);
134
+ // validate config against the manifest
135
+ if ((_a = config.navigation) === null || _a === void 0 ? void 0 : _a.sourcePage) {
136
+ const manifest = fs.readJSON(path_1.join(basePath, 'webapp/manifest.json'));
137
+ if (!((_d = (_c = (_b = manifest['sap.ui5']) === null || _b === void 0 ? void 0 : _b.routing) === null || _c === void 0 ? void 0 : _c.targets) === null || _d === void 0 ? void 0 : _d[config.navigation.sourcePage])) {
138
+ throw new Error(`Could not find navigation source ${config.navigation.sourcePage}!`);
139
+ }
140
+ const routes = {};
141
+ if (((_g = (_f = (_e = manifest['sap.ui5']) === null || _e === void 0 ? void 0 : _e.routing) === null || _f === void 0 ? void 0 : _f.routes) === null || _g === void 0 ? void 0 : _g.constructor) === Array) {
142
+ manifest['sap.ui5'].routing.routes.forEach((routeWithName) => {
143
+ routes[routeWithName.name] = routeWithName;
144
+ });
145
+ }
146
+ else {
147
+ Object.assign(routes, (_k = (_j = (_h = manifest['sap.ui5']) === null || _h === void 0 ? void 0 : _h.routing) === null || _j === void 0 ? void 0 : _j.routes) !== null && _k !== void 0 ? _k : {});
148
+ }
149
+ const route = routes[config.navigation.sourcePage];
150
+ if (!route || !route.pattern || !route.target) {
151
+ throw new Error(`Invalid routing configuration for navigation source ${config.navigation.sourcePage}!`);
152
+ }
153
+ }
154
+ return fs;
155
+ }
156
+ exports.validatePageConfig = validatePageConfig;
157
+ //# sourceMappingURL=common.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"common.js","sourceRoot":"","sources":["../../src/page/common.ts"],"names":[],"mappings":";;;AACA,+BAA4B;AAE5B,iDAAsD;AAWtD,iDAAgD;AAEhD;;GAEG;AACU,QAAA,cAAc,GAAG,UAAU,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AAG,EAAE,CAAC,QAAQ,CAAC,WAAI,CAAC,QAAQ,EAAE,sBAAsB,CAAC,CAAa,CAAC;QACjF,IAAI,oBAAC,QAAQ,CAAC,SAAS,CAAC,0CAAE,OAAO,0CAAE,OAAO,0CAAG,MAAM,CAAC,UAAU,CAAC,UAAU,EAAC,EAAE;YACxE,MAAM,IAAI,KAAK,CAAC,oCAAoC,MAAM,CAAC,UAAU,CAAC,UAAU,GAAG,CAAC,CAAC;SACxF;QACD,MAAM,MAAM,GAAwD,EAAE,CAAC;QACvE,IAAI,mBAAA,QAAQ,CAAC,SAAS,CAAC,0CAAE,OAAO,0CAAE,MAAM,0CAAE,WAAW,MAAK,KAAK,EAAE;YAC7D,QAAQ,CAAC,SAAS,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,aAAa,EAAE,EAAE;gBACzD,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,GAAG,aAAa,CAAC;YAC/C,CAAC,CAAC,CAAC;SACN;aAAM;YACH,MAAM,CAAC,MAAM,CAAC,MAAM,oBAAE,QAAQ,CAAC,SAAS,CAAC,0CAAE,OAAO,0CAAE,MAAM,mCAAI,EAAE,CAAC,CAAC;SACrE;QAED,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;QACnD,IAAI,CAAC,KAAK,IAAI,CAAC,KAAK,CAAC,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE;YAC3C,MAAM,IAAI,KAAK,CAAC,uDAAuD,MAAM,CAAC,UAAU,CAAC,UAAU,GAAG,CAAC,CAAC;SAC3G;KACJ;IAED,OAAO,EAAE,CAAC;AACd,CAAC;AA3BD,gDA2BC"}
@@ -0,0 +1,28 @@
1
+ import type { Editor } from 'mem-fs-editor';
2
+ import type { CustomPage, InternalCustomPage } from './types';
3
+ /**
4
+ * Enhances the provided custom page configuration with default data.
5
+ *
6
+ * @param data - a custom page configuration object
7
+ * @param manifestPath - path to the application manifest
8
+ * @param fs - mem-fs reference to be used for file access
9
+ * @returns enhanced configuration
10
+ */
11
+ export declare function enhanceData(data: CustomPage, manifestPath: string, fs: Editor): InternalCustomPage;
12
+ /**
13
+ * Validate the UI5 version and if valid return the root folder for the templates to be used.
14
+ *
15
+ * @param ui5Version - optional minimum required UI5 version
16
+ * @returns root folder containg the templates if the version is supported otherwise throws an error
17
+ */
18
+ export declare function getTemplateRoot(ui5Version?: number): string;
19
+ /**
20
+ * Add a custom page to an existing UI5 application.
21
+ *
22
+ * @param {string} basePath - the base path
23
+ * @param {CustomPage} data - the custom page configuration
24
+ * @param {Editor} [fs] - the memfs editor instance
25
+ * @returns {Promise<Editor>} the updated memfs editor instance
26
+ */
27
+ export declare function generate(basePath: string, data: CustomPage, fs?: Editor): Editor;
28
+ //# sourceMappingURL=custom.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"custom.d.ts","sourceRoot":"","sources":["../../src/page/custom.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAG5C,OAAO,KAAK,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAM9D;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,kBAAkB,CAiBlG;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,CAM3D;AAED;;;;;;;GAOG;AACH,wBAAgB,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAgChF"}
@@ -0,0 +1,82 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.generate = exports.getTemplateRoot = exports.enhanceData = void 0;
4
+ const path_1 = require("path");
5
+ const mem_fs_1 = require("mem-fs");
6
+ const mem_fs_editor_1 = require("mem-fs-editor");
7
+ const ejs_1 = require("ejs");
8
+ const common_1 = require("./common");
9
+ const defaults_1 = require("../common/defaults");
10
+ const validate_1 = require("../common/validate");
11
+ /**
12
+ * Enhances the provided custom page configuration with default data.
13
+ *
14
+ * @param data - a custom page configuration object
15
+ * @param manifestPath - path to the application manifest
16
+ * @param fs - mem-fs reference to be used for file access
17
+ * @returns enhanced configuration
18
+ */
19
+ function enhanceData(data, manifestPath, fs) {
20
+ const manifest = fs.readJSON(manifestPath);
21
+ // set common defaults
22
+ const config = defaults_1.setCommonDefaults(data, manifestPath, manifest);
23
+ // set FCL configuration
24
+ const fclConfig = common_1.getFclConfig(manifest, config.navigation);
25
+ config.fcl = fclConfig.fcl;
26
+ config.controlAggregation = fclConfig.controlAggregation;
27
+ if (config.view === undefined) {
28
+ config.view = {
29
+ title: config.name
30
+ };
31
+ }
32
+ return config;
33
+ }
34
+ exports.enhanceData = enhanceData;
35
+ /**
36
+ * Validate the UI5 version and if valid return the root folder for the templates to be used.
37
+ *
38
+ * @param ui5Version - optional minimum required UI5 version
39
+ * @returns root folder containg the templates if the version is supported otherwise throws an error
40
+ */
41
+ function getTemplateRoot(ui5Version) {
42
+ if (ui5Version === undefined || ui5Version >= 1.94) {
43
+ return path_1.join(__dirname, '../../templates/page/custom/1.94');
44
+ }
45
+ else {
46
+ return path_1.join(__dirname, '../../templates/page/custom/1.84');
47
+ }
48
+ }
49
+ exports.getTemplateRoot = getTemplateRoot;
50
+ /**
51
+ * Add a custom page to an existing UI5 application.
52
+ *
53
+ * @param {string} basePath - the base path
54
+ * @param {CustomPage} data - the custom page configuration
55
+ * @param {Editor} [fs] - the memfs editor instance
56
+ * @returns {Promise<Editor>} the updated memfs editor instance
57
+ */
58
+ function generate(basePath, data, fs) {
59
+ if (!fs) {
60
+ fs = mem_fs_editor_1.create(mem_fs_1.create());
61
+ }
62
+ validate_1.validateVersion(data.ui5Version);
63
+ common_1.validatePageConfig(basePath, data, fs);
64
+ const manifestPath = path_1.join(basePath, 'webapp/manifest.json');
65
+ const config = enhanceData(data, manifestPath, fs);
66
+ // merge content into existing files
67
+ const root = getTemplateRoot(data.ui5Version);
68
+ // enhance manifest.json
69
+ fs.extendJSON(manifestPath, JSON.parse(ejs_1.render(fs.read(path_1.join(root, `manifest.json`)), config)), common_1.getManifestJsonExtensionHelper(config));
70
+ // add extension content
71
+ const viewPath = path_1.join(config.path, `${config.name}.view.xml`);
72
+ if (!fs.exists(viewPath)) {
73
+ fs.copyTpl(path_1.join(root, 'ext/View.xml'), viewPath, config);
74
+ }
75
+ const controllerPath = path_1.join(config.path, `${config.name}.controller.js`);
76
+ if (!fs.exists(controllerPath)) {
77
+ fs.copyTpl(path_1.join(root, 'ext/Controller.js'), controllerPath, config);
78
+ }
79
+ return fs;
80
+ }
81
+ exports.generate = generate;
82
+ //# sourceMappingURL=custom.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"custom.js","sourceRoot":"","sources":["../../src/page/custom.ts"],"names":[],"mappings":";;;AAAA,+BAA4B;AAC5B,mCAAiD;AAEjD,iDAAuC;AACvC,6BAA6B;AAE7B,qCAA4F;AAC5F,iDAAuD;AAEvD,iDAAqD;AAErD;;;;;;;GAOG;AACH,SAAgB,WAAW,CAAC,IAAgB,EAAE,YAAoB,EAAE,EAAU;IAC1E,MAAM,QAAQ,GAAG,EAAE,CAAC,QAAQ,CAAC,YAAY,CAAa,CAAC;IAEvD,sBAAsB;IACtB,MAAM,MAAM,GAAG,4BAAiB,CAAC,IAAI,EAAE,YAAY,EAAE,QAAQ,CAAuB,CAAC;IAErF,wBAAwB;IACxB,MAAM,SAAS,GAAG,qBAAY,CAAC,QAAQ,EAAE,MAAM,CAAC,UAAU,CAAC,CAAC;IAC5D,MAAM,CAAC,GAAG,GAAG,SAAS,CAAC,GAAG,CAAC;IAC3B,MAAM,CAAC,kBAAkB,GAAG,SAAS,CAAC,kBAAkB,CAAC;IAEz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AAM,CAAC,IAAI,EAAE,GAAG,MAAM,CAAC,IAAI,WAAW,CAAC,CAAC;IAC9D,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE;QACtB,EAAE,CAAC,OAAO,CAAC,WAAI,CAAC,IAAI,EAAE,cAAc,CAAC,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;KAC5D;IACD,MAAM,cAAc,GAAG,WAAI,CAAC,MAAM,CAAC,IAAI,EAAE,GAAG,MAAM,CAAC,IAAI,gBAAgB,CAAC,CAAC;IACzE,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC,cAAc,CAAC,EAAE;QAC5B,EAAE,CAAC,OAAO,CAAC,WAAI,CAAC,IAAI,EAAE,mBAAmB,CAAC,EAAE,cAAc,EAAE,MAAM,CAAC,CAAC;KACvE;IAED,OAAO,EAAE,CAAC;AACd,CAAC;AAhCD,4BAgCC"}
@@ -1,28 +1,7 @@
1
- import type { Editor } from 'mem-fs-editor';
2
- import type { CustomPage } from './types';
3
- /**
4
- * Validate the UI5 version and if valid return the root folder for the templates to be used.
5
- *
6
- * @param ui5Version - optional minimum required UI5 version
7
- * @returns root folder containg the templates if the version is supported otherwise throws an error
8
- */
9
- export declare function getTemplateRoot(ui5Version?: number): string;
10
- /**
11
- * Validate the input parameters for the execution of generateCustomAction.
12
- *
13
- * @param {string} basePath - the base path
14
- * @param {CustomPage} config - the custom page configuration
15
- * @param {Editor} [fs] - the memfs editor instance
16
- * @returns {Promise<Editor>} the updated memfs editor instance
17
- */
18
- export declare function validateCustomPageConfig(basePath: string, config: CustomPage, fs?: Editor): Editor;
19
- /**
20
- * Add a custom page to an existing UI5 application.
21
- *
22
- * @param {string} basePath - the base path
23
- * @param {CustomPage} data - the custom page configuration
24
- * @param {Editor} [fs] - the memfs editor instance
25
- * @returns {Promise<Editor>} the updated memfs editor instance
26
- */
27
- export declare function generateCustomPage(basePath: string, data: CustomPage, fs?: Editor): Editor;
1
+ import type { CustomPage, ObjectPage, ListReport, Navigation } from './types';
2
+ import { validatePageConfig } from './common';
3
+ import { generate as generateCustomPage } from './custom';
4
+ import { generate as generateObjectPage } from './object';
5
+ import { generate as generateListReport } from './list';
6
+ export { validatePageConfig, generateCustomPage, generateObjectPage, generateListReport, CustomPage, ObjectPage, ListReport, Navigation };
28
7
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/page/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAK5C,OAAO,KAAK,EAAE,UAAU,EAAsB,MAAM,SAAS,CAAC;AAI9D;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,CAM3D;AAqCD;;;;;;;GAOG;AACH,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAgClG;AAED;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAmC1F"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/page/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAC9E,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAC9C,OAAO,EAAE,QAAQ,IAAI,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAC1D,OAAO,EAAE,QAAQ,IAAI,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAC1D,OAAO,EAAE,QAAQ,IAAI,kBAAkB,EAAE,MAAM,QAAQ,CAAC;AAExD,OAAO,EACH,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,EAClB,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACb,CAAC"}
@@ -1,142 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.generateCustomPage = exports.validateCustomPageConfig = exports.getTemplateRoot = void 0;
4
- const path_1 = require("path");
5
- const mem_fs_1 = require("mem-fs");
6
- const mem_fs_editor_1 = require("mem-fs-editor");
7
- const ejs_1 = require("ejs");
8
- const defaults_1 = require("./defaults");
9
- const validate_1 = require("../common/validate");
10
- /**
11
- * Validate the UI5 version and if valid return the root folder for the templates to be used.
12
- *
13
- * @param ui5Version - optional minimum required UI5 version
14
- * @returns root folder containg the templates if the version is supported otherwise throws an error
15
- */
16
- function getTemplateRoot(ui5Version) {
17
- if (ui5Version === undefined || ui5Version >= 1.94) {
18
- return path_1.join(__dirname, '../../templates/page/1.94');
19
- }
20
- else {
21
- return path_1.join(__dirname, '../../templates/page/1.84');
22
- }
23
- }
24
- exports.getTemplateRoot = getTemplateRoot;
25
- /**
26
- * Add a new route to the provided route array, and update existing routes if necessary (e.g. if targets are defined as arrays for FCL).
27
- *
28
- * @param routes existing application routes (from the manifest)
29
- * @param config configuration object
30
- */
31
- function updateRoutes(routes, config) {
32
- var _a, _b;
33
- const newRoute = {
34
- name: `${config.entity}${config.name}`
35
- };
36
- if (config.navigation) {
37
- const sourceRoute = routes.find((route) => { var _a; return route.name === ((_a = config.navigation) === null || _a === void 0 ? void 0 : _a.sourcePage); });
38
- const pattern = {
39
- base: (_a = sourceRoute === null || sourceRoute === void 0 ? void 0 : sourceRoute.pattern) === null || _a === void 0 ? void 0 : _a.replace(':?query:', ''),
40
- navEntity: config.navigation.navEntity,
41
- navKey: config.navigation.navKey ? `({${config.navigation.navEntity}Key})` : ''
42
- };
43
- newRoute.pattern = `${pattern.base}/${pattern.navEntity}${pattern.navKey}:?query:`;
44
- if (((_b = sourceRoute === null || sourceRoute === void 0 ? void 0 : sourceRoute.target) === null || _b === void 0 ? void 0 : _b.constructor) === Array) {
45
- const pages = sourceRoute.target;
46
- // FCL only supports 3 columns, therefore, show the page in fullscreen if it is the 4th level of navigation
47
- newRoute.target =
48
- pages.length > 2
49
- ? [newRoute.name]
50
- : [...pages, newRoute.name];
51
- }
52
- else {
53
- newRoute.target = config.fcl ? [newRoute.name] : newRoute.name;
54
- }
55
- }
56
- else {
57
- newRoute.pattern = routes.length > 0 ? `${config.entity}:?query:` : ':?query:';
58
- newRoute.target = config.fcl ? [newRoute.name] : newRoute.name;
59
- }
60
- routes.push(newRoute);
61
- }
62
- /**
63
- * Validate the input parameters for the execution of generateCustomAction.
64
- *
65
- * @param {string} basePath - the base path
66
- * @param {CustomPage} config - the custom page configuration
67
- * @param {Editor} [fs] - the memfs editor instance
68
- * @returns {Promise<Editor>} the updated memfs editor instance
69
- */
70
- function validateCustomPageConfig(basePath, config, fs) {
71
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
72
- // common validators
73
- validate_1.validateVersion(config.ui5Version);
74
- if (!fs) {
75
- fs = mem_fs_editor_1.create(mem_fs_1.create());
76
- }
77
- validate_1.validateBasePath(basePath, fs);
78
- // validate config against the manifest
79
- const manifest = fs.readJSON(path_1.join(basePath, 'webapp/manifest.json'));
80
- if (config.navigation) {
81
- if (!((_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.navigation.sourcePage])) {
82
- throw new Error(`Could not find navigation source ${config.navigation.sourcePage}!`);
83
- }
84
- const routes = {};
85
- if (((_f = (_e = (_d = manifest['sap.ui5']) === null || _d === void 0 ? void 0 : _d.routing) === null || _e === void 0 ? void 0 : _e.routes) === null || _f === void 0 ? void 0 : _f.constructor) === Array) {
86
- manifest['sap.ui5'].routing.routes.forEach((routeWithName) => {
87
- routes[routeWithName.name] = routeWithName;
88
- });
89
- }
90
- else {
91
- Object.assign(routes, (_j = (_h = (_g = manifest['sap.ui5']) === null || _g === void 0 ? void 0 : _g.routing) === null || _h === void 0 ? void 0 : _h.routes) !== null && _j !== void 0 ? _j : {});
92
- }
93
- const route = routes[(_k = config.navigation) === null || _k === void 0 ? void 0 : _k.sourcePage];
94
- if (!route || !route.pattern || !route.target) {
95
- throw new Error(`Missing or invalid routing configuration for navigation source ${config.navigation.sourcePage}!`);
96
- }
97
- }
98
- return fs;
99
- }
100
- exports.validateCustomPageConfig = validateCustomPageConfig;
101
- /**
102
- * Add a custom page to an existing UI5 application.
103
- *
104
- * @param {string} basePath - the base path
105
- * @param {CustomPage} data - the custom page configuration
106
- * @param {Editor} [fs] - the memfs editor instance
107
- * @returns {Promise<Editor>} the updated memfs editor instance
108
- */
109
- function generateCustomPage(basePath, data, fs) {
110
- fs = validateCustomPageConfig(basePath, data, fs);
111
- const manifestPath = path_1.join(basePath, 'webapp/manifest.json');
112
- const config = defaults_1.enhanceData(data, manifestPath, fs);
113
- // merge content into existing files
114
- const root = getTemplateRoot(data.ui5Version);
115
- // enhance manifest.json
116
- fs.extendJSON(manifestPath, JSON.parse(ejs_1.render(fs.read(path_1.join(root, `manifest.json`)), config)), (key, value) => {
117
- var _a;
118
- switch (key) {
119
- case 'routing':
120
- value.routes = (_a = value.routes) !== null && _a !== void 0 ? _a : [];
121
- break;
122
- case 'routes':
123
- updateRoutes(value, config);
124
- break;
125
- default:
126
- break;
127
- }
128
- return value;
129
- });
130
- // add extension content
131
- const viewPath = path_1.join(config.path, `${config.name}.view.xml`);
132
- if (!fs.exists(viewPath)) {
133
- fs.copyTpl(path_1.join(root, 'ext/View.xml'), viewPath, config);
134
- }
135
- const controllerPath = path_1.join(config.path, `${config.name}.controller.js`);
136
- if (!fs.exists(controllerPath)) {
137
- fs.copyTpl(path_1.join(root, 'ext/Controller.js'), controllerPath, config);
138
- }
139
- return fs;
140
- }
141
- exports.generateCustomPage = generateCustomPage;
3
+ exports.generateListReport = exports.generateObjectPage = exports.generateCustomPage = exports.validatePageConfig = void 0;
4
+ const common_1 = require("./common");
5
+ Object.defineProperty(exports, "validatePageConfig", { enumerable: true, get: function () { return common_1.validatePageConfig; } });
6
+ const custom_1 = require("./custom");
7
+ Object.defineProperty(exports, "generateCustomPage", { enumerable: true, get: function () { return custom_1.generate; } });
8
+ const object_1 = require("./object");
9
+ Object.defineProperty(exports, "generateObjectPage", { enumerable: true, get: function () { return object_1.generate; } });
10
+ const list_1 = require("./list");
11
+ Object.defineProperty(exports, "generateListReport", { enumerable: true, get: function () { return list_1.generate; } });
142
12
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/page/index.ts"],"names":[],"mappings":";;;AAAA,+BAA4B;AAC5B,mCAAiD;AAEjD,iDAAuC;AACvC,6BAA6B;AAE7B,yCAAyC;AAEzC,iDAAuE;AAGvE;;;;;GAKG;AACH,SAAgB,eAAe,CAAC,UAAmB;IAC/C,IAAI,UAAU,KAAK,SAAS,IAAI,UAAU,IAAI,IAAI,EAAE;QAChD,OAAO,WAAI,CAAC,SAAS,EAAE,2BAA2B,CAAC,CAAC;KACvD;SAAM;QACH,OAAO,WAAI,CAAC,SAAS,EAAE,2BAA2B,CAAC,CAAC;KACvD;AACL,CAAC;AAND,0CAMC;AAED;;;;;GAKG;AACH,SAAS,YAAY,CAAC,MAAiC,EAAE,MAA0B;;IAC/E,MAAM,QAAQ,GAA4B;QACtC,IAAI,EAAE,GAAG,MAAM,CAAC,MAAM,GAAG,MAAM,CAAC,IAAI,EAAE;KACzC,CAAC;IACF,IAAI,MAAM,CAAC,UAAU,EAAE;QACnB,MAAM,WAAW,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,WAAC,OAAA,KAAK,CAAC,IAAI,YAAK,MAAM,CAAC,UAAU,0CAAE,UAAU,CAAA,CAAA,EAAA,CAAC,CAAC;QACzF,MAAM,OAAO,GAAG;YACZ,IAAI,QAAE,WAAW,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AAC,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE;QACtB,EAAE,CAAC,OAAO,CAAC,WAAI,CAAC,IAAI,EAAE,cAAc,CAAC,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;KAC5D;IACD,MAAM,cAAc,GAAG,WAAI,CAAC,MAAM,CAAC,IAAI,EAAE,GAAG,MAAM,CAAC,IAAI,gBAAgB,CAAC,CAAC;IACzE,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC,cAAc,CAAC,EAAE;QAC5B,EAAE,CAAC,OAAO,CAAC,WAAI,CAAC,IAAI,EAAE,mBAAmB,CAAC,EAAE,cAAc,EAAE,MAAM,CAAC,CAAC;KACvE;IAED,OAAO,EAAE,CAAC;AACd,CAAC;AAnCD,gDAmCC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/page/index.ts"],"names":[],"mappings":";;;AACA,qCAA8C;AAM1C,mGANK,2BAAkB,OAML;AALtB,qCAA0D;AAMtD,mGANiB,iBAAkB,OAMjB;AALtB,qCAA0D;AAMtD,mGANiB,iBAAkB,OAMjB;AALtB,iCAAwD;AAMpD,mGANiB,eAAkB,OAMjB"}
@@ -0,0 +1,12 @@
1
+ import type { Editor } from 'mem-fs-editor';
2
+ import type { ListReport } from './types';
3
+ /**
4
+ * Add a ListReport to an existing UI5 application.
5
+ *
6
+ * @param basePath - the base path
7
+ * @param data - the object page configuration
8
+ * @param fs - the memfs editor instance
9
+ * @returns the updated memfs editor instance
10
+ */
11
+ export declare function generate(basePath: string, data: ListReport, fs?: Editor): Editor;
12
+ //# sourceMappingURL=list.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../src/page/list.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAK5C,OAAO,KAAK,EAAE,UAAU,EAAsB,MAAM,SAAS,CAAC;AA+B9D;;;;;;;GAOG;AACH,wBAAgB,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAmBhF"}
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.generate = void 0;
4
+ const path_1 = require("path");
5
+ const mem_fs_1 = require("mem-fs");
6
+ const mem_fs_editor_1 = require("mem-fs-editor");
7
+ const ejs_1 = require("ejs");
8
+ const common_1 = require("./common");
9
+ /**
10
+ * Enhances the provided list report configuration with default data.
11
+ *
12
+ * @param data - a list report configuration object
13
+ * @param manifest - application manifest
14
+ * @returns enhanced configuration
15
+ */
16
+ function enhanceData(data, manifest) {
17
+ var _a, _b;
18
+ const config = Object.assign(Object.assign(Object.assign({ settings: {} }, data), { name: 'ListReport' }), common_1.getFclConfig(manifest));
19
+ // move settings into correct possition in the manifest
20
+ config.settings.entitySet = data.entity;
21
+ config.settings.navigation = {};
22
+ // use standard file name if i18n enhancement required
23
+ if (config.settings.enhanceI18n === true) {
24
+ config.settings.enhanceI18n = `i18n/custom${config.entity}${config.name}.properties`;
25
+ }
26
+ // move table settings into the correct structure
27
+ if (config.settings.tableSettings) {
28
+ config.settings.controlConfiguration = (_a = config.settings.controlConfiguration) !== null && _a !== void 0 ? _a : {};
29
+ config.settings.controlConfiguration['@com.sap.vocabularies.UI.v1.LineItem'] = (_b = config.settings.controlConfiguration['@com.sap.vocabularies.UI.v1.LineItem']) !== null && _b !== void 0 ? _b : {};
30
+ config.settings.controlConfiguration['@com.sap.vocabularies.UI.v1.LineItem'].tableSettings =
31
+ config.settings.tableSettings;
32
+ delete config.settings.tableSettings;
33
+ }
34
+ return config;
35
+ }
36
+ /**
37
+ * Add a ListReport to an existing UI5 application.
38
+ *
39
+ * @param basePath - the base path
40
+ * @param data - the object page configuration
41
+ * @param fs - the memfs editor instance
42
+ * @returns the updated memfs editor instance
43
+ */
44
+ function generate(basePath, data, fs) {
45
+ if (!fs) {
46
+ fs = mem_fs_editor_1.create(mem_fs_1.create());
47
+ }
48
+ common_1.validatePageConfig(basePath, data, fs);
49
+ const manifestPath = path_1.join(basePath, 'webapp/manifest.json');
50
+ const manifest = fs.readJSON(manifestPath);
51
+ const config = enhanceData(data, manifest);
52
+ // enhance manifest.json
53
+ fs.extendJSON(manifestPath, JSON.parse(ejs_1.render(fs.read(path_1.join(__dirname, '../../templates/page/list/manifest.json')), config)), common_1.getManifestJsonExtensionHelper(config));
54
+ return fs;
55
+ }
56
+ exports.generate = generate;
57
+ //# sourceMappingURL=list.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"list.js","sourceRoot":"","sources":["../../src/page/list.ts"],"names":[],"mappings":";;;AAAA,+BAA4B;AAC5B,mCAAiD;AAEjD,iDAAuC;AACvC,6BAA6B;AAC7B,qCAA4F;AAI5F;;;;;;GAMG;AACH,SAAS,WAAW,CAAC,IAAgB,EAAE,QAAkB;;IACrD,MAAM,MAAM,+CAAyB,QAAQ,EAAE,EAAE,IAAK,IAAI,KAAE,IAAI,EAAE,YAAY,KAAK,qBAAY,CAAC,QAAQ,CAAC,CAAE,CAAC;IAE5G,uDAAuD;IACvD,MAAM,CAAC,QAAQ,CAAC,SAAS,GAAG,IAAI,CAAC,MAAM,CAAC;IACxC,MAAM,CAAC,QAAQ,CAAC,UAAU,GAAG,EAAE,CAAC;IAChC,sDAAsD;IACtD,IAAI,MAAM,CAAC,QAAQ,CAAC,WAAW,KAAK,IAAI,EAAE;QACtC,MAAM,CAAC,QAAQ,CAAC,WAAW,GAAG,cAAc,MAAM,CAAC,MAAM,GAAG,MAAM,CAAC,IAAI,aAAa,CAAC;KACxF;IACD,iDAAiD;IACjD,IAAI,MAAM,CAAC,QAAQ,CAAC,aAAa,EAAE;QAC/B,MAAM,CAAC,QAAQ,CAAC,oBAAoB,SAAG,MAAM,CAAC,QAAQ,CAAC,oBAAoB,mCAAI,EAAE,CAAC;QAClF,MAAM,CAAC,QAAQ,CAAC,oBAAoB,CAAC,sCAAsC,CAAC,SACxE,MAAM,CAAC,QAAQ,CAAC,oBAAoB,CAAC,sCAAsC,CAAC,mCAAI,EAAE,CAAC;QACvF,MAAM,CAAC,QAAQ,CAAC,oBAAoB,CAAC,sCAAsC,CAAC,CAAC,aAAa;YACtF,MAAM,CAAC,QAAQ,CAAC,aAAa,CAAC;QAClC,OAAO,MAAM,CAAC,QAAQ,CAAC,aAAa,CAAC;KACxC;IACD,OAAO,MAAM,CAAC;AAClB,CAAC;AAED;;;;;;;GAOG;AACH,SAAgB,QAAQ,CAAC,QAAgB,EAAE,IAAgB,EAAE,EAAW;IACpE,IAAI,CAAC,EAAE,EAAE;QACL,EAAE,GAAG,sBAAM,CAAC,eAAa,EAAE,CAAC,CAAC;KAChC;IACD,2BAAkB,CAAC,QAAQ,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC;IAEvC,MAAM,YAAY,GAAG,WAAI,CAAC,QAAQ,EAAE,sBAAsB,CAAC,CAAC;IAC5D,MAAM,QAAQ,GAAG,EAAE,CAAC,QAAQ,CAAC,YAAY,CAAa,CAAC;IAEvD,MAAM,MAAM,GAAG,WAAW,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;IAE3C,wBAAwB;IACxB,EAAE,CAAC,UAAU,CACT,YAAY,EACZ,IAAI,CAAC,KAAK,CAAC,YAAM,CAAC,EAAE,CAAC,IAAI,CAAC,WAAI,CAAC,SAAS,EAAE,yCAAyC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,EAC/F,uCAA8B,CAAC,MAAM,CAAC,CACzC,CAAC;IAEF,OAAO,EAAE,CAAC;AACd,CAAC;AAnBD,4BAmBC"}
@@ -0,0 +1,12 @@
1
+ import type { Editor } from 'mem-fs-editor';
2
+ import type { ObjectPage } from './types';
3
+ /**
4
+ * Add an object page to an existing UI5 application.
5
+ *
6
+ * @param basePath - the base path
7
+ * @param data - the object page configuration
8
+ * @param fs - the memfs editor instance
9
+ * @returns the updated memfs editor instance
10
+ */
11
+ export declare function generate(basePath: string, data: ObjectPage, fs?: Editor): Editor;
12
+ //# sourceMappingURL=object.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"object.d.ts","sourceRoot":"","sources":["../../src/page/object.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAK5C,OAAO,KAAK,EAAE,UAAU,EAAsB,MAAM,SAAS,CAAC;AAsB9D;;;;;;;GAOG;AACH,wBAAgB,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAmBhF"}
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.generate = void 0;
4
+ const path_1 = require("path");
5
+ const mem_fs_1 = require("mem-fs");
6
+ const mem_fs_editor_1 = require("mem-fs-editor");
7
+ const ejs_1 = require("ejs");
8
+ const common_1 = require("./common");
9
+ /**
10
+ * Enhances the provided list report configuration with default data.
11
+ *
12
+ * @param data - a list report configuration object
13
+ * @param manifest - application manifest
14
+ * @returns enhanced configuration
15
+ */
16
+ function enhanceData(data, manifest) {
17
+ const config = Object.assign(Object.assign(Object.assign({ settings: {} }, data), { name: 'ObjectPage' }), common_1.getFclConfig(manifest));
18
+ // move settings into correct possition in the manifest
19
+ config.settings.entitySet = data.entity;
20
+ config.settings.navigation = {};
21
+ // use standard file name if i18n enhancement required
22
+ if (config.settings.enhanceI18n === true) {
23
+ config.settings.enhanceI18n = `i18n/custom${config.entity}${config.name}.properties`;
24
+ }
25
+ return config;
26
+ }
27
+ /**
28
+ * Add an object page to an existing UI5 application.
29
+ *
30
+ * @param basePath - the base path
31
+ * @param data - the object page configuration
32
+ * @param fs - the memfs editor instance
33
+ * @returns the updated memfs editor instance
34
+ */
35
+ function generate(basePath, data, fs) {
36
+ if (!fs) {
37
+ fs = mem_fs_editor_1.create(mem_fs_1.create());
38
+ }
39
+ common_1.validatePageConfig(basePath, data, fs);
40
+ const manifestPath = path_1.join(basePath, 'webapp/manifest.json');
41
+ const manifest = fs.readJSON(manifestPath);
42
+ const config = enhanceData(data, manifest);
43
+ // enhance manifest.json
44
+ fs.extendJSON(manifestPath, JSON.parse(ejs_1.render(fs.read(path_1.join(__dirname, '../../templates/page/object/manifest.json')), config)), common_1.getManifestJsonExtensionHelper(config));
45
+ return fs;
46
+ }
47
+ exports.generate = generate;
48
+ //# sourceMappingURL=object.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"object.js","sourceRoot":"","sources":["../../src/page/object.ts"],"names":[],"mappings":";;;AAAA,+BAA4B;AAC5B,mCAAiD;AAEjD,iDAAuC;AACvC,6BAA6B;AAC7B,qCAA4F;AAI5F;;;;;;GAMG;AACH,SAAS,WAAW,CAAC,IAAgB,EAAE,QAAkB;IACrD,MAAM,MAAM,+CAAyB,QAAQ,EAAE,EAAE,IAAK,IAAI,KAAE,IAAI,EAAE,YAAY,KAAK,qBAAY,CAAC,QAAQ,CAAC,CAAE,CAAC;IAE5G,uDAAuD;IACvD,MAAM,CAAC,QAAQ,CAAC,SAAS,GAAG,IAAI,CAAC,MAAM,CAAC;IACxC,MAAM,CAAC,QAAQ,CAAC,UAAU,GAAG,EAAE,CAAC;IAChC,sDAAsD;IACtD,IAAI,MAAM,CAAC,QAAQ,CAAC,WAAW,KAAK,IAAI,EAAE;QACtC,MAAM,CAAC,QAAQ,CAAC,WAAW,GAAG,cAAc,MAAM,CAAC,MAAM,GAAG,MAAM,CAAC,IAAI,aAAa,CAAC;KACxF;IACD,OAAO,MAAM,CAAC;AAClB,CAAC;AAED;;;;;;;GAOG;AACH,SAAgB,QAAQ,CAAC,QAAgB,EAAE,IAAgB,EAAE,EAAW;IACpE,IAAI,CAAC,EAAE,EAAE;QACL,EAAE,GAAG,sBAAM,CAAC,eAAa,EAAE,CAAC,CAAC;KAChC;IACD,2BAAkB,CAAC,QAAQ,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC;IAEvC,MAAM,YAAY,GAAG,WAAI,CAAC,QAAQ,EAAE,sBAAsB,CAAC,CAAC;IAC5D,MAAM,QAAQ,GAAG,EAAE,CAAC,QAAQ,CAAC,YAAY,CAAa,CAAC;IAEvD,MAAM,MAAM,GAAG,WAAW,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;IAE3C,wBAAwB;IACxB,EAAE,CAAC,UAAU,CACT,YAAY,EACZ,IAAI,CAAC,KAAK,CAAC,YAAM,CAAC,EAAE,CAAC,IAAI,CAAC,WAAI,CAAC,SAAS,EAAE,2CAA2C,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,EACjG,uCAA8B,CAAC,MAAM,CAAC,CACzC,CAAC;IAEF,OAAO,EAAE,CAAC;AACd,CAAC;AAnBD,4BAmBC"}
@@ -1,4 +1,65 @@
1
1
  import type { CustomElement, InternalCustomElement } from '../common/types';
2
+ /**
3
+ * Incoming navigation configuration.
4
+ */
5
+ export interface Navigation {
6
+ /**
7
+ * Source of the navigation to the custom page
8
+ */
9
+ sourcePage?: string;
10
+ /**
11
+ * Name of the navigation entity
12
+ */
13
+ navEntity?: string;
14
+ /**
15
+ * If set to true, then the generated route will point to a specific entity, otherwise, it will point to a list of the entities.
16
+ */
17
+ navKey?: boolean;
18
+ }
19
+ export interface StandardPageSettings {
20
+ enhanceI18n?: string | true;
21
+ variantManagement?: 'Page' | 'None';
22
+ }
23
+ /**
24
+ * Support list of settings for a ListReport page
25
+ */
26
+ export interface ListReportSettings extends StandardPageSettings {
27
+ tableSettings?: {
28
+ type?: 'ResponsiveTable' | 'GridTable';
29
+ selectionMode?: 'None' | 'Single' | 'Multi' | 'Auto';
30
+ condensedTableLayout?: boolean;
31
+ };
32
+ }
33
+ /**
34
+ * Configuration options for adding a list report page.
35
+ */
36
+ export interface ListReport {
37
+ /**
38
+ * Name of the entity used for the custom page.
39
+ */
40
+ entity: string;
41
+ /**
42
+ * Optional settings for the ListReport page
43
+ */
44
+ settings?: ListReportSettings;
45
+ }
46
+ /**
47
+ * Configuration options for adding an object page.
48
+ */
49
+ export interface ObjectPage {
50
+ /**
51
+ * Name of the entity used for the custom page.
52
+ */
53
+ entity: string;
54
+ /**
55
+ * Optional settings for the object page
56
+ */
57
+ settings?: StandardPageSettings;
58
+ /**
59
+ * Optional incoming navigation configuration. If provided then a navigation configuration is added to an existing page navigating to this custom page.
60
+ */
61
+ navigation?: Navigation;
62
+ }
2
63
  /**
3
64
  * Configuration options for adding a custom page.
4
65
  */
@@ -10,19 +71,7 @@ export interface CustomPage extends CustomElement {
10
71
  /**
11
72
  * Optional incoming navigation configuration. If provided then a navigation configuration is added to an existing page navigating to this custom page.
12
73
  */
13
- navigation?: {
14
- /**
15
- * Source of the navigation to the custom page
16
- */
17
- sourcePage: string;
18
- /**
19
- * Source entity that is use as the base part of the route
20
- */
21
- sourceEntity: string;
22
- /**
23
- * Name of the navigation entity
24
- */
25
- navEntity: string;
74
+ navigation?: Navigation & {
26
75
  /**
27
76
  * If set to true, then the generated route will point to a specific entity, otherwise, it will point to a list of the entities.
28
77
  */
@@ -38,18 +87,28 @@ export interface CustomPage extends CustomElement {
38
87
  title?: string;
39
88
  };
40
89
  }
41
- /**
42
- * Additional internal configuration options that will be calculated based on the provided input as well as the target application.
43
- */
44
- export declare type InternalCustomPage = CustomPage & InternalCustomElement & {
90
+ export interface FCL {
45
91
  /**
46
- * The FLC flag is calculated to true if the existing app is configured to use the flexible column layout
92
+ * The FCL flag is calculated to true if the existing app is configured to use the flexible column layout
47
93
  */
48
- fcl: boolean;
94
+ fcl?: boolean;
49
95
  /**
50
96
  * Represents the name of the control aggregation to be used for the custom page.
51
97
  * This is only used if FCL is enabled and is calculated based on the optional sourcepage.
52
98
  */
53
99
  controlAggregation?: 'beginColumnPages' | 'midColumnPages' | 'endColumnPages';
100
+ }
101
+ /**
102
+ * Additional internal configuration options that will be calculated based on the provided input as well as the target application.
103
+ */
104
+ export declare type InternalCustomPage = CustomPage & InternalCustomElement & FCL;
105
+ export declare type InternalListReport = ListReport & FCL & {
106
+ name: 'ListReport';
107
+ navigation?: Navigation;
108
+ settings: any;
109
+ };
110
+ export declare type InternalObjectPage = ObjectPage & FCL & {
111
+ name: 'ObjectPage';
112
+ settings: any;
54
113
  };
55
114
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/page/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAE5E;;GAEG;AACH,MAAM,WAAW,UAAW,SAAQ,aAAa;IAC7C;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,UAAU,CAAC,EAAE;QACT;;WAEG;QACH,UAAU,EAAE,MAAM,CAAC;QAEnB;;WAEG;QACH,YAAY,EAAE,MAAM,CAAC;QAErB;;WAEG;QACH,SAAS,EAAE,MAAM,CAAC;QAElB;;WAEG;QACH,MAAM,CAAC,EAAE,OAAO,CAAC;KACpB,CAAC;IAEF;;OAEG;IACH,IAAI,CAAC,EAAE;QACH;;WAEG;QACH,KAAK,CAAC,EAAE,MAAM,CAAC;KAClB,CAAC;CACL;AAED;;GAEG;AACH,oBAAY,kBAAkB,GAAG,UAAU,GACvC,qBAAqB,GAAG;IACpB;;OAEG;IACH,GAAG,EAAE,OAAO,CAAC;IAEb;;;OAGG;IACH,kBAAkB,CAAC,EAAE,kBAAkB,GAAG,gBAAgB,GAAG,gBAAgB,CAAC;CACjF,CAAC"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/page/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAE5E;;GAEG;AACH,MAAM,WAAW,UAAU;IACvB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;OAEG;IACH,SAA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AAgB,CAAC;CACjF;AAED;;GAEG;AACH,oBAAY,kBAAkB,GAAG,UAAU,GAAG,qBAAqB,GAAG,GAAG,CAAC;AAE1E,oBAAY,kBAAkB,GAAG,UAAU,GAAG,GAAG,GAAG;IAAE,IAAI,EAAE,YAAY,CAAC;IAAC,UAAU,CAAC,EAAE,UAAU,CAAC;IAAC,QAAQ,EAAE,GAAG,CAAA;CAAE,CAAC;AAEnH,oBAAY,kBAAkB,GAAG,UAAU,GAAG,GAAG,GAAG;IAAE,IAAI,EAAE,YAAY,CAAC;IAAC,QAAQ,EAAE,GAAG,CAAA;CAAE,CAAC"}
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.8.0",
4
+ "version": "0.11.0",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "https://github.com/SAP/open-ux-tools.git",
@@ -2,7 +2,8 @@
2
2
  "<%- name %>": {
3
3
  "press": "<%- settings.eventHandler %>",
4
4
  "visible": <%- settings.visible -%>,
5
- "enabled": <%- settings.enabled -%>,
5
+ "enabled": <%- settings.enabled -%><%if (settings.requiresSelection !== undefined) {%>,
6
+ "requiresSelection": <%- settings.requiresSelection -%><% } %>,
6
7
  "text": "<%- settings.text %>"<%if (settings.position) {%>,
7
8
  "position": {
8
9
  "placement": "<%- settings.position.placement %>",
@@ -0,0 +1,17 @@
1
+ {
2
+ "sap.ui5": {
3
+ "routing": {
4
+ "targets": {
5
+ "<%- entity %>ListReport": {
6
+ "type": "Component",
7
+ "id": "<%- entity %>ListReport",
8
+ "name": "sap.fe.templates.ListReport",<%if (locals.controlAggregation) {%>
9
+ "controlAggregation": "<%- locals.controlAggregation %>",<% } %>
10
+ "options": {
11
+ "settings": <%- JSON.stringify(settings) %>
12
+ }
13
+ }
14
+ }
15
+ }
16
+ }
17
+ }
@@ -0,0 +1,30 @@
1
+ {
2
+ "sap.ui5": {
3
+ "routing": {
4
+ "targets": {
5
+ "<%- entity %>ObjectPage": {
6
+ "type": "Component",
7
+ "id": "<%- entity %>ObjectPage",
8
+ "name": "sap.fe.templates.ObjectPage",<%if (locals.controlAggregation) {%>
9
+ "controlAggregation": "<%- locals.controlAggregation %>",<% } %>
10
+ "options": {
11
+ "settings": <%- JSON.stringify(settings) %>
12
+ }
13
+ }<%if (locals.navigation) {%>,
14
+ "<%- navigation.sourcePage %>": {
15
+ "options": {
16
+ "settings": {
17
+ "navigation": {
18
+ "<%- navigation.navEntity %>": {
19
+ "detail": {
20
+ "route": "<%- entity %>ObjectPage"
21
+ }
22
+ }
23
+ }
24
+ }
25
+ }
26
+ }<% } %>
27
+ }
28
+ }
29
+ }
30
+ }
@@ -1,12 +0,0 @@
1
- import type { Editor } from 'mem-fs-editor';
2
- import type { CustomPage, InternalCustomPage } from './types';
3
- /**
4
- * Enhances the provided custom page configuration with default data.
5
- *
6
- * @param {CustomPage} data - a custom page configuration object
7
- * @param manifestPath - path to the application manifest
8
- * @param fs - mem-fs reference to be used for file access
9
- * @returns enhanced configuration
10
- */
11
- export declare function enhanceData(data: CustomPage, manifestPath: string, fs: Editor): InternalCustomPage;
12
- //# sourceMappingURL=defaults.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"defaults.d.ts","sourceRoot":"","sources":["../../src/page/defaults.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAG5C,OAAO,KAAK,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAI9D;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,kBAAkB,CA0BlG"}
@@ -1,38 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.enhanceData = void 0;
4
- const defaults_1 = require("../common/defaults");
5
- /**
6
- * Enhances the provided custom page configuration with default data.
7
- *
8
- * @param {CustomPage} data - a custom page configuration object
9
- * @param manifestPath - path to the application manifest
10
- * @param fs - mem-fs reference to be used for file access
11
- * @returns enhanced configuration
12
- */
13
- function enhanceData(data, manifestPath, fs) {
14
- var _a, _b, _c, _d, _e, _f;
15
- const manifest = fs.readJSON(manifestPath);
16
- // set common defaults
17
- const config = defaults_1.setCommonDefaults(data, manifestPath, manifest);
18
- // if FCL is enabled enhance the configuration
19
- if (((_c = (_b = (_a = manifest['sap.ui5']) === null || _a === void 0 ? void 0 : _a.routing) === null || _b === void 0 ? void 0 : _b.config) === null || _c === void 0 ? void 0 : _c.routerClass) === defaults_1.FCL_ROUTER) {
20
- config.fcl = true;
21
- if (config.navigation) {
22
- const sourceRoute = (((_e = (_d = manifest['sap.ui5']) === null || _d === void 0 ? void 0 : _d.routing) === null || _e === void 0 ? void 0 : _e.routes) || []).find((route) => { var _a; return route.name === ((_a = config.navigation) === null || _a === void 0 ? void 0 : _a.sourcePage); });
23
- config.controlAggregation =
24
- ((_f = sourceRoute === null || sourceRoute === void 0 ? void 0 : sourceRoute.target) !== null && _f !== void 0 ? _f : []).length > 1 ? 'endColumnPages' : 'midColumnPages';
25
- }
26
- else {
27
- config.controlAggregation = 'beginColumnPages';
28
- }
29
- }
30
- if (config.view === undefined) {
31
- config.view = {
32
- title: config.name
33
- };
34
- }
35
- return config;
36
- }
37
- exports.enhanceData = enhanceData;
38
- //# sourceMappingURL=defaults.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"defaults.js","sourceRoot":"","sources":["../../src/page/defaults.ts"],"names":[],"mappings":";;;AAKA,iDAAmE;AAEnE;;;;;;;GAOG;AACH,SAAgB,WAAW,CAAC,IAAgB,EAAE,YAAoB,EAAE,EAAU;;IAC1E,MAAM,QAAQ,GAAG,EAAE,CAAC,QAAQ,CAAC,YAAY,CAAa,CAAC;IAEvD,sBAAsB;IACtB,MAAM,MAAM,GAAG,4BAAiB,CAAC,I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