From 98a5f25492f0fd1b61db8fd6480ee474bfe81b43 Mon Sep 17 00:00:00 2001
From: Renaud Le Gac <legac@cppm.in2p3.fr>
Date: Fri, 6 Jun 2014 10:40:07 +0200
Subject: [PATCH] Add the configuration option panelLayout and selectorLayout
 to the BasseWithSelector class.

---
 controllers/reports.py                        |  9 +++-
 languages/fr-fr.py                            |  1 +
 models/widgets_viewport.py                    |  5 ++-
 .../plugin_dbui/src/panel/BaseWithSelector.js | 45 +++++++++++++++----
 views/reports/report_2.html                   |  5 +--
 views/reports/report_4.html                   |  5 +++
 6 files changed, 55 insertions(+), 15 deletions(-)
 create mode 100644 views/reports/report_4.html

diff --git a/controllers/reports.py b/controllers/reports.py
index 5440b361..76f03ed4 100644
--- a/controllers/reports.py
+++ b/controllers/reports.py
@@ -39,4 +39,11 @@ def report_3():
     """
     selector = Selector(virtdb.harvester_selector)
     response.view = 'reports/report_2.html'
-    return dict(test=selector.as_dict())
\ No newline at end of file
+    return dict(test=selector.as_dict())
+
+
+def report_4():
+    """Execute a javascript in the view using python information
+    
+    """
+    return dict(msg="Hello world")
\ No newline at end of file
diff --git a/languages/fr-fr.py b/languages/fr-fr.py
index 7c4aaa90..19d25af4 100644
--- a/languages/fr-fr.py
+++ b/languages/fr-fr.py
@@ -89,6 +89,7 @@
 'report_1': 'report_1',
 'report_2': 'report_2',
 'report_3': 'report_3',
+'report_4': 'report_4',
 'reports': 'rapports',
 'Reports': 'Rapports',
 'Select': 'Selectionner',
diff --git a/models/widgets_viewport.py b/models/widgets_viewport.py
index 909a3cea..cfcc9393 100644
--- a/models/widgets_viewport.py
+++ b/models/widgets_viewport.py
@@ -72,7 +72,6 @@ leaf_2 = PanelWithUrlSelector(virtdb.foo1,
                               baseUrl=URL('reports', 'report_2'),
                               baseParams={'hello': 3},
                               extField='my_format',
-                              panelLoader={"renderer": "html", "scripts": True},
                               plugins=['pMathJax'])
 
 leaf_3 = PanelWithUrlSelector(virtdb.harvester_selector,
@@ -80,10 +79,14 @@ leaf_3 = PanelWithUrlSelector(virtdb.harvester_selector,
                               selectorRegion='east',
                               selectorTitle='Select a project')
 
+leaf_4 = PanelWithUrlSelector(virtdb.foo1, 
+                              baseUrl=URL('reports', 'report_4'))
+
 reportNode = Node(T('Reports'))
 reportNode.add_child(T('report_1'), leaf_1)
 reportNode.add_child(T('report_2'), leaf_2)
 reportNode.add_child(T('report_3'), leaf_3)
+reportNode.add_child(T('report_4'), leaf_4)
 
 #-------------------------------------------------------------------------------
 #
diff --git a/static/plugin_dbui/src/panel/BaseWithSelector.js b/static/plugin_dbui/src/panel/BaseWithSelector.js
index 1acc6a2b..b7b2cea0 100644
--- a/static/plugin_dbui/src/panel/BaseWithSelector.js
+++ b/static/plugin_dbui/src/panel/BaseWithSelector.js
@@ -36,22 +36,33 @@ Ext.define('App.panel.BaseWithSelector', {
 
     /**
      * @cfg {Object}
-     * The main panel items.
+     * The items configuration option for the main panel.
      */
     panelItems: null,
 
     /**
      * @cfg {Boolean}
+     * The border configuration option for the main panel.
+     *
      */
     panelBorder: false,
 
     /**
      * @cfg {Object}
+     * The defaults configuration option for the main panel.
      */
     panelDefaults: null,
 
+    /**
+     * @cfg {Ext.enums.Layout/Object}
+     * The layout configuration option for the main panel.
+     */
+    panelLayout: 'fit',
+
     /**
      * @cfg {Ext.ComponentLoader/Object}
+     * The laoder configuration option for the selector.
+     *
      * A configuration object or an instance of a {@link Ext.ComponentLoader}
      * to load remote content for this Component. By default, the content
      * loaded will be processed as raw html. The response text from the
@@ -60,34 +71,47 @@ Ext.define('App.panel.BaseWithSelector', {
      * in the resulting content.
      *
      */
-    panelLoader: {},
+    panelLoader: {
+        renderer: 'html',
+        scripts: true
+    },
 
     /**
      * @cfg {Object}
-     * The selector items.
+     * The items configuration option for the selector.
      */
     selectorItems: null,
 
     /**
      * @cfg {Boolean}
+     * The collapsible configuration option for the selector.
      */
     selectorCollapsible: true,
 
     /**
      * @cfg {Object}
+     * The defaults configuration option for the selector.
      */
     selectorDefaults: {layout: 'form', padding: '0 10 10 10'},
 
     /**
      * @cfg {Boolean}
+     * The frame configuration option for the selector.
      */
     selectorFrame: true,
 
     /**
      * @cfg {Number}
+     * The height configuration option for the selector.
      */
     selectorHeight: 300,
 
+    /**
+     * @cfg {Ext.enums.Layout/Object}
+     * The layout configuration option for the selector.
+     */
+    selectorLayout: 'form',
+
     /**
      * @cfg {String}
      * Authorized values are east, west, south and north.
@@ -96,40 +120,43 @@ Ext.define('App.panel.BaseWithSelector', {
 
     /**
      * @cfg {Boolean}
+     * The split configuration option for the selector.
      */
     selectorSplit: true,
 
     /**
      * @cfg {String}
+     * The title configuration option for the selector.
      */
     selectorTitle: "Selector",
 
     /**
      * @cfg {Number}
+     * The width configuration option for the selector.
      */
     selectorWidth: 300,
 
     /**
      * @property {Ext.Button}
-     * The reference to the *go* button of the selector
+     * The reference to the *go* button of the selector.
      */
     goButton: null,
 
     /**
      * @property {Ext.Button}
-     * The reference to the *reset* button of the selector
+     * The reference to the *reset* button of the selector.
      */
     resetButton: null,
 
     /**
      * @property {Ext.panel.Panel}
-     * reference to the mainPanel
+     * reference to the mainPanel.
      */
     mainPanel: null,
 
     /**
      * @property {Ext.panel.Panel}
-     * reference to the selectorPanel
+     * reference to the selectorPanel.
      */
     selectorPanel: null,
 
@@ -154,7 +181,7 @@ Ext.define('App.panel.BaseWithSelector', {
                 defaults: this.panelDefaults,
                 itemId: 'mainPanel',
                 items: this.panelItems,
-                layout: 'fit',
+                layout: this.panelLayout,
                 loader: this.panelLoader,
                 plugins: ['pPanelLoaderException'],
                 region: 'center'
@@ -171,7 +198,7 @@ Ext.define('App.panel.BaseWithSelector', {
                 defaults: this.selectorDefaults,
                 frame: this.selectorFrame,
                 height: this.selectorHeight,
-                layout: 'form',
+                layout: this.selectorLayout,
                 itemId: 'selectorPanel',
                 items: this.selectorItems,
                 region: this.selectorRegion,
diff --git a/views/reports/report_2.html b/views/reports/report_2.html
index 9bfed297..13dfe425 100644
--- a/views/reports/report_2.html
+++ b/views/reports/report_2.html
@@ -5,7 +5,4 @@
 <hr>
 <h4>request.vars:</h4>
 {{=BEAUTIFY(vars)}}
-<hr>
-<script type="text/javascript">
-    Ext.Msg.alert("Hello", "Execute inline script");
-</script>
+<hr>
\ No newline at end of file
diff --git a/views/reports/report_4.html b/views/reports/report_4.html
new file mode 100644
index 00000000..5bc5e5bb
--- /dev/null
+++ b/views/reports/report_4.html
@@ -0,0 +1,5 @@
+{{=msg}}
+<script type="text/javascript">
+    var v1 = "{{=msg}}";
+    Ext.Msg.alert("Execute inline script", v1);
+</script>
-- 
GitLab