and have list actions check for zero-selection actions
authorGalen Charlton <gmc@equinoxinitiative.org>
Fri, 8 Jun 2018 21:31:22 +0000 (17:31 -0400)
committerGalen Charlton <gmc@equinoxinitiative.org>
Fri, 8 Jun 2018 21:31:22 +0000 (17:31 -0400)
Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org>
Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm
Open-ILS/src/templates/opac/myopac/lists.tt2
Open-ILS/src/templates/opac/parts/anon_list.tt2
Open-ILS/src/templates/opac/parts/header.tt2

index 3ea7d79..b0d39ce 100644 (file)
@@ -2496,6 +2496,16 @@ sub load_myopac_bookbag_update {
     my $success = 0;
     my $list;
 
+    # bail out if user is attempting an action that requires
+    # that at least one list item be selected
+    if ((scalar(@selected_item) == 0) &&
+        ($action eq 'place_hold' || $action eq 'print' ||
+         $action eq 'email' || $action eq 'del_item')) {
+        my $url = $self->ctx->{referer};
+        $url .= ($url =~ /\?/ ? '&' : '?') . 'list_none_selected=1' unless $url =~ /list_none_selected/;
+        return $self->generic_redirect($url);
+    }
+
     # This url intentionally leaves off the edit_notes parameter, but
     # may need to add some back in for paging.
 
index d46dc34..0830cd3 100644 (file)
         <form action="[% mkurl(ctx.opac_root _ '/myopac/list/update') %]" method="post">
         <input type="hidden" name="list" value="[% bbag.id %]" />
         <input type="hidden" name="sort" value="[% CGI.param('sort') | uri %]" />
-        <input type="hidden" name="redirect_to" value="[% ctx.unparsed_uri | html %]" />
+        <input type="hidden" name="redirect_to" value="[% mkurl('', {}, ['list_none_selected', 'cart_none_selected']) %]" />
         <div class="bbag-content">
         [% IF bbag.items.size %]
             <div class="bbag-action">
                 </select>
                 [%- INCLUDE "opac/parts/preserve_params.tt2"; %]
                 <input class="opac-button" type="submit" value="[% l('Go') %]" />
+                [% IF CGI.param('list_none_selected') %]
+                    <span class="error">[% l('No items were selected') %]</span>
+                [% END %]
             </div>
         [% END %]
         <table class="bookbag-specific table_no_cell_pad table_no_border_space table_no_border">
index caf6f0a..0f2bacb 100644 (file)
@@ -13,7 +13,7 @@
             </form>
         </div>
         <form action="[% mkurl(ctx.opac_root _ '/mylist/move') %]" method="post">
-        <input type="hidden" name="redirect_to" value="[% mkurl('', {}, ['cart_none_selected']) %]" />
+        <input type="hidden" name="redirect_to" value="[% mkurl('', {}, ['list_none_selected', 'cart_none_selected']) %]" />
         <div class="bbag-action" style="clear:both;">
             <select name="action">
                 <option>[% l('-- Actions for these items --') %]</option>
index 12fbda7..1d3550d 100644 (file)
@@ -65,6 +65,7 @@
         # because they're used for specific, transitory purposes
         cgi.delete('move_cart_by_default');
         cgi.delete('cart_none_selected');
+        cgi.delete('list_none_selected');
 
         # x and y are artifacts of using <input type="image" /> tags 
         # instead of true submit buttons, and their values are never used.