From: Bill Erickson Date: Fri, 9 Sep 2011 18:08:31 +0000 (-0400) Subject: TPac: on-fly-list management improvements X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=64961f464187503fa4d282a47f1e54af9f0c9ac7;p=contrib%2FConifer.git TPac: on-fly-list management improvements * 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 --- diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader.pm index a9d0565757..651ac483e3 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader.pm @@ -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|; diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Container.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Container.pm index be45ffc7c7..a51ddc5e45 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Container.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Container.pm @@ -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 => '/', diff --git a/Open-ILS/src/templates/opac/parts/result/table.tt2 b/Open-ILS/src/templates/opac/parts/result/table.tt2 index 905307ed07..3948515f92 100644 --- a/Open-ILS/src/templates/opac/parts/result/table.tt2 +++ b/Open-ILS/src/templates/opac/parts/result/table.tt2 @@ -53,7 +53,7 @@ name='result_table_title_cell' valign="top"> @@ -216,8 +216,10 @@ [% operation = ctx.mylist.grep(rec.id).size ? "delete" : "add"; label = (operation == "add") ? l("Add to my list") : l("Remove from my list"); + href = mkurl(ctx.opac_root _ '/mylist/' _ operation, + {record => rec.id, anchor => 'record_' _ rec.id}, 1); %] - + [% label %]