Browse Source

Bug 8278 - Replace YUI autocomplete in UNIMARC 210c plugin

This plugin, for pseudo-authority-control of publisher information,
used YUI autocomplete to pull existing publisher data from the
biblioitems table. Despite its name it is not UNIMARC-specific.
It assumes publisher name data is saved in biblioitems.

This patch converts the autocomplete to jQueryUI. The search
script has been amended to return valid JSON. The template has
been modified to enable the jQueryUI autocomplete and to add
structure more consistent with other popups.

To test, link the publisher name field in your MARC structure to
the unimarc_field_210c_bis.pl plugin. Open a MARC record for
editing and click the "tag editor" link to launch the plugin.
Type the first few letters of a publisher which exists in your
database. You should get an autocomplete menu of publishers
which match your search. Select one and click the "choose"
button to fill the field in the MARC editor.

Signed-off-by: Bernardo Gonzalez Kriegel <bgkriegel@gmail.com>
Comment: work as described. No errors.

Test: link 260b to plugin. Edit record and search first letters
of present editors. Menú appears and can select and fill value.

Why plugin 210c_bis talk about field 225a?

Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
Plugin now works correctly for me, even when linked
to 260$b in a MARC21 installation. All tests and QA script
pass.
Signed-off-by: Jared Camins-Esakov <jcamins@cpbibliography.com>
new/bootstrap-opac
Owen Leonard 11 years ago
committed by Jared Camins-Esakov
parent
commit
626c27baf9
  1. 10
      cataloguing/ysearch.pl
  2. 91
      koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/value_builder/unimarc_field_210c_bis.tt

10
cataloguing/ysearch.pl

@ -31,7 +31,7 @@ use C4::Charset;
use C4::Auth qw/check_cookie_auth/;
my $input = new CGI;
my $query = $input->param('query');
my $query = $input->param('term');
my $table = $input->param('table');
my $field = $input->param('field');
@ -54,8 +54,14 @@ $sql .= qq( ORDER BY $field);
my $sth = $dbh->prepare($sql);
$sth->execute("$query%", "% $query%", "%-$query%");
print "[";
my $i = 0;
while ( my $rec = $sth->fetchrow_hashref ) {
print nsb_clean($rec->{$field}) . "\n";
if($i > 0){ print ","; }
print "{\"fieldvalue\":\"" . nsb_clean($rec->{$field}) . "\"" .
"}";
$i++;
}
print "]";

91
koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/value_builder/unimarc_field_210c_bis.tt

@ -1,65 +1,51 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD Xhtml 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>UNIMARC field 225a builder</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="[% yuipath %]/utilities/utilities.js"></script>
<script type="text/javascript" src="[% yuipath %]/datasource/datasource.js"></script>
<script type="text/javascript" src="[% yuipath %]/autocomplete/autocomplete-min.js"></script>
<link rel="stylesheet" type="text/css" href="[% themelang %]/css/staff-global.css" />
</head>
<body id="cat_unimarc_field_210c_bis" class="cat">
<div id="header_search">
[% INCLUDE 'doc-head-open.inc' %]
<title>Koha &rsaquo; UNIMARC field 225a builder</title>
[% INCLUDE 'doc-head-close.inc' %]
<style type="text/css">
#custom-doc { width:37.85em;*width:36.93em;min-width:492px; margin:auto; text-align:left; }
</style>
<script type="text/javascript">
//<![CDATA[
YAHOO.util.Event.onContentReady("header_search", function() {
new function() {
// Define a custom formatter function
this.fnCustomFormatter = function(oResultItem, sQuery) {
var name = oResultItem[0];
var aMarkup = [
"<div class=\"sample-result\">",
name,
"<\/div>"];
return (aMarkup.join(""));
};
$(document).ready(function(){
$( "#findvalue" ).autocomplete({
source: "/cgi-bin/koha/cataloguing/ysearch.pl?table=biblioitems&field=publishercode",
minLength: 3,
select: function( event, ui ) {
$( "#findvalue" ).val( ui.item.fieldvalue );
return false;
}
})
.data( "autocomplete" )._renderItem = function( ul, item ) {
return $( "<li></li>" )
.data( "item.autocomplete", item )
.append( "<a>" + item.fieldvalue + "</a>" )
.appendTo( ul );
};
// Instantiate one XHR DataSource and define schema as an array:
// ["Record Delimiter",
// "Field Delimiter"]
this.oACDS = new YAHOO.widget.DS_XHR("/cgi-bin/koha/cataloguing/ysearch.pl", ["\n", "\t"]);
this.oACDS.scriptQueryAppend = "table=biblioitems&field=publishercode";
this.oACDS.responseType = YAHOO.widget.DS_XHR.TYPE_FLAT;
this.oACDS.maxCacheEntries = 60;
this.oACDS.queryMatchSubset = false;
// Instantiate first AutoComplete
var myInput = document.getElementById('findvalue');
var myContainer = document.getElementById('yvaluecontainer');
this.oAutoComp = new YAHOO.widget.AutoComplete(myInput,myContainer,this.oACDS);
//this.oAutoComp.delimChar = ";";
this.oAutoComp.queryDelay = 1;
this.oAutoComp.formatResult = this.fnCustomFormatter;
this.oAutoComp.maxResultsDisplayed = 1000;
}
});
});
//]]>
</script>
<div id="mainbloc">
<div id="plugin">
</head>
<body id="cat_unimarc_field_210c_bis" class="cat">
<div id="custom-doc" class="yui-t7">
<div id="bd">
<h1>UNIMARC field 225a builder</h1>
<div class="autocomplete">
<form name="f_pop" onsubmit="javascript:report()" action="">
<div id="borrowerautocomplete" class="autocomplete">
<input autocomplete="off" id="findvalue" name="findvalue" size="40" class="focus" type="text" /><br /><br />
<input id="ysearchsubmit" type="submit" class="submit" value="Submit" />
<div id="yvaluecontainer"></div>
<div id="fieldautocomplete" class="autocomplete">
<fieldset>
<input autocomplete="off" id="findvalue" name="findvalue" size="40" class="focus" type="text" />
<fieldset class="action">
<input type="submit" class="submit" value="Choose" />
</fieldset>
</fieldset>
</div>
</form>
</div>
</div>
</div>
</div>
<script type="text/javascript">
function report() {
@ -71,5 +57,4 @@ YAHOO.util.Event.onContentReady("header_search", function() {
return false;
}
</script>
</body>
</html>
[% INCLUDE 'popup-bottom.inc' %]
Loading…
Cancel
Save