1
0
Fork 0
mirror of https://github.com/Radarr/Radarr synced 2025-02-25 15:43:08 +00:00

Fix the filter modes on the movie list xD

This commit is contained in:
Devin Buhl 2017-01-30 17:00:52 -05:00
parent b51916fb2b
commit 3d33e630ec

View file

@ -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'
},
statusWeight : {
sortValue : function(model, attr) {
if (model.getStatus() == "released") {
return 1;
}
if (model.getStatus() == "inCinemas") {
return 0;
}
return -1;
}
},
downloadedQuality : {
sortValue : function(model, attr) {
if (model.get("movieFile")) {
return 1000-model.get("movieFile").quality.quality.id;
}
var proxy = _.extend(new Backbone.Model(), { return -1;
id : "", }
},
nextAiring : {
sortValue : function(model, attr, order) {
var nextAiring = model.get(attr);
url : self.url + "/import", if (nextAiring) {
return moment(nextAiring).unix();
}
toJSON : function() { if (order === 1) {
return models; return 0;
} }
});
this.listenTo(proxy, "sync", function(proxyModel, models) { return Number.MAX_VALUE;
this.add(models, { merge : true}); }
this.trigger("save", this); },
}); 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 proxy.save(); return percentOfEpisodes + episodeCount / 1000000;
}, }
},
inCinemas : {
filterModes : { sortValue : function(model, attr) {
'all' : [ var monthNames = ["January", "February", "March", "April", "May", "June",
null, "July", "August", "September", "October", "November", "December"
null ];
], if (model.get("inCinemas")) {
'continuing' : [ return model.get("inCinemas");
'status', }
'continuing' return "2100-01-01";
], }
'ended' : [ },
'status', path : {
'ended' sortValue : function(model) {
], var path = model.get('path');
'monitored' : [
'monitored',
true
],
'missing' : [
'downloaded',
false
]
},
sortMappings : { return path.toLowerCase();
title : { }
sortKey : 'sortTitle' }
}, }
statusWeight : {
sortValue : function(model, attr) {
if (model.getStatus() == "released") {
return 1;
}
if (model.getStatus() == "inCinemas") {
return 0;
}
return -1;
}
},
downloadedQuality : {
sortValue : function(model, attr) {
if (model.get("movieFile")) {
return 1000-model.get("movieFile").quality.quality.id;
}
return -1;
}
},
nextAiring : {
sortValue : function(model, attr, order) {
var nextAiring = model.get(attr);
if (nextAiring) {
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();