From 8151ed9d949a6613c1bf40d605c59f2d07efd06c Mon Sep 17 00:00:00 2001 From: Art Rhyno Date: Fri, 27 Jul 2012 11:39:14 -0400 Subject: [PATCH] Block "Place Hold" link in TPAC if item is available Suppress the display of the "Place Hold" link based on whether an item is available. This is set as a preference in config.tt2. Some sites may want the ability to place holds regardless of availability. Signed-off-by: Art Rhyno Signed-off-by: Dan Scott Conflicts: Open-ILS/src/templates/opac/parts/record/summary.tt2 Open-ILS/src/templates/opac/parts/result/table.tt2 Signed-off-by: Dan Scott --- Open-ILS/src/templates/opac/parts/config.tt2 | 9 +++++++++ Open-ILS/src/templates/opac/parts/misc_util.tt2 | 4 +++- Open-ILS/src/templates/opac/parts/record/summary.tt2 | 10 ++++++++-- Open-ILS/src/templates/opac/parts/result/table.tt2 | 11 +++++++++-- 4 files changed, 29 insertions(+), 5 deletions(-) diff --git a/Open-ILS/src/templates/opac/parts/config.tt2 b/Open-ILS/src/templates/opac/parts/config.tt2 index 813280aeff..f23ef4d492 100644 --- a/Open-ILS/src/templates/opac/parts/config.tt2 +++ b/Open-ILS/src/templates/opac/parts/config.tt2 @@ -6,6 +6,15 @@ ############################################################################## ############################################################################## +# Holds blocking +############################################################################## +# Prevent the "Place hold" link from being displayed if a copy is available. +# This is not perfect, given the umpteen different types of holds that are +# possible, but addresses the major use case for libraries that don't want +# to fetch copies from the shelves. +ctx.holds_block.enabled = 'false'; + +############################################################################## # RefWorks configuration ############################################################################## # RefWorks is a Web-based citation manager diff --git a/Open-ILS/src/templates/opac/parts/misc_util.tt2 b/Open-ILS/src/templates/opac/parts/misc_util.tt2 index 524a66b94f..124d1245c7 100644 --- a/Open-ILS/src/templates/opac/parts/misc_util.tt2 +++ b/Open-ILS/src/templates/opac/parts/misc_util.tt2 @@ -238,10 +238,12 @@ FOR node IN xml.findnodes(xpath); FOR attr IN ['count', 'available', 'unshadow', 'transcendant', 'org_unit']; depth = node.getAttribute('depth'); + org_unit = node.getAttribute('org_unit'); args.copy_counts.$depth.$attr = node.getAttribute(attr); + args.org_copy_counts.$org_unit.$attr = node.getAttribute(attr); END; END; - + # Get preferred library copy count args.plib_copy_counts = {}; count_type = 'pref_lib'; diff --git a/Open-ILS/src/templates/opac/parts/record/summary.tt2 b/Open-ILS/src/templates/opac/parts/record/summary.tt2 index 7e3c88397b..32858db322 100644 --- a/Open-ILS/src/templates/opac/parts/record/summary.tt2 +++ b/Open-ILS/src/templates/opac/parts/record/summary.tt2 @@ -23,14 +23,20 @@
-[% IF ctx.place_unfillable || attrs.marc_xml.findnodes('//*[local-name()="holdings" and @has_holdable="true"]').size > 0 %] + [%- search_ou = ctx.search_ou; + IF ctx.place_unfillable || + (ctx.holds_block.enabled != 'true' && + attrs.marc_xml.findnodes('//*[local-name()="holdings" and @has_holdable="true"]').size > 0 + ) || + (ctx.holds_block.enable == 'true' && attrs.org_copy_counts.$search_ou.available > 0) + %] -[% END %] + [%- END -%]
[% IF ctx.user; INCLUDE "opac/parts/bookbag_actions.tt2"; diff --git a/Open-ILS/src/templates/opac/parts/result/table.tt2 b/Open-ILS/src/templates/opac/parts/result/table.tt2 index 426803c864..1d809d6ec4 100644 --- a/Open-ILS/src/templates/opac/parts/result/table.tt2 +++ b/Open-ILS/src/templates/opac/parts/result/table.tt2 @@ -216,7 +216,14 @@
-[% IF ctx.place_unfillable || attrs.marc_xml.findnodes('//*[local-name()="holdings" and @has_holdable="true"]').size > 0 %] +[%- search_ou = ctx.search_ou; + IF ctx.place_unfillable || + (ctx.holds_block.enabled != 'true' && + attrs.marc_xml.findnodes('//*[local-name()="holdings" and @has_holdable="true"]').size > 0 + ) || + (ctx.holds_block.enable == 'true' && attrs.org_copy_counts.$search_ou.available > 0) + +%] -[% END %] +[%- END -%]
[% IF ctx.user; INCLUDE "opac/parts/bookbag_actions.tt2"; -- 2.11.0