# 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');
}
} 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) {
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');
$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);
}
#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; }
</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>
[% 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>