N°3887 - Harmonize number of autocomplete displayed results throughout the app

This commit is contained in:
Molkobain
2021-04-06 11:56:30 +02:00
parent f6be3736fd
commit 4c289edac7
6 changed files with 62 additions and 16 deletions

View File

@@ -26,6 +26,7 @@ use Combodo\iTop\Form\Validator\NotEmptyExtKeyValidator;
use DBObjectSet;
use DBSearch;
use FieldExpression;
use MetaModel;
use ScalarExpression;
/**
@@ -43,10 +44,22 @@ class SelectObjectField extends Field
/** @var \DBSearch $oSearch */
protected $oSearch;
/** @var int $iMaximumComboLength */
/**
* @see \Config 'max_combo_length'
* @var int $iMaximumComboLength
*/
protected $iMaximumComboLength;
/** @var int $iMinAutoCompleteChars */
/**
* @see \Config 'min_autocomplete_chars'
* @var int $iMinAutoCompleteChars
*/
protected $iMinAutoCompleteChars;
/**
* @see \Config 'max_autocomplete_results'
* @var int
* @since 3.0.0
*/
protected $iMaxAutoCompleteResults;
/** @var bool $bHierarchical */
protected $bHierarchical;
/** @var int $iControlType */
@@ -61,8 +74,9 @@ class SelectObjectField extends Field
{
parent::__construct($sId, $onFinalizeCallback);
$this->oSearch = null;
$this->iMaximumComboLength = null;
$this->iMinAutoCompleteChars = 3;
$this->iMaximumComboLength = MetaModel::GetConfig()->Get('max_combo_length');
$this->iMinAutoCompleteChars = MetaModel::GetConfig()->Get('min_autocomplete_chars');
$this->iMaxAutoCompleteResults = MetaModel::GetConfig()->Get('max_autocomplete_results');
$this->bHierarchical = false;
$this->iControlType = self::CONTROL_SELECT;
$this->sSearchEndpoint = null;
@@ -104,6 +118,21 @@ class SelectObjectField extends Field
return $this;
}
/**
* @see static::$iMaxAutoCompleteResults
*
* @param int $iMaxAutoCompleteResults
*
* @return $this;
* @since 3.0.0
*/
public function SetMaxAutoCompleteResults(int $iMaxAutoCompleteResults)
{
$this->iMaxAutoCompleteResults = $iMaxAutoCompleteResults;
return $this;
}
/**
* @param bool $bHierarchical
*
@@ -187,6 +216,16 @@ class SelectObjectField extends Field
return $this->iMinAutoCompleteChars;
}
/**
* @see static::$iMaxAutoCompleteResults
* @return int
* @since 3.0.0
*/
public function GetMaxAutoCompleteResults(): int
{
return $this->iMaxAutoCompleteResults;
}
/**
* @return bool
*/