Commit c77a6108 authored by Renaud Le Gac's avatar Renaud Le Gac
Browse files

Create a new widget PanelWithSelector and fix minor typo in

gridwithfilter.
parent 79d3bf6a
......@@ -35,4 +35,11 @@ def report_1():
db.publications.conference_title,
db.categories.code)
return {'title': 'Rapport 1', 'publis': rows}
\ No newline at end of file
return {'title': 'Rapport 1', 'publis': rows}
def report_2():
"""Return the url arguments
"""
return 'report_2: '+str(request.args)
\ No newline at end of file
......@@ -10,51 +10,39 @@ from gluon import current
def cfg_configurable_url_panel(key, value):
""" Return the configuration dictionary for a panel displaying
an url. The argument of the url can be change using a form
appearing on the right side.
an URL. The argument of the URL can be change using a form
appearing on the right side. The form is defined by a table
of the dummy database.
The ExtJS widget behind the scene is App.panel.PanelWithConfigurator.
Technicaly, the configuration dictionary describe an ExtJS.Viewport
key
it the name of the leaf
value
dictionary containing
url
its content is displayed in the panel
form
an xxx form allowing to customize the url request
It is displaied on the right side of the panel
tuple containing a well form URL string
and a gluon.dal.Table build the form allowing to setup
the URL arguments
"""
cfg = {
'layout': 'border',
'items': [{
'autoScroll': True,
'defaults': {'layout': 'fit'},
'itemId': 'urlPanel',
'region': 'center',
}, {
'autoScroll': True,
'buttons': [{
'text': 'Go',
}],
'collapsible': True,
'frame': True,
'layout': 'form',
'itemId': 'urlConfigurator',
'region': 'east',
'split': True,
'width': 200,
}]
}
url, table = value
cfg = {'panelCfg': None,
'selectorCfg':None,
'xtype': 'xpanelwithselector'}
cfg['panelCfg'] = {'baseUrl': url,
'plugins': ['pPanelMathJax'],
'preventBodyReset': True}
cfg['selectorCfg'] = {}
return cfg
def cfg_url_panel(key, url):
"""Return the configuration dictionary for an Ext.Panel
displaying an url.
displaying an URL.
key
it the name of the leaf
......
......@@ -47,4 +47,11 @@ if (App.grid.RowEditorContextMenu) {
textUpdate : 'Actualiser',
textView : 'Voir'
});
}
\ No newline at end of file
}
if (App.panel.PanelWithSelector) {
Ext.apply(App.panel.PanelWithSelector.prototype, {
textGo: 'Go',
textReset: 'Annuler',
});
}
/**
* A border layout with a grid and its filter
*
* The type of this component is xgridwithfilter.
*
* @extend: Ext.Panel
......@@ -27,7 +26,8 @@ App.grid.GridWithFilter = Ext.extend(Ext.Panel, {
*/
constructor: function(config) {
var filter,
var cfg,
filter,
grid;
Ext.apply(this, config);
......
/**
* A border layout with a panel and an url selector
* The type of this component is xpanelwithselector.
*
* @extend: Ext.Panel
*
*/
Ext.namespace('App.panel');
App.panel.PanelWithSelector = Ext.extend(Ext.Panel, {
/**
* @param {String} base url to be displayed in the panel
*/
panelCfg: null,
selectorCfg: null,
/**
* Private attribute for internationalization
*/
textGo: 'Go',
textReset: 'Reset',
/**
* constructor
* @param {Object} config
*/
constructor: function(config){
var cfg;
// predefined configuration of the panel
cfg = {
layout: 'border',
items: [{
autoScroll: true,
border: false,
defaults: {
layout: 'fit'
},
itemId: 'urlPanel',
region: 'center',
}, {
autoScroll: true,
buttons: [{
ref: '../../goButton',
text: this.textGo
}, {
ref: '../../resetButton',
text: this.textReset
}],
collapsible: true,
frame: true,
layout: 'form',
itemId: 'urlConfigurator',
region: 'east',
split: true,
width: 200,
}]
};
// apply user panel configuration
Ext.apply(cfg, config.panelCfg);
// apply user selector cnonfiguration
Ext.apply(cfg, config.selectorCfg);
// instanciate the panel
Ext.apply(this, cfg);
App.panel.PanelWithSelector.superclass.constructor.call(this);
// handlers
this.goButton.on('click', this.onGo, this);
},
/**
* handle to build the URL and to load it in the panel
*/
onGo: function() {
var urlconfigurator = this.getComponent('urlConfigurator'),
urlPanel = this.getComponent('urlPanel');
// buil the url
// load the url in the panel
console.log('onGo', this.baseUrl, urlPanel);
urlPanel.load({
url: this.baseUrl,
text: 'Loading...',
timeout: 30
});
}
});
Ext.reg('xpanelwithselector', App.panel.PanelWithSelector);
\ No newline at end of file
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