Fixed issue where enabling bulk selection, then disabling it, resulted in subsequent bulk actions not applying to any items
This commit is contained in:
		
							parent
							
								
									919a3039c4
								
							
						
					
					
						commit
						7c32b1f7a8
					
				| @ -167,8 +167,11 @@ class BulkActions extends Extension | |||||||
|             $action = $_POST['bulk_action']; |             $action = $_POST['bulk_action']; | ||||||
| 
 | 
 | ||||||
|             $items = null; |             $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']); |                 $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)) { |                 if (is_array($data)&&!empty($data)) { | ||||||
|                     $items = $this->yield_items($data); |                     $items = $this->yield_items($data); | ||||||
|                 } |                 } | ||||||
| @ -177,6 +180,8 @@ class BulkActions extends Extension | |||||||
|                 if ($query != null && $query != "") { |                 if ($query != null && $query != "") { | ||||||
|                     $items = $this->yield_search_results($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); |             $bae = new BulkActionEvent($action, $items); | ||||||
|  | |||||||
| @ -53,6 +53,7 @@ function deactivate_bulk_selector() { | |||||||
|     set_selected_items([]); |     set_selected_items([]); | ||||||
|     $('#bulk_selector_controls').hide(); |     $('#bulk_selector_controls').hide(); | ||||||
|     $('#bulk_selector_activate').show(); |     $('#bulk_selector_activate').show(); | ||||||
|  |     $('input[name="bulk_selected_ids"]').val(""); | ||||||
|     bulk_selector_active = false; |     bulk_selector_active = false; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| @ -94,7 +95,6 @@ function deselect_item(id) { | |||||||
| 
 | 
 | ||||||
| function toggle_selection( id ) { | function toggle_selection( id ) { | ||||||
|     var data = get_selected_items(); |     var data = get_selected_items(); | ||||||
|     console.log(id); |  | ||||||
|     if(data.includes(id)) { |     if(data.includes(id)) { | ||||||
|         data.splice(data.indexOf(id),1); |         data.splice(data.indexOf(id),1); | ||||||
|         set_selected_items(data);             |         set_selected_items(data);             | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user