From 8bfd86d452b599db58e93bb41934ddd3a751a99a Mon Sep 17 00:00:00 2001
From: Renaud Le Gac <legac@cppm.in2p3.fr>
Date: Sat, 8 Mar 2014 11:29:40 +0100
Subject: [PATCH] Add the configuration baseParams to the PanelwithUrlSlector.

---
 controllers/reports.py                          |  2 +-
 models/widgets_viewport.py                      |  1 +
 static/plugin_dbui/src/panel/WithUrlSelector.js | 12 ++++++++++++
 views/reports/report_2.html                     |  6 +++++-
 4 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/controllers/reports.py b/controllers/reports.py
index 6fb43845..5440b361 100644
--- a/controllers/reports.py
+++ b/controllers/reports.py
@@ -30,7 +30,7 @@ def report_2():
     time.sleep(5)
     
     # standard response with the selected values
-    return dict(test=selector.as_dict())
+    return dict(test=selector.as_dict(), vars=request.vars)
 
 
 def report_3():
diff --git a/models/widgets_viewport.py b/models/widgets_viewport.py
index a7fd315e..f5d1af81 100644
--- a/models/widgets_viewport.py
+++ b/models/widgets_viewport.py
@@ -49,6 +49,7 @@ leaf_1 = dbui.Panel(html="salut ma poule")
 
 leaf_2 = dbui.to_panelWithUrlSelector(virtdb.foo1, 
                                       baseUrl=URL('reports', 'report_2'),
+                                      baseParams={'hello': 3},
                                       extField='my_format',
                                       plugins=['pMathJax'])
 
diff --git a/static/plugin_dbui/src/panel/WithUrlSelector.js b/static/plugin_dbui/src/panel/WithUrlSelector.js
index f1e4010f..9f121b2e 100644
--- a/static/plugin_dbui/src/panel/WithUrlSelector.js
+++ b/static/plugin_dbui/src/panel/WithUrlSelector.js
@@ -17,6 +17,13 @@ Ext.define('App.panel.WithUrlSelector', {
     extend: 'App.panel.BaseWithSelector',
     alias: 'widget.xpanelwithurlselector',
 
+    /**
+     * @cfg {Object} baseParams
+     * Params that will be attached to every URL request.
+     * These parameters will not be overridden by the load options.
+     */
+    baseParams: null,
+
     /**
      * @cfg {String}
      * The well-formed URL, e.g http://blabla.
@@ -59,6 +66,10 @@ Ext.define('App.panel.WithUrlSelector', {
 
         this.callParent(arguments);
 
+        if (this.baseParams) {
+            this.mainPanel.loader.baseParams = this.baseParams;
+        }
+
         this.goButton.on('click', this.onGo, this);
         this.resetButton.on('click', this.onReset, this);
     },
@@ -195,6 +206,7 @@ Ext.define('App.panel.WithUrlSelector', {
             };
 
             this.mainPanel.getLoader().load({
+                baseParams: this.baseParams,
                 loadMask: mask,
                 params: request.vars,
                 url: request.http,
diff --git a/views/reports/report_2.html b/views/reports/report_2.html
index c082d94f..def402bd 100644
--- a/views/reports/report_2.html
+++ b/views/reports/report_2.html
@@ -1,4 +1,8 @@
 <h3>Report_2</h3>
 <hr>
+<h4>selector:</h4>
 {{=BEAUTIFY(test)}}
-<hr>
\ No newline at end of file
+<hr>
+<h4>request.vars:</h4>
+{{=BEAUTIFY(vars)}}
+<hr>
-- 
GitLab