call.service.command
CallServiceCommand : d2/sdk/commands/call.service.command
Base class for implementing command/menu that invokes a D2FS serive method. D2 Smartview runtime already provides an OOTB binding for such a command implementation. However, to suit particular business needs where an OOTB binding does not suffice, a new implementation extending from this module can be used to define such custom bindings.
Extends: CommandModel
See
Example (to register binding for a custom implementation, add in extension.json)
{
"d2/sdk/commands/node.actions.rules": {
"extensions": {
"mybundle": {
"mybundle/commands/my.node.actions.rules"
}
}
}
}
Example (whereas my.node.actions.rules.js is defined similar to)
define([], function(){
'use strict';
return [
{
command_key: 'D2-CustomCallService',
decides: function(item) {
return item.action === 'D2_ACTION_EXECUTE' &&
item.actionParameters && item.actionParameters.eService === 'PermissionActionService';
}
iconName: 'some_icon'
}
];
});
Example ( to register an implementation with command collection, in extension.json )
{
"d2/sdk/utils/commands": {
"extensions": {
"mybundle": {
"mybundle/commands/my.custom.call.service"
}
}
}
}
Example (module mybundle/commands/my.custom.call.service can be defined as)
define([
'nuc/lib/jquery',
'd2/sdk/commands/call.service.command'
], function($, CallServiceCommandImpl){
var MyCustomCallService = CallServiceCommandImpl.extend({
defaults: {
command_key: 'D2-CustomCallService',
signature: 'D2-CustomCallService',
name: 'Custom call service'
},
constructor: function MyCustomCallService(attr, options) {
MyCustomCallService.__super__.constructor.call(this, attr, options);
}
beforeServiceCall: function(nodes, commandData) {
var requestProperties = {};
//Custom logic to populate
return requestProperties; //It will be mixed with other default properties as part of request body while sending d2-generic-action-service
},
afterServiceCall: function(nodes, commandData, responseProperties) {
//Custom logic to modify responseProperties
//Later this modified responseProperties becomes input for final JS action invocation.
}
});
return MyCustomCallService;
});
- CallServiceCommand :
d2/sdk/commands/call.service.command
CallServiceCommand~beforeServiceCall(nodes, commandData) ⇒ Object
Make changes to the request properties sent out for underlying D2-REST API call.
Kind: inner method of CallServiceCommand
Returns: Object
- Returns the final propoerties set to be used as part of request body. Will also be mixed with the default properties.
Param | Type | Description |
---|---|---|
nodes | Array.<NodeModel> | Selected NodeModel objects upon which the command is being run. |
commandData | Object | Object hash containing the default invocation properties |
CallServiceCommand~afterServiceCall(nodes, commandData, responseProperties) ⇒
Change invocation data for final JS action
Kind: inner method of CallServiceCommand
Returns: void
Param | Type | Description |
---|---|---|
nodes | Array.<NodeModel> | Selected NodeModel objects upon which the command is being run. |
commandData | Object | Object hash containing the default invocation properties |
responseProperties | Object | Raw response from underlying D2-REST API call. The same object is also used to invoke final JS action. |