New: Absolute episode numbers shown beside episode numbers

This commit is contained in:
Mark McDowall 2014-08-23 00:07:44 -07:00
parent bc727e7187
commit 367ab6a361
4 changed files with 26 additions and 2 deletions

View File

@ -17,6 +17,7 @@ define(
var airDateField = this.column.get('airDateUtc') || 'airDateUtc';
var seasonField = this.column.get('seasonNumber') || 'seasonNumber';
var episodeField = this.column.get('episodes') || 'episodeNumber';
var absoluteEpisodeField = 'absoluteEpisodeNumber';
if (this.model) {
var result = 'Unknown';
@ -24,6 +25,7 @@ define(
var airDate = this.model.get(airDateField);
var seasonNumber = this.model.get(seasonField);
var episodes = this.model.get(episodeField);
var absoluteEpisodeNumber = this.model.get(absoluteEpisodeField);
if (this.cellValue) {
if (!seasonNumber) {
@ -34,6 +36,10 @@ define(
episodes = this.cellValue.get(episodeField);
}
if (!absoluteEpisodeNumber) {
absoluteEpisodeNumber = this.cellValue.get(absoluteEpisodeField);
}
if (!airDate) {
this.model.get(airDateField);
}
@ -42,6 +48,7 @@ define(
if (episodes) {
var paddedEpisodes;
var paddedAbsoluteEpisode;
if (episodes.constructor === Array) {
paddedEpisodes = _.map(episodes,function (episodeNumber) {
@ -50,9 +57,14 @@ define(
}
else {
paddedEpisodes = FormatHelpers.pad(episodes, 2);
paddedAbsoluteEpisode = FormatHelpers.pad(absoluteEpisodeNumber, 2);
}
result = '{0}x{1}'.format(seasonNumber, paddedEpisodes);
if (absoluteEpisodeNumber > 0 && paddedAbsoluteEpisode) {
result += ' ({0})'.format(paddedAbsoluteEpisode);
}
}
else if (airDate) {
result = new Date(airDate).toLocaleDateString();

View File

@ -11,6 +11,10 @@ define(
return moment(this.airDate).format('L');
}
else if (this.series.seriesType === 'anime' && this.absoluteEpisodeNumber > 0) {
return '{0}x{1} ({2})'.format(this.seasonNumber, FormatHelpers.pad(this.episodeNumber, 2), FormatHelpers.pad(this.absoluteEpisodeNumber, 2));
}
else {
return '{0}x{1}'.format(this.seasonNumber, FormatHelpers.pad(this.episodeNumber, 2));
}

View File

@ -4,8 +4,9 @@ define(
[
'marionette',
'Cells/NzbDroneCell',
'reqres'
], function (Marionette, NzbDroneCell, reqres) {
'reqres',
'Series/SeriesCollection'
], function (Marionette, NzbDroneCell, reqres, SeriesCollection) {
return NzbDroneCell.extend({
className: 'episode-number-cell',
@ -16,6 +17,12 @@ define(
this.$el.empty();
this.$el.html(this.model.get('episodeNumber'));
var series = SeriesCollection.get(this.model.get('seriesId'));
if (series.get('seriesType') === 'anime' && this.model.has('absoluteEpisodeNumber')) {
this.$el.html('{0} ({1})'.format(this.model.get('episodeNumber'), this.model.get('absoluteEpisodeNumber')));
}
var alternateTitles = [];
if (reqres.hasHandler(reqres.Requests.GetAlternateNameBySeasonNumber)) {

View File

@ -244,6 +244,7 @@
.episode-number-cell {
width : 22px;
white-space: nowrap;
}
.episode-air-date-cell {
width : 150px;