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