mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-21 09:38:48 +02:00
N°2847 - Quick create: Add config. parameter for max. autocomplete results ('quick_create.max_autocomplete_results')
This commit is contained in:
@@ -1136,6 +1136,14 @@ class Config
|
||||
'source_of_value' => '',
|
||||
'show_in_conf_sample' => false,
|
||||
),
|
||||
'quick_create.max_autocomplete_results' => array(
|
||||
'type' => 'integer',
|
||||
'description' => 'Max. number of elements returned by the autocomplete.',
|
||||
'default' => 10,
|
||||
'value' => 10,
|
||||
'source_of_value' => '',
|
||||
'show_in_conf_sample' => false,
|
||||
),
|
||||
'global_search.enabled' => array(
|
||||
'type' => 'bool',
|
||||
'description' => 'Whether or not the global search is enabled',
|
||||
|
||||
@@ -26,7 +26,7 @@ $(function()
|
||||
// default options
|
||||
options:
|
||||
{
|
||||
|
||||
max_autocomplete_results: 10,
|
||||
},
|
||||
css_classes:
|
||||
{
|
||||
@@ -58,7 +58,6 @@ $(function()
|
||||
{
|
||||
const me = this;
|
||||
|
||||
// TODO 2.8.0 Use config parameter for maxOptions value
|
||||
// Instantiate selectize.js on input
|
||||
this.element.find(this.js_selectors.input).selectize({
|
||||
dropdownParent: this.js_selectors.select_dropdown_parent,
|
||||
@@ -66,7 +65,7 @@ $(function()
|
||||
dropdownContentClass: 'ibo-quick-create--compartment-results--element',
|
||||
openOnFocus: false,
|
||||
maxItems: 1,
|
||||
maxOptions: 10,
|
||||
maxOptions: this.options.max_autocomplete_results,
|
||||
});
|
||||
|
||||
// Remove some inline styling from the widget
|
||||
|
||||
@@ -21,6 +21,7 @@ namespace Combodo\iTop\Application\UI\Component\QuickCreate;
|
||||
|
||||
|
||||
use Combodo\iTop\Application\UI\UIBlock;
|
||||
use MetaModel;
|
||||
use UserRights;
|
||||
|
||||
/**
|
||||
@@ -52,6 +53,8 @@ class QuickCreate extends UIBlock
|
||||
protected $aAvailableClasses;
|
||||
/** @var array $aLastClasses */
|
||||
protected $aLastClasses;
|
||||
/** @var int $iMaxAutocompleteResults Max. number of elements returned by the autocomplete */
|
||||
protected $iMaxAutocompleteResults;
|
||||
|
||||
/**
|
||||
* QuickCreate constructor.
|
||||
@@ -67,6 +70,7 @@ class QuickCreate extends UIBlock
|
||||
parent::__construct($sId);
|
||||
$this->aAvailableClasses = UserRights::GetAllowedClasses(UR_ACTION_CREATE, array('bizmodel'), true);
|
||||
$this->aLastClasses = $aLastClasses;
|
||||
$this->iMaxAutocompleteResults = (int) MetaModel::GetConfig()->Get('quick_create.max_autocomplete_results');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -102,4 +106,13 @@ class QuickCreate extends UIBlock
|
||||
{
|
||||
return $this->aLastClasses;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see $iMaxAutocompleteResults
|
||||
* @return int
|
||||
*/
|
||||
public function GetMaxAutocompleteResults(): int
|
||||
{
|
||||
return $this->iMaxAutocompleteResults;
|
||||
}
|
||||
}
|
||||
@@ -1 +1,3 @@
|
||||
$('#{{ oUIBlock.GetId() }}').quick_create();
|
||||
$('#{{ oUIBlock.GetId() }}').quick_create({
|
||||
max_autocomplete_results: {{ oUIBlock.GetMaxAutocompleteResults() }}
|
||||
});
|
||||
Reference in New Issue
Block a user