mirror of https://github.com/Radarr/Radarr
Fixed default sorting for series grid
This commit is contained in:
parent
b4242f9fb2
commit
3983a36492
Binary file not shown.
|
@ -49,12 +49,6 @@ define([
|
||||||
editable : false,
|
editable : false,
|
||||||
cell : 'airDate',
|
cell : 'airDate',
|
||||||
headerCell: 'nzbDrone'
|
headerCell: 'nzbDrone'
|
||||||
// headerCell: Backgrid.NzbDroneHeaderCell.extend({
|
|
||||||
// initialize: function(options) {
|
|
||||||
// this.constructor.__super__.initialize.apply(this, [options]);
|
|
||||||
// this.direction('descending');
|
|
||||||
// }
|
|
||||||
// })
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name : 'edit',
|
name : 'edit',
|
||||||
|
|
|
@ -25,6 +25,25 @@ Backgrid.NzbDroneHeaderCell = Backgrid.HeaderCell.extend({
|
||||||
|
|
||||||
if (this.column.get('sortable')) {
|
if (this.column.get('sortable')) {
|
||||||
this.$el.append(" <i class='icon-sort pull-right'></i>");
|
this.$el.append(" <i class='icon-sort pull-right'></i>");
|
||||||
|
|
||||||
|
if (this.collection.state) {
|
||||||
|
var sortKey = this.collection.state.sortKey;
|
||||||
|
var sortDir = this._convertIntToDirection(this.collection.state.order);
|
||||||
|
|
||||||
|
if (sortKey === this.column.get('name')) {
|
||||||
|
this.$el.children('i').addClass(this._convertDirectionToIcon(sortDir));
|
||||||
|
this._direction = sortDir;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (this.collection.defaultSortKey) {
|
||||||
|
var sortKey = this.collection.defaultSortKey;
|
||||||
|
var sortDir = this._convertIntToDirection(this.collection.defaultSortDir);
|
||||||
|
|
||||||
|
if (sortKey === this.column.get('name')) {
|
||||||
|
this.$el.children('i').addClass(this._convertDirectionToIcon(sortDir));
|
||||||
|
this._direction = sortDir;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
this.delegateEvents();
|
this.delegateEvents();
|
||||||
return this;
|
return this;
|
||||||
|
@ -57,9 +76,6 @@ Backgrid.NzbDroneHeaderCell = Backgrid.HeaderCell.extend({
|
||||||
return 1;
|
return 1;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else if (this.direction() === "descending") {
|
|
||||||
this.sort(columnName, "ascending");
|
|
||||||
}
|
|
||||||
else {
|
else {
|
||||||
this.sort(columnName, "ascending", function (left, right) {
|
this.sort(columnName, "ascending", function (left, right) {
|
||||||
var leftVal = left.get(columnName);
|
var leftVal = left.get(columnName);
|
||||||
|
@ -80,6 +96,14 @@ Backgrid.NzbDroneHeaderCell = Backgrid.HeaderCell.extend({
|
||||||
}
|
}
|
||||||
|
|
||||||
return 'icon-sort-down';
|
return 'icon-sort-down';
|
||||||
|
},
|
||||||
|
|
||||||
|
_convertIntToDirection: function (dir) {
|
||||||
|
if (dir === '-1') {
|
||||||
|
return 'ascending';
|
||||||
|
}
|
||||||
|
|
||||||
|
return 'descending';
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,13 @@
|
||||||
define(['app', 'Series/SeriesModel'], function () {
|
define(['app', 'Series/SeriesModel'], function () {
|
||||||
NzbDrone.Series.SeriesCollection = Backbone.Collection.extend({
|
NzbDrone.Series.SeriesCollection = Backbone.Collection.extend({
|
||||||
url : NzbDrone.Constants.ApiRoot + '/series',
|
url : NzbDrone.Constants.ApiRoot + '/series',
|
||||||
model: NzbDrone.Series.SeriesModel
|
model: NzbDrone.Series.SeriesModel,
|
||||||
|
|
||||||
|
defaultSortKey: 'title',
|
||||||
|
defaultSortDir: '-1',
|
||||||
|
|
||||||
|
comparator: function (model) {
|
||||||
|
return model.get(this.defaultSortKey);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
Loading…
Reference in New Issue