From f32cbbb224750b16c4b59d9a5f524c77c5270555 Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Mon, 23 Sep 2013 17:53:56 -0700 Subject: [PATCH] Toggle monitored status from season pass as well as all seasons (skip specials) --- UI/AddSeries/SearchResultView.js | 3 +- UI/Controller.js | 2 +- UI/Instrumentation/ErrorHandler.js | 2 +- .../{Layout.js => SeasonPassLayout.js} | 2 +- ...ate.html => SeasonPassLayoutTemplate.html} | 0 UI/SeasonPass/SeriesLayout.js | 59 +++++++++++++++---- UI/SeasonPass/SeriesLayoutTemplate.html | 20 +++++-- UI/Series/Details/SeriesDetailsTemplate.html | 2 +- UI/Series/series.less | 13 ++++ 9 files changed, 81 insertions(+), 22 deletions(-) rename UI/SeasonPass/{Layout.js => SeasonPassLayout.js} (93%) rename UI/SeasonPass/{LayoutTemplate.html => SeasonPassLayoutTemplate.html} (100%) diff --git a/UI/AddSeries/SearchResultView.js b/UI/AddSeries/SearchResultView.js index e19bfecaf..3f8c6ec33 100644 --- a/UI/AddSeries/SearchResultView.js +++ b/UI/AddSeries/SearchResultView.js @@ -2,6 +2,7 @@ define( [ 'app', + 'underscore', 'marionette', 'Quality/QualityProfileCollection', 'AddSeries/RootFolders/Collection', @@ -11,7 +12,7 @@ define( 'Shared/Messenger', 'Mixins/AsValidatedView', 'jquery.dotdotdot' - ], function (App, Marionette, QualityProfiles, RootFolders, RootFolderLayout, SeriesCollection, Config, Messenger, AsValidatedView) { + ], function (App, _, Marionette, QualityProfiles, RootFolders, RootFolderLayout, SeriesCollection, Config, Messenger, AsValidatedView) { var view = Marionette.ItemView.extend({ diff --git a/UI/Controller.js b/UI/Controller.js index 190708195..8f0c059c8 100644 --- a/UI/Controller.js +++ b/UI/Controller.js @@ -15,7 +15,7 @@ define( 'Logs/Files/Layout', 'Release/Layout', 'System/Layout', - 'SeasonPass/Layout', + 'SeasonPass/SeasonPassLayout', 'Shared/NotFoundView', 'Shared/Modal/Region' ], function (App, Marionette, HistoryLayout, SettingsLayout, AddSeriesLayout, SeriesIndexLayout, SeriesDetailsLayout, SeriesCollection, MissingLayout, CalendarLayout, diff --git a/UI/Instrumentation/ErrorHandler.js b/UI/Instrumentation/ErrorHandler.js index 475edc68f..92ccd4db1 100644 --- a/UI/Instrumentation/ErrorHandler.js +++ b/UI/Instrumentation/ErrorHandler.js @@ -13,7 +13,7 @@ var filename = a.pathname.split('/').pop(); //Suppress Firefox debug errors when console window is closed - if (filename.toLowerCase() === 'markupview.jsm') { + if (filename.toLowerCase() === 'markupview.jsm' || filename.toLowerCase() === 'markup-view.js') { return false; } diff --git a/UI/SeasonPass/Layout.js b/UI/SeasonPass/SeasonPassLayout.js similarity index 93% rename from UI/SeasonPass/Layout.js rename to UI/SeasonPass/SeasonPassLayout.js index ebf2609cf..0a1e51d92 100644 --- a/UI/SeasonPass/Layout.js +++ b/UI/SeasonPass/SeasonPassLayout.js @@ -12,7 +12,7 @@ define( SeriesCollectionView, LoadingView) { return Marionette.Layout.extend({ - template: 'SeasonPass/LayoutTemplate', + template: 'SeasonPass/SeasonPassLayoutTemplate', regions: { series: '#x-series' diff --git a/UI/SeasonPass/LayoutTemplate.html b/UI/SeasonPass/SeasonPassLayoutTemplate.html similarity index 100% rename from UI/SeasonPass/LayoutTemplate.html rename to UI/SeasonPass/SeasonPassLayoutTemplate.html diff --git a/UI/SeasonPass/SeriesLayout.js b/UI/SeasonPass/SeriesLayout.js index 1eae0ce0e..34b26855a 100644 --- a/UI/SeasonPass/SeriesLayout.js +++ b/UI/SeasonPass/SeriesLayout.js @@ -1,24 +1,28 @@ 'use strict'; define( [ + 'underscore', 'marionette', 'backgrid', 'Series/SeasonCollection' - ], function (Marionette, Backgrid, SeasonCollection) { + ], function (_, Marionette, Backgrid, SeasonCollection) { return Marionette.Layout.extend({ template: 'SeasonPass/SeriesLayoutTemplate', ui: { - seasonSelect: '.x-season-select', - expander : '.x-expander', - seasonGrid : '.x-season-grid' + seasonSelect : '.x-season-select', + expander : '.x-expander', + seasonGrid : '.x-season-grid', + seriesMonitored: '.x-series-monitored' }, events: { - 'change .x-season-select': '_seasonSelected', - 'click .x-expander' : '_expand', - 'click .x-latest' : '_latest', - 'click .x-monitored' : '_toggleSeasonMonitored' + 'change .x-season-select' : '_seasonSelected', + 'click .x-expander' : '_expand', + 'click .x-latest' : '_latest', + 'click .x-all' : '_all', + 'click .x-monitored' : '_toggleSeasonMonitored', + 'click .x-series-monitored': '_toggleSeriesMonitored' }, regions: { @@ -26,6 +30,7 @@ define( }, initialize: function () { + this.listenTo(this.model, 'sync', this._setSeriesMonitoredState); this.seasonCollection = new SeasonCollection(this.model.get('seasons')); this.expanded = false; }, @@ -36,16 +41,17 @@ define( } this._setExpanderIcon(); + this._setSeriesMonitoredState(); }, _seasonSelected: function () { var seasonNumber = parseInt(this.ui.seasonSelect.val()); - if (seasonNumber == -1 || isNaN(seasonNumber)) { + if (seasonNumber === -1 || isNaN(seasonNumber)) { return; } - this._setMonitored(seasonNumber) + this._setSeasonMonitored(seasonNumber); }, _expand: function () { @@ -79,10 +85,16 @@ define( return s.seasonNumber; }); - this._setMonitored(season.seasonNumber); + this._setSeasonMonitored(season.seasonNumber); }, - _setMonitored: function (seasonNumber) { + _all: function () { + var minSeasonNotZero = _.min(_.reject(this.model.get('seasons'), { seasonNumber: 0 }), 'seasonNumber'); + + this._setSeasonMonitored(minSeasonNotZero.seasonNumber); + }, + + _setSeasonMonitored: function (seasonNumber) { var self = this; this.model.setSeasonPass(seasonNumber); @@ -118,6 +130,29 @@ define( _afterToggleSeasonMonitored: function () { this.render(); + }, + + _setSeriesMonitoredState: function () { + var monitored = this.model.get('monitored'); + + this.ui.seriesMonitored.removeAttr('data-idle-icon'); + + if (monitored) { + this.ui.seriesMonitored.addClass('icon-nd-monitored'); + this.ui.seriesMonitored.removeClass('icon-nd-unmonitored'); + } + else { + this.ui.seriesMonitored.addClass('icon-nd-unmonitored'); + this.ui.seriesMonitored.removeClass('icon-nd-monitored'); + } + }, + + _toggleSeriesMonitored: function (e) { + var savePromise = this.model.save('monitored', !this.model.get('monitored'), { + wait: true + }); + + this.ui.seriesMonitored.spinForPromise(savePromise); } }); }); diff --git a/UI/SeasonPass/SeriesLayoutTemplate.html b/UI/SeasonPass/SeriesLayoutTemplate.html index 9c12a4483..844307b51 100644 --- a/UI/SeasonPass/SeriesLayoutTemplate.html +++ b/UI/SeasonPass/SeriesLayoutTemplate.html @@ -1,8 +1,8 @@