New: Sort queue by series, episode and episode title

pull/6/head
Mark McDowall 10 years ago
parent 9cf575c096
commit f13a4b5aa5

@ -1,7 +1,9 @@
var _ = require('underscore');
var Backbone = require('backbone');
var PageableCollection = require('backbone.pageable');
var QueueModel = require('./QueueModel');
var FormatHelpers = require('../../Shared/FormatHelpers');
var AsSortedCollection = require('../../Mixins/AsSortedCollection');
require('../../Mixins/backbone.signalr.mixin');
var QueueCollection = PageableCollection.extend({
@ -18,10 +20,39 @@ var QueueCollection = PageableCollection.extend({
return _.find(this.fullCollection.models, function(queueModel) {
return queueModel.get('episode').id === episodeId;
});
},
sortMappings : {
series : {
sortValue : function(model, attr) {
var series = model.get(attr);
return series.get('sortTitle');
}
},
episode : {
sortValue : function(model, attr) {
var episode = model.get('episode');
return FormatHelpers.pad(episode.get('seasonNumber'), 4) + FormatHelpers.pad(episode.get('episodeNumber'), 4);
}
},
episodeTitle : {
sortValue : function(model, attr) {
var episode = model.get('episode');
return episode.get('title');
}
}
}
});
QueueCollection = AsSortedCollection.call(QueueCollection);
var collection = new QueueCollection().bindSignalR();
collection.fetch();
module.exports = collection;

@ -30,20 +30,18 @@ module.exports = Marionette.Layout.extend({
{
name : 'series',
label : 'Series',
cell : SeriesTitleCell,
sortable : false
cell : SeriesTitleCell
},
{
name : 'episode',
label : 'Episode',
cell : EpisodeNumberCell,
sortable : false
cell : EpisodeNumberCell
},
{
name : 'episode',
label : 'Episode Title',
cell : EpisodeTitleCell,
sortable : false
name : 'episodeTitle',
label : 'Episode Title',
cell : EpisodeTitleCell,
cellValue : 'episode'
},
{
name : 'quality',

@ -33,6 +33,10 @@ module.exports = Backgrid.Cell.extend({
if (cellValue === 'this') {
return this.model;
}
else {
return this.model.get(cellValue);
}
}
var name = this.column.get('name');

Loading…
Cancel
Save