@sap-ux/fe-fpm-writer 0.38.2 → 0.38.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/action/index.js
CHANGED
|
@@ -99,7 +99,7 @@ async function generateCustomAction(basePath, actionConfig, fs) {
|
|
|
99
99
|
config.eventHandler = (0, event_handler_1.applyEventHandlerConfiguration)(fs, config, config.eventHandler, {
|
|
100
100
|
controllerSuffix: false,
|
|
101
101
|
typescript: config.typescript
|
|
102
|
-
}, event_handler_1.contextParameter);
|
|
102
|
+
}, [event_handler_1.contextParameter, event_handler_1.selectedContextsParameter]);
|
|
103
103
|
}
|
|
104
104
|
// enhance manifest with action definition and controller reference
|
|
105
105
|
const actions = enhanceManifestAndGetActionsElementReference(manifest, config.target);
|
|
@@ -9,23 +9,32 @@ interface EventHandlerConfigurationOptions {
|
|
|
9
9
|
templatePath?: string;
|
|
10
10
|
eventHandlerFnName?: string;
|
|
11
11
|
}
|
|
12
|
+
type EventHandlerTypescriptParameters = EventHandlerTypescriptParameter[];
|
|
12
13
|
/**
|
|
13
14
|
* Interface to describe the input parameters for the generated event handler function.
|
|
14
15
|
*/
|
|
15
|
-
export interface
|
|
16
|
+
export interface EventHandlerTypescriptParameter {
|
|
17
|
+
/** Variable name in TypeScript style */
|
|
16
18
|
name: string;
|
|
19
|
+
/** Variable name in JavaScript style (Hungarian notation) */
|
|
20
|
+
jsName: string;
|
|
17
21
|
description: string;
|
|
18
22
|
importType: string;
|
|
23
|
+
/**
|
|
24
|
+
* Optional. If not defined, the parameter type will be taken from `importType`.
|
|
25
|
+
*/
|
|
26
|
+
paramType?: string;
|
|
19
27
|
importSource: string;
|
|
20
28
|
}
|
|
21
29
|
/**
|
|
22
30
|
* Default values for the input parameters of newly created event handlers.
|
|
23
31
|
*/
|
|
24
|
-
export declare const defaultParameter:
|
|
32
|
+
export declare const defaultParameter: EventHandlerTypescriptParameter;
|
|
25
33
|
/**
|
|
26
34
|
* Values for the input parameters of newly created event handlers that are added as manifest actions.
|
|
27
35
|
*/
|
|
28
|
-
export declare const contextParameter:
|
|
36
|
+
export declare const contextParameter: EventHandlerTypescriptParameter;
|
|
37
|
+
export declare const selectedContextsParameter: EventHandlerTypescriptParameter;
|
|
29
38
|
/**
|
|
30
39
|
* Method creates or updates handler js file and update 'settings.eventHandler' entry with namespace path entry to method.
|
|
31
40
|
*
|
|
@@ -33,7 +42,7 @@ export declare const contextParameter: EventHandlerTypescriptParameters;
|
|
|
33
42
|
* @param config - configuration
|
|
34
43
|
* @param eventHandler - eventHandler for creation
|
|
35
44
|
* @param eventHandlerOptions - eventHandler options
|
|
36
|
-
* @param parameters -
|
|
45
|
+
* @param parameters - parameters and its configurations for the event handler
|
|
37
46
|
* @returns {string} full namespace path to method
|
|
38
47
|
*/
|
|
39
48
|
export declare function applyEventHandlerConfiguration(fs: Editor, config: Partial<InternalCustomElement>, eventHandler: EventHandlerConfiguration | true | string, eventHandlerOptions: EventHandlerConfigurationOptions, parameters?: EventHandlerTypescriptParameters): string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.contextParameter = exports.defaultParameter = void 0;
|
|
3
|
+
exports.selectedContextsParameter = exports.contextParameter = exports.defaultParameter = void 0;
|
|
4
4
|
exports.applyEventHandlerConfiguration = applyEventHandlerConfiguration;
|
|
5
5
|
const path_1 = require("path");
|
|
6
6
|
const templates_1 = require("../templates");
|
|
@@ -10,7 +10,8 @@ const utils_1 = require("../common/utils");
|
|
|
10
10
|
*/
|
|
11
11
|
exports.defaultParameter = {
|
|
12
12
|
name: 'event',
|
|
13
|
-
|
|
13
|
+
jsName: 'oEvent',
|
|
14
|
+
description: 'the event object provided by the event provider.',
|
|
14
15
|
importType: 'UI5Event',
|
|
15
16
|
importSource: 'sap/ui/base/Event'
|
|
16
17
|
};
|
|
@@ -18,9 +19,19 @@ exports.defaultParameter = {
|
|
|
18
19
|
* Values for the input parameters of newly created event handlers that are added as manifest actions.
|
|
19
20
|
*/
|
|
20
21
|
exports.contextParameter = {
|
|
21
|
-
name: '
|
|
22
|
-
|
|
22
|
+
name: 'context',
|
|
23
|
+
jsName: 'oContext',
|
|
24
|
+
description: 'the context of the page on which the event was fired. `undefined` for list report page.',
|
|
23
25
|
importType: 'Context',
|
|
26
|
+
paramType: 'Context | undefined',
|
|
27
|
+
importSource: 'sap/ui/model/odata/v4/Context'
|
|
28
|
+
};
|
|
29
|
+
exports.selectedContextsParameter = {
|
|
30
|
+
name: 'selectedContexts',
|
|
31
|
+
jsName: 'aSelectedContexts',
|
|
32
|
+
description: 'the selected contexts of the table rows.',
|
|
33
|
+
importType: 'Context',
|
|
34
|
+
paramType: 'Context[]',
|
|
24
35
|
importSource: 'sap/ui/model/odata/v4/Context'
|
|
25
36
|
};
|
|
26
37
|
/**
|
|
@@ -49,10 +60,10 @@ function getFileName(fileName, controllerPrefix) {
|
|
|
49
60
|
* @param config - configuration
|
|
50
61
|
* @param eventHandler - eventHandler for creation
|
|
51
62
|
* @param eventHandlerOptions - eventHandler options
|
|
52
|
-
* @param parameters -
|
|
63
|
+
* @param parameters - parameters and its configurations for the event handler
|
|
53
64
|
* @returns {string} full namespace path to method
|
|
54
65
|
*/
|
|
55
|
-
function applyEventHandlerConfiguration(fs, config, eventHandler, eventHandlerOptions, parameters = exports.defaultParameter) {
|
|
66
|
+
function applyEventHandlerConfiguration(fs, config, eventHandler, eventHandlerOptions, parameters = [exports.defaultParameter]) {
|
|
56
67
|
const { controllerSuffix, typescript, templatePath = 'common/EventHandler' } = eventHandlerOptions;
|
|
57
68
|
let { eventHandlerFnName = 'onPress' } = eventHandlerOptions;
|
|
58
69
|
if (typeof eventHandler === 'string') {
|
package/dist/filter/index.js
CHANGED
|
@@ -56,7 +56,7 @@ async function generateCustomFilter(basePath, filterConfig, fs) {
|
|
|
56
56
|
controllerSuffix: false,
|
|
57
57
|
typescript: config.typescript,
|
|
58
58
|
templatePath: 'filter/Controller'
|
|
59
|
-
}, event_handler_1.contextParameter);
|
|
59
|
+
}, [event_handler_1.contextParameter]);
|
|
60
60
|
}
|
|
61
61
|
// enhance manifest with the filter definition and controller reference
|
|
62
62
|
const filters = enhanceManifestAndGetFiltersReference(manifest);
|
package/package.json
CHANGED
|
@@ -4,7 +4,21 @@ sap.ui.define([
|
|
|
4
4
|
'use strict';
|
|
5
5
|
|
|
6
6
|
return {
|
|
7
|
-
|
|
7
|
+
<% if (typeof parameters !== "undefined" && parameters.length) { -%>
|
|
8
|
+
/**
|
|
9
|
+
* Generated event handler.
|
|
10
|
+
*
|
|
11
|
+
<% parameters.forEach(function(param) { -%>
|
|
12
|
+
* @param <%- param.jsName %> <%- param.description %>
|
|
13
|
+
<% }) -%>
|
|
14
|
+
*/
|
|
15
|
+
<% } -%>
|
|
16
|
+
<%- eventHandlerFnName %>: function(<%=
|
|
17
|
+
(typeof parameters !== "undefined" ? parameters : [])
|
|
18
|
+
.map(function(param) {
|
|
19
|
+
return param.jsName;
|
|
20
|
+
}).join(", ")
|
|
21
|
+
-%>) {
|
|
8
22
|
MessageToast.show("Custom handler invoked.");
|
|
9
23
|
}
|
|
10
24
|
};
|
|
@@ -1,13 +1,28 @@
|
|
|
1
1
|
import ExtensionAPI from 'sap/fe/core/ExtensionAPI';
|
|
2
|
-
|
|
2
|
+
<%
|
|
3
|
+
const importedTypes = new Set();
|
|
4
|
+
parameters.forEach(param => {
|
|
5
|
+
if (param.importType && !importedTypes.has(param.importType)) {
|
|
6
|
+
importedTypes.add(param.importType);
|
|
7
|
+
-%>
|
|
8
|
+
import <%- param.importType %> from '<%- param.importSource %>';
|
|
9
|
+
<%
|
|
10
|
+
}
|
|
11
|
+
}); -%>
|
|
3
12
|
import MessageToast from 'sap/m/MessageToast';
|
|
4
13
|
|
|
5
14
|
/**
|
|
6
15
|
* Generated event handler.
|
|
7
16
|
*
|
|
8
17
|
* @param this reference to the 'this' that the event handler is bound to.
|
|
9
|
-
|
|
18
|
+
<% parameters.forEach(function(param) { -%>
|
|
19
|
+
* @param <%- param.name %> <%- param.description %>
|
|
20
|
+
<% }) -%>
|
|
10
21
|
*/
|
|
11
|
-
export function <%- eventHandlerFnName %>(this: ExtensionAPI,
|
|
22
|
+
export function <%- eventHandlerFnName %>(this: ExtensionAPI, <%=
|
|
23
|
+
parameters.map(function(param) {
|
|
24
|
+
return param.name + ": " + (param.paramType ?? param.importType);
|
|
25
|
+
}).join(", ")
|
|
26
|
+
%>) {
|
|
12
27
|
MessageToast.show("Custom handler invoked.");
|
|
13
28
|
}
|