Merge pull request #531 from Radarr/patch/fix-filter-movie-list

Fix the filter modes on the movie list xD
Devin Buhl 8 years ago committed by GitHub
commit 09fb58c3e9

@ -10,9 +10,9 @@ 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',
@ -22,30 +22,30 @@ var Collection = PageableCollection.extend({
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 : { filterModes : {
'all' : [ 'all' : [
@ -85,126 +85,82 @@ var Collection = PageableCollection.extend({
] ]
}, },
importFromList : function(models) { sortMappings : {
var self = this; title : {
sortKey : 'sortTitle'
var proxy = _.extend(new Backbone.Model(), { },
id : "", statusWeight : {
sortValue : function(model, attr) {
url : self.url + "/import", if (model.getStatus() == "released") {
return 1;
toJSON : function() { }
return models; if (model.getStatus() == "inCinemas") {
} return 0;
}); }
return -1;
this.listenTo(proxy, "sync", function(proxyModel, models) { }
this.add(models, { merge : true}); },
this.trigger("save", this); downloadedQuality : {
}); sortValue : function(model, attr) {
if (model.get("movieFile")) {
return proxy.save(); return 1000-model.get("movieFile").quality.quality.id;
}, }
filterModes : { return -1;
'all' : [ }
null, },
null nextAiring : {
], sortValue : function(model, attr, order) {
'continuing' : [ var nextAiring = model.get(attr);
'status',
'continuing' if (nextAiring) {
], return moment(nextAiring).unix();
'ended' : [ }
'status',
'ended' if (order === 1) {
], return 0;
'monitored' : [ }
'monitored',
true return Number.MAX_VALUE;
], }
'missing' : [ },
'downloaded', status: {
false sortValue : function(model, attr) {
] debugger;
}, if (model.get("downloaded")) {
return -1;
sortMappings : { }
title : { return 0;
sortKey : 'sortTitle' }
}, },
statusWeight : { percentOfEpisodes : {
sortValue : function(model, attr) { sortValue : function(model, attr) {
if (model.getStatus() == "released") { var percentOfEpisodes = model.get(attr);
return 1; var episodeCount = model.get('episodeCount');
}
if (model.getStatus() == "inCinemas") { return percentOfEpisodes + episodeCount / 1000000;
return 0; }
} },
return -1; inCinemas : {
}
}, sortValue : function(model, attr) {
downloadedQuality : { var monthNames = ["January", "February", "March", "April", "May", "June",
sortValue : function(model, attr) { "July", "August", "September", "October", "November", "December"
if (model.get("movieFile")) { ];
return 1000-model.get("movieFile").quality.quality.id; if (model.get("inCinemas")) {
} return model.get("inCinemas");
}
return -1; return "2100-01-01";
} }
}, },
nextAiring : { path : {
sortValue : function(model, attr, order) { sortValue : function(model) {
var nextAiring = model.get(attr); var path = model.get('path');
if (nextAiring) { return path.toLowerCase();
return moment(nextAiring).unix(); }
} }
}
if (order === 1) {
return 0;
}
return Number.MAX_VALUE;
}
},
status: {
sortValue : function(model, attr) {
debugger;
if (model.get("downloaded")) {
return -1;
}
return 0;
}
},
percentOfEpisodes : {
sortValue : function(model, attr) {
var percentOfEpisodes = model.get(attr);
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);
@ -213,4 +169,4 @@ Collection = AsPersistedStateCollection.call(Collection);
var data = ApiData.get('movie'); var data = ApiData.get('movie');
module.exports = new Collection(data, { full : true }).bindSignalR(); module.exports = new Collection(data, { full : true }).bindSignalR();
Loading…
Cancel
Save