implement warning if attempting action from cart view with nothing selected
authorGalen Charlton <gmc@equinoxinitiative.org>
Fri, 8 Jun 2018 21:14:01 +0000 (17:14 -0400)
committerGalen Charlton <gmc@equinoxinitiative.org>
Fri, 8 Jun 2018 21:14:01 +0000 (17:14 -0400)
Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org>
Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Container.pm
Open-ILS/src/templates/opac/parts/anon_list.tt2
Open-ILS/src/templates/opac/parts/header.tt2

index 3976e5f..07f1aab 100644 (file)
@@ -236,6 +236,14 @@ sub load_mylist_move {
     my $action = $self->cgi->param('action') || '';
 
     my ($cache_key, $list) = $self->fetch_mylist;
+
+    if ((scalar(@rec_ids) == 0) ||
+        ($self->cgi->param('entire_list') && scalar(@$list) == 0)) {
+        my $url = $self->ctx->{referer};
+        $url .= ($url =~ /\?/ ? '&' : '?') . 'cart_none_selected=1';
+        return $self->generic_redirect($url);
+    }
+
     if ($action eq 'place_hold') {
         if ($self->cgi->param('entire_list')) {
             @rec_ids = @$list;
index d137411..caf6f0a 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="[% ctx.unparsed_uri | html %]" />
+        <input type="hidden" name="redirect_to" value="[% mkurl('', {}, ['cart_none_selected']) %]" />
         <div class="bbag-action" style="clear:both;">
             <select name="action">
                 <option>[% l('-- Actions for these items --') %]</option>
@@ -31,6 +31,9 @@
             </select>
             [%- INCLUDE "opac/parts/preserve_params.tt2"; %]
             <input class="opac-button" type="submit" value="[% l('Go') %]" />
+            [% IF CGI.param('cart_none_selected') %]
+                <span class="error">[% l('No items were selected') %]</span>
+            [% END %]
         </div>
         <div class="bbag-content">
             <table class="bookbag-specific table_no_cell_pad table_no_border_space table_no_border">
index d5c0871..12fbda7 100644 (file)
@@ -64,6 +64,7 @@
         # some standing, hardcoded parameters to always clear
         # because they're used for specific, transitory purposes
         cgi.delete('move_cart_by_default');
+        cgi.delete('cart_none_selected');
 
         # x and y are artifacts of using <input type="image" /> tags 
         # instead of true submit buttons, and their values are never used.