TPAC: Add "preferred search location" preference setting
authorDan Scott <dan@coffeecode.net>
Wed, 28 Dec 2011 23:42:18 +0000 (18:42 -0500)
committerJason Stephenson <jstephenson@mvlc.org>
Thu, 29 Dec 2011 15:13:34 +0000 (10:13 -0500)
Working towards parity with the JSPAC, give the user the ability to set
their preferred search library in account preferences via the org
selector. The value defaults to the user's home OU.

Also set a sane default of 10 search results per page in the absence of
any preference, as the default had been set to 5.

While we're in there, remove some of the inline styles and weird markup
in the user preference page, and refactor the O:W:EGCatLoader:Account
module to accept an easily-appended list of preferences to be set.

Signed-off-by: Dan Scott <dan@coffeecode.net>
Signed-off-by: Jason Stephenson <jstephenson@mvlc.org>
Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm
Open-ILS/src/templates/opac/myopac/prefs_settings.tt2

index 526fbfa..116f8c5 100644 (file)
@@ -297,6 +297,11 @@ sub _prepare_anonlist_sorting_query {
 sub load_myopac_prefs_settings {
     my $self = shift;
 
+    my @user_prefs = qw/
+        opac.hits_per_page
+        opac.default_search_location
+    /;
+
     my $stat = $self->_load_user_with_prefs;
     return $stat if $stat;
 
@@ -310,13 +315,14 @@ sub load_myopac_prefs_settings {
     my %settings;
     my $set_map = $self->ctx->{user_setting_map};
 
-    my $key = 'opac.hits_per_page';
-    my $val = $self->cgi->param($key);
-    $settings{$key}= $val unless $$set_map{$key} eq $val;
+    foreach my $key (@user_prefs) {
+        my $val = $self->cgi->param($key);
+        $settings{$key}= $val unless $$set_map{$key} eq $val;
+    }
 
     my $now = DateTime->now->strftime('%F');
-    for $key (qw/history.circ.retention_start history.hold.retention_start/) {
-        $val = $self->cgi->param($key);
+    foreach my $key (qw/history.circ.retention_start history.hold.retention_start/) {
+        my $val = $self->cgi->param($key);
         if($val and $val eq 'on') {
             # Set the start time to 'now' unless a start time already exists for the user
             $settings{$key} = $now unless $$set_map{$key};
index 0a117bb..7cb3103 100644 (file)
@@ -1,4 +1,5 @@
 [%  PROCESS "opac/parts/header.tt2";
+    PROCESS "opac/parts/org_selector.tt2";
     WRAPPER "opac/parts/myopac/prefs_base.tt2";
     myopac_page = "prefs_notify";
     prefs_page = 'settings' %]
@@ -6,15 +7,7 @@
 
     <form method='POST'>
 
-        <div style="float:right;width:65px;">
-            <div style="position:absolute">
-                <div style="position:relative;top:75px;">
-                    <input type="submit" value="[% l('Save') %]" alt="[% l('Save') %]" class="opac-button"/>
-                </div>
-            </div>
-        </div>
-
-        <table class="full-width data_grid" id="acct_search_main">
+       <table class="full-width data_grid" id="acct_search_main">
             <tbody>
 
                 [% IF ctx.updated_user_settings %]
                 <tr >
                     <td width='20%'>[% l("Search hits per page") %]</td>
                     <td>
-                        <div style="position:absolute">
-                            <div style="position:relative;top:0px;left:55px;">
-                                <a href="#"><img alt="[% l('Search Hits Help') %]" 
-                                    src="[% ctx.media_prefix %]/images/question-mark.png" /></a>
-                            </div>
-                        </div>
                         [% setting = 'opac.hits_per_page' %]
                         <select name='[% setting %]'>
-                            [%  FOR val IN [5, 8, 10, 15, 20, 25, 50] %]
+                            [%  UNLESS ctx.user_setting_map.$setting;
+                                    ctx.user_setting_map.$setting = 10;
+                                END;
+                                FOR val IN [5, 8, 10, 15, 20, 25, 50] %]
                                 <option value='[% val | uri %]' 
                                     [% IF ctx.user_setting_map.$setting == val %]
                                         selected='selected'[% END %]>[% val | html %]</option>
                             [% END %]
                         </select>
+                        <a href="#"><img alt="[% l('Search Hits Help') %]" 
+                            src="[% ctx.media_prefix %]/images/question-mark.png"
+                        /></a>
+                    </td>
+                </tr>
+                <tr >
+                    <td width='20%'>[% l("Preferred search location") %]</td>
+                    <td>
+                        [%- setting = 'opac.default_search_location';
+                            thang = ctx.user.home_ou.id;
+                            IF ctx.user_setting_map.$setting;
+                                thang = ctx.user_setting_map.$setting;
+                            END;
+                            PROCESS build_org_selector name=setting value=thang;
+                        %]
                     </td>
                 </tr>
                 <tr>
                         </select>
                     </td>
                 </tr>
-
-                <tr>
-                    <td>[% l("Default Search Location") %]</td>
-                    <td>
-                        <div style='margin-bottom: 5px;'>
-                            <input type='checkbox' id='myopac_pref_home_lib' />
-                            [% l("Search my home library by default.") %]
-                        </div>
-                        <select id='prefs_def_location'></select>
-                    </td>
-                </tr>
-
-                <tr>
-                    <td>[% l("Default Search Range") %]</td>
-                    <td>
-                        <select>
-                            [%# TODO %]
-                        </select>
-                    </td>
-                </tr>
                 -->
 
             </tbody>
         </table>
+        <input type="submit" value="[% l('Save') %]" alt="[% l('Save') %]" class="opac-button"/>
     </form>
     [% INCLUDE "opac/parts/myopac/prefs_hints.tt2" %]
 [% END %]