From dc2930dc98ca17c0833386509d2d7466b59aaa9c Mon Sep 17 00:00:00 2001 From: "kay.one" Date: Sat, 8 Jun 2013 23:21:32 -0700 Subject: [PATCH] added toggle cell for episode ignore status. --- .../MonitoredEpisodeSpecification.cs | 11 +---- .../QualityAllowedByProfileSpecification.cs | 2 - UI/Series/Details/SeasonLayout.js | 11 ++++- UI/Series/SeriesModel.js | 9 +++- UI/Series/details.less | 6 +++ UI/Shared/Cells/ToggleCell.js | 41 +++++++++++-------- 6 files changed, 48 insertions(+), 32 deletions(-) diff --git a/NzbDrone.Core/DecisionEngine/Specifications/MonitoredEpisodeSpecification.cs b/NzbDrone.Core/DecisionEngine/Specifications/MonitoredEpisodeSpecification.cs index 37fa01993..7d01ca688 100644 --- a/NzbDrone.Core/DecisionEngine/Specifications/MonitoredEpisodeSpecification.cs +++ b/NzbDrone.Core/DecisionEngine/Specifications/MonitoredEpisodeSpecification.cs @@ -1,22 +1,15 @@ using System.Linq; using NLog; -using NzbDrone.Core.Model; -using NzbDrone.Core.Parser; using NzbDrone.Core.Parser.Model; -using NzbDrone.Core.Tv; namespace NzbDrone.Core.DecisionEngine.Specifications { public class MonitoredEpisodeSpecification : IDecisionEngineSpecification { - private readonly IEpisodeService _episodeService; - private readonly ISeriesRepository _seriesRepository; private readonly Logger _logger; - public MonitoredEpisodeSpecification(IEpisodeService episodeService, ISeriesRepository seriesRepository, Logger logger) + public MonitoredEpisodeSpecification(Logger logger) { - _episodeService = episodeService; - _seriesRepository = seriesRepository; _logger = logger; } @@ -24,7 +17,7 @@ namespace NzbDrone.Core.DecisionEngine.Specifications { get { - return "Series is not monitored"; + return "Series is not monitored or Episode is ignored"; } } diff --git a/NzbDrone.Core/DecisionEngine/Specifications/QualityAllowedByProfileSpecification.cs b/NzbDrone.Core/DecisionEngine/Specifications/QualityAllowedByProfileSpecification.cs index 99f6b247f..3b12fd4e9 100644 --- a/NzbDrone.Core/DecisionEngine/Specifications/QualityAllowedByProfileSpecification.cs +++ b/NzbDrone.Core/DecisionEngine/Specifications/QualityAllowedByProfileSpecification.cs @@ -1,6 +1,4 @@ using NLog; -using NzbDrone.Core.Model; -using NzbDrone.Core.Parser; using NzbDrone.Core.Parser.Model; namespace NzbDrone.Core.DecisionEngine.Specifications diff --git a/UI/Series/Details/SeasonLayout.js b/UI/Series/Details/SeasonLayout.js index c7c15b259..aab574bd8 100644 --- a/UI/Series/Details/SeasonLayout.js +++ b/UI/Series/Details/SeasonLayout.js @@ -1,5 +1,5 @@ 'use strict'; -define(['app', 'Series/Details/EpisodeStatusCell', 'Series/Details/EpisodeTitleCell'], function () { +define(['app', 'Series/Details/EpisodeStatusCell', 'Series/Details/EpisodeTitleCell','Shared/Cells/ToggleCell'], function () { NzbDrone.Series.Details.SeasonLayout = Backbone.Marionette.Layout.extend({ template: 'Series/Details/SeasonLayoutTemplate', @@ -9,6 +9,13 @@ define(['app', 'Series/Details/EpisodeStatusCell', 'Series/Details/EpisodeTitleC columns: [ + { + name : 'ignored', + label: '', + cell : NzbDrone.Shared.Cells.ToggleCell, + trueClass : 'icon-bookmark-empty', + falseClass :'icon-bookmark' + }, { name : 'episodeNumber', label: '#', @@ -50,7 +57,7 @@ define(['app', 'Series/Details/EpisodeStatusCell', 'Series/Details/EpisodeTitleC { columns : this.columns, collection: this.episodeCollection, - className : 'table table-hover' + className : 'table table-hover season-grid' })); } }); diff --git a/UI/Series/SeriesModel.js b/UI/Series/SeriesModel.js index e7c8b4807..88f4a7f77 100644 --- a/UI/Series/SeriesModel.js +++ b/UI/Series/SeriesModel.js @@ -50,7 +50,14 @@ define(['app', 'Quality/QualityProfileCollection'], function (app, qualityProfil }, qualityProfile: function () { - return qualityProfiles.get(this.get('qualityProfileId')).toJSON(); + + var profile = qualityProfiles.get(this.get('qualityProfileId')); + + if(profile){ + return profile.toJSON(); + } + + return undefined; } }, diff --git a/UI/Series/details.less b/UI/Series/details.less index bb4dd863c..9e05949dc 100644 --- a/UI/Series/details.less +++ b/UI/Series/details.less @@ -28,3 +28,9 @@ font-size: 12px; } } + +.season-grid { + .toggle-cell { + width: 10px; + } +} diff --git a/UI/Shared/Cells/ToggleCell.js b/UI/Shared/Cells/ToggleCell.js index 4fb9c06ed..d0c60aeba 100644 --- a/UI/Shared/Cells/ToggleCell.js +++ b/UI/Shared/Cells/ToggleCell.js @@ -1,33 +1,38 @@ "use strict"; define(['app', 'Episode/Layout'], function () { - NzbDrone.Series.Details.EpisodeIgnoreCell = Backgrid.Cell.extend({ + NzbDrone.Shared.Cells.ToggleCell = Backgrid.Cell.extend({ + + className: 'toggle-cell clickable', + + events: { + 'click': '_onClick' + }, + + + _onClick: function () { + var name = this.column.get('name'); + this.model.set(name, !this.model.get(name)); + this.render(); + + this.model.save(); + }, - className: 'episode-status-cell', render: function () { this.$el.empty(); - if (this.model) { - - var icon; - if (this.model.get('episodeFile')) { - icon = 'icon-ok'; + this.$el.html(''); - } - else { - if (this.model.get('hasAired')) { - icon = 'icon-warning-sign'; - } - else { - icon = 'icon-time'; - } - } + var name = this.column.get('name'); - this.$el.html(''.format(icon)); + if (this.model.get(name)) { + this.$('i').addClass(this.column.get('trueClass')); + } + else { + this.$('i').addClass(this.column.get('falseClass')); } - return this; } });