From: Lebbeous Fogle-Weekley <lebbeous@esilibrary.com> Date: Wed, 29 Jun 2011 23:34:56 +0000 (-0400) Subject: working! with paging and linking to bibs, except: X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=d8367973056752365a69ada9593b77fea9b92600;p=evergreen%2Fmasslnc.git working! with paging and linking to bibs, except: ... my new facet thingy doesn't seem to work. here's what I did sql-wise: INSERT INTO config.metabib_field ( id, field_class, name, label, xpath, format, search_field, facet_field ) VALUES ( 28, 'identifier', 'authority_id', 'Authority Record ID', '//marc:datafield/marc:subfield[@code=''0'']', 'marcxml', false, true ); INSERT INTO config.metabib_field_index_norm_map (field, norm) VALUES (28, 5); Yet after re-ingesting my bibs I have nothing new in metabib.facet_entry. So the "show related bibliographic holdings" links don't quite work (I believe they /would/, though, if I had the facet thingy right). Signed-off-by: Lebbeous Fogle-Weekley <lebbeous@esilibrary.com> --- diff --git a/Open-ILS/web/opac/common/js/config.js b/Open-ILS/web/opac/common/js/config.js index 21b20fa2d8..1cdc09dd27 100644 --- a/Open-ILS/web/opac/common/js/config.js +++ b/Open-ILS/web/opac/common/js/config.js @@ -47,8 +47,10 @@ var PARAM_PUBD_AFTER = 'pda'; var PARAM_PUBD_BETWEEN = 'pdt'; var PARAM_PUBD_DURING = 'pdd'; var PARAM_NOPERSIST_SEARCH = 'nps'; -var PARAM_AUTHORITY_BROWSE_AXIS = "ax"; +var PARAM_AUTHORITY_BROWSE_AXIS = "bx"; var PARAM_AUTHORITY_BROWSE_TERM = "bt"; +var PARAM_AUTHORITY_BROWSE_PAGE = "bp"; +var PARAM_AUTHORITY_BROWSE_PER_PAGE = "be"; /* URL param values (see comments above) */ var TERM; diff --git a/Open-ILS/web/opac/skin/default/css/layout.css b/Open-ILS/web/opac/skin/default/css/layout.css index 7aaed35b28..8a4ca89efc 100644 --- a/Open-ILS/web/opac/skin/default/css/layout.css +++ b/Open-ILS/web/opac/skin/default/css/layout.css @@ -76,8 +76,10 @@ table { border-collapse: collapse; } table.authority-record { width: 48em; background-color: #ddd; margin: 1em; } td.authority-record-right { width: 24em; } -td.authority-record-main { font-weight: bold; } td.authority-tag-label { font-style: italic; } +.authority-pager { margin: 1ex 0; } +.authority-count-holder { padding-left: 1em; font-weight: bold; } +a.authority-content { font-weight: bold; } #searchbar { margin-top: 22px; width: 100%; } #searchbar table tr td {font-weight: bold; font-size: 8pt; } diff --git a/Open-ILS/web/opac/skin/default/js/authbrowse.js b/Open-ILS/web/opac/skin/default/js/authbrowse.js index 643d6c530c..b2664906df 100644 --- a/Open-ILS/web/opac/skin/default/js/authbrowse.js +++ b/Open-ILS/web/opac/skin/default/js/authbrowse.js @@ -2,20 +2,24 @@ dojo.require("openils.CGI"); dojo.require("openils.Util"); dojo.require("MARC.FixedFields"); dojo.require("openils.AuthorityControlSet"); -var cgi; +var cgi, acs_helper; attachEvt("common", "init", doAuthorityBrowse); /* repeatable, supports all args or no args */ function doAuthorityBrowse(axis, term, page, per_page) { + swapCanvas(dojo.byId("loading_alt")); + 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; + page = cgi.param(PARAM_AUTHORITY_BROWSE_PAGE) || 0; + per_page = cgi.param(PARAM_AUTHORITY_BROWSE_PER_PAGE) || 20; } + setPagingLinks(axis, term, page, per_page); + var url = '/opac/extras/browse/marcxml/authority.' + axis + '/1' /* this will be OU if OU ever means anything for authorities */ @@ -32,7 +36,30 @@ function doAuthorityBrowse(axis, term, page, per_page) { }); } +function setPagingLinks(axis, term, page, per_page) { + /* XXX since authority browse drops us into the middle of the record set, + * we need additional complexity to find out if we're have more records + * above and below, so just assume we always do for now. + */ + var up_page = Number(page) - 1; + var down_page = Number(page) + 1; + + dojo.attr( + "authority-page-up", "onclick", function() { + doAuthorityBrowse(axis, term, up_page, per_page); + } + ); + dojo.attr( + "authority-page-down", "onclick", function() { + doAuthorityBrowse(axis, term, down_page, per_page); + } + ); +} + function renderAuthorityTagContent(m, af) { + /* XXX This doesn't take into account possible tag repeatability -- a + * bona fide library scientist could probably improve this. :-) + */ if (af.tag() && af.sf_list()) { return dojo.filter( dojo.map( @@ -82,14 +109,19 @@ function renderAuthorityMainEntry(m, field, tbody) { if (!content.length) return; /* don't display empty tags */ var tr = dojo.create("tr", null, tbody); - dojo.create( + var content_holder = dojo.create( "td", { "className": "authority-tag-content authority-record-main", - "innerHTML": content, "colspan": 2 }, tr ); dojo.create( + "span", + {"className":"authority-content", "innerHTML": content}, + content_holder + ); + dojo.create("span", {"className":"authority-count-holder"}, content_holder); + dojo.create( "td", { "className": "authority-tag-label authority-record-right", "innerHTML": field.name(), @@ -105,7 +137,7 @@ function renderAuthorityMainEntry(m, field, tbody) { } } -function renderAuthorityRecord(m, control_set) { +function renderAuthorityRecord(m, control_set, auth_id) { var main_entries = openils.Util.objectSort( dojo.filter( control_set.authority_fields(), @@ -114,7 +146,7 @@ function renderAuthorityRecord(m, control_set) { ); var table = dojo.create("table", {"className": "authority-record"}); - var tbody = dojo.create("tbody", null, table); + var tbody = dojo.create("tbody", {"id": "authority_" + auth_id}, table); dojo.forEach( main_entries, function(af) { renderAuthorityMainEntry(m, af, tbody); } @@ -123,19 +155,82 @@ function renderAuthorityRecord(m, control_set) { return table; } +/* displayAuthorityRecords: given a DOM document object that contains marcxml + * records, display each one in a table using the apporiate control set to + * determine which fields to show. + */ function displayAuthorityRecords(doc) { - var acs_helper = new openils.AuthorityControlSet(); + if (!acs_helper) + acs_helper = new openils.AuthorityControlSet(); /* XXX I wanted to use bibtemplate here, but now I'm not sure it makes * sense: the template itself would have to be dynamic, as it would vary * from record to record when different control sets were in use. */ + var auth_ids = []; + dojo.empty("authority-record-holder"); dojo.query("record", doc).forEach( function(record) { var m = new MARC.Record({"xml": record}); - var s = m.extractFixedField("Subj"); - var cs = acs_helper.controlSetByThesaurusCode(s); - dojo.place(renderAuthorityRecord(m, cs.raw), "test-holder"); + + /* is 001 reliable for this? I'm guessing not */ + var auth_id = m.field("001").data; + auth_ids.push(auth_id); + + var cs = acs_helper.controlSetByThesaurusCode( + m.extractFixedField("Subj") + ); + + dojo.place( + renderAuthorityRecord(m, cs.raw, auth_id), + "authority-record-holder" + ); + } + ); + displayRecordCounts(auth_ids); + swapCanvas(dojo.byId("canvas_main")); +} + +function displayRecordCounts(auth_ids) { + fieldmapper.standardRequest( + ["open-ils.cat", "open-ils.cat.authority.records.count_linked_bibs"], { + "params": [auth_ids], + "async": true, + "oncomplete": function(r) { + if ((r = openils.Util.readResponse(r))) { + dojo.forEach(r, function(blob) { + if (blob.bibs > 0) { + displayRecordCount(blob.authority, blob.bibs); + } + }); + } + } } ); } + +function displayRecordCount(id, count) { + /* 1) put record count where we can see it */ + dojo.query("#authority_" + id + " .authority-count-holder")[0].innerHTML = + "(" + count + ")"; /* XXX i18n ? */ + + /* 2) also, provide a link to show those records */ + var span = dojo.query("#authority_" + id + " .authority-content")[0]; + + var args = {}; + args.page = RRESULT; + args[PARAM_DEPTH] = depthSelGetDepth(); + args[PARAM_LOCATION] = depthSelGetNewLoc(); + args[PARAM_TERM] = "identifier|authority_id[" + id + "]"; + + dojo.create( + "a", { + "innerHTML": span.innerHTML, + "href": buildOPACLink(args), + "className": "authority-content", + "title": "Show related bibliographic holdings" /* XXX i18n! */ + }, + span, "replace" + ); +} + diff --git a/Open-ILS/web/opac/skin/default/xml/page_authbrowse.xml b/Open-ILS/web/opac/skin/default/xml/page_authbrowse.xml index 69675ebdca..f137c5d934 100644 --- a/Open-ILS/web/opac/skin/default/xml/page_authbrowse.xml +++ b/Open-ILS/web/opac/skin/default/xml/page_authbrowse.xml @@ -1,5 +1,13 @@ <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> - Records: <div id="test-holder"> + + <div class="authority-pager"> + <a id="authority-page-up" href="#" class="classic_link">&common.cn.previous;</a> + </div> + + <div id="authority-record-holder"></div> + + <div class="authority-pager"> + <a id="authority-page-down" href="#" class="classic_link">&common.cn.next;</a> </div> </div>