Skip to content
Snippets Groups Projects
Commit 90224604 authored by tux091's avatar tux091
Browse files

redesign to_panelWithUrlSelector, add to_panel and to_fieldset, simplify the report section.

parent e8e0fde1
No related branches found
No related tags found
No related merge requests found
...@@ -13,30 +13,7 @@ def report_1(): ...@@ -13,30 +13,7 @@ def report_1():
"""First trial """First trial
""" """
# Resolve foreign key return "report_1"
query = db.publications.id_collaborations == db.collaborations.id
query = (query) & (db.publications.id_publishers == db.publishers.id)
query = (query) & (db.publications.id_categories == db.categories.id)
# publication with comite de lecture
query = (query) & (db.publications.conference_title == '')
query = (query) & ((db.categories.code == 'ACL') | (db.categories.code == 'ACLN'))
# Interrogate the database
rows = db(query).select(db.publications.title,
db.publications.authors,
db.publications.id_collaborations,
db.collaborations.collaboration,
db.publishers.abbreviation,
db.publications.year,
db.publications.doi,
db.publications.volume,
db.publications.first_page,
db.publications.last_page,
db.publications.conference_title,
db.categories.code)
return {'title': 'Rapport 1', 'publis': rows}
def report_2(): def report_2():
...@@ -45,6 +22,7 @@ def report_2(): ...@@ -45,6 +22,7 @@ def report_2():
""" """
s = "" s = ""
print request.post_vars
for k in request.post_vars: for k in request.post_vars:
s += "<br>%s: %s" % (k, request.post_vars[k]) s += "<br>%s: %s" % (k, request.post_vars[k])
......
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
'Report Numbers': 'Numéro du rapport', 'Report Numbers': 'Numéro du rapport',
'Report type': 'Type du rapport', 'Report type': 'Type du rapport',
'Reports': 'Rapports', 'Reports': 'Rapports',
'Select': 'Selectionner',
'Speaker': 'Orateur', 'Speaker': 'Orateur',
'Start date': 'Date de début', 'Start date': 'Date de début',
'Table': 'Table', 'Table': 'Table',
...@@ -63,6 +64,7 @@ ...@@ -63,6 +64,7 @@
'report_1': 'report_1', 'report_1': 'report_1',
'report_2': 'report_2', 'report_2': 'report_2',
'reports': 'rapports', 'reports': 'rapports',
'select': 'select',
'select publication for a given year': 'selectionne les publication pour une année', 'select publication for a given year': 'selectionne les publication pour une année',
'select publications for a given CPPM author': 'selectionne les publications pour un auteur du CPPM', 'select publications for a given CPPM author': 'selectionne les publications pour un auteur du CPPM',
'select publications for a given project': 'selectionne les publications pour un projet', 'select publications for a given project': 'selectionne les publications pour un projet',
......
...@@ -192,13 +192,17 @@ configurator = lambda tablename: cvtSvc.to_grid_panel(db[tablename]) ...@@ -192,13 +192,17 @@ configurator = lambda tablename: cvtSvc.to_grid_panel(db[tablename])
gridNode.add_children(db.tables, func=configurator) gridNode.add_children(db.tables, func=configurator)
reportNode = dbui.Node(T('Reports')) reportNode = dbui.Node(T('Reports'))
cfg = dbui.to_urlPanel(URL(c="reports", f="report_1")) node = dbui.to_panel(html='salut ma poule')
reportNode.add_child(T('report_1'), cfg) reportNode.add_child(T('report_1'), node)
form_items = cvtSvc.to_form_items(dummy.foo1) panel = dbui.to_panel()
cfg = dbui.to_panelWithUrlSelector(form_items, fields = cvtSvc.to_form_items(dummy.foo1)
baseUrl=URL(c="reports", f="report_2")) selector = dbui.to_fieldset(fields, title=T('Select'))
reportNode.add_child(T('report_2'), cfg) node = dbui.to_panelWithUrlSelector(panel,
selector,
controller="reports",
function="report_2")
reportNode.add_child(T('report_2'), node)
viewportModifier = dbui.ViewportModifier() viewportModifier = dbui.ViewportModifier()
viewportModifier.add_node(formNode, gridNode, reportNode) viewportModifier.add_node(formNode, gridNode, reportNode)
...@@ -28,5 +28,9 @@ from helper import (as_list, ...@@ -28,5 +28,9 @@ from helper import (as_list,
rows_serializer) rows_serializer)
from mapper import map_default, map_tabpanel from mapper import map_default, map_tabpanel
from modifier import Spacer, Widget from modifier import Spacer, Widget
from navtree import Node, to_panelWithUrlSelector, to_urlPanel from navtree import (Node,
to_fieldset,
to_panel,
to_panelWithUrlSelector,
to_urlPanel)
from viewportmodifier import ViewportModifier from viewportmodifier import ViewportModifier
\ No newline at end of file
...@@ -3,74 +3,123 @@ ...@@ -3,74 +3,123 @@
""" """
import locale import locale
import os
from gluon import current from gluon import current
from helper import is_mathjax from helper import is_mathjax
def to_panelWithUrlSelector(formItems, def to_panel(**kwargs):
application=None, """Return the configuration dictionary of an Ext.Panel.
The keyword arguments are the configuration options of
the Ext.Panel widget.
"""
cfg = {'xtype': 'panel'}
cfg.update(kwargs)
return cfg
def to_fieldset(fields, **kwargs):
"""Return the confiuration dictionary of Ext.form.Fieldset.
This widget contains list of Ext.form.Field.
fields is a list of configuration dictioanry for form.Fields.
The keyword arguments are the configuration options of
the Ext.form.FieldSet widget.
"""
cfg = {'defaults': {'anchor': '99%'},
'items': fields,
'xtype': 'fieldset'}
cfg.update(kwargs)
return cfg
def to_panelWithUrlSelector(panelCfg,
selectorCfg,
baseUrl=None, baseUrl=None,
application=None,
controller=None, controller=None,
function=None,
ctrlField=None, ctrlField=None,
extField=None, extField=None,
title='Configure'): funcField=None):
"""Return the configuration dictionary for an App.PanelWithUrlSelector. """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 This widget is split in two part a main panel and a selector.
The base URL is: /application/controller. The selector display a list of fields organized in fieldset.
There values define the URL parameters. The main panel displays
the URL content.
Configuration dictionary for the main panel and fieldset are set via:
panelCfg
selectorCfg
In web2py an URL is defined as application/controller/function.extension
There are several ways to define it.
application
The base URL is: /application
By default the application is the current application. 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 baseUrl
Another way to defined the base URL associated to the panel. Another way to defined the URL associated to the panel.
It should be a well-formed URL string, i.e http://blabla It should be a well-formed URL string, i.e http://blabla.
It is a more general approach where the URL can point to a
any links.
controller
The base URL is: /application/controller.
function
The base URL is: /application/controller/function.
The URL can be modified dynamicaly by extracting the name of the
controller, function and/or extension from the selector fields.
ctrlField ctrlField
Name of the form field defining the name of the controller. Name of the field defining the name of the controller.
When define the URL become baseUrl/ctrlFieldValue When define the URL become baseURL/ctrlFieldValue.
extField extField
the url become baseUrl/ctrField.extField Name of the field defining the name of the extension.
Useful to play with different view rendering their content in When define the URL become baseUrl.extFieldValue.
html, json, xml, ... Useful to play with different view rendering the same
controller/function.
formItems
A list of configuration dictionary defining the funcField
widget embedded in the form Name of the form field defining the name of the function.
When define the URL become baseURL/funcFieldValue.
title To be used with ctrlField. In that case the URL is
Title of the box surrounding form widgets /application/ctrFieldValue/funcFieldValue.
""" """
url = baseUrl url = baseUrl
if not url: if not url:
if application: if application:
url = '/%s/%s' % (application, controller) url = os.path.join('/', application)
else: else:
url = '/%s/%s' % (current.request.application, controller) url = os.path.join('/', current.request.application)
if controller:
url = os.path.join(url, controller)
if function:
url = os.path.join(url, function)
cfg = {'baseUrl': url, cfg = {'baseUrl': url,
'ctrlField': ctrlField, 'ctrlField': ctrlField,
'extField': extField, 'extField': extField,
'funcField': funcField,
'isMathJax': is_mathjax(), 'isMathJax': is_mathjax(),
'panelCfg': None, 'panelCfg': panelCfg,
'selectorCfg':None, 'selectorCfg': selectorCfg,
'xtype': 'xpanelwithurlselector'} 'xtype': 'xpanelwithurlselector'}
# configuration of the child panel displaying URL
cfg['panelCfg'] = {'plugins': [],
'xtype': 'panel'}
# configuration of the selector
cfg['selectorCfg'] = {'defaults': {'anchor': '99%'},
'items': formItems,
'title': title,
'xtype': 'fieldset'}
return cfg return cfg
...@@ -82,13 +131,11 @@ def to_urlPanel(url): ...@@ -82,13 +131,11 @@ def to_urlPanel(url):
well-formed URL string, i.e http://blabla well-formed URL string, i.e http://blabla
""" """
cfg = {'autoLoad': url, cfg = to_panel(autoload=url,
'plugins': [], preventBodyReset=True)
'preventBodyReset': True,
'xtype': 'panel'}
if is_mathjax: if is_mathjax():
cfg['plugins'].append('pPanelMathJax') cfg['plugins'] = ['pPanelMathJax']
return cfg return cfg
......
/** /**
* A panel displaying an url content with a collpasible selector. * This widget is split in two part a main panel and a selector.
* The selector allows to setup the url parameters and to launch the * The selector display a list of fields organized in fieldset.
* request to the server. * There values define the URL parameters. The main panel displays
* the URL content.
* *
* The url is build as baseUrl or baseUrl/CtrlFieldValue if ctrlField * Configuration for the main panel and the selelctor are set via
* is defined. The value of the other fields are pass as Field1=Field1Value, * the option panelCfg and selectorCgf.
* Field2=Field2Value via the POST transfert *
* The URL display in the main panel is defined by the baseUrl option.
* It can be modified dynamicaly by extracting the name of the
* controller, function and/or extension from the selector fields.
* The options ctrlField, extField and funcField associated field
* used to determine the value.
* *
* Mathematical symbols will be interpreted, if the javascript library * Mathematical symbols will be interpreted, if the javascript library
* mathjax is load. Use the isMathJax property. * mathjax is load. Use the isMathJax property.
...@@ -27,18 +33,24 @@ App.PanelWithUrlSelector = Ext.extend(App.BasePanelWithSelector, { ...@@ -27,18 +33,24 @@ App.PanelWithUrlSelector = Ext.extend(App.BasePanelWithSelector, {
/** /**
* @param {String} ctrFiedl name of the field defining the controller * @param {String} ctrFiedl name of the field defining the controller
* When define the url become http://blabla/ctrlFieldValue * When define the url become baseUrl/ctrlFieldValue
*/ */
ctrlField: null, ctrlField: null,
/** /**
* @param {String} extFiedl name of the field defining the view extension * @param {String} extFiedl name of the field defining the extension
* When define the url become http://blabla/ctrlFieldValue.extField * When define the url become baseUrl.extFieldValue
*/ */
extField: null, extField: null,
/**
* @param {String} funcFiedl name of the field defining the function
* When define the url become baseUrl/funcFieldValue
*/
funcField: null,
/** /**
* @param {Boolean} isMathJax * @param {Boolean} isMathJax True is the mathjax library is installed
*/ */
isMathJax: false, isMathJax: false,
...@@ -64,33 +76,37 @@ App.PanelWithUrlSelector = Ext.extend(App.BasePanelWithSelector, { ...@@ -64,33 +76,37 @@ App.PanelWithUrlSelector = Ext.extend(App.BasePanelWithSelector, {
*/ */
onGo: function() { onGo: function() {
var ctrlFunc=null, var fields,
ctrlExt=null,
fields,
i, i,
mainPanel = this.getComponent('mainPanel'), mainPanel = this.getComponent('mainPanel'),
params = {}, params = {},
selector = this.getComponent('selectorPanel'), selector = this.getComponent('selectorPanel'),
url = this.baseUrl; url = this.baseUrl,
urlCtrl = null,
urlFunc = null,
urlExt = null;
// activate the auto scrolling // activate the auto scrolling
mainPanel.setAutoScroll(true); mainPanel.setAutoScroll(true);
// basic fields // extract basic parameters
fields = selector.findByType('field'); fields = selector.findByType('field');
for (i = 0; i < fields.length; i += 1) { for (i = 0; i < fields.length; i += 1) {
if(fields[i].getName() === this.ctrlField) { if(fields[i].getName() === this.ctrlField) {
ctrlFunc = fields[i].getValue(); urlCtrl = fields[i].getValue();
} else if (fields[i].getName() === this.extField) { } else if (fields[i].getName() === this.extField) {
ctrlExt = fields[i].getValue(); urlExt = fields[i].getValue();
} else if (fields[i].getName() === this.funcField) {
urlFunc = fields[i].getValue();
} else { } else {
params[fields[i].getName()] = fields[i].getValue(); params[fields[i].getName()] = fields[i].getValue();
} }
} }
// fields embedded in composite fields // extract parameters embedded in composite fields
fields = this.findByType('compositefield'); fields = this.findByType('compositefield');
for (i = 0; i < fields.length; i += 1) { for (i = 0; i < fields.length; i += 1) {
fields[i].items.eachKey(function(key, subfield) { fields[i].items.eachKey(function(key, subfield) {
...@@ -98,15 +114,20 @@ App.PanelWithUrlSelector = Ext.extend(App.BasePanelWithSelector, { ...@@ -98,15 +114,20 @@ App.PanelWithUrlSelector = Ext.extend(App.BasePanelWithSelector, {
}); });
} }
// build the URL when only the ctrlFunc is defined // build the URL
if (ctrlFunc !== null && ctrlExt === null) { if (urlCtrl !== null) {
url = url + '/' + ctrlFunc; url = url + '/' + urlCtrl;
}
// build the url when both the ctrlFunc and ctrlExt are defined
} else if (ctrlFunc !== null && ctrlExt !== null) { if (urlFunc !== null) {
url = url + '/' + ctrlFunc + '.' + ctrlExt; url = url + '/' + urlFunc;
}
if (urlExt !== null) {
url = url + '.' + urlExt;
} }
// load url in the main panel
mainPanel.load({ mainPanel.load({
callback: this.onLoad, callback: this.onLoad,
params: params, params: params,
......
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>{{=title}}</title>
<!-- mathjax library -->
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
extensions: ["tex2jax.js"],
jax: ["input/TeX", "output/HTML-CSS"],
tex2jax: {
inlineMath: [ ['$','$'], ["\\(","\\)"] ],
displayMath: [ ['$$','$$'], ["\\[","\\]"] ],
processEscapes: true
},
"HTML-CSS": { availableFonts: ["TeX"] }
});
</script>
<script type="text/javascript" src="/{{=request.application}}/static/plugin_mathjax/MathJax.js"></script>
</head>
<body>
<h2>Publications avec comité de lecture</h2>
<ol>
{{for el in publis:}}
<li>
{{=el.publications.title}}<br>
{{=el.publications.authors}}
{{if el.publications.id_collaborations > 1:}}, {{=el.collaborations.collaboration}},{{pass}}<br>
{{if el.publishers.abbreviation:}}{{=el.publishers.abbreviation}}{{pass}}
{{if el.publications.volume:}}{{=el.publications.volume}}{{pass}}
{{if el.publications.year:}}({{=el.publications.year}}){{pass}}
{{if el.publications.first_page:}}{{=el.publications.first_page}}{{pass}}
{{if el.publications.last_page:}}- {{=el.publications.last_page}}{{pass}}
</li>
{{pass}}
</ol>
</body>
</html>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment