From: Lebbeous Fogle-Weekley Date: Thu, 30 Jun 2011 20:54:35 +0000 (-0400) Subject: attempted to add sanity to paging, but not really there yet X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=e82a1234718120f7673922862d70e24123bf2cc8;p=contrib%2FConifer.git attempted to add sanity to paging, but not really there yet Signed-off-by: Lebbeous Fogle-Weekley --- diff --git a/Open-ILS/web/opac/skin/default/js/authbrowse.js b/Open-ILS/web/opac/skin/default/js/authbrowse.js index f073b0c837..e1b144245a 100644 --- a/Open-ILS/web/opac/skin/default/js/authbrowse.js +++ b/Open-ILS/web/opac/skin/default/js/authbrowse.js @@ -2,7 +2,7 @@ dojo.require("openils.CGI"); dojo.require("openils.Util"); dojo.require("MARC.FixedFields"); dojo.require("openils.AuthorityControlSet"); -var cgi, acs_helper; +var cgi, acs_helper, last_fetched_length = 0; attachEvt("common", "init", doAuthorityBrowse); @@ -18,8 +18,6 @@ function doAuthorityBrowse(axis, term, page, per_page) { 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,28 +30,38 @@ function doAuthorityBrowse(axis, term, page, per_page) { "handleAs": "xml", "content": {"format": "marcxml"}, "preventCache": true, - "load": displayAuthorityRecords + "load": function(doc) { + displayAuthorityRecords(doc); + setPagingLinks(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; + unHideMe(dojo.byId("authority-page-up")); 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); - } - ); + + /* XXX In theory this would generally stop the "next page" link from + * showing up when it's unwanted, but in practice the supercat/unapi + * call we make doesn't return the number of records it's supposed to. + */ +// if (last_fetched_length == per_page) { + unHideMe(dojo.byId("authority-page-down")); + dojo.attr( + "authority-page-down", "onclick", function() { + doAuthorityBrowse(axis, term, down_page, per_page); + } + ); +// } else { +// hideMe(dojo.byId("authority-page-down")); +// } } function renderAuthorityTagContent(m, af) { @@ -168,8 +176,15 @@ function displayAuthorityRecords(doc) { * from record to record when different control sets were in use. */ var auth_ids = []; + dojo.empty("authority-record-holder"); - dojo.query("record", doc).forEach( + + var records = dojo.query("record", doc); + last_fetched_length = records.length; + console.log("length here is " + last_fetched_length); + + dojo.forEach( + records, function(record) { var m = new MARC.Record({"xml": record}); 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 f137c5d934..f8c8897792 100644 --- a/Open-ILS/web/opac/skin/default/xml/page_authbrowse.xml +++ b/Open-ILS/web/opac/skin/default/xml/page_authbrowse.xml @@ -2,12 +2,12 @@