mirror of
https://github.com/Radarr/Radarr
synced 2024-12-25 17:27:59 +00:00
restructuring series detail around season and episodes being separate resources.
This commit is contained in:
parent
c5b845cbee
commit
6447b78a5a
12 changed files with 35 additions and 83 deletions
|
@ -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; }
|
||||
|
|
|
@ -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 }));
|
||||
}
|
||||
});
|
||||
},
|
||||
|
|
|
@ -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
|
||||
});
|
||||
});
|
|
@ -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',
|
||||
|
|
|
@ -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'
|
||||
});
|
||||
});
|
||||
|
|
|
@ -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
|
||||
}
|
||||
});
|
||||
});
|
14
NzbDrone.Backbone/Series/Details/SeasonCompositeView.js
Normal file
14
NzbDrone.Backbone/Series/Details/SeasonCompositeView.js
Normal file
|
@ -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) {
|
||||
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 id="details"></div>
|
||||
<div id="seasons"></div>
|
||||
<div class="x-series-details"></div>
|
||||
<div class="x-series-seasons"></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({
|
||||
itemView: NzbDrone.Series.Details.SeasonCollectionView,
|
||||
itemViewContainer: '#seasons',
|
||||
|
||||
itemView: NzbDrone.Series.Details.SeasonCompositeView,
|
||||
itemViewContainer: '.x-series-seasons',
|
||||
template: 'Series/Details/SeriesDetailsTemplate',
|
||||
qualityProfileCollection: qualityProfileCollection,
|
||||
|
||||
initialize: function (options) {
|
||||
this.collection = options.collection;
|
||||
|
||||
this.qualityProfileCollection.fetch();
|
||||
},
|
||||
|
||||
onCompositeCollectionRendered: function()
|
||||
{
|
||||
var test = 1;
|
||||
initialize: function () {
|
||||
}
|
||||
});
|
||||
});
|
|
@ -1,6 +1,8 @@
|
|||
define(['app', 'Quality/QualityProfileCollection'], function (app, qualityProfileCollection) {
|
||||
NzbDrone.Series.SeriesModel = Backbone.Model.extend({
|
||||
|
||||
urlRoot: NzbDrone.Constants.ApiRoot + '/series',
|
||||
|
||||
mutators: {
|
||||
bestDateString: function () {
|
||||
return bestDateString(this.get('nextAiring'));
|
||||
|
|
Loading…
Reference in a new issue