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.
Lidarr/UI/Series/Index/SeriesIndexLayout.js

205 lines
6.6 KiB

'use strict';
12 years ago
define([
'app',
'Series/Index/List/CollectionView',
'Series/Index/Posters/CollectionView',
12 years ago
'Series/Index/EmptyView',
'Series/SeriesCollection',
'Cells/AirDateCell',
'Cells/SeriesTitleCell',
'Cells/TemplatedCell',
12 years ago
'Series/Index/Table/SeriesStatusCell',
'Shared/Toolbar/ToolbarLayout',
'Config',
'Shared/LoadingView'
12 years ago
],
function (
App,
ListCollectionView,
PosterCollectionView,
EmptyView,
SeriesCollection,
AirDateCell,
SeriesTitleCell,
TemplatedCell,
SeriesStatusCell,
ToolbarLayout,
Config,
LoadingView)
{
12 years ago
NzbDrone.Series.Index.SeriesIndexLayout = Backbone.Marionette.Layout.extend({
template: 'Series/Index/SeriesIndexLayoutTemplate',
regions: {
series : '#x-series',
toolbar: '#x-toolbar'
12 years ago
},
columns: [
{
name : 'status',
label: '',
cell : 'seriesStatus'
},
{
name : 'this',
label: 'Title',
cell : SeriesTitleCell
},
{
name : 'seasonCount',
label: 'Seasons',
cell : 'integer'
},
{
name : 'quality',
label: 'Quality',
cell : 'integer'
},
{
name : 'network',
label: 'Network',
cell : 'string'
},
{
name : 'nextAiring',
label: 'Next Airing',
cell : AirDateCell
},
{
name : 'this',
label : 'Episodes',
sortable: false,
template: 'Series/EpisodeProgressTemplate',
cell : TemplatedCell
},
{
name : 'this',
label : '',
sortable: false,
template: 'Series/Index/Table/ControlsColumnTemplate',
cell : TemplatedCell
}
],
12 years ago
leftSideButtons: {
type : 'default',
storeState: false,
items : [
{
title: 'Add Series',
icon : 'icon-plus',
route: 'series/add'
},
{
title : 'RSS Sync',
icon : 'icon-rss',
command : 'rsssync',
successMessage: 'RSS Sync Completed',
errorMessage : 'RSS Sync Failed!'
},
{
title : 'Update Library',
icon : 'icon-refresh',
command : 'refreshseries',
successMessage: 'Library was updated!',
errorMessage : 'Library update failed!'
}
]
},
_showTable: function () {
var view = new Backgrid.Grid(
{
row : NzbDrone.Series.Index.Table.Row,
columns : this.columns,
collection: this.seriesCollection,
className : 'table table-hover'
});
12 years ago
this._fetchCollection(view);
12 years ago
},
_showList: function () {
var view = new ListCollectionView();
this._fetchCollection(view);
12 years ago
},
_showPosters: function () {
var view = new PosterCollectionView();
this._fetchCollection(view);
},
_showEmpty: function () {
this.series.show(new EmptyView());
12 years ago
},
_fetchCollection: function (view) {
var self = this;
if (this.seriesCollection.models.length === 0) {
this.series.show(new LoadingView());
this.seriesCollection.fetch()
.done(function () {
if (self.seriesCollection.models.length === 0) {
self._showEmpty();
}
else {
view.collection = self.seriesCollection;
self.series.show(view);
}
});
}
else {
view.collection = this.seriesCollection;
this.series.show(view);
}
},
12 years ago
initialize: function () {
this.seriesCollection = new SeriesCollection();
12 years ago
},
onShow: function () {
//TODO: Move this outside of the function - 'this' is not available for the call back though (use string like events?)
var viewButtons = {
type : 'radio',
storeState : true,
menuKey : 'seriesViewMode',
defaultAction: 'listView',
items : [
{
key : 'tableView',
title : '',
icon : 'icon-table',
callback: this._showTable
},
{
key : 'listView',
title : '',
icon : 'icon-list',
callback: this._showList
},
{
key : 'posterView',
title : '',
icon : 'icon-picture',
callback: this._showPosters
}
]
};
this.toolbar.show(new ToolbarLayout({
right : [ viewButtons],
left : [ this.leftSideButtons],
context: this
}));
12 years ago
}
});
return NzbDrone.Series.Index.SeriesIndexLayou;
});