2013-06-22 09:24:24 +03:00
|
|
|
'use strict';
|
2013-06-25 02:41:59 +03:00
|
|
|
define(
|
|
|
|
[
|
|
|
|
'marionette',
|
|
|
|
'backgrid',
|
|
|
|
'History/Collection',
|
|
|
|
'History/EventTypeCell',
|
|
|
|
'Cells/SeriesTitleCell',
|
|
|
|
'Cells/EpisodeNumberCell',
|
|
|
|
'Cells/EpisodeTitleCell',
|
|
|
|
'Cells/QualityCell',
|
|
|
|
'Cells/RelativeDateCell',
|
|
|
|
'Shared/Grid/Pager',
|
|
|
|
'Shared/LoadingView'
|
|
|
|
], function (Marionette, Backgrid, HistoryCollection, EventTypeCell, SeriesTitleCell, EpisodeNumberCell, EpisodeTitleCell, QualityCell, RelativeDateCell, GridPager, LoadingView) {
|
|
|
|
return Marionette.Layout.extend({
|
2013-05-03 09:53:32 +03:00
|
|
|
template: 'History/HistoryLayoutTemplate',
|
|
|
|
|
|
|
|
regions: {
|
|
|
|
history: '#x-history',
|
|
|
|
toolbar: '#x-toolbar',
|
|
|
|
pager : '#x-pager'
|
|
|
|
},
|
|
|
|
|
2013-06-25 02:41:59 +03:00
|
|
|
columns:
|
|
|
|
[
|
|
|
|
{
|
|
|
|
name : 'eventType',
|
|
|
|
label: '',
|
|
|
|
cell : EventTypeCell
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name : 'series',
|
|
|
|
label: 'Series',
|
|
|
|
cell : SeriesTitleCell
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name : 'episode',
|
|
|
|
label : 'Episode',
|
|
|
|
sortable: false,
|
|
|
|
cell : EpisodeNumberCell
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name : 'episode',
|
|
|
|
label : 'Episode Title',
|
|
|
|
sortable: false,
|
|
|
|
cell : EpisodeTitleCell
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name : 'quality',
|
|
|
|
label: 'Quality',
|
|
|
|
cell : QualityCell
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name : 'date',
|
|
|
|
label: 'Date',
|
|
|
|
cell : RelativeDateCell
|
|
|
|
}
|
|
|
|
],
|
2013-05-03 09:53:32 +03:00
|
|
|
|
2013-06-25 02:41:59 +03:00
|
|
|
_showTable: function (collection) {
|
2013-05-03 09:53:32 +03:00
|
|
|
|
2013-06-25 02:41:59 +03:00
|
|
|
this.history.show(new Backgrid.Grid({
|
|
|
|
columns : this.columns,
|
|
|
|
collection: collection,
|
|
|
|
className : 'table table-hover'
|
|
|
|
}));
|
2013-05-03 09:53:32 +03:00
|
|
|
|
2013-06-25 02:41:59 +03:00
|
|
|
this.pager.show(new GridPager({
|
2013-06-09 23:51:32 +03:00
|
|
|
columns : this.columns,
|
2013-06-25 02:41:59 +03:00
|
|
|
collection: collection
|
2013-05-03 09:53:32 +03:00
|
|
|
}));
|
|
|
|
},
|
|
|
|
|
2013-06-08 10:57:43 +03:00
|
|
|
onShow: function () {
|
|
|
|
var self = this;
|
|
|
|
|
2013-06-24 05:31:02 +03:00
|
|
|
this.history.show(new LoadingView());
|
2013-06-08 10:57:43 +03:00
|
|
|
|
2013-06-25 02:41:59 +03:00
|
|
|
var collection = new HistoryCollection();
|
|
|
|
collection.fetch().done(function () {
|
|
|
|
self._showTable(collection);
|
|
|
|
});
|
2013-05-03 09:53:32 +03:00
|
|
|
}
|
|
|
|
|
2013-06-25 02:41:59 +03:00
|
|
|
});
|
|
|
|
});
|