sonarr-repo-only/UI/Series/Details/SeasonLayout.js

113 lines
3.6 KiB
JavaScript
Raw Normal View History

2013-06-25 04:43:16 +00:00
'use strict';
define(
[
'marionette',
'backgrid',
'Cells/ToggleCell',
'Cells/EpisodeTitleCell',
'Cells/AirDateCell',
'Cells/EpisodeStatusCell',
'Commands/CommandController',
'Shared/Messenger'
], function ( Marionette, Backgrid, ToggleCell, EpisodeTitleCell, AirDateCell, EpisodeStatusCell, CommandController, Messenger) {
return Marionette.Layout.extend({
template: 'Series/Details/SeasonLayoutTemplate',
2013-04-23 02:07:21 +00:00
2013-06-24 04:37:55 +00:00
ui: {
seasonSearch: '.x-season-search'
},
events: {
'click .x-season-search': '_seasonSearch'
},
regions: {
episodeGrid: '#x-episode-grid'
},
2013-04-23 02:07:21 +00:00
columns:
[
{
name : 'ignored',
label : '',
cell : ToggleCell,
trueClass : 'icon-bookmark-empty',
falseClass: 'icon-bookmark'
},
{
name : 'episodeNumber',
label: '#',
cell : Backgrid.IntegerCell.extend({
className: 'episode-number-cell'
})
},
{
name : 'this',
label: 'Title',
cell : EpisodeTitleCell
},
{
name : 'airDate',
label: 'Air Date',
cell : AirDateCell
} ,
{
name : 'status',
label: 'Status',
cell : EpisodeStatusCell
}
],
2013-04-23 02:07:21 +00:00
initialize: function (options) {
if (!options.episodeCollection) {
throw 'episodeCollection is needed';
}
this.episodeCollection = options.episodeCollection.bySeason(this.model.get('seasonNumber'));
},
2013-04-23 02:07:21 +00:00
onShow: function () {
this.episodeGrid.show(new Backgrid.Grid({
columns : this.columns,
collection: this.episodeCollection,
className : 'table table-hover season-grid'
}));
2013-06-24 04:37:55 +00:00
},
_seasonSearch: function () {
var command = 'seasonSearch';
this.idle = false;
this.ui.seasonSearch.addClass('icon-spinner icon-spin');
var properties = {
seriesId : this.model.get('seriesId'),
2013-06-24 04:37:55 +00:00
seasonNumber: this.model.get('seasonNumber')
};
var self = this;
var commandPromise = CommandController.Execute(command, properties);
2013-06-24 04:37:55 +00:00
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;
}
});
}
});
2013-04-23 02:07:21 +00:00
});