mirror of
https://github.com/Sonarr/Sonarr.git
synced 2024-12-16 11:37:58 +02:00
Fixed sorting in episode file editor
This commit is contained in:
parent
42f9992af0
commit
a3d649452f
@ -2,6 +2,7 @@ var _ = require('underscore');
|
||||
var reqres = require('../../reqres');
|
||||
var Marionette = require('marionette');
|
||||
var Backgrid = require('backgrid');
|
||||
var FormatHelpers = require('../../Shared/FormatHelpers');
|
||||
var SelectAllCell = require('../../Cells/SelectAllCell');
|
||||
var EpisodeNumberCell = require('../../Series/Details/EpisodeNumberCell');
|
||||
var SeasonEpisodeNumberCell = require('../../Cells/EpisodeNumberCell');
|
||||
@ -63,15 +64,17 @@ module.exports = Marionette.Layout.extend({
|
||||
var episodeCell = {};
|
||||
|
||||
if (this.model) {
|
||||
episodeCell.name = 'episodeNumber';
|
||||
episodeCell.name = 'episodeNumber';s
|
||||
episodeCell.label = '#';
|
||||
episodeCell.cell = EpisodeNumberCell;
|
||||
}
|
||||
|
||||
else {
|
||||
episodeCell.name = 'this';
|
||||
episodeCell.name = 'seasonEpisode';
|
||||
episodeCell.cellValue = 'this';
|
||||
episodeCell.label = 'Episode';
|
||||
episodeCell.cell = SeasonEpisodeNumberCell;
|
||||
episodeCell.sortValue = this._seasonEpisodeSorter;
|
||||
}
|
||||
|
||||
this.columns = [
|
||||
@ -83,9 +86,10 @@ module.exports = Marionette.Layout.extend({
|
||||
},
|
||||
episodeCell,
|
||||
{
|
||||
name : 'episodeNumber',
|
||||
label : 'Relative Path',
|
||||
cell : EpisodeFilePathCell
|
||||
name : 'episodeNumber',
|
||||
label : 'Relative Path',
|
||||
cell : EpisodeFilePathCell,
|
||||
sortable : false
|
||||
},
|
||||
{
|
||||
name : 'airDateUtc',
|
||||
@ -99,11 +103,6 @@ module.exports = Marionette.Layout.extend({
|
||||
sortable : false
|
||||
}
|
||||
];
|
||||
|
||||
if (!this.model) {
|
||||
this.columns[1].name = 'this';
|
||||
this.columns[1].cell = SeasonEpisodeNumberCell;
|
||||
}
|
||||
},
|
||||
|
||||
_showEpisodes : function() {
|
||||
@ -112,6 +111,8 @@ module.exports = Marionette.Layout.extend({
|
||||
return;
|
||||
}
|
||||
|
||||
this._setInitialSort();
|
||||
|
||||
this.episodeGridView = new Backgrid.Grid({
|
||||
columns : this.columns,
|
||||
collection : this.filteredEpisodes,
|
||||
@ -121,6 +122,13 @@ module.exports = Marionette.Layout.extend({
|
||||
this.episodeGrid.show(this.episodeGridView);
|
||||
},
|
||||
|
||||
_setInitialSort : function () {
|
||||
if (!this.model) {
|
||||
this.filteredEpisodes.setSorting('seasonEpisode', 1, { sortValue: this._seasonEpisodeSorter });
|
||||
this.filteredEpisodes.fullCollection.sort();
|
||||
}
|
||||
},
|
||||
|
||||
_getQualities : function() {
|
||||
var self = this;
|
||||
|
||||
@ -181,5 +189,12 @@ module.exports = Marionette.Layout.extend({
|
||||
return _.uniq(_.map(this.episodeGridView.getSelectedModels(), function (episode) {
|
||||
return episode.get('episodeFileId');
|
||||
}));
|
||||
},
|
||||
|
||||
_seasonEpisodeSorter : function (model, attr) {
|
||||
var seasonNumber = FormatHelpers.pad(model.get('seasonNumber'), 4, 0);
|
||||
var episodeNumber = FormatHelpers.pad(model.get('episodeNumber'), 4, 0);
|
||||
|
||||
return seasonNumber + episodeNumber;
|
||||
}
|
||||
});
|
@ -1,16 +1,20 @@
|
||||
var Backbone = require('backbone');
|
||||
var PageableCollection = require('backbone.pageable');
|
||||
var EpisodeModel = require('./EpisodeModel');
|
||||
require('./EpisodeCollection');
|
||||
|
||||
module.exports = Backbone.Collection.extend({
|
||||
module.exports = PageableCollection.extend({
|
||||
url : window.NzbDrone.ApiRoot + '/episode',
|
||||
model : EpisodeModel,
|
||||
|
||||
state : {
|
||||
sortKey : 'episodeNumber',
|
||||
order : 1
|
||||
sortKey : 'episodeNumber',
|
||||
order : 1,
|
||||
pageSize : 100000
|
||||
},
|
||||
|
||||
mode : 'client',
|
||||
|
||||
originalFetch : Backbone.Collection.prototype.fetch,
|
||||
|
||||
initialize : function(options) {
|
||||
|
Loading…
Reference in New Issue
Block a user