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(
|
define(
|
||||||
[
|
[
|
||||||
|
'underscore',
|
||||||
'Cells/ToggleCell',
|
'Cells/ToggleCell',
|
||||||
'Series/SeriesCollection',
|
'Series/SeriesCollection',
|
||||||
'Shared/Messenger'
|
'Shared/Messenger'
|
||||||
], function (ToggleCell, SeriesCollection, Messenger) {
|
], function (_, ToggleCell, SeriesCollection, Messenger) {
|
||||||
return ToggleCell.extend({
|
return ToggleCell.extend({
|
||||||
|
|
||||||
className: 'toggle-cell episode-monitored',
|
className: 'toggle-cell episode-monitored',
|
||||||
|
|
||||||
_originalOnClick: ToggleCell.prototype._onClick,
|
_originalOnClick: ToggleCell.prototype._onClick,
|
||||||
|
|
||||||
_onClick: function () {
|
_onClick: function (e) {
|
||||||
|
|
||||||
var series = SeriesCollection.get(this.model.get('seriesId'));
|
var series = SeriesCollection.get(this.model.get('seriesId'));
|
||||||
|
|
||||||
if (!series.get('monitored')) {
|
if (!series.get('monitored')) {
|
||||||
|
@ -25,7 +27,41 @@ define(
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (e.shiftKey) {
|
||||||
|
this._selectRange();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this._originalOnClick.apply(this, arguments);
|
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/variables";
|
||||||
@import "../Content/Bootstrap/buttons";
|
@import "../Content/Bootstrap/buttons";
|
||||||
@import "../Shared/Styles/clickable";
|
@import "../Shared/Styles/clickable";
|
||||||
|
@import "../Content/mixins";
|
||||||
|
|
||||||
.episode-title-cell {
|
.episode-title-cell {
|
||||||
.btn-link;
|
.btn-link;
|
||||||
|
@ -31,6 +32,7 @@
|
||||||
|
|
||||||
.toggle-cell{
|
.toggle-cell{
|
||||||
.clickable();
|
.clickable();
|
||||||
|
.not-selectable;
|
||||||
}
|
}
|
||||||
|
|
||||||
.approval-status-cell {
|
.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) {
|
initialize: function (options) {
|
||||||
|
|
||||||
|
|
||||||
if (!options.episodeCollection) {
|
if (!options.episodeCollection) {
|
||||||
throw 'episodeCollection is needed';
|
throw 'episodeCollection is needed';
|
||||||
}
|
}
|
||||||
|
|
||||||
this.episodeCollection = options.episodeCollection.bySeason(this.model.get('seasonNumber'));
|
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.series = options.series;
|
||||||
|
|
||||||
this.showingEpisodes = this._shouldShowEpisodes();
|
this.showingEpisodes = this._shouldShowEpisodes();
|
||||||
|
@ -249,6 +257,34 @@ define(
|
||||||
|
|
||||||
this.templateHelpers.showingEpisodes = this.showingEpisodes;
|
this.templateHelpers.showingEpisodes = this.showingEpisodes;
|
||||||
this.render();
|
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 {
|
.series-season {
|
||||||
|
|
||||||
.episode-number-cell {
|
.episode-number-cell {
|
||||||
width : 22px;
|
width : 22px;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue