mirror of https://github.com/Sonarr/Sonarr
Required toolbar
This commit is contained in:
parent
e856a31a4d
commit
56cf3555a6
|
@ -1,8 +1,8 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
define(['app', 'Shared/Toolbar/Button/ButtonView', 'Config'], function () {
|
define(['app', 'Shared/Toolbar/Button/ButtonView', 'Config'], function (App, ButtonView, Config) {
|
||||||
NzbDrone.Shared.Toolbar.ButtonCollectionView = Backbone.Marionette.CollectionView.extend({
|
return Backbone.Marionette.CollectionView.extend({
|
||||||
className: 'btn-group',
|
className: 'btn-group',
|
||||||
itemView : NzbDrone.Shared.Toolbar.ButtonView
|
itemView : ButtonView
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,11 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
define(['app', 'Config', 'Commands/CommandController', 'Shared/Messenger'], function () {
|
define(['app', 'Config', 'Commands/CommandController', 'Shared/Messenger'],
|
||||||
|
function (App,
|
||||||
|
Config,
|
||||||
|
CommandController,
|
||||||
|
Messenger) {
|
||||||
|
|
||||||
NzbDrone.Shared.Toolbar.ButtonView = Backbone.Marionette.ItemView.extend({
|
return Backbone.Marionette.ItemView.extend({
|
||||||
template : 'Shared/Toolbar/ButtonTemplate',
|
template : 'Shared/Toolbar/ButtonTemplate',
|
||||||
className: 'btn',
|
className: 'btn',
|
||||||
|
|
||||||
|
@ -13,7 +17,6 @@ define(['app', 'Config', 'Commands/CommandController', 'Shared/Messenger'], func
|
||||||
icon: '.x-icon'
|
icon: '.x-icon'
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
initialize: function () {
|
initialize: function () {
|
||||||
this.storageKey = this.model.get('menuKey') + ':' + this.model.get('key');
|
this.storageKey = this.model.get('menuKey') + ':' + this.model.get('key');
|
||||||
this.idle = true;
|
this.idle = true;
|
||||||
|
@ -34,7 +37,6 @@ define(['app', 'Config', 'Commands/CommandController', 'Shared/Messenger'], func
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
invokeCommand: function () {
|
invokeCommand: function () {
|
||||||
var command = this.model.get('command');
|
var command = this.model.get('command');
|
||||||
if (command) {
|
if (command) {
|
||||||
|
@ -43,10 +45,10 @@ define(['app', 'Config', 'Commands/CommandController', 'Shared/Messenger'], func
|
||||||
this.ui.icon.addClass('icon-spinner icon-spin');
|
this.ui.icon.addClass('icon-spinner icon-spin');
|
||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
var commandPromise = NzbDrone.Commands.Execute(command);
|
var commandPromise = CommandController.Execute(command);
|
||||||
commandPromise.done(function () {
|
commandPromise.done(function () {
|
||||||
if (self.model.get('successMessage')) {
|
if (self.model.get('successMessage')) {
|
||||||
NzbDrone.Shared.Messenger.show({
|
Messenger.show({
|
||||||
message: self.model.get('successMessage')
|
message: self.model.get('successMessage')
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -57,7 +59,7 @@ define(['app', 'Config', 'Commands/CommandController', 'Shared/Messenger'], func
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (self.model.get('errorMessage')) {
|
if (self.model.get('errorMessage')) {
|
||||||
NzbDrone.Shared.Messenger.show({
|
Messenger.show({
|
||||||
message: self.model.get('errorMessage'),
|
message: self.model.get('errorMessage'),
|
||||||
type : 'error'
|
type : 'error'
|
||||||
});
|
});
|
||||||
|
@ -93,7 +95,6 @@ define(['app', 'Config', 'Commands/CommandController', 'Shared/Messenger'], func
|
||||||
callback.call(this.model.ownerContext);
|
callback.call(this.model.ownerContext);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
define(['app', 'Shared/Toolbar/ButtonModel'], function () {
|
define(['app', 'Shared/Toolbar/ButtonModel'], function () {
|
||||||
NzbDrone.Shared.Toolbar.ButtonCollection = Backbone.Collection.extend({
|
return Backbone.Collection.extend({
|
||||||
model: NzbDrone.Shared.Toolbar.ButtonModel
|
model: NzbDrone.Shared.Toolbar.ButtonModel
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -7,7 +7,7 @@ define(['app'], function () {
|
||||||
CallBack : 'CallBack'
|
CallBack : 'CallBack'
|
||||||
};
|
};
|
||||||
|
|
||||||
NzbDrone.Shared.Toolbar.ButtonModel = Backbone.Model.extend({
|
return Backbone.Model.extend({
|
||||||
defaults: {
|
defaults: {
|
||||||
'target' : '/nzbdrone/route',
|
'target' : '/nzbdrone/route',
|
||||||
'title' : '',
|
'title' : '',
|
||||||
|
|
|
@ -5,7 +5,7 @@ define(
|
||||||
'Shared/Toolbar/Radio/RadioButtonView',
|
'Shared/Toolbar/Radio/RadioButtonView',
|
||||||
'Config'
|
'Config'
|
||||||
], function (App, RadioButtonView, Config) {
|
], function (App, RadioButtonView, Config) {
|
||||||
NzbDrone.Shared.Toolbar.RadioButtonCollectionView = Backbone.Marionette.CollectionView.extend({
|
return Backbone.Marionette.CollectionView.extend({
|
||||||
className: 'btn-group',
|
className: 'btn-group',
|
||||||
itemView : NzbDrone.Shared.Toolbar.RadioButtonView,
|
itemView : NzbDrone.Shared.Toolbar.RadioButtonView,
|
||||||
|
|
||||||
|
|
|
@ -4,8 +4,14 @@ define(
|
||||||
'app',
|
'app',
|
||||||
'Shared/Toolbar/Radio/RadioButtonCollectionView',
|
'Shared/Toolbar/Radio/RadioButtonCollectionView',
|
||||||
'Shared/Toolbar/Button/ButtonCollectionView',
|
'Shared/Toolbar/Button/ButtonCollectionView',
|
||||||
'Shared/Toolbar/ButtonCollection'
|
'Shared/Toolbar/ButtonCollection',
|
||||||
], function () {
|
'Shared/Toolbar/ButtonModel'
|
||||||
|
],
|
||||||
|
function (App,
|
||||||
|
RadioButtonCollectionView,
|
||||||
|
ButtonCollectionView,
|
||||||
|
ButtonCollection,
|
||||||
|
ButtonModel) {
|
||||||
NzbDrone.Shared.Toolbar.ToolbarLayout = Backbone.Marionette.Layout.extend({
|
NzbDrone.Shared.Toolbar.ToolbarLayout = Backbone.Marionette.Layout.extend({
|
||||||
template: 'Shared/Toolbar/ToolbarLayoutTemplate',
|
template: 'Shared/Toolbar/ToolbarLayoutTemplate',
|
||||||
|
|
||||||
|
@ -32,7 +38,6 @@ define(
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
onShow: function () {
|
onShow: function () {
|
||||||
if (this.left) {
|
if (this.left) {
|
||||||
_.each(this.left, this._showToolbarLeft, this);
|
_.each(this.left, this._showToolbarLeft, this);
|
||||||
|
@ -53,7 +58,7 @@ define(
|
||||||
|
|
||||||
_showToolbar: function (buttonGroup, index, position) {
|
_showToolbar: function (buttonGroup, index, position) {
|
||||||
|
|
||||||
var groupCollection = new NzbDrone.Shared.Toolbar.ButtonCollection();
|
var groupCollection = new ButtonCollection();
|
||||||
|
|
||||||
_.each(buttonGroup.items, function (button) {
|
_.each(buttonGroup.items, function (button) {
|
||||||
|
|
||||||
|
@ -61,7 +66,7 @@ define(
|
||||||
throw 'must provide key for all buttons when storSstate is enabled';
|
throw 'must provide key for all buttons when storSstate is enabled';
|
||||||
}
|
}
|
||||||
|
|
||||||
var model = new NzbDrone.Shared.Toolbar.ButtonModel(button);
|
var model = new ButtonModel(button);
|
||||||
model.set('menuKey', buttonGroup.menuKey);
|
model.set('menuKey', buttonGroup.menuKey);
|
||||||
model.ownerContext = this.toolbarContext;
|
model.ownerContext = this.toolbarContext;
|
||||||
groupCollection.add(model);
|
groupCollection.add(model);
|
||||||
|
@ -73,7 +78,7 @@ define(
|
||||||
switch (buttonGroup.type) {
|
switch (buttonGroup.type) {
|
||||||
case 'radio':
|
case 'radio':
|
||||||
{
|
{
|
||||||
buttonGroupView = new NzbDrone.Shared.Toolbar.RadioButtonCollectionView({
|
buttonGroupView = new RadioButtonCollectionView({
|
||||||
collection: groupCollection,
|
collection: groupCollection,
|
||||||
menu : buttonGroup
|
menu : buttonGroup
|
||||||
});
|
});
|
||||||
|
@ -81,7 +86,7 @@ define(
|
||||||
}
|
}
|
||||||
default :
|
default :
|
||||||
{
|
{
|
||||||
buttonGroupView = new NzbDrone.Shared.Toolbar.ButtonCollectionView({
|
buttonGroupView = new ButtonCollectionView({
|
||||||
collection: groupCollection,
|
collection: groupCollection,
|
||||||
menu : buttonGroup
|
menu : buttonGroup
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue