diff --git a/UI/Series/Index/SeriesIndexLayout.js b/UI/Series/Index/SeriesIndexLayout.js
index fc6bedcbc..6ee8b1da9 100644
--- a/UI/Series/Index/SeriesIndexLayout.js
+++ b/UI/Series/Index/SeriesIndexLayout.js
@@ -12,6 +12,7 @@ define(
'Cells/QualityProfileCell',
'Shared/Grid/DateHeaderCell',
'Series/Index/Table/SeriesStatusCell',
+ 'Series/Index/Table/SeriesStatusHeaderCell',
'Series/Index/Table/Row',
'Series/Index/FooterView',
'Series/Index/FooterModel',
@@ -28,6 +29,7 @@ define(
QualityProfileCell,
DateHeaderCell,
SeriesStatusCell,
+ SeriesStatusHeaderCell,
SeriesIndexRow,
FooterView,
FooterModel,
@@ -45,9 +47,10 @@ define(
columns:
[
{
- name : 'status',
- label: '',
- cell : SeriesStatusCell
+ name : 'status',
+ label : '',
+ cell : SeriesStatusCell,
+ headerCell: SeriesStatusHeaderCell
},
{
name : 'title',
diff --git a/UI/Series/Index/Table/SeriesStatusCell.js b/UI/Series/Index/Table/SeriesStatusCell.js
index f20ec2dc3..b180a172c 100644
--- a/UI/Series/Index/Table/SeriesStatusCell.js
+++ b/UI/Series/Index/Table/SeriesStatusCell.js
@@ -11,15 +11,19 @@ define(
var monitored = this.model.get('monitored');
var status = this.model.get('status');
- if (!monitored) {
- this.$el.html('');
+ if (status === 'ended') {
+ this.$el.html('');
+ this.model.set('statusWeight', 3);
}
- else if (status === 'continuing') {
- this.$el.html('');
+
+ else if (!monitored) {
+ this.$el.html('');
+ this.model.set('statusWeight', 2);
}
else {
- this.$el.html('');
+ this.$el.html('');
+ this.model.set('statusWeight', 1);
}
return this;
diff --git a/UI/Series/Index/Table/SeriesStatusHeaderCell.js b/UI/Series/Index/Table/SeriesStatusHeaderCell.js
new file mode 100644
index 000000000..4d398cdc5
--- /dev/null
+++ b/UI/Series/Index/Table/SeriesStatusHeaderCell.js
@@ -0,0 +1,58 @@
+'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;
+ });