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
This commit is contained in:
Mark McDowall 2014-02-26 19:11:50 -08:00
parent 4478f2d723
commit d44b220fd0
8 changed files with 96 additions and 10 deletions

View File

@ -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);
}
});
});

View File

@ -5,8 +5,9 @@ define(
'Episode/Summary/EpisodeSummaryLayout', 'Episode/Summary/EpisodeSummaryLayout',
'Episode/Search/EpisodeSearchLayout', 'Episode/Search/EpisodeSearchLayout',
'Episode/Activity/EpisodeActivityLayout', 'Episode/Activity/EpisodeActivityLayout',
'Series/SeriesCollection' 'Series/SeriesCollection',
], function (Marionette, SummaryLayout, SearchLayout, EpisodeActivityLayout, SeriesCollection) { 'Shared/Messenger'
], function (Marionette, SummaryLayout, SearchLayout, EpisodeActivityLayout, SeriesCollection, Messenger) {
return Marionette.Layout.extend({ return Marionette.Layout.extend({
template: 'Episode/EpisodeDetailsLayoutTemplate', template: 'Episode/EpisodeDetailsLayoutTemplate',
@ -37,7 +38,7 @@ define(
initialize: function (options) { initialize: function (options) {
this.templateHelpers.hideSeriesLink = options.hideSeriesLink; 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.templateHelpers.series = this.series.toJSON();
this.openingTab = options.openingTab || 'summary'; this.openingTab = options.openingTab || 'summary';
@ -57,6 +58,14 @@ define(
} }
this._setMonitoredState(); this._setMonitoredState();
if (this.series.get('monitored')) {
this.$el.removeClass('series-not-monitored');
}
else {
this.$el.addClass('series-not-monitored');
}
}, },
_showSummary: function (e) { _showSummary: function (e) {
@ -87,6 +96,16 @@ define(
}, },
_toggleMonitored: function () { _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'; var name = 'monitored';
this.model.set(name, !this.model.get(name), { silent: true }); this.model.set(name, !this.model.get(name), { silent: true });

View File

@ -3,7 +3,7 @@
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button> <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h3> <h3>
<i class="icon-bookmark x-episode-monitored" title="Toggle monitored status" /> <i class="icon-bookmark x-episode-monitored episode-monitored" title="Toggle monitored status" />
{{series.title}} - {{EpisodeNumber}} - {{title}} {{series.title}} - {{EpisodeNumber}} - {{title}}
</h3> </h3>

View File

@ -4,15 +4,27 @@ define(
'vent', 'vent',
'marionette', 'marionette',
'backgrid', 'backgrid',
'Cells/ToggleCell', 'Cells/EpisodeMonitoredCell',
'Cells/EpisodeTitleCell', 'Cells/EpisodeTitleCell',
'Cells/RelativeDateCell', 'Cells/RelativeDateCell',
'Cells/EpisodeStatusCell', 'Cells/EpisodeStatusCell',
'Cells/EpisodeActionsCell', 'Cells/EpisodeActionsCell',
'Commands/CommandController', 'Commands/CommandController',
'moment', 'moment',
'underscore' 'underscore',
], function (vent, Marionette, Backgrid, ToggleCell, EpisodeTitleCell, RelativeDateCell, EpisodeStatusCell, EpisodeActionsCell, CommandController, Moment, _) { 'Shared/Messenger'
], function (vent,
Marionette,
Backgrid,
ToggleCell,
EpisodeTitleCell,
RelativeDateCell,
EpisodeStatusCell,
EpisodeActionsCell,
CommandController,
Moment,
_,
Messenger) {
return Marionette.Layout.extend({ return Marionette.Layout.extend({
template: 'Series/Details/SeasonLayoutTemplate', template: 'Series/Details/SeasonLayoutTemplate',
@ -95,7 +107,6 @@ define(
onRender: function () { onRender: function () {
if (this.showingEpisodes) { if (this.showingEpisodes) {
this._showEpisodes(); this._showEpisodes();
} }
@ -135,6 +146,16 @@ define(
}, },
_seasonMonitored: function () { _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'; var name = 'monitored';
this.model.set(name, !this.model.get(name)); this.model.set(name, !this.model.get(name));
this.series.setSeasonMonitored(this.model.get('seasonNumber')); this.series.setSeasonMonitored(this.model.get('seasonNumber'));

View File

@ -1,6 +1,6 @@
<div class="series-season" id="season-{{seasonNumber}}"> <div class="series-season" id="season-{{seasonNumber}}">
<h2> <h2>
<i class="x-season-monitored clickable" title="Toggle season monitored status"/> <i class="x-season-monitored season-monitored clickable" title="Toggle season monitored status"/>
{{#if seasonNumber}} {{#if seasonNumber}}
Season {{seasonNumber}} Season {{seasonNumber}}

View File

@ -141,10 +141,12 @@ define(
if (monitored) { if (monitored) {
this.ui.monitored.addClass('icon-nd-monitored'); this.ui.monitored.addClass('icon-nd-monitored');
this.ui.monitored.removeClass('icon-nd-unmonitored'); this.ui.monitored.removeClass('icon-nd-unmonitored');
this.$el.removeClass('series-not-monitored');
} }
else { else {
this.ui.monitored.addClass('icon-nd-unmonitored'); this.ui.monitored.addClass('icon-nd-unmonitored');
this.ui.monitored.removeClass('icon-nd-monitored'); this.ui.monitored.removeClass('icon-nd-monitored');
this.$el.addClass('series-not-monitored');
} }
}, },

View File

@ -310,4 +310,17 @@
.selected-count { .selected-count {
margin-right: 10px; margin-right: 10px;
} }
}
//Series Details
.series-not-monitored {
.season-monitored, .episode-monitored {
color: #888888;
cursor: not-allowed;
i {
cursor: not-allowed;
}
}
} }

View File

@ -23,7 +23,7 @@ require.config({
'signalR' : 'JsLibraries/jquery.signalR', 'signalR' : 'JsLibraries/jquery.signalR',
'jquery-ui' : 'JsLibraries/jquery-ui', 'jquery-ui' : 'JsLibraries/jquery-ui',
'jquery.knob' : 'JsLibraries/jquery.knob', 'jquery.knob' : 'JsLibraries/jquery.knob',
'jquery.easypiechart' : 'JsLibraries/jquery.easypiechart', 'jquery.easypiechart' : 'JsLibraries/jquery.easypiechart',
'jquery.dotdotdot' : 'JsLibraries/jquery.dotdotdot', 'jquery.dotdotdot' : 'JsLibraries/jquery.dotdotdot',
'messenger' : 'JsLibraries/messenger', 'messenger' : 'JsLibraries/messenger',
'jquery' : 'JsLibraries/jquery', 'jquery' : 'JsLibraries/jquery',