Fixed: Searching from missing won't trigger spinner on both buttons

Some formatting updates
pull/75/merge
Mark McDowall 11 years ago
parent e7683642dd
commit 2fdb0513e8

@ -17,6 +17,7 @@
<option name="VALUE_ALIGNMENT" value="1" /> <option name="VALUE_ALIGNMENT" value="1" />
</CssCodeStyleSettings> </CssCodeStyleSettings>
<JSCodeStyleSettings> <JSCodeStyleSettings>
<option name="SPACE_BEFORE_PROPERTY_COLON" value="true" />
<option name="ALIGN_OBJECT_PROPERTIES" value="2" /> <option name="ALIGN_OBJECT_PROPERTIES" value="2" />
</JSCodeStyleSettings> </JSCodeStyleSettings>
<XML> <XML>
@ -33,8 +34,7 @@
<option name="ELSE_ON_NEW_LINE" value="true" /> <option name="ELSE_ON_NEW_LINE" value="true" />
<option name="CATCH_ON_NEW_LINE" value="true" /> <option name="CATCH_ON_NEW_LINE" value="true" />
<option name="FINALLY_ON_NEW_LINE" value="true" /> <option name="FINALLY_ON_NEW_LINE" value="true" />
<option name="ALIGN_MULTILINE_PARAMETERS" value="false" /> <option name="SPACE_BEFORE_METHOD_PARENTHESES" value="true" />
<option name="SPACE_AFTER_COLON" value="false" />
<option name="METHOD_PARAMETERS_WRAP" value="5" /> <option name="METHOD_PARAMETERS_WRAP" value="5" />
<option name="ARRAY_INITIALIZER_WRAP" value="2" /> <option name="ARRAY_INITIALIZER_WRAP" value="2" />
<option name="IF_BRACE_FORCE" value="3" /> <option name="IF_BRACE_FORCE" value="3" />

@ -33,6 +33,10 @@ define(
this.$el.addClass('btn-icon-only'); this.$el.addClass('btn-icon-only');
} }
if (this.model.get('className')) {
this.$el.addClass(this.model.get('className'));
}
var command = this.model.get('command'); var command = this.model.get('command');
if (command) { if (command) {
var properties = _.extend({ name: command }, this.model.get('properties')); var properties = _.extend({ name: command }, this.model.get('properties'));

@ -1,6 +1,5 @@
'use strict'; 'use strict';
define( define([
[
'underscore', 'underscore',
'marionette', 'marionette',
'backgrid', 'backgrid',
@ -16,7 +15,7 @@ define(
'Shared/Messenger', 'Shared/Messenger',
'Commands/CommandController', 'Commands/CommandController',
'backgrid.selectall' 'backgrid.selectall'
], function (_, ], function (_,
Marionette, Marionette,
Backgrid, Backgrid,
CutoffUnmetCollection, CutoffUnmetCollection,
@ -31,24 +30,23 @@ define(
Messenger, Messenger,
CommandController) { CommandController) {
return Marionette.Layout.extend({ return Marionette.Layout.extend({
template: 'Wanted/Cutoff/CutoffUnmetLayoutTemplate', template : 'Wanted/Cutoff/CutoffUnmetLayoutTemplate',
regions: { regions : {
cutoff : '#x-cutoff-unmet', cutoff : '#x-cutoff-unmet',
toolbar : '#x-toolbar', toolbar : '#x-toolbar',
pager : '#x-pager' pager : '#x-pager'
}, },
ui: { ui : {
searchSelectedButton: '.btn i.icon-search' searchSelectedButton : '.btn i.icon-search'
}, },
columns: columns : [
[
{ {
name : '', name : '',
cell : 'select-row', cell : 'select-row',
headerCell: 'select-all', headerCell : 'select-all',
sortable : false sortable : false
}, },
{ {
@ -67,7 +65,7 @@ define(
name : 'this', name : 'this',
label : 'Episode Title', label : 'Episode Title',
sortable : false, sortable : false,
cell : EpisodeTitleCell, cell : EpisodeTitleCell
}, },
{ {
name : 'airDateUtc', name : 'airDateUtc',
@ -78,26 +76,26 @@ define(
name : 'status', name : 'status',
label : 'Status', label : 'Status',
cell : EpisodeStatusCell, cell : EpisodeStatusCell,
sortable: false sortable : false
} }
], ],
initialize: function () { initialize : function () {
this.collection = new CutoffUnmetCollection(); this.collection = new CutoffUnmetCollection();
this.listenTo(this.collection, 'sync', this._showTable); this.listenTo(this.collection, 'sync', this._showTable);
}, },
onShow: function () { onShow : function () {
this.cutoff.show(new LoadingView()); this.cutoff.show(new LoadingView());
this._showToolbar(); this._showToolbar();
this.collection.fetch(); this.collection.fetch();
}, },
_showTable: function () { _showTable : function () {
this.cutoffGrid = new Backgrid.Grid({ this.cutoffGrid = new Backgrid.Grid({
columns : this.columns, columns : this.columns,
collection: this.collection, collection : this.collection,
className : 'table table-hover' className : 'table table-hover'
}); });
@ -105,26 +103,26 @@ define(
this.pager.show(new GridPager({ this.pager.show(new GridPager({
columns : this.columns, columns : this.columns,
collection: this.collection collection : this.collection
})); }));
}, },
_showToolbar: function () { _showToolbar : function () {
var leftSideButtons = { var leftSideButtons = {
type : 'default', type : 'default',
storeState: false, storeState : false,
items : items : [
[
{ {
title: 'Search Selected', title : 'Search Selected',
icon : 'icon-search', icon : 'icon-search',
callback: this._searchSelected, callback : this._searchSelected,
ownerContext: this ownerContext : this,
className : 'x-search-selected'
}, },
{ {
title: 'Season Pass', title : 'Season Pass',
icon : 'icon-bookmark', icon : 'icon-bookmark',
route: 'seasonpass' route : 'seasonpass'
} }
] ]
}; };
@ -134,8 +132,7 @@ define(
storeState : false, storeState : false,
menuKey : 'wanted.filterMode', menuKey : 'wanted.filterMode',
defaultAction : 'monitored', defaultAction : 'monitored',
items : items : [
[
{ {
key : 'monitored', key : 'monitored',
title : '', title : '',
@ -154,26 +151,24 @@ define(
}; };
this.toolbar.show(new ToolbarLayout({ this.toolbar.show(new ToolbarLayout({
left : left : [
[
leftSideButtons leftSideButtons
], ],
right : right : [
[
filterOptions filterOptions
], ],
context: this context : this
})); }));
CommandController.bindToCommand({ CommandController.bindToCommand({
element: this.$('.x-toolbar-left-1 .btn i.icon-search'), element : this.$('.x-search-selected'),
command: { command : {
name: 'episodeSearch' name : 'episodeSearch'
} }
}); });
}, },
_setFilter: function(buttonContext) { _setFilter : function (buttonContext) {
var mode = buttonContext.model.get('key'); var mode = buttonContext.model.get('key');
this.collection.state.currentPage = 1; this.collection.state.currentPage = 1;
@ -184,13 +179,13 @@ define(
} }
}, },
_searchSelected: function () { _searchSelected : function () {
var selected = this.cutoffGrid.getSelectedModels(); var selected = this.cutoffGrid.getSelectedModels();
if (selected.length === 0) { if (selected.length === 0) {
Messenger.show({ Messenger.show({
type: 'error', type : 'error',
message: 'No episodes selected' message : 'No episodes selected'
}); });
return; return;
@ -200,8 +195,8 @@ define(
CommandController.Execute('episodeSearch', { CommandController.Execute('episodeSearch', {
name : 'episodeSearch', name : 'episodeSearch',
episodeIds: ids episodeIds : ids
}); });
} }
}); });
}); });

@ -1,6 +1,5 @@
'use strict'; 'use strict';
define( define([
[
'underscore', 'underscore',
'marionette', 'marionette',
'backgrid', 'backgrid',
@ -16,7 +15,7 @@ define(
'Shared/Messenger', 'Shared/Messenger',
'Commands/CommandController', 'Commands/CommandController',
'backgrid.selectall' 'backgrid.selectall'
], function (_, ], function (_,
Marionette, Marionette,
Backgrid, Backgrid,
MissingCollection, MissingCollection,
@ -31,24 +30,23 @@ define(
Messenger, Messenger,
CommandController) { CommandController) {
return Marionette.Layout.extend({ return Marionette.Layout.extend({
template: 'Wanted/Missing/MissingLayoutTemplate', template : 'Wanted/Missing/MissingLayoutTemplate',
regions: { regions : {
missing: '#x-missing', missing : '#x-missing',
toolbar: '#x-toolbar', toolbar : '#x-toolbar',
pager : '#x-pager' pager : '#x-pager'
}, },
ui: { ui : {
searchSelectedButton: '.btn i.icon-search' searchSelectedButton : '.btn i.icon-search'
}, },
columns: columns : [
[
{ {
name : '', name : '',
cell : 'select-row', cell : 'select-row',
headerCell: 'select-all', headerCell : 'select-all',
sortable : false sortable : false
}, },
{ {
@ -78,26 +76,26 @@ define(
name : 'status', name : 'status',
label : 'Status', label : 'Status',
cell : EpisodeStatusCell, cell : EpisodeStatusCell,
sortable: false sortable : false
} }
], ],
initialize: function () { initialize : function () {
this.collection = new MissingCollection(); this.collection = new MissingCollection();
this.listenTo(this.collection, 'sync', this._showTable); this.listenTo(this.collection, 'sync', this._showTable);
}, },
onShow: function () { onShow : function () {
this.missing.show(new LoadingView()); this.missing.show(new LoadingView());
this._showToolbar(); this._showToolbar();
this.collection.fetch(); this.collection.fetch();
}, },
_showTable: function () { _showTable : function () {
this.missingGrid = new Backgrid.Grid({ this.missingGrid = new Backgrid.Grid({
columns : this.columns, columns : this.columns,
collection: this.collection, collection : this.collection,
className : 'table table-hover' className : 'table table-hover'
}); });
@ -105,40 +103,41 @@ define(
this.pager.show(new GridPager({ this.pager.show(new GridPager({
columns : this.columns, columns : this.columns,
collection: this.collection collection : this.collection
})); }));
}, },
_showToolbar: function () { _showToolbar : function () {
var leftSideButtons = { var leftSideButtons = {
type : 'default', type : 'default',
storeState : false, storeState : false,
collapse : true, collapse : true,
items : items : [
[
{ {
title: 'Search Selected', title : 'Search Selected',
icon : 'icon-search', icon : 'icon-search',
callback: this._searchSelected, callback : this._searchSelected,
ownerContext: this ownerContext : this,
className : 'x-search-selected'
}, },
{ {
title: 'Search All Missing', title : 'Search All Missing',
icon : 'icon-search', icon : 'icon-search',
callback: this._searchMissing, callback : this._searchMissing,
ownerContext: this ownerContext : this,
className : 'x-search-missing'
}, },
{ {
title: 'Season Pass', title : 'Season Pass',
icon : 'icon-bookmark', icon : 'icon-bookmark',
route: 'seasonpass' route : 'seasonpass'
}, },
{ {
title: 'Rescan Drone Factory Folder', title : 'Rescan Drone Factory Folder',
icon : 'icon-refresh', icon : 'icon-refresh',
command: 'downloadedepisodesscan', command : 'downloadedepisodesscan',
properties: { properties : {
sendUpdates: true sendUpdates : true
} }
} }
] ]
@ -149,8 +148,7 @@ define(
storeState : false, storeState : false,
menuKey : 'wanted.filterMode', menuKey : 'wanted.filterMode',
defaultAction : 'monitored', defaultAction : 'monitored',
items : items : [
[
{ {
key : 'monitored', key : 'monitored',
title : '', title : '',
@ -169,42 +167,48 @@ define(
}; };
this.toolbar.show(new ToolbarLayout({ this.toolbar.show(new ToolbarLayout({
left : left : [
[
leftSideButtons leftSideButtons
], ],
right : right : [
[
filterOptions filterOptions
], ],
context: this context : this
})); }));
CommandController.bindToCommand({ CommandController.bindToCommand({
element: this.$('.x-toolbar-left-1 .btn i.icon-search'), element : this.$('.x-search-selected'),
command: { command : {
name: 'episodeSearch' name : 'episodeSearch'
}
});
CommandController.bindToCommand({
element : this.$('.x-search-missing'),
command : {
name : 'missingEpisodeSearch'
} }
}); });
}, },
_setFilter: function(buttonContext) { _setFilter : function (buttonContext) {
var mode = buttonContext.model.get('key'); var mode = buttonContext.model.get('key');
this.collection.state.currentPage = 1; this.collection.state.currentPage = 1;
var promise = this.collection.setFilterMode(mode); var promise = this.collection.setFilterMode(mode);
if (buttonContext) if (buttonContext) {
buttonContext.ui.icon.spinForPromise(promise); buttonContext.ui.icon.spinForPromise(promise);
}
}, },
_searchSelected: function () { _searchSelected : function () {
var selected = this.missingGrid.getSelectedModels(); var selected = this.missingGrid.getSelectedModels();
if (selected.length === 0) { if (selected.length === 0) {
Messenger.show({ Messenger.show({
type: 'error', type : 'error',
message: 'No episodes selected' message : 'No episodes selected'
}); });
return; return;
@ -214,18 +218,16 @@ define(
CommandController.Execute('episodeSearch', { CommandController.Execute('episodeSearch', {
name : 'episodeSearch', name : 'episodeSearch',
episodeIds: ids episodeIds : ids
}); });
}, },
_searchMissing: function () { _searchMissing : function () {
if (window.confirm('Are you sure you want to search for {0} missing episodes? '.format(this.collection.state.totalRecords) + if (window.confirm('Are you sure you want to search for {0} missing episodes? '.format(this.collection.state.totalRecords) + 'One API request to each indexer will be used for each episode. ' + 'This cannot be stopped once started.')) {
'One API request to each indexer will be used for each episode. ' +
'This cannot be stopped once started.')) {
CommandController.Execute('missingEpisodeSearch', { CommandController.Execute('missingEpisodeSearch', {
name : 'missingEpisodeSearch' name : 'missingEpisodeSearch'
}); });
} }
} }
}); });
}); });

Loading…
Cancel
Save