copy loc groups: tpac
authorBill Erickson <berick@esilibrary.com>
Mon, 20 Feb 2012 19:48:45 +0000 (14:48 -0500)
committerBill Erickson <berick@esilibrary.com>
Mon, 20 Feb 2012 19:48:45 +0000 (14:48 -0500)
* added 'locg' param to org selector which contains location:copy_loc_group
* determine 'loc' from 'locg' if set
* for consistency, use ctx.search_ou everywhere instead of
cgi.param('loc')

Signed-off-by: Bill Erickson <berick@esilibrary.com>
15 files changed:
Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader.pm
Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm
Open-ILS/src/templates/opac/advanced.tt2
Open-ILS/src/templates/opac/myopac/prefs_notify.tt2
Open-ILS/src/templates/opac/parts/advanced/expert.tt2
Open-ILS/src/templates/opac/parts/advanced/search.tt2
Open-ILS/src/templates/opac/parts/org_selector.tt2
Open-ILS/src/templates/opac/parts/place_hold.tt2
Open-ILS/src/templates/opac/parts/preserve_params.tt2
Open-ILS/src/templates/opac/parts/record/copy_counts.tt2
Open-ILS/src/templates/opac/parts/record/copy_table.tt2
Open-ILS/src/templates/opac/parts/record/refworks.tt2
Open-ILS/src/templates/opac/parts/record/series.tt2
Open-ILS/src/templates/opac/parts/record/subjects.tt2
Open-ILS/src/templates/opac/parts/searchbar.tt2

index 9f4a642..5546e4b 100644 (file)
@@ -251,11 +251,15 @@ sub load_common {
             return $self->load_logout($self->apache->unparsed_uri);
         }
     }
-    $ctx->{search_ou} = $self->_get_search_lib();
 
-    $self->staff_saved_searches_set_expansion_state if $ctx->{is_staff};
+    # load copy location search groups and see if there is a "logc" 
+    # paremeter set.  If so, use it to set/override the "loc" parameter
+    # as well as the copy_location_group context var
     $self->load_copy_location_groups;
 
+    $ctx->{search_ou} = $self->_get_search_lib();
+    $self->staff_saved_searches_set_expansion_state if $ctx->{is_staff};
+
     return Apache2::Const::OK;
 }
 
@@ -283,12 +287,24 @@ sub staff_saved_searches_set_expansion_state {
     $self->ctx->{saved_searches_expanded} = $value;
 }
 
+# If "locg" is set, we extract the org unit and copy location.  
+# The org unit from 'locg' overrides the local CGI variable 'loc'.
+# Overridding it here will not override it globaly though (i.e. in 
+# the template environment), unless the same CGI ref is used everywhere,
+# which is usually isn't.  To be safe, always use ctx.search_ou 
+# to determine the context org unit.
 sub load_copy_location_groups {
     my $self = shift;
     my $grps = $self->editor->search_asset_copy_location_group({opac_visible => 't'});
     my %buckets;
     push(@{$buckets{$_->owner}}, $_) for @$grps;
     $self->ctx->{copy_location_groups} = \%buckets;
+
+    if (my $clump = $self->cgi->param('locg')) {
+        my ($org, $grp) = split(/:/, $clump);
+        $self->ctx->{copy_location_group} = $grp if $grp;
+        $self->cgi->param('loc', $org); 
+    }
 }
 
 # physical_loc (i.e. "original location") passed in as a URL 
index b8907a6..ecf8ef0 100644 (file)
@@ -112,6 +112,10 @@ sub _prepare_biblio_search {
         $query .= " site($site)";
     }
 
+    if (my $grp = $ctx->{copy_location_group}) {
+        $query .= " location_groups($grp)";
+    }
+
     if(!$site) {
         ($site) = ($query =~ /site\(([^\)]+)\)/);
         $site ||= $ctx->{aou_tree}->()->shortname;
index 17cb74f..220c56f 100644 (file)
@@ -1,9 +1,9 @@
-[%-  PROCESS "opac/parts/header.tt2";
+[%- PROCESS "opac/parts/header.tt2";
     WRAPPER "opac/parts/base.tt2";
     INCLUDE "opac/parts/topnav.tt2";
     ctx.page_title = l("Advanced Search");
     pane = CGI.param("pane") || "advanced";
-    loc = CGI.param("loc");
+    loc = ctx.search_ou;
 -%]
     <div id="search-wrapper">
         <div id="search-box">
index 7d23021..aeaaa41 100644 (file)
@@ -51,7 +51,7 @@
                         [% IF ctx.user_setting_map.$setting; %] value='[% ctx.user_setting_map.$setting | html %]' [% END %]/>
                 </td>
             </tr>
-            [% IF ctx.get_org_setting(CGI.param('loc') OR ctx.aou_tree.id, 'sms.enable') == 1 %]
+            [% IF ctx.get_org_setting(ctx.search_ou, 'sms.enable') == 1 %]
             <tr>
                 <td>[% l('Notify by Text by default when a hold is ready for pickup?') %]</td>
                 <td>
index 24fbd1c..da8bba6 100644 (file)
@@ -1,4 +1,3 @@
-[% loc = CGI.param("loc") %]
 <form action="[% ctx.opac_root %]/results" method="GET">
     <div class="header_middle">[% l("Expert Search") %]</div>
     <input type="hidden" name="_special" value="1" />
index f14aaa8..6b62221 100644 (file)
@@ -67,7 +67,7 @@
                         <td valign='top'>
                             <strong>[% l("Search Library") %]</strong><br />
                             [% PROCESS "opac/parts/org_selector.tt2";
-                                PROCESS build_org_selector name='loc' value=ctx.search_ou %]
+                                PROCESS build_org_selector show_loc_groups=1 %]
                             <div style="position:relative;top:7px;">
                                 <input type='checkbox' name="modifier"
                                     value="available"[% CGI.param('modifier').grep('available').size ? ' checked="checked"' : '' %]
index 3f8b754..aadb6db 100644 (file)
@@ -4,7 +4,18 @@
 #       value=org_id show_loc_groups=1/0 can_have_vols_only=1/0
 
 BLOCK build_org_selector;
-    node_stack = [{org => org_unit || ctx.aou_tree}] %]
+    node_stack = [{org => org_unit || ctx.aou_tree}];
+    IF !name; 
+        name = 'loc';
+        IF show_loc_groups; name = 'locg'; END;
+    END;
+    IF !value;
+        value = ctx.search_ou;
+        IF show_loc_groups; 
+            value = CGI.param('locg'); 
+        END;
+    END;
+    %]
 
     <select [% IF id %] id='[% id %]' [% END %] name='[% name %]'>
     [% 
@@ -29,13 +40,16 @@ BLOCK build_org_selector;
                 END;
             END;
 
+            node_value = ou_id;
+            IF loc_grp; node_value = node_value _ ':' _ loc_grp.id; END;
+
             IF can_have_vols_only AND org_unit.ou_type.can_have_vols != 't';
                 disabled = 'disabled="disabled"';
-            ELSIF ou_id == value; # TODO: test for copy_loc value
+            ELSIF node_value == value;
                 selected = 'selected="selected"';
             END %] 
 
-            <option value='[% org_unit.id | uri %]' [% selected %] [% disabled %]> 
+            <option value='[% node_value %]' [% selected %] [% disabled %]> 
             [%
                 # loc_grp's are displayed as children of the current org
                 depth = org_unit.ou_type.depth;
@@ -45,7 +59,6 @@ BLOCK build_org_selector;
                 loc_grp ? loc_grp.name : org_unit.name | html ;
             %]
             </option> 
-
             [%
         END;
     %]
index bd95814..97ffe96 100644 (file)
@@ -83,7 +83,7 @@
                     [% l('Phone Number:') %]<input type="text" name="phone_notify" [% setting = 'opac.default_phone';
                     IF ctx.user_setting_map.$setting; %] value='[% ctx.user_setting_map.$setting | html %]' [% END %]/>
                 </blockquote>
-                [% IF ctx.get_org_setting(CGI.param('loc') OR ctx.aou_tree.id, 'sms.enable') == 1 %]
+                [% IF ctx.get_org_setting(ctx.search_ou, 'sms.enable') == 1 %]
                 <input type="checkbox" name="sms_notify_checkbox"
                     [% IF ctx.default_sms_notify %]checked="checked"[% END %]/>
                     [% l('Yes, by Text Messaging') %]<br/>
index 14fe5be..3517f58 100644 (file)
@@ -1,6 +1,6 @@
 [%- 
 UNLESS params;
-    params = ['loc', 'query', 'qtype', 'sort'];
+    params = ['locg', 'loc', 'query', 'qtype', 'sort'];
 END;
 FOR param IN params;
     IF CGI.param(param); %]
index 9d85ae7..defa0ae 100644 (file)
@@ -10,7 +10,7 @@
     <li>
     [% l('[quant,_1,copy,copies] at [_2].', ou_avail, ctx.get_aou(ou_id).name)
         | html %]
-    [%- IF ou_avail > 0 && ou_id != CGI.param('loc'); %]
+    [%- IF ou_avail > 0 && ou_id != ctx.search_ou; %]
     <a href="[% mkurl('', {loc => ou_id}); %]"
        title="[% l('Show copies at [_1]', ctx.get_aou(ou_id).name); %]">
        [%- l('(Show)'); %]</a>
index 8148dd9..240f970 100644 (file)
@@ -54,7 +54,7 @@ END;
                 org_name | html
             -%]
             </td>
-            <td header='copy_header_callnumber'>[% callnum | html %] [% IF ctx.get_org_setting(CGI.param('loc') OR ctx.aou_tree.id, 'sms.enable') == 1 %](<a href="[% mkurl(ctx.opac_root _ '/sms_cn', {copy_id => copy_info.id}) %]">Text</a>)[% END %]</td>
+            <td header='copy_header_callnumber'>[% callnum | html %] [% IF ctx.get_org_setting(ctx.search_ou, 'sms.enable') == 1 %](<a href="[% mkurl(ctx.opac_root _ '/sms_cn', {copy_id => copy_info.id}) %]">Text</a>)[% END %]</td>
             [%- IF has_parts == 'true' %]
             <td header='copy_header_part'>[% copy_info.part_label | html %]</td>
             [%- END %]
index 928ce90..ed02a74 100644 (file)
@@ -1,9 +1,6 @@
 [%
     # Default to the root of the org unit tree in the absence of a specific library
-    loc = ctx.aou_tree.id;
-    IF CGI.param('loc');
-        loc = CGI.param('loc');
-    END;
+    loc = ctx.search_ou;
 
     # Get the full name of the library
     ou_name = ctx.get_aou(loc).name | uri;
index 06def16..4695768 100644 (file)
@@ -1,6 +1,6 @@
 [% 
     series_tags = ['440', '490', '800', '810', '811', '830', '694']; 
-    loc = CGI.param('loc');
+    loc = ctx.search_ou;
 %]
 
 [% BLOCK render_series;
index df06100..c91b834 100644 (file)
@@ -28,7 +28,6 @@
     ];
 
     BLOCK render_subject;
-        loc = CGI.param('loc') | uri;
         xpath = xpath || '//*[starts-with(@tag,"6")]';
         FOR node IN ctx.marc_xml.findnodes(xpath);
             all_terms = [];
index 97d709e..c16db2e 100644 (file)
@@ -21,7 +21,7 @@
                 x-webkit-speech />
         </span>
         [%- INCLUDE "opac/parts/qtype_selector.tt2";
-            l(' in '); PROCESS build_org_selector name='loc' value=ctx.search_ou show_loc_groups=1;
+            l(' in '); PROCESS build_org_selector show_loc_groups=1;
     %]
     <span>
         <input id='search-submit-go' type="submit" value="[% l('Search') %]" alt="[% l('Search') %]" class="opac-button"