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:
parent
2d2c6f866c
commit
82378a8628
@ -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',
|
||||
|
@ -11,15 +11,19 @@ define(
|
||||
var monitored = this.model.get('monitored');
|
||||
var status = this.model.get('status');
|
||||
|
||||
if (!monitored) {
|
||||
this.$el.html('<i class="icon-pause grid-icon" title="Not Monitored"></i>');
|
||||
if (status === 'ended') {
|
||||
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 {
|
||||
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;
|
||||
|
58
UI/Series/Index/Table/SeriesStatusHeaderCell.js
Normal file
58
UI/Series/Index/Table/SeriesStatusHeaderCell.js
Normal 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;
|
||||
});
|
Loading…
Reference in New Issue
Block a user