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)
committerDan Wells <dbw2@calvin.edu>
Fri, 13 Sep 2013 19:22:36 +0000 (15:22 -0400)
Added a user setting for the number of lists per page.
Added code for page number navigation.

Signed-off-by: Kyle Tomita <ktomita@catalystitservices.com>
Signed-off-by: Dan Wells <dbw2@calvin.edu>
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

index 6acb39e..c9d53ae 100644 (file)
@@ -470,6 +470,7 @@ sub load_myopac_prefs_my_lists {
     my $self = shift;
 
     my @user_prefs = qw/
+        opac.lists_per_page
         opac.list_items_per_page
     /;
 
@@ -1737,6 +1738,22 @@ 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 _get_items_per_page {
     my $self = shift;
 
@@ -1757,7 +1774,7 @@ 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 77cdf76..328ce33 100644 (file)
@@ -2558,6 +2558,25 @@ INSERT INTO config.usr_setting_type (name,opac_visible,label,description,datatyp
 
 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.list_items_per_page',
         TRUE,
         oils_i18n_gettext(
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 3be190f..22b3bd9 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 (offset - (limit * 3)) >= 0 -%]
+                <a href='[% mkurl(ctx.opac_root _ '/myopac/lists', {
+                    offset => (offset - (limit * 3))
+                }) %]'>[% ((offset - (limit * 3)) / limit) + 1 %]</a>
+            [%- END; -%]
+            [%- IF (offset - (limit * 2)) >= 0 -%]
+                <a href='[% mkurl(ctx.opac_root _ '/myopac/lists', {
+                    offset => (offset - (limit * 2))
+                }) %]'>[% ((offset - (limit * 2)) / limit) + 1 %]</a>
+            [%- END; -%]
+            [%- IF (offset - limit) >= 0 -%]
+                <a href='[% mkurl(ctx.opac_root _ '/myopac/lists', {
+                    offset => (offset - limit)
+                }) %]'>[% ((offset - limit) / limit) + 1 %]</a>
+            [%- END; -%]
+            <span style="color:red;" >[% (offset / limit) + 1 %]</span>
+            [%- IF (offset + limit) <= ctx.bookbag_count -%]
+                <a href='[% mkurl(ctx.opac_root _ '/myopac/lists', {
+                    offset => (offset + limit)
+                }) %]'>[% ((offset + limit) / limit) + 1 %]</a>
+            [%- END; -%]
+            [%- IF (offset + (limit * 2)) <= ctx.bookbag_count -%]
+                <a href='[% mkurl(ctx.opac_root _ '/myopac/lists', {
+                    offset => (offset + (limit * 2))
+                }) %]'>[% ((offset + (limit * 2)) / limit) + 1 %]</a>
+            [%- END; -%]
+            [%- IF (offset + (limit * 3)) <= ctx.bookbag_count -%]
+                <a href='[% mkurl(ctx.opac_root _ '/myopac/lists', {
+                    offset => (offset + (limit * 3))
+                }) %]'>[% ((offset + (limit * 3)) / limit) + 1 %]</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; -%]
index 746df98..69106a4 100644 (file)
                 </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>
                 [%- setting = 'opac.list_items_per_page' -%]
                 <tr >
                     <td width='20%'><label for='[% setting %]'>[%l("List items per page") %]</label></td>