@sap-ux/fe-fpm-writer 0.18.6 → 0.18.7
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.
|
@@ -198,6 +198,11 @@ function generateControllerExtension(basePath, controllerConfig, fs) {
|
|
|
198
198
|
}
|
|
199
199
|
if (controllerConfig.typescript) {
|
|
200
200
|
(0, utils_1.addExtensionTypes)(basePath, controllerConfig.minUI5Version, fs);
|
|
201
|
+
// Typescript - add declaration ts file for 'sap/ui/core/mvc/ControllerExtension', which allows access to `this.base.getExtensionAPI()` within Controller extension classes
|
|
202
|
+
const declarationFilePath = (0, path_1.join)(basePath, '/webapp/ext/controller/ControllerExtension.d.ts');
|
|
203
|
+
if (!fs.exists(declarationFilePath)) {
|
|
204
|
+
fs.copy((0, templates_1.getTemplatePath)('controller-extension/ControllerExtension.d.ts'), declarationFilePath);
|
|
205
|
+
}
|
|
201
206
|
}
|
|
202
207
|
return fs;
|
|
203
208
|
}
|
package/package.json
CHANGED
|
@@ -2,30 +2,19 @@ import ControllerExtension from 'sap/ui/core/mvc/ControllerExtension';
|
|
|
2
2
|
import ExtensionAPI from 'sap/fe/<%- typeof extension === "object" ? `templates/${extension.pageType}` : "core" -%>/ExtensionAPI';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* @namespace <%- ns %>.<%- name %>
|
|
6
|
+
* @controller
|
|
6
7
|
*/
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
base: {
|
|
10
|
-
getExtensionAPI(): ExtensionAPI;
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Cannot change to class syntax until https://github.com/SAP/ui5-typescript/issues/332 is fixed.
|
|
17
|
-
*/
|
|
18
|
-
export default ControllerExtension.extend('<%- ns %>.<%- name %>', {
|
|
19
|
-
// this section allows to extend lifecycle hooks or hooks provided by Fiori elements
|
|
20
|
-
override: {
|
|
8
|
+
export default class <%- name %> extends ControllerExtension<ExtensionAPI> {
|
|
9
|
+
static override = {
|
|
21
10
|
/**
|
|
22
11
|
* Called when a controller is instantiated and its View controls (if available) are already created.
|
|
23
12
|
* Can be used to modify the View before it is displayed, to bind event handlers and do other one-time initialization.
|
|
24
13
|
* @memberOf <%- ns %>.<%- name %>
|
|
25
14
|
*/
|
|
26
|
-
onInit(this:
|
|
15
|
+
onInit(this: <%- name %>) {
|
|
27
16
|
// you can access the Fiori elements extensionAPI via this.base.getExtensionAPI
|
|
28
17
|
const model = this.base.getExtensionAPI().getModel();
|
|
29
18
|
}
|
|
30
19
|
}
|
|
31
|
-
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helper to be able to define how to get the page specific extension API when writing a controller extension.
|
|
3
|
+
*/
|
|
4
|
+
declare module 'sap/ui/core/mvc/ControllerExtension' {
|
|
5
|
+
export default class ControllerExtension<API> {
|
|
6
|
+
static override: unknown;
|
|
7
|
+
base: {
|
|
8
|
+
getExtensionAPI(): API;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
}
|