From d44b220fd0e867c42a532bb538ce6ec6863ba0a5 Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Wed, 26 Feb 2014 19:11:50 -0800 Subject: [PATCH] Series monitored visible on seasons/episodes on details page and episode details modal New: Visual indication on season/episode when series is not monitored New: Prevent changing monitored state when series is not monitored --- src/UI/Cells/EpisodeMonitoredCell.js | 31 +++++++++++++++++++ src/UI/Episode/EpisodeDetailsLayout.js | 25 +++++++++++++-- .../Episode/EpisodeDetailsLayoutTemplate.html | 2 +- src/UI/Series/Details/SeasonLayout.js | 29 ++++++++++++++--- .../Series/Details/SeasonLayoutTemplate.html | 2 +- src/UI/Series/Details/SeriesDetailsLayout.js | 2 ++ src/UI/Series/series.less | 13 ++++++++ src/UI/app.js | 2 +- 8 files changed, 96 insertions(+), 10 deletions(-) create mode 100644 src/UI/Cells/EpisodeMonitoredCell.js diff --git a/src/UI/Cells/EpisodeMonitoredCell.js b/src/UI/Cells/EpisodeMonitoredCell.js new file mode 100644 index 000000000..72a3e2fee --- /dev/null +++ b/src/UI/Cells/EpisodeMonitoredCell.js @@ -0,0 +1,31 @@ +'use strict'; + +define( + [ + 'Cells/ToggleCell', + 'Series/SeriesCollection', + 'Shared/Messenger' + ], function (ToggleCell, SeriesCollection, Messenger) { + return ToggleCell.extend({ + + className: 'toggle-cell episode-monitored', + + _originalOnClick: ToggleCell.prototype._onClick, + + _onClick: function () { + var series = SeriesCollection.get(this.model.get('seriesId')); + + if (!series.get('monitored')) { + + Messenger.show({ + message: 'Unable to change monitored state when series is not monitored', + type : 'error' + }); + + return; + } + + this._originalOnClick.apply(this, arguments); + } + }); + }); diff --git a/src/UI/Episode/EpisodeDetailsLayout.js b/src/UI/Episode/EpisodeDetailsLayout.js index e52334e0f..d8431ec93 100644 --- a/src/UI/Episode/EpisodeDetailsLayout.js +++ b/src/UI/Episode/EpisodeDetailsLayout.js @@ -5,8 +5,9 @@ define( 'Episode/Summary/EpisodeSummaryLayout', 'Episode/Search/EpisodeSearchLayout', 'Episode/Activity/EpisodeActivityLayout', - 'Series/SeriesCollection' - ], function (Marionette, SummaryLayout, SearchLayout, EpisodeActivityLayout, SeriesCollection) { + 'Series/SeriesCollection', + 'Shared/Messenger' + ], function (Marionette, SummaryLayout, SearchLayout, EpisodeActivityLayout, SeriesCollection, Messenger) { return Marionette.Layout.extend({ template: 'Episode/EpisodeDetailsLayoutTemplate', @@ -37,7 +38,7 @@ define( initialize: function (options) { this.templateHelpers.hideSeriesLink = options.hideSeriesLink; - this.series = SeriesCollection.find({ id: this.model.get('seriesId') }); + this.series = SeriesCollection.get(this.model.get('seriesId')); this.templateHelpers.series = this.series.toJSON(); this.openingTab = options.openingTab || 'summary'; @@ -57,6 +58,14 @@ define( } this._setMonitoredState(); + + if (this.series.get('monitored')) { + this.$el.removeClass('series-not-monitored'); + } + + else { + this.$el.addClass('series-not-monitored'); + } }, _showSummary: function (e) { @@ -87,6 +96,16 @@ define( }, _toggleMonitored: function () { + if (!this.series.get('monitored')) { + + Messenger.show({ + message: 'Unable to change monitored state when series is not monitored', + type : 'error' + }); + + return; + } + var name = 'monitored'; this.model.set(name, !this.model.get(name), { silent: true }); diff --git a/src/UI/Episode/EpisodeDetailsLayoutTemplate.html b/src/UI/Episode/EpisodeDetailsLayoutTemplate.html index d06bdf905..33a0c5514 100644 --- a/src/UI/Episode/EpisodeDetailsLayoutTemplate.html +++ b/src/UI/Episode/EpisodeDetailsLayoutTemplate.html @@ -3,7 +3,7 @@

- + {{series.title}} - {{EpisodeNumber}} - {{title}}

diff --git a/src/UI/Series/Details/SeasonLayout.js b/src/UI/Series/Details/SeasonLayout.js index 0492f1768..5f9620c75 100644 --- a/src/UI/Series/Details/SeasonLayout.js +++ b/src/UI/Series/Details/SeasonLayout.js @@ -4,15 +4,27 @@ define( 'vent', 'marionette', 'backgrid', - 'Cells/ToggleCell', + 'Cells/EpisodeMonitoredCell', 'Cells/EpisodeTitleCell', 'Cells/RelativeDateCell', 'Cells/EpisodeStatusCell', 'Cells/EpisodeActionsCell', 'Commands/CommandController', 'moment', - 'underscore' - ], function (vent, Marionette, Backgrid, ToggleCell, EpisodeTitleCell, RelativeDateCell, EpisodeStatusCell, EpisodeActionsCell, CommandController, Moment, _) { + 'underscore', + 'Shared/Messenger' + ], function (vent, + Marionette, + Backgrid, + ToggleCell, + EpisodeTitleCell, + RelativeDateCell, + EpisodeStatusCell, + EpisodeActionsCell, + CommandController, + Moment, + _, + Messenger) { return Marionette.Layout.extend({ template: 'Series/Details/SeasonLayoutTemplate', @@ -95,7 +107,6 @@ define( onRender: function () { - if (this.showingEpisodes) { this._showEpisodes(); } @@ -135,6 +146,16 @@ define( }, _seasonMonitored: function () { + if (!this.series.get('monitored')) { + + Messenger.show({ + message: 'Unable to change monitored state when series is not monitored', + type : 'error' + }); + + return; + } + var name = 'monitored'; this.model.set(name, !this.model.get(name)); this.series.setSeasonMonitored(this.model.get('seasonNumber')); diff --git a/src/UI/Series/Details/SeasonLayoutTemplate.html b/src/UI/Series/Details/SeasonLayoutTemplate.html index 827671ab2..4e5f598de 100644 --- a/src/UI/Series/Details/SeasonLayoutTemplate.html +++ b/src/UI/Series/Details/SeasonLayoutTemplate.html @@ -1,6 +1,6 @@ 

- + {{#if seasonNumber}} Season {{seasonNumber}} diff --git a/src/UI/Series/Details/SeriesDetailsLayout.js b/src/UI/Series/Details/SeriesDetailsLayout.js index c54e777fb..95d20c627 100644 --- a/src/UI/Series/Details/SeriesDetailsLayout.js +++ b/src/UI/Series/Details/SeriesDetailsLayout.js @@ -141,10 +141,12 @@ define( if (monitored) { this.ui.monitored.addClass('icon-nd-monitored'); this.ui.monitored.removeClass('icon-nd-unmonitored'); + this.$el.removeClass('series-not-monitored'); } else { this.ui.monitored.addClass('icon-nd-unmonitored'); this.ui.monitored.removeClass('icon-nd-monitored'); + this.$el.addClass('series-not-monitored'); } }, diff --git a/src/UI/Series/series.less b/src/UI/Series/series.less index 2e23c92a5..78a1098fa 100644 --- a/src/UI/Series/series.less +++ b/src/UI/Series/series.less @@ -310,4 +310,17 @@ .selected-count { margin-right: 10px; } +} + +//Series Details + +.series-not-monitored { + .season-monitored, .episode-monitored { + color: #888888; + cursor: not-allowed; + + i { + cursor: not-allowed; + } + } } \ No newline at end of file diff --git a/src/UI/app.js b/src/UI/app.js index c3cb3bb57..2ab1cbdd1 100644 --- a/src/UI/app.js +++ b/src/UI/app.js @@ -23,7 +23,7 @@ require.config({ 'signalR' : 'JsLibraries/jquery.signalR', 'jquery-ui' : 'JsLibraries/jquery-ui', 'jquery.knob' : 'JsLibraries/jquery.knob', - 'jquery.easypiechart' : 'JsLibraries/jquery.easypiechart', + 'jquery.easypiechart' : 'JsLibraries/jquery.easypiechart', 'jquery.dotdotdot' : 'JsLibraries/jquery.dotdotdot', 'messenger' : 'JsLibraries/messenger', 'jquery' : 'JsLibraries/jquery',