working on an auth browser
authorLebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Tue, 28 Jun 2011 14:43:54 +0000 (10:43 -0400)
committerMike Rylander <mrylander@gmail.com>
Mon, 11 Jul 2011 17:48:30 +0000 (13:48 -0400)
Signed-off-by: Lebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Open-ILS/src/perlmods/lib/OpenILS/Application/SuperCat.pm
Open-ILS/web/opac/skin/default/js/advanced.js
Open-ILS/web/opac/skin/default/js/authbrowse.js
Open-ILS/web/opac/skin/default/xml/common/sidebar.xml
Open-ILS/web/opac/skin/default/xml/page_authbrowse.xml

index 1f0a46a..a43abc5 100644 (file)
@@ -888,6 +888,7 @@ Returns a list of the requested org-scoped record IDs held
 );
 
 sub grab_authority_browse_axes {
+    my ($self, $client, $full) = @_;
 
     unless(scalar(keys(%authority_browse_axis_cache))) {
         my $axes = new_editor->search_authority_browse_axis([
@@ -897,14 +898,26 @@ sub grab_authority_browse_axes {
         $authority_browse_axis_cache{$_->code} = $_ for (@$axes);
     }
 
-    return [keys %authority_browse_axis_cache];
+    if ($full) {
+        return [
+            map { $authority_browse_axis_cache{$_} } sort keys %authority_browse_axis_cache
+        ];
+    } else {
+        return [keys %authority_browse_axis_cache];
+    }
 }
 __PACKAGE__->register_method(
        method    => 'grab_authority_browse_axes',
        api_name  => 'open-ils.supercat.authority.browse_axis_list',
        api_level => 1,
-       argc      => 0,
-       note      => "Returns a list of valid authority browse/startswith axes"
+       argc      => 1,
+       signature =>
+               { desc     => "Returns a list of valid authority browse/startswith axes",
+                 params   => [
+              { name => 'full', desc => 'Optional. If true, return array containing the full object for each axis, sorted by code. Otherwise just return an array of the codes.', type => 'number' }
+          ],
+                 'return' => { desc => 'Axis codes or whole axes, see "full" param', type => 'array' }
+               }
 );
 
 sub axis_authority_browse {
index d292c7f..08e9b22 100644 (file)
@@ -7,6 +7,7 @@ function advInit() {
        /* propogate these? */
 
        depthSelInit(); 
+       authoritySelInit(); 
        setEnterFunc( $n( $('advanced.marc.tbody'), 'advanced.marc.value'), advMARCRun );
 
        unHideMe($('adv_quick_search_sidebar'));
@@ -16,12 +17,31 @@ function advInit() {
                setSelector($('adv_quick_type'), 'tcn'); */
 
        setEnterFunc($('adv_quick_text'), advGenericSearch);
+       setEnterFunc($('authority_browse_term'), advAuthorityBrowse);
 
        unHideMe($('adv_marc_search_sidebar'));
        unHideMe($('adv_authority_browse_sidebar'));
 }
 
 
+function authoritySelInit() {
+    dojo.require("openils.Util");
+    fieldmapper.standardRequest(
+        ["open-ils.supercat", "open-ils.supercat.authority.browse_axis_list"], {
+            "params": [true /* whole objects */], 
+            "async": true,
+            "oncomplete": function(r) {
+                if ((r = openils.Util.readResponse(r))) {
+                    dojo.empty("authority_browse_axis");
+                    dojo.forEach(r, function(axis) {
+                        dojo.create("option", {"innerHTML": axis.name(), "value": axis.code()}, "authority_browse_axis");
+                    });
+                }
+            }
+        }
+    );
+}
+
 function advAddMARC() {
        var newt = $('adv_sdbar_table').cloneNode(true);
        newt.id = "";
@@ -175,7 +195,7 @@ function advDrawBarcode(r) {
     location.href = buildOPACLink(args);
 }
 
-function authBrowseSubmit() {
+function advAuthorityBrowse() {
     var selector = dojo.byId("authority_browse_axis");
     var args = {"page": AUTHBROWSE};
     args[PARAM_AUTHORITY_BROWSE_AXIS] =
index ea711b3..69dc516 100644 (file)
@@ -1 +1,50 @@
-alert("test 1");
+dojo.require("openils.CGI");
+dojo.require("MARC.FixedFields");
+dojo.require("openils.AuthorityControlSet");
+var cgi;
+
+attachEvt("common", "init", doAuthorityBrowse);
+
+/* repeatable, supports all args or no args */
+function doAuthorityBrowse(axis, term, page, per_page) {
+    console.log("doAuthorityBrowse 1");
+    if (!axis) {
+        if (!cgi) cgi = new openils.CGI();
+        axis = cgi.param(PARAM_AUTHORITY_BROWSE_AXIS);
+        term = cgi.param(PARAM_AUTHORITY_BROWSE_TERM);
+        page = 0;
+        per_page = 20;
+    }
+    console.log("doAuthorityBrowse 2");
+
+    var url = '/opac/extras/browse/marcxml/authority.'
+        + axis
+        + '/1' /* this will be OU if OU ever means anything for authorities */
+        + '/' + term /* FIXME urlescape or however it's spelt */
+        + '/' + page
+        + '/' + per_page
+    ;
+    dojo.xhrGet({
+        "url": url,
+        "handleAs": "xml",
+        "content": {"format": "marcxml"},
+        "preventCache": true,
+        "load": displayAuthorityRecords
+    });
+}
+
+function displayAuthorityRecords(doc) {
+    console.log("displayAuthorityRecords");
+    dojo.query("record", doc).forEach(
+        function(record) {
+            console.log("record");
+            var m = new MARC.Record({"xml": record});
+            dojo.create(
+                "div", {
+                    "innerHTML": "record here, Subj is " +
+                        m.extractFixedField("Subj")
+                }, "test-holder"
+            );
+        }
+    );
+}
index e7352a5..4bd6c53 100644 (file)
         </div>
 
         <div style="text-align: left">
-            <select id="authority_browse_axis">
-                <!-- there's a supercat method
-                     open-ils.supercat.authority.browse_axis_list to get us 
-                     this list dynamically, but how do we get that with XML
-                     api? or do we? -->
-                <option value="author">Author</option>
-                <option value="subject">Subject</option>
-                <option value="title">Title</option>
-                <option value="topic">Topic</option>
-            </select>
-            <input id="authority_browse_term" />
+            <select id="authority_browse_axis"></select><input
+                id="authority_browse_term" type="text" size="16"/>
         </div>
 
-        <a id="authority_browse_submit" class="classic_link" href="javascript:authBrowseSubmit();">&common.submit;</a>
+        <div style="margin-top: 8px;">
+            <a id="authority_browse_submit" class="classic_link" href="javascript:advAuthorityBrowse();">&common.submit;</a>
+        </div>
     </div>
 
        <div id='adv_marc_search_sidebar' class='sidebar_chunk hide_me' 
index 6dc6ce0..69675eb 100644 (file)
@@ -1,6 +1,5 @@
 <div id='canvas_main' class='canvas' style='margin-top: 20px;'>
        <script language='javascript' type='text/javascript' src='<!--#echo var="OILS_OPAC_JS_HOST"-->/skin/default/js/authbrowse.js'></script>
-    Boo.
+    Records: <div id="test-holder">
+    </div>
 </div>
-
-