fixed season template helpers.

This commit is contained in:
kay.one 2013-09-11 19:31:45 -07:00
parent c090b3efa1
commit 5a5e160002
1 changed files with 15 additions and 18 deletions

View File

@ -75,7 +75,7 @@ define(
if (!options.episodeCollection) { if (!options.episodeCollection) {
throw 'episodeCollection is needed'; throw 'episodeCollection is needed';
} }
this.templateHelpers = this.templateHelpers || {};
this.episodeCollection = options.episodeCollection.bySeason(this.model.get('seasonNumber')); this.episodeCollection = options.episodeCollection.bySeason(this.model.get('seasonNumber'));
this.series = options.series; this.series = options.series;
@ -87,7 +87,6 @@ define(
onRender: function () { onRender: function () {
this._generateTemplateHelpers();
if (this.showingEpisodes) { if (this.showingEpisodes) {
this._showEpisodes(); this._showEpisodes();
@ -137,8 +136,7 @@ define(
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'));
var savePromise = this.series.save() var savePromise = this.series.save().always(this._afterSeasonMonitored.bind(this));
.always(this._afterSeasonMonitored.bind(this));
this.ui.seasonMonitored.spinForPromise(savePromise); this.ui.seasonMonitored.spinForPromise(savePromise);
}, },
@ -167,7 +165,6 @@ define(
}, },
_afterRename: function () { _afterRename: function () {
App.vent.trigger(App.Events.SeasonRenamed, { series: this.series, seasonNumber: this.model.get('seasonNumber') }); App.vent.trigger(App.Events.SeasonRenamed, { series: this.series, seasonNumber: this.model.get('seasonNumber') });
}, },
@ -184,7 +181,7 @@ define(
var startDate = Moment().add('month', -1); var startDate = Moment().add('month', -1);
var endDate = Moment().add('year', 1); var endDate = Moment().add('year', 1);
var result = this.episodeCollection.some(function (episode) { return this.episodeCollection.some(function (episode) {
var airDate = episode.get('airDateUtc'); var airDate = episode.get('airDateUtc');
@ -198,15 +195,12 @@ define(
return false; return false;
}); });
return result;
}, },
_generateTemplateHelpers: function () { templateHelpers: function () {
this.templateHelpers.showingEpisodes = this.showingEpisodes;
var episodeCount = this.episodeCollection.filter(function (episode) { var episodeCount = this.episodeCollection.filter(function (episode) {
return (episode.get('monitored') && Moment(episode.get('airDateUtc')).isBefore(Moment())) || episode.get('hasFile'); return episode.get('hasFile') || (episode.get('monitored') && Moment(episode.get('airDateUtc')).isBefore(Moment()));
}).length; }).length;
var episodeFileCount = this.episodeCollection.where({ hasFile: true }).length; var episodeFileCount = this.episodeCollection.where({ hasFile: true }).length;
@ -216,9 +210,12 @@ define(
percentOfEpisodes = episodeFileCount / episodeCount * 100; percentOfEpisodes = episodeFileCount / episodeCount * 100;
} }
this.templateHelpers.episodeCount = episodeCount; return {
this.templateHelpers.episodeFileCount = episodeFileCount; showingEpisodes : this.showingEpisodes,
this.templateHelpers.percentOfEpisodes = percentOfEpisodes; episodeCount : episodeCount,
episodeFileCount : episodeFileCount,
percentOfEpisodes: percentOfEpisodes
};
}, },
_showHideEpisodes: function () { _showHideEpisodes: function () {