|
|
@ -12,15 +12,14 @@ define(
|
|
|
|
'Series/Index/Table/SeriesStatusCell',
|
|
|
|
'Series/Index/Table/SeriesStatusCell',
|
|
|
|
'Series/Index/Table/Row',
|
|
|
|
'Series/Index/Table/Row',
|
|
|
|
'Shared/Toolbar/ToolbarLayout',
|
|
|
|
'Shared/Toolbar/ToolbarLayout',
|
|
|
|
'Config',
|
|
|
|
|
|
|
|
'Shared/LoadingView'
|
|
|
|
'Shared/LoadingView'
|
|
|
|
], function (Marionette, PosterCollectionView, ListCollectionView, EmptyView, SeriesCollection, AirDateCell, SeriesTitleCell, TemplatedCell, SeriesStatusCell, SeriesIndexRow,
|
|
|
|
], function (Marionette, PosterCollectionView, ListCollectionView, EmptyView, SeriesCollection, AirDateCell, SeriesTitleCell, TemplatedCell, SeriesStatusCell, SeriesIndexRow,
|
|
|
|
ToolbarLayout, Config, LoadingView) {
|
|
|
|
ToolbarLayout, LoadingView) {
|
|
|
|
return Marionette.Layout.extend({
|
|
|
|
return Marionette.Layout.extend({
|
|
|
|
template: 'Series/Index/SeriesIndexLayoutTemplate',
|
|
|
|
template: 'Series/Index/SeriesIndexLayoutTemplate',
|
|
|
|
|
|
|
|
|
|
|
|
regions: {
|
|
|
|
regions: {
|
|
|
|
series : '#x-series',
|
|
|
|
seriesRegion: '#x-series',
|
|
|
|
toolbar : '#x-toolbar'
|
|
|
|
toolbar : '#x-toolbar'
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
@ -100,60 +99,71 @@ define(
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
_showTable: function () {
|
|
|
|
_showTable: function () {
|
|
|
|
var view = new Backgrid.Grid({
|
|
|
|
this.currentView = new Backgrid.Grid({
|
|
|
|
row : SeriesIndexRow,
|
|
|
|
row : SeriesIndexRow,
|
|
|
|
|
|
|
|
collection: SeriesCollection,
|
|
|
|
columns : this.columns,
|
|
|
|
columns : this.columns,
|
|
|
|
collection: this.seriesCollection,
|
|
|
|
|
|
|
|
className : 'table table-hover'
|
|
|
|
className : 'table table-hover'
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
this._fetchCollection(view);
|
|
|
|
this._renderView();
|
|
|
|
|
|
|
|
this._fetchCollection();
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
_showList: function () {
|
|
|
|
_showList: function () {
|
|
|
|
var view = new ListCollectionView();
|
|
|
|
this.currentView = new ListCollectionView();
|
|
|
|
this._fetchCollection(view);
|
|
|
|
this._fetchCollection();
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
_showPosters: function () {
|
|
|
|
_showPosters: function () {
|
|
|
|
var view = new PosterCollectionView();
|
|
|
|
this.currentView = new PosterCollectionView();
|
|
|
|
this._fetchCollection(view);
|
|
|
|
this._fetchCollection();
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
_showEmpty: function () {
|
|
|
|
|
|
|
|
this.series.show(new EmptyView());
|
|
|
|
initialize: function () {
|
|
|
|
|
|
|
|
this.seriesCollection = SeriesCollection;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.listenTo(SeriesCollection, 'sync', this._renderView);
|
|
|
|
|
|
|
|
this.listenTo(SeriesCollection, 'remove', this._renderView);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
_fetchCollection: function (view) {
|
|
|
|
|
|
|
|
var self = this;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (this.seriesCollection.models.length === 0) {
|
|
|
|
_renderView: function () {
|
|
|
|
this.series.show(new LoadingView());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.seriesCollection.fetch().done(function () {
|
|
|
|
if (SeriesCollection.length === 0) {
|
|
|
|
if (self.seriesCollection.models.length === 0) {
|
|
|
|
this.seriesRegion.show(new EmptyView());
|
|
|
|
self._showEmpty();
|
|
|
|
this.toolbar.close();
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
view.collection = self.seriesCollection;
|
|
|
|
|
|
|
|
self.series.show(view);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (this.currentView && !this.currentView.isClosed) {
|
|
|
|
|
|
|
|
this.currentView.collection = SeriesCollection;
|
|
|
|
|
|
|
|
this.seriesRegion.show(this.currentView);
|
|
|
|
|
|
|
|
|
|
|
|
else {
|
|
|
|
this._showToolbar();
|
|
|
|
view.collection = this.seriesCollection;
|
|
|
|
|
|
|
|
this.series.show(view);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
initialize: function () {
|
|
|
|
|
|
|
|
this.seriesCollection = new SeriesCollection();
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
onShow: function () {
|
|
|
|
onShow: function () {
|
|
|
|
|
|
|
|
this._fetchCollection();
|
|
|
|
|
|
|
|
this._showToolbar();
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_fetchCollection: function () {
|
|
|
|
|
|
|
|
if (SeriesCollection.length === 0) {
|
|
|
|
|
|
|
|
this.seriesRegion.show(new LoadingView());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SeriesCollection.fetch();
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_showToolbar: function () {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (this.toolbar.currentView) {
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//TODO: Move this outside of the function - 'this' is not available for the call back though (use string like events?)
|
|
|
|
|
|
|
|
var viewButtons = {
|
|
|
|
var viewButtons = {
|
|
|
|
type : 'radio',
|
|
|
|
type : 'radio',
|
|
|
|
storeState : true,
|
|
|
|
storeState : true,
|
|
|
|