fixed calendar view
This commit is contained in:
parent
70cfa5e685
commit
aca5d1f361
|
@ -13,6 +13,11 @@ namespace NzbDrone.Core.Datastore.Converters
|
||||||
|
|
||||||
public object ToDB(object clrValue)
|
public object ToDB(object clrValue)
|
||||||
{
|
{
|
||||||
|
if (clrValue == DBNull.Value)
|
||||||
|
{
|
||||||
|
return clrValue;
|
||||||
|
}
|
||||||
|
|
||||||
var dateTime = (DateTime)clrValue;
|
var dateTime = (DateTime)clrValue;
|
||||||
return dateTime.ToUniversalTime();
|
return dateTime.ToUniversalTime();
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,7 +64,7 @@ define(['app', 'Calendar/Collection'], function () {
|
||||||
success: function (calendarCollection) {
|
success: function (calendarCollection) {
|
||||||
_.each(calendarCollection.models, function (element) {
|
_.each(calendarCollection.models, function (element) {
|
||||||
var episodeTitle = element.get('title');
|
var episodeTitle = element.get('title');
|
||||||
var seriesTitle = element.get('series').title;
|
var seriesTitle = element.get('series').get('title');
|
||||||
var start = element.get('airDate');
|
var start = element.get('airDate');
|
||||||
|
|
||||||
element.set('title', seriesTitle);
|
element.set('title', seriesTitle);
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
<h1>{{day}}</h1>
|
<h1>{{day}}</h1>
|
||||||
<h4>{{month}}</h4>
|
<h4>{{month}}</h4>
|
||||||
</div>
|
</div>
|
||||||
<a href="/series/details/{{series.titleSlug}}">
|
<a href="{{series.route}}">
|
||||||
<h4>{{series.title}}</h4>
|
<h4>{{series.title}}</h4>
|
||||||
</a>
|
</a>
|
||||||
<p>{{startTime}} {{date airDate}}<span class="pull-right">{{seasonNumber}}x{{paddedEpisodeNumber}}</span><br>{{episodeTitle}}</p>
|
<p>{{startTime}} {{date airDate}}<span class="pull-right">{{seasonNumber}}x{{paddedEpisodeNumber}}</span><br>{{episodeTitle}}</p>
|
||||||
|
|
|
@ -7,26 +7,41 @@ define(['app', 'Cells/NzbDroneCell'], function () {
|
||||||
|
|
||||||
render: function () {
|
render: function () {
|
||||||
|
|
||||||
var airDate = this.cellValue.get('airDate') || this.get(this.column.get("airDate"));
|
this.$el.empty();
|
||||||
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"));
|
|
||||||
|
|
||||||
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();
|
this.delegateEvents();
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,9 +28,13 @@ define(['app'], function () {
|
||||||
|
|
||||||
var value = this.model.get(name);
|
var value = this.model.get(name);
|
||||||
|
|
||||||
|
if(!value){
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
//if not a model
|
//if not a model
|
||||||
if (!value.get) {
|
if (!value.get) {
|
||||||
return value = new Backbone.Model(value);
|
value = new Backbone.Model(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
return value;
|
return value;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
define(['app','Series/SeriesModel'], function () {
|
define(['app', 'Series/SeriesModel'], function () {
|
||||||
NzbDrone.Series.EpisodeModel = Backbone.Model.extend({
|
NzbDrone.Series.EpisodeModel = Backbone.Model.extend({
|
||||||
|
|
||||||
mutators: {
|
mutators: {
|
||||||
|
@ -62,6 +62,13 @@ define(['app','Series/SeriesModel'], function () {
|
||||||
return model;
|
return model;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
toJSON: function () {
|
||||||
|
var json = _.clone(this.attributes);
|
||||||
|
json.series = this.get('series').toJSON();
|
||||||
|
|
||||||
|
return json;
|
||||||
|
},
|
||||||
|
|
||||||
defaults: {
|
defaults: {
|
||||||
seasonNumber: 0,
|
seasonNumber: 0,
|
||||||
status : 0
|
status : 0
|
||||||
|
|
Loading…
Reference in New Issue