diff --git a/NzbDrone.Api/Episodes/EpisodeResource.cs b/NzbDrone.Api/Episodes/EpisodeResource.cs index b1ff70ef7..485bc5333 100644 --- a/NzbDrone.Api/Episodes/EpisodeResource.cs +++ b/NzbDrone.Api/Episodes/EpisodeResource.cs @@ -6,8 +6,8 @@ namespace NzbDrone.Api.Episodes { public class EpisodeResource { + public Int32 Id { get; set; } public Int32 SeriesId { get; set; } - public Int32 EpisodeId { get; set; } public Int32 EpisodeFileId { get; set; } public Int32 SeasonNumber { get; set; } public Int32 EpisodeNumber { get; set; } diff --git a/NzbDrone.Backbone/Controller.js b/NzbDrone.Backbone/Controller.js index b960af31d..6f8b47678 100644 --- a/NzbDrone.Backbone/Controller.js +++ b/NzbDrone.Backbone/Controller.js @@ -30,31 +30,14 @@ }, 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 }); - seriesEpisodes.fetch({ - success: function (collection) { - var seasons = collection.models.groupBy(function(episode){ - var seasonNumber = episode.get('seasonNumber'); - - if (seasonNumber === undefined) - 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 })); + var self = this; + this.setTitle('Loading Series'); + var series = new NzbDrone.Series.SeriesModel({ id: query }); + series.fetch({ + success: function (seriesModel) { + self.setTitle(seriesModel.get('title')); + NzbDrone.mainRegion.show(new NzbDrone.Series.Details.SeriesDetailsView({ model: seriesModel })); } }); }, diff --git a/NzbDrone.Backbone/Series/Details/EpisodeCollection.js b/NzbDrone.Backbone/Series/Details/EpisodeCollection.js index f4cbff92d..786f205cd 100644 --- a/NzbDrone.Backbone/Series/Details/EpisodeCollection.js +++ b/NzbDrone.Backbone/Series/Details/EpisodeCollection.js @@ -1,13 +1,6 @@ define(['app', 'Series/Details/EpisodeModel'], function () { NzbDrone.Series.Details.EpisodeCollection = Backbone.Collection.extend({ - initialize: function(options) { - this.seriesId = options.seriesId; - }, - - url: function(){ - return NzbDrone.Constants.ApiRoot + '/episodes/' + this.seriesId; - }, - + url: NzbDrone.Constants.ApiRoot + '/episode', model: NzbDrone.Series.Details.EpisodeModel }); }); \ No newline at end of file diff --git a/NzbDrone.Backbone/Series/Details/EpisodeItemView.js b/NzbDrone.Backbone/Series/Details/EpisodeItemView.js index c9874da5f..3f8e70125 100644 --- a/NzbDrone.Backbone/Series/Details/EpisodeItemView.js +++ b/NzbDrone.Backbone/Series/Details/EpisodeItemView.js @@ -1,10 +1,5 @@ 'use strict'; - -define([ - 'app', - 'Series/Details/SeasonModel' - -], function () { +define(['app', 'Series/Details/SeasonModel'], function () { NzbDrone.Series.Details.EpisodeItemView = Backbone.Marionette.ItemView.extend({ template: 'Series/Details/EpisodeItemTemplate', diff --git a/NzbDrone.Backbone/Series/Details/SeasonCollection.js b/NzbDrone.Backbone/Series/Details/SeasonCollection.js index c99fc64cd..64f998157 100644 --- a/NzbDrone.Backbone/Series/Details/SeasonCollection.js +++ b/NzbDrone.Backbone/Series/Details/SeasonCollection.js @@ -1,10 +1,5 @@ -define(['app'], function (app) { +define(['app','Series/Details/SeasonModel'], function () { NzbDrone.Series.Details.SeasonCollection = Backbone.Collection.extend({ - // Todo: Why does this throw: "this.model is undefined" - Chnaging to another model fixes it - //model: NzbDrone.Series.Details.SeasonModel, - model: NzbDrone.Series.Details.EpisodeModel, - comparator: function(model) { - return -model.get('seasonNumber'); - } + url: NzbDrone.Constants.ApiRoot + '/season' }); }); diff --git a/NzbDrone.Backbone/Series/Details/SeasonCollectionView.js b/NzbDrone.Backbone/Series/Details/SeasonCollectionView.js deleted file mode 100644 index f3d09e88a..000000000 --- a/NzbDrone.Backbone/Series/Details/SeasonCollectionView.js +++ /dev/null @@ -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 - } - }); -}); \ No newline at end of file diff --git a/NzbDrone.Backbone/Series/Details/SeasonCollectionTemplate.html b/NzbDrone.Backbone/Series/Details/SeasonCompositeTemplate.html similarity index 100% rename from NzbDrone.Backbone/Series/Details/SeasonCollectionTemplate.html rename to NzbDrone.Backbone/Series/Details/SeasonCompositeTemplate.html diff --git a/NzbDrone.Backbone/Series/Details/SeasonCompositeView.js b/NzbDrone.Backbone/Series/Details/SeasonCompositeView.js new file mode 100644 index 000000000..89ca91e5d --- /dev/null +++ b/NzbDrone.Backbone/Series/Details/SeasonCompositeView.js @@ -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 + } + }); +}); \ No newline at end of file diff --git a/NzbDrone.Backbone/Series/Details/SeasonModel.js b/NzbDrone.Backbone/Series/Details/SeasonModel.js index 10f189ccc..579e20d9e 100644 --- a/NzbDrone.Backbone/Series/Details/SeasonModel.js +++ b/NzbDrone.Backbone/Series/Details/SeasonModel.js @@ -1,11 +1,4 @@ define(['app', 'Series/Details/SeasonCollection'], function (app) { NzbDrone.Series.Details.SeasonModel = Backbone.Model.extend({ - //Season Number - //Episodes - - initialize: function(options) { - this.seasonNumber = options.seasonNumber; - this.episodes = options.episodes; - } }); }); \ No newline at end of file diff --git a/NzbDrone.Backbone/Series/Details/SeriesDetailsTemplate.html b/NzbDrone.Backbone/Series/Details/SeriesDetailsTemplate.html index 273256ce1..0bd52c335 100644 --- a/NzbDrone.Backbone/Series/Details/SeriesDetailsTemplate.html +++ b/NzbDrone.Backbone/Series/Details/SeriesDetailsTemplate.html @@ -1,4 +1,4 @@