From fcdcab1d2904f46d2d9ff0e15087fad81efa90a1 Mon Sep 17 00:00:00 2001 From: Jason Stephenson Date: Fri, 21 Jul 2017 12:47:14 -0400 Subject: [PATCH] LP 1189989: Add suspend option when placing hold This commit adds some bells and whistles to the basic functionality: 1. Adds two new styles in style.css.tt2 for toggled blocks and inline text. These styles allow text with id attributes beginnging with certain strings to be normally hidden and then shown when they are the target of an active anchor. Only the block form is currently used, but the inline text version may prove useful in the near future. 2. Moves the "Suspend this hold?" language above the checkbox and adds a variant to make it clear that all of the holds will be suspended when multiple holds are placed. 3. Adds the question mark graphic with mouseover help text indicating that a suspended hold will not be fulfilled until it has been activated. 4. Adds a "Set activation date" anchor to toggle the appearance of the text input for the optional thaw date. 5. Adds a script block with a JavaScript function to toggle the appearance of the text input for the optional thaw date and to check the suspend hold check box when first toggled. This function returns false to prohibit the href of the anchor from firing and toggling the appearance via CSS. If JavaScript is disabled, the input's appearance will be toggled via CSS, but the checkbox will not be checked automatically. 6. Adds language to the place hold results page to indicate if the hold is suspended and adds the reactive date if supplied. 7. Modifies the backend holds code to not set the expire time on a hold if it is suspended. This is a logical extension of code added for Lp bug #1076399: Activating an expired hold cancels the hold. PLEASE NOTE: I would very much like to keep this branch in three commits because the first commit is Bill Ott's initial implementation from 2013. The second commit is a fix to Bill's work required to make it work with modern ttopac. This third commit overs the expansion of the functionality to meet MassLNC requirements. I think it would behoove us to keep these three pieces of work in distinct commits. Signed-off-by: Jason Stephenson Signed-off-by: Kathy Lussier Signed-off-by: Galen Charlton --- .../perlmods/lib/OpenILS/Application/Circ/Holds.pm | 2 +- .../lib/OpenILS/WWW/EGCatLoader/Account.pm | 3 ++ Open-ILS/src/templates/opac/css/style.css.tt2 | 16 ++++++++ Open-ILS/src/templates/opac/parts/place_hold.tt2 | 44 +++++++++++++++++++--- .../src/templates/opac/parts/place_hold_result.tt2 | 10 +++++ 5 files changed, 68 insertions(+), 7 deletions(-) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Holds.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Holds.pm index a331facf6c..c46ad21c21 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Holds.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Holds.pm @@ -342,7 +342,7 @@ sub create_hold { $hold->expire_time(undef) if ($hold->expire_time && $U->datecmp($hold->expire_time) == -1); # set the configured expire time - unless($hold->expire_time) { + unless($hold->expire_time || $U->is_true($hold->frozen)) { $hold->expire_time(calculate_expire_time($recipient->home_ou)); } 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 95bad4a858..9c5f14d1db 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm @@ -1036,6 +1036,9 @@ sub load_place_hold { } if ($cgi->param('hold_suspend')) { $ctx->{frozen} = 1; + # TODO: Make this support other date formats, not just mm/dd/yyyy. + # We should use a date input type on the forms once it is supported by Firefox. + # I didn't do that now because it is not available in a general release. if ($cgi->param('thaw_date') =~ m:^(\d{2})/(\d{2})/(\d{4})$:){ $ctx->{thaw_date} = "$3-$1-$2"; } diff --git a/Open-ILS/src/templates/opac/css/style.css.tt2 b/Open-ILS/src/templates/opac/css/style.css.tt2 index 226b294d75..bdbb2d3b1c 100644 --- a/Open-ILS/src/templates/opac/css/style.css.tt2 +++ b/Open-ILS/src/templates/opac/css/style.css.tt2 @@ -3235,3 +3235,19 @@ label[for*=expert_] } .metarecord_filter_container select{padding: 2px;width: 13em; /* consistent w/ adv search selectors */} .metarecord_filter_header{padding-bottom: 5px;} + +/* Toggled items. */ +/* A block that is initially hidden and shown by clicking an anchor. */ +[id^="toggled-block-"]{ + display: none; +} +[id^="toggled-block-"]:target{ + display: block; +} +/* Inline text that is initially hidden and shown by clicking an anchor. Useful on a span. */ +[id^="toggled-inline-"]{ + display: none; +} +[id^="toggled-inline-"]:target{ + display: inline; +} diff --git a/Open-ILS/src/templates/opac/parts/place_hold.tt2 b/Open-ILS/src/templates/opac/parts/place_hold.tt2 index 0a759f02d3..1ec5862ddc 100644 --- a/Open-ILS/src/templates/opac/parts/place_hold.tt2 +++ b/Open-ILS/src/templates/opac/parts/place_hold.tt2 @@ -2,7 +2,29 @@ PROCESS "opac/parts/hold_error_messages.tt2"; PROCESS "opac/parts/metarecord_hold_filters.tt2"; %] - +

[% l('Place Hold') %]

@@ -203,12 +225,22 @@ [% END %]
- [% l('Suspend This Hold?') %] + [% IF ctx.hold_data.size == 1; + l('Suspend this hold?'); + ELSE; + l('Suspend these holds?'); + END %] + [% l('Suspend Hold Help') %] +
+ [% l('Yes') %] + [% l('Set activation date') %]
-
- [% l('If suspended, activate on') %] - - [% l('Enter date in MM/DD/YYYY format') %] +
+ + + [% l('Enter date in MM/DD/YYYY format') %]

[% l("Hold was successfully placed"); %]
+ [% IF hdata.frozen %] +
+ [% l("Hold is suspended") %] + [% IF hdata.thaw_date %] +
+ [% l("Reactivate on [_1]", date.format(ctx.parse_datetime(hdata.thaw_date), DATE_FORMAT)); + END %] +
+ [% END %] + [% IF ctx.is_staff %]