fixed calendar view

This commit is contained in:
kay.one 2013-06-09 19:10:15 -07:00
parent 70cfa5e685
commit aca5d1f361
6 changed files with 51 additions and 20 deletions

View File

@ -13,6 +13,11 @@ namespace NzbDrone.Core.Datastore.Converters
public object ToDB(object clrValue)
{
if (clrValue == DBNull.Value)
{
return clrValue;
}
var dateTime = (DateTime)clrValue;
return dateTime.ToUniversalTime();
}

View File

@ -64,7 +64,7 @@ define(['app', 'Calendar/Collection'], function () {
success: function (calendarCollection) {
_.each(calendarCollection.models, function (element) {
var episodeTitle = element.get('title');
var seriesTitle = element.get('series').title;
var seriesTitle = element.get('series').get('title');
var start = element.get('airDate');
element.set('title', seriesTitle);

View File

@ -3,7 +3,7 @@
<h1>{{day}}</h1>
<h4>{{month}}</h4>
</div>
<a href="/series/details/{{series.titleSlug}}">
<a href="{{series.route}}">
<h4>{{series.title}}</h4>
</a>
<p>{{startTime}} {{date airDate}}<span class="pull-right">{{seasonNumber}}x{{paddedEpisodeNumber}}</span><br>{{episodeTitle}}</p>

View File

@ -7,26 +7,41 @@ define(['app', 'Cells/NzbDroneCell'], function () {
render: function () {
var airDate = this.cellValue.get('airDate') || this.get(this.column.get("airDate"));
var seasonNumber = this.cellValue.get('seasonNumber') || this.model.get(this.column.get("seasonNumber"));
var episodes = this.cellValue.get('episodeNumber') || this.model.get(this.column.get("episodes"));
this.$el.empty();
var result = 'Unknown';
var airDateField = this.column.get('airDate') || 'airDate';
var seasonFiled = this.column.get('seasonNumber') || 'seasonNumber';
var episodeFiled = this.column.get('episodes') || 'episodeNumber';
if (airDate) {
if (this.cellValue) {
result = new Date(airDate).toLocaleDateString();
var airDate = this.cellValue.get(airDateField);
var seasonNumber = this.cellValue.get(seasonFiled);
var episodes = this.cellValue.get(episodeFiled);
var result = 'Unknown';
if (episodes) {
var paddedEpisodes;
if (episodes.constructor === Array) {
paddedEpisodes = _.map(episodes,function (episodeNumber) {
return episodeNumber.pad(2);
}).join();
}
else {
paddedEpisodes = episodes.pad(2);
}
result = 'S{0}-E{1}'.format(seasonNumber.pad(2), paddedEpisodes);
}
else if (airDate) {
result = new Date(airDate).toLocaleDateString();
}
this.$el.html(result);
}
else {
var paddedEpisodes = _.map(episodes, function (episodeNumber) {
return episodeNumber.pad(2);
});
result = 'S{0}-E{1}'.format(seasonNumber, paddedEpisodes.join());
}
this.$el.html(result);
this.delegateEvents();
return this;
}

View File

@ -28,9 +28,13 @@ define(['app'], function () {
var value = this.model.get(name);
if(!value){
return undefined;
}
//if not a model
if (!value.get) {
return value = new Backbone.Model(value);
value = new Backbone.Model(value);
}
return value;

View File

@ -1,5 +1,5 @@
"use strict";
define(['app','Series/SeriesModel'], function () {
define(['app', 'Series/SeriesModel'], function () {
NzbDrone.Series.EpisodeModel = Backbone.Model.extend({
mutators: {
@ -62,6 +62,13 @@ define(['app','Series/SeriesModel'], function () {
return model;
},
toJSON: function () {
var json = _.clone(this.attributes);
json.series = this.get('series').toJSON();
return json;
},
defaults: {
seasonNumber: 0,
status : 0