[icinga-checkins] icinga.org: icinga-web/next: Filter activity display missing

git at icinga.org git at icinga.org
Mon Apr 8 13:04:25 CEST 2013


Module: icinga-web
Branch: next
Commit: 401407b7ec55a3e3f30dc733e7bfcf0a94961ccc
URL:    https://git.icinga.org/?p=icinga-web.git;a=commit;h=401407b7ec55a3e3f30dc733e7bfcf0a94961ccc

Author: Marius Hein <marius.hein at netways.de>
Date:   Mon Apr  8 13:02:33 2013 +0200

Filter activity display missing

The filter window now knows the button and implement listeners
to set the class of active filters on json state or on
filterchange event.

fixes #3928

---

 .../Cronks/lib/js/Cronk/grid/MetaGridPanel.js      |   12 ++++-
 .../js/Icinga/Cronks/util/FilterEditorWindow.js    |   51 +++++++++++++------
 2 files changed, 44 insertions(+), 19 deletions(-)

diff --git a/app/modules/Cronks/lib/js/Cronk/grid/MetaGridPanel.js b/app/modules/Cronks/lib/js/Cronk/grid/MetaGridPanel.js
index 761956d..351027a 100644
--- a/app/modules/Cronks/lib/js/Cronk/grid/MetaGridPanel.js
+++ b/app/modules/Cronks/lib/js/Cronk/grid/MetaGridPanel.js
@@ -671,8 +671,10 @@ Ext.ns("Cronk.grid");
             });
 
             if (filters.length) {
-                this.filterHdl = new Icinga.Cronks.util.FilterEditorWindow(this,filters);
-                this.topToolbar.add(['-', {
+
+                // Button is extracted from creation because we need it
+                // on the filter window to mark active state #3928
+                var btn = Ext.create({
                     xtype: 'button',
                     text: _('View filter'),
                     iconCls: 'icinga-icon-pencil',
@@ -685,7 +687,11 @@ Ext.ns("Cronk.grid");
                         this.filterHdl.show();
                     },
                     scope: this
-                }]);
+                });
+
+                this.filterHdl = new Icinga.Cronks.util.FilterEditorWindow(this, filters, btn);
+
+                this.topToolbar.add(['-', btn]);
                 this.topToolbarFilterPos = this.topToolbar.items.length;
             }
         },
diff --git a/app/modules/Cronks/lib/js/Icinga/Cronks/util/FilterEditorWindow.js b/app/modules/Cronks/lib/js/Icinga/Cronks/util/FilterEditorWindow.js
index d7676a0..3b45d3f 100644
--- a/app/modules/Cronks/lib/js/Icinga/Cronks/util/FilterEditorWindow.js
+++ b/app/modules/Cronks/lib/js/Icinga/Cronks/util/FilterEditorWindow.js
@@ -21,37 +21,60 @@
 // {{{ICINGA_LICENSE_CODE}}}
 /*jshint browser:true, curly:false */
 /*global Ext: false, Icinga: false, _: false*/
-Ext.ns("Icinga.Cronks.util").FilterEditorWindow = function(grid,filters) {
+Ext.ns("Icinga.Cronks.util").FilterEditorWindow = function(grid, filters, btn) {
     "use strict";
-    var tree = new Icinga.Cronks.util.FilterEditor({
-        autoDestroy: false,
-        grid: grid,
-        filterCfg:filters
-    });
 
-    this.state = new Icinga.Cronks.util.FilterState({
-        autoDestroy: false,
-        grid: grid,
-        tree: tree
-    });
+    /**
+     * CSS class name for a button to mark filter active
+     * @type {string}
+     */
+    var filterActiveCls = 'activeFilter';
+
+    /**
+     * Mark the filter as active
+     *
+     * Sets the class on the button
+     *
+     * @param {Boolean} isActive
+     */
+    var changeActiveState = function(isActive) {
+        isActive = Boolean(isActive);
+        if (isActive === true) {
+            btn.addClass(filterActiveCls);
+        } else {
+            btn.removeClass(filterActiveCls);
+        }
+    };
 
     this.updateFromJsonString = function(json) {
+
         if(Ext.isString(json))
             this.filter = Ext.decode(json);
         else
             this.filter = json;
         if(this.state)
             this.state.update(this.filter);
+
+        changeActiveState(Ext.isEmpty(json) === false);
+
         grid.getStore().load();
     };
 
     this.show = function() {
-        tree = new Icinga.Cronks.util.FilterEditor({
+        var tree = new Icinga.Cronks.util.FilterEditor({
             autoDestroy: false,
             grid: grid,
             filterCfg:filters
         });
 
+        tree.on('filterchanged', function(fo) {
+            if (!fo) {
+                changeActiveState(false);
+            } else {
+                changeActiveState(true);
+            }
+        });
+
         this.state = new Icinga.Cronks.util.FilterState({
             autoDestroy: false,
             grid: grid,
@@ -94,8 +117,6 @@ Ext.ns("Icinga.Cronks.util").FilterEditorWindow = function(grid,filters) {
         });
     };
 
-
-    
     var registerEvents = function(filterPanel,cronkPanel) {
         // resizing must be done manually here
         var resizePanelHandler = function(resizedCmp) {
@@ -120,6 +141,4 @@ Ext.ns("Icinga.Cronks.util").FilterEditorWindow = function(grid,filters) {
             cronkPanel.removeListener("resize",resizePanelHandler);
         });    
     };
-    
-    
 };





More information about the icinga-checkins mailing list