New: Shift-click to change monitored status of multiple episodes in season

pull/77/head
Mark McDowall 11 years ago
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;
}
});
});

@ -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 {

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

@ -12,7 +12,7 @@ define(
SeriesDeleted : 'series:deleted',
CommandComplete : 'command:complete',
ServerUpdated : 'server:updated',
EpisodeFileDeleted: 'episodefile:deleted'
EpisodeFileDeleted : 'episodefile:deleted'
};
vent.Commands = {

Loading…
Cancel
Save