From a1300cc322c1297568d51c9541f234c0e57c5d86 Mon Sep 17 00:00:00 2001
From: Renaud Le Gac <legac@cppm.in2p3.fr>
Date: Mon, 10 Dec 2012 16:28:52 +0100
Subject: [PATCH] Add the private attribute initialWhere.

---
 static/plugin_dbui/src/jsonstore.js | 21 +++++++++++++++++++--
 1 file changed, 19 insertions(+), 2 deletions(-)

diff --git a/static/plugin_dbui/src/jsonstore.js b/static/plugin_dbui/src/jsonstore.js
index 9ab340fc..0a70891f 100644
--- a/static/plugin_dbui/src/jsonstore.js
+++ b/static/plugin_dbui/src/jsonstore.js
@@ -41,14 +41,23 @@ App.data.DirectStore = Ext.extend(Ext.data.DirectStore, {
      */
     autoLoad: true,
     autoSave: true,
-    
+
+    /**
+     * private parameter
+     * List of the where condition at startup. 
+     * It is a copy of the baseParams.where which can be modified by filter.
+     * The intialWhere configuration parameter can be used reseting filter
+     */
+    initialWhere: undefined,    
+
     /**
      * constructor
      */
     constructor: function (config) {
         
         var cfg, 
-            cfgWrt;
+            cfgWrt,
+            i;
 
         // configuration option with default value for 
         // the Ext.data.JsonWriter. Changing these options might break 
@@ -74,6 +83,14 @@ App.data.DirectStore = Ext.extend(Ext.data.DirectStore, {
             cfgWrt = Ext.copyTo({}, cfg, 'encode, listful, writeAllFields');
             cfg.writer = new Ext.data.JsonWriter(cfgWrt);    
         }
+
+        // keep a copy of the initial where condition
+        if ('where' in cfg.baseParams) {
+            cfg.initialWhere = [];
+             for (i = 0; i < cfg.baseParams.where.length; i += 1) {
+                cfg.initialWhere.push(cfg.baseParams.where[i]);
+            }
+        }
         
         // instantiate the store
         App.data.DirectStore.superclass.constructor.call(this, cfg);
-- 
GitLab