mirror of
https://github.com/Sonarr/Sonarr.git
synced 2024-12-16 11:37:58 +02:00
New: Shift-click to change monitored status of multiple episodes in season
This commit is contained in:
parent
6c5a5340b8
commit
836c39a47d
@ -2,17 +2,19 @@
|
||||
|
||||
define(
|
||||
[
|
||||
'underscore',
|
||||
'Cells/ToggleCell',
|
||||
'Series/SeriesCollection',
|
||||
'Shared/Messenger'
|
||||
], function (ToggleCell, SeriesCollection, Messenger) {
|
||||
], function (_, ToggleCell, SeriesCollection, Messenger) {
|
||||
return ToggleCell.extend({
|
||||
|
||||
className: 'toggle-cell episode-monitored',
|
||||
|
||||
_originalOnClick: ToggleCell.prototype._onClick,
|
||||
|
||||
_onClick: function () {
|
||||
_onClick: function (e) {
|
||||
|
||||
var series = SeriesCollection.get(this.model.get('seriesId'));
|
||||
|
||||
if (!series.get('monitored')) {
|
||||
@ -25,7 +27,41 @@ define(
|
||||
return;
|
||||
}
|
||||
|
||||
if (e.shiftKey) {
|
||||
this._selectRange();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
this._originalOnClick.apply(this, arguments);
|
||||
this.model.episodeCollection.lastToggled = this.model;
|
||||
},
|
||||
|
||||
_selectRange: function () {
|
||||
var episodeCollection = this.model.episodeCollection;
|
||||
var lastToggled = episodeCollection.lastToggled;
|
||||
|
||||
if (!lastToggled) {
|
||||
return;
|
||||
}
|
||||
|
||||
var currentIndex = episodeCollection.indexOf(this.model);
|
||||
var lastIndex = episodeCollection.indexOf(lastToggled);
|
||||
|
||||
var low = Math.min(currentIndex, lastIndex);
|
||||
var high = Math.max(currentIndex, lastIndex);
|
||||
var range = _.range(low + 1, high);
|
||||
|
||||
_.each(range, function (index) {
|
||||
var model = episodeCollection.at(index);
|
||||
|
||||
model.set('monitored', lastToggled.get('monitored'));
|
||||
model.save();
|
||||
});
|
||||
|
||||
this.model.set('monitored', lastToggled.get('monitored'));
|
||||
this.model.save();
|
||||
this.model.episodeCollection.lastToggled = undefined;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
@ -24,8 +24,8 @@ define(
|
||||
this.$('i').addClass('icon-spinner icon-spin');
|
||||
|
||||
this.model.save().always(function () {
|
||||
self.render();
|
||||
});
|
||||
self.render();
|
||||
});
|
||||
},
|
||||
|
||||
render: function () {
|
||||
|
@ -2,6 +2,7 @@
|
||||
@import "../Content/Bootstrap/variables";
|
||||
@import "../Content/Bootstrap/buttons";
|
||||
@import "../Shared/Styles/clickable";
|
||||
@import "../Content/mixins";
|
||||
|
||||
.episode-title-cell {
|
||||
.btn-link;
|
||||
@ -31,6 +32,7 @@
|
||||
|
||||
.toggle-cell{
|
||||
.clickable();
|
||||
.not-selectable;
|
||||
}
|
||||
|
||||
.approval-status-cell {
|
||||
|
11
src/UI/Content/mixins.less
Normal file
11
src/UI/Content/mixins.less
Normal file
@ -0,0 +1,11 @@
|
||||
.selectable() {
|
||||
-moz-user-select : all;
|
||||
-webkit-user-select : all;
|
||||
-ms-user-select : all;
|
||||
}
|
||||
|
||||
.not-selectable() {
|
||||
-moz-user-select : none;
|
||||
-webkit-user-select : none;
|
||||
-ms-user-select : none;
|
||||
}
|
@ -92,11 +92,19 @@ define(
|
||||
|
||||
initialize: function (options) {
|
||||
|
||||
|
||||
if (!options.episodeCollection) {
|
||||
throw 'episodeCollection is needed';
|
||||
}
|
||||
|
||||
this.episodeCollection = options.episodeCollection.bySeason(this.model.get('seasonNumber'));
|
||||
|
||||
var self = this;
|
||||
|
||||
this.episodeCollection.each(function (model) {
|
||||
model.episodeCollection = self.episodeCollection;
|
||||
});
|
||||
|
||||
this.series = options.series;
|
||||
|
||||
this.showingEpisodes = this._shouldShowEpisodes();
|
||||
@ -249,6 +257,34 @@ define(
|
||||
|
||||
this.templateHelpers.showingEpisodes = this.showingEpisodes;
|
||||
this.render();
|
||||
},
|
||||
|
||||
_episodeMonitoredToggled: function (options) {
|
||||
var model = options.model;
|
||||
var shiftKey = options.shiftKey;
|
||||
|
||||
if (!this.episodeCollection.get(model.get('id'))) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!shiftKey) {
|
||||
return;
|
||||
}
|
||||
|
||||
var lastToggled = this.episodeCollection.lastToggled;
|
||||
|
||||
if (!lastToggled) {
|
||||
return;
|
||||
}
|
||||
|
||||
var currentIndex = this.episodeCollection.indexOf(model);
|
||||
var lastIndex = this.episodeCollection.indexOf(lastToggled);
|
||||
|
||||
var low = Math.min(currentIndex, lastIndex);
|
||||
var high = Math.max(currentIndex, lastIndex);
|
||||
var range = _.range(low + 1, high);
|
||||
|
||||
this.episodeCollection.lastToggled = model;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
@ -178,6 +178,7 @@
|
||||
}
|
||||
|
||||
.series-season {
|
||||
|
||||
.episode-number-cell {
|
||||
width : 22px;
|
||||
}
|
||||
|
@ -8,11 +8,11 @@ define(
|
||||
var vent = new Backbone.Wreqr.EventAggregator();
|
||||
|
||||
vent.Events = {
|
||||
SeriesAdded : 'series:added',
|
||||
SeriesDeleted : 'series:deleted',
|
||||
CommandComplete : 'command:complete',
|
||||
ServerUpdated : 'server:updated',
|
||||
EpisodeFileDeleted: 'episodefile:deleted'
|
||||
SeriesAdded : 'series:added',
|
||||
SeriesDeleted : 'series:deleted',
|
||||
CommandComplete : 'command:complete',
|
||||
ServerUpdated : 'server:updated',
|
||||
EpisodeFileDeleted : 'episodefile:deleted'
|
||||
};
|
||||
|
||||
vent.Commands = {
|
||||
|
Loading…
Reference in New Issue
Block a user