TPac: on-fly-list management improvements
authorBill Erickson <berick@esilibrary.com>
Fri, 9 Sep 2011 18:08:31 +0000 (14:08 -0400)
committerBill Erickson <berick@esilibrary.com>
Fri, 9 Sep 2011 18:08:31 +0000 (14:08 -0400)
* implemented remove-from-list function
* After add or remove from list on results page, direct user back to the
context record via page anchor

Signed-off-by: Bill Erickson <berick@esilibrary.com>
Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader.pm
Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Container.pm
Open-ILS/web/templates/default/opac/parts/result/table.tt2

index a9d0565..651ac48 100644 (file)
@@ -97,6 +97,7 @@ sub load {
     return $self->load_cnbrowse if $path =~ m|opac/cnbrowse|;
 
     return $self->load_mylist_add if $path =~ m|opac/mylist/add|;
+    return $self->load_mylist_delete if $path =~ m|opac/mylist/delete|;
     return $self->load_mylist_move if $path =~ m|opac/mylist/move|;
     return $self->load_mylist if $path =~ m|opac/mylist|;
     return $self->load_cache_clear if $path =~ m|opac/cache/clear|;
index be45ffc..a51ddc5 100644 (file)
@@ -56,7 +56,21 @@ sub load_mylist_add {
     return $self->mylist_action_redirect($cache_key);
 }
 
-# Removes a record ID from My List, or moves to an actual bookbag
+sub load_mylist_delete {
+    my $self = shift;
+    my $rec_id = $self->cgi->param('record');
+
+    my ($cache_key, $list) = $self->fetch_mylist;
+    $list = [ grep { $_ ne $rec_id } @$list ];
+
+    $cache_key = $U->simplereq(
+        'open-ils.actor',
+        'open-ils.actor.anon_cache.set_value', 
+        $cache_key, ANON_CACHE_MYLIST, $list);
+
+    return $self->mylist_action_redirect($cache_key);
+}
+
 sub load_mylist_move {
     my $self = shift;
     my @rec_ids = $self->cgi->param('record');
@@ -112,8 +126,16 @@ sub mylist_action_redirect {
     my $self = shift;
     my $cache_key = shift;
 
+    my $url;
+    if( my $anchor = $self->cgi->param('anchor') ) {
+        # on the results page, we want to redirect 
+        # back to record that was affected
+        $url = $self->ctx->{referer};
+        $url =~ s/#.*|$/#$anchor/g;
+    } 
+
     return $self->generic_redirect(
-        undef, 
+        $url,
         $self->cgi->cookie(
             -name => COOKIE_ANON_CACHE,
             -path => '/',
index ad97115..2ec11ac 100644 (file)
@@ -49,7 +49,7 @@
                                                 name='result_table_title_cell'
                                                 valign="top">
                                                 <div class="bold">
-                                                    <a title="[% attrs.title | uri %]" name='item_title'
+                                                    <a name='record_[% rec.id %]' title="[% attrs.title | uri %]" name='item_title'
                                                         href="[% mkurl(ctx.opac_root _ '/record/' _ rec.id) %]"
                                                         class='search_link'>[% attrs.title | html %]</a>
                                                 </div>
                                                                 label = (operation == "add") ? l("Add to") : l("Remove from"); %]
                                                             <form action="[% ctx.opac_root %]/mylist/[% operation %]" method="POST">
                                                                 <input type="hidden" name="record" value="[% rec.id %]" />
+                                                                <input type="hidden" name="anchor" value="record_[% rec.id %]" />
                                                             <div style="position:absolute;">
                                                                 <div style="position:relative;top:5px; left: 25px;">
                                                                     <input type="submit" title="[% '[_1] my list' | l(label) %]"