mirror of https://github.com/lidarr/Lidarr
New: Shift-click range selection for Series Editor
This commit is contained in:
parent
fc4170c581
commit
b4c6284fae
|
@ -27,7 +27,7 @@ define(
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (e.shiftKey) {
|
if (e.shiftKey && this.model.episodeCollection.lastToggled) {
|
||||||
this._selectRange();
|
this._selectRange();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
@ -41,10 +41,6 @@ define(
|
||||||
var episodeCollection = this.model.episodeCollection;
|
var episodeCollection = this.model.episodeCollection;
|
||||||
var lastToggled = episodeCollection.lastToggled;
|
var lastToggled = episodeCollection.lastToggled;
|
||||||
|
|
||||||
if (!lastToggled) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var currentIndex = episodeCollection.indexOf(this.model);
|
var currentIndex = episodeCollection.indexOf(this.model);
|
||||||
var lastIndex = episodeCollection.indexOf(lastToggled);
|
var lastIndex = episodeCollection.indexOf(lastToggled);
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,49 @@
|
||||||
|
'use strict';
|
||||||
|
define(
|
||||||
|
[
|
||||||
|
'jquery',
|
||||||
|
'underscore',
|
||||||
|
'backgrid.selectall'
|
||||||
|
], function ($, _, BackgridSelectAll) {
|
||||||
|
return BackgridSelectAll.extend({
|
||||||
|
|
||||||
|
enterEditMode: function (e) {
|
||||||
|
if (e.shiftKey && this.model.collection.lastToggled) {
|
||||||
|
this._selectRange();
|
||||||
|
}
|
||||||
|
|
||||||
|
var checked = $(e.target).prop('checked');
|
||||||
|
|
||||||
|
this.model.collection.lastToggled = this.model;
|
||||||
|
this.model.collection.checked = checked;
|
||||||
|
},
|
||||||
|
|
||||||
|
onChange: function (e) {
|
||||||
|
var checked = $(e.target).prop('checked');
|
||||||
|
this.$el.parent().toggleClass('selected', checked);
|
||||||
|
this.model.trigger('backgrid:selected', this.model, checked);
|
||||||
|
},
|
||||||
|
|
||||||
|
_selectRange: function () {
|
||||||
|
var collection = this.model.collection;
|
||||||
|
var lastToggled = collection.lastToggled;
|
||||||
|
var checked = collection.checked;
|
||||||
|
|
||||||
|
var currentIndex = collection.indexOf(this.model);
|
||||||
|
var lastIndex = collection.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 = collection.at(index);
|
||||||
|
|
||||||
|
model.trigger('backgrid:select', model, checked);
|
||||||
|
});
|
||||||
|
|
||||||
|
this.model.collection.lastToggled = undefined;
|
||||||
|
this.model.collection.checked = undefined;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
|
@ -10,6 +10,7 @@ define(
|
||||||
'Cells/ProfileCell',
|
'Cells/ProfileCell',
|
||||||
'Cells/SeriesStatusCell',
|
'Cells/SeriesStatusCell',
|
||||||
'Cells/SeasonFolderCell',
|
'Cells/SeasonFolderCell',
|
||||||
|
'Cells/SelectAllCell',
|
||||||
'Shared/Toolbar/ToolbarLayout',
|
'Shared/Toolbar/ToolbarLayout',
|
||||||
'Series/Editor/SeriesEditorFooterView',
|
'Series/Editor/SeriesEditorFooterView',
|
||||||
'Mixins/backbone.signalr.mixin'
|
'Mixins/backbone.signalr.mixin'
|
||||||
|
@ -22,6 +23,7 @@ define(
|
||||||
ProfileCell,
|
ProfileCell,
|
||||||
SeriesStatusCell,
|
SeriesStatusCell,
|
||||||
SeasonFolderCell,
|
SeasonFolderCell,
|
||||||
|
SelectAllCell,
|
||||||
ToolbarLayout,
|
ToolbarLayout,
|
||||||
FooterView) {
|
FooterView) {
|
||||||
return Marionette.Layout.extend({
|
return Marionette.Layout.extend({
|
||||||
|
@ -48,7 +50,7 @@ define(
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
name : '',
|
name : '',
|
||||||
cell : 'select-row',
|
cell : SelectAllCell,
|
||||||
headerCell : 'select-all',
|
headerCell : 'select-all',
|
||||||
sortable : false
|
sortable : false
|
||||||
},
|
},
|
||||||
|
|
|
@ -221,7 +221,7 @@ require.config({
|
||||||
},
|
},
|
||||||
'backgrid.selectall' : {
|
'backgrid.selectall' : {
|
||||||
|
|
||||||
exports: 'Backgrid.Extension.SelectAll',
|
exports: 'Backgrid.Extension.SelectRowCell',
|
||||||
|
|
||||||
deps:
|
deps:
|
||||||
[
|
[
|
||||||
|
|
Loading…
Reference in New Issue