From: Bill Erickson Date: Mon, 28 Dec 2015 20:31:51 +0000 (-0500) Subject: LP#1527342 warn patrons on history delete X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=60b432c1c6694e3e2bd0e75444a7bed6ddd7c730;p=working%2FEvergreen.git LP#1527342 warn patrons on history delete Signed-off-by: Bill Erickson --- diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm index 1b26b0b354..b3c15bf611 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm @@ -616,22 +616,81 @@ sub load_myopac_prefs_settings { $settings{$key}= $val unless $$set_map{$key} eq $val; } + # Used by the settings update form when warning on history delete. + my $clear_circ_history = 0; + my $clear_hold_history = 0; + + # true if we need to show the warning on next page load. + my $hist_warning_needed = 0; + my $hist_clear_confirmed = $self->cgi->param('history_delete_confirmed'); + my $now = DateTime->now->strftime('%F'); - foreach my $key (qw/history.circ.retention_start history.hold.retention_start/) { + foreach my $key ( + qw/history.circ.retention_start history.hold.retention_start/) { + my $val = $self->cgi->param($key); if($val and $val eq 'on') { # Set the start time to 'now' unless a start time already exists for the user $settings{$key} = $now unless $$set_map{$key}; + } else { - # clear the start time if one previously existed for the user - $settings{$key} = undef if $$set_map{$key}; - $U->simplereq( - 'open-ils.actor', - 'open-ils.actor.history.circ.clear', - $self->editor->authtoken); + + next unless $$set_map{$key}; # nothing to do + + $clear_circ_history = 1 if $key =~ /circ/; + $clear_hold_history = 1 if $key =~ /hold/; + + if (!$hist_clear_confirmed) { + # when clearing circ history, only warn if history data exists. + + if ($clear_circ_history) { + + if ($self->fetch_user_circ_history(0, 1)->[0]) { + $hist_warning_needed = 1; + next; # no history updates while confirmation pending + } + + } else { + + my $one_hold = $e->json_query({ + select => { + au => [{ + column => 'id', + transform => 'action.usr_visible_holds', + result_field => 'id' + }] + }, + from => 'au', + where => {id => $e->requestor->id}, + limit => 1 + })->[0]; + + if ($one_hold) { + $hist_warning_needed = 1; + next; # no history updates while confirmation pending + } + } + } + + $settings{$key} = undef; + + if ($key eq 'history.circ.retention_start') { + # delete existing circulation history data. + $U->simplereq( + 'open-ils.actor', + 'open-ils.actor.history.circ.clear', + $self->editor->authtoken); + } } } + # Warn patrons before clearing circ/hold history + if ($hist_warning_needed) { + $self->ctx->{clear_circ_history} = $clear_circ_history; + $self->ctx->{clear_hold_history} = $clear_hold_history; + $self->ctx->{confirm_history_delete} = 1; + } + # Send the modified settings off to be saved $U->simplereq( 'open-ils.actor', diff --git a/Open-ILS/src/templates/opac/css/style.css.tt2 b/Open-ILS/src/templates/opac/css/style.css.tt2 index f91b5045ad..f5622c2602 100644 --- a/Open-ILS/src/templates/opac/css/style.css.tt2 +++ b/Open-ILS/src/templates/opac/css/style.css.tt2 @@ -2119,3 +2119,9 @@ label[for*=expert_] text-align: center; font-style: italic; } + +#clear-history-confirm { + font-weight: bold; + color: [% css_colors.text_badnews %]; + padding: 10px; +} diff --git a/Open-ILS/src/templates/opac/myopac/prefs_settings.tt2 b/Open-ILS/src/templates/opac/myopac/prefs_settings.tt2 index 9f1288c8b5..edefb5c581 100644 --- a/Open-ILS/src/templates/opac/myopac/prefs_settings.tt2 +++ b/Open-ILS/src/templates/opac/myopac/prefs_settings.tt2 @@ -72,7 +72,8 @@ + [% IF ctx.user_setting_map.$setting + AND !ctx.clear_circ_history; %] checked='checked' [% END %]/> [%- setting = 'history.hold.retention_start' -%] @@ -82,7 +83,8 @@ + [% IF ctx.user_setting_map.$setting + AND !ctx.clear_hold_history; %] checked='checked' [% END %]/> [%- setting = 'opac.temporary_list_no_warn' -%] @@ -121,7 +123,18 @@ + [% IF ctx.confirm_history_delete %] +
+ [% l('Disabling checkout or holds history will permanently remove all items from your history.') %] +
+ [% l('Are you sure you wish to continue?') %] +
+ [% l('Cancel') %] + + + [% ELSE %] + [% END %] [% INCLUDE "opac/parts/myopac/prefs_hints.tt2" %] [% END %]