N°3621 - Add config. parameter to disable "global search" history

This commit is contained in:
Molkobain
2021-01-13 10:53:11 +01:00
parent 9fccb6dd3f
commit 0a4db9bd50
4 changed files with 26 additions and 1 deletions

View File

@@ -1178,6 +1178,14 @@ class Config
'source_of_value' => '',
'show_in_conf_sample' => false,
],
'global_search.show_history' => [
'type' => 'bool',
'description' => 'Whether or not to display the elements in the history',
'default' => true,
'value' => true,
'source_of_value' => '',
'show_in_conf_sample' => false,
],
'global_search.max_history_results' => [
'type' => 'integer',
'description' => 'Max. number of elements in the history.',

View File

@@ -23,4 +23,5 @@ Dict::Add('EN US', 'English', 'English', array(
'UI:Component:GlobalSearch:Input:Placeholder' => 'Search...',
'UI:Component:GlobalSearch:Recents:Title' => 'Recents',
'UI:Component:GlobalSearch:LastQueries:NoQuery:Placeholder' => 'You haven\'t run any search yet',
'UI:Component:GlobalSearch:HistoryDisabled' => 'History is disabled',
));

View File

@@ -48,6 +48,8 @@ class GlobalSearch extends UIBlock
protected $sEndpoint;
/** @var array $aLastQueries */
protected $aLastQueries;
/** @var bool $bShowHistory Whether or not to display the elements in the history */
protected $bShowHistory;
/** @var int $iMaxHistoryResults Max. number of elements in the history */
protected $iMaxHistoryResults;
@@ -64,6 +66,7 @@ class GlobalSearch extends UIBlock
parent::__construct($sId);
$this->SetEndpoint(static::DEFAULT_ENDPOINT_REL_URL);
$this->SetLastQueries($aLastQueries);
$this->bShowHistory = (bool) MetaModel::GetConfig()->Get('global_search.show_history');
$this->iMaxHistoryResults = (int) MetaModel::GetConfig()->Get('global_search.max_history_results');
}
@@ -119,6 +122,15 @@ class GlobalSearch extends UIBlock
return $this->aLastQueries;
}
/**
* @see $bShowHistory
* @return bool
*/
public function GetShowHistory(): bool
{
return $this->bShowHistory;
}
/**
* @see $iMaxHistoryResults
* @return int

View File

@@ -11,7 +11,11 @@
<span>{{ 'UI:Component:GlobalSearch:Recents:Title'|dict_s }}</span>
</div>
<div class="ibo-global-search--compartment-content" data-role="ibo-global-search--compartment-content">
{% if oUIBlock.GetLastQueries()|length > 0 %}
{% if oUIBlock.GetShowHistory == false %}
<div class="ibo-global-search--compartment--placeholder">
<div class="ibo-global-search--compartment--placeholder-hint">{{ 'UI:Component:QuickCreate:HistoryDisabled'|dict_s }}</div>
</div>
{% elseif oUIBlock.GetLastQueries()|length > 0 %}
{% for aQuery in oUIBlock.GetLastQueries() %}
<a href="#" class="ibo-global-search--compartment-element" data-role="ibo-global-search--compartment-element" data-query-raw="{{ aQuery.query }}" title="{{ aQuery.query }}">
{% if aQuery.icon_url is defined %}