Bookbag enhancements
authorLebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Fri, 5 Aug 2011 17:46:47 +0000 (13:46 -0400)
committerLebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Wed, 31 Aug 2011 17:24:38 +0000 (13:24 -0400)
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 <lebbeous@esilibrary.com>
Open-ILS/examples/fm_IDL.xml
Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm
Open-ILS/src/sql/Pg/070.schema.container.sql
Open-ILS/src/sql/Pg/upgrade/YYYY.schema.bookbag-goodies.sql [new file with mode: 0644]
Open-ILS/web/css/skin/default/opac/style.css
Open-ILS/web/templates/default/opac/myopac/lists.tt2

index 2f9eb59..f0f19c4 100644 (file)
@@ -3646,6 +3646,7 @@ SELECT  usr,
                        <field name="btype" reporter:datatype="text"/>
                        <field name="id" reporter:datatype="id" />
                        <field name="name" reporter:datatype="text"/>
+                       <field name="description" reporter:datatype="text"/>
                        <field name="owner" reporter:datatype="link"/>
                        <field name="pub" reporter:datatype="bool"/>
                        <field name="create_time" reporter:datatype="timestamp" />
@@ -4603,6 +4604,7 @@ SELECT  usr,
                        <field name="btype" reporter:datatype="text"/>
                        <field name="id" reporter:datatype="id" />
                        <field name="name"  reporter:datatype="text"/>
+                       <field name="description" reporter:datatype="text"/>
                        <field name="owner" reporter:datatype="link"/>
                        <field name="pub" reporter:datatype="bool"/>
                        <field name="create_time" reporter:datatype="timestamp" />
@@ -4709,6 +4711,7 @@ SELECT  usr,
                        <field name="btype" reporter:datatype="text"/>
                        <field name="id" reporter:datatype="id" />
                        <field name="name"  reporter:datatype="text"/>
+                       <field name="description" reporter:datatype="text"/>
                        <field name="owner" reporter:datatype="link"/>
                        <field name="pub" reporter:datatype="bool"/>
                        <field name="create_time" reporter:datatype="timestamp" />
@@ -5398,6 +5401,7 @@ SELECT  usr,
                        <field name="btype" reporter:datatype="text"/>
                        <field name="id" reporter:datatype="id" />
                        <field name="name" reporter:datatype="text"/>
+                       <field name="description" reporter:datatype="text"/>
                        <field name="owner" reporter:datatype="link"/>
                        <field name="pub" reporter:datatype="bool"/>
                        <field name="create_time" reporter:datatype="timestamp" />
index e32cd93..c8cf984 100644 (file)
@@ -1213,17 +1213,14 @@ 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'},
-            {"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
+            }
+        ],
         {substream => 1}
     );
 
@@ -1232,7 +1229,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 (
@@ -1263,12 +1297,14 @@ sub load_myopac_bookbag_update {
     my @selected_item = $cgi->param('selected_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');
index 6bbd17c..0e21c5f 100644 (file)
@@ -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 (file)
index 0000000..d6f82a4
--- /dev/null
@@ -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;
index 72a5566..13e5c48 100644 (file)
@@ -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; }
index e94f94f..303bb1a 100644 (file)
@@ -27,6 +27,8 @@
             <tr>
                 <td>
                     <label for="list_create_name">[% l('Enter the name of the new list:') %]</label>
+                </td>
+                <td>
                     <input id="list_create_name" type="text" name="name" />
                     <input type="hidden" name="action" value="create" />
                 </td>
                         src="[% ctx.media_prefix %]/images/btnCancel.png" /></a>
                 </td>
             </tr>
+            <tr>
+                <td class="text-right-top">
+                    <label for="list_description">[% l("List description (optional):") %]</label>
+                </td>
+                <td colspan="3">
+                    <textarea cols="40" rows="3" name="description"
+                        id="list_description"></textarea>
+                </td>
         </table>
     </form>