mirror of
https://github.com/Prowlarr/Prowlarr.git
synced 2025-09-28 13:01:28 +02:00
UI Cleanup - Updated Series subtree.
This commit is contained in:
@@ -8,68 +8,98 @@ var AsSortedCollection = require('../Mixins/AsSortedCollection');
|
||||
var AsPersistedStateCollection = require('../Mixins/AsPersistedStateCollection');
|
||||
var moment = require('moment');
|
||||
|
||||
module.exports = (function(){
|
||||
var Collection = PageableCollection.extend({
|
||||
url : window.NzbDrone.ApiRoot + '/series',
|
||||
model : SeriesModel,
|
||||
tableName : 'series',
|
||||
state : {
|
||||
sortKey : 'sortTitle',
|
||||
order : -1,
|
||||
pageSize : 100000,
|
||||
secondarySortKey : 'sortTitle',
|
||||
secondarySortOrder : -1
|
||||
var Collection = PageableCollection.extend({
|
||||
url : window.NzbDrone.ApiRoot + '/series',
|
||||
model : SeriesModel,
|
||||
tableName : 'series',
|
||||
|
||||
state : {
|
||||
sortKey : 'sortTitle',
|
||||
order : -1,
|
||||
pageSize : 100000,
|
||||
secondarySortKey : 'sortTitle',
|
||||
secondarySortOrder : -1
|
||||
},
|
||||
|
||||
mode : 'client',
|
||||
|
||||
save : function() {
|
||||
var self = this;
|
||||
|
||||
var proxy = _.extend(new Backbone.Model(), {
|
||||
id : '',
|
||||
|
||||
url : self.url + '/editor',
|
||||
|
||||
toJSON : function() {
|
||||
return self.filter(function(model) {
|
||||
return model.edited;
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
this.listenTo(proxy, 'sync', function(proxyModel, models) {
|
||||
this.add(models, { merge : true });
|
||||
this.trigger('save', this);
|
||||
});
|
||||
|
||||
return proxy.save();
|
||||
},
|
||||
|
||||
filterModes : {
|
||||
'all' : [
|
||||
null,
|
||||
null
|
||||
],
|
||||
'continuing' : [
|
||||
'status',
|
||||
'continuing'
|
||||
],
|
||||
'ended' : [
|
||||
'status',
|
||||
'ended'
|
||||
],
|
||||
'monitored' : [
|
||||
'monitored',
|
||||
true
|
||||
]
|
||||
},
|
||||
|
||||
sortMappings : {
|
||||
'title' : {
|
||||
sortKey : 'sortTitle'
|
||||
},
|
||||
mode : 'client',
|
||||
save : function(){
|
||||
var self = this;
|
||||
var proxy = _.extend(new Backbone.Model(), {
|
||||
id : '',
|
||||
url : self.url + '/editor',
|
||||
toJSON : function(){
|
||||
return self.filter(function(model){
|
||||
return model.edited;
|
||||
});
|
||||
'nextAiring' : {
|
||||
sortValue : function(model, attr, order) {
|
||||
var nextAiring = model.get(attr);
|
||||
|
||||
if (nextAiring) {
|
||||
return moment(nextAiring).unix();
|
||||
}
|
||||
});
|
||||
this.listenTo(proxy, 'sync', function(proxyModel, models){
|
||||
this.add(models, {merge : true});
|
||||
this.trigger('save', this);
|
||||
});
|
||||
return proxy.save();
|
||||
|
||||
if (order === 1) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return Number.MAX_VALUE;
|
||||
}
|
||||
},
|
||||
filterModes : {
|
||||
"all" : [null, null],
|
||||
"continuing" : ['status', 'continuing'],
|
||||
"ended" : ['status', 'ended'],
|
||||
"monitored" : ['monitored', true]
|
||||
},
|
||||
sortMappings : {
|
||||
"title" : {sortKey : 'sortTitle'},
|
||||
"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;
|
||||
}
|
||||
},
|
||||
percentOfEpisodes : {
|
||||
sortValue : function(model, attr){
|
||||
var percentOfEpisodes = model.get(attr);
|
||||
var episodeCount = model.get('episodeCount');
|
||||
return percentOfEpisodes + episodeCount / 1000000;
|
||||
}
|
||||
|
||||
percentOfEpisodes : {
|
||||
sortValue : function(model, attr) {
|
||||
var percentOfEpisodes = model.get(attr);
|
||||
var episodeCount = model.get('episodeCount');
|
||||
|
||||
return percentOfEpisodes + episodeCount / 1000000;
|
||||
}
|
||||
}
|
||||
});
|
||||
Collection = AsFilteredCollection.call(Collection);
|
||||
Collection = AsSortedCollection.call(Collection);
|
||||
Collection = AsPersistedStateCollection.call(Collection);
|
||||
var data = ApiData.get('series');
|
||||
return new Collection(data, {full : true});
|
||||
}).call(this);
|
||||
}
|
||||
});
|
||||
|
||||
Collection = AsFilteredCollection.call(Collection);
|
||||
Collection = AsSortedCollection.call(Collection);
|
||||
Collection = AsPersistedStateCollection.call(Collection);
|
||||
|
||||
var data = ApiData.get('series');
|
||||
|
||||
module.exports = new Collection(data, { full : true });
|
Reference in New Issue
Block a user