Ability to move records from temp list to bookbag
authorsenator <lebbeous@esilibrary.com>
Wed, 23 Mar 2011 20:57:37 +0000 (16:57 -0400)
committersenator <lebbeous@esilibrary.com>
Wed, 23 Mar 2011 20:58:37 +0000 (16:58 -0400)
Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader.pm
Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm
Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Container.pm
Open-ILS/web/css/skin/default/opac/semiauto.css
Open-ILS/web/templates/default/opac/myopac/lists.tt2
Open-ILS/web/templates/default/opac/parts/anon_list.tt2

index ebfbbec..7ddec2e 100644 (file)
@@ -93,7 +93,7 @@ sub load {
     return $self->load_record if $path =~ /opac\/record/;
 
     return $self->load_mylist_add if $path =~ /opac\/mylist\/add/;
-    return $self->load_mylist_del if $path =~ /opac\/mylist\/del/;
+    return $self->load_mylist_move if $path =~ /opac\/mylist\/move/;
     return $self->load_mylist if $path =~ /opac\/mylist/;
     return $self->load_cache_clear if $path =~ /opac\/cache\/clear/;
 
index e92a4bd..bed70d4 100644 (file)
@@ -508,26 +508,30 @@ sub load_myopac_bookbags {
     # get unique record IDs
     my %rec_ids = ();
     foreach my $bbag (@{$ctx->{bookbags}}) {
-        foreach my $item_id (map { $_->id } @{$bbag->items}) {
-            $rec_ids{$item_id} = 1;
+        foreach my $rec_id (
+            map { $_->target_biblio_record_entry } @{$bbag->items}
+        ) {
+            $rec_ids{$rec_id} = 1;
         }
     }
 
-    $ctx->{bookbags_marc_xml} = $self->fetch_marc_xml_by_id(keys %rec_ids);
+    $ctx->{bookbags_marc_xml} = $self->fetch_marc_xml_by_id([keys %rec_ids]);
 
     return Apache2::Const::OK;
 }
 
 
 # actions are create, delete, show, hide, rename, add_rec, delete_item
-# CGI is action, list=list_id, add_rec=bre_id, del_item=bucket_item_id, name=new_bucket_name
+# CGI is action, list=list_id, add_rec/record=bre_id, del_item=bucket_item_id, name=new_bucket_name
 sub load_myopac_bookbag_update {
-    my $self = shift;
+    my ($self, $action, $list_id) = @_;
     my $e = $self->editor;
     my $cgi = $self->cgi;
-    my $action = $cgi->param('action');
-    my $list_id = $cgi->param('list');
-    my $add_rec = $cgi->param('add_rec');
+
+    $action ||= $cgi->param('action');
+    $list_id ||= $cgi->param('list');
+
+    my @add_rec = $cgi->param('add_rec') || $cgi->param('record');
     my @del_item = $cgi->param('del_item');
     my $shared = $cgi->param('shared');
     my $name = $cgi->param('name');
@@ -577,11 +581,14 @@ sub load_myopac_bookbag_update {
         }
 
     } elsif($action eq 'add_rec') {
-        my $item = Fieldmapper::container::biblio_record_entry_bucket_item->new;
-        $item->bucket($list_id);
-        $item->target_biblio_record_entry($add_rec);
-        $success = $U->simplereq('open-ils.actor', 
-            'open-ils.actor.container.item.create', $e->authtoken, 'biblio', $item);
+        foreach my $add_rec (@add_rec) {
+            my $item = Fieldmapper::container::biblio_record_entry_bucket_item->new;
+            $item->bucket($list_id);
+            $item->target_biblio_record_entry($add_rec);
+            $success = $U->simplereq('open-ils.actor', 
+                'open-ils.actor.container.item.create', $e->authtoken, 'biblio', $item);
+            last unless $success;
+        }
 
     } elsif($action eq 'del_item') {
         foreach (@del_item) {
index 38a9755..a930144 100644 (file)
@@ -57,8 +57,8 @@ sub load_mylist_add {
     return $self->mylist_action_redirect($cache_key);
 }
 
-# Removes a record ID from My List
-sub load_mylist_del {
+# Removes a record ID from My List, or moves to an actual bookbag
+sub load_mylist_move {
     my $self = shift;
     my @rec_ids = $self->cgi->param('record');
 
@@ -74,6 +74,12 @@ sub load_mylist_del {
         $cache_key, ANON_CACHE_MYLIST, \@keep
     );
 
+    if ($self->ctx->{user} and $self->cgi->param('action') =~ /^\d+$/) {
+        # in this case, action becomes list_id
+        $self->load_myopac_bookbag_update('add_rec', $self->cgi->param('action'));
+        # XXX TODO: test for failure of above
+    }
+
     return $self->mylist_action_redirect($cache_key);
 }
 
index db43f54..81d8632 100644 (file)
 #search_box { width: 162px; }
 .opac-auto-178 { width: 174px; }
 .opac-auto-179 { width: 175px; margin-right: 11px; }
+.opac-auto-179 optgroup { margin-left: 1em; font-weight: normal; font-style: italic; }
+.opac-auto-179-inner-option { margin-left: 2em; } /* XXX ".opac-auto-179 optgroup option" doesn't work!? */
 .opac-auto-180 { width: 182px; color: black; padding: 5px 25px; }
 .opac-auto-181 { width: 195px; }
 .opac-auto-182 { width: 230px; text-align: left; margin-top: 3px; }
index b72a97f..1fa28f9 100644 (file)
                         </td></tr>
                         [% END %]
                         [% FOR item IN bbag.items;
-                            item_id = item.id;
-                            attrs = {marc_xml => ctx.bookbags_marc_xml.$item_id};
+                            rec_id = item.target_biblio_record_entry;
+                            attrs = {marc_xml => ctx.bookbags_marc_xml.$rec_id};
                             PROCESS get_marc_attrs args=attrs %]
                         <tr>
-                            <td class="opac-auto-097b" style="padding-left: 10px;"><input type="checkbox" name="del_item" value="[% item_id %]" /></td>
+                            <td class="opac-auto-097b" style="padding-left: 10px;"><input type="checkbox" name="del_item" value="[% item.id %]" /></td>
                             <td class="opac-auto-097b" style="padding-left: 5px;">[% attrs.title %]</td>
                             <td class="opac-auto-097b">[% attrs.author %]</td>
                         </tr>
index cc06a0d..8fb8258 100644 (file)
@@ -1,5 +1,5 @@
         [% IF ctx.mylist.size %]
-        <form action="[% ctx.opac_root %]/mylist/del" method="POST">
+        <form action="[% ctx.opac_root %]/mylist/move" method="POST">
         <div id='acct_list_template2'>
             <div style="width:100%">
                 <table cellpadding="0" cellspacing="0" border="0">
                                 <option>[% l('-- Actions for this list --') %]</option>
                                 <!-- XXX not ready <option value="hold">[% l('Place Hold') %]</option> -->
                                 <option value="delete">[% l('Remove Items') %]</option>
+                                [% IF ctx.user AND ctx.bookbags.size %]
+                                <optgroup label="Move selected items to">
+                                    [% FOR bbag IN ctx.bookbags %]]
+                                    <option value="[% bbag.id %]" class="opac-auto-179-inner-option">[% bbag.name %]</option>
+                                    [% END %]
+                                </optgroup>
+                                [% END %]
                             </select>
                             <input type="submit" value="[% l('Go') %]" />
                         </td>