Bug 33322: Refine click handler for suggestion batch operations
authorOwen Leonard <oleonard@myacpl.org>
Thu, 23 Mar 2023 17:15:48 +0000 (17:15 +0000)
committerTomas Cohen Arazi <tomascohen@theke.io>
Fri, 31 Mar 2023 16:41:37 +0000 (18:41 +0200)
The handler for suggestion batch operations looks for clicks on
"button[type='submit']" which is not very specific. With the new staff
interface this ends up including the header search form.

This patch modifies the markup of the batch operations section of
the template and makes the click handler more specific so that only the
right buttons are affected.

To test, apply the patch and go to Suggestions.

- In the header search form, perform a catalog search. You should be
  able to click the submit button to successfully initiate the search.
- Without checking a checkbox associated with any open suggestion, test
  the batch operation buttons at the bottom:
  - Change status
  - Change item type
  - Update manager
  - Delete
  - Archive
  All should trigger a JS alert, "Please select at least one suggestion"
- Test each batch operation with one or more suggestions selected and
  confirm that the operation completes successfully.

Signed-off-by: Laura Escamilla <laura.escamilla@bywatersolutions.com>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
koha-tmpl/intranet-tmpl/prog/en/modules/suggestion/suggestion.tt

index 66a8fcb..f343ff9 100644 (file)
                                         <h2>Change selected suggestions</h2>
                                     </div>
                                 </div>
-                                <div class="row">
+                                <div id="suggestions_batch_ops" class="row">
                                     <div class="col-sm-4">
                                         <fieldset class="brief">
                                             <div id="select-reason[% loop.index | html %]">
                     $("." + target).toggle();
                 });
 
-                $("button[type='submit']").on("click", function(e) {
+                $("button[type='submit']", "#suggestions_batch_ops").on("click", function(e) {
                     var submit_button = this;
                     var form = $(submit_button).parents("form");
                     var action = $(submit_button).val();