mirror of
https://github.com/lidarr/Lidarr
synced 2025-01-30 19:02:06 +00:00
UI Cleanup - Updated Rename and SeasonPass subtrees.
This commit is contained in:
parent
860f55996c
commit
1bf433872a
11 changed files with 233 additions and 145 deletions
|
@ -2,26 +2,33 @@ var Backbone = require('backbone');
|
||||||
var RenamePreviewModel = require('./RenamePreviewModel');
|
var RenamePreviewModel = require('./RenamePreviewModel');
|
||||||
|
|
||||||
module.exports = Backbone.Collection.extend({
|
module.exports = Backbone.Collection.extend({
|
||||||
url : window.NzbDrone.ApiRoot + '/rename',
|
url : window.NzbDrone.ApiRoot + '/rename',
|
||||||
model : RenamePreviewModel,
|
model : RenamePreviewModel,
|
||||||
|
|
||||||
originalFetch : Backbone.Collection.prototype.fetch,
|
originalFetch : Backbone.Collection.prototype.fetch,
|
||||||
initialize : function(options){
|
|
||||||
if(!options.seriesId) {
|
initialize : function(options) {
|
||||||
|
if (!options.seriesId) {
|
||||||
throw 'seriesId is required';
|
throw 'seriesId is required';
|
||||||
}
|
}
|
||||||
|
|
||||||
this.seriesId = options.seriesId;
|
this.seriesId = options.seriesId;
|
||||||
this.seasonNumber = options.seasonNumber;
|
this.seasonNumber = options.seasonNumber;
|
||||||
},
|
},
|
||||||
fetch : function(options){
|
|
||||||
if(!this.seriesId) {
|
fetch : function(options) {
|
||||||
|
if (!this.seriesId) {
|
||||||
throw 'seriesId is required';
|
throw 'seriesId is required';
|
||||||
}
|
}
|
||||||
|
|
||||||
options = options || {};
|
options = options || {};
|
||||||
options.data = {};
|
options.data = {};
|
||||||
options.data.seriesId = this.seriesId;
|
options.data.seriesId = this.seriesId;
|
||||||
if(this.seasonNumber) {
|
|
||||||
|
if (this.seasonNumber) {
|
||||||
options.data.seasonNumber = this.seasonNumber;
|
options.data.seasonNumber = this.seasonNumber;
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.originalFetch.call(this, options);
|
return this.originalFetch.call(this, options);
|
||||||
}
|
}
|
||||||
});
|
});
|
|
@ -1,4 +1,6 @@
|
||||||
var Marionette = require('marionette');
|
var Marionette = require('marionette');
|
||||||
var RenamePreviewItemView = require('./RenamePreviewItemView');
|
var RenamePreviewItemView = require('./RenamePreviewItemView');
|
||||||
|
|
||||||
module.exports = Marionette.CollectionView.extend({itemView : RenamePreviewItemView});
|
module.exports = Marionette.CollectionView.extend({
|
||||||
|
itemView : RenamePreviewItemView
|
||||||
|
});
|
|
@ -1,4 +1,6 @@
|
||||||
var vent = require('vent');
|
var vent = require('vent');
|
||||||
var Marionette = require('marionette');
|
var Marionette = require('marionette');
|
||||||
|
|
||||||
module.exports = Marionette.ItemView.extend({template : 'Rename/RenamePreviewEmptyCollectionViewTemplate'});
|
module.exports = Marionette.ItemView.extend({
|
||||||
|
template : 'Rename/RenamePreviewEmptyCollectionViewTemplate'
|
||||||
|
});
|
|
@ -3,15 +3,17 @@ var Marionette = require('marionette');
|
||||||
var NamingModel = require('../Settings/MediaManagement/Naming/NamingModel');
|
var NamingModel = require('../Settings/MediaManagement/Naming/NamingModel');
|
||||||
|
|
||||||
module.exports = Marionette.ItemView.extend({
|
module.exports = Marionette.ItemView.extend({
|
||||||
template : 'Rename/RenamePreviewFormatViewTemplate',
|
template : 'Rename/RenamePreviewFormatViewTemplate',
|
||||||
templateHelpers : function(){
|
|
||||||
|
templateHelpers : function() {
|
||||||
var type = this.model.get('seriesType');
|
var type = this.model.get('seriesType');
|
||||||
return {
|
return {
|
||||||
rename : this.naming.get('renameEpisodes'),
|
rename : this.naming.get('renameEpisodes'),
|
||||||
format : this.naming.get(type + 'EpisodeFormat')
|
format : this.naming.get(type + 'EpisodeFormat')
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
initialize : function(){
|
|
||||||
|
initialize : function() {
|
||||||
this.naming = new NamingModel();
|
this.naming = new NamingModel();
|
||||||
this.naming.fetch();
|
this.naming.fetch();
|
||||||
this.listenTo(this.naming, 'sync', this.render);
|
this.listenTo(this.naming, 'sync', this.render);
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
{{#if rename}}
|
{{#if rename}}
|
||||||
Naming pattern: {{format}}
|
Naming pattern: {{format}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
|
@ -1,36 +1,39 @@
|
||||||
var vent = require('vent');
|
var vent = require('vent');
|
||||||
var Marionette = require('marionette');
|
var Marionette = require('marionette');
|
||||||
var AsModelBoundView = require('../Mixins/AsModelBoundView');
|
var AsModelBoundView = require('../Mixins/AsModelBoundView');
|
||||||
|
|
||||||
module.exports = (function(){
|
var view = Marionette.ItemView.extend({
|
||||||
var view = Marionette.ItemView.extend({
|
template : 'Rename/RenamePreviewItemViewTemplate',
|
||||||
template : 'Rename/RenamePreviewItemViewTemplate',
|
|
||||||
ui : {
|
ui : {
|
||||||
itemDiv : '.rename-preview-item',
|
itemDiv : '.rename-preview-item',
|
||||||
checkboxIcon : '.rename-checkbox i'
|
checkboxIcon : '.rename-checkbox i'
|
||||||
},
|
},
|
||||||
onRender : function(){
|
|
||||||
this._setItemState();
|
onRender : function() {
|
||||||
this.listenTo(this.model, 'change', this._setItemState);
|
this._setItemState();
|
||||||
this.listenTo(this.model, 'rename:select', this._onRenameAll);
|
this.listenTo(this.model, 'change', this._setItemState);
|
||||||
},
|
this.listenTo(this.model, 'rename:select', this._onRenameAll);
|
||||||
_setItemState : function(){
|
},
|
||||||
var checked = this.model.get('rename');
|
|
||||||
this.model.trigger('rename:select', this.model, checked);
|
_setItemState : function() {
|
||||||
if(checked) {
|
var checked = this.model.get('rename');
|
||||||
this.ui.itemDiv.removeClass('do-not-rename');
|
this.model.trigger('rename:select', this.model, checked);
|
||||||
this.ui.checkboxIcon.addClass('icon-check');
|
|
||||||
this.ui.checkboxIcon.removeClass('icon-check-empty');
|
if (checked) {
|
||||||
}
|
this.ui.itemDiv.removeClass('do-not-rename');
|
||||||
else {
|
this.ui.checkboxIcon.addClass('icon-check');
|
||||||
this.ui.itemDiv.addClass('do-not-rename');
|
this.ui.checkboxIcon.removeClass('icon-check-empty');
|
||||||
this.ui.checkboxIcon.addClass('icon-check-empty');
|
} else {
|
||||||
this.ui.checkboxIcon.removeClass('icon-check');
|
this.ui.itemDiv.addClass('do-not-rename');
|
||||||
}
|
this.ui.checkboxIcon.addClass('icon-check-empty');
|
||||||
},
|
this.ui.checkboxIcon.removeClass('icon-check');
|
||||||
_onRenameAll : function(model, checked){
|
|
||||||
this.model.set('rename', checked);
|
|
||||||
}
|
}
|
||||||
});
|
},
|
||||||
return AsModelBoundView.apply(view);
|
|
||||||
}).call(this);
|
_onRenameAll : function(model, checked) {
|
||||||
|
this.model.set('rename', checked);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
module.exports = AsModelBoundView.apply(view);
|
|
@ -9,66 +9,79 @@ var LoadingView = require('../Shared/LoadingView');
|
||||||
var CommandController = require('../Commands/CommandController');
|
var CommandController = require('../Commands/CommandController');
|
||||||
|
|
||||||
module.exports = Marionette.Layout.extend({
|
module.exports = Marionette.Layout.extend({
|
||||||
className : 'modal-lg',
|
className : 'modal-lg',
|
||||||
template : 'Rename/RenamePreviewLayoutTemplate',
|
template : 'Rename/RenamePreviewLayoutTemplate',
|
||||||
regions : {
|
|
||||||
|
regions : {
|
||||||
renamePreviews : '#rename-previews',
|
renamePreviews : '#rename-previews',
|
||||||
formatRegion : '.x-format-region'
|
formatRegion : '.x-format-region'
|
||||||
},
|
},
|
||||||
ui : {
|
|
||||||
|
ui : {
|
||||||
pathInfo : '.x-path-info',
|
pathInfo : '.x-path-info',
|
||||||
renameAll : '.x-rename-all',
|
renameAll : '.x-rename-all',
|
||||||
checkboxIcon : '.x-rename-all-button i'
|
checkboxIcon : '.x-rename-all-button i'
|
||||||
},
|
},
|
||||||
events : {
|
|
||||||
"click .x-organize" : '_organizeFiles',
|
events : {
|
||||||
"change .x-rename-all" : '_toggleAll'
|
'click .x-organize' : '_organizeFiles',
|
||||||
|
'change .x-rename-all' : '_toggleAll'
|
||||||
},
|
},
|
||||||
initialize : function(options){
|
|
||||||
|
initialize : function(options) {
|
||||||
this.model = options.series;
|
this.model = options.series;
|
||||||
this.seasonNumber = options.seasonNumber;
|
this.seasonNumber = options.seasonNumber;
|
||||||
|
|
||||||
var viewOptions = {};
|
var viewOptions = {};
|
||||||
viewOptions.seriesId = this.model.id;
|
viewOptions.seriesId = this.model.id;
|
||||||
viewOptions.seasonNumber = this.seasonNumber;
|
viewOptions.seasonNumber = this.seasonNumber;
|
||||||
|
|
||||||
this.collection = new RenamePreviewCollection(viewOptions);
|
this.collection = new RenamePreviewCollection(viewOptions);
|
||||||
this.listenTo(this.collection, 'sync', this._showPreviews);
|
this.listenTo(this.collection, 'sync', this._showPreviews);
|
||||||
this.listenTo(this.collection, 'rename:select', this._itemRenameChanged);
|
this.listenTo(this.collection, 'rename:select', this._itemRenameChanged);
|
||||||
|
|
||||||
this.collection.fetch();
|
this.collection.fetch();
|
||||||
},
|
},
|
||||||
onRender : function(){
|
|
||||||
|
onRender : function() {
|
||||||
this.renamePreviews.show(new LoadingView());
|
this.renamePreviews.show(new LoadingView());
|
||||||
this.formatRegion.show(new RenamePreviewFormatView({model : this.model}));
|
this.formatRegion.show(new RenamePreviewFormatView({ model : this.model }));
|
||||||
},
|
},
|
||||||
_showPreviews : function(){
|
|
||||||
if(this.collection.length === 0) {
|
_showPreviews : function() {
|
||||||
|
if (this.collection.length === 0) {
|
||||||
this.ui.pathInfo.hide();
|
this.ui.pathInfo.hide();
|
||||||
this.renamePreviews.show(new EmptyCollectionView());
|
this.renamePreviews.show(new EmptyCollectionView());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.ui.pathInfo.show();
|
this.ui.pathInfo.show();
|
||||||
this.collection.invoke('set', {rename : true});
|
this.collection.invoke('set', { rename : true });
|
||||||
this.renamePreviews.show(new RenamePreviewCollectionView({collection : this.collection}));
|
this.renamePreviews.show(new RenamePreviewCollectionView({ collection : this.collection }));
|
||||||
},
|
},
|
||||||
_organizeFiles : function(){
|
|
||||||
if(this.collection.length === 0) {
|
_organizeFiles : function() {
|
||||||
|
if (this.collection.length === 0) {
|
||||||
vent.trigger(vent.Commands.CloseModalCommand);
|
vent.trigger(vent.Commands.CloseModalCommand);
|
||||||
}
|
}
|
||||||
var files = _.map(this.collection.where({rename : true}), function(model){
|
|
||||||
|
var files = _.map(this.collection.where({ rename : true }), function(model) {
|
||||||
return model.get('episodeFileId');
|
return model.get('episodeFileId');
|
||||||
});
|
});
|
||||||
if(files.length === 0) {
|
|
||||||
|
if (files.length === 0) {
|
||||||
vent.trigger(vent.Commands.CloseModalCommand);
|
vent.trigger(vent.Commands.CloseModalCommand);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(this.seasonNumber) {
|
|
||||||
|
if (this.seasonNumber) {
|
||||||
CommandController.Execute('renameFiles', {
|
CommandController.Execute('renameFiles', {
|
||||||
name : 'renameFiles',
|
name : 'renameFiles',
|
||||||
seriesId : this.model.id,
|
seriesId : this.model.id,
|
||||||
seasonNumber : this.seasonNumber,
|
seasonNumber : this.seasonNumber,
|
||||||
files : files
|
files : files
|
||||||
});
|
});
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
CommandController.Execute('renameFiles', {
|
CommandController.Execute('renameFiles', {
|
||||||
name : 'renameFiles',
|
name : 'renameFiles',
|
||||||
seriesId : this.model.id,
|
seriesId : this.model.id,
|
||||||
|
@ -76,30 +89,35 @@ module.exports = Marionette.Layout.extend({
|
||||||
files : files
|
files : files
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
vent.trigger(vent.Commands.CloseModalCommand);
|
vent.trigger(vent.Commands.CloseModalCommand);
|
||||||
},
|
},
|
||||||
_setCheckedState : function(checked){
|
|
||||||
if(checked) {
|
_setCheckedState : function(checked) {
|
||||||
|
if (checked) {
|
||||||
this.ui.checkboxIcon.addClass('icon-check');
|
this.ui.checkboxIcon.addClass('icon-check');
|
||||||
this.ui.checkboxIcon.removeClass('icon-check-empty');
|
this.ui.checkboxIcon.removeClass('icon-check-empty');
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
this.ui.checkboxIcon.addClass('icon-check-empty');
|
this.ui.checkboxIcon.addClass('icon-check-empty');
|
||||||
this.ui.checkboxIcon.removeClass('icon-check');
|
this.ui.checkboxIcon.removeClass('icon-check');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
_toggleAll : function(){
|
|
||||||
|
_toggleAll : function() {
|
||||||
var checked = this.ui.renameAll.prop('checked');
|
var checked = this.ui.renameAll.prop('checked');
|
||||||
this._setCheckedState(checked);
|
this._setCheckedState(checked);
|
||||||
this.collection.each(function(model){
|
|
||||||
|
this.collection.each(function(model) {
|
||||||
model.trigger('rename:select', model, checked);
|
model.trigger('rename:select', model, checked);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
_itemRenameChanged : function(model, checked){
|
|
||||||
var allChecked = this.collection.all(function(m){
|
_itemRenameChanged : function(model, checked) {
|
||||||
|
var allChecked = this.collection.all(function(m) {
|
||||||
return m.get('rename');
|
return m.get('rename');
|
||||||
});
|
});
|
||||||
if(!checked || allChecked) {
|
|
||||||
|
if (!checked || allChecked) {
|
||||||
this._setCheckedState(checked);
|
this._setCheckedState(checked);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
<div class="rename-preview-modal">
|
<div class="rename-preview-modal">
|
||||||
<div class="modal-header">
|
<div class="modal-header">
|
||||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||||
|
|
|
@ -7,59 +7,75 @@ var ToolbarLayout = require('../Shared/Toolbar/ToolbarLayout');
|
||||||
require('../Mixins/backbone.signalr.mixin');
|
require('../Mixins/backbone.signalr.mixin');
|
||||||
|
|
||||||
module.exports = Marionette.Layout.extend({
|
module.exports = Marionette.Layout.extend({
|
||||||
template : 'SeasonPass/SeasonPassLayoutTemplate',
|
template : 'SeasonPass/SeasonPassLayoutTemplate',
|
||||||
regions : {
|
|
||||||
|
regions : {
|
||||||
toolbar : '#x-toolbar',
|
toolbar : '#x-toolbar',
|
||||||
series : '#x-series'
|
series : '#x-series'
|
||||||
},
|
},
|
||||||
initialize : function(){
|
|
||||||
|
initialize : function() {
|
||||||
this.seriesCollection = SeriesCollection.clone();
|
this.seriesCollection = SeriesCollection.clone();
|
||||||
this.seriesCollection.shadowCollection.bindSignalR();
|
this.seriesCollection.shadowCollection.bindSignalR();
|
||||||
|
|
||||||
this.listenTo(this.seriesCollection, 'sync', this.render);
|
this.listenTo(this.seriesCollection, 'sync', this.render);
|
||||||
|
|
||||||
this.filteringOptions = {
|
this.filteringOptions = {
|
||||||
type : 'radio',
|
type : 'radio',
|
||||||
storeState : true,
|
storeState : true,
|
||||||
menuKey : 'seasonpass.filterMode',
|
menuKey : 'seasonpass.filterMode',
|
||||||
defaultAction : 'all',
|
defaultAction : 'all',
|
||||||
items : [{
|
items : [
|
||||||
key : 'all',
|
{
|
||||||
title : '',
|
key : 'all',
|
||||||
tooltip : 'All',
|
title : '',
|
||||||
icon : 'icon-circle-blank',
|
tooltip : 'All',
|
||||||
callback : this._setFilter
|
icon : 'icon-circle-blank',
|
||||||
}, {
|
callback : this._setFilter
|
||||||
key : 'monitored',
|
},
|
||||||
title : '',
|
{
|
||||||
tooltip : 'Monitored Only',
|
key : 'monitored',
|
||||||
icon : 'icon-nd-monitored',
|
title : '',
|
||||||
callback : this._setFilter
|
tooltip : 'Monitored Only',
|
||||||
}, {
|
icon : 'icon-nd-monitored',
|
||||||
key : 'continuing',
|
callback : this._setFilter
|
||||||
title : '',
|
},
|
||||||
tooltip : 'Continuing Only',
|
{
|
||||||
icon : 'icon-play',
|
key : 'continuing',
|
||||||
callback : this._setFilter
|
title : '',
|
||||||
}, {
|
tooltip : 'Continuing Only',
|
||||||
key : 'ended',
|
icon : 'icon-play',
|
||||||
title : '',
|
callback : this._setFilter
|
||||||
tooltip : 'Ended Only',
|
},
|
||||||
icon : 'icon-stop',
|
{
|
||||||
callback : this._setFilter
|
key : 'ended',
|
||||||
}]
|
title : '',
|
||||||
|
tooltip : 'Ended Only',
|
||||||
|
icon : 'icon-stop',
|
||||||
|
callback : this._setFilter
|
||||||
|
}
|
||||||
|
]
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
onRender : function(){
|
|
||||||
this.series.show(new SeriesCollectionView({collection : this.seriesCollection}));
|
onRender : function() {
|
||||||
|
this.series.show(new SeriesCollectionView({
|
||||||
|
collection : this.seriesCollection
|
||||||
|
}));
|
||||||
|
|
||||||
this._showToolbar();
|
this._showToolbar();
|
||||||
},
|
},
|
||||||
_showToolbar : function(){
|
|
||||||
|
_showToolbar : function() {
|
||||||
this.toolbar.show(new ToolbarLayout({
|
this.toolbar.show(new ToolbarLayout({
|
||||||
right : [this.filteringOptions],
|
right : [this.filteringOptions],
|
||||||
context : this
|
context : this
|
||||||
}));
|
}));
|
||||||
},
|
},
|
||||||
_setFilter : function(buttonContext){
|
|
||||||
|
_setFilter : function(buttonContext) {
|
||||||
var mode = buttonContext.model.get('key');
|
var mode = buttonContext.model.get('key');
|
||||||
|
|
||||||
this.seriesCollection.setFilterMode(mode);
|
this.seriesCollection.setFilterMode(mode);
|
||||||
}
|
}
|
||||||
});
|
});
|
|
@ -1,4 +1,6 @@
|
||||||
var Marionette = require('marionette');
|
var Marionette = require('marionette');
|
||||||
var SeriesLayout = require('./SeriesLayout');
|
var SeriesLayout = require('./SeriesLayout');
|
||||||
|
|
||||||
module.exports = Marionette.CollectionView.extend({itemView : SeriesLayout});
|
module.exports = Marionette.CollectionView.extend({
|
||||||
|
itemView : SeriesLayout
|
||||||
|
});
|
|
@ -4,113 +4,149 @@ var Backgrid = require('backgrid');
|
||||||
var SeasonCollection = require('../Series/SeasonCollection');
|
var SeasonCollection = require('../Series/SeasonCollection');
|
||||||
|
|
||||||
module.exports = Marionette.Layout.extend({
|
module.exports = Marionette.Layout.extend({
|
||||||
template : 'SeasonPass/SeriesLayoutTemplate',
|
template : 'SeasonPass/SeriesLayoutTemplate',
|
||||||
ui : {
|
|
||||||
|
ui : {
|
||||||
seasonSelect : '.x-season-select',
|
seasonSelect : '.x-season-select',
|
||||||
expander : '.x-expander',
|
expander : '.x-expander',
|
||||||
seasonGrid : '.x-season-grid',
|
seasonGrid : '.x-season-grid',
|
||||||
seriesMonitored : '.x-series-monitored'
|
seriesMonitored : '.x-series-monitored'
|
||||||
},
|
},
|
||||||
events : {
|
|
||||||
"change .x-season-select" : '_seasonSelected',
|
events : {
|
||||||
"click .x-expander" : '_expand',
|
'change .x-season-select' : '_seasonSelected',
|
||||||
"click .x-latest" : '_latest',
|
'click .x-expander' : '_expand',
|
||||||
"click .x-all" : '_all',
|
'click .x-latest' : '_latest',
|
||||||
"click .x-monitored" : '_toggleSeasonMonitored',
|
'click .x-all' : '_all',
|
||||||
"click .x-series-monitored" : '_toggleSeriesMonitored'
|
'click .x-monitored' : '_toggleSeasonMonitored',
|
||||||
|
'click .x-series-monitored' : '_toggleSeriesMonitored'
|
||||||
},
|
},
|
||||||
regions : {seasonGrid : '.x-season-grid'},
|
|
||||||
initialize : function(){
|
regions : {
|
||||||
|
seasonGrid : '.x-season-grid'
|
||||||
|
},
|
||||||
|
|
||||||
|
initialize : function() {
|
||||||
this.listenTo(this.model, 'sync', this._setSeriesMonitoredState);
|
this.listenTo(this.model, 'sync', this._setSeriesMonitoredState);
|
||||||
this.seasonCollection = new SeasonCollection(this.model.get('seasons'));
|
this.seasonCollection = new SeasonCollection(this.model.get('seasons'));
|
||||||
this.expanded = false;
|
this.expanded = false;
|
||||||
},
|
},
|
||||||
onRender : function(){
|
|
||||||
if(!this.expanded) {
|
onRender : function() {
|
||||||
|
if (!this.expanded) {
|
||||||
this.ui.seasonGrid.hide();
|
this.ui.seasonGrid.hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
this._setExpanderIcon();
|
this._setExpanderIcon();
|
||||||
this._setSeriesMonitoredState();
|
this._setSeriesMonitoredState();
|
||||||
},
|
},
|
||||||
_seasonSelected : function(){
|
|
||||||
|
_seasonSelected : function() {
|
||||||
var seasonNumber = parseInt(this.ui.seasonSelect.val(), 10);
|
var seasonNumber = parseInt(this.ui.seasonSelect.val(), 10);
|
||||||
if(seasonNumber === -1 || isNaN(seasonNumber)) {
|
|
||||||
|
if (seasonNumber === -1 || isNaN(seasonNumber)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this._setSeasonMonitored(seasonNumber);
|
this._setSeasonMonitored(seasonNumber);
|
||||||
},
|
},
|
||||||
_expand : function(){
|
|
||||||
if(this.expanded) {
|
_expand : function() {
|
||||||
|
if (this.expanded) {
|
||||||
this.ui.seasonGrid.slideUp();
|
this.ui.seasonGrid.slideUp();
|
||||||
this.expanded = false;
|
this.expanded = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
else {
|
else {
|
||||||
this.ui.seasonGrid.slideDown();
|
this.ui.seasonGrid.slideDown();
|
||||||
this.expanded = true;
|
this.expanded = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
this._setExpanderIcon();
|
this._setExpanderIcon();
|
||||||
},
|
},
|
||||||
_setExpanderIcon : function(){
|
|
||||||
if(this.expanded) {
|
_setExpanderIcon : function() {
|
||||||
|
if (this.expanded) {
|
||||||
this.ui.expander.removeClass('icon-chevron-right');
|
this.ui.expander.removeClass('icon-chevron-right');
|
||||||
this.ui.expander.addClass('icon-chevron-down');
|
this.ui.expander.addClass('icon-chevron-down');
|
||||||
}
|
}
|
||||||
|
|
||||||
else {
|
else {
|
||||||
this.ui.expander.removeClass('icon-chevron-down');
|
this.ui.expander.removeClass('icon-chevron-down');
|
||||||
this.ui.expander.addClass('icon-chevron-right');
|
this.ui.expander.addClass('icon-chevron-right');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
_latest : function(){
|
|
||||||
var season = _.max(this.model.get('seasons'), function(s){
|
_latest : function() {
|
||||||
|
var season = _.max(this.model.get('seasons'), function(s) {
|
||||||
return s.seasonNumber;
|
return s.seasonNumber;
|
||||||
});
|
});
|
||||||
|
|
||||||
this._setSeasonMonitored(season.seasonNumber);
|
this._setSeasonMonitored(season.seasonNumber);
|
||||||
},
|
},
|
||||||
_all : function(){
|
|
||||||
var minSeasonNotZero = _.min(_.reject(this.model.get('seasons'), {seasonNumber : 0}), 'seasonNumber');
|
_all : function() {
|
||||||
|
var minSeasonNotZero = _.min(_.reject(this.model.get('seasons'), { seasonNumber : 0 }), 'seasonNumber');
|
||||||
|
|
||||||
this._setSeasonMonitored(minSeasonNotZero.seasonNumber);
|
this._setSeasonMonitored(minSeasonNotZero.seasonNumber);
|
||||||
},
|
},
|
||||||
_setSeasonMonitored : function(seasonNumber){
|
|
||||||
|
_setSeasonMonitored : function(seasonNumber) {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
this.model.setSeasonPass(seasonNumber);
|
this.model.setSeasonPass(seasonNumber);
|
||||||
|
|
||||||
var promise = this.model.save();
|
var promise = this.model.save();
|
||||||
promise.done(function(data){
|
|
||||||
|
promise.done(function(data) {
|
||||||
self.seasonCollection = new SeasonCollection(data);
|
self.seasonCollection = new SeasonCollection(data);
|
||||||
self.render();
|
self.render();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
_toggleSeasonMonitored : function(e){
|
|
||||||
|
_toggleSeasonMonitored : function(e) {
|
||||||
var seasonNumber = 0;
|
var seasonNumber = 0;
|
||||||
var element;
|
var element;
|
||||||
if(e.target.localName === 'i') {
|
|
||||||
|
if (e.target.localName === 'i') {
|
||||||
seasonNumber = parseInt(this.$(e.target).parent('td').attr('data-season-number'), 10);
|
seasonNumber = parseInt(this.$(e.target).parent('td').attr('data-season-number'), 10);
|
||||||
element = this.$(e.target);
|
element = this.$(e.target);
|
||||||
}
|
}
|
||||||
|
|
||||||
else {
|
else {
|
||||||
seasonNumber = parseInt(this.$(e.target).attr('data-season-number'), 10);
|
seasonNumber = parseInt(this.$(e.target).attr('data-season-number'), 10);
|
||||||
element = this.$(e.target).children('i');
|
element = this.$(e.target).children('i');
|
||||||
}
|
}
|
||||||
|
|
||||||
this.model.setSeasonMonitored(seasonNumber);
|
this.model.setSeasonMonitored(seasonNumber);
|
||||||
|
|
||||||
var savePromise = this.model.save().always(this.render.bind(this));
|
var savePromise = this.model.save().always(this.render.bind(this));
|
||||||
element.spinForPromise(savePromise);
|
element.spinForPromise(savePromise);
|
||||||
},
|
},
|
||||||
_afterToggleSeasonMonitored : function(){
|
|
||||||
|
_afterToggleSeasonMonitored : function() {
|
||||||
this.render();
|
this.render();
|
||||||
},
|
},
|
||||||
_setSeriesMonitoredState : function(){
|
|
||||||
|
_setSeriesMonitoredState : function() {
|
||||||
var monitored = this.model.get('monitored');
|
var monitored = this.model.get('monitored');
|
||||||
|
|
||||||
this.ui.seriesMonitored.removeAttr('data-idle-icon');
|
this.ui.seriesMonitored.removeAttr('data-idle-icon');
|
||||||
if(monitored) {
|
|
||||||
|
if (monitored) {
|
||||||
this.ui.seriesMonitored.addClass('icon-nd-monitored');
|
this.ui.seriesMonitored.addClass('icon-nd-monitored');
|
||||||
this.ui.seriesMonitored.removeClass('icon-nd-unmonitored');
|
this.ui.seriesMonitored.removeClass('icon-nd-unmonitored');
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
this.ui.seriesMonitored.addClass('icon-nd-unmonitored');
|
this.ui.seriesMonitored.addClass('icon-nd-unmonitored');
|
||||||
this.ui.seriesMonitored.removeClass('icon-nd-monitored');
|
this.ui.seriesMonitored.removeClass('icon-nd-monitored');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
_toggleSeriesMonitored : function(){
|
|
||||||
var savePromise = this.model.save('monitored', !this.model.get('monitored'), {wait : true});
|
_toggleSeriesMonitored : function() {
|
||||||
|
var savePromise = this.model.save('monitored', !this.model.get('monitored'), {
|
||||||
|
wait : true
|
||||||
|
});
|
||||||
|
|
||||||
this.ui.seriesMonitored.spinForPromise(savePromise);
|
this.ui.seriesMonitored.spinForPromise(savePromise);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue