diff --git a/controllers/reports.py b/controllers/reports.py index b685aa2edf948acc80f788cce6739a1d66859d01..d5719027e7c9ed389f51424ffb024af41b837c16 100644 --- a/controllers/reports.py +++ b/controllers/reports.py @@ -13,30 +13,7 @@ def report_1(): """First trial """ - # Resolve foreign key - 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} + return "report_1" def report_2(): @@ -45,6 +22,7 @@ def report_2(): """ s = "" + print request.post_vars for k in request.post_vars: s += "<br>%s: %s" % (k, request.post_vars[k]) diff --git a/languages/fr-fr.py b/languages/fr-fr.py index f1a502287cdee95147df86a9e47f38af9e2abf3e..583ddf00fc32531d90f93bcb51305c3883e5fe97 100644 --- a/languages/fr-fr.py +++ b/languages/fr-fr.py @@ -40,6 +40,7 @@ 'Report Numbers': 'Numéro du rapport', 'Report type': 'Type du rapport', 'Reports': 'Rapports', +'Select': 'Selectionner', 'Speaker': 'Orateur', 'Start date': 'Date de début', 'Table': 'Table', @@ -63,6 +64,7 @@ 'report_1': 'report_1', 'report_2': 'report_2', 'reports': 'rapports', +'select': 'select', '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 project': 'selectionne les publications pour un projet', diff --git a/models/widgets.py b/models/widgets.py index 8017f88597648feac877c6f40ae4e2fff690f812..6be3dfade3907844fba3ac2d54c5c07bf34580ca 100755 --- a/models/widgets.py +++ b/models/widgets.py @@ -192,13 +192,17 @@ configurator = lambda tablename: cvtSvc.to_grid_panel(db[tablename]) gridNode.add_children(db.tables, func=configurator) reportNode = dbui.Node(T('Reports')) -cfg = dbui.to_urlPanel(URL(c="reports", f="report_1")) -reportNode.add_child(T('report_1'), cfg) - -form_items = cvtSvc.to_form_items(dummy.foo1) -cfg = dbui.to_panelWithUrlSelector(form_items, - baseUrl=URL(c="reports", f="report_2")) -reportNode.add_child(T('report_2'), cfg) +node = dbui.to_panel(html='salut ma poule') +reportNode.add_child(T('report_1'), node) + +panel = dbui.to_panel() +fields = cvtSvc.to_form_items(dummy.foo1) +selector = dbui.to_fieldset(fields, title=T('Select')) +node = dbui.to_panelWithUrlSelector(panel, + selector, + controller="reports", + function="report_2") +reportNode.add_child(T('report_2'), node) viewportModifier = dbui.ViewportModifier() viewportModifier.add_node(formNode, gridNode, reportNode) diff --git a/modules/plugin_dbui/__init__.py b/modules/plugin_dbui/__init__.py index 260a7f1607693f07652fe616071051828da0e002..1988a8c846673c3290292d5ed233c18ddba12da5 100755 --- a/modules/plugin_dbui/__init__.py +++ b/modules/plugin_dbui/__init__.py @@ -28,5 +28,9 @@ from helper import (as_list, rows_serializer) from mapper import map_default, map_tabpanel 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 \ No newline at end of file diff --git a/modules/plugin_dbui/navtree.py b/modules/plugin_dbui/navtree.py index 56f6094b74a08aad411847bee4a981577e61a9ab..b5b9e39cc349d670183d4a1119a3bbffd4a86e40 100644 --- a/modules/plugin_dbui/navtree.py +++ b/modules/plugin_dbui/navtree.py @@ -3,74 +3,123 @@ """ import locale +import os from gluon import current from helper import is_mathjax -def to_panelWithUrlSelector(formItems, - application=None, +def to_panel(**kwargs): + """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, + application=None, controller=None, + function=None, ctrlField=None, - extField=None, - title='Configure'): + extField=None, + funcField=None): """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 base URL is: /application/controller. + This widget is split in two part a main panel and a selector. + 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. - The argument ctlField and extField allow to extend the base URL to - /application/controller/ctlField.extField - baseUrl - Another way to defined the base URL associated to the panel. - It should be a well-formed URL string, i.e http://blabla + Another way to defined the URL associated to the panel. + 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 - Name of the form field defining the name of the controller. - When define the URL become baseUrl/ctrlFieldValue + Name of the 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 - - title - Title of the box surrounding form widgets - + Name of the field defining the name of the extension. + When define the URL become baseUrl.extFieldValue. + Useful to play with different view rendering the same + controller/function. + + funcField + Name of the form field defining the name of the function. + When define the URL become baseURL/funcFieldValue. + To be used with ctrlField. In that case the URL is + /application/ctrFieldValue/funcFieldValue. + """ url = baseUrl if not url: if application: - url = '/%s/%s' % (application, controller) + url = os.path.join('/', application) 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, 'ctrlField': ctrlField, 'extField': extField, + 'funcField': funcField, 'isMathJax': is_mathjax(), - 'panelCfg': None, - 'selectorCfg':None, + 'panelCfg': panelCfg, + 'selectorCfg': selectorCfg, '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 @@ -82,13 +131,11 @@ def to_urlPanel(url): well-formed URL string, i.e http://blabla """ - cfg = {'autoLoad': url, - 'plugins': [], - 'preventBodyReset': True, - 'xtype': 'panel'} + cfg = to_panel(autoload=url, + preventBodyReset=True) - if is_mathjax: - cfg['plugins'].append('pPanelMathJax') + if is_mathjax(): + cfg['plugins'] = ['pPanelMathJax'] return cfg diff --git a/static/plugin_dbui/src/apppanelwithurlselector.js b/static/plugin_dbui/src/apppanelwithurlselector.js index ac80cc897d9fb065216f33b72686f391075787a6..6f0fdfa442f5be00da19ffec2e5c4a66409865f2 100644 --- a/static/plugin_dbui/src/apppanelwithurlselector.js +++ b/static/plugin_dbui/src/apppanelwithurlselector.js @@ -1,11 +1,17 @@ /** - * A panel displaying an url content with a collpasible selector. - * The selector allows to setup the url parameters and to launch the - * request to the server. + * This widget is split in two part a main panel and a selector. + * The selector display a list of fields organized in fieldset. + * There values define the URL parameters. The main panel displays + * the URL content. * - * The url is build as baseUrl or baseUrl/CtrlFieldValue if ctrlField - * is defined. The value of the other fields are pass as Field1=Field1Value, - * Field2=Field2Value via the POST transfert + * Configuration for the main panel and the selelctor are set via + * the option panelCfg and selectorCgf. + * + * 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 * mathjax is load. Use the isMathJax property. @@ -27,18 +33,24 @@ App.PanelWithUrlSelector = Ext.extend(App.BasePanelWithSelector, { /** * @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, /** - * @param {String} extFiedl name of the field defining the view extension - * When define the url become http://blabla/ctrlFieldValue.extField + * @param {String} extFiedl name of the field defining the extension + * When define the url become baseUrl.extFieldValue */ 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, @@ -64,33 +76,37 @@ App.PanelWithUrlSelector = Ext.extend(App.BasePanelWithSelector, { */ onGo: function() { - var ctrlFunc=null, - ctrlExt=null, - fields, + var fields, i, mainPanel = this.getComponent('mainPanel'), params = {}, selector = this.getComponent('selectorPanel'), - url = this.baseUrl; + url = this.baseUrl, + urlCtrl = null, + urlFunc = null, + urlExt = null; // activate the auto scrolling mainPanel.setAutoScroll(true); - // basic fields + // extract basic parameters fields = selector.findByType('field'); for (i = 0; i < fields.length; i += 1) { if(fields[i].getName() === this.ctrlField) { - ctrlFunc = fields[i].getValue(); + urlCtrl = fields[i].getValue(); } 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 { params[fields[i].getName()] = fields[i].getValue(); } } - // fields embedded in composite fields + // extract parameters embedded in composite fields fields = this.findByType('compositefield'); for (i = 0; i < fields.length; i += 1) { fields[i].items.eachKey(function(key, subfield) { @@ -98,15 +114,20 @@ 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; + // build the URL + if (urlCtrl !== null) { + url = url + '/' + urlCtrl; + } + + if (urlFunc !== null) { + url = url + '/' + urlFunc; + } + + if (urlExt !== null) { + url = url + '.' + urlExt; } + // load url in the main panel mainPanel.load({ callback: this.onLoad, params: params, diff --git a/views/reports/report_1.html b/views/reports/report_1.html deleted file mode 100644 index 1c35bdc831975a44f1c68da7abcf167f054014f6..0000000000000000000000000000000000000000 --- a/views/reports/report_1.html +++ /dev/null @@ -1,40 +0,0 @@ -<!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>