restructuring series detail around season and episodes being separate resources.

pull/3113/head
kay.one 12 years ago
parent c5b845cbee
commit 6447b78a5a

@ -6,8 +6,8 @@ namespace NzbDrone.Api.Episodes
{ {
public class EpisodeResource public class EpisodeResource
{ {
public Int32 Id { get; set; }
public Int32 SeriesId { get; set; } public Int32 SeriesId { get; set; }
public Int32 EpisodeId { get; set; }
public Int32 EpisodeFileId { get; set; } public Int32 EpisodeFileId { get; set; }
public Int32 SeasonNumber { get; set; } public Int32 SeasonNumber { get; set; }
public Int32 EpisodeNumber { get; set; } public Int32 EpisodeNumber { get; set; }

@ -30,31 +30,14 @@
}, },
seriesDetails: function (query) { seriesDetails: function (query) {
this.setTitle('Series Title Goes Here');
// var seriesModel = new NzbDrone.Series.SeriesModel();
// seriesModel.fetch();
var seriesEpisodes = new NzbDrone.Series.Details.EpisodeCollection({ seriesId: query }); var self = this;
seriesEpisodes.fetch({ this.setTitle('Loading Series');
success: function (collection) { var series = new NzbDrone.Series.SeriesModel({ id: query });
var seasons = collection.models.groupBy(function(episode){ series.fetch({
var seasonNumber = episode.get('seasonNumber'); success: function (seriesModel) {
self.setTitle(seriesModel.get('title'));
if (seasonNumber === undefined) NzbDrone.mainRegion.show(new NzbDrone.Series.Details.SeriesDetailsView({ model: seriesModel }));
return 0;
return seasonNumber;
});
var seasonCollection = new NzbDrone.Series.Details.SeasonCollection();
$.each(seasons, function(index, season){
seasonCollection.add(new NzbDrone.Series.Details.SeasonModel(
{ seasonNumber: index, episodes: season })
);
});
NzbDrone.mainRegion.show(new NzbDrone.Series.Details.SeriesDetailsView({ collection: seasonCollection }));
} }
}); });
}, },

@ -1,13 +1,6 @@
define(['app', 'Series/Details/EpisodeModel'], function () { define(['app', 'Series/Details/EpisodeModel'], function () {
NzbDrone.Series.Details.EpisodeCollection = Backbone.Collection.extend({ NzbDrone.Series.Details.EpisodeCollection = Backbone.Collection.extend({
initialize: function(options) { url: NzbDrone.Constants.ApiRoot + '/episode',
this.seriesId = options.seriesId;
},
url: function(){
return NzbDrone.Constants.ApiRoot + '/episodes/' + this.seriesId;
},
model: NzbDrone.Series.Details.EpisodeModel model: NzbDrone.Series.Details.EpisodeModel
}); });
}); });

@ -1,10 +1,5 @@
'use strict'; 'use strict';
define(['app', 'Series/Details/SeasonModel'], function () {
define([
'app',
'Series/Details/SeasonModel'
], function () {
NzbDrone.Series.Details.EpisodeItemView = Backbone.Marionette.ItemView.extend({ NzbDrone.Series.Details.EpisodeItemView = Backbone.Marionette.ItemView.extend({
template: 'Series/Details/EpisodeItemTemplate', template: 'Series/Details/EpisodeItemTemplate',

@ -1,10 +1,5 @@
define(['app'], function (app) { define(['app','Series/Details/SeasonModel'], function () {
NzbDrone.Series.Details.SeasonCollection = Backbone.Collection.extend({ NzbDrone.Series.Details.SeasonCollection = Backbone.Collection.extend({
// Todo: Why does this throw: "this.model is undefined" - Chnaging to another model fixes it url: NzbDrone.Constants.ApiRoot + '/season'
//model: NzbDrone.Series.Details.SeasonModel,
model: NzbDrone.Series.Details.EpisodeModel,
comparator: function(model) {
return -model.get('seasonNumber');
}
}); });
}); });

@ -1,15 +0,0 @@
'use strict';
define(['app', 'Series/Details/EpisodeItemView'], function (app) {
NzbDrone.Series.Details.SeasonCollectionView = Backbone.Marionette.CompositeView.extend({
itemView: NzbDrone.Series.Details.EpisodeItemView,
itemViewContainer: '#seasons',
template: 'Series/Details/SeasonCollectionTemplate',
initialize: function() {
var episodes = this.model.get('episodes');
var test = 1;
//this.collection
}
});
});

@ -0,0 +1,14 @@
'use strict';
define(['app', 'Series/Details/EpisodeItemView'], function () {
NzbDrone.Series.Details.SeasonCompositeView = Backbone.Marionette.CompositeView.extend({
itemView: NzbDrone.Series.Details.EpisodeItemView,
itemViewContainer: '.x-episodes',
template: 'Series/Details/SeasonCompositeTemplate',
initialize: function() {
var episodes = this.model.get('episodes');
var test = 1;
//this.collection
}
});
});

@ -1,11 +1,4 @@
define(['app', 'Series/Details/SeasonCollection'], function (app) { define(['app', 'Series/Details/SeasonCollection'], function (app) {
NzbDrone.Series.Details.SeasonModel = Backbone.Model.extend({ NzbDrone.Series.Details.SeasonModel = Backbone.Model.extend({
//Season Number
//Episodes
initialize: function(options) {
this.seasonNumber = options.seasonNumber;
this.episodes = options.episodes;
}
}); });
}); });

@ -1,4 +1,4 @@
<div> <div>
<div id="details"></div> <div class="x-series-details"></div>
<div id="seasons"></div> <div class="x-series-seasons"></div>
</div> </div>

@ -1,19 +1,11 @@
define(['app', 'Quality/QualityProfileCollection', 'Series/Details/SeasonCollectionView'], function (app, qualityProfileCollection) { define(['app', 'Quality/QualityProfileCollection', 'Series/Details/SeasonCompositeView'], function () {
NzbDrone.Series.Details.SeriesDetailsView = Backbone.Marionette.CompositeView.extend({ NzbDrone.Series.Details.SeriesDetailsView = Backbone.Marionette.CompositeView.extend({
itemView: NzbDrone.Series.Details.SeasonCollectionView,
itemViewContainer: '#seasons',
template: 'Series/Details/SeriesDetailsTemplate',
qualityProfileCollection: qualityProfileCollection,
initialize: function (options) {
this.collection = options.collection;
this.qualityProfileCollection.fetch(); itemView: NzbDrone.Series.Details.SeasonCompositeView,
}, itemViewContainer: '.x-series-seasons',
template: 'Series/Details/SeriesDetailsTemplate',
onCompositeCollectionRendered: function() initialize: function () {
{
var test = 1;
} }
}); });
}); });

@ -1,6 +1,8 @@
define(['app', 'Quality/QualityProfileCollection'], function (app, qualityProfileCollection) { define(['app', 'Quality/QualityProfileCollection'], function (app, qualityProfileCollection) {
NzbDrone.Series.SeriesModel = Backbone.Model.extend({ NzbDrone.Series.SeriesModel = Backbone.Model.extend({
urlRoot: NzbDrone.Constants.ApiRoot + '/series',
mutators: { mutators: {
bestDateString: function () { bestDateString: function () {
return bestDateString(this.get('nextAiring')); return bestDateString(this.get('nextAiring'));

Loading…
Cancel
Save