Merge pull request #299 from eReuse/feature/3426-shift-select

select with shift
This commit is contained in:
cayop 2022-06-08 10:57:00 +02:00 committed by GitHub
commit 00a2f47189
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 46 additions and 2 deletions

View File

@ -26,8 +26,10 @@ $(document).ready(() => {
newTrade(show_trade_form);
} else {
$(".deviceSelect").on("change", deviceSelect);
} // $('#selectLot').selectpicker();
}
;
select_shift(); // $('#selectLot').selectpicker();
});
class TableController {
@ -239,6 +241,26 @@ function addTag() {
$("#addTagAlertModal").click();
}
function select_shift() {
const chkboxes = $('.deviceSelect');
var lastChecked = null;
chkboxes.click(function (e) {
if (!lastChecked) {
lastChecked = this;
return;
}
if (e.shiftKey) {
const start = chkboxes.index(this);
const end = chkboxes.index(lastChecked);
chkboxes.slice(Math.min(start, end), Math.max(start, end) + 1).prop("checked", lastChecked.checked);
}
lastChecked = this;
});
selectorController("softInit");
}
function newTrade(action) {
let title = "Trade ";
const user_to = $("#user_to").data("email");

View File

@ -13,7 +13,8 @@ $(document).ready(() => {
newTrade(show_trade_form);
} else {
$(".deviceSelect").on("change", deviceSelect);
}
};
select_shift();
// $('#selectLot').selectpicker();
})
@ -229,6 +230,27 @@ function addTag() {
$("#addTagAlertModal").click();
}
function select_shift() {
const chkboxes = $(".deviceSelect");
let lastChecked = null;
chkboxes.click(function(e) {
if (!lastChecked) {
lastChecked = this;
return;
}
if (e.shiftKey) {
const start = chkboxes.index(this);
const end = chkboxes.index(lastChecked);
chkboxes.slice(Math.min(start,end), Math.max(start,end)+ 1).prop("checked", lastChecked.checked);
}
lastChecked = this;
});
selectorController("softInit");
}
function newTrade(action) {
let title = "Trade "
const user_to = $("#user_to").data("email");