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

View File

@ -11,6 +11,10 @@ define(
return moment(this.airDate).format('L'); 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 { else {
return '{0}x{1}'.format(this.seasonNumber, FormatHelpers.pad(this.episodeNumber, 2)); return '{0}x{1}'.format(this.seasonNumber, FormatHelpers.pad(this.episodeNumber, 2));
} }

View File

@ -4,8 +4,9 @@ define(
[ [
'marionette', 'marionette',
'Cells/NzbDroneCell', 'Cells/NzbDroneCell',
'reqres' 'reqres',
], function (Marionette, NzbDroneCell, reqres) { 'Series/SeriesCollection'
], function (Marionette, NzbDroneCell, reqres, SeriesCollection) {
return NzbDroneCell.extend({ return NzbDroneCell.extend({
className: 'episode-number-cell', className: 'episode-number-cell',
@ -16,6 +17,12 @@ define(
this.$el.empty(); this.$el.empty();
this.$el.html(this.model.get('episodeNumber')); 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 = []; var alternateTitles = [];
if (reqres.hasHandler(reqres.Requests.GetAlternateNameBySeasonNumber)) { if (reqres.hasHandler(reqres.Requests.GetAlternateNameBySeasonNumber)) {

View File

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