@ -15,6 +15,7 @@ var MovieStatusCell = require('../../Cells/MovieStatusCell');
var MovieDownloadStatusCell = require ( '../../Cells/MovieDownloadStatusCell' ) ;
var DownloadedQualityCell = require ( '../../Cells/DownloadedQualityCell' ) ;
var FooterView = require ( './FooterView' ) ;
var GridPager = require ( '../../Shared/Grid/Pager' ) ;
var FooterModel = require ( './FooterModel' ) ;
var ToolbarLayout = require ( '../../Shared/Toolbar/ToolbarLayout' ) ;
require ( '../../Mixins/backbone.signalr.mixin' ) ;
@ -26,12 +27,14 @@ module.exports = Marionette.Layout.extend({
seriesRegion : '#x-series' ,
toolbar : '#x-toolbar' ,
toolbar2 : '#x-toolbar2' ,
footer : '#x-series-footer'
footer : '#x-series-footer' ,
pager : "#x-movie-pager" ,
pagerTop : "#x-movie-pager-top"
} ,
columns : [
{
name : 'status Weight ',
name : 'status ',
label : '' ,
cell : MovieStatusCell
} ,
@ -45,6 +48,7 @@ module.exports = Marionette.Layout.extend({
name : "downloadedQuality" ,
label : "Downloaded" ,
cell : DownloadedQualityCell ,
sortable : true
} ,
{
name : 'profileId' ,
@ -67,6 +71,7 @@ module.exports = Marionette.Layout.extend({
name : "this" ,
label : "Status" ,
cell : MovieDownloadStatusCell ,
sortable : false ,
sortValue : function ( m , k ) {
if ( m . get ( "downloaded" ) ) {
return - 1 ;
@ -115,31 +120,40 @@ module.exports = Marionette.Layout.extend({
initialize : function ( ) {
this . seriesCollection = MoviesCollection . clone ( ) ;
this . seriesCollection . shadowCollection. bindSignalR( ) ;
this . seriesCollection . bindSignalR( ) ;
this . listenTo ( this . seriesCollection . shadowCollection , 'sync' , function ( model , collection , options ) {
this . seriesCollection . fullCollection . resetFiltered ( ) ;
this . listenTo ( this . seriesCollection , 'sync' , function ( model , collection , options ) {
//this.seriesCollection.fullCollection.resetFiltered();
this . _renderView ( ) ;
} ) ;
this . listenTo ( this . seriesCollection . shadowCollection , 'add' , function ( model , collection , options ) {
this . seriesCollection . fullCollection . resetFiltered ( ) ;
this . _renderView ( ) ;
this . listenTo ( MoviesCollection , "sync" , function ( eventName ) {
this . seriesCollection = MoviesCollection . clone ( ) ;
//this._showTable();
this . _renderView ( ) ;
} ) ;
this . listenTo ( this . seriesCollection . shadowCollection , 'remove' , function ( model , collection , options ) {
this . seriesCollection . fullCollection . resetFiltered ( ) ;
this . _renderView ( ) ;
this . listenTo ( this . seriesCollection , 'add' , function ( model , collection , options ) {
//this.seriesCollection.fullCollection.resetFiltered();
//this._renderView();
} ) ;
this . listenTo ( this . seriesCollection , 'remove' , function ( model , collection , options ) {
//this.seriesCollection.fullCollection.resetFiltered();
//this._showTable();
} ) ;
this . sortingOptions = {
type : 'sorting' ,
storeState : false ,
viewCollection : this . seriesCollection ,
callback : this . _sort ,
items : [
{
title : 'Title' ,
name : ' sor tT itle'
name : ' title'
} ,
{
title : 'Downloaded' ,
@ -153,10 +167,10 @@ module.exports = Marionette.Layout.extend({
title : 'In Cinemas' ,
name : 'inCinemas'
} ,
{
/ * {
title : "Status" ,
name : "status" ,
}
} * /
]
} ;
@ -254,10 +268,13 @@ module.exports = Marionette.Layout.extend({
className : 'table table-hover'
} ) ;
this . _showPager ( ) ;
this . _renderView ( ) ;
} ,
_showList : function ( ) {
//this.current = "list";
this . currentView = new ListCollectionView ( {
collection : this . seriesCollection
} ) ;
@ -273,6 +290,10 @@ module.exports = Marionette.Layout.extend({
this . _renderView ( ) ;
} ,
_sort : function ( ) {
console . warn ( "Sorting" ) ;
} ,
_renderView : function ( ) {
if ( MoviesCollection . length === 0 ) {
this . seriesRegion . show ( new EmptyView ( ) ) ;
@ -280,8 +301,12 @@ module.exports = Marionette.Layout.extend({
this . toolbar . close ( ) ;
this . toolbar2 . close ( ) ;
} else {
this . seriesRegion . show ( this . currentView ) ;
this . seriesRegion . show ( this . currentView ) ;
this . listenTo ( this . currentView . collection , "sync" , function ( eventName ) {
this . _showPager ( ) ;
//debugger;
} ) ;
this . _showToolbar ( ) ;
this . _showFooter ( ) ;
}
@ -293,7 +318,6 @@ module.exports = Marionette.Layout.extend({
_setFilter : function ( buttonContext ) {
var mode = buttonContext . model . get ( 'key' ) ;
this . seriesCollection . setFilterMode ( mode ) ;
} ,
@ -321,6 +345,19 @@ module.exports = Marionette.Layout.extend({
} ) ) ;
} ,
_showPager : function ( ) {
var pager = new GridPager ( {
columns : this . columns ,
collection : this . seriesCollection ,
} ) ;
var pagerTop = new GridPager ( {
columns : this . columns ,
collection : this . seriesCollection ,
} ) ;
this . pager . show ( pager ) ;
this . pagerTop . show ( pagerTop ) ;
} ,
_showFooter : function ( ) {
var footerModel = new FooterModel ( ) ;
var movies = MoviesCollection . models . length ;
@ -330,12 +367,12 @@ module.exports = Marionette.Layout.extend({
var released = 0 ;
var monitored = 0 ;
var downloaded = 0 ;
var missingMonitored = 0 ;
var missingNotMonitored = 0 ;
var missingNotAvailable = 0 ;
var missingMonitoredAvailable = 0 ;
var missingMonitoredAvailable = 0 ;
var downloadedNotMonitored = 0 ;