Working bookbag sorting TODO: check anon list retrieval/sorting
authorLebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Wed, 10 Aug 2011 18:25:58 +0000 (14:25 -0400)
committerLebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Wed, 31 Aug 2011 17:24:38 +0000 (13:24 -0400)
Signed-off-by: Lebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm
Open-ILS/web/templates/default/opac/myopac/lists.tt2
Open-ILS/web/templates/default/opac/parts/advanced/search.tt2
Open-ILS/web/templates/default/opac/parts/filtersort.tt2

index c8cf984..adde100 100644 (file)
@@ -1205,6 +1205,9 @@ sub load_myopac_bookbags {
     my $e = $self->editor;
     my $ctx = $self->ctx;
 
+    my $sorter = $self->cgi->param("sort");
+    my $modifier = ($sorter =~ /\.(.+$)/) ? $1 : undef;
+
     $e->xact_begin; # replication...
 
     my $rv = $self->load_mylist;
@@ -1237,7 +1240,10 @@ sub load_myopac_bookbags {
 
     foreach my $bookbag (@{$ctx->{bookbags}}) {
         my $query = sprintf(
-            "container(bre,bookbag,%d,%s)", $bookbag->id, $e->authtoken
+            "container(bre,bookbag,%d,%s)%s%s",
+            $bookbag->id, $e->authtoken,
+            ($sorter ? " sort($sorter)" : ""),
+            ($modifier ? "#$modifier" : "")
         );
         my $results = $U->simplereq(
             "open-ils.search", "open-ils.search.biblio.multiclass.query",
@@ -1247,6 +1253,12 @@ sub load_myopac_bookbags {
         # now we have record ids, but we need the cbrebi objects too
         my $record_id_list = [ map { pop @$_ } @{$results->{ids}} ];
 
+        # We're done with this bookbag if it has no items
+        unless (@$record_id_list) {
+            $bookbag->items([]);
+            next;
+        }
+
         my $items = $e->search_container_biblio_record_entry_bucket_item([
             {
                 "target_biblio_record_entry" => $record_id_list,
index 303bb1a..3708751 100644 (file)
         </table>
     </form>
 
+    <h2>[% l("Your existing lists") %]</h2>
+    <p>
+        <form method="GET">
+            <label for="opac.result.sort">[% l("Sort list items by: ") %]</label>
+            [% INCLUDE "default/opac/parts/filtersort.tt2"
+                value=CGI.param('sort') %]
+            <input type="submit" value="[% l('Sort') %]" />
+        </form>
+    </p>
+
     [% INCLUDE "default/opac/parts/anon_list.tt2" %]
     [% IF ctx.bookbags.size %]
     <div id='acct_lists_prime'>
                                     inputs[i].checked = this.checked;}"/>
 
                         </td>
-                        <td width="49%" style="padding-left: 5px;">[% l('Title') %]</td>
-                        <td width="49%">[% l('Author(s)') %]</td>
+                        <td width="49%" style="padding-left: 5px;">
+                            <a href="[% ctx.opac_root %]/myopac/lists?sort=titlesort">[% l('Title') %]</a>
+                        </td>
+                        <td width="49%">
+                            <a href="[% ctx.opac_root %]/myopac/lists?sort=authorsort">[% l('Author(s)') %]</a>
+                        </td>
                         <td width="1%" class="nowrap">
                             <select class="opac-auto-179" name="action">
                                 <option>[% l('-- Actions for this list --') %]</option>
                 </tbody>
             </table>
             </form>
-            <br /><br />
+            <hr /><br />
         </div>
         [% END %]
     </div>
index 5762ead..3da7b46 100644 (file)
@@ -66,7 +66,7 @@
                 <tr>
                     <td align='center' width='100%'>
                         [% INCLUDE "default/opac/parts/filtersort.tt2"
-                            value=CGI.param('sort') %]
+                            value=CGI.param('sort') class='results_header_sel' %]
                     </td>
                 </tr>
               </table>
index 428626c..491f532 100644 (file)
@@ -1,15 +1,15 @@
-<select class="results_header_sel" id='opac.result.sort' name="sort">
+<select [% class ? ('class="' _ class _ '"') : '' %] id="opac.result.sort" name="[% name || 'sort' %]">
     <option value=''>[% l("Sort by Relevance") %]</option>
     <optgroup label='[% l("Sort by Title") %]'>
         <option value='titlesort'[% value == 'titlesort' ? ' selected="selected"' : '' %]>[% l("Title: A to Z") %]</option>
-        <option value='titlesort.desc'[% value == 'titlesort.desc' ? ' selected="selected"' : '' %]>[% l("Title: Z to A") %]</option>
+        <option value='titlesort.descending'[% value == 'titlesort.descending' ? ' selected="selected"' : '' %]>[% l("Title: Z to A") %]</option>
     </optgroup>
     <optgroup label='[% l("Sort by Author") %]'>
         <option value='authorsort'[% value == 'authorsort' ? ' selected="selected"' : '' %]>[% l("Author: A to Z") %]</option>
-        <option value='authorsort.desc'[% value == 'authorsort.desc' ? ' selected="selected"' : '' %]>[% l("Author: Z to A") %]</option>
+        <option value='authorsort.descending'[% value == 'authorsort.descending' ? ' selected="selected"' : '' %]>[% l("Author: Z to A") %]</option>
     </optgroup>
     <optgroup label='[% l("Sort by Publication Date") %]'>
-        <option value='pubdate.desc'[% value == 'pubdate.desc' ? ' selected="selected"' : '' %]>[% l("Date: Newest to Oldest") %]</option>
+        <option value='pubdate.descending'[% value == 'pubdate.descending' ? ' selected="selected"' : '' %]>[% l("Date: Newest to Oldest") %]</option>
         <option value='pubdate'[% value == 'pubdate' ? ' selected="selected"' : '' %]>[% l("Date: Oldest to Newest") %]</option>
     </optgroup>
 </select>