From e164df217d06a6f2b1776e88c988ff4064cd8d80 Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Tue, 16 Jul 2013 17:41:04 -0700 Subject: [PATCH] Removed mutators from EpisodeModel --- UI/Calendar/CalendarView.js | 29 +++++++++++-- UI/Calendar/UpcomingItemTemplate.html | 8 ++-- UI/Episode/LayoutTemplate.html | 4 +- UI/Handlebars/Helpers/DateTime.js | 29 +++++++++++++ UI/Handlebars/Helpers/Episode.js | 27 +++++++++++- UI/Handlebars/Helpers/Numbers.js | 4 ++ UI/Handlebars/Helpers/Quality.js | 2 +- UI/Series/EpisodeModel.js | 62 ++------------------------- 8 files changed, 95 insertions(+), 70 deletions(-) diff --git a/UI/Calendar/CalendarView.js b/UI/Calendar/CalendarView.js index 91976be28..6ba4f40cc 100644 --- a/UI/Calendar/CalendarView.js +++ b/UI/Calendar/CalendarView.js @@ -60,12 +60,14 @@ define( var episodeTitle = element.get('title'); var seriesTitle = element.get('series').get('title'); var start = element.get('airDate'); + var statusLevel = _instance.getStatusLevel(element); element.set({ - 'title': seriesTitle, + title : seriesTitle, episodeTitle: episodeTitle, - start: start, - allDay: false + start : start, + allDay : false, + statusLevel : statusLevel }); element.set('model', element); @@ -74,6 +76,27 @@ define( callback(calendarCollection.toJSON()); } }); + }, + + getStatusLevel: function (element) { + var hasFile = element.get('hasFile'); + var currentTime = Date.create(); + var start = Date.create(element.get('airDate')); + var end = Date.create(element.get('end')); + + if (currentTime.isBetween(start, end)) { + return 'warning'; + } + + if (start.isBefore(currentTime) && !hasFile) { + return 'danger'; + } + + if (hasFile) { + return 'success'; + } + + return 'primary'; } }); }); diff --git a/UI/Calendar/UpcomingItemTemplate.html b/UI/Calendar/UpcomingItemTemplate.html index af9fd5854..f8b4a8ee9 100644 --- a/UI/Calendar/UpcomingItemTemplate.html +++ b/UI/Calendar/UpcomingItemTemplate.html @@ -1,11 +1,11 @@ 
-
-

{{day}}

-

{{month}}

+
+

{{Day airDate}}

+

{{Month airDate}}

{{series.title}}

-

{{startTime}} {{ShortDate airDate}}{{seasonNumber}}x{{paddedEpisodeNumber}}
{{episodeTitle}}

+

{{StartTime airDate}} {{ShortDate airDate}}{{seasonNumber}}x{{Pad2 episodeNumber}}
{{episodeTitle}}

{{title}}

diff --git a/UI/Episode/LayoutTemplate.html b/UI/Episode/LayoutTemplate.html index 35048ed7a..7cbe5ba2b 100644 --- a/UI/Episode/LayoutTemplate.html +++ b/UI/Episode/LayoutTemplate.html @@ -3,9 +3,9 @@ {{#if episodeTitle}} -

{{episodeTitle}} - {{episodeNumberHelper}}

+

{{episodeTitle}} - {{EpisodeNumber}}

{{else}} -

{{title}} - {{episodeNumberHelper}}

+

{{title}} - {{EpisodeNumber}}

{{/if}}