mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-21 14:03:29 -07:00
Added season pass for toggling monitored status of seasons
Linked from missing
This commit is contained in:
parent
694714726c
commit
6ca17942f0
12 changed files with 316 additions and 22 deletions
39
UI/SeasonPass/Layout.js
Normal file
39
UI/SeasonPass/Layout.js
Normal file
|
@ -0,0 +1,39 @@
|
|||
'use strict';
|
||||
define(
|
||||
[
|
||||
'marionette',
|
||||
'Series/SeriesCollection',
|
||||
'Series/SeasonCollection',
|
||||
'SeasonPass/SeriesCollectionView',
|
||||
'Shared/LoadingView'
|
||||
], function (Marionette,
|
||||
SeriesCollection,
|
||||
SeasonCollection,
|
||||
SeriesCollectionView,
|
||||
LoadingView) {
|
||||
return Marionette.Layout.extend({
|
||||
template: 'SeasonPass/LayoutTemplate',
|
||||
|
||||
regions: {
|
||||
series: '#x-series'
|
||||
},
|
||||
|
||||
onShow: function () {
|
||||
var self = this;
|
||||
|
||||
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
|
||||
}));
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
11
UI/SeasonPass/LayoutTemplate.html
Normal file
11
UI/SeasonPass/LayoutTemplate.html
Normal file
|
@ -0,0 +1,11 @@
|
|||
<div class="row">
|
||||
<div class="span12">
|
||||
<div class="alert alert-info">Season Pass allows you to quickly change the monitored status of seasons for all your series in one place</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="span12">
|
||||
<div id="x-series"></div>
|
||||
</div>
|
||||
</div>
|
26
UI/SeasonPass/SeriesCollectionView.js
Normal file
26
UI/SeasonPass/SeriesCollectionView.js
Normal file
|
@ -0,0 +1,26 @@
|
|||
'use strict';
|
||||
define(
|
||||
[
|
||||
'marionette',
|
||||
'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
|
||||
};
|
||||
}
|
||||
});
|
||||
});
|
117
UI/SeasonPass/SeriesLayout.js
Normal file
117
UI/SeasonPass/SeriesLayout.js
Normal file
|
@ -0,0 +1,117 @@
|
|||
'use strict';
|
||||
define(
|
||||
[
|
||||
'marionette',
|
||||
'backgrid',
|
||||
'Series/SeasonCollection',
|
||||
'Cells/ToggleCell',
|
||||
'Shared/Actioneer'
|
||||
], function (Marionette, Backgrid, SeasonCollection, ToggleCell, Actioneer) {
|
||||
return Marionette.Layout.extend({
|
||||
template: 'SeasonPass/SeriesLayoutTemplate',
|
||||
|
||||
ui: {
|
||||
seasonSelect: '.x-season-select',
|
||||
expander : '.x-expander',
|
||||
seasonGrid : '.x-season-grid'
|
||||
},
|
||||
|
||||
events: {
|
||||
'change .x-season-select': '_seasonSelected',
|
||||
'click .x-expander' : '_expand'
|
||||
},
|
||||
|
||||
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);
|
||||
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._setExpanderIcon();
|
||||
},
|
||||
|
||||
_seasonSelected: function () {
|
||||
var self = this;
|
||||
var seasonNumber = parseInt(this.ui.seasonSelect.val());
|
||||
|
||||
if (seasonNumber == -1) {
|
||||
return;
|
||||
}
|
||||
|
||||
var promise = $.ajax({
|
||||
url: this.seasonCollection.url + '/pass',
|
||||
type: 'POST',
|
||||
data: {
|
||||
seriesId: this.model.get('id'),
|
||||
seasonNumber: seasonNumber
|
||||
}
|
||||
});
|
||||
|
||||
promise.done(function (data) {
|
||||
self.seasonCollection = new SeasonCollection(data);
|
||||
self.render();
|
||||
});
|
||||
},
|
||||
|
||||
_expand: function () {
|
||||
if (this.expanded) {
|
||||
this.ui.seasonGrid.slideUp();
|
||||
this.expanded = false;
|
||||
}
|
||||
|
||||
else {
|
||||
this.ui.seasonGrid.slideDown();
|
||||
this.expanded = true;
|
||||
}
|
||||
|
||||
this._setExpanderIcon();
|
||||
},
|
||||
|
||||
_setExpanderIcon: function () {
|
||||
if (this.expanded) {
|
||||
this.ui.expander.removeClass('icon-chevron-right');
|
||||
this.ui.expander.addClass('icon-chevron-down');
|
||||
}
|
||||
|
||||
else {
|
||||
this.ui.expander.removeClass('icon-chevron-down');
|
||||
this.ui.expander.addClass('icon-chevron-right');
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
32
UI/SeasonPass/SeriesLayoutTemplate.html
Normal file
32
UI/SeasonPass/SeriesLayoutTemplate.html
Normal file
|
@ -0,0 +1,32 @@
|
|||
<div class="seasonpass-series">
|
||||
<div class="row">
|
||||
<div class="span11">
|
||||
<i class="icon-chevron-right x-expander expander pull-left"/>
|
||||
|
||||
<span class="title span5">
|
||||
<a href="{{route}}">
|
||||
{{title}}
|
||||
</a>
|
||||
</span>
|
||||
<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.seasonumber}}">Specials</option>
|
||||
{{else}}
|
||||
<option value="{{attributes.seasonNumber}}">Season {{attributes.seasonNumber}}</option>
|
||||
{{/if_eq}}
|
||||
{{/each}}
|
||||
</select>
|
||||
<span class="help-inline">
|
||||
<i class="icon-question-sign" title="Selecting a season will unmonitor all previous seasons"/>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="span11">
|
||||
<div class="x-season-grid season-grid"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
Loading…
Add table
Add a link
Reference in a new issue