mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-26 07:14:35 +02:00
FilterEditor: add compact search render support
We show the search box and a filter preview while not modifying the filter
This commit is contained in:
parent
44d5ee8fa0
commit
ac483a0fe6
@ -284,8 +284,38 @@ class FilterEditor extends AbstractWidget
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function renderSearch()
|
||||||
|
{
|
||||||
|
$html = ' <form method="post" class="inline" action="'
|
||||||
|
. $this->url()
|
||||||
|
. '"><input type="text" name="q" style="width: 8em" class="search" value="" placeholder="'
|
||||||
|
. t('Search...')
|
||||||
|
. '" /></form>';
|
||||||
|
|
||||||
|
if ($this->filter->isEmpty()) {
|
||||||
|
$title = t('Filter this list');
|
||||||
|
} else {
|
||||||
|
$title = t('Modify this filter');
|
||||||
|
if (! $this->filter->isEmpty()) {
|
||||||
|
$title .= ': ' . $this->filter;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $html
|
||||||
|
. '<a href="'
|
||||||
|
. $this->url()->with('modifyFilter', true)
|
||||||
|
. '" title="'
|
||||||
|
. $title
|
||||||
|
. '">'
|
||||||
|
. '<i class="icon-filter"></i>'
|
||||||
|
. '</a>';
|
||||||
|
}
|
||||||
|
|
||||||
public function render()
|
public function render()
|
||||||
{
|
{
|
||||||
|
if (! $this->url()->getParam('modifyFilter')) {
|
||||||
|
return $this->renderSearch() . $this->shorten($this->filter, 50);
|
||||||
|
}
|
||||||
|
|
||||||
return '<h3>'
|
return '<h3>'
|
||||||
. t('Modify this filter')
|
. t('Modify this filter')
|
||||||
. '</h3>'
|
. '</h3>'
|
||||||
@ -298,6 +328,14 @@ class FilterEditor extends AbstractWidget
|
|||||||
. '</form>';
|
. '</form>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function shorten($string, $length)
|
||||||
|
{
|
||||||
|
if (strlen($string) > $length) {
|
||||||
|
return substr($string, 0, $length) . '...';
|
||||||
|
}
|
||||||
|
return $string;
|
||||||
|
}
|
||||||
|
|
||||||
public function __toString()
|
public function __toString()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user