mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-21 14:03:29 -07:00
Seasons are now subdocuments of series
This commit is contained in:
parent
0861e5f8c1
commit
33986a9185
40 changed files with 256 additions and 633 deletions
|
@ -2,8 +2,7 @@
|
|||
<div class="row">
|
||||
<div class="span2">
|
||||
<a href="{{traktUrl}}" target="_blank">
|
||||
<img class="new-series-poster" src="{{remotePoster}}"
|
||||
{{defaultImg}} >
|
||||
<img class="new-series-poster" src="{{remotePoster}}" {{defaultImg}} >
|
||||
</a>
|
||||
</div>
|
||||
<div class="span9">
|
||||
|
|
|
@ -113,4 +113,12 @@
|
|||
|
||||
.icon-nd-status:before {
|
||||
.icon(@circle);
|
||||
}
|
||||
|
||||
.icon-nd-monitored:before {
|
||||
.icon(@bookmark);
|
||||
}
|
||||
|
||||
.icon-nd-unmonitored:before {
|
||||
.icon(@bookmark-empty);
|
||||
}
|
|
@ -24,16 +24,10 @@ define(
|
|||
this.series.show(new LoadingView());
|
||||
|
||||
this.seriesCollection = SeriesCollection;
|
||||
this.seasonCollection = new SeasonCollection();
|
||||
|
||||
var promise = this.seasonCollection.fetch();
|
||||
|
||||
promise.done(function () {
|
||||
self.series.show(new SeriesCollectionView({
|
||||
collection: self.seriesCollection,
|
||||
seasonCollection: self.seasonCollection
|
||||
}));
|
||||
});
|
||||
self.series.show(new SeriesCollectionView({
|
||||
collection: self.seriesCollection
|
||||
}));
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
@ -5,22 +5,6 @@ define(
|
|||
'SeasonPass/SeriesLayout'
|
||||
], function (Marionette, SeriesLayout) {
|
||||
return Marionette.CollectionView.extend({
|
||||
|
||||
itemView: SeriesLayout,
|
||||
|
||||
initialize: function (options) {
|
||||
|
||||
if (!options.seasonCollection) {
|
||||
throw 'seasonCollection is needed';
|
||||
}
|
||||
|
||||
this.seasonCollection = options.seasonCollection;
|
||||
},
|
||||
|
||||
itemViewOptions: function () {
|
||||
return {
|
||||
seasonCollection: this.seasonCollection
|
||||
};
|
||||
}
|
||||
itemView: SeriesLayout
|
||||
});
|
||||
});
|
||||
|
|
|
@ -2,11 +2,9 @@
|
|||
define(
|
||||
[
|
||||
'marionette',
|
||||
'backgrid',
|
||||
'Series/SeasonCollection',
|
||||
'Cells/ToggleCell',
|
||||
'Shared/Actioneer'
|
||||
], function (Marionette, Backgrid, SeasonCollection, ToggleCell, Actioneer) {
|
||||
], function (Marionette, SeasonCollection, Actioneer) {
|
||||
return Marionette.Layout.extend({
|
||||
template: 'SeasonPass/SeriesLayoutTemplate',
|
||||
|
||||
|
@ -19,48 +17,22 @@ define(
|
|||
events: {
|
||||
'change .x-season-select': '_seasonSelected',
|
||||
'click .x-expander' : '_expand',
|
||||
'click .x-latest' : '_latest'
|
||||
'click .x-latest' : '_latest',
|
||||
'click .x-monitored' : '_toggleSeasonMonitored'
|
||||
},
|
||||
|
||||
regions: {
|
||||
seasonGrid: '.x-season-grid'
|
||||
},
|
||||
|
||||
columns:
|
||||
[
|
||||
{
|
||||
name : 'monitored',
|
||||
label : '',
|
||||
cell : ToggleCell,
|
||||
trueClass : 'icon-bookmark',
|
||||
falseClass: 'icon-bookmark-empty',
|
||||
tooltip : 'Toggle monitored status',
|
||||
sortable : false
|
||||
},
|
||||
{
|
||||
name : 'seasonNumber',
|
||||
label: 'Season',
|
||||
cell : Backgrid.IntegerCell.extend({
|
||||
className: 'season-number-cell'
|
||||
})
|
||||
}
|
||||
],
|
||||
|
||||
initialize: function (options) {
|
||||
this.seasonCollection = options.seasonCollection.bySeries(this.model.get('id'));
|
||||
this.model.set('seasons', this.seasonCollection);
|
||||
initialize: function () {
|
||||
this.seasonCollection = new SeasonCollection(this.model.get('seasons'));
|
||||
this.expanded = false;
|
||||
},
|
||||
|
||||
onRender: function () {
|
||||
this.seasonGrid.show(new Backgrid.Grid({
|
||||
columns : this.columns,
|
||||
collection: this.seasonCollection,
|
||||
className : 'table table-condensed season-grid span5'
|
||||
}));
|
||||
|
||||
if (!this.expanded) {
|
||||
this.seasonGrid.$el.hide();
|
||||
this.ui.seasonGrid.hide();
|
||||
}
|
||||
|
||||
this._setExpanderIcon();
|
||||
|
@ -103,33 +75,51 @@ define(
|
|||
},
|
||||
|
||||
_latest: function () {
|
||||
var season = _.max(this.seasonCollection.models, function (model) {
|
||||
return model.get('seasonNumber');
|
||||
var season = _.max(this.model.get('seasons'), function (s) {
|
||||
return s.seasonNumber;
|
||||
});
|
||||
|
||||
//var seasonNumber = season.get('seasonNumber');
|
||||
|
||||
this._setMonitored(season.get('seasonNumber'))
|
||||
this._setMonitored(season.seasonNumber);
|
||||
},
|
||||
|
||||
_setMonitored: function (seasonNumber) {
|
||||
//TODO: use Actioneer?
|
||||
|
||||
var self = this;
|
||||
|
||||
var promise = $.ajax({
|
||||
url: this.seasonCollection.url + '/pass',
|
||||
type: 'POST',
|
||||
data: {
|
||||
seriesId: this.model.get('id'),
|
||||
seasonNumber: seasonNumber
|
||||
}
|
||||
});
|
||||
this.model.setSeasonPass(seasonNumber);
|
||||
|
||||
var promise = this.model.save();
|
||||
|
||||
promise.done(function (data) {
|
||||
self.seasonCollection = new SeasonCollection(data);
|
||||
self.render();
|
||||
});
|
||||
},
|
||||
|
||||
_toggleSeasonMonitored: function (e) {
|
||||
var seasonNumber = 0;
|
||||
var element;
|
||||
|
||||
if (e.target.localName === 'i') {
|
||||
seasonNumber = parseInt($(e.target).parent('td').attr('data-season-number'));
|
||||
element = $(e.target);
|
||||
}
|
||||
|
||||
else {
|
||||
seasonNumber = parseInt($(e.target).attr('data-season-number'));
|
||||
element = $(e.target).children('i');
|
||||
}
|
||||
|
||||
this.model.setSeasonMonitored(seasonNumber);
|
||||
|
||||
Actioneer.SaveModel({
|
||||
element: element,
|
||||
context: this,
|
||||
always : this._afterToggleSeasonMonitored
|
||||
});
|
||||
},
|
||||
|
||||
_afterToggleSeasonMonitored: function () {
|
||||
this.render();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
@ -12,12 +12,12 @@
|
|||
<span class="span3">
|
||||
<select class="x-season-select season-select">
|
||||
<option value="-1">Select season...</option>
|
||||
{{#each seasons.models}}
|
||||
{{#if_eq attributes.seasonNumber compare="0"}}
|
||||
<option value="{{attributes.seasonNumber}}">Specials</option>
|
||||
{{else}}
|
||||
<option value="{{attributes.seasonNumber}}">Season {{attributes.seasonNumber}}</option>
|
||||
{{/if_eq}}
|
||||
{{#each seasons}}
|
||||
{{#if_eq seasonNumber compare="0"}}
|
||||
<option value="{{seasonNumber}}">Specials</option>
|
||||
{{else}}
|
||||
<option value="{{seasonNumber}}">Season {{seasonNumber}}</option>
|
||||
{{/if_eq}}
|
||||
{{/each}}
|
||||
</select>
|
||||
|
||||
|
@ -36,7 +36,36 @@
|
|||
|
||||
<div class="row">
|
||||
<div class="span11">
|
||||
<div class="x-season-grid season-grid"></div>
|
||||
<div class="x-season-grid season-grid">
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th></th>
|
||||
<th class="sortable">Season</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{{#each seasons}}
|
||||
<tr>
|
||||
<td class="toggle-cell x-monitored" data-season-number="{{seasonNumber}}">
|
||||
{{#if monitored}}
|
||||
<i class="icon-nd-monitored"></i>
|
||||
{{else}}
|
||||
<i class="icon-nd-unmonitored"></i>
|
||||
{{/if}}
|
||||
</td>
|
||||
<td>
|
||||
{{#if_eq seasonNumber compare="0"}}
|
||||
Specials
|
||||
{{else}}
|
||||
Season {{seasonNumber}}
|
||||
{{/if_eq}}
|
||||
</td>
|
||||
</tr>
|
||||
{{/each}}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -117,8 +117,10 @@ define(
|
|||
_seasonMonitored: function () {
|
||||
var name = 'monitored';
|
||||
this.model.set(name, !this.model.get(name));
|
||||
this.series.setSeasonMonitored(this.model.get('seasonNumber'));
|
||||
|
||||
Actioneer.SaveModel({
|
||||
model : this.series,
|
||||
context: this,
|
||||
element: this.ui.seasonMonitored,
|
||||
always : this._afterSeasonMonitored
|
||||
|
|
|
@ -113,12 +113,12 @@ define(
|
|||
this.ui.monitored.removeClass('icon-spin icon-spinner');
|
||||
|
||||
if (this.model.get('monitored')) {
|
||||
this.ui.monitored.addClass('icon-bookmark');
|
||||
this.ui.monitored.removeClass('icon-bookmark-empty');
|
||||
this.ui.monitored.addClass('icon-nd-monitored');
|
||||
this.ui.monitored.removeClass('icon-nd-unmonitored');
|
||||
}
|
||||
else {
|
||||
this.ui.monitored.addClass('icon-bookmark-empty');
|
||||
this.ui.monitored.removeClass('icon-bookmark');
|
||||
this.ui.monitored.addClass('icon-nd-unmonitored');
|
||||
this.ui.monitored.removeClass('icon-nd-monitored');
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -176,11 +176,11 @@ define(
|
|||
|
||||
this.seasons.show(new LoadingView());
|
||||
|
||||
this.seasonCollection = new SeasonCollection();
|
||||
this.seasonCollection = new SeasonCollection(this.model.get('seasons'));
|
||||
this.episodeCollection = new EpisodeCollection({ seriesId: this.model.id });
|
||||
this.episodeFileCollection = new EpisodeFileCollection({ seriesId: this.model.id });
|
||||
|
||||
$.when(this.episodeCollection.fetch(), this.episodeFileCollection.fetch(), this.seasonCollection.fetch({data: { seriesId: this.model.id }})).done(function () {
|
||||
$.when(this.episodeCollection.fetch(), this.episodeFileCollection.fetch()).done(function () {
|
||||
var seasonCollectionView = new SeasonCollectionView({
|
||||
collection : self.seasonCollection,
|
||||
episodeCollection: self.episodeCollection,
|
||||
|
|
|
@ -5,21 +5,10 @@ define(
|
|||
'Series/SeasonModel'
|
||||
], function (Backbone, SeasonModel) {
|
||||
return Backbone.Collection.extend({
|
||||
url : window.ApiRoot + '/season',
|
||||
model: SeasonModel,
|
||||
|
||||
comparator: function (season) {
|
||||
return -season.get('seasonNumber');
|
||||
},
|
||||
|
||||
bySeries: function (series) {
|
||||
var filtered = this.filter(function (season) {
|
||||
return season.get('seriesId') === series;
|
||||
});
|
||||
|
||||
var SeasonCollection = require('Series/SeasonCollection');
|
||||
|
||||
return new SeasonCollection(filtered);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
@ -14,6 +14,25 @@ define(
|
|||
episodeCount : 0,
|
||||
isExisting : false,
|
||||
status : 0
|
||||
},
|
||||
|
||||
setSeasonMonitored: function (seasonNumber) {
|
||||
_.each(this.get('seasons'), function (season) {
|
||||
if (season.seasonNumber === seasonNumber) {
|
||||
season.monitored = !season.monitored;
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
setSeasonPass: function (seasonNumber) {
|
||||
_.each(this.get('seasons'), function (season) {
|
||||
if (season.seasonNumber >= seasonNumber) {
|
||||
season.monitored = true;
|
||||
}
|
||||
else {
|
||||
season.monitored = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
@ -256,6 +256,7 @@
|
|||
.clickable;
|
||||
line-height: 30px;
|
||||
margin-left: 8px;
|
||||
width: 16px;
|
||||
}
|
||||
|
||||
.season-grid {
|
||||
|
|
|
@ -33,7 +33,9 @@ define(
|
|||
this._showStartMessage(options);
|
||||
this._setSpinnerOnElement(options);
|
||||
|
||||
var promise = options.context.model.save();
|
||||
var model = options.model ? options.model : options.context.model;
|
||||
|
||||
var promise = model.save();
|
||||
this._handlePromise(promise, options);
|
||||
},
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue