From 7c32b1f7a89e70f54268b07fa321542973115226 Mon Sep 17 00:00:00 2001 From: Matthew Barbour Date: Sun, 21 Jun 2020 18:25:23 -0500 Subject: [PATCH] Fixed issue where enabling bulk selection, then disabling it, resulted in subsequent bulk actions not applying to any items --- ext/bulk_actions/main.php | 7 ++++++- ext/bulk_actions/script.js | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/ext/bulk_actions/main.php b/ext/bulk_actions/main.php index 65852b5d..ba613be3 100644 --- a/ext/bulk_actions/main.php +++ b/ext/bulk_actions/main.php @@ -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); diff --git a/ext/bulk_actions/script.js b/ext/bulk_actions/script.js index 5e0b9423..b8a816da 100644 --- a/ext/bulk_actions/script.js +++ b/ext/bulk_actions/script.js @@ -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);