Koha/koha-tmpl/intranet-tmpl/prog/js/auth-finder-search.js
Fridolin Somers 36d96180ae
Bug 35903: In cataloguing authority plugin using autocomplete must set operator exact
When cataloguing and using authority plugin, there is auto-completion on inputs and default operator is "contains".
When using auto-completion and selecting a result it would be logical to set operator "exact".

See doc https://api.jqueryui.com/autocomplete/#event-select

This patch also adds auto-completion missing on "Search all headings".

Test plan:
1) Create a new authority Topical Term with heading "Cart"
2) Create a new authority Topical Term with heading "Carthage"
3) Create a new biblio record
4) Use authority plugin on field 650
5) You see current operator are "contains"
6) Enter "Car" in "Search main heading ($a only):"
7) You see auto-completion showing "Cart" and "Carthage"
8) Click on "Cart"
9) You see operator changes to "is exactly"
10) Submit form to see the results
11) Clear form and repeat 6-9 for the three other inputs

Signed-off-by: Michelle Spinney <mspinney@clamsnet.org>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
2024-04-29 09:35:44 +02:00

155 lines
5.1 KiB
JavaScript

/* global index authtypecode */
$(document).ready(function(){
$("#clear").on("click",function(e){
e.preventDefault();
finderjump('blinddetail-biblio-search.pl?authid=0&index=' + index );
});
$("#createnew").on("click",function(e){
e.preventDefault();
finderjump('authorities.pl?index=' + index + '&authtypecode=' + authtypecode, 'full' );
});
// marclistanywhere
$( "#value_any" ).autocomplete({
source: function(request, response) {
$.ajax({
url: "/cgi-bin/koha/authorities/ysearch.pl",
dataType: "json",
data: {
authtypecode : authtypecode,
term: request.term,
op: "do_search",
type: "intranet",
and_or: "and",
operator: "start",
orderby: "HeadingAsc",
querytype: "all"
},
success: function(data) {
response( $.map( data, function( item ) {
return {
label: item.summary,
value: item.summary
};
}));
}
});
},
select: function( event, ui ) {
$("#marclistanywhere").val("exact");
},
minLength: 3,
});
// marclistheading
$( "#value_match" ).autocomplete({
source: function(request, response) {
$.ajax({
url: "/cgi-bin/koha/authorities/ysearch.pl",
dataType: "json",
data: {
authtypecode : authtypecode,
term: request.term,
op: "do_search",
type: "intranet",
and_or: "and",
operator: "start",
orderby: "HeadingAsc",
querytype: "match"
},
success: function(data) {
response( $.map( data, function( item ) {
return {
label: item.summary,
value: item.summary
};
}));
}
});
},
select: function( event, ui ) {
$("#marclistheading").val("exact");
},
minLength: 3,
});
// mainentry
$( "#value_main" ).autocomplete({
source: function(request, response) {
$.ajax({
url: "/cgi-bin/koha/authorities/ysearch.pl",
dataType: "json",
data: {
authtypecode : authtypecode,
term: request.term,
op: "do_search",
type: "intranet",
and_or: "and",
operator: "start",
orderby: "HeadingAsc",
querytype: "mainentry"
},
success: function(data) {
response( $.map( data, function( item ) {
return {
label: item.summary,
value: item.summary
};
}));
}
});
},
select: function( event, ui ) {
$("#mainentry").val("exact");
},
minLength: 3,
});
// mainmainentry
$( "#value_mainstr" ).autocomplete({
source: function(request, response) {
$.ajax({
url: "/cgi-bin/koha/authorities/ysearch.pl",
dataType: "json",
data: {
authtypecode : authtypecode,
term: request.term,
op: "do_search",
type: "intranet",
and_or: "and",
operator: "start",
orderby: "HeadingAsc",
querytype: "mainmainentry"
},
success: function(data) {
response( $.map( data, function( item ) {
return {
label: item.summary,
value: item.summary
};
}));
}
});
},
select: function( event, ui ) {
$("#mainmainentry").val("exact");
},
minLength: 3,
});
$("#clear-form").click(function(){
setTimeout(function(){
$(":input[type='text']").val('');
$("#mainmainentry").val("contains");
$("#mainentry").val("contains");
$("#marclistheading").val("contains");
$("#marclistanywhere").val("contains");
$("#orderby").val("HeadingAsc");
}, 50);
return true;
});
});
function finderjump(page, full){
var window_size = '';
if( full != "full"){
window_size = 'width=100,height=100,';
}
window.open(page,'', window_size + 'resizable=yes,toolbar=false,scrollbars=yes,top');
}