Fixed issue where enabling bulk selection, then disabling it, resulted in subsequent bulk actions not applying to any items

This commit is contained in:
Matthew Barbour 2020-06-21 18:25:23 -05:00 committed by Shish
parent 919a3039c4
commit 7c32b1f7a8
2 changed files with 7 additions and 2 deletions

View file

@ -167,8 +167,11 @@ class BulkActions extends Extension
$action = $_POST['bulk_action'];
$items = null;
if (isset($_POST['bulk_selected_ids']) && $_POST['bulk_selected_ids'] != "") {
if (isset($_POST['bulk_selected_ids']) && !empty($_POST['bulk_selected_ids'])) {
$data = json_decode($_POST['bulk_selected_ids']);
if (empty($data)) {
throw new SCoreException("No ids specified in bulk_selected_ids");
}
if (is_array($data)&&!empty($data)) {
$items = $this->yield_items($data);
}
@ -177,6 +180,8 @@ class BulkActions extends Extension
if ($query != null && $query != "") {
$items = $this->yield_search_results($query);
}
} else {
throw new SCoreException("No ids selected and no query present, cannot perform bulk operation on entire collection");
}
$bae = new BulkActionEvent($action, $items);

View file

@ -53,6 +53,7 @@ function deactivate_bulk_selector() {
set_selected_items([]);
$('#bulk_selector_controls').hide();
$('#bulk_selector_activate').show();
$('input[name="bulk_selected_ids"]').val("");
bulk_selector_active = false;
}
@ -94,7 +95,6 @@ function deselect_item(id) {
function toggle_selection( id ) {
var data = get_selected_items();
console.log(id);
if(data.includes(id)) {
data.splice(data.indexOf(id),1);
set_selected_items(data);