Render search hint without using a view script

This commit is contained in:
Yonas Habteab 2022-06-13 08:57:21 +02:00
parent a726348718
commit 1ecbce7041
3 changed files with 18 additions and 11 deletions

View File

@ -4,6 +4,8 @@
namespace Icinga\Controllers;
use Icinga\Web\Widget\SearchDashboard;
use ipl\Html\HtmlElement;
use ipl\Html\Text;
use ipl\Web\Compat\CompatController;
/**
@ -22,5 +24,17 @@ class SearchController extends CompatController
public function hintAction()
{
$this->getTabs()->disableLegacyExtensions();
$this->addContent(new HtmlElement('h1', null, Text::create(t('I\'m ready to search, waiting for your input'))));
$p = new HtmlElement('p');
$p->addHtml(new HtmlElement('strong', null, Text::create(t('Hint') . ': ')));
$p->addHtml(Text::create(t(
'Please use the asterisk (*) as a placeholder for wildcard searches. For convenience I\'ll always add' .
' a wildcard in front and after your search string.'
)));
$this->addContent($p);
}
}

View File

@ -1,8 +0,0 @@
<div class="content">
<h1><?= $this->translate("I'm ready to search, waiting for your input") ?></h1>
<p><strong><?= $this->translate('Hint') ?>: </strong><?= $this->translate(
'Please use the asterisk (*) as a placeholder for wildcard searches.'
. " For convenience I'll always add a wildcard in front and after your"
. ' search string.'
) ?></p>
</div>

View File

@ -5,6 +5,7 @@ namespace Icinga\Web\Widget;
use Icinga\Exception\Http\HttpNotFoundException;
use Icinga\Application\Icinga;
use Icinga\Web\Dashboard\Dashboard;
use Icinga\Web\Dashboard\DashboardHome;
use Icinga\Web\Dashboard\Dashlet;
use Icinga\Web\Url;
@ -12,7 +13,7 @@ use Icinga\Web\Url;
/**
* Class SearchDashboard display multiple search views on a single search page
*/
class SearchDashboard extends \Icinga\Web\Dashboard\Dashboard
class SearchDashboard extends Dashboard
{
/**
* Name for the search home
@ -58,7 +59,7 @@ class SearchDashboard extends \Icinga\Web\Dashboard\Dashboard
return $this->tabs;
}
public function getActiveHome()
public function getActiveHome(): ?DashboardHome
{
return $this->searchHome;
}
@ -70,7 +71,7 @@ class SearchDashboard extends \Icinga\Web\Dashboard\Dashboard
*
* @return $this
*/
public function search($searchString = '')
public function search(string $searchString = ''): self
{
$pane = $this->searchHome->createEntry(self::SEARCH_PANE)->getEntry(self::SEARCH_PANE);
$pane->setTitle(t('Search'));