From 807b2b120832b2a191e335c7918c0b15e1d20df4 Mon Sep 17 00:00:00 2001 From: Lebbeous Fogle-Weekley Date: Fri, 5 Aug 2011 13:46:47 -0400 Subject: [PATCH] Bookbag enhancements Added description to container types. Added UI bits to add bookbag descriptions. Got bookbag item retrieval using new QueryParser container searching. More to go. Signed-off-by: Lebbeous Fogle-Weekley --- Open-ILS/examples/fm_IDL.xml | 4 ++ .../lib/OpenILS/WWW/EGCatLoader/Account.pm | 55 ++++++++++++++++++---- Open-ILS/src/sql/Pg/070.schema.container.sql | 4 ++ .../sql/Pg/upgrade/YYYY.schema.bookbag-goodies.sql | 19 ++++++++ Open-ILS/web/css/skin/default/opac/style.css | 1 + .../web/templates/default/opac/myopac/lists.tt2 | 10 ++++ 6 files changed, 83 insertions(+), 10 deletions(-) create mode 100644 Open-ILS/src/sql/Pg/upgrade/YYYY.schema.bookbag-goodies.sql diff --git a/Open-ILS/examples/fm_IDL.xml b/Open-ILS/examples/fm_IDL.xml index 9b224dfa41..4d9ac12040 100644 --- a/Open-ILS/examples/fm_IDL.xml +++ b/Open-ILS/examples/fm_IDL.xml @@ -3636,6 +3636,7 @@ SELECT usr, + @@ -4593,6 +4594,7 @@ SELECT usr, + @@ -4699,6 +4701,7 @@ SELECT usr, + @@ -5388,6 +5391,7 @@ SELECT usr, + 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 9d3fab0844..45fb5e5b9c 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm @@ -1128,16 +1128,12 @@ sub load_myopac_bookbags { return $rv; } - my $args = { - order_by => {cbreb => 'name'}, - limit => $self->cgi->param('limit') || 10, - offset => $self->cgi->param('offset') || 0 - }; - $ctx->{bookbags} = $e->search_container_biblio_record_entry_bucket([ - {owner => $self->editor->requestor->id, btype => 'bookbag'}, - # XXX what to do about the possibility of really large bookbags here? - {"flesh" => 1, "flesh_fields" => {"cbreb" => ["items"]}, %$args} + {owner => $e->requestor->id, btype => 'bookbag'}, { + order_by => {cbreb => 'name'}, + limit => $self->cgi->param('limit') || 10, + offset => $self->cgi->param('offset') || 0 + } ]); if(!$ctx->{bookbags}) { @@ -1145,7 +1141,44 @@ sub load_myopac_bookbags { return Apache2::Const::HTTP_INTERNAL_SERVER_ERROR; } - # get unique record IDs + # Here is the loop that uses search to find the bib records in each + # bookbag. XXX This should be parallelized. Should this be done + # with OpenSRF::MultiSession, or is it enough to use OpenSRF::AppSession + # and call ->request() without calling ->gather() on any of those objects + # until all the requests have been issued? + + foreach my $bookbag (@{$ctx->{bookbags}}) { + my $query = sprintf( + "container(bre,bookbag,%d,%s)", $bookbag->id, $e->authtoken + ); + my $results = $U->simplereq( + "open-ils.search", "open-ils.search.biblio.multiclass.query", + {}, $query # XXX we need to limit the number of records per bbag + ); + + # now we have record ids, but we need the cbrebi objects too + my $record_id_list = [ map { pop @$_ } @{$results->{ids}} ]; + + my $items = $e->search_container_biblio_record_entry_bucket_item([ + { + "target_biblio_record_entry" => $record_id_list, + "bucket" => $bookbag->id + } + ]) or do { + $self->apache->log->warn( + "retrieving cbrebi, got " . $e->die_event->{textcode} + ); + return Apache2::Const::HTTP_INTERNAL_SERVER_ERROR; + }; + + # Put all the bucket's items in the order that search returned them in. + my %ordering_hash = map { $_->target_biblio_record_entry, $_ } @$items; + my @ordered_items = map { $ordering_hash{$_} } @$record_id_list; + $bookbag->items(\@ordered_items); + } + + # Get unique record IDs over the set of all fetched bookbags. + # We'll need to fetch their marcxml. my %rec_ids = (); foreach my $bbag (@{$ctx->{bookbags}}) { foreach my $rec_id ( @@ -1176,12 +1209,14 @@ sub load_myopac_bookbag_update { my @del_item = $cgi->param('del_item'); my $shared = $cgi->param('shared'); my $name = $cgi->param('name'); + my $description = $cgi->param('description'); my $success = 0; my $list; if($action eq 'create') { $list = Fieldmapper::container::biblio_record_entry_bucket->new; $list->name($name); + $list->name($description); $list->owner($e->requestor->id); $list->btype('bookbag'); $list->pub($shared ? 't' : 'f'); diff --git a/Open-ILS/src/sql/Pg/070.schema.container.sql b/Open-ILS/src/sql/Pg/070.schema.container.sql index 6bbd17c76c..0e21c5fda4 100644 --- a/Open-ILS/src/sql/Pg/070.schema.container.sql +++ b/Open-ILS/src/sql/Pg/070.schema.container.sql @@ -35,6 +35,7 @@ CREATE TABLE container.copy_bucket ( INITIALLY DEFERRED, name TEXT NOT NULL, btype TEXT NOT NULL DEFAULT 'misc' REFERENCES container.copy_bucket_type (code) DEFERRABLE INITIALLY DEFERRED, + description TEXT, pub BOOL NOT NULL DEFAULT FALSE, create_time TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(), CONSTRAINT cb_name_once_per_owner UNIQUE (owner,name,btype) @@ -88,6 +89,7 @@ CREATE TABLE container.call_number_bucket ( INITIALLY DEFERRED, name TEXT NOT NULL, btype TEXT NOT NULL DEFAULT 'misc' REFERENCES container.call_number_bucket_type (code) DEFERRABLE INITIALLY DEFERRED, + description TEXT, pub BOOL NOT NULL DEFAULT FALSE, create_time TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(), CONSTRAINT cnb_name_once_per_owner UNIQUE (owner,name,btype) @@ -142,6 +144,7 @@ CREATE TABLE container.biblio_record_entry_bucket ( INITIALLY DEFERRED, name TEXT NOT NULL, btype TEXT NOT NULL DEFAULT 'misc' REFERENCES container.biblio_record_entry_bucket_type (code) DEFERRABLE INITIALLY DEFERRED, + description TEXT, pub BOOL NOT NULL DEFAULT FALSE, create_time TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(), CONSTRAINT breb_name_once_per_owner UNIQUE (owner,name,btype) @@ -194,6 +197,7 @@ CREATE TABLE container.user_bucket ( INITIALLY DEFERRED, name TEXT NOT NULL, btype TEXT NOT NULL DEFAULT 'misc' REFERENCES container.user_bucket_type (code) DEFERRABLE INITIALLY DEFERRED, + description TEXT, pub BOOL NOT NULL DEFAULT FALSE, create_time TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(), CONSTRAINT ub_name_once_per_owner UNIQUE (owner,name,btype) diff --git a/Open-ILS/src/sql/Pg/upgrade/YYYY.schema.bookbag-goodies.sql b/Open-ILS/src/sql/Pg/upgrade/YYYY.schema.bookbag-goodies.sql new file mode 100644 index 0000000000..d6f82a43cc --- /dev/null +++ b/Open-ILS/src/sql/Pg/upgrade/YYYY.schema.bookbag-goodies.sql @@ -0,0 +1,19 @@ +-- Evergreen DB patch YYYY.schema.bookbag-goodies.sql + +BEGIN; + +SELECT evergreen.upgrade_deps_block_check('YYYY', :eg_version); + +ALTER TABLE container.biblio_record_entry_bucket + ADD COLUMN description TEXT; + +ALTER TABLE container.call_number_bucket + ADD COLUMN description TEXT; + +ALTER TABLE container.copy_bucket + ADD COLUMN description TEXT; + +ALTER TABLE container.user_bucket + ADD COLUMN description TEXT; + +COMMIT; diff --git a/Open-ILS/web/css/skin/default/opac/style.css b/Open-ILS/web/css/skin/default/opac/style.css index a58c132de6..7df710cc22 100644 --- a/Open-ILS/web/css/skin/default/opac/style.css +++ b/Open-ILS/web/css/skin/default/opac/style.css @@ -1009,6 +1009,7 @@ a.dash-link:hover { text-decoration: underline !important; } .hold-editor-controls a { padding-left: 2em; } .text-right { text-align: right; } +.text-right-top { text-align: right; vertical-align: top; } .rdetail-author-div { padding-bottom: 10px; } .invisible { visibility: hidden; } diff --git a/Open-ILS/web/templates/default/opac/myopac/lists.tt2 b/Open-ILS/web/templates/default/opac/myopac/lists.tt2 index ba8d556360..17ef572d7f 100644 --- a/Open-ILS/web/templates/default/opac/myopac/lists.tt2 +++ b/Open-ILS/web/templates/default/opac/myopac/lists.tt2 @@ -27,6 +27,8 @@ + + @@ -48,6 +50,14 @@ src="[% ctx.media_prefix %]/images/btnCancel.png" /> + + + + + + + -- 2.11.0