You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Prowlarr/UI/Series/Details/SeasonLayout.js

112 lines
3.4 KiB

'use strict';
define([
'app',
'Cells/EpisodeStatusCell',
'Cells/EpisodeTitleCell',
'Cells/AirDateCell',
'Cells/ToggleCell',
'Shared/Messenger'],
function (App, EpisodeStatusCell, EpisodeTitleCell, AirDateCell, ToggleCell, Messenger) {
12 years ago
return Backbone.Marionette.Layout.extend({
template: 'Series/Details/SeasonLayoutTemplate',
ui: {
seasonSearch: '.x-season-search'
},
events: {
'click .x-season-search': '_seasonSearch'
},
regions: {
episodeGrid: '#x-episode-grid'
},
columns: [
{
name : 'ignored',
label : '',
12 years ago
cell : ToggleCell,
trueClass : 'icon-bookmark-empty',
falseClass: 'icon-bookmark'
},
{
name : 'episodeNumber',
label: '#',
cell : Backgrid.IntegerCell.extend({
className: 'episode-number-cell'
})
},
{
name : 'this',
label: 'Title',
12 years ago
cell : EpisodeTitleCell
},
{
name : 'airDate',
label: 'Air Date',
12 years ago
cell : AirDateCell
} ,
{
name : 'status',
label: 'Status',
12 years ago
cell : EpisodeStatusCell
}
],
initialize: function (options) {
if (!options.episodeCollection) {
throw 'episodeCollection is needed';
}
this.episodeCollection = options.episodeCollection.bySeason(this.model.get('seasonNumber'));
},
onShow: function () {
this.episodeGrid.show(new Backgrid.Grid(
{
columns : this.columns,
collection: this.episodeCollection,
className : 'table table-hover season-grid'
}));
},
_seasonSearch: function () {
var command = 'seasonSearch';
this.idle = false;
this.ui.seasonSearch.addClass('icon-spinner icon-spin');
var properties = {
seriesId: this.model.get('seriesId'),
seasonNumber: this.model.get('seasonNumber')
};
var self = this;
var commandPromise = App.Commands.Execute(command, properties);
commandPromise.fail(function (options) {
if (options.readyState === 0 || options.status === 0) {
return;
}
Messenger.show({
message: 'Season search failed',
type : 'error'
});
});
commandPromise.always(function () {
if (!self.isClosed) {
self.ui.seasonSearch.removeClass('icon-spinner icon-spin');
self.idle = true;
}
});
}
});
});