LP1164197 - Add page number navigation to my lists and setting for number of lists...
authorKyle Tomita <ktomita@catalystitservices.com>
Thu, 4 Apr 2013 00:07:51 +0000 (17:07 -0700)
committerKyle Tomita <ktomita@catalystitservices.com>
Thu, 4 Apr 2013 00:07:51 +0000 (17:07 -0700)
Added a user setting for the number of lists per page.

Signed-off-by: Kyle Tomita <ktomita@catalystitservices.com>
Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader.pm
Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm
Open-ILS/src/sql/Pg/950.data.seed-values.sql
Open-ILS/src/sql/Pg/upgrade/XXXX.add_setting_for_selecting_lists_per_page_for_my_list.sql [new file with mode: 0644]
Open-ILS/src/templates/opac/myopac/lists.tt2
Open-ILS/src/templates/opac/myopac/prefs_my_lists.tt2 [new file with mode: 0644]
Open-ILS/src/templates/opac/myopac/prefs_settings.tt2
Open-ILS/src/templates/opac/parts/myopac/prefs_base.tt2

index 0838a29..38cbbbd 100644 (file)
@@ -191,6 +191,7 @@ sub load {
     return $self->load_myopac_hold_history if $path =~ m|opac/myopac/hold_history|;
     return $self->load_myopac_prefs_notify if $path =~ m|opac/myopac/prefs_notify|;
     return $self->load_myopac_prefs_settings if $path =~ m|opac/myopac/prefs_settings|;
+    return $self->load_myopac_prefs_my_lists if $path =~ m|opac/myopac/prefs_my_lists|;
     return $self->load_myopac_prefs if $path =~ m|opac/myopac/prefs|;
     return $self->load_sms_cn if $path =~ m|opac/sms_cn|;
 
index ec7bb96..00c8eae 100644 (file)
@@ -437,6 +437,42 @@ sub load_myopac_prefs_settings {
     return $self->_load_user_with_prefs || Apache2::Const::OK;
 }
 
+sub load_myopac_prefs_my_lists {
+    my $self = shift;
+
+    my @user_prefs = qw/
+        opac.lists_per_page
+    /;
+
+    my $stat = $self->_load_user_with_prefs;
+    return $stat if $stat;
+
+    return Apache2::Const::OK
+        unless $self->cgi->request_method eq 'POST';
+
+    # some setting values from the form don't match the
+    # required value/format for the db, so they have to be
+    # individually translated.
+
+    my %settings;
+    my $set_map = $self->ctx->{user_setting_map};
+
+    foreach my $key (@user_prefs) {
+        my $val = $self->cgi->param($key);
+        $settings{$key}= $val unless $$set_map{$key} eq $val;
+    }
+
+    # Send the modified settings off to be saved
+    $U->simplereq(
+        'open-ils.actor',
+        'open-ils.actor.patron.settings.update',
+        $self->editor->authtoken, undef, \%settings);
+
+    # re-fetch user prefs
+    $self->ctx->{updated_user_settings} = \%settings;
+    return $self->_load_user_with_prefs || Apache2::Const::OK;
+}
+
 sub fetch_user_holds {
     my $self = shift;
     my $hold_ids = shift;
@@ -1676,11 +1712,27 @@ sub _update_bookbag_metadata {
     return 0;
 }
 
+sub _get_lists_per_page {
+    my $self = shift;
+
+    if($self->editor->requestor) {
+        $self->timelog("Checking for opac.lists_per_page preference");
+        # See if the user has a lists per page preference
+        my $ipp = $self->editor->search_actor_user_setting({
+            usr => $self->editor->requestor->id,
+            name => 'opac.lists_per_page'
+        })->[0];
+        $self->timelog("Got opac.lists_per_page preference");
+        return OpenSRF::Utils::JSON->JSON2perl($ipp->value) if $ipp;
+    }
+    return 10; # default
+}
+
 sub load_myopac_bookbags {
     my $self = shift;
     my $e = $self->editor;
     my $ctx = $self->ctx;
-    my $limit = $self->cgi->param('limit') || 10;
+    my $limit = $self->_get_lists_per_page || 10;
     my $offset = $self->cgi->param('offset') || 0;
 
     $ctx->{bookbags_limit} = $limit;
index d693e6c..454357b 100644 (file)
@@ -2481,6 +2481,25 @@ INSERT INTO config.usr_setting_type (name,opac_visible,label,description,datatyp
     VALUES ('opac.hits_per_page', TRUE, 'Hits per Page', 'Hits per Page', 'string');
 
 INSERT INTO config.usr_setting_type (name,opac_visible,label,description,datatype)
+    VALUES (
+        'opac.lists_per_page',
+        TRUE,
+        oils_i18n_gettext(
+            'opac.lists_per_page',
+            'Lists per Page',
+            'cust',
+            'label'
+        ),
+        oils_i18n_gettext(
+            'opac.lists_per_page',
+            'A number designating the amount of lists displayed per page.',
+            'cust',
+            'description'
+        ),
+        'string'
+    );
+
+INSERT INTO config.usr_setting_type (name,opac_visible,label,description,datatype)
     VALUES ('opac.hold_notify', TRUE, 'Hold Notification Format', 'Hold Notification Format', 'string');
 
 INSERT INTO config.usr_setting_type (name,opac_visible,label,description,datatype)
diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.add_setting_for_selecting_lists_per_page_for_my_list.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.add_setting_for_selecting_lists_per_page_for_my_list.sql
new file mode 100644 (file)
index 0000000..3af2a12
--- /dev/null
@@ -0,0 +1,29 @@
+-- Evergreen DB patch XXXX.add_setting_for_selecting_lists_per_page_for_my_list.sql
+--
+-- Adds a setting for selecting the number of lists per page for my list.
+--
+BEGIN;
+
+-- check whether patch can be applied
+SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version);
+
+INSERT INTO config.usr_setting_type (name,opac_visible,label,description,datatype)
+    VALUES (
+        'opac.lists_per_page',
+        TRUE,
+        oils_i18n_gettext(
+            'opac.lists_per_page',
+            'Lists per Page',
+            'cust',
+            'label'
+        ),
+        oils_i18n_gettext(
+            'opac.lists_per_page',
+            'A number designating the amount of lists displayed per page.',
+            'cust',
+            'description'
+        ),
+        'string'
+    );
+    
+COMMIT;
index 0b2977d..5f7dc2d 100644 (file)
         <span class='float-left' style='padding-left: 10px;'>
             [%- IF offset > 0 -%]
                 <a href='[% mkurl(ctx.opac_root _ '/myopac/lists', {
-                    limit => limit, offset => (offset - limit)
+                    offset => (offset - limit)
                 }) %]'><span class="nav_arrow_fix">&#9668;</span>[% l('Previous') %]</a>
             [%- END; -%]
             [%- IF (ctx.bookbag_count - offset) > limit; -%] 
                 <a href='[% mkurl(ctx.opac_root _ '/myopac/lists', {
-                    limit => limit, offset => (offset + limit)
+                    offset => (offset + limit)
                 }) %]'>[% l('Next') %]<span class="nav_arrow_fix">&#9658;</span></a>
             </span>
             [%- END; -%]
diff --git a/Open-ILS/src/templates/opac/myopac/prefs_my_lists.tt2 b/Open-ILS/src/templates/opac/myopac/prefs_my_lists.tt2
new file mode 100644 (file)
index 0000000..3e92a52
--- /dev/null
@@ -0,0 +1,45 @@
+[%  PROCESS "opac/parts/header.tt2";
+    WRAPPER "opac/parts/myopac/prefs_base.tt2";
+    myopac_page = "prefs";
+    prefs_page = 'my_lists' %]
+
+
+    <form method='post'>
+
+       <table class="full-width data_grid" id="acct_search_main">
+            <tbody>
+
+                [% IF ctx.updated_user_settings %]
+                <tr><td colspan='2'>
+                    <div class='renew-summary'>
+                        [% l('Account Successfully Updated') %]
+                    </div>
+                </td></tr>
+                [% END %]
+
+                [%- setting = 'opac.lists_per_page' -%]
+                <tr >
+                    <td width='20%'><label for='[% setting %]'>[%l("Lists per page") %]</label></td>
+                    <td>
+                        <select id='[% setting %]' name='[% setting %]'>
+                            [%  UNLESS ctx.user_setting_map.$setting;
+                                    ctx.user_setting_map.$setting = 10;
+                                END;
+                                FOR val IN [10, 15, 20, 25] %]
+                                <option value='[% val | uri %]' 
+                                    [% IF ctx.user_setting_map.$setting == val %]
+                                        selected='selected'[% END %]>[% val | html %]</option>
+                            [% END %]
+                        </select>
+                        <img alt="[% l('List Items Help') %]"
+                            src="[% ctx.media_prefix %]/images/question-mark.png"
+                            title="[% l('The number of lists displayed per page.') %]"
+                        />
+                    </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 %]
\ No newline at end of file
index 7f682a2..7b27be7 100644 (file)
@@ -20,7 +20,7 @@
 
                 [%- setting = 'opac.hits_per_page' -%]
                 <tr >
-                    <td width='20%'><label for='[% setting %]'>l("Search hits per page") %]</label></td>
+                    <td width='20%'><label for='[% setting %]'>[% l("Search hits per page") %]</label></td>
                     <td>
                         <select id='[% setting %]' name='[% setting %]'>
                             [%  UNLESS ctx.user_setting_map.$setting;
index 5f3a154..031da15 100644 (file)
@@ -15,6 +15,9 @@
             <div class="align">
                 <a href='[% mkurl('prefs_settings') %]'>[% l("Search and History Preferences") %]</a>
             </div>
+            <div class="align">
+                <a href='[% mkurl('prefs_my_lists') %]'>[% l("My Lists Preferences") %]</a>
+            </div>
         [% ELSIF prefs_page == 'notify' %]
             <div class="align">
                 <a href='[% mkurl('prefs') %]'>[% l("Personal Information") %]</a>
             <div class="align" >
                 <a href='[% mkurl('prefs_settings') %]'>[% l("Search and History Preferences") %]</a>
             </div>
-        [% ELSE %]
+            <div class="align">
+                <a href='[% mkurl('prefs_my_lists') %]'>[% l("My Lists Preferences") %]</a>
+            </div>
+        [% ELSIF prefs_page == 'settings' %]
             <div class="align">
                 <a href='[% mkurl('prefs') %]'>[% l("Personal Information") %]</a>
             </div>
             <div class="align selected" >
                 <a href='#'>[% l("Search and History Preferences") %]</a>
             </div>
+            <div class="align">
+                <a href='[% mkurl('prefs_my_lists') %]'>[% l("My Lists Preferences") %]</a>
+            </div>
+        [% ELSE %]
+            <div class="align">
+                <a href='[% mkurl('prefs') %]'>[% l("Personal Information") %]</a>
+            </div>
+            <div class="align">
+                <a href='[% mkurl('prefs_notify') %]'>[% l("Notification Preferences") %]</a>
+            </div>
+            <div class="align" >
+                <a href='[% mkurl('prefs_settings') %]'>[% l("Search and History Preferences") %]</a>
+            </div>
+            <div class="align selected">
+                <a href='#'>[% l("My Lists Preferences") %]</a>
+            </div>
         [% END %]
         </div>
     </div>