Commit a5dcc2be authored by legac's avatar legac
Browse files

Add the configuration parameter extField in App.PanelWithUrlSelector.

parent 75d82260
......@@ -11,27 +11,33 @@ def to_panelWithUrlSelector(formItems,
application=None,
baseUrl=None,
controller=None,
ctrlField=None,
ctrlField=None,
extField=None,
title='Configure'):
"""Return the configuration dictionary for an App.PanelWithUrlSelector.
the main panel displays the URL content while the selector panel shows
a form allowing to change the URL setting.
application and controller
The web2py way of defining the URL: /application/controller.
If the application is not defined the URL is:
/current application/controller.
These keyword arguments make sense when using the ctrlField.
See also baseUrl.
The base URL is: /application/controller.
By default the application is the current application.
The argument ctlField and extField allow to extend the base URL to
/application/controller/ctlField.extField
baseUrl
Well-formed URL string, i.e http://blabla
See also application and controller
Another way to defined the base URL associated to the panel.
It should be a well-formed URL string, i.e http://blabla
ctrlField
Name of the form field defining the controller
When define the URL become http://blabla/ctrlFieldValue
Name of the form field defining the name of the controller.
When define the URL become baseUrl/ctrlFieldValue
extField
the url become baseUrl/ctrField.extField
Useful to play with different view rendering their content in
html, json, xml, ...
formItems
A list of configuration dictionary defining the
widget embedded in the form
......@@ -49,6 +55,7 @@ def to_panelWithUrlSelector(formItems,
cfg = {'baseUrl': url,
'ctrlField': ctrlField,
'extfield': extField,
'isMathJax': is_mathjax(),
'panelCfg': None,
'selectorCfg':None,
......
......@@ -29,6 +29,6 @@
<h3>Licence</h3>
This software is distributed under the Open Source license CeCILL.
<br>
&copy; 2010 - 2011 R. Le Gac
&copy; 2009 - 2012 R. Le Gac
</body>
</html>
\ No newline at end of file
--------------------------------- CHANGE LOG ----------------------------------
HEAD
- Bugs fixed
- Add the configuration parameter extField in App.PanelWithUrlSelector.
Design to manipulate different web2py views like foo.html, foo.xml, ...
0.4.5 (Feb 2012)
- Consolidation version
- Polish code and documentation as well as bug fixed
......
......@@ -20,7 +20,7 @@ Ext.namespace('App');
/**
* @param {String} App.version version of the library
*/
App.version = '0.4.5';
App.version = '0.4.x';
/**
* Helper function mimicking the encode_field function running on the server
......
......@@ -31,6 +31,12 @@ App.PanelWithUrlSelector = Ext.extend(App.BasePanelWithSelector, {
*/
ctrlField: null,
/**
* @param {String} extFiedl name of the field defining the view extension
* When define the url become http://blabla/ctrlFieldValue.extField
*/
extField: null,
/**
* @param {Boolean} isMathJax
*/
......@@ -58,21 +64,27 @@ App.PanelWithUrlSelector = Ext.extend(App.BasePanelWithSelector, {
*/
onGo: function() {
var fields,
var ctrlFunc=null,
ctrlExt=null,
fields,
i,
mainPanel = this.getComponent('mainPanel'),
params = {},
selector = this.getComponent('selectorPanel'),
url = this.baseUrl;
// activate the autoscrolling
// activate the auto scrolling
mainPanel.setAutoScroll(true);
// basic fields
fields = selector.findByType('field');
for (i = 0; i < fields.length; i += 1) {
if(fields[i].getName() === this.ctrlField) {
url = url + '/' + fields[i].getValue();
ctrlFunc = fields[i].getValue();
} else if (fields[i].getName() === this.extField) {
ctrlExt = fields[i].getValue();
} else {
params[fields[i].getName()] = fields[i].getValue();
}
......@@ -86,6 +98,15 @@ App.PanelWithUrlSelector = Ext.extend(App.BasePanelWithSelector, {
});
}
// build the URL when only the ctrlFunc is defined
if (ctrlFunc !== null && ctrlExt === null) {
url = url + '/' + ctrlFunc;
// build the url when both the ctrlFunc and ctrlExt are defined
} else if (ctrlFunc !== null && ctrlExt !== null) {
url = url + '/' + ctrlFunc + '.' + ctrlExt;
}
mainPanel.load({
callback: this.onLoad,
params: params,
......@@ -98,7 +119,7 @@ App.PanelWithUrlSelector = Ext.extend(App.BasePanelWithSelector, {
/**
* Handler call when the web page is load in the panel.
* It is usefeul to detect HTTP error and to perform post
* It is useful to detect HTTP error and to perform post
* processing (MathJax).
*
* Arguments ares those of the Ext.Update.update.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment