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 :
d2/sdk/models/mixins/commandable.mixin
- instance
- static
- .mixin(prototype) ⇒
void
- .mixin(prototype) ⇒
- inner
- ~ActionOption :
Object
- ~ActionOption :
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.
Param | Type | Description |
---|---|---|
options | object | 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
Param | Type | Description |
---|---|---|
prototype | Object | The target prototype where the mixin methods will be fused. |
CommandableMixin~ActionOption : Object
Kind: inner typedef of CommandableMixin
Properties
Name | Type | Description |
---|---|---|
menuType | string | Controls the |
widgetType | string | Controls the |