1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2024-12-16 11:37:58 +02:00

Ended overrides not monitored and sorting separates by monitored state

This commit is contained in:
Mark McDowall 2013-08-17 23:10:18 -07:00
parent 2d2c6f866c
commit 82378a8628
3 changed files with 73 additions and 8 deletions

View File

@ -12,6 +12,7 @@ define(
'Cells/QualityProfileCell', 'Cells/QualityProfileCell',
'Shared/Grid/DateHeaderCell', 'Shared/Grid/DateHeaderCell',
'Series/Index/Table/SeriesStatusCell', 'Series/Index/Table/SeriesStatusCell',
'Series/Index/Table/SeriesStatusHeaderCell',
'Series/Index/Table/Row', 'Series/Index/Table/Row',
'Series/Index/FooterView', 'Series/Index/FooterView',
'Series/Index/FooterModel', 'Series/Index/FooterModel',
@ -28,6 +29,7 @@ define(
QualityProfileCell, QualityProfileCell,
DateHeaderCell, DateHeaderCell,
SeriesStatusCell, SeriesStatusCell,
SeriesStatusHeaderCell,
SeriesIndexRow, SeriesIndexRow,
FooterView, FooterView,
FooterModel, FooterModel,
@ -46,8 +48,9 @@ define(
[ [
{ {
name : 'status', name : 'status',
label: '', label : '',
cell : SeriesStatusCell cell : SeriesStatusCell,
headerCell: SeriesStatusHeaderCell
}, },
{ {
name : 'title', name : 'title',

View File

@ -11,15 +11,19 @@ define(
var monitored = this.model.get('monitored'); var monitored = this.model.get('monitored');
var status = this.model.get('status'); var status = this.model.get('status');
if (!monitored) { if (status === 'ended') {
this.$el.html('<i class="icon-pause grid-icon" title="Not Monitored"></i>'); this.$el.html('<i class="icon-stop grid-icon" title="Ended"></i>');
this.model.set('statusWeight', 3);
} }
else if (status === 'continuing') {
this.$el.html('<i class="icon-play grid-icon" title="Continuing"></i>'); else if (!monitored) {
this.$el.html('<i class="icon-pause grid-icon" title="Not Monitored"></i>');
this.model.set('statusWeight', 2);
} }
else { else {
this.$el.html('<i class="icon-stop grid-icon" title="Ended"></i>'); this.$el.html('<i class="icon-play grid-icon" title="Continuing"></i>');
this.model.set('statusWeight', 1);
} }
return this; return this;

View File

@ -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;
});