From 14cf5bf3ccaf7e7f44c1666a52f9860c5fb13a15 Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Thu, 28 Feb 2013 08:34:18 -0800 Subject: [PATCH] Calendar is coming together! --- NzbDrone.Backbone/AddSeries/addSeries.css | 2 +- .../Calendar/CalendarCollection.js | 5 ++- .../Calendar/CalendarCollectionTemplate.html | 7 ++-- .../Calendar/CalendarCollectionView.js | 5 +-- .../Calendar/CalendarItemTemplate.html | 11 ++++--- .../Calendar/CalendarItemView.js | 3 +- NzbDrone.Backbone/Calendar/CalendarModel.js | 33 ++++++++++++++++++- 7 files changed, 53 insertions(+), 13 deletions(-) diff --git a/NzbDrone.Backbone/AddSeries/addSeries.css b/NzbDrone.Backbone/AddSeries/addSeries.css index 304cabcd7..7c533e25d 100644 --- a/NzbDrone.Backbone/AddSeries/addSeries.css +++ b/NzbDrone.Backbone/AddSeries/addSeries.css @@ -71,7 +71,7 @@ font-size: 16px; } -.existing-root-folder-view, h1 { +.existing-root-folder-view h1 { padding: 10px 0 20px 0; } diff --git a/NzbDrone.Backbone/Calendar/CalendarCollection.js b/NzbDrone.Backbone/Calendar/CalendarCollection.js index b824db275..d074d328b 100644 --- a/NzbDrone.Backbone/Calendar/CalendarCollection.js +++ b/NzbDrone.Backbone/Calendar/CalendarCollection.js @@ -1,6 +1,9 @@ define(['app', 'Calendar/CalendarModel'], function () { NzbDrone.Calendar.CalendarCollection = Backbone.Collection.extend({ url: NzbDrone.Constants.ApiRoot + '/calendar', - model: NzbDrone.Calendar.CalendarModel + model: NzbDrone.Calendar.CalendarModel, + comparator: function(model) { + return model.get('start'); + } }); }); \ No newline at end of file diff --git a/NzbDrone.Backbone/Calendar/CalendarCollectionTemplate.html b/NzbDrone.Backbone/Calendar/CalendarCollectionTemplate.html index 7633f71a6..b34deeca2 100644 --- a/NzbDrone.Backbone/Calendar/CalendarCollectionTemplate.html +++ b/NzbDrone.Backbone/Calendar/CalendarCollectionTemplate.html @@ -1,3 +1,6 @@ -
+
+

Upcoming

-
\ No newline at end of file +
+
+
\ No newline at end of file diff --git a/NzbDrone.Backbone/Calendar/CalendarCollectionView.js b/NzbDrone.Backbone/Calendar/CalendarCollectionView.js index 2fe112a3c..053829baf 100644 --- a/NzbDrone.Backbone/Calendar/CalendarCollectionView.js +++ b/NzbDrone.Backbone/Calendar/CalendarCollectionView.js @@ -3,8 +3,9 @@ define(['app', 'Calendar/CalendarItemView'], function (app) { NzbDrone.Calendar.CalendarCollectionView = Backbone.Marionette.CompositeView.extend({ itemView: NzbDrone.Calendar.CalendarItemView, - itemViewContainer: '#upcomingContainer', + itemViewContainer: '#events', template: 'Calendar/CalendarCollectionTemplate', + className: 'row', ui: { calendar: '#calendar' @@ -17,7 +18,7 @@ define(['app', 'Calendar/CalendarItemView'], function (app) { onCompositeCollectionRendered: function() { $(this.ui.calendar).fullCalendar({ allDayDefault: false, - //ignoreTimezone: false, + ignoreTimezone: false, weekMode: 'variable', header: { left: 'prev,next today', diff --git a/NzbDrone.Backbone/Calendar/CalendarItemTemplate.html b/NzbDrone.Backbone/Calendar/CalendarItemTemplate.html index b53ef04e9..0a64d1e30 100644 --- a/NzbDrone.Backbone/Calendar/CalendarItemTemplate.html +++ b/NzbDrone.Backbone/Calendar/CalendarItemTemplate.html @@ -1,5 +1,6 @@ -{{seriesTitle}} -{{seasonNumber}}x{{episodeNumber}} -{{episodeTitle}} -{{airTime}} -{{status}} \ No newline at end of file +
+

{{day}}

+

{{month}}

+
+

{{seriesTitle}}

+

{{startTime}}{{seasonNumber}}x{{paddedEpisodeNumber}}
{{episodeTitle}}

diff --git a/NzbDrone.Backbone/Calendar/CalendarItemView.js b/NzbDrone.Backbone/Calendar/CalendarItemView.js index e7c2a8cf8..9fc659003 100644 --- a/NzbDrone.Backbone/Calendar/CalendarItemView.js +++ b/NzbDrone.Backbone/Calendar/CalendarItemView.js @@ -7,7 +7,8 @@ define([ ], function () { NzbDrone.Calendar.CalendarItemView = Backbone.Marionette.ItemView.extend({ template: 'Calendar/CalendarItemTemplate', - tagName: 'tr', + tagName: 'div', + className: 'event', onRender: function () { NzbDrone.ModelBinder.bind(this.model, this.el); diff --git a/NzbDrone.Backbone/Calendar/CalendarModel.js b/NzbDrone.Backbone/Calendar/CalendarModel.js index 300c04d77..4cd80b5c6 100644 --- a/NzbDrone.Backbone/Calendar/CalendarModel.js +++ b/NzbDrone.Backbone/Calendar/CalendarModel.js @@ -2,10 +2,41 @@ NzbDrone.Calendar.CalendarModel = Backbone.Model.extend({ mutators: { title: function () { - return this.get('seriesTitle') + ' - ' + this.get('seasonNumber') + 'x' + this.get('episodeNumber').pad(2); + return this.get('seriesTitle'); }, allDay: function(){ return false; + }, + day: function() { + return Date.create(this.get('start')).format('{dd}'); + }, + month: function(){ + return Date.create(this.get('start')).format('{MON}'); + }, + startTime: function(){ + var start = Date.create(this.get('start')); + + if (start.format('{mm}') === '00') + return start.format('{h}{tt}'); + + return start.format('{h}.{mm}{tt}'); + }, + paddedEpisodeNumber: function(){ + return this.get('episodeNumber'); + }, + statusLevel: function() { + var status = this.get('status'); + var currentTime = Date.create(); + var start = Date.create(this.get('start')); + var end = Date.create(this.get('end')); + + if (currentTime.isBetween(start, end)) + return 'warning'; + + if (status === 'Missing') return 'danger'; + if (status === 'Ready') return 'success'; + + return 'info'; } }, defaults: {