fixed season template helpers.
This commit is contained in:
parent
c090b3efa1
commit
5a5e160002
|
@ -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();
|
||||||
|
@ -98,7 +97,7 @@ define(
|
||||||
CommandController.bindToCommand({
|
CommandController.bindToCommand({
|
||||||
element: this.ui.seasonSearch,
|
element: this.ui.seasonSearch,
|
||||||
command: {
|
command: {
|
||||||
name: 'seasonSearch',
|
name : 'seasonSearch',
|
||||||
seriesId : this.series.id,
|
seriesId : this.series.id,
|
||||||
seasonNumber: this.model.get('seasonNumber')
|
seasonNumber: this.model.get('seasonNumber')
|
||||||
}
|
}
|
||||||
|
@ -107,7 +106,7 @@ define(
|
||||||
CommandController.bindToCommand({
|
CommandController.bindToCommand({
|
||||||
element: this.ui.seasonRename,
|
element: this.ui.seasonRename,
|
||||||
command: {
|
command: {
|
||||||
name: 'renameSeason',
|
name : 'renameSeason',
|
||||||
seriesId : this.series.id,
|
seriesId : this.series.id,
|
||||||
seasonNumber: this.model.get('seasonNumber')
|
seasonNumber: this.model.get('seasonNumber')
|
||||||
}
|
}
|
||||||
|
@ -117,7 +116,7 @@ define(
|
||||||
_seasonSearch: function () {
|
_seasonSearch: function () {
|
||||||
|
|
||||||
CommandController.Execute('seasonSearch', {
|
CommandController.Execute('seasonSearch', {
|
||||||
name: 'seasonSearch',
|
name : 'seasonSearch',
|
||||||
seriesId : this.series.id,
|
seriesId : this.series.id,
|
||||||
seasonNumber: this.model.get('seasonNumber')
|
seasonNumber: this.model.get('seasonNumber')
|
||||||
});
|
});
|
||||||
|
@ -126,7 +125,7 @@ define(
|
||||||
_seasonRename: function () {
|
_seasonRename: function () {
|
||||||
|
|
||||||
CommandController.Execute('renameSeason', {
|
CommandController.Execute('renameSeason', {
|
||||||
name: 'renameSeason',
|
name : 'renameSeason',
|
||||||
seriesId : this.series.id,
|
seriesId : this.series.id,
|
||||||
seasonNumber: this.model.get('seasonNumber')
|
seasonNumber: this.model.get('seasonNumber')
|
||||||
});
|
});
|
||||||
|
@ -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 () {
|
||||||
|
|
Loading…
Reference in New Issue