diff --git a/core/config.class.inc.php b/core/config.class.inc.php index 31a7d813b..7faec4710 100644 --- a/core/config.class.inc.php +++ b/core/config.class.inc.php @@ -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.', diff --git a/dictionaries/ui/components/en.dictionary.itop.global-search.php b/dictionaries/ui/components/en.dictionary.itop.global-search.php index 37953c28c..07c4f6277 100644 --- a/dictionaries/ui/components/en.dictionary.itop.global-search.php +++ b/dictionaries/ui/components/en.dictionary.itop.global-search.php @@ -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', )); \ No newline at end of file diff --git a/sources/application/UI/Base/Component/GlobalSearch/GlobalSearch.php b/sources/application/UI/Base/Component/GlobalSearch/GlobalSearch.php index 5d392a69d..b09e869e4 100644 --- a/sources/application/UI/Base/Component/GlobalSearch/GlobalSearch.php +++ b/sources/application/UI/Base/Component/GlobalSearch/GlobalSearch.php @@ -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 diff --git a/templates/base/components/global-search/layout.html.twig b/templates/base/components/global-search/layout.html.twig index 8a3b3660e..b4b3b4c1e 100644 --- a/templates/base/components/global-search/layout.html.twig +++ b/templates/base/components/global-search/layout.html.twig @@ -11,7 +11,11 @@ {{ 'UI:Component:GlobalSearch:Recents:Title'|dict_s }}
- {% if oUIBlock.GetLastQueries()|length > 0 %} + {% if oUIBlock.GetShowHistory == false %} +
+
{{ 'UI:Component:QuickCreate:HistoryDisabled'|dict_s }}
+
+ {% elseif oUIBlock.GetLastQueries()|length > 0 %} {% for aQuery in oUIBlock.GetLastQueries() %} {% if aQuery.icon_url is defined %}