);
sub grab_authority_browse_axes {
+ my ($self, $client, $full) = @_;
unless(scalar(keys(%authority_browse_axis_cache))) {
my $axes = new_editor->search_authority_browse_axis([
$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 {
/* propogate these? */
depthSelInit();
+ authoritySelInit();
setEnterFunc( $n( $('advanced.marc.tbody'), 'advanced.marc.value'), advMARCRun );
unHideMe($('adv_quick_search_sidebar'));
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 = "";
location.href = buildOPACLink(args);
}
-function authBrowseSubmit() {
+function advAuthorityBrowse() {
var selector = dojo.byId("authority_browse_axis");
var args = {"page": AUTHBROWSE};
args[PARAM_AUTHORITY_BROWSE_AXIS] =
-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"
+ );
+ }
+ );
+}
</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'
<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>
-
-