forked from Wavyzz/dolibarr
Fix: Option COMPANY_USE_SEARCH_TO_SELECT was not working for third party
selection when autocomplete is on.
This commit is contained in:
@@ -688,8 +688,21 @@ class Form
|
||||
if ($conf->use_javascript_ajax && $conf->global->COMPANY_USE_SEARCH_TO_SELECT && ! $forcecombo)
|
||||
{
|
||||
//$minLength = (is_numeric($conf->global->COMPANY_USE_SEARCH_TO_SELECT)?$conf->global->COMPANY_USE_SEARCH_TO_SELECT:2);
|
||||
|
||||
$out.= ajax_combobox($htmlname, $event);
|
||||
$out.= ajax_combobox($htmlname, $event, $conf->global->COMPANY_USE_SEARCH_TO_SELECT);
|
||||
/*
|
||||
if ($selected && empty($selected_input_value))
|
||||
{
|
||||
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
|
||||
$product = new Product($this->db);
|
||||
$product->fetch($selected);
|
||||
$selected_input_value=$product->ref;
|
||||
}
|
||||
// mode=1 means customers products
|
||||
$ajaxoptions=array();
|
||||
$urloption='htmlname='.$htmlname.'&outjson=1&filter='.urlencode($filter).'&showtype='.$showtype;
|
||||
$out.=ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT.'/societe/ajax/company.php', $urloption, $conf->global->COMPANY_USE_SEARCH_TO_SELECT, 0, $ajaxoptions);
|
||||
$out.='<input type="text" size="20" name="search_'.$htmlname.'" id="search_'.$htmlname.'" value="'.$selected_input_value.'" />';
|
||||
*/
|
||||
}
|
||||
|
||||
$out.= '<select id="'.$htmlname.'" class="flat" name="'.$htmlname.'">';
|
||||
|
||||
@@ -771,7 +771,11 @@ function confirmConstantAction(action, url, code, input, box, entity, yesButton,
|
||||
*/
|
||||
(function( $ ) {
|
||||
$.widget( "ui.combobox", {
|
||||
options: {
|
||||
minLengthToAutocomplete: 0,
|
||||
},
|
||||
_create: function() {
|
||||
var savMinLengthToAutocomplete = this.options.minLengthToAutocomplete;
|
||||
var self = this,
|
||||
select = this.element.hide(),
|
||||
selected = select.children( ":selected" ),
|
||||
@@ -781,7 +785,7 @@ function confirmConstantAction(action, url, code, input, box, entity, yesButton,
|
||||
.val( value )
|
||||
.autocomplete({
|
||||
delay: 0,
|
||||
minLength: 0,
|
||||
minLength: this.options.minLengthToAutocomplete,
|
||||
source: function( request, response ) {
|
||||
var matcher = new RegExp( $.ui.autocomplete.escapeRegex(request.term), "i" );
|
||||
response( select.children( "option" ).map(function() {
|
||||
@@ -854,7 +858,9 @@ function confirmConstantAction(action, url, code, input, box, entity, yesButton,
|
||||
}
|
||||
|
||||
// pass empty string as value to search for, displaying all results
|
||||
input.autocomplete({ minLength: 0 });
|
||||
input.autocomplete( "search", "" );
|
||||
input.autocomplete({ minLength: savMinLengthToAutocomplete });
|
||||
input.focus();
|
||||
});
|
||||
},
|
||||
|
||||
@@ -303,11 +303,12 @@ function ajax_dialog($title,$message,$w=350,$h=150)
|
||||
* @param array $event Event options. Example: array(array('method'=>'getContacts', 'url'=>dol_buildpath('/core/ajax/contacts.php',1), 'htmlname'=>'contactid', 'params'=>array('add-customer-contact'=>'disabled')))
|
||||
* @return string Return html string to convert a select field into a combo
|
||||
*/
|
||||
function ajax_combobox($htmlname, $event=array())
|
||||
function ajax_combobox($htmlname, $event=array(), $minLengthToAutocomplete=0)
|
||||
{
|
||||
$msg = '<script type="text/javascript">
|
||||
$(function() {
|
||||
$("#'.$htmlname.'").combobox({
|
||||
minLengthToAutocomplete : '.$minLengthToAutocomplete.',
|
||||
selected : function(event,ui) {
|
||||
var obj = '.json_encode($event).';
|
||||
$.each(obj, function(key,values) {
|
||||
|
||||
Reference in New Issue
Block a user