[open-ils-commits] [GIT] Evergreen ILS branch master updated. 97221b394a50415d9ac52efb9304b5b96d0ae581

Evergreen Git git at git.evergreen-ils.org
Wed Oct 3 14:54:26 EDT 2012


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Evergreen ILS".

The branch, master has been updated
       via  97221b394a50415d9ac52efb9304b5b96d0ae581 (commit)
      from  aed8ee4859dbe1a1b5a34f115c6a1a34e73f31cb (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 97221b394a50415d9ac52efb9304b5b96d0ae581
Author: Thomas Berezansky <tsbere at mvlc.org>
Date:   Thu May 17 10:29:58 2012 -0400

    TPac: Holds Paging
    
    Add Paging for current holds with page numbers
    
    Update Paging for hold history to include page numbers
    
    Signed-off-by: Thomas Berezansky <tsbere at mvlc.org>
    Signed-off-by: Lebbeous Fogle-Weekley <lebbeous at esilibrary.com>

diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Holds.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Holds.pm
index 1dee0c3..be54c68 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Holds.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Holds.pm
@@ -419,7 +419,8 @@ __PACKAGE__->register_method(
         desc   => "Retrieves all the holds, with hold transits attached, for the specified user.  $ses_is_req_note",
         params => [
             { desc => 'Authentication token', type => 'string'  },
-            { desc => 'User ID',              type => 'integer' }
+            { desc => 'User ID',              type => 'integer' },
+            { desc => 'Available Only',       type => 'boolean' }
         ],
         return => {
             desc => 'list of holds, event on error',
@@ -435,7 +436,8 @@ __PACKAGE__->register_method(
         desc   => "Retrieves all the hold IDs, for the specified user.  $ses_is_req_note",
         params => [
             { desc => 'Authentication token', type => 'string'  },
-            { desc => 'User ID',              type => 'integer' }
+            { desc => 'User ID',              type => 'integer' },
+            { desc => 'Available Only',       type => 'boolean' }
         ],
         return => {
             desc => 'list of holds, event on error',
@@ -477,7 +479,7 @@ __PACKAGE__->register_method(
 
 
 sub retrieve_holds {
-    my ($self, $client, $auth, $user_id) = @_;
+    my ($self, $client, $auth, $user_id, $available) = @_;
 
     my $e = new_editor(authtoken=>$auth);
     return $e->event unless $e->checkauth;
@@ -551,6 +553,11 @@ sub retrieve_holds {
 
         ];
         $holds_query->{where}->{cancel_time} = undef;
+        if($available) {
+            $holds_query->{where}->{shelf_time} = {'!=' => undef};
+            # Maybe?
+            $holds_query->{where}->{pickup_lib} = {'+ahr' => 'current_shelf_lib'};
+        }
     }
 
     my $hold_ids = $e->json_query($holds_query);
diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm
index 81edf81..91576d4 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm
@@ -454,15 +454,16 @@ sub fetch_user_holds {
         $hold_ids = $circ->request(
             'open-ils.circ.holds.id_list.retrieve.authoritative', 
             $e->authtoken, 
-            $e->requestor->id
+            $e->requestor->id,
+            $available
         )->gather(1);
         $circ->kill_me;
-    
-        $hold_ids = [ grep { defined $_ } @$hold_ids[$offset..($offset + $limit - 1)] ] if $limit or $offset;
     }
 
+    my $all_ids = $hold_ids;
+    $hold_ids = [ grep { defined $_ } @$hold_ids[$offset..($offset + $limit - 1)] ] if $limit or $offset;
 
-    return $hold_ids if $ids_only or @$hold_ids == 0;
+    return { ids => $hold_ids, all_ids => $all_ids } if $ids_only or @$hold_ids == 0;
 
     my $args = {
         suppress_notices => 1,
@@ -499,10 +500,6 @@ sub fetch_user_holds {
         last if $first and not @ses;
 
         if(@collected) {
-            # If desired by the caller, filter any holds that are not available.
-            if ($available) {
-                @collected = grep { $_->{hold}->{status} == 4 } @collected;
-            }
             while(my $blob = pop(@collected)) {
                 my (undef, @data) = $self->get_records_and_facets(
                     [$blob->{hold}->{bre_id}], undef, {flesh => '{mra}'}
@@ -528,7 +525,7 @@ sub fetch_user_holds {
         push @sorted, grep { $_->{hold}->{hold}->id == $id } @holds;
     }
 
-    return \@sorted;
+    return { holds => \@sorted, ids => $hold_ids, all_ids => $all_ids };
 }
 
 sub handle_hold_update {
@@ -539,7 +536,7 @@ sub handle_hold_update {
     my $url;
 
     my @hold_ids = ($hold_ids) ? @$hold_ids : $self->cgi->param('hold_id'); # for non-_all actions
-    @hold_ids = @{$self->fetch_user_holds(undef, 1)} if $action =~ /_all/;
+    @hold_ids = @{$self->fetch_user_holds(undef, 1)->{ids}} if $action =~ /_all/;
 
     my $circ = OpenSRF::AppSession->create('open-ils.circ');
 
@@ -609,7 +606,7 @@ sub load_myopac_holds {
     my $e = $self->editor;
     my $ctx = $self->ctx;
     
-    my $limit = $self->cgi->param('limit') || 0;
+    my $limit = $self->cgi->param('limit') || 15;
     my $offset = $self->cgi->param('offset') || 0;
     my $action = $self->cgi->param('action') || '';
     my $hold_id = $self->cgi->param('id');
@@ -618,7 +615,13 @@ sub load_myopac_holds {
     my $hold_handle_result;
     $hold_handle_result = $self->handle_hold_update($action) if $action;
 
-    $ctx->{holds} = $self->fetch_user_holds($hold_id ? [$hold_id] : undef, 0, 1, $available, $limit, $offset);
+    my $holds_object = $self->fetch_user_holds($hold_id ? [$hold_id] : undef, 0, 1, $available, $limit, $offset);
+    if($holds_object->{holds}) {
+        $ctx->{holds} = $holds_object->{holds};
+    }
+    $ctx->{holds_ids} = $holds_object->{all_ids};
+    $ctx->{holds_limit} = $limit;
+    $ctx->{holds_offset} = $offset;
 
     return defined($hold_handle_result) ? $hold_handle_result : Apache2::Const::OK;
 }
@@ -1173,12 +1176,15 @@ sub load_myopac_hold_history {
             }]
         },
         from => 'au',
-        where => {id => $e->requestor->id}, 
-        limit => $limit,
-        offset => $offset
+        where => {id => $e->requestor->id}
     });
 
-    $ctx->{holds} = $self->fetch_user_holds([map { $_->{id} } @$hold_ids], 0, 1, 0);
+    my $holds_object = $self->fetch_user_holds([map { $_->{id} } @$hold_ids], 0, 1, 0, $limit, $offset);
+    if($holds_object->{holds}) {
+        $ctx->{holds} = $holds_object->{holds};
+    }
+    $ctx->{hold_history_ids} = $holds_object->{all_ids};
+
     return Apache2::Const::OK;
 }
 
diff --git a/Open-ILS/src/templates/opac/myopac/hold_history.tt2 b/Open-ILS/src/templates/opac/myopac/hold_history.tt2
index 2c3e611..7276c9d 100644
--- a/Open-ILS/src/templates/opac/myopac/hold_history.tt2
+++ b/Open-ILS/src/templates/opac/myopac/hold_history.tt2
@@ -5,13 +5,14 @@
     myopac_page = "holds";
     limit = ctx.hold_history_limit;
     offset = ctx.hold_history_offset;
+    count = ctx.hold_history_ids.size;
 %]
 
 <div id='myopac_holds_div'>
 
     <div id="acct_holds_tabs">
         <div class="align">
-            <a href='[% mkurl('holds') %]'>[% l("Items on Hold") %]</a>
+            <a href='[% mkurl('holds',{},['limit','offset']) %]'>[% l("Items on Hold") %]</a>
         </div>
         <div class="align selected">
             <a href="#">[% l("Holds History") %]</a>
@@ -21,11 +22,22 @@
     <div class="header_middle">
         <span style="float:left;">[% l("Previously Held Items") %]</span>
         <span class='float-left' style='padding-left: 10px;'>
-            <a href='[% mkurl(hold_history, {limit => limit,offset => (offset - limit)}) %]'
+            <a href='[% mkurl('hold_history', {limit => limit,offset => (offset - limit)}) %]'
                 [% IF offset == 0 %] class='invisible' [% END %]><span class="nav_arrow_fix">&#9668;</span>[% l('Previous') %]</a>
-            [%# TODO: get total to prevent paging off then end of the list.. %]
-            <a href='[% mkurl(hold_history, {limit => limit, offset => (offset + limit)}) %]'
-               [% IF ctx.holds.size < limit %] class='invisible' [% END %] >[% l('Next') %]<span class="nav_arrow_fix">&#9658;</span></a>
+            [% IF offset > 0 || count > limit;
+                curpage = 0;
+                WHILE curpage * limit < count;
+                    IF curpage * limit == offset;
+            %]
+            [% curpage + 1 %]
+                    [%- ELSE %]
+            <a href='[% mkurl('holds_history', {limit => limit, offset => (curpage * limit)}) %]'>[% curpage + 1 %]</a>
+                    [%- END;
+                    curpage = curpage + 1;
+                END;
+            END %]
+            <a href='[% mkurl('hold_history', {limit => limit, offset => (offset + limit)}) %]'
+               [% IF count <= limit + offset %] class='invisible' [% END %] >[% l('Next') %]<span class="nav_arrow_fix">&#9658;</span></a>
         </span>
         <span style="float:right;">
             <a class="hide_me" href="#">Export List</a>
diff --git a/Open-ILS/src/templates/opac/myopac/holds.tt2 b/Open-ILS/src/templates/opac/myopac/holds.tt2
index 1a6f209..8321067 100644
--- a/Open-ILS/src/templates/opac/myopac/holds.tt2
+++ b/Open-ILS/src/templates/opac/myopac/holds.tt2
@@ -2,7 +2,11 @@
     PROCESS "opac/parts/misc_util.tt2";
     PROCESS "opac/parts/hold_status.tt2";
     WRAPPER "opac/parts/myopac/base.tt2";
-    myopac_page = "holds"  %]
+    myopac_page = "holds";
+    limit = ctx.holds_limit;
+    offset = ctx.holds_offset;
+    count = ctx.holds_ids.size;
+%]
 <div id='myopac_holds_div'>
 
     <div id="acct_holds_tabs">
@@ -10,7 +14,7 @@
             <a href='#'>[% l("Items on Hold") %]</a>
         </div>
         <div class="align">
-            <a href='[% mkurl('hold_history') %]'>[% l("Holds History") %]</a>
+            <a href='[% mkurl('hold_history', {}, ['limit','offset','available']) %]'>[% l("Holds History") %]</a>
         </div>
     </div>
 
@@ -23,6 +27,25 @@
                 END
             %]
         </span>
+        <span class='float-left' style='padding-left: 10px;'>
+            <a href='[% mkurl('holds', {limit => limit,offset => (offset - limit)}) %]'
+                [% IF offset <= 0 %] class='invisible' [% END %]><span class="nav_arrow_fix">&#9668;</span>[% l('Previous') %]</a>
+            [% IF offset > 0 || count > limit;
+                curpage = 0;
+                WHILE curpage * limit < count;
+                    IF curpage * limit == offset;
+            %]
+            [% curpage + 1 %]
+                    [%- ELSE %]
+            <a href='[% mkurl('holds', {limit => limit, offset => (curpage * limit)}) %]'>[% curpage + 1 %]</a>
+                    [%- END;
+                    curpage = curpage + 1;
+                END;
+            END %]
+            <a href='[% mkurl('holds', {limit => limit, offset => (offset + limit)}) %]'
+               [% IF count <= limit + offset %] class='invisible' [% END %] >[% l('Next') %]<span class="nav_arrow_fix">&#9658;</span></a>
+        </span>
+
         <span style="float:right;">
             <a class="hide_me" href="#">Export List</a>
         </span>
@@ -62,11 +85,11 @@
                 <td align="right">
                     [% l("Show") %] &nbsp; &nbsp;
                     [% IF CGI.param("available") %]
-                    <a href="[% mkurl('holds', {}, ['available']) %]">[% l('all') %]</a> |
+                    <a href="[% mkurl('holds', {},['limit','offset','available']) %]">[% l('all') %]</a> |
                     <strong>[% l("only available") %]</strong>
                     [% ELSE %]
                     <strong>[% l("all") %]</strong> |
-                    <a href="[% mkurl('holds', {available => 1}) %]">[% l("only available") %]</a>
+                    <a href="[% mkurl('holds', {available => 1}, ['limit','offset']) %]">[% l("only available") %]</a>
                     [% END %] &nbsp; &nbsp;
                     [% l("holds") %]
                     <select class="hide_me" id="holds_sort">

-----------------------------------------------------------------------

Summary of changes:
 .../perlmods/lib/OpenILS/Application/Circ/Holds.pm |   13 +++++--
 .../lib/OpenILS/WWW/EGCatLoader/Account.pm         |   38 +++++++++++--------
 .../src/templates/opac/myopac/hold_history.tt2     |   22 +++++++++---
 Open-ILS/src/templates/opac/myopac/holds.tt2       |   31 ++++++++++++++--
 4 files changed, 76 insertions(+), 28 deletions(-)


hooks/post-receive
-- 
Evergreen ILS


More information about the open-ils-commits mailing list