Control whether a filter editor should be rendered via setVisible()
We (may) have situations where a controller or view has to access the filter editor being created via Controller::setupFilterControl(). This is impossible if the view is compact because the filterEditor will be unset. This change introduces FilterEditor::setVisible() for giving the responsibility of rendering to the filter editor. Controller::setupFilterControl() will be adapted accordingly. refs #10778
This commit is contained in:
parent
c5aab53745
commit
d8b14cb772
|
@ -55,6 +55,13 @@ class FilterEditor extends AbstractWidget
|
|||
*/
|
||||
private $selectedIdx;
|
||||
|
||||
/**
|
||||
* Whether the filter control is visible
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $visible = true;
|
||||
|
||||
/**
|
||||
* Create a new FilterWidget
|
||||
*
|
||||
|
@ -144,6 +151,30 @@ class FilterEditor extends AbstractWidget
|
|||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get whether the filter control is visible
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isVisible()
|
||||
{
|
||||
return $this->visible;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set whether the filter control is visible
|
||||
*
|
||||
* @param bool $visible
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setVisible($visible)
|
||||
{
|
||||
$this->visible = (bool) $visible;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
protected function redirectNow($url)
|
||||
{
|
||||
$response = Icinga::app()->getFrontController()->getResponse();
|
||||
|
@ -731,6 +762,9 @@ class FilterEditor extends AbstractWidget
|
|||
|
||||
public function render()
|
||||
{
|
||||
if (! $this->visible) {
|
||||
return '';
|
||||
}
|
||||
if (! $this->preservedUrl()->getParam('modifyFilter')) {
|
||||
return '<div class="filter">' . $this->renderSearch() . $this->view()->escape($this->shorten($this->filter, 50)) . '</div>';
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue