From 693520254eb55728d54826f910876ebc79d44299 Mon Sep 17 00:00:00 2001 From: Lebbeous Fogle-Weekley Date: Tue, 28 Jun 2011 10:43:54 -0400 Subject: [PATCH] working on an auth browser Signed-off-by: Lebbeous Fogle-Weekley --- .../perlmods/lib/OpenILS/Application/SuperCat.pm | 19 ++++++-- Open-ILS/web/opac/skin/default/js/advanced.js | 22 +++++++++- Open-ILS/web/opac/skin/default/js/authbrowse.js | 51 +++++++++++++++++++++- .../web/opac/skin/default/xml/common/sidebar.xml | 17 +++----- .../web/opac/skin/default/xml/page_authbrowse.xml | 5 +-- 5 files changed, 94 insertions(+), 20 deletions(-) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/SuperCat.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/SuperCat.pm index 1f0a46ae60..a43abc5fb8 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/SuperCat.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/SuperCat.pm @@ -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 { diff --git a/Open-ILS/web/opac/skin/default/js/advanced.js b/Open-ILS/web/opac/skin/default/js/advanced.js index d292c7f3af..08e9b22285 100644 --- a/Open-ILS/web/opac/skin/default/js/advanced.js +++ b/Open-ILS/web/opac/skin/default/js/advanced.js @@ -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] = diff --git a/Open-ILS/web/opac/skin/default/js/authbrowse.js b/Open-ILS/web/opac/skin/default/js/authbrowse.js index ea711b3fb9..69dc51679b 100644 --- a/Open-ILS/web/opac/skin/default/js/authbrowse.js +++ b/Open-ILS/web/opac/skin/default/js/authbrowse.js @@ -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" + ); + } + ); +} diff --git a/Open-ILS/web/opac/skin/default/xml/common/sidebar.xml b/Open-ILS/web/opac/skin/default/xml/common/sidebar.xml index e7352a501f..4bd6c530ee 100644 --- a/Open-ILS/web/opac/skin/default/xml/common/sidebar.xml +++ b/Open-ILS/web/opac/skin/default/xml/common/sidebar.xml @@ -115,20 +115,13 @@
- - +
- &common.submit; +
+ &common.submit; +
- - -- 2.11.0