Skip to main content

commandable.mixin

CommandableMixin : d2/sdk/models/mixins/commandable.mixin

Commandable mixin. Add action capability to a Backbone.Collection or Backbone.Model such that when the collection or model instance is synced with server, it fetches menu actions for the inidividual models.

promoted actions are fetched immediately but non-promoted actions are delayed until an external trigger.

Extends: Object
Example (A typical collection using this mixin may look like)

define([
'nuc/lib/backbone',
'd2/sdk/models/mixins/commandable.mixin'
], function(Backbone, CommandableMixin){
'use strict';

var MyCollection = Backbone.Collection.extend({
constructor: function MyCollection(models, options) {
options = options || {};
options.d2ActionsOptions = options.d2ActionsOptions || {
menuType: 'MenuContext',
widgetType: 'DoclistWidget'
};

MyCollection.__super__.constructor.call(this, models, options);

this.makeCommandable(options);
}
});

CommandableMixin.mixin(MyCollection.ptototype); //Can be equally mixed with a Backbone.Model prototype

return MyCollection;
});

commandableMixin.makeCommandable(options) ⇒ *

Does the necessary setup on an instance of Backbone.Model or Backbone.Collection so that it can fetch associated menu actions.

Kind: instance method of CommandableMixin
Returns: * - the model/collection instance itself.

ParamTypeDescription
optionsobject

Options hash

[options.delayedActionsOptions]ActionOption

Controls options for the delayed action fetch behavior

[options.nonPromotedActionsOptions]ActionOption

Controls options for the non-promoted action fetch behavior

[options.additionalActionsOptions]ActionOption

Controls options for the additional action fetch behavior

[options.d2ActionsOptions]ActionOption

Controls options for the delayed, non-promoted & additional action fetch behavior simultaneously unless the above corresponding options are also explicitly specified.

CommandableMixin.mixin(prototype) ⇒ void

Fuse the mixin methods to a prototype

Kind: static method of CommandableMixin

ParamTypeDescription
prototypeObject

The target prototype where the mixin methods will be fused.

CommandableMixin~ActionOption : Object

Kind: inner typedef of CommandableMixin
Properties

NameTypeDescription
menuTypestring

Controls the type query parameter sent during D2-REST actions endpoint invocation.

widgetTypestring

Controls the widgetType query parameter sent during D2-REST actions endpoint invocation.