$self->ctx->{add_rec} = $add_rec;
# But not in the staff client, 'cause that breaks things.
unless ($self->ctx->{is_staff}) {
- $self->ctx->{where_from} = $self->ctx->{referer};
- if ( my $anchor = $self->cgi->param('anchor') ) {
- $self->ctx->{where_from} =~ s/#.*|$/#$anchor/;
+ # allow caller to provide the where_from in cases where
+ # the referer is an intermediate error page
+ if ($self->cgi->param('where_from')) {
+ $self->ctx->{where_from} = $self->cgi->param('where_from');
+ } else {
+ $self->ctx->{where_from} = $self->ctx->{referer};
+ if ( my $anchor = $self->cgi->param('anchor') ) {
+ $self->ctx->{where_from} =~ s/#.*|$/#$anchor/;
+ }
}
}
}
}
if ($action eq 'create') {
- $list = Fieldmapper::container::biblio_record_entry_bucket->new;
- $list->name($name);
- $list->description($description);
- $list->owner($e->requestor->id);
- $list->btype('bookbag');
- $list->pub($shared ? 't' : 'f');
- $success = $U->simplereq('open-ils.actor',
- 'open-ils.actor.container.create', $e->authtoken, 'biblio', $list);
- if (ref($success) ne 'HASH' && scalar @add_rec) {
- $list_id = (ref($success)) ? $success->id : $success;
- 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;
+
+ if ($name) {
+ $list = Fieldmapper::container::biblio_record_entry_bucket->new;
+ $list->name($name);
+ $list->description($description);
+ $list->owner($e->requestor->id);
+ $list->btype('bookbag');
+ $list->pub($shared ? 't' : 'f');
+ $success = $U->simplereq('open-ils.actor',
+ 'open-ils.actor.container.create', $e->authtoken, 'biblio', $list);
+ if (ref($success) ne 'HASH' && scalar @add_rec) {
+ $list_id = (ref($success)) ? $success->id : $success;
+ 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;
+ }
}
$url = $cgi->param('where_from') if ($success && $cgi->param('where_from'));
+
+ } else { # no name
+ $self->ctx->{bucket_failure_noname} = 1;
}
+
} elsif($action eq 'place_hold') {
# @hold_recs comes from anon lists redirect; selected_itesm comes from existing buckets
return $self->generic_redirect($url) if $success;
- # XXX FIXME Bucket failure doesn't have a page to show the user anything
- # right now. User just sees a 404 currently.
-
+ $self->ctx->{where_from} = $cgi->param('where_from');
$self->ctx->{bucket_action} = $action;
$self->ctx->{bucket_action_failed} = 1;
return Apache2::Const::OK;
--- /dev/null
+[% PROCESS "opac/parts/header.tt2";
+ PROCESS "opac/parts/misc_util.tt2";
+ WRAPPER "opac/parts/myopac/base.tt2";
+ myopac_page = "lists/update"
+%]
+
+<!-- we should never see this page on success -->
+
+[% IF ctx.bucket_action_failed %]
+<div id='bookbag_udpate_failures'>
+
+ <div>
+ <strong>[% l("Problem with list management:") %]</strong>
+ </div>
+
+ <div>
+ <ul>
+ [% IF ctx.bucket_action == 'create' %]
+ [% IF ctx.bucket_failure_noname %]
+ <li>[% l('A list name is required') %]</li>
+ [% END %]
+ [% END %]
+ </ul>
+ </div>
+
+ <div>
+ [% url = ctx.referer;
+ # The return link should return the user to the page where the edit
+ # failure occurred.
+ # mkurl() does not support 'page' params w/ existing CGI params.
+ # build the URL manually.
+ IF ctx.where_from;
+ from = ctx.where_from | uri;
+ IF url.match('\?');
+ url = url _ ';where_from=' _ from;
+ ELSE;
+ url = url _ '?where_from=' _ from;
+ END;
+ END; %]
+ <a href="[% url %]">[% l('Return') %]</a>
+ </div>
+</div>
+[% END %]
+[% END %]