LP#1815815: Simplify basic search UI
authorMike Rylander <mrylander@gmail.com>
Thu, 6 Aug 2020 20:43:25 +0000 (16:43 -0400)
committerGalen Charlton <gmc@equinoxinitiative.org>
Thu, 11 Mar 2021 18:18:26 +0000 (13:18 -0500)
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 <mrylander@gmail.com>
Signed-off-by: Ruth Frasur <rfrasur@library.in.gov>
Signed-off-by: Terran McCanna <tmccanna@georgialibraries.org>
Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org>
Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader.pm
Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm
Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Util.pm
Open-ILS/src/templates/opac/parts/advanced/search.tt2
Open-ILS/src/templates/opac/parts/org_selector.tt2
Open-ILS/src/templates/opac/parts/searchbar.tt2

index 1c6cb78..bf927ce 100644 (file)
@@ -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;
index 748b79a..b713323 100644 (file)
@@ -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.
index 4816c7e..33cf92d 100644 (file)
@@ -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;
     }
 }
 
index 0736738..c2c1916 100644 (file)
                     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 %]
                             <div class="adv_search_available">
                                 <input type='checkbox' name="modifier"
                                     value="available"[% CGI.param('modifier').grep('available').size ? ' checked="checked"' : '' %]
index e2890e8..4407793 100644 (file)
@@ -2,7 +2,7 @@
 # Org Unit Selector Widget :
 #   INCLUDE build_org_selector id='selector-id' name='selector-name' 
 #       value=org_id show_loc_groups=1/0 can_have_vols_only=1/0
-#       can_have_users_only=1/0 valid_org_list=[1,2,3]
+#       can_have_users_only=1/0 valid_org_list=[1,2,3] show_lassos=1/0
 #
 # NOTE: DO NOT USE PROCESS
 # Use of PROCESS results in internal variables, such as value or org_unit, to "leak" out
@@ -25,12 +25,33 @@ BLOCK build_org_selector;
     # disable the ou-hide scoping altogether.
     hiding_disabled = ctx.org_hiding_disabled(value);
 
+    # Some setup for Library Groups
+    lasso_selected = 0;
+    base_value = value.split(':').0;
+
     -%]
 
     <select [% IF id %] id='[% id %]' [% END -%]
             title='[% arialabel || l("Select Library") %]' 
             name='[% name %]'>
-    [%- 
+
+        [% IF show_lassos AND ctx.lassos.size > 0;
+            %] <optgroup label="[% l('Library Groups') %]"> [%
+            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 %]
+                <option value='[% opt_value %]' [% selected %]> 
+                    [% lasso.name | html %]
+                </option>
+            [% END %]
+            </optgroup>
+            <optgroup label="[% l('Libraries') %]">
+        [% 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;
                 [% '&nbsp;' FOR [0..pad_depth]; display_name | html %]
             </option> 
 
+        [%- END -%]
+
+        [%- IF show_lassos AND ctx.lassos.size > 0 -%]
+            </optgroup>
         [%- END %]
     </select>
 [%- END;
@@ -150,7 +175,7 @@ BLOCK build_scope_selector;
     hiding_depth = ctx.get_org_setting(ou_id, 'opac.org_unit_hiding.depth') -%]
 
     <select [% IF id %] id='[% id %]' [% END -%]
-            title='[% arialabel || l("Select Library") %]' 
+            title='[% arialabel || l("Select scoping restrictions") %]' 
             name='[% name %]'>
             <option value=''>[% l('No Restrictions') | html %]</option>
 
@@ -167,7 +192,7 @@ BLOCK build_scope_selector;
         [% END %]
         </optgroup>
 
-        [% IF ctx.lassos.size > 0;
+        [% IF show_lassos AND ctx.lassos.size > 0;
             %] <optgroup label="[% l('Library Groups') %]"> [%
             FOR lasso IN ctx.lassos;
                 opt_value = 'lasso(' _ lasso.id _ ')';
index 2e5f6e3..d574ba4 100644 (file)
@@ -97,11 +97,11 @@ END;
             l('Library: ');
             select_lib_label = l("Select search library");
             INCLUDE build_org_selector arialabel=select_lib_label 
-              id='search_org_selector' show_loc_groups=0
+              id='search_org_selector' show_loc_groups=1 show_lassos=1
         -%]
         </label>
         <label id="search_scope_label" for="search_scope_selector">
-        [%
+        [%#-
             l('Where: ');
             select_scope_label = l("Select search scope");
             INCLUDE build_scope_selector arialabel=select_scope_label value=ctx.search_scope