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

Some formatting updates
pull/6/head
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,207 +1,202 @@
'use strict'; 'use strict';
define( define([
[ 'underscore',
'underscore', 'marionette',
'marionette', 'backgrid',
'backgrid', 'Wanted/Cutoff/CutoffUnmetCollection',
'Wanted/Cutoff/CutoffUnmetCollection', 'Cells/SeriesTitleCell',
'Cells/SeriesTitleCell', 'Cells/EpisodeNumberCell',
'Cells/EpisodeNumberCell', 'Cells/EpisodeTitleCell',
'Cells/EpisodeTitleCell', 'Cells/RelativeDateCell',
'Cells/RelativeDateCell', 'Cells/EpisodeStatusCell',
'Cells/EpisodeStatusCell', 'Shared/Grid/Pager',
'Shared/Grid/Pager', 'Shared/Toolbar/ToolbarLayout',
'Shared/Toolbar/ToolbarLayout', 'Shared/LoadingView',
'Shared/LoadingView', 'Shared/Messenger',
'Shared/Messenger', 'Commands/CommandController',
'Commands/CommandController', 'backgrid.selectall'
'backgrid.selectall' ], function (_,
], function (_, Marionette,
Marionette, Backgrid,
Backgrid, CutoffUnmetCollection,
CutoffUnmetCollection, SeriesTitleCell,
SeriesTitleCell, EpisodeNumberCell,
EpisodeNumberCell, EpisodeTitleCell,
EpisodeTitleCell, RelativeDateCell,
RelativeDateCell, EpisodeStatusCell,
EpisodeStatusCell, GridPager,
GridPager, ToolbarLayout,
ToolbarLayout, LoadingView,
LoadingView, 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 : {
searchSelectedButton : '.btn i.icon-search'
},
columns : [
{
name : '',
cell : 'select-row',
headerCell : 'select-all',
sortable : false
}, },
{
ui: { name : 'series',
searchSelectedButton: '.btn i.icon-search' label : 'Series Title',
sortable : false,
cell : SeriesTitleCell
}, },
{
columns: name : 'this',
[ label : 'Episode',
{ sortable : false,
name : '', cell : EpisodeNumberCell
cell : 'select-row', },
headerCell: 'select-all', {
sortable : false name : 'this',
}, label : 'Episode Title',
{ sortable : false,
name : 'series', cell : EpisodeTitleCell
label : 'Series Title', },
sortable : false, {
cell : SeriesTitleCell name : 'airDateUtc',
}, label : 'Air Date',
cell : RelativeDateCell
},
{
name : 'status',
label : 'Status',
cell : EpisodeStatusCell,
sortable : false
}
],
initialize : function () {
this.collection = new CutoffUnmetCollection();
this.listenTo(this.collection, 'sync', this._showTable);
},
onShow : function () {
this.cutoff.show(new LoadingView());
this._showToolbar();
this.collection.fetch();
},
_showTable : function () {
this.cutoffGrid = new Backgrid.Grid({
columns : this.columns,
collection : this.collection,
className : 'table table-hover'
});
this.cutoff.show(this.cutoffGrid);
this.pager.show(new GridPager({
columns : this.columns,
collection : this.collection
}));
},
_showToolbar : function () {
var leftSideButtons = {
type : 'default',
storeState : false,
items : [
{ {
name : 'this', title : 'Search Selected',
label : 'Episode', icon : 'icon-search',
sortable : false, callback : this._searchSelected,
cell : EpisodeNumberCell ownerContext : this,
className : 'x-search-selected'
}, },
{ {
name : 'this', title : 'Season Pass',
label : 'Episode Title', icon : 'icon-bookmark',
sortable : false, route : 'seasonpass'
cell : EpisodeTitleCell, }
}, ]
};
var filterOptions = {
type : 'radio',
storeState : false,
menuKey : 'wanted.filterMode',
defaultAction : 'monitored',
items : [
{ {
name : 'airDateUtc', key : 'monitored',
label : 'Air Date', title : '',
cell : RelativeDateCell tooltip : 'Monitored Only',
icon : 'icon-nd-monitored',
callback : this._setFilter
}, },
{ {
name : 'status', key : 'unmonitored',
label : 'Status', title : '',
cell : EpisodeStatusCell, tooltip : 'Unmonitored Only',
sortable: false icon : 'icon-nd-unmonitored',
callback : this._setFilter
} }
], ]
};
initialize: function () { this.toolbar.show(new ToolbarLayout({
this.collection = new CutoffUnmetCollection(); left : [
leftSideButtons
],
right : [
filterOptions
],
context : this
}));
this.listenTo(this.collection, 'sync', this._showTable); CommandController.bindToCommand({
}, element : this.$('.x-search-selected'),
command : {
name : 'episodeSearch'
}
});
},
onShow: function () { _setFilter : function (buttonContext) {
this.cutoff.show(new LoadingView()); var mode = buttonContext.model.get('key');
this._showToolbar();
this.collection.fetch();
},
_showTable: function () { this.collection.state.currentPage = 1;
this.cutoffGrid = new Backgrid.Grid({ var promise = this.collection.setFilterMode(mode);
columns : this.columns,
collection: this.collection,
className : 'table table-hover'
});
this.cutoff.show(this.cutoffGrid); if (buttonContext) {
buttonContext.ui.icon.spinForPromise(promise);
}
},
this.pager.show(new GridPager({ _searchSelected : function () {
columns : this.columns, var selected = this.cutoffGrid.getSelectedModels();
collection: this.collection
}));
},
_showToolbar: function () { if (selected.length === 0) {
var leftSideButtons = { Messenger.show({
type : 'default', type : 'error',
storeState: false, message : 'No episodes selected'
items :
[
{
title: 'Search Selected',
icon : 'icon-search',
callback: this._searchSelected,
ownerContext: this
},
{
title: 'Season Pass',
icon : 'icon-bookmark',
route: 'seasonpass'
}
]
};
var filterOptions = {
type : 'radio',
storeState : false,
menuKey : 'wanted.filterMode',
defaultAction : 'monitored',
items :
[
{
key : 'monitored',
title : '',
tooltip : 'Monitored Only',
icon : 'icon-nd-monitored',
callback : this._setFilter
},
{
key : 'unmonitored',
title : '',
tooltip : 'Unmonitored Only',
icon : 'icon-nd-unmonitored',
callback : this._setFilter
}
]
};
this.toolbar.show(new ToolbarLayout({
left :
[
leftSideButtons
],
right :
[
filterOptions
],
context: this
}));
CommandController.bindToCommand({
element: this.$('.x-toolbar-left-1 .btn i.icon-search'),
command: {
name: 'episodeSearch'
}
}); });
},
_setFilter: function(buttonContext) {
var mode = buttonContext.model.get('key');
this.collection.state.currentPage = 1;
var promise = this.collection.setFilterMode(mode);
if (buttonContext) {
buttonContext.ui.icon.spinForPromise(promise);
}
},
_searchSelected: function () {
var selected = this.cutoffGrid.getSelectedModels();
if (selected.length === 0) { return;
Messenger.show({ }
type: 'error',
message: 'No episodes selected'
});
return;
}
var ids = _.pluck(selected, 'id'); var ids = _.pluck(selected, 'id');
CommandController.Execute('episodeSearch', { CommandController.Execute('episodeSearch', {
name : 'episodeSearch', name : 'episodeSearch',
episodeIds: ids episodeIds : ids
}); });
} }
});
}); });
});

@ -1,231 +1,233 @@
'use strict'; 'use strict';
define( define([
[ 'underscore',
'underscore', 'marionette',
'marionette', 'backgrid',
'backgrid', 'Wanted/Missing/MissingCollection',
'Wanted/Missing/MissingCollection', 'Cells/SeriesTitleCell',
'Cells/SeriesTitleCell', 'Cells/EpisodeNumberCell',
'Cells/EpisodeNumberCell', 'Cells/EpisodeTitleCell',
'Cells/EpisodeTitleCell', 'Cells/RelativeDateCell',
'Cells/RelativeDateCell', 'Cells/EpisodeStatusCell',
'Cells/EpisodeStatusCell', 'Shared/Grid/Pager',
'Shared/Grid/Pager', 'Shared/Toolbar/ToolbarLayout',
'Shared/Toolbar/ToolbarLayout', 'Shared/LoadingView',
'Shared/LoadingView', 'Shared/Messenger',
'Shared/Messenger', 'Commands/CommandController',
'Commands/CommandController', 'backgrid.selectall'
'backgrid.selectall' ], function (_,
], function (_, Marionette,
Marionette, Backgrid,
Backgrid, MissingCollection,
MissingCollection, SeriesTitleCell,
SeriesTitleCell, EpisodeNumberCell,
EpisodeNumberCell, EpisodeTitleCell,
EpisodeTitleCell, RelativeDateCell,
RelativeDateCell, EpisodeStatusCell,
EpisodeStatusCell, GridPager,
GridPager, ToolbarLayout,
ToolbarLayout, LoadingView,
LoadingView, 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 : {
searchSelectedButton : '.btn i.icon-search'
},
columns : [
{
name : '',
cell : 'select-row',
headerCell : 'select-all',
sortable : false
}, },
{
ui: { name : 'series',
searchSelectedButton: '.btn i.icon-search' label : 'Series Title',
sortable : false,
cell : SeriesTitleCell
}, },
{
columns: name : 'this',
[ label : 'Episode',
sortable : false,
cell : EpisodeNumberCell
},
{
name : 'this',
label : 'Episode Title',
sortable : false,
cell : EpisodeTitleCell
},
{
name : 'airDateUtc',
label : 'Air Date',
cell : RelativeDateCell
},
{
name : 'status',
label : 'Status',
cell : EpisodeStatusCell,
sortable : false
}
],
initialize : function () {
this.collection = new MissingCollection();
this.listenTo(this.collection, 'sync', this._showTable);
},
onShow : function () {
this.missing.show(new LoadingView());
this._showToolbar();
this.collection.fetch();
},
_showTable : function () {
this.missingGrid = new Backgrid.Grid({
columns : this.columns,
collection : this.collection,
className : 'table table-hover'
});
this.missing.show(this.missingGrid);
this.pager.show(new GridPager({
columns : this.columns,
collection : this.collection
}));
},
_showToolbar : function () {
var leftSideButtons = {
type : 'default',
storeState : false,
collapse : true,
items : [
{ {
name : '', title : 'Search Selected',
cell : 'select-row', icon : 'icon-search',
headerCell: 'select-all', callback : this._searchSelected,
sortable : false ownerContext : this,
className : 'x-search-selected'
}, },
{ {
name : 'series', title : 'Search All Missing',
label : 'Series Title', icon : 'icon-search',
sortable : false, callback : this._searchMissing,
cell : SeriesTitleCell ownerContext : this,
className : 'x-search-missing'
}, },
{ {
name : 'this', title : 'Season Pass',
label : 'Episode', icon : 'icon-bookmark',
sortable : false, route : 'seasonpass'
cell : EpisodeNumberCell
}, },
{ {
name : 'this', title : 'Rescan Drone Factory Folder',
label : 'Episode Title', icon : 'icon-refresh',
sortable : false, command : 'downloadedepisodesscan',
cell : EpisodeTitleCell properties : {
}, sendUpdates : true
}
}
]
};
var filterOptions = {
type : 'radio',
storeState : false,
menuKey : 'wanted.filterMode',
defaultAction : 'monitored',
items : [
{ {
name : 'airDateUtc', key : 'monitored',
label : 'Air Date', title : '',
cell : RelativeDateCell tooltip : 'Monitored Only',
icon : 'icon-nd-monitored',
callback : this._setFilter
}, },
{ {
name : 'status', key : 'unmonitored',
label : 'Status', title : '',
cell : EpisodeStatusCell, tooltip : 'Unmonitored Only',
sortable: false icon : 'icon-nd-unmonitored',
callback : this._setFilter
} }
]
};
this.toolbar.show(new ToolbarLayout({
left : [
leftSideButtons
], ],
right : [
filterOptions
],
context : this
}));
initialize: function () { CommandController.bindToCommand({
this.collection = new MissingCollection(); element : this.$('.x-search-selected'),
command : {
name : 'episodeSearch'
}
});
this.listenTo(this.collection, 'sync', this._showTable); CommandController.bindToCommand({
}, element : this.$('.x-search-missing'),
command : {
name : 'missingEpisodeSearch'
}
});
},
onShow: function () { _setFilter : function (buttonContext) {
this.missing.show(new LoadingView()); var mode = buttonContext.model.get('key');
this._showToolbar();
this.collection.fetch();
},
_showTable: function () { this.collection.state.currentPage = 1;
this.missingGrid = new Backgrid.Grid({ var promise = this.collection.setFilterMode(mode);
columns : this.columns,
collection: this.collection,
className : 'table table-hover'
});
this.missing.show(this.missingGrid); if (buttonContext) {
buttonContext.ui.icon.spinForPromise(promise);
}
},
this.pager.show(new GridPager({ _searchSelected : function () {
columns : this.columns, var selected = this.missingGrid.getSelectedModels();
collection: this.collection
}));
},
_showToolbar: function () { if (selected.length === 0) {
var leftSideButtons = { Messenger.show({
type : 'default', type : 'error',
storeState : false, message : 'No episodes selected'
collapse : true,
items :
[
{
title: 'Search Selected',
icon : 'icon-search',
callback: this._searchSelected,
ownerContext: this
},
{
title: 'Search All Missing',
icon : 'icon-search',
callback: this._searchMissing,
ownerContext: this
},
{
title: 'Season Pass',
icon : 'icon-bookmark',
route: 'seasonpass'
},
{
title: 'Rescan Drone Factory Folder',
icon : 'icon-refresh',
command: 'downloadedepisodesscan',
properties: {
sendUpdates: true
}
}
]
};
var filterOptions = {
type : 'radio',
storeState : false,
menuKey : 'wanted.filterMode',
defaultAction : 'monitored',
items :
[
{
key : 'monitored',
title : '',
tooltip : 'Monitored Only',
icon : 'icon-nd-monitored',
callback : this._setFilter
},
{
key : 'unmonitored',
title : '',
tooltip : 'Unmonitored Only',
icon : 'icon-nd-unmonitored',
callback : this._setFilter
}
]
};
this.toolbar.show(new ToolbarLayout({
left :
[
leftSideButtons
],
right :
[
filterOptions
],
context: this
}));
CommandController.bindToCommand({
element: this.$('.x-toolbar-left-1 .btn i.icon-search'),
command: {
name: 'episodeSearch'
}
}); });
},
_setFilter: function(buttonContext) {
var mode = buttonContext.model.get('key');
this.collection.state.currentPage = 1;
var promise = this.collection.setFilterMode(mode);
if (buttonContext)
buttonContext.ui.icon.spinForPromise(promise);
},
_searchSelected: function () {
var selected = this.missingGrid.getSelectedModels();
if (selected.length === 0) { return;
Messenger.show({ }
type: 'error',
message: 'No episodes selected'
});
return; var ids = _.pluck(selected, 'id');
}
var ids = _.pluck(selected, 'id'); CommandController.Execute('episodeSearch', {
name : 'episodeSearch',
episodeIds : ids
});
},
CommandController.Execute('episodeSearch', { _searchMissing : function () {
name : 'episodeSearch', 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.')) {
episodeIds: ids CommandController.Execute('missingEpisodeSearch', {
name : 'missingEpisodeSearch'
}); });
},
_searchMissing: function () {
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.')) {
CommandController.Execute('missingEpisodeSearch', {
name : 'missingEpisodeSearch'
});
}
} }
}); }
}); });
});

Loading…
Cancel
Save