-
{{title}}
+ {{titleWithYear}}
{{overview}}
{{#if existing}}
-
+
Already Exists
{{else}}
-
- Add
-
-
{{#unless path}}
{{> RootFolderSelectionPartial rootFolders}}
{{/unless}}
-
- {{> QualityProfileSelectionPartial qualityProfiles}}
+
+ {{> StartingSeasonSelectionPartial seasons}}
+ {{> QualityProfileSelectionPartial qualityProfiles}}
+
+
+ Add
{{/if}}
-
diff --git a/UI/Content/icons.less b/UI/Content/icons.less
index 06c6292cd..e48924f8b 100644
--- a/UI/Content/icons.less
+++ b/UI/Content/icons.less
@@ -113,4 +113,12 @@
.icon-nd-status:before {
.icon(@circle);
+}
+
+.icon-nd-monitored:before {
+ .icon(@bookmark);
+}
+
+.icon-nd-unmonitored:before {
+ .icon(@bookmark-empty);
}
\ No newline at end of file
diff --git a/UI/Handlebars/Helpers/Series.js b/UI/Handlebars/Helpers/Series.js
index ac2a21747..f9d849325 100644
--- a/UI/Handlebars/Helpers/Series.js
+++ b/UI/Handlebars/Helpers/Series.js
@@ -62,4 +62,12 @@ define(
return new Handlebars.SafeString('
{0} Seasons'.format(seasonCount))
});
+
+ Handlebars.registerHelper('titleWithYear', function () {
+ if (this.title.endsWith(' ({0})'.format(this.year))) {
+ return this.title;
+ }
+
+ return '{0} ({1})'.format(this.title, this.year);
+ });
});
diff --git a/UI/SeasonPass/Layout.js b/UI/SeasonPass/Layout.js
index cb4500daf..ebf2609cf 100644
--- a/UI/SeasonPass/Layout.js
+++ b/UI/SeasonPass/Layout.js
@@ -24,16 +24,10 @@ define(
this.series.show(new LoadingView());
this.seriesCollection = SeriesCollection;
- this.seasonCollection = new SeasonCollection();
- var promise = this.seasonCollection.fetch();
-
- promise.done(function () {
- self.series.show(new SeriesCollectionView({
- collection: self.seriesCollection,
- seasonCollection: self.seasonCollection
- }));
- });
+ self.series.show(new SeriesCollectionView({
+ collection: self.seriesCollection
+ }));
}
});
});
diff --git a/UI/SeasonPass/SeriesCollectionView.js b/UI/SeasonPass/SeriesCollectionView.js
index 48cf5c39e..d5de2530e 100644
--- a/UI/SeasonPass/SeriesCollectionView.js
+++ b/UI/SeasonPass/SeriesCollectionView.js
@@ -5,22 +5,6 @@ define(
'SeasonPass/SeriesLayout'
], function (Marionette, SeriesLayout) {
return Marionette.CollectionView.extend({
-
- itemView: SeriesLayout,
-
- initialize: function (options) {
-
- if (!options.seasonCollection) {
- throw 'seasonCollection is needed';
- }
-
- this.seasonCollection = options.seasonCollection;
- },
-
- itemViewOptions: function () {
- return {
- seasonCollection: this.seasonCollection
- };
- }
+ itemView: SeriesLayout
});
});
diff --git a/UI/SeasonPass/SeriesLayout.js b/UI/SeasonPass/SeriesLayout.js
index fd4d6b985..e69a155e4 100644
--- a/UI/SeasonPass/SeriesLayout.js
+++ b/UI/SeasonPass/SeriesLayout.js
@@ -2,11 +2,9 @@
define(
[
'marionette',
- 'backgrid',
'Series/SeasonCollection',
- 'Cells/ToggleCell',
'Shared/Actioneer'
- ], function (Marionette, Backgrid, SeasonCollection, ToggleCell, Actioneer) {
+ ], function (Marionette, SeasonCollection, Actioneer) {
return Marionette.Layout.extend({
template: 'SeasonPass/SeriesLayoutTemplate',
@@ -19,48 +17,22 @@ define(
events: {
'change .x-season-select': '_seasonSelected',
'click .x-expander' : '_expand',
- 'click .x-latest' : '_latest'
+ 'click .x-latest' : '_latest',
+ 'click .x-monitored' : '_toggleSeasonMonitored'
},
regions: {
seasonGrid: '.x-season-grid'
},
- columns:
- [
- {
- name : 'monitored',
- label : '',
- cell : ToggleCell,
- trueClass : 'icon-bookmark',
- falseClass: 'icon-bookmark-empty',
- tooltip : 'Toggle monitored status',
- sortable : false
- },
- {
- name : 'seasonNumber',
- label: 'Season',
- cell : Backgrid.IntegerCell.extend({
- className: 'season-number-cell'
- })
- }
- ],
-
- initialize: function (options) {
- this.seasonCollection = options.seasonCollection.bySeries(this.model.get('id'));
- this.model.set('seasons', this.seasonCollection);
+ initialize: function () {
+ this.seasonCollection = new SeasonCollection(this.model.get('seasons'));
this.expanded = false;
},
onRender: function () {
- this.seasonGrid.show(new Backgrid.Grid({
- columns : this.columns,
- collection: this.seasonCollection,
- className : 'table table-condensed season-grid span5'
- }));
-
if (!this.expanded) {
- this.seasonGrid.$el.hide();
+ this.ui.seasonGrid.hide();
}
this._setExpanderIcon();
@@ -103,33 +75,51 @@ define(
},
_latest: function () {
- var season = _.max(this.seasonCollection.models, function (model) {
- return model.get('seasonNumber');
+ var season = _.max(this.model.get('seasons'), function (s) {
+ return s.seasonNumber;
});
- //var seasonNumber = season.get('seasonNumber');
-
- this._setMonitored(season.get('seasonNumber'))
+ this._setMonitored(season.seasonNumber);
},
_setMonitored: function (seasonNumber) {
- //TODO: use Actioneer?
-
var self = this;
- var promise = $.ajax({
- url: this.seasonCollection.url + '/pass',
- type: 'POST',
- data: {
- seriesId: this.model.get('id'),
- seasonNumber: seasonNumber
- }
- });
+ this.model.setSeasonPass(seasonNumber);
+
+ var promise = this.model.save();
promise.done(function (data) {
self.seasonCollection = new SeasonCollection(data);
self.render();
});
+ },
+
+ _toggleSeasonMonitored: function (e) {
+ var seasonNumber = 0;
+ var element;
+
+ if (e.target.localName === 'i') {
+ seasonNumber = parseInt($(e.target).parent('td').attr('data-season-number'));
+ element = $(e.target);
+ }
+
+ else {
+ seasonNumber = parseInt($(e.target).attr('data-season-number'));
+ element = $(e.target).children('i');
+ }
+
+ this.model.setSeasonMonitored(seasonNumber);
+
+ Actioneer.SaveModel({
+ element: element,
+ context: this,
+ always : this._afterToggleSeasonMonitored
+ });
+ },
+
+ _afterToggleSeasonMonitored: function () {
+ this.render();
}
});
});
diff --git a/UI/SeasonPass/SeriesLayoutTemplate.html b/UI/SeasonPass/SeriesLayoutTemplate.html
index 026718493..9c12a4483 100644
--- a/UI/SeasonPass/SeriesLayoutTemplate.html
+++ b/UI/SeasonPass/SeriesLayoutTemplate.html
@@ -12,12 +12,12 @@
@@ -36,7 +36,36 @@
-
+
+
+
+
+ |
+ Season |
+
+
+
+ {{#each seasons}}
+
+
+ {{#if monitored}}
+
+ {{else}}
+
+ {{/if}}
+ |
+
+ {{#if_eq seasonNumber compare="0"}}
+ Specials
+ {{else}}
+ Season {{seasonNumber}}
+ {{/if_eq}}
+ |
+
+ {{/each}}
+
+
+
diff --git a/UI/Series/Details/SeasonLayout.js b/UI/Series/Details/SeasonLayout.js
index 201103fd8..d6234ee87 100644
--- a/UI/Series/Details/SeasonLayout.js
+++ b/UI/Series/Details/SeasonLayout.js
@@ -117,8 +117,10 @@ define(
_seasonMonitored: function () {
var name = 'monitored';
this.model.set(name, !this.model.get(name));
+ this.series.setSeasonMonitored(this.model.get('seasonNumber'));
Actioneer.SaveModel({
+ model : this.series,
context: this,
element: this.ui.seasonMonitored,
always : this._afterSeasonMonitored
diff --git a/UI/Series/Details/SeriesDetailsLayout.js b/UI/Series/Details/SeriesDetailsLayout.js
index fb271a94c..bd794fbfe 100644
--- a/UI/Series/Details/SeriesDetailsLayout.js
+++ b/UI/Series/Details/SeriesDetailsLayout.js
@@ -113,12 +113,12 @@ define(
this.ui.monitored.removeClass('icon-spin icon-spinner');
if (this.model.get('monitored')) {
- this.ui.monitored.addClass('icon-bookmark');
- this.ui.monitored.removeClass('icon-bookmark-empty');
+ this.ui.monitored.addClass('icon-nd-monitored');
+ this.ui.monitored.removeClass('icon-nd-unmonitored');
}
else {
- this.ui.monitored.addClass('icon-bookmark-empty');
- this.ui.monitored.removeClass('icon-bookmark');
+ this.ui.monitored.addClass('icon-nd-unmonitored');
+ this.ui.monitored.removeClass('icon-nd-monitored');
}
},
@@ -176,11 +176,11 @@ define(
this.seasons.show(new LoadingView());
- this.seasonCollection = new SeasonCollection();
+ this.seasonCollection = new SeasonCollection(this.model.get('seasons'));
this.episodeCollection = new EpisodeCollection({ seriesId: this.model.id });
this.episodeFileCollection = new EpisodeFileCollection({ seriesId: this.model.id });
- $.when(this.episodeCollection.fetch(), this.episodeFileCollection.fetch(), this.seasonCollection.fetch({data: { seriesId: this.model.id }})).done(function () {
+ $.when(this.episodeCollection.fetch(), this.episodeFileCollection.fetch()).done(function () {
var seasonCollectionView = new SeasonCollectionView({
collection : self.seasonCollection,
episodeCollection: self.episodeCollection,
diff --git a/UI/Series/SeasonCollection.js b/UI/Series/SeasonCollection.js
index 68e312ff1..35984204a 100644
--- a/UI/Series/SeasonCollection.js
+++ b/UI/Series/SeasonCollection.js
@@ -5,21 +5,10 @@ define(
'Series/SeasonModel'
], function (Backbone, SeasonModel) {
return Backbone.Collection.extend({
- url : window.ApiRoot + '/season',
model: SeasonModel,
comparator: function (season) {
return -season.get('seasonNumber');
- },
-
- bySeries: function (series) {
- var filtered = this.filter(function (season) {
- return season.get('seriesId') === series;
- });
-
- var SeasonCollection = require('Series/SeasonCollection');
-
- return new SeasonCollection(filtered);
}
});
});
diff --git a/UI/Series/SeriesModel.js b/UI/Series/SeriesModel.js
index 075e0fc80..5be5eecb4 100644
--- a/UI/Series/SeriesModel.js
+++ b/UI/Series/SeriesModel.js
@@ -14,6 +14,25 @@ define(
episodeCount : 0,
isExisting : false,
status : 0
+ },
+
+ setSeasonMonitored: function (seasonNumber) {
+ _.each(this.get('seasons'), function (season) {
+ if (season.seasonNumber === seasonNumber) {
+ season.monitored = !season.monitored;
+ }
+ });
+ },
+
+ setSeasonPass: function (seasonNumber) {
+ _.each(this.get('seasons'), function (season) {
+ if (season.seasonNumber >= seasonNumber) {
+ season.monitored = true;
+ }
+ else {
+ season.monitored = false;
+ }
+ });
}
});
});
diff --git a/UI/Series/series.less b/UI/Series/series.less
index 5a8222bd5..c3b7170d0 100644
--- a/UI/Series/series.less
+++ b/UI/Series/series.less
@@ -256,6 +256,7 @@
.clickable;
line-height: 30px;
margin-left: 8px;
+ width: 16px;
}
.season-grid {
diff --git a/UI/Shared/Actioneer.js b/UI/Shared/Actioneer.js
index de9fcef8f..2eac452b3 100644
--- a/UI/Shared/Actioneer.js
+++ b/UI/Shared/Actioneer.js
@@ -33,7 +33,9 @@ define(
this._showStartMessage(options);
this._setSpinnerOnElement(options);
- var promise = options.context.model.save();
+ var model = options.model ? options.model : options.context.model;
+
+ var promise = model.save();
this._handlePromise(promise, options);
},