No need for custom header for series status

This commit is contained in:
Mark McDowall 2013-08-18 15:32:03 -07:00
parent 4a530a6c91
commit 73ee1f89fe
2 changed files with 2 additions and 61 deletions

View File

@ -47,10 +47,9 @@ define(
columns:
[
{
name : 'status',
name : 'statusWeight',
label : '',
cell : SeriesStatusCell,
headerCell: SeriesStatusHeaderCell
cell : SeriesStatusCell
},
{
name : 'title',

View File

@ -1,58 +0,0 @@
'use strict';
define(
[
'backgrid',
'Shared/Grid/HeaderCell'
], function (Backgrid, NzbDroneHeaderCell) {
Backgrid.SeriesStatusHeaderCell = NzbDroneHeaderCell.extend({
events: {
'click': 'onClick'
},
onClick: function (e) {
e.preventDefault();
var self = this;
var columnName = this.column.get('name');
if (this.column.get('sortable')) {
if (this.direction() === 'ascending') {
this.sort(columnName, 'descending', function (left, right) {
var leftVal = self._getStatus(left);
var rightVal = self._getStatus(right);
return self._comparator(leftVal, rightVal)
});
}
else {
this.sort(columnName, 'ascending', function (left, right) {
var leftVal = self._getStatus(left);
var rightVal = self._getStatus(right);
return self._comparator(rightVal, leftVal)
});
}
}
},
_comparator: function (leftVal, rightVal) {
if (leftVal === rightVal) {
return 0;
}
if (leftVal > rightVal) {
return -1;
}
return 1;
},
_getStatus: function (obj) {
return obj.get('statusWeight');
}
});
return Backgrid.SeriesStatusHeaderCell;
});