add print and email actions to list and cart pages
authorGalen Charlton <gmc@equinoxinitiative.org>
Thu, 24 May 2018 01:41:01 +0000 (21:41 -0400)
committerGalen Charlton <gmc@equinoxinitiative.org>
Thu, 24 May 2018 01:41:01 +0000 (21:41 -0400)
Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org>
Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm
Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Container.pm
Open-ILS/src/templates/opac/myopac/lists.tt2
Open-ILS/src/templates/opac/parts/anon_list.tt2

index b630517..9b9cd06 100644 (file)
@@ -2473,7 +2473,7 @@ sub load_myopac_bookbags {
 }
 
 
-# actions are create, delete, show, hide, rename, add_rec, delete_item, place_hold
+# actions are create, delete, show, hide, rename, add_rec, delete_item, place_hold, print, email
 # CGI is action, list=list_id, add_rec/record=bre_id, del_item=bucket_item_id, name=new_bucket_name
 sub load_myopac_bookbag_update {
     my ($self, $action, $list_id, @hold_recs) = @_;
@@ -2557,6 +2557,12 @@ sub load_myopac_bookbag_update {
         }
         return $self->generic_redirect($url);
 
+    } elsif ($action eq 'print') {
+        my $temp_cache_key = $self->_stash_record_list_in_anon_cache(@selected_item);
+        return $self->load_mylist_print($temp_cache_key);
+    } elsif ($action eq 'email') {
+        my $temp_cache_key = $self->_stash_record_list_in_anon_cache(@selected_item);
+        return $self->load_mylist_email($temp_cache_key);
     } else {
 
         $list = $e->retrieve_container_biblio_record_entry_bucket($list_id);
index eb818ec..d2cb53e 100644 (file)
@@ -170,7 +170,7 @@ sub _do_mylist_delete {
 sub load_mylist_print {
     my $self = shift;
 
-    my $cache_key = $self->cgi->cookie((ref $self)->COOKIE_ANON_CACHE);
+    my $cache_key = shift // $self->cgi->cookie((ref $self)->COOKIE_ANON_CACHE);
 
     if (!$cache_key) {
         return $self->generic_redirect;
@@ -219,6 +219,17 @@ sub load_mylist_email {
     return $self->generic_redirect($url);
 }
 
+sub _stash_record_list_in_anon_cache {
+    my $self = shift;
+    my @rec_ids = @_;
+
+    my $cache_key = $U->simplereq(
+        'open-ils.actor',
+        'open-ils.actor.anon_cache.set_value',
+        undef, (ref $self)->ANON_CACHE_MYLIST, [ @rec_ids ]);
+    return $cache_key;
+}
+
 sub load_mylist_move {
     my $self = shift;
     my @rec_ids = $self->cgi->param('record');
@@ -231,6 +242,14 @@ sub load_mylist_move {
         }
         return $self->load_myopac_bookbag_update('place_hold', undef, @rec_ids);
     }
+    if ($action eq 'print') {
+        my $temp_cache_key = $self->_stash_record_list_in_anon_cache(@rec_ids);
+        return $self->load_mylist_print($temp_cache_key);
+    }
+    if ($action eq 'email') {
+        my $temp_cache_key = $self->_stash_record_list_in_anon_cache(@rec_ids);
+        return $self->load_mylist_email($temp_cache_key);
+    }
 
     return $self->mylist_action_redirect unless $cache_key;
 
index c8bee08..53b604a 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 %]" />
         <div class="bbag-content">
         [% IF bbag.items.size %]
             <div class="bbag-action">
                 <select name="action" class="bbag-action-field">
                     <option disabled="disabled" selected="selected">[% l('-- Actions for these items --') %]</option>
                     <option value="place_hold">[% l('Place hold') %]</option>
+                    <option value="print">[% l('Print title details') %]</option>
+                    <option value="email">[% l('Email title details') %]</option>
                     <option value="del_item">[% l('Remove from list') %]</option>
                 </select>
                 [%- INCLUDE "opac/parts/preserve_params.tt2"; %]
index 7888792..d137411 100644 (file)
                 <input class="opac-button" type="submit" value="[% l('Sort') %]" />
             </form>
         </div>
-        <form action="[% mkurl(ctx.opac_root _ '/mylist/move') %]" method="get">
+        <form action="[% mkurl(ctx.opac_root _ '/mylist/move') %]" method="post">
+        <input type="hidden" name="redirect_to" value="[% ctx.unparsed_uri | html %]" />
         <div class="bbag-action" style="clear:both;">
             <select name="action">
                 <option>[% l('-- Actions for these items --') %]</option>
                 <option value="place_hold">[% l('Place hold') %]</option>
+                <option value="print">[% l('Print title details') %]</option>
+                <option value="email">[% l('Email title details') %]</option>
                 <option value="delete">[% l('Remove from cart') %]</option>
                 [% IF ctx.user AND ctx.bookbags.size %]
                     <optgroup label="[% l('Move selected items to list:') %]">