Add BooPAC support for Library Groups (lassos)
authorMike Rylander <mrylander@gmail.com>
Fri, 13 Nov 2020 20:30:41 +0000 (15:30 -0500)
committerGalen Charlton <gmc@equinoxinitiative.org>
Thu, 11 Mar 2021 18:18:28 +0000 (13:18 -0500)
Signed-off-by: Mike Rylander <mrylander@gmail.com>
Signed-off-by: Terran McCanna <tmccanna@georgialibraries.org>
Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org>
Open-ILS/src/templates-bootstrap/opac/parts/advanced/search.tt2
Open-ILS/src/templates-bootstrap/opac/parts/config.tt2
Open-ILS/src/templates-bootstrap/opac/parts/org_selector.tt2
Open-ILS/src/templates-bootstrap/opac/parts/searchbar.tt2

index 4f4ff73..9e97ddd 100755 (executable)
@@ -85,7 +85,8 @@
         <div class='col-12 my-2'>
             <div [% IF adv_chunk.js_only %] id='adv_chunk_[% adv_chunk.adv_special %]' class='hidden' [% END %]>
                 <strong><label for="[% adv_chunk.id %]"> [% adv_chunk.adv_label %] </label></strong>
-                    [% IF adv_chunk.adv_special == "lib_selector"; PROCESS "opac/parts/org_selector.tt2"; INCLUDE build_org_selector show_loc_groups=1 id=adv_chunk.id %]
+                    [% IF adv_chunk.adv_special == "lib_selector"; PROCESS "opac/parts/org_selector.tt2"; INCLUDE build_org_selector show_loc_groups=0 show_lassos=0 id=adv_chunk.id %]
+                    [% ELSIF adv_chunk.adv_special == "scope_selector"; PROCESS "opac/parts/org_selector.tt2"; INCLUDE build_scope_selector show_loc_groups=1 show_lassos=1 id=adv_chunk.id %]
                     [% ELSIF adv_chunk.adv_special == "pub_year"; %]
                     <div id='adv_special_block' class="text-center form-inline">
                             <select name='pubdate' class='form-control' id="[% adv_chunk.id %]" onchange='if(this.selectedIndex == 3) $("#adv_global_pub_date_2_span").removeClass("hide_me"); else $("#adv_global_pub_date_2_span").addClass("hide_me");'>
index 68ee267..6e45668 100755 (executable)
@@ -149,6 +149,7 @@ search.adv_config = [
     {adv_label => l("Literary Form"), adv_attr => "lit_form", id => 'adv_selector_lit_form'},
     {adv_label => l("Shelving Location"), adv_special => "copy_location", id => 'adv_copy_location_selector', js_only => 101, adv_break => 1},
     {adv_label => l("Search Library"), adv_special => "lib_selector", id => 'adv_org_selector'},
+    {adv_label => l("Where"), adv_special => "scope_selector", id => 'adv_scope_selector'},
     {adv_label => l("Publication Year"), adv_special => "pub_year", id => 'adv_selector_pub_year'},
     {adv_label => l("Sort Results"), adv_special => "sort_selector", id => 'adv_selector_sort_results'},
 ];
index e368399..89d5f6c 100755 (executable)
@@ -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 %]' class="form-control w-100">
-    [%-
+
+        [% 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,75 @@ 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;
+
+BLOCK build_scope_selector;
+    IF !name;
+        name = id;
+    END;
+    IF !value;
+        value = loc_value;
+    END;
+
+    ou_id = ctx.search_ou;
+    context_org = ctx.get_aou(ou_id);
+
+    # if the selected org unit is out of hiding scope,
+    # disable the ou-hide scoping altogether.
+    hiding_disabled = ctx.org_hiding_disabled(value);
+    hiding_depth = ctx.get_org_setting(ou_id, 'opac.org_unit_hiding.depth') -%]
+
+    <select [% IF id %] id='[% id %]' [% END -%]
+            title='[% arialabel || l("Select scoping restrictions") %]'
+            name='[% name %]' class="form-control w-100">
+            <option value=''>[% l('No Restrictions') | html %]</option>
+
+        <optgroup label="[% l('Search Scope') %]"> [%
+        FOR d IN ctx.sorted_aout_list(); # sorts by depth and opac_label
+            NEXT IF !hiding_disabled AND hiding_depth > 0 AND d.depth < hiding_depth;
+            NEXT IF d.depth > context_org.ou_type.depth; # only show ancestors-and-self
+            opt_value = 'depth(' _ d.depth _ ')';
+            selected = '';
+            IF value == opt_value; selected = 'selected="selected"'; END %]
+            <option value='[% opt_value %]' [% selected %]>
+                [% d.opac_label | html %]
+            </option>
+        [% END %]
+        </optgroup>
+
+        [% IF show_lassos AND ctx.lassos.size > 0;
+            %] <optgroup label="[% l('Library Groups') %]"> [%
+            FOR lasso IN ctx.lassos;
+                opt_value = 'lasso(' _ lasso.id _ ')';
+                selected = '';
+                IF value == opt_value; selected = 'selected="selected"'; END %]
+                <option value='[% opt_value %]' [% selected %]>
+                    [% lasso.name | html %]
+                </option>
+            [% END %]
+            </optgroup>
+        [% END;
+
+        IF show_loc_groups AND ctx.copy_location_groups.size > 0;
+            %] <optgroup label="[% l('Location Groups') %]"> [%
+            FOR lc_ou_id IN ctx.copy_location_groups.keys;
+                FOR grp IN ctx.copy_location_groups.$lc_ou_id;
+                    opt_value = 'location_groups(' _ grp.id _ ')';
+                    selected = '';
+                    IF value == opt_value; selected = 'selected="selected"'; END %]
+                    <option value='[% opt_value %]' [% selected %]>
+                        [% grp.name | html %]
+                    </option>
+                [% END %]
+            [% END %]
+            </optgroup>
+        [% END %]
+
+    </select>
 [%- END %]
index 433b2fa..696882e 100755 (executable)
@@ -3,7 +3,7 @@
 
 # We need to ignore some filters in our count
 
-fignore = ['location_groups','site','core_limit','limit','badge_orgs','badges','estimation_strategy','depth'];
+fignore = ['lasso','location_groups','site','core_limit','limit','badge_orgs','badges','estimation_strategy','depth'];
 fcount = 0;
 FOR f IN ctx.query_struct.filters;
     IF fignore.grep('^' _ f.name _ '$').size;
@@ -105,7 +105,7 @@ 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=1
+              id='search_org_selector' show_loc_groups=1 show_lassos=1
         -%]
         </label>
         </div>