From 1defe5bd0438c9f2d4b3d4f14ee9e00f99e49dcd Mon Sep 17 00:00:00 2001
From: legac <renaud.legac@free.fr>
Date: Sat, 6 Oct 2012 19:31:16 +0200
Subject: [PATCH] First tentative to run the filterbox widget.

---
 languages/fr-fr.py                     |  3 +++
 models/widgets_fields.py               |  4 ++--
 static/plugin_dbui/src/appfilterbox.js | 32 ++++++++++++++++++++++++++
 3 files changed, 37 insertions(+), 2 deletions(-)
 create mode 100644 static/plugin_dbui/src/appfilterbox.js

diff --git a/languages/fr-fr.py b/languages/fr-fr.py
index 04bb98eb..e492c7de 100644
--- a/languages/fr-fr.py
+++ b/languages/fr-fr.py
@@ -35,8 +35,11 @@
 'Id': 'Id',
 'Last Page': 'Dernière Page',
 'Max Records': 'Max Records',
+'My Axes': 'My Axes',
+'My Axis': 'My Axis',
 'My Date': 'My Date',
 'My Format': 'My Format',
+'My Granularity': 'My Granularity',
 'My Int': 'My Int',
 'My List': 'My List',
 'My String': 'My String',
diff --git a/models/widgets_fields.py b/models/widgets_fields.py
index c0a927a1..87c03bb3 100755
--- a/models/widgets_fields.py
+++ b/models/widgets_fields.py
@@ -32,11 +32,11 @@ fieldsModifier.configure_field('my_axis',
                                mode='local',
                                store='axesStore',
                                valueField='axis', 
-                               xtype='xcombobox')
+                               xtype='xfilterbox')
 
 fieldsModifier.configure_field('my_granularity',
                                displayField='granularity',
                                mode='local',
                                store='axesStore',
                                valueField='granularity', 
-                               xtype='xcombobox')
+                               xtype='xfilterbox')
diff --git a/static/plugin_dbui/src/appfilterbox.js b/static/plugin_dbui/src/appfilterbox.js
new file mode 100644
index 00000000..b484d07b
--- /dev/null
+++ b/static/plugin_dbui/src/appfilterbox.js
@@ -0,0 +1,32 @@
+/**
+ * combobox setup to filter the content of its local store
+ * 
+ * @extends Ext.form.ComboBox 
+ *
+ */
+Ext.namespace('App.form');
+
+App.form.FilterBox = Ext.extend(App.form.ComboBox, {
+    
+    /**
+     * private method require by the ExtJS component model
+     */	
+    initComponent: function () {
+
+        // construct the underlying class. DON'T MOVE
+        App.form.FilterBox.superclass.initComponent.call(this);
+
+        //logic to filter the content of the store to the combobox value
+        this.on('select', this.onChange, this);
+        
+    },
+
+    /**
+     * Handler to catch a change in field value anf to filter the store
+     */    
+    onChange: function (combo, record, index) {
+        this.store.filter(this.displayField, combo.getValue());
+    }
+});
+
+Ext.reg('xfilterbox', App.form.FilterBox);
-- 
GitLab