support SVF in staff client bib record summary
authorJason Etheridge <jason@esilibrary.com>
Thu, 8 Dec 2011 22:48:42 +0000 (17:48 -0500)
committerBill Erickson <berick@esilibrary.com>
Thu, 22 Dec 2011 15:21:37 +0000 (10:21 -0500)
This is in support of https://bugs.launchpad.net/evergreen/+bug/822928, re: Cat Date

So for example, let's suppose you want to store a "Cat Date" in MARC tag 915, subfield a.

You could do this in the database:

INSERT INTO config.record_attr_definition (name,label,filter,sorter,tag,sf_list)
    VALUES ( 'cat_date', 'Cat Date', 'f', 't', '915', 'd' );

Add this to server/locale/en-US/cat_custom.properties (optional but recommended):

staff.cat.bib_brief.cat_date.label=Cat Date:
staff.cat.bib_brief.cat_date.accesskey=

And then add something like this to server/skin/custom.js:

    try {

        netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
        var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces['nsIPrefBranch']);

        prefs.setCharPref(
            'oils.bib_brief.horizontal.dynamic_grid_replacement.data',
            js2JSON([
                ["title",           "edition",  "editor",       "cat_date"],
                ["author",          "pubdate",  "edit_date",    "holds"],
                ["bib_call_number", "tcn",      "create_date",  "items"]
            ])
        );

        prefs.setCharPref(
            'oils.bib_brief.alternate_copy_summary.dynamic_grid_replacement.data',
            js2JSON([
                ["title",       "edition",  "editor",       "cat_date"],
                ["author",      "pubdate",  "edit_date",    "holds"],
                ["call_number", "tcn",      "create_date",  "items"]
            ])
        );

    } catch(E) {
        dump('Error in custom.js trying to set oils.bib_brief.*.dynamic_grid_replacement.data: ' + E + '\n');
    }

Finally, re-ingest any records with tag 915d (you can simply edit the MARC via
the MARC Editor for a specific record, or if the ingest.reingest.force_on_same_marc
row in config.internal_flag is enabled and you're not doing this during library
hours, you can re-ingest all records with UPDATE biblio.record_entry SET marc = marc;)

Signed-off-by: Jason Etheridge <jason@esilibrary.com>
Signed-off-by: Bill Erickson <berick@esilibrary.com>
Open-ILS/src/perlmods/lib/OpenILS/Application/Cat.pm
Open-ILS/xul/staff_client/server/cat/bib_brief_overlay.js

index 8e311f6..6a9ee33 100644 (file)
@@ -427,9 +427,9 @@ __PACKAGE__->register_method(
     method        => "biblio_record_record_metadata",
     api_name      => "open-ils.cat.biblio.record.metadata.retrieve",
     authoritative => 1,
-    argc          => 1, #(session_id, biblio_tree ) 
-    notes         => "Walks the tree and commits any changed nodes " .
-                     "adds any new nodes, and deletes any deleted nodes",
+    argc          => 2, #(session_id, list of bre ids )
+    notes         => "Returns a list of slim-downed bre objects based on the " .
+                     "ids passed in",
 );
 
 sub biblio_record_record_metadata {
@@ -448,6 +448,7 @@ sub biblio_record_record_metadata {
             my $rec = $editor->retrieve_biblio_record_entry($_);
         $rec->creator($editor->retrieve_actor_user($rec->creator));
         $rec->editor($editor->retrieve_actor_user($rec->editor));
+        $rec->attrs($editor->retrieve_metabib_record_attr($rec->id));
         $rec->clear_marc; # slim the record down
         push( @results, $rec );
     }
index bc6d784..f939e68 100644 (file)
@@ -94,6 +94,24 @@ function bib_brief_overlay(params) {
             }
         }
 
+        // Let's loop through bre.attrs.attrs and put them with any matching
+        // elements in bib_brief_overlay.xul
+        if (params.bre.attrs()) {
+            // FIXME -- we should do this in the perl; what's below isn't robust
+            var attrs = JSON2js(
+                '{' +
+                params.bre.attrs().attrs().replace(
+                    '=>',':','g').replace('NULL','null','g')
+                + '}'
+            );
+            for (var attr in attrs) {
+                if (exists(attr)) {
+                    set(attr,attrs[attr]);
+                    set_tooltip(attr,attr);
+                }
+            }
+        }
+
         // Let's fetch a bib call number, if the "bib_call_number" field exists
         // in our display
         if (exists('bib_call_number')) {