N°3207 - Global search: Keep input open and focus at the end of the query when running a search

This commit is contained in:
Molkobain
2021-01-20 11:02:59 +01:00
parent 54c5c8c016
commit d54e156ec2
5 changed files with 60 additions and 5 deletions

View File

@@ -46,6 +46,8 @@ class GlobalSearch extends UIBlock
/** @var string $sEndpoint Absolute endpoint URL of the search form */
protected $sEndpoint;
/** @var string Query currently in the input */
protected $sQuery;
/** @var array $aLastQueries */
protected $aLastQueries;
/** @var bool $bShowHistory Whether or not to display the elements in the history */
@@ -65,6 +67,7 @@ class GlobalSearch extends UIBlock
{
parent::__construct($sId);
$this->SetEndpoint(static::DEFAULT_ENDPOINT_REL_URL);
$this->SetQuery('');
$this->SetLastQueries($aLastQueries);
$this->bShowHistory = (bool) MetaModel::GetConfig()->Get('global_search.show_history');
$this->iMaxHistoryResults = (int) MetaModel::GetConfig()->Get('global_search.max_history_results');
@@ -98,6 +101,36 @@ class GlobalSearch extends UIBlock
return $this->sEndpoint;
}
/**
* @uses $sQuery
* @param string $sQuery
*
* @return $this
*/
public function SetQuery(string $sQuery)
{
$this->sQuery = $sQuery;
return $this;
}
/**
* @uses $sQuery
* @return string
*/
public function GetQuery(): string
{
return $this->sQuery;
}
/**
* @uses $sQuery
* @return bool
*/
public function HasQuery(): bool
{
return !empty($this->sQuery);
}
/**
* Set all the last queries at once
*