From 9ddce92adc9c2093a32c2356c80c6ed6c1ecff73 Mon Sep 17 00:00:00 2001 From: Mike Rylander Date: Thu, 6 Aug 2020 16:43:25 -0400 Subject: [PATCH] LP#1815815: Simplify basic search UI This commit adds logic to the org selector (and backing context building logic) to allow the library dropdown to render Library Groups in a way mechanically similar to location groups. This is used in the basic search interface to simplify the Library Group feature. The advanced search interface still uses separate Library and Where dropdowns, as this allows advance search to retain the depth selection capability, and more directly shows the (real) relationship between a library and the location groups, library groups, and depths that are relevant to it. Signed-off-by: Mike Rylander Signed-off-by: Ruth Frasur Signed-off-by: Terran McCanna Signed-off-by: Galen Charlton --- .../perlmods/lib/OpenILS/WWW/EGCatLoader.pm | 7 +++- .../lib/OpenILS/WWW/EGCatLoader/Search.pm | 3 ++ .../lib/OpenILS/WWW/EGCatLoader/Util.pm | 12 +++++- .../templates/opac/parts/advanced/search.tt2 | 4 +- .../src/templates/opac/parts/org_selector.tt2 | 37 ++++++++++++++++--- .../src/templates/opac/parts/searchbar.tt2 | 4 +- 6 files changed, 54 insertions(+), 13 deletions(-) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader.pm index 1c6cb78116..bf927cec48 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader.pm @@ -407,7 +407,12 @@ sub load_common { $self->extract_copy_location_group_info; $ctx->{search_ou} = $self->_get_search_lib(); - $ctx->{search_scope} = $self->cgi->param('search_scope'); + if (!$ctx->{search_scope}) { # didn't get it from locg above in extract_... + $ctx->{search_scope} = $self->cgi->param('search_scope'); + if ($ctx->{search_scope} =~ /^lasso\(([^)]+)\)/) { + $ctx->{search_lasso} = $1; # make it visible to basic search + } + } $self->staff_saved_searches_set_expansion_state if $ctx->{is_staff}; $self->load_eg_cache_hash; $self->load_copy_location_groups; diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm index 748b79a6b9..b7133236dc 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm @@ -142,6 +142,9 @@ sub _prepare_biblio_search { # lasso, and location_groups filters. $query .= ' ' . $cgi->param('search_scope') if defined $cgi->param('search_scope'); + # The search_lasso context param comes from the locg dropdown, like the copy location. + $query .= ' lasso(' . $ctx->{search_lasso} .')' if $ctx->{search_lasso}; + # sort is treated specially, even though it's actually a filter if (defined($cgi->param('sort'))) { $query =~ s/sort\([^\)]*\)//g; # override existing sort(). no stacking. diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Util.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Util.pm index 4816c7e10b..33cf92d731 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Util.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Util.pm @@ -665,15 +665,23 @@ sub load_eg_cache_hash { } # Extracts the copy location org unit and group from the -# "logc" param, which takes the form org_id:grp_id. +# "logc" param, which takes the form org_id:grp, where +# grp can either be a location group id or can match the +# pattern "lasso(lasso_name_or_id)". sub extract_copy_location_group_info { my $self = shift; my $ctx = $self->ctx; if (my $clump = $self->cgi->param('locg')) { my ($org, $grp) = split(/:/, $clump); + if ($grp =~ /^lasso\(([^)]+)\)/) { + $ctx->{search_lasso} = $1; + $ctx->{search_scope} = $grp; + } elsif ($grp) { + $ctx->{copy_location_group} = $grp; + $ctx->{search_scope} = "location_groups($grp)"; + } $ctx->{copy_location_group_org} = $self->_resolve_org_id_or_shortname($org); - $ctx->{copy_location_group} = $grp if $grp; } } diff --git a/Open-ILS/src/templates/opac/parts/advanced/search.tt2 b/Open-ILS/src/templates/opac/parts/advanced/search.tt2 index 07367388a1..c2c1916652 100644 --- a/Open-ILS/src/templates/opac/parts/advanced/search.tt2 +++ b/Open-ILS/src/templates/opac/parts/advanced/search.tt2 @@ -70,11 +70,11 @@ PROCESS "opac/parts/org_selector.tt2"; select_scope_label = l("Select search scope"); INCLUDE build_scope_selector arialabel=select_scope_label value=ctx.search_scope - id=adv_chunk.id name='search_scope' show_loc_groups=1; + id=adv_chunk.id name='search_scope' show_loc_groups=1 show_lassos=1; CASE "lib_selector"; PROCESS "opac/parts/org_selector.tt2"; - INCLUDE build_org_selector show_loc_groups=0 id=adv_chunk.id %] + INCLUDE build_org_selector show_loc_groups=1 show_lassos=0 id=adv_chunk.id %]
- [%- + + [% IF show_lassos AND ctx.lassos.size > 0; + %] [% + FOR lasso IN ctx.lassos; + opt_value = base_value _ ':lasso(' _ lasso.id _ ')'; + selected = ''; + IF !lasso_selected AND ctx.search_lasso == lasso.id; + lasso_selected = 1; + selected = 'selected="selected"'; + END %] + + [% END %] + + + [% END; + WHILE node_stack.size > 0; node = node_stack.pop(); org_unit = node.org; @@ -87,13 +108,13 @@ BLOCK build_org_selector; IF can_have_vols_only AND org_unit.ou_type.can_have_vols != 't'; disabled = 'disabled="disabled"'; - ELSIF node_value == value; + ELSIF !lasso_selected AND node_value == value; selected = 'selected="selected"'; END; IF can_have_users_only AND org_unit.ou_type.can_have_users != 't'; disabled = 'disabled="disabled"'; - ELSIF node_value == value; + ELSIF !lasso_selected AND node_value == value; selected = 'selected="selected"'; END; @@ -129,6 +150,10 @@ BLOCK build_org_selector; [% ' ' FOR [0..pad_depth]; display_name | html %] + [%- END -%] + + [%- IF show_lassos AND ctx.lassos.size > 0 -%] + [%- END %] [%- END; @@ -150,7 +175,7 @@ BLOCK build_scope_selector; hiding_depth = ctx.get_org_setting(ou_id, 'opac.org_unit_hiding.depth') -%]