@ -10,142 +10,163 @@ var moment = require('moment');
require ( '../Mixins/backbone.signalr.mixin' ) ;
require ( '../Mixins/backbone.signalr.mixin' ) ;
var Collection = PageableCollection . extend ( {
var Collection = PageableCollection . extend ( {
url : window . NzbDrone . ApiRoot + '/movie' ,
url : window . NzbDrone . ApiRoot + '/movie' ,
model : MovieModel ,
model : MovieModel ,
tableName : 'movie' ,
tableName : 'movie' ,
state : {
state : {
sortKey : 'sortTitle' ,
sortKey : 'sortTitle' ,
order : 1 ,
order : 1 ,
pageSize : 100000 ,
pageSize : 100000 ,
secondarySortKey : 'sortTitle' ,
secondarySortKey : 'sortTitle' ,
secondarySortOrder : - 1
secondarySortOrder : - 1
} ,
} ,
mode : 'client' ,
mode : 'client' ,
save : function ( ) {
save : function ( ) {
var self = this ;
var self = this ;
var proxy = _ . extend ( new Backbone . Model ( ) , {
var proxy = _ . extend ( new Backbone . Model ( ) , {
id : '' ,
id : '' ,
url : self . url + '/editor' ,
url : self . url + '/editor' ,
toJSON : function ( ) {
toJSON : function ( ) {
return self . filter ( function ( model ) {
return self . filter ( function ( model ) {
return model . edited ;
return model . edited ;
} ) ;
} ) ;
}
}
} ) ;
} ) ;
this . listenTo ( proxy , 'sync' , function ( proxyModel , models ) {
this . listenTo ( proxy , 'sync' , function ( proxyModel , models ) {
this . add ( models , { merge : true } ) ;
this . add ( models , { merge : true } ) ;
this . trigger ( 'save' , this ) ;
this . trigger ( 'save' , this ) ;
} ) ;
} ) ;
return proxy . save ( ) ;
return proxy . save ( ) ;
} ,
} ,
filterModes : {
importFromList : function ( models ) {
'all' : [
var self = this ;
null ,
null
var proxy = _ . extend ( new Backbone . Model ( ) , {
] ,
id : "" ,
'continuing' : [
'status' ,
url : self . url + "/import" ,
'continuing'
] ,
toJSON : function ( ) {
'ended' : [
return models ;
'status' ,
}
'ended'
} ) ;
] ,
'monitored' : [
this . listenTo ( proxy , "sync" , function ( proxyModel , models ) {
'monitored' ,
this . add ( models , { merge : true } ) ;
true
this . trigger ( "save" , this ) ;
] ,
} ) ;
'missing' : [
'downloaded' ,
return proxy . save ( ) ;
false
} ,
]
} ,
filterModes : {
'all' : [
sortMappings : {
null ,
title : {
null
sortKey : 'sortTitle'
] ,
} ,
'continuing' : [
statusWeight : {
'status' ,
sortValue : function ( model , attr ) {
'continuing'
if ( model . getStatus ( ) == "released" ) {
] ,
return 1 ;
'ended' : [
}
'status' ,
if ( model . getStatus ( ) == "inCinemas" ) {
'ended'
return 0 ;
] ,
}
'monitored' : [
return - 1 ;
'monitored' ,
}
true
} ,
] ,
downloadedQuality : {
'missing' : [
sortValue : function ( model , attr ) {
'downloaded' ,
if ( model . get ( "movieFile" ) ) {
false
return 1000 - model . get ( "movieFile" ) . quality . quality . id ;
]
}
} ,
return - 1 ;
sortMappings : {
}
title : {
} ,
sortKey : 'sortTitle'
nextAiring : {
} ,
sortValue : function ( model , attr , order ) {
statusWeight : {
var nextAiring = model . get ( attr ) ;
sortValue : function ( model , attr ) {
if ( model . getStatus ( ) == "released" ) {
if ( nextAiring ) {
return 1 ;
return moment ( nextAiring ) . unix ( ) ;
}
}
if ( model . getStatus ( ) == "inCinemas" ) {
return 0 ;
if ( order === 1 ) {
}
return 0 ;
return - 1 ;
}
}
} ,
return Number . MAX _VALUE ;
downloadedQuality : {
}
sortValue : function ( model , attr ) {
} ,
if ( model . get ( "movieFile" ) ) {
status : {
return 1000 - model . get ( "movieFile" ) . quality . quality . id ;
sortValue : function ( model , attr ) {
}
debugger ;
if ( model . get ( "downloaded" ) ) {
return - 1 ;
return - 1 ;
}
}
} ,
return 0 ;
nextAiring : {
}
sortValue : function ( model , attr , order ) {
} ,
var nextAiring = model . get ( attr ) ;
percentOfEpisodes : {
sortValue : function ( model , attr ) {
if ( nextAiring ) {
var percentOfEpisodes = model . get ( attr ) ;
return moment ( nextAiring ) . unix ( ) ;
var episodeCount = model . get ( 'episodeCount' ) ;
}
return percentOfEpisodes + episodeCount / 1000000 ;
if ( order === 1 ) {
}
return 0 ;
} ,
}
inCinemas : {
return Number . MAX _VALUE ;
sortValue : function ( model , attr ) {
}
var monthNames = [ "January" , "February" , "March" , "April" , "May" , "June" ,
} ,
"July" , "August" , "September" , "October" , "November" , "December"
status : {
] ;
sortValue : function ( model , attr ) {
if ( model . get ( "inCinemas" ) ) {
debugger ;
return model . get ( "inCinemas" ) ;
if ( model . get ( "downloaded" ) ) {
}
return - 1 ;
return "2100-01-01" ;
}
}
return 0 ;
} ,
}
path : {
} ,
sortValue : function ( model ) {
percentOfEpisodes : {
var path = model . get ( 'path' ) ;
sortValue : function ( model , attr ) {
var percentOfEpisodes = model . get ( attr ) ;
return path . toLowerCase ( ) ;
var episodeCount = model . get ( 'episodeCount' ) ;
}
}
return percentOfEpisodes + episodeCount / 1000000 ;
}
}
} ,
inCinemas : {
sortValue : function ( model , attr ) {
var monthNames = [ "January" , "February" , "March" , "April" , "May" , "June" ,
"July" , "August" , "September" , "October" , "November" , "December"
] ;
if ( model . get ( "inCinemas" ) ) {
return model . get ( "inCinemas" ) ;
}
return "2100-01-01" ;
}
} ,
path : {
sortValue : function ( model ) {
var path = model . get ( 'path' ) ;
return path . toLowerCase ( ) ;
}
}
}
} ) ;
} ) ;
Collection = AsFilteredCollection . call ( Collection ) ;
Collection = AsFilteredCollection . call ( Collection ) ;