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>
This commit is contained in:
parent
42ed28573e
commit
626c27baf9
2 changed files with 47 additions and 56 deletions
|
@ -31,7 +31,7 @@ use C4::Charset;
|
||||||
use C4::Auth qw/check_cookie_auth/;
|
use C4::Auth qw/check_cookie_auth/;
|
||||||
|
|
||||||
my $input = new CGI;
|
my $input = new CGI;
|
||||||
my $query = $input->param('query');
|
my $query = $input->param('term');
|
||||||
my $table = $input->param('table');
|
my $table = $input->param('table');
|
||||||
my $field = $input->param('field');
|
my $field = $input->param('field');
|
||||||
|
|
||||||
|
@ -54,8 +54,14 @@ $sql .= qq( ORDER BY $field);
|
||||||
my $sth = $dbh->prepare($sql);
|
my $sth = $dbh->prepare($sql);
|
||||||
$sth->execute("$query%", "% $query%", "%-$query%");
|
$sth->execute("$query%", "% $query%", "%-$query%");
|
||||||
|
|
||||||
|
print "[";
|
||||||
|
my $i = 0;
|
||||||
while ( my $rec = $sth->fetchrow_hashref ) {
|
while ( my $rec = $sth->fetchrow_hashref ) {
|
||||||
print nsb_clean($rec->{$field}) . "\n";
|
if($i > 0){ print ","; }
|
||||||
|
print "{\"fieldvalue\":\"" . nsb_clean($rec->{$field}) . "\"" .
|
||||||
|
"}";
|
||||||
|
$i++;
|
||||||
}
|
}
|
||||||
|
print "]";
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,65 +1,51 @@
|
||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD Xhtml 1.0 Transitional//EN"
|
[% INCLUDE 'doc-head-open.inc' %]
|
||||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
<title>Koha › UNIMARC field 225a builder</title>
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
[% INCLUDE 'doc-head-close.inc' %]
|
||||||
<head>
|
<style type="text/css">
|
||||||
<title>UNIMARC field 225a builder</title>
|
#custom-doc { width:37.85em;*width:36.93em;min-width:492px; margin:auto; text-align:left; }
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
</style>
|
||||||
<script type="text/javascript" src="[% yuipath %]/utilities/utilities.js"></script>
|
<script type="text/javascript">
|
||||||
<script type="text/javascript" src="[% yuipath %]/datasource/datasource.js"></script>
|
//<![CDATA[
|
||||||
<script type="text/javascript" src="[% yuipath %]/autocomplete/autocomplete-min.js"></script>
|
$(document).ready(function(){
|
||||||
<link rel="stylesheet" type="text/css" href="[% themelang %]/css/staff-global.css" />
|
$( "#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 );
|
||||||
|
};
|
||||||
|
|
||||||
|
});
|
||||||
|
//]]>
|
||||||
|
</script>
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
<body id="cat_unimarc_field_210c_bis" class="cat">
|
<body id="cat_unimarc_field_210c_bis" class="cat">
|
||||||
<div id="header_search">
|
|
||||||
<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(""));
|
|
||||||
};
|
|
||||||
|
|
||||||
// Instantiate one XHR DataSource and define schema as an array:
|
<div id="custom-doc" class="yui-t7">
|
||||||
// ["Record Delimiter",
|
<div id="bd">
|
||||||
// "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">
|
<h1>UNIMARC field 225a builder</h1>
|
||||||
<div class="autocomplete">
|
<div class="autocomplete">
|
||||||
<form name="f_pop" onsubmit="javascript:report()" action="">
|
<form name="f_pop" onsubmit="javascript:report()" action="">
|
||||||
<div id="borrowerautocomplete" class="autocomplete">
|
<div id="fieldautocomplete" class="autocomplete">
|
||||||
<input autocomplete="off" id="findvalue" name="findvalue" size="40" class="focus" type="text" /><br /><br />
|
<fieldset>
|
||||||
<input id="ysearchsubmit" type="submit" class="submit" value="Submit" />
|
<input autocomplete="off" id="findvalue" name="findvalue" size="40" class="focus" type="text" />
|
||||||
<div id="yvaluecontainer"></div>
|
<fieldset class="action">
|
||||||
|
<input type="submit" class="submit" value="Choose" />
|
||||||
|
</fieldset>
|
||||||
|
</fieldset>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
function report() {
|
function report() {
|
||||||
|
@ -71,5 +57,4 @@ YAHOO.util.Event.onContentReady("header_search", function() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
</body>
|
[% INCLUDE 'popup-bottom.inc' %]
|
||||||
</html>
|
|
Loading…
Reference in a new issue