[icinga-checkins] icinga.org: icingaweb2/master: Control whether a filter editor should be rendered via setVisible()

git at icinga.org git at icinga.org
Sat Feb 27 22:50:03 CET 2016


Module: icingaweb2
Branch: master
Commit: d8b14cb772a13f54f711cd39d535b8271df56fe5
URL:    https://git.icinga.org/?p=icingaweb2.git;a=commit;h=d8b14cb772a13f54f711cd39d535b8271df56fe5

Author: Eric Lippmann <eric.lippmann at netways.de>
Date:   Sat Feb 27 15:51:13 2016 +0100

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

---

 library/Icinga/Web/Widget/FilterEditor.php |   34 ++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)

diff --git a/library/Icinga/Web/Widget/FilterEditor.php b/library/Icinga/Web/Widget/FilterEditor.php
index d6f186f..f512ffe 100644
--- a/library/Icinga/Web/Widget/FilterEditor.php
+++ b/library/Icinga/Web/Widget/FilterEditor.php
@@ -56,6 +56,13 @@ class FilterEditor extends AbstractWidget
     private $selectedIdx;
 
     /**
+     * Whether the filter control is visible
+     *
+     * @var bool
+     */
+    protected $visible = true;
+
+    /**
      * Create a new FilterWidget
      *
      * @param Filter $filter Your filter
@@ -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>';
         }



More information about the icinga-checkins mailing list