diff --git a/configure_build.py b/configure_build.py index af0ffb9dc543ecc3a8e13eb20773da0047369282..68e9e138296c0dc911fd5560f41e7405d30afbed 100644 --- a/configure_build.py +++ b/configure_build.py @@ -119,11 +119,11 @@ def commit_release(): call(["git", "checkout", "master"], stdout=fi, stderr=fi) # Commit modified files - print '\n\tgit add', DBUIJS, CHANGELOG, VERSION + print "\n\tgit add", DBUIJS, CHANGELOG, VERSION call(["git", "add", DBUIJS, CHANGELOG, VERSION]) msg = "Start release candidate %s" % get_version() - print '\tgit commit:', msg + print "\tgit commit:", msg call(["git", "commit", "-m", msg]) @@ -158,12 +158,12 @@ def get_plugin_version(plugin): elif plugin == "extjs": - fn = os.path.join('static', 'plugin_extjs', 'version.properties') + fn = os.path.join("static", "plugin_extjs", "version.properties") if not os.path.exists(fn): error("\n\tNo version file for the plugin extjs !") sys.exit(1) - with open(fn, 'rb') as fi: + with open(fn, "rb") as fi: s = fi.read() match = re.search(r"version.release=(\d+(\.\d+)*)", s) @@ -174,14 +174,14 @@ def get_plugin_version(plugin): release = match.group(1) # shrink the release identifier 4.2.1 or 4.2.1.883 -> 421 - li = release.split('.') - release = ''.join(li) if len(li) < 4 else ''.join(li[:-1]) + li = release.split(".") + release = "".join(li) if len(li) < 4 else "".join(li[:-1]) elif plugin == "mathjax": - filename = os.path.join('static', 'plugin_mathjax', 'MathJax.js') + filename = os.path.join("static", "plugin_mathjax", "MathJax.js") - with open(filename, 'rb') as tmpfile: + with open(filename, "rb") as tmpfile: text = tmpfile.read() match = re.match(r'.+MathJax.version="(\d+(\.\d+)*)";', text, re.DOTALL) @@ -228,52 +228,52 @@ def set_version(version): print "\n\tRelease %s already exit in git" % version sys.exit(1) - print '\tSet release', version, 'in', DBUIJS + print "\tSet release", version, "in", DBUIJS with open(DBUIJS) as fi: txt = fi.read() - # look for a pattern Dbui.version = '0.8.3'; in appbase.js + # look for a pattern Dbui.version = "0.8.3"; in appbase.js # split the the string in 3 parts (pre, version, post) - match = re.match(r"(.+ version: ')([\w._-]*)('.+)", txt, re.DOTALL) + match = re.match(r'(.+ version: ")([\w._-]*)(".+)', txt, re.DOTALL) if match.group(2) == version: - msg = '\n\tVersion "%s" already exists in the Dbui.js file !' + msg = "\n\tVersion '%s' already exists in the Dbui.js file !" print msg % version - rep = raw_input('\tDo you want to continue [n]? ') - if rep not in ('y', 'yes'): + rep = raw_input("\tDo you want to continue [n]? ") + if rep not in ("y", "yes"): sys.exit(1) # update the version and write a new file txt = match.group(1) + version + match.group(3) - with open(DBUIJS, 'w') as fi: + with open(DBUIJS, "w") as fi: fi.write(txt) # look for a pattern HEAD in the CHANGELOG # split the the string in 2 parts (pre HEAD, post HEAD) - print '\tSet release', version, 'in', CHANGELOG + print "\tSet release", version, "in", CHANGELOG with open(CHANGELOG) as fi: txt = fi.read() match = re.match("(.+HEAD\n)(.*)", txt, re.DOTALL) if match is None: - print '\n\tNo HEAD tag in the CHANGELOG!\n' - rep = raw_input('\tDo you want to continue [n]?') - if rep not in ('y', 'yes'): + print "\n\tNo HEAD tag in the CHANGELOG!\n" + rep = raw_input("\tDo you want to continue [n]?") + if rep not in ("y", "yes"): sys.exit(1) # update the version and edit the CHANGELOG - tpl = (match.group(1), version, NOW.strftime('%b %Y'), match.group(2)) - txt = '%s\n%s (%s)\n%s' % tpl + tpl = (match.group(1), version, NOW.strftime("%b %Y"), match.group(2)) + txt = "%s\n%s (%s)\n%s" % tpl - with open(CHANGELOG, 'w') as fi: + with open(CHANGELOG, "w") as fi: fi.write(txt) call(["vim", CHANGELOG]) # update VERSION - print '\tSet release', version, 'in', VERSION - with open(VERSION, 'w') as fi: + print "\tSet release", version, "in", VERSION + with open(VERSION, "w") as fi: fi.write(version) # cleaning diff --git a/controllers/default.py b/controllers/default.py index c799e0601735ee1715b911d3c8a73c07b2871cb8..cf7009bdc60e4baa7baa9bf90963bc036a66bcd3 100644 --- a/controllers/default.py +++ b/controllers/default.py @@ -1,15 +1,13 @@ """ """ -import os -import re def index(): """Main Controller to run the application. """ - url = URL('plugin_dbui', 'index', args=request.args, vars=request.vars) + url = URL("plugin_dbui", "index", args=request.args, vars=request.vars) return redirect(url) def user(): - return 'hello you hit the default/user controller' \ No newline at end of file + return "hello you hit the default/user controller" diff --git a/controllers/plugin_dbui.py b/controllers/plugin_dbui.py index bc4a7b81403c7831f382c0eb75bc0d3b37701edc..32f3810cef777df465a4dfc15984f4dc9db33c2a 100644 --- a/controllers/plugin_dbui.py +++ b/controllers/plugin_dbui.py @@ -15,22 +15,19 @@ """ import json import os -import plugin_dbui as dbui - from gluon.tools import PluginManager - API = """ -Dbui.csvUrl = '/%s/plugin_dbui/csv'; +Dbui.csvUrl = "/%s/plugin_dbui/csv"; Dbui.config = %s; Dbui.debug = %s; -Dbui.latex2pdfUrl = '/%s/plugin_dbui/latex2pdf.pdf'; -Dbui.name = '%s'; +Dbui.latex2pdfUrl = "/%s/plugin_dbui/latex2pdf.pdf"; +Dbui.name = "%s"; Dbui.REMOTE_API = { - 'url': '/%s/plugin_dbui/call', - 'type': 'remoting', - 'actions': %s + "url": "/%s/plugin_dbui/call", + "type": "remoting", + "actions": %s };""" @@ -38,7 +35,7 @@ def about(): fn = os.path.join("applications", request.application, PluginManager("dbui").dbui.app_about) - return open(fn, 'rb').read() + return open(fn, "rb").read() def call(): @@ -59,10 +56,11 @@ def csv(): is_foreign_field, is_table_with_foreign_fields) - tablename = request.vars['tableName'] + tablename = request.vars["tableName"] - response.headers['Content-Type'] = contenttype('.csv') - response.headers['Content-Disposition'] = 'attachment; filename=%s.csv;' % tablename + headers = response.headers + headers["Content-Type"] = contenttype(".csv") + headers["Content-Disposition"] = "attachment; filename=%s.csv;" % tablename table = db[tablename] query = table.id > 0 @@ -95,9 +93,9 @@ def dbui_conf(): the plugin dbui: application name, store definition,... """ - from gluon.contrib import simplejson as json from plugin_dbui import (DBUI, get_all_tables, + JSONEncoder, to_jsonstore, to_model, to_treeNodes, @@ -108,7 +106,7 @@ def dbui_conf(): # build the dictionary required by Ext.direct # containing the definition of the remote procedure for (k, f) in directSvc.procedures.iteritems(): - action, method = k.split('.') + action, method = k.split(".") if action == DBUI: nargs = f.func_code.co_argcount @@ -118,42 +116,42 @@ def dbui_conf(): if action not in di: di[action] = [] - di[action].append({'name': method, 'len': nargs}) + di[action].append({"name": method, "len": nargs}) # the definition of the models - config = {'models': {}, - 'stores': {}, - 'treeNodes': [], - 'viewport': None} + config = {"models": {}, + "stores": {}, + "treeNodes": [], + "viewport": None} for table in get_all_tables(db): - config['models'][table._tablename] = to_model(table) + config["models"][table._tablename] = to_model(table) # the stores configuration (static, for each table,...) # NOTE: the interface require a store for all tables including alias. # The only way to extract them is to scan the attributes list of # the DAL since the method db.tables() or any variant return # tables but not the alias one - config['stores'].update(PluginManager("dbui").dbui.static_stores) + config["stores"].update(PluginManager("dbui").dbui.static_stores) for table in get_all_tables(db): cfg = to_jsonstore(table) - config['stores'][cfg['storeId']] = cfg + config["stores"][cfg["storeId"]] = cfg # the tree nodes configuration for the TreeStore - config['treeNodes'] = to_treeNodes() + config["treeNodes"] = to_treeNodes() # the viewport configuration - config['viewport'] = to_viewport() + config["viewport"] = to_viewport() # debug mode - debug = 'false' - if 'debug' in request.vars: - debug = 'true' + debug = "false" + if "debug" in request.vars: + debug = "true" # fill the javascript template app = request.application script = API % (app, - json.dumps(config, cls=dbui.JSONEncoder), + json.dumps(config, cls=JSONEncoder), debug, app, app, @@ -161,7 +159,7 @@ def dbui_conf(): json.dumps(di)) # return the response as a javascript - response.headers['Content-Type'] = 'text/javascript' + response.headers["Content-Type"] = "text/javascript" return script @@ -175,6 +173,12 @@ def documentations_table(): """ from plugin_dbui import get_reference_paths, Store + def path_exists(x): + return x and os.path.exists(os.path.join(apath, x)) + + def f(x): + return x.replace("static/", "") + plugin = PluginManager("dbui").dbui # alias @@ -186,62 +190,71 @@ def documentations_table(): apath, lpath = get_reference_paths() - path_exists = lambda x: x and os.path.exists(os.path.join(apath, x)) - f = lambda x: x.replace("static/", "") - # documentation of the application userdoc = "" path_db_schema = plugin.app_db_schema if path_exists(path_db_schema): - userdoc = a % (URL('static', f(path_db_schema)), T("Data base scheme")) + userdoc = a % (URL("static", f(path_db_schema)), T("Data base scheme")) pydoc = "" path_html_api = plugin.app_html_api if path_exists(path_html_api): - pydoc = a % (URL('static', f(path_html_api)), trPy) + pydoc = a % (URL("static", f(path_html_api)), trPy) jsdoc = "" path_html_jsduck = plugin.app_html_jsduck if path_exists(path_html_jsduck): - jsdoc = a % (URL('static', f(path_html_jsduck)), trJS) + jsdoc = a % (URL("static", f(path_html_jsduck)), trJS) # configuration of the Ext.data.Store for the documentation cfg = Store() - cfg.fields = [dict(name='code', type='string'), - dict(name='developer', type='string'), - dict(name='python', type='string'), - dict(name='javascript', type='string')] - - r1 = dict(code=request.application, - developer=userdoc, - python=pydoc, - javascript=jsdoc) - - r2 = dict(code=a % ("https://marprod.in2p3.fr/plugin_dbui_book", "plugin_dbui"), - developer=a % (URL('static', 'plugin_dbui/docs/reference/index.html'), trDev), - python=a % (URL('static', 'plugin_dbui/docs/api/index.html'), trPy), - javascript=a % (URL('static', 'plugin_dbui/docs/jsduck/index.html'), trJS)) - - r3 = dict(code=a % ("http://web2py.com/", "Web2py"), - developer=a % ("http://web2py.com/book", trDev), - python=a % ("http://web2py.readthedocs.org/en/latest/", trPy), - javascript="") - - r4 = dict(code=a % ("http://www.sencha.com/products/extjs/", "Ext JS"), - developer="", - python="", - javascript=a % ("http://docs.sencha.com/extjs/6.0.1-classic/", trJS)) - - r5 = dict(code=a % ("http://www.mathjax.org/", "MathJax"), - developer="", - python="", - javascript=a % ("http://docs.mathjax.org/", trJS)) - - r6 = dict(code=a % ("http://ace.c9.io/#nav=about", "Ace"), - developer="", - python="", - javascript=a % ("http://ace.c9.io/#nav=api", trJS)) + cfg.fields = [ + dict(name="code", type="string"), + dict(name="developer", type="string"), + dict(name="python", type="string"), + dict(name="javascript", type="string")] + + r1 = dict( + code=request.application, + developer=userdoc, + python=pydoc, + javascript=jsdoc) + + r2 = dict( + code=a % ("https://marprod.in2p3.fr/plugin_dbui_book", "plugin_dbui"), + + developer=a % + (URL("static", "plugin_dbui/docs/reference/index.html"), trDev), + + python=a % (URL("static", "plugin_dbui/docs/api/index.html"), trPy), + + javascript=a % + (URL("static", "plugin_dbui/docs/jsduck/index.html"), trJS)) + + r3 = dict( + code=a % ("http://web2py.com/", "Web2py"), + developer=a % ("http://web2py.com/book", trDev), + python=a % ("http://web2py.readthedocs.org/en/latest/", trPy), + javascript="") + + r4 = dict( + code=a % ("http://www.sencha.com/products/extjs/", "Ext JS"), + developer="", + python="", + javascript=a % ("http://docs.sencha.com/extjs/6.0.1-classic/", trJS)) + + r5 = dict( + code=a % ("http://www.mathjax.org/", "MathJax"), + developer="", + python="", + javascript=a % ("http://docs.mathjax.org/", trJS)) + + r6 = dict( + code=a % ("http://ace.c9.io/#nav=about", "Ace"), + developer="", + python="", + javascript=a % ("http://ace.c9.io/#nav=api", trJS)) cfg.data = [r1, r2, r3, r4, r5, r6] @@ -249,33 +262,38 @@ def documentations_table(): # configuration of the Ext.data.Store for the source code cfg = Store() - cfg.fields = [dict(name='code', type='string'), - dict(name='source', type='string')] + cfg.fields = [ + dict(name="code", type="string"), + dict(name="source", type="string")] src = "" if plugin.app_git: src = "<em>git clone %s</em>" % plugin.app_git - r1 = dict(code=request.application, - source=src) + r1 = dict(code=request.application, source=src) - r2 = dict(code="plugin_dbui", - source="<em>git clone https://gitlab.in2p3.fr/w2pext/" - "plugin_dbui.git</em>") + r2 = dict( + code="plugin_dbui", + source="<em>git clone https://gitlab.in2p3.fr/w2pext/" + "plugin_dbui.git</em>") - r3 = dict(code="Web2py", - source="<em>git clone https://github.com/web2py/web2py.git</em>") + r3 = dict( + code="Web2py", + source="<em>git clone https://github.com/web2py/web2py.git</em>") - r4 = dict(code="Ext JS", - source="<em>Download from the Ext JS web site. </em><br>" - "<em>It is also available in the local directory: " - "%s/static/plugin_extjs/src</em>" % request.application) + r4 = dict( + code="Ext JS", + source="<em>Download from the Ext JS web site. </em><br>" + "<em>It is also available in the local directory: " + "%s/static/plugin_extjs/src</em>" % request.application) - r5 = dict(code="MathJax", - source="<em>git clone http://github.com/mathjax/MathJax</em>") + r5 = dict( + code="MathJax", + source="<em>git clone http://github.com/mathjax/MathJax</em>") - r6 = dict(code="Ace", - source="<em>git clone git://github.com/ajaxorg/ace.git</em>") + r6 = dict( + code="Ace", + source="<em>git clone git://github.com/ajaxorg/ace.git</em>") cfg.data = [r1, r2, r3, r4, r5, r6] @@ -340,34 +358,34 @@ def index(): # css for plg in plugins_paths: - path =plugins_paths[plg]["css"] - if path is not None: - lst.extend(get_file_paths(path, ext='.css')) + path = plugins_paths[plg]["css"] + if path is not None: + lst.extend(get_file_paths(path, ext=".css")) - lst.extend(get_file_paths(plugin.app_css, ext='.css')) + lst.extend(get_file_paths(plugin.app_css, ext=".css")) # javascript libraries # depend on the debug mode either minified or full version key = ("debug" if is_debug else "libmin") for plg in plugins_paths: - path =plugins_paths[plg][key] - if path is not None: + path = plugins_paths[plg][key] + if path is not None: if plg == "extjs": - lst.extend(get_file_paths(path, ext='.js', alpha=False)) + lst.extend(get_file_paths(path, ext=".js", alpha=False)) else: - lst.extend(get_file_paths(path, ext='.js')) + lst.extend(get_file_paths(path, ext=".js")) path = (plugin.app_debug if is_debug else plugin.app_libmin) - lst.extend(get_file_paths(path, ext='.js')) + lst.extend(get_file_paths(path, ext=".js")) # language for plg in plugins_paths: - path =plugins_paths[plg]["lg"] - if path is not None: - lst.extend(get_file_paths(path, ext='.js')) + path = plugins_paths[plg]["lg"] + if path is not None: + lst.extend(get_file_paths(path, ext=".js")) - lst.extend(get_file_paths(plugin.app_lg, ext='.js')) + lst.extend(get_file_paths(plugin.app_lg, ext=".js")) # URL for dbui configuration script path = (plugin.dbui_conf_debug if is_debug else plugin.dbui_conf) @@ -388,7 +406,7 @@ def index(): '<link rel="stylesheet" type="text/css" href="%s"/>\n\t\t' % el else: fwlib += \ - '<script type="text/javascript" src="%s"></script>\n\t\t' %el + '<script type="text/javascript" src="%s"></script>\n\t\t' % el return dict(fwlib=fwlib) @@ -406,32 +424,32 @@ def latex2pdf(): # create the latex file in the private directory cwd = os.getcwd() - os.chdir(os.path.join(request.folder, 'private')) + os.chdir(os.path.join(request.folder, "private")) fn = str(uuid4()) - fi = open('%s.tex' % fn, 'wb') + fi = open("%s.tex" % fn, "wb") fi.write(latex_string) fi.close() # convert the latex file into pdf # run latex twice for longtable, ... - cmd = ['pdflatex', '-interaction', 'nonstopmode', '%s.tex' % fn] + cmd = ["pdflatex", "-interaction", "nonstopmode", "%s.tex" % fn] call(cmd, stdout=TemporaryFile()) call(cmd, stdout=TemporaryFile()) # clean latex processing - for ext in ('aux', 'log', 'tex'): - f = '%s.%s' % (fn, ext) + for ext in ("aux", "log", "tex"): + f = "%s.%s" % (fn, ext) if os.path.exists(f): os.remove(f) # dummy pdf if latex processing failed - pdf = '%s.pdf' % fn + pdf = "%s.pdf" % fn if not os.path.exists(pdf): - return 'Empty PDF file since LaTeX processing failed.' + return "Empty PDF file since LaTeX processing failed." # copy the pdf file into a string an clean - fi = open(pdf, 'rb') + fi = open(pdf, "rb") pdf_string = fi.read() fi.close() @@ -451,14 +469,14 @@ def versions(): """Return the versions of the different part of the code. """ - from plugin_dbui import get_versions, Store + from plugin_dbui import get_versions, JSONEncoder, Store # the configuration for the Ext.data.Store cfg = Store() - cfg.fields = [dict(name='code', type='string'), - dict(name='version', type='string')] + cfg.fields = [dict(name="code", type="string"), + dict(name="version", type="string")] cfg.data = get_versions() - return dict(cfg_store=json.dumps(cfg, cls=dbui.JSONEncoder)) + return dict(cfg_store=json.dumps(cfg, cls=JSONEncoder)) diff --git a/controllers/reports.py b/controllers/reports.py index 7795cd58726cf68f8ec66fa81a98f5b71534390e..e6f0a29230dc3fdf716770b1958489f8dc8a83a6 100644 --- a/controllers/reports.py +++ b/controllers/reports.py @@ -8,7 +8,7 @@ def index(): """Main Controller handling report. """ - return 'Report section' + return "Report section" def report_1(): @@ -38,7 +38,7 @@ def report_3(): """ selector = Selector(virtdb.harvester_selector) - response.view = 'reports/report_2.html' + response.view = "reports/report_2.html" return dict(test=selector.as_dict()) @@ -53,13 +53,13 @@ def report_4(): cfg = Store() - cfg.fields = [dict(name='controller', type='string'), - dict(name='host', type='string'), - dict(name='collections', type='string'), - dict(name='ratio', type='number')] + cfg.fields = [dict(name="controller", type="string"), + dict(name="host", type="string"), + dict(name="collections", type="string"), + dict(name="ratio", type="number")] if selector.grouping or selector.grouping_summary: - cfg.groupField = 'controller' + cfg.groupField = "controller" cfg.data = [] @@ -70,7 +70,7 @@ def report_4(): collections=row.collections, ratio=row.ratio) - cfg['data'].append(di) + cfg["data"].append(di) return dict(msg="Hello world", cfg_store=json.dumps(cfg), diff --git a/docs/api/conf.py b/docs/api/conf.py index 3b4531b8c37204ebeedcb7cb6562b0b12f2759fe..37cb5029abdffeb5e0923022620eb375608803a4 100644 --- a/docs/api/conf.py +++ b/docs/api/conf.py @@ -19,66 +19,66 @@ from datetime import datetime def get_plugin_dbui_release(): - JSBASE = '../../static/plugin_dbui/src/Dbui.js' - s = open(JSBASE, 'rb').read() - m = re.match("(.+ version: ')([\w._-]*)('.+)", s, re.DOTALL) + JSBASE = "../../static/plugin_dbui/src/Dbui.js" + s = open(JSBASE, "rb").read() + m = re.match('(.+ version: ")([\w._-]*)(".+)', s, re.DOTALL) return m.group(2) # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. -# sys.path.insert(0, os.path.abspath('.')) -sys.path.insert(0, os.path.abspath('../../modules')) +# sys.path.insert(0, os.path.abspath(".")) +sys.path.insert(0, os.path.abspath("../../modules")) # docker image if os.path.exists("/opt/web2py"): - sys.path.insert(0, os.path.abspath('/opt/web2py')) + sys.path.insert(0, os.path.abspath("/opt/web2py")) # older running environment else: - sys.path.insert(0, os.path.abspath('../../../web2py')) + sys.path.insert(0, os.path.abspath("../../../web2py")) # -- General configuration ----------------------------------------------------- # If your documentation needs a minimal Sphinx version, state it here. -# needs_sphinx = '1.0' +# needs_sphinx = "1.0" # Add any Sphinx extension module names here, as strings. They can be extensions -# coming with Sphinx (named 'sphinx.ext.*') or your custom ones. -extensions = ['sphinx.ext.autodoc', - 'sphinx.ext.autosummary', - 'sphinx.ext.intersphinx', - 'sphinx.ext.napoleon', - 'sphinx.ext.todo', - 'sphinx.ext.mathjax', - 'sphinx.ext.viewcode'] +# coming with Sphinx (named "sphinx.ext.*") or your custom ones. +extensions = ["sphinx.ext.autodoc", + "sphinx.ext.autosummary", + "sphinx.ext.intersphinx", + "sphinx.ext.napoleon", + "sphinx.ext.todo", + "sphinx.ext.mathjax", + "sphinx.ext.viewcode"] # autosummary configuration autosummary_generate = False # intersphinx configuration -intersphinx_mapping = {'python': ('http://docs.python.org/2.7', None)} +intersphinx_mapping = {"python": ("http://docs.python.org/2.7", None)} # napoleon configuration napoleon_user_rtype = False # Add any paths that contain templates here, relative to this directory. -templates_path = ['_templates'] +templates_path = ["_templates"] # The suffix of source filenames. -source_suffix = '.rst' +source_suffix = ".rst" # The encoding of source files. -# source_encoding = 'utf-8-sig' +# source_encoding = "utf-8-sig" # The master toctree document. -master_doc = 'index' +master_doc = "index" # General information about the project. now = datetime.now() -project = u'plugin_dbui' -copyright = u'2009-%s, R. Le Gac, licensed under CeCILL' % now.year +project = u"plugin_dbui" +copyright = u"2009-%s, R. Le Gac, licensed under CeCILL" % now.year # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the @@ -88,7 +88,7 @@ copyright = u'2009-%s, R. Le Gac, licensed under CeCILL' % now.year release = get_plugin_dbui_release() # The short X.Y version. -version = release[:release.rfind('.')] +version = release[:release.rfind(".")] # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. @@ -96,18 +96,18 @@ version = release[:release.rfind('.')] # There are two options for replacing |today|: either, you set today to some # non-false value, then it is used: -# today = '' +# today = "" # Else, today_fmt is used as the format for a strftime call. -# today_fmt = '%B %d, %Y' +# today_fmt = "%B %d, %Y" # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. -exclude_patterns = ['_build'] +exclude_patterns = ["_build"] # The reST default role (used for this markup: `text`) to use for all documents. # default_role = None -# If true, '()' will be appended to :func: etc. cross-reference text. +# If true, "()" will be appended to :func: etc. cross-reference text. # add_function_parentheses = True # If true, the current module name will be prepended to all description @@ -119,7 +119,7 @@ exclude_patterns = ['_build'] # show_authors = False # The name of the Pygments (syntax highlighting) style to use. -pygments_style = 'sphinx' +pygments_style = "sphinx" # A list of ignored prefixes for module index sorting. # modindex_common_prefix = [] @@ -129,7 +129,7 @@ pygments_style = 'sphinx' # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. -html_theme = 'sphinxdoc' +html_theme = "sphinxdoc" # Theme options are theme-specific and customize the look and feel of a theme # further. For a list of options available for each theme, see the @@ -158,11 +158,11 @@ html_theme = 'sphinxdoc' # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". -# html_static_path = ['_static'] +# html_static_path = ["_static"] -# If not '', a 'Last updated on:' timestamp is inserted at every page bottom, +# If not "", a "Last updated on:" timestamp is inserted at every page bottom, # using the given strftime format. -# html_last_updated_fmt = '%b %d, %Y' +# html_last_updated_fmt = "%b %d, %Y" # If true, SmartyPants will be used to convert quotes and dashes to # typographically correct entities. @@ -196,33 +196,33 @@ html_theme = 'sphinxdoc' # If true, an OpenSearch description file will be output, and all pages will # contain a <link> tag referring to it. The value of this option must be the # base URL from which the finished HTML is served. -# html_use_opensearch = '' +# html_use_opensearch = "" # This is the file name suffix for HTML files (e.g. ".xhtml"). # html_file_suffix = None # Output file base name for HTML help builder. -htmlhelp_basename = 'plugin_dbuidoc' +htmlhelp_basename = "plugin_dbuidoc" # -- Options for LaTeX output -------------------------------------------------- latex_elements = { -# The paper size ('letterpaper' or 'a4paper'). -# 'papersize': 'letterpaper', +# The paper size ("letterpaper" or "a4paper"). +# "papersize": "letterpaper", -# The font size ('10pt', '11pt' or '12pt'). -# 'pointsize': '10pt', +# The font size ("10pt", "11pt" or "12pt"). +# "pointsize": "10pt", # Additional stuff for the LaTeX preamble. -# 'preamble': '', +# "preamble": "", } # Grouping the document tree into LaTeX files. List of tuples # (source start file, target name, title, author, documentclass [howto/manual]). latex_documents = [ - ('index', 'plugin_dbui.tex', u'plugin\\_dbui Documentation', - u'R. Le Gac', 'manual'), + ("index", "plugin_dbui.tex", u"plugin\\_dbui Documentation", + u"R. Le Gac", "manual"), ] # The name of an image file (relative to this directory) to place at the top of @@ -251,8 +251,8 @@ latex_documents = [ # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). man_pages = [ - ('index', 'plugin_dbui', u'plugin_dbui Documentation', - [u'R. Le Gac'], 1) + ("index", "plugin_dbui", u"plugin_dbui Documentation", + [u"R. Le Gac"], 1) ] # If true, show URL addresses after external links. @@ -265,9 +265,9 @@ man_pages = [ # (source start file, target name, title, author, # dir menu entry, description, category) texinfo_documents = [ - ('index', 'plugin_dbui', u'plugin_dbui Documentation', - u'R. Le Gac', 'plugin_dbui', 'One line description of project.', - 'Miscellaneous'), + ("index", "plugin_dbui", u"plugin_dbui Documentation", + u"R. Le Gac", "plugin_dbui", "One line description of project.", + "Miscellaneous"), ] # Documents to append as an appendix to all manuals. @@ -276,5 +276,5 @@ texinfo_documents = [ # If false, no module index is generated. # texinfo_domain_indices = True -# How to display URL addresses: 'footnote', 'no', or 'inline'. -# texinfo_show_urls = 'footnote' +# How to display URL addresses: "footnote", "no", or "inline". +# texinfo_show_urls = "footnote" diff --git a/docs/reference/conf.py b/docs/reference/conf.py index c99d6e1be3dc31de57ff6bae09123d0e95ab2dd9..53a5972646cfe9e91f3763710016cc7e03b3ab24 100644 --- a/docs/reference/conf.py +++ b/docs/reference/conf.py @@ -20,41 +20,41 @@ from datetime import datetime def get_plugin_dbui_release(): - JSBASE = '../../static/plugin_dbui/src/Dbui.js' - s = open(JSBASE, 'rb').read() - m = re.match("(.+ version: ')([\w._-]*)('.+)", s, re.DOTALL) + JSBASE = "../../static/plugin_dbui/src/Dbui.js" + s = open(JSBASE, "rb").read() + m = re.match('(.+ version: ")([\w._-]*)(".+)', s, re.DOTALL) return m.group(2) # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. -# sys.path.insert(0, os.path.abspath('.')) +# sys.path.insert(0, os.path.abspath(".")) # -- General configuration ----------------------------------------------------- # If your documentation needs a minimal Sphinx version, state it here. -# needs_sphinx = '1.0' +# needs_sphinx = "1.0" # Add any Sphinx extension module names here, as strings. They can be extensions -# coming with Sphinx (named 'sphinx.ext.*') or your custom ones. -extensions = ['sphinx.ext.todo'] +# coming with Sphinx (named "sphinx.ext.*") or your custom ones. +extensions = ["sphinx.ext.todo"] # Add any paths that contain templates here, relative to this directory. -templates_path = ['_templates'] +templates_path = ["_templates"] # The suffix of source filenames. -source_suffix = '.rst' +source_suffix = ".rst" # The encoding of source files. -# source_encoding = 'utf-8-sig' +# source_encoding = "utf-8-sig" # The master toctree document. -master_doc = 'index' +master_doc = "index" # General information about the project. now = datetime.now() -project = u'plugin_dbui' -copyright = u'2009-%s by Renaud Le Gac, licensed under CeCILL' % now.year +project = u"plugin_dbui" +copyright = u"2009-%s by Renaud Le Gac, licensed under CeCILL" % now.year # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the @@ -64,7 +64,7 @@ copyright = u'2009-%s by Renaud Le Gac, licensed under CeCILL' % now.year release = get_plugin_dbui_release() # The short X.Y version. -version = release[:release.rfind('.')] +version = release[:release.rfind(".")] # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. @@ -72,9 +72,9 @@ version = release[:release.rfind('.')] # There are two options for replacing |today|: either, you set today to some # non-false value, then it is used: -# today = '' +# today = "" # Else, today_fmt is used as the format for a strftime call. -# today_fmt = '%B %d, %Y' +# today_fmt = "%B %d, %Y" # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. @@ -83,7 +83,7 @@ exclude_patterns = [] # The reST default role (used for this markup: `text`) to use for all documents. # default_role = None -# If true, '()' will be appended to :func: etc. cross-reference text. +# If true, "()" will be appended to :func: etc. cross-reference text. # add_function_parentheses = True # If true, the current module name will be prepended to all description @@ -95,7 +95,7 @@ exclude_patterns = [] # show_authors = False # The name of the Pygments (syntax highlighting) style to use. -pygments_style = 'sphinx' +pygments_style = "sphinx" # A list of ignored prefixes for module index sorting. # modindex_common_prefix = [] @@ -105,7 +105,7 @@ pygments_style = 'sphinx' # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. -html_theme = 'sphinxdoc' +html_theme = "sphinxdoc" # Theme options are theme-specific and customize the look and feel of a theme # further. For a list of options available for each theme, see the @@ -134,11 +134,11 @@ html_theme = 'sphinxdoc' # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". -# html_static_path = ['_static'] +# html_static_path = ["_static"] -# If not '', a 'Last updated on:' timestamp is inserted at every page bottom, +# If not "", a "Last updated on:" timestamp is inserted at every page bottom, # using the given strftime format. -# html_last_updated_fmt = '%b %d, %Y' +# html_last_updated_fmt = "%b %d, %Y" # If true, SmartyPants will be used to convert quotes and dashes to # typographically correct entities. @@ -172,33 +172,33 @@ html_theme = 'sphinxdoc' # If true, an OpenSearch description file will be output, and all pages will # contain a <link> tag referring to it. The value of this option must be the # base URL from which the finished HTML is served. -# html_use_opensearch = '' +# html_use_opensearch = "" # This is the file name suffix for HTML files (e.g. ".xhtml"). # html_file_suffix = None # Output file base name for HTML help builder. -htmlhelp_basename = 'plugin_dbuidoc' +htmlhelp_basename = "plugin_dbuidoc" # -- Options for LaTeX output -------------------------------------------------- latex_elements = { -# The paper size ('letterpaper' or 'a4paper'). -# 'papersize': 'letterpaper', +# The paper size ("letterpaper" or "a4paper"). +# "papersize": "letterpaper", -# The font size ('10pt', '11pt' or '12pt'). -# 'pointsize': '10pt', +# The font size ("10pt", "11pt" or "12pt"). +# "pointsize": "10pt", # Additional stuff for the LaTeX preamble. -# 'preamble': '', +# "preamble": "", } # Grouping the document tree into LaTeX files. List of tuples # (source start file, target name, title, author, documentclass [howto/manual]). latex_documents = [ - ('index', 'plugin_dbui.tex', u'plugin\\_dbui Documentation', - u'R. Le Gac', 'manual'), + ("index", "plugin_dbui.tex", u"plugin\\_dbui Documentation", + u"R. Le Gac", "manual"), ] # The name of an image file (relative to this directory) to place at the top of @@ -227,8 +227,8 @@ latex_documents = [ # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). man_pages = [ - ('index', 'plugin_dbui', u'plugin_dbui Documentation', - [u'R. Le Gac'], 1) + ("index", "plugin_dbui", u"plugin_dbui Documentation", + [u"R. Le Gac"], 1) ] # If true, show URL addresses after external links. @@ -241,9 +241,9 @@ man_pages = [ # (source start file, target name, title, author, # dir menu entry, description, category) texinfo_documents = [ - ('index', 'plugin_dbui', u'plugin_dbui Documentation', - u'R. Le Gac', 'plugin_dbui', 'One line description of project.', - 'Miscellaneous'), + ("index", "plugin_dbui", u"plugin_dbui Documentation", + u"R. Le Gac", "plugin_dbui", "One line description of project.", + "Miscellaneous"), ] # Documents to append as an appendix to all manuals. @@ -252,5 +252,5 @@ texinfo_documents = [ # If false, no module index is generated. # texinfo_domain_indices = True -# How to display URL addresses: 'footnote', 'no', or 'inline'. -# texinfo_show_urls = 'footnote' +# How to display URL addresses: "footnote", "no", or "inline". +# texinfo_show_urls = "footnote" diff --git a/models/access.py b/models/access.py deleted file mode 100644 index 20faac331fbdf2a78d1079030e2907c8dd450309..0000000000000000000000000000000000000000 --- a/models/access.py +++ /dev/null @@ -1,20 +0,0 @@ -# -*- coding: utf-8 -*- -""" access - - setup the connection to the databases - -""" -#------------------------------------------------------------------------------- -# -# sqlite database -# -#------------------------------------------------------------------------------- - -db = DAL('sqlite://storage.sqlite', lazy_tables=True, migrate=True) - -#------------------------------------------------------------------------------- -# -# virtual database -# -#------------------------------------------------------------------------------- -virtdb = DAL(None) diff --git a/models/common_settings.py b/models/common_settings.py deleted file mode 100644 index 9f9b4f6d15fb38d637e6c97759f99602f7465ec5..0000000000000000000000000000000000000000 --- a/models/common_settings.py +++ /dev/null @@ -1,80 +0,0 @@ -# -*- coding: utf-8 -*- -""" Common settings - -""" -import plugin_dbui as dbui - -from callbacks import country_delete, country_insert, country_update -from datetime import datetime -from gluon.tools import PluginManager - -#............................................................................. -# -# Language -# - -T.set_current_languages("en", "en-gb", "en-us") # mother tongue -T.force("fr-fr") # user language -T.lazy = True # no immediate translation - -#............................................................................. -# -# Configure plugin_dbui -# - -plg_dbui = dbui.Dbui - -plg_dbui.define_paths( - app_about="static/plugin_dbui/ABOUT.html", - # app_css=None, - app_db_schema=None, - app_changelog="static/plugin_dbui/CHANGELOG", - app_git="https://gitlab.in2p3.fr/w2pext/plugin_dbui.git", - app_html_api="static/plugin_dbui/docs/api/index.html", - app_html_jsduck="static/plugin_dbui/docs/jsduck/index.html", - app_html_reference="static/plugin_dbui/docs/reference/index.html", - app_html_user=None, - # app_libmin=None, - app_pdf_api="static/plugin_dbui/docs/pdf/dbui_api.pdf", - app_pdf_reference="static/plugin_dbui/docs/pdf/dbui_reference.pdf", - app_script="static/app.js", - app_script_dir="static/scripts", - # dbui_libmin="static/plugin_dbui/dbui-debug.js" -) - -plg_dbui.initialise_ui() - -directSvc = plg_dbui.start_directSvc() - -#............................................................................. -# -# Constants -# - -undef = T(dbui.UNDEF) -undef_id = dbui.UNDEF_ID -year = datetime.now().year - -#............................................................................. -# -# Common configuration for forms and grids -# - -tables = ["categories", - "collaborations", - "countries", - "harvesters", - "new_fields", - "projects", - "publishers", - "publications", - "reports", - "teams"] - -dbui.configure_forms(tables, plugins=["pFormToolTip"], - width=300) - -dbui.configure_grids(tables, plugins=["pGridRowEditorConfirmDelete", - "pGridRowEditorContextMenu", - "pGridRowEditorDblClick", - "pGridToolbar"]) diff --git a/models/db0_categories.py b/models/db0_categories.py deleted file mode 100644 index 97279dbdccfeeea30c484abf771d5c647ffeecdc..0000000000000000000000000000000000000000 --- a/models/db0_categories.py +++ /dev/null @@ -1,13 +0,0 @@ -# -*- coding: utf-8 -*- -""" categories - -""" -tp_code = "The code has to be in upper case." - -db.define_table("categories", - Field("code", "string", comment=tp_code, notnull=True, unique=True), - Field("definition", "text", notnull=True), - migrate="categories.table") - -db.categories._before_delete.append(dbui.INHIBIT_DELETE_UNDEF) -db.categories._before_update.append(dbui.INHIBIT_UPDATE_UNDEF) \ No newline at end of file diff --git a/models/db0_collaborations.py b/models/db0_collaborations.py deleted file mode 100644 index 1068b6a55606a8d5930c6db2a56026940ab4f88d..0000000000000000000000000000000000000000 --- a/models/db0_collaborations.py +++ /dev/null @@ -1,7 +0,0 @@ -# -*- coding: utf-8 -*- -""" Collaborations - -""" -db.define_table("collaborations", - Field("collaboration", "string", notnull=True, unique=True), - migrate="collaborations.table") \ No newline at end of file diff --git a/models/db0_countries_.py b/models/db0_countries_.py deleted file mode 100644 index 3b0a95dcb6de7de71f6583bb8875acef68af15f9..0000000000000000000000000000000000000000 --- a/models/db0_countries_.py +++ /dev/null @@ -1,12 +0,0 @@ -# -*- coding: utf-8 -*- -""" countries - -""" -db.define_table("countries", - Field("country", "string", notnull=True, unique=True), - Field("abbreviation", "string", notnull=True), - migrate="countries.table") - -db.countries._before_delete.append(country_delete) -db.countries._before_insert.append(country_insert) -db.countries._before_update.append(country_update) \ No newline at end of file diff --git a/models/db0_new_fields.py b/models/db0_new_fields.py deleted file mode 100644 index 424973ef042ec9f47d6fb88c64086f2725e7b921..0000000000000000000000000000000000000000 --- a/models/db0_new_fields.py +++ /dev/null @@ -1,13 +0,0 @@ -# -*- coding: utf-8 -*- -""" new_fields - -""" -db.define_table("new_fields", - Field("string", "string"), - Field("list_string", "list:string"), - Field("dictionary", "json"), - Field("python_code", "text"), - migrate="new_fields.table") - -# NOTE: if we remove the json validator its seem to work ? -db.new_fields.dictionary.requires = None \ No newline at end of file diff --git a/models/db0_preferences.py b/models/db0_preferences.py deleted file mode 100644 index 9a92ce922f92755b3ba6f06561e704d011af660e..0000000000000000000000000000000000000000 --- a/models/db0_preferences.py +++ /dev/null @@ -1,12 +0,0 @@ -# -*- coding: utf-8 -*- -""" preferences - -""" -db.define_table("preferences", - Field("property", "string", length=255, notnull=True, unique=True), - Field("value", "json", length=255), - Field("definition", "text", notnull=True), - migrate="preferences.table") - -# NOTE: if we remove the json validator its seem to work ? -db.preferences.value.requires = None \ No newline at end of file diff --git a/models/db0_projects.py b/models/db0_projects.py deleted file mode 100644 index e51534cd74c6435717ff629ee48bde967dc11bf3..0000000000000000000000000000000000000000 --- a/models/db0_projects.py +++ /dev/null @@ -1,7 +0,0 @@ -# -*- coding: utf-8 -*- -""" projects - -""" -db.define_table("projects", - Field("project", "string", notnull=True, unique=True), - migrate="projects.table") \ No newline at end of file diff --git a/models/db0_publishers.py b/models/db0_publishers.py deleted file mode 100644 index 7a691530537439b2dde67c84a6b0e08dc45f1656..0000000000000000000000000000000000000000 --- a/models/db0_publishers.py +++ /dev/null @@ -1,8 +0,0 @@ -# -*- coding: utf-8 -*- -""" publishers - -""" -db.define_table("publishers", - Field("publisher", "string", notnull=True, unique=True), - Field("abbreviation", "string", notnull=True), - migrate="publishers.table") \ No newline at end of file diff --git a/models/db0_reports.py b/models/db0_reports.py deleted file mode 100644 index efa0f7f28306549d88a486f4a8bc6378cd84a5c0..0000000000000000000000000000000000000000 --- a/models/db0_reports.py +++ /dev/null @@ -1,7 +0,0 @@ -# -*- coding: utf-8 -*- -""" reports - -""" -db.define_table("reports", - Field("type", "string", notnull=True, unique=True), - migrate="reports.table") \ No newline at end of file diff --git a/models/db0_teams.py b/models/db0_teams.py deleted file mode 100644 index 8579f698694d342318ca3b1297341e9aee2415ee..0000000000000000000000000000000000000000 --- a/models/db0_teams.py +++ /dev/null @@ -1,9 +0,0 @@ -# -*- coding: utf-8 -*- -""" teams - -""" -db.define_table("teams", - Field("team", "string", notnull=True, unique=True), - migrate="teams.table") - -db.teams.team.filter_in = dbui.CLEAN_SPACES \ No newline at end of file diff --git a/models/db1_harvesters.py b/models/db1_harvesters.py deleted file mode 100644 index a4a677759d9291a439a6b62794e580a79955426b..0000000000000000000000000000000000000000 --- a/models/db1_harvesters.py +++ /dev/null @@ -1,47 +0,0 @@ -# -*- coding: utf-8 -*- -""" harvesters - -""" -tp_category = \ -"Publication category associated to the record." - -tp_collections = \ -"List of collections separated by commma: LHCb Papers, LHCb Talks" - -tp_controller = \ -"The name of the web2py controller running the search: articles, proceedings,..." - -tp_host = \ -"Address of the invenio store where the search is performed." - -tp_max_records = \ -"Maximum number of records which can be retrieved from a search." - -tp_ratio = \ -"Parameter for fuzzy string search." - -db.define_table("harvesters", - Field("id_teams", "reference teams", default=undef_id, label='Team'), - Field("id_projects", "reference projects", default=undef_id, label='Project'), - Field("controller", "string", default='articles', notnull=True, comment=tp_controller), - Field("host", "string", notnull=True, default='cdsweb.cern.ch', label='Store', comment=tp_host), - Field("collections", "string", comment=tp_collections), - Field("ratio", "double", notnull=True, default=1.0, comment=tp_ratio), - Field("id_categories", "reference categories", default=1, label='Category', comment=tp_category), - migrate="harvesters.table") - -db.harvesters.controller.requires = \ -IS_IN_SET(['articles', 'notes', 'preprints', 'proceedings', 'reports', 'talks', 'theses']) - -# TEST THE DIFFERENT SYNTAX DEFINING FOREIGN KEY -db.harvesters.id_categories.requires = \ -IS_IN_DB(db, 'categories.id', 'categories.code') - -db.harvesters.id_projects.requires = \ -IS_IN_DB(db, 'projects.project') - -#db.harvesters.id_teams.requires = \ -#IS_IN_DB(db, 'teams.id', 'teams.team') - -db.harvesters.ratio.requires = \ -IS_FLOAT_IN_RANGE(0., 1.0) \ No newline at end of file diff --git a/models/db1_publications.py b/models/db1_publications.py deleted file mode 100644 index e70a213a988b3d43cae53eada4a4acd991705265..0000000000000000000000000000000000000000 --- a/models/db1_publications.py +++ /dev/null @@ -1,55 +0,0 @@ -# -*- coding: utf-8 -*- -""" publications - -""" -tp_authors = \ -"""List of authors separated by commma: J. Doe, P.-Y. Smith -For large collaboration the first author followed by et al.: J. Doe et al.""" - -tp_authors_cppm = \ -"""List of authors separated by comma: P.-Y. Doe, J. Smith""" - -tp_first = "first page" - -tp_last = "last_page" - -tp_report_numbers = \ -"""List of report identifier separated by comma: -LHCb-PROC-2008-04, arXiv:0906.1516 """ - -tp_speaker = \ -"""The name of the speaker: P.-Y. Smith""" - -db.define_table("publications", - Field("title", "text", notnull=True), - Field("authors", "string", notnull=True, comment=tp_authors), - Field("id_collaborations", 'reference collaborations', default=undef_id, label="Collaboration"), - Field("id_publishers", 'reference publishers', default=undef_id, label="Publisher"), - Field("year", "integer", notnull=True, default=year, requires=IS_INT_IN_RANGE(1900, year+1)), - Field("doi", "string"), - Field("volume", "integer", requires=IS_EMPTY_OR(IS_INT_IN_RANGE(1, None))), - Field("first_page", "integer", requires=IS_EMPTY_OR(IS_INT_IN_RANGE(1, None)), comment=tp_first), - Field("last_page", "integer", requires=IS_EMPTY_OR(IS_INT_IN_RANGE(1, None)), comment=tp_last), - Field("e_print", "string", requires=IS_EMPTY_OR(IS_URL())), - Field("conference_title", "text", label='Title'), - Field("conference_url", "string", label='url', requires=IS_EMPTY_OR(IS_URL())), - Field("conference_start", "date", label='Start date'), - Field("conference_end", "date", label='End date'), - Field("conference_town", "string", label='Town'), - Field("id_countries", 'reference countries', default=undef_id, label='Country'), - Field("conference_speaker", "string", label='Speaker', comment=tp_speaker), - Field("report_numbers", "string", comment=tp_report_numbers), - Field("id_reports", 'reference reports', default=undef_id, label="Report type"), - Field("authors_cppm", "text", notnull=True, comment=tp_authors_cppm), - Field("id_teams", 'reference teams', default=undef_id, label='Team'), - Field("id_projects", 'reference projects', default=undef_id, label='Projects'), - Field("id_categories", 'reference categories', default=undef_id, label='AERES'), - migrate="publications.table") - -# use different techniques to define foreign field -db.publications.id_categories.requires = \ - IS_IN_DB(db, 'categories.id', 'categories.code') - -db.publications.id_publishers.requires = IS_IN_DB(db, 'publishers.abbreviation') - -db.publications.id_projects.requires = IS_IN_DB(db, db.projects.project) diff --git a/models/main.py b/models/main.py new file mode 100644 index 0000000000000000000000000000000000000000..4bb09055b3b63c829ad11c90588b17137616b828 --- /dev/null +++ b/models/main.py @@ -0,0 +1,109 @@ +# -*- coding: utf-8 -*- +""" main + +Instantiate the database connection, model database tables and configure the +user interface. It is tune to only satisfy the need of the controller, +function pair. + +Note: + Expose to controllers several global variables: + + * app + * auth + * db + * virtdb + * directSvc + + They can be retrieved in module via the protocol "current". + +""" +from gluon import current +from model_core import Core +from model_selector import Selector +from plugin_dbui import configure_forms, configure_grids, Dbui +from ui_core import CoreUI +from ui_selector import SelectorUI +from ui_viewport import ViewportUi + +# ............................................................................ +# +# Connection to databases +# + +db = DAL('sqlite://storage.sqlite', lazy_tables=False, migrate=True) +virtdb = DAL(None) + +current.db = db +current.virtdb = virtdb + +# ............................................................................ +# +# Language +# + +T.set_current_languages("en", "en-gb", "en-us") # mother tongue +T.force("fr-fr") # user language +T.lazy = True # immediate translation + +# ............................................................................ +# +# Configure plugin_dbui +# + +Dbui.define_paths( + app_about="static/plugin_dbui/ABOUT.html", + # app_css=None, + app_db_schema=None, + app_changelog="static/plugin_dbui/CHANGELOG", + app_git="https://gitlab.in2p3.fr/w2pext/plugin_dbui.git", + app_html_api="static/plugin_dbui/docs/api/index.html", + app_html_jsduck="static/plugin_dbui/docs/jsduck/index.html", + app_html_reference="static/plugin_dbui/docs/reference/index.html", + app_html_user=None, + # app_libmin=None, + app_pdf_api="static/plugin_dbui/docs/pdf/dbui_api.pdf", + app_pdf_reference="static/plugin_dbui/docs/pdf/dbui_reference.pdf", + app_script="static/app.js", + app_script_dir="static/scripts", + # dbui_libmin="static/plugin_dbui/dbui-debug.js" +) + +# ............................................................................ +# +# Create the database models +# +Core.define_tables(db, T) +Selector.define_tables(virtdb, db, T) + +# ............................................................................ +# +# Configure the user interface +# + +Dbui.initialise_ui() +directSvc = Dbui.start_directSvc() + +# Common configuration for forms and grids +tables = ["categories", + "collaborations", + "countries", + "harvesters", + "new_fields", + "projects", + "publishers", + "publications", + "reports", + "teams"] + +configure_forms(tables, plugins=["pFormToolTip"], width=300) + +configure_grids( + tables, + plugins=["pGridRowEditorConfirmDelete", + "pGridRowEditorContextMenu", + "pGridRowEditorDblClick", + "pGridToolbar"]) + +CoreUI.configure(db, T) +SelectorUI.configure(virtdb, db, T) +ViewportUi.configure(virtdb, db, T) diff --git a/models/ui_categories.py b/models/ui_categories.py deleted file mode 100644 index d94acfaae672a2ce680d34392ad2027717c23c35..0000000000000000000000000000000000000000 --- a/models/ui_categories.py +++ /dev/null @@ -1,51 +0,0 @@ -# -*- coding: utf-8 -*- -""" categories widgets - -""" -#------------------------------------------------------------------------------- -# -# FIELDS CONFIGURATiON -# -#------------------------------------------------------------------------------- - -#------------------------------------------------------------------------------- -# -# FORM CONFIGURATiON -# -#------------------------------------------------------------------------------- - -#------------------------------------------------------------------------------- -# -# GRID CONFIGURATiON -# -#------------------------------------------------------------------------------- -gridModifier = dbui.GridModifier('categories') -gridModifier.configure(plugins=['pGridPaging', 'pMathJax']) - -gridModifier.configure_column('code', width=10) -gridModifier.set_rownumbering(True) - -gridModifier.append_filter(('code', 'contains', T('bla bla...'))) - -gridModifier.configure_filters(plugins=['pFormToolTip'], width=300) -gridModifier.configure_gridWithFilter(selectorTitle= 'MyFoo') - -# -# Example of buffered rendering -# In that case the full store is loaded but only few row are rendered in the grid -# -# plugin = dict(ptype='bufferedrenderer', -# leadingBufferZone=0, -# trailingBufferZone=0) -# gridModifier.append_plugins(plugin) - -#------------------------------------------------------------------------------- -# -# STORE CONFIGURATiON -# -#------------------------------------------------------------------------------- -# example of buffered store -# -# storeModifier = dbui.StoreModifier('categories') -# storeModifier.set_buffered() - diff --git a/models/ui_collaborations.py b/models/ui_collaborations.py deleted file mode 100644 index 5e93a64e403d80c36b1cc9780fd2aa3bb49e8eea..0000000000000000000000000000000000000000 --- a/models/ui_collaborations.py +++ /dev/null @@ -1,27 +0,0 @@ -# -*- coding: utf-8 -*- -""" Collaborations widgets - -""" -#------------------------------------------------------------------------------- -# -# FIELDS CONFIGURATiON -# -#------------------------------------------------------------------------------- - -#------------------------------------------------------------------------------- -# -# FORM CONFIGURATiON -# -#------------------------------------------------------------------------------- - -#------------------------------------------------------------------------------- -# -# GRID CONFIGURATiON -# -#------------------------------------------------------------------------------- - -#------------------------------------------------------------------------------- -# -# STORE CONFIGURATiON -# -#------------------------------------------------------------------------------- diff --git a/models/ui_countries.py b/models/ui_countries.py deleted file mode 100644 index 752dd7922adc5cc451a9c1d31b901987bb24ad43..0000000000000000000000000000000000000000 --- a/models/ui_countries.py +++ /dev/null @@ -1,27 +0,0 @@ -# -*- coding: utf-8 -*- -""" countries widgets - -""" -#------------------------------------------------------------------------------- -# -# FIELDS CONFIGURATiON -# -#------------------------------------------------------------------------------- - -#------------------------------------------------------------------------------- -# -# FORM CONFIGURATiON -# -#------------------------------------------------------------------------------- - -#------------------------------------------------------------------------------- -# -# GRID CONFIGURATiON -# -#------------------------------------------------------------------------------- - -#------------------------------------------------------------------------------- -# -# STORE CONFIGURATiON -# -#------------------------------------------------------------------------------- diff --git a/models/ui_harvesters.py b/models/ui_harvesters.py deleted file mode 100644 index 2fe2e541c28f9af4130c8c1213cc94858932aabb..0000000000000000000000000000000000000000 --- a/models/ui_harvesters.py +++ /dev/null @@ -1,37 +0,0 @@ -# -*- coding: utf-8 -*- -""" harvesters widgets - -""" -#------------------------------------------------------------------------------- -# -# FIELDS CONFIGURATiON -# -#------------------------------------------------------------------------------- - -#------------------------------------------------------------------------------- -# -# FORM CONFIGURATiON -# -#------------------------------------------------------------------------------- - -#------------------------------------------------------------------------------- -# -# GRID CONFIGURATiON -# -#------------------------------------------------------------------------------- -gridModifier = dbui.GridModifier('harvesters') - -gridModifier.append_filter(('id_teams', '==', T('is equal to'))) -# gridModifier.append_filter(('id_projects', '==', T('is equal to'))) -gridModifier.append_filter(('controller', 'contains', T('contains'))) -# gridModifier.append_filter(('host', 'contains', T('contains'))) -# gridModifier.append_filter(('id_categories', '==', T('is equal to'))) - -gridModifier.configure_filters(plugins=['pFormToolTip'], width=300) -gridModifier.configure_gridWithFilter(selectorTitle='Filter') - -#------------------------------------------------------------------------------- -# -# STORE CONFIGURATiON -# -#------------------------------------------------------------------------------- diff --git a/models/ui_new_fields.py b/models/ui_new_fields.py deleted file mode 100644 index e5dd12c569f4dd1d2a6e715db7d12fda243d4565..0000000000000000000000000000000000000000 --- a/models/ui_new_fields.py +++ /dev/null @@ -1,39 +0,0 @@ -# -*- coding: utf-8 -*- -""" new_fields widgets - -""" -#------------------------------------------------------------------------------- -# -# FIELDS CONFIGURATiON -# -#------------------------------------------------------------------------------- -fieldsModifier = dbui.FieldsModifier('new_fields') -fieldsModifier.configure_field('dictionary', headers=['foo', 'faa'], - modifyKeys=True, - value={"string": "test", - "boolean": False, - "integer": 0, - "float": 0.01, - "date": "not implemented"}) - -fieldsModifier.configure_field('python_code', xtype='xaceeditorfield') - -#------------------------------------------------------------------------------- -# -# FORM CONFIGURATiON -# -#------------------------------------------------------------------------------- -formModifier = dbui.FormModifier('new_fields') -formModifier.configure(width=400) - -#------------------------------------------------------------------------------- -# -# GRID CONFIGURATiON -# -#------------------------------------------------------------------------------- - -#------------------------------------------------------------------------------- -# -# STORE CONFIGURATiON -# -#------------------------------------------------------------------------------- diff --git a/models/ui_projects.py b/models/ui_projects.py deleted file mode 100644 index a85411f2a7f626a331002003d729c5e1b5b712a4..0000000000000000000000000000000000000000 --- a/models/ui_projects.py +++ /dev/null @@ -1,27 +0,0 @@ -# -*- coding: utf-8 -*- -""" projects widgets - -""" -#------------------------------------------------------------------------------- -# -# FIELDS CONFIGURATiON -# -#------------------------------------------------------------------------------- - -#------------------------------------------------------------------------------- -# -# FORM CONFIGURATiON -# -#------------------------------------------------------------------------------- - -#------------------------------------------------------------------------------- -# -# GRID CONFIGURATiON -# -#------------------------------------------------------------------------------- - -#------------------------------------------------------------------------------- -# -# STORE CONFIGURATiON -# -#------------------------------------------------------------------------------- diff --git a/models/ui_publications.py b/models/ui_publications.py deleted file mode 100644 index dd26beabae1a18ec3a082afe278b43098932f64b..0000000000000000000000000000000000000000 --- a/models/ui_publications.py +++ /dev/null @@ -1,152 +0,0 @@ -# -*- coding: utf-8 -*- -""" publications widgets - -""" -#------------------------------------------------------------------------------- -# -# FIELDS CONFIGURATiON -# -#------------------------------------------------------------------------------- -fieldsModifier = dbui.FieldsModifier('publications') -fieldsModifier.configure_field('conference_start', format='Y-m-d') -fieldsModifier.configure_field('conference_end', format='Y-m-d') -fieldsModifier.configure_field('year', maxValue=datetime.now().year) - -fieldsModifier.merge_fields('first_page', - 'last_page', - fieldLabel=T('Pages')) - -fieldsModifier.merge_fields('conference_start', - 'conference_end', - fieldLabel=T('Dates')) - -#------------------------------------------------------------------------------- -# -# FORM CONFIGURATiON -# -#------------------------------------------------------------------------------- -formModifier = dbui.FormModifier('publications') -formModifier.merge_fields('title', - 'authors', - 'id_collaborations', - 'id_publishers', - 'year', - 'doi', - 'volume', - 'first_page', - 'e_print', - title=T('General')) - -formModifier.merge_fields('conference_title', - 'conference_url', - 'conference_start', - 'conference_town', - 'id_countries', - 'conference_speaker', - title=T('Conference')) - -formModifier.merge_fields('report_numbers', - 'id_reports', - title=T('Report')) - -formModifier.merge_fields('authors_cppm', - 'id_teams', - 'id_projects', - 'id_categories', - title='CPPM') - -# -# Organise fieldSet within a TabPanel embedded in the publication form -# -formModifier.set_mapper(dbui.map_tabpanel) - -# -# Polish the look and feel of the publication form -# NOTE: the width/height define the size of the window -# when running the form from the grid. The defaults defines the height -# of the fieldSet allowing a fine tuning of the form layout. -# -formModifier.configure(buttonAlign='right', - labelWidth=100, - labelAlign='right', - width=400) - -#------------------------------------------------------------------------------- -# -# GRID CONFIGURATiON -# -#------------------------------------------------------------------------------- -tpl = ['<b>{PublicationsTitle}</b><br>', - '{PublicationsAuthors}', - '<tpl if="PublicationsId_collaborations > 1">, {CollaborationsCollaboration}</tpl>', - '<tpl if="PublicationsDoi">, {PublicationsDoi}</tpl>', - '<tpl if="PublicationsId_publishers > 1">, {PublishersAbbreviation}', - '<tpl if="PublicationsVolume"> {PublicationsVolume}</tpl>', - '<tpl if="PublicationsYear"> ({PublicationsYear}) </tpl>', - '<tpl if="PublicationsFirst_page"> {PublicationsFirst_page}</tpl>', - '<tpl if="PublicationsLast_page">-{PublicationsLast_page}</tpl>', - '</tpl>', - '<tpl if="PublicationsConference_title"><br><br>{PublicationsConference_title}', - '<tpl if="PublicationsConference_town"><br>{PublicationsConference_town}</tpl>', - '<tpl if="CountriesCountry">, {CountriesCountry}</tpl>', - '<tpl if="PublicationsConference_start">, {PublicationsConference_start}</tpl>', - '<tpl if="PublicationsConference_end"> - {PublicationsConference_end}</tpl>', - '<tpl if="PublicationsConference_url"><br>{PublicationsConference_url}</tpl>', - '<br>%s: {PublicationsConference_speaker}' % T('Speaker'), - '</tpl>', - '<tpl if="PublicationsReport_numbers"><br><br>', - '<tpl if="PublicationsId_reports > 1">{ReportsType}, </tpl>', - '{PublicationsReport_numbers}', - '</tpl>' - ] - -gridModifier = dbui.GridModifier('publications') -gridModifier.configure(plugins=['pMathJax', - {'ptype': 'pGridRowEditorConfirmDelete', - 'resetFields': ['PublicationsId_projects']} - ]) -gridModifier.merge_columns('title', - 'authors', - 'id_collaborations', - 'id_publishers', - 'doi', - 'volume', - 'first_page', - 'last_page', - 'conference_title', - 'conference_url', - 'conference_start', - 'conference_end', - 'conference_town', - 'id_countries', - 'conference_speaker', - 'report_numbers', - 'id_reports', - autohide=True, - header=T('Publication'), - position=0, - tpl=tpl, - width=700) - -gridModifier.hide_columns('authors_cppm', - 'e_print') - -# -# Setup a filter panel for the publication grid -# - -gridModifier.append_filter(('year', '==', T('select publication for a given year'))) -gridModifier.append_filter(('id_teams', '==', T('select publications for a given team'))) -gridModifier.append_filter(('id_projects', '==', T('select publications for a given project'))) -gridModifier.append_filter(('id_categories', '==', T('select publications with a given category code'))) -gridModifier.append_filter(('authors_cppm', 'contains', T('select publications for a given CPPM author'))) -gridModifier.append_filter(('countries.country', 'contains', T('blab blab ....'))) - -gridModifier.configure_filters(plugins=['pFormToolTip'], - width=300) - -#------------------------------------------------------------------------------- -# -# STORE CONFIGURATiON -# -#------------------------------------------------------------------------------- diff --git a/models/ui_publishers.py b/models/ui_publishers.py deleted file mode 100644 index 58feb91fd8e382b1e258913c1e6e51b394999752..0000000000000000000000000000000000000000 --- a/models/ui_publishers.py +++ /dev/null @@ -1,27 +0,0 @@ -# -*- coding: utf-8 -*- -""" publishers widgets - -""" -#------------------------------------------------------------------------------- -# -# FIELDS CONFIGURATiON -# -#------------------------------------------------------------------------------- - -#------------------------------------------------------------------------------- -# -# FORM CONFIGURATiON -# -#------------------------------------------------------------------------------- - -#------------------------------------------------------------------------------- -# -# GRID CONFIGURATiON -# -#------------------------------------------------------------------------------- - -#------------------------------------------------------------------------------- -# -# STORE CONFIGURATiON -# -#------------------------------------------------------------------------------- diff --git a/models/ui_reports.py b/models/ui_reports.py deleted file mode 100644 index 7bb18b96b82a95c82b8ab246d324941afb63a73a..0000000000000000000000000000000000000000 --- a/models/ui_reports.py +++ /dev/null @@ -1,27 +0,0 @@ -# -*- coding: utf-8 -*- -""" reports widgets - -""" -#------------------------------------------------------------------------------- -# -# FIELDS CONFIGURATiON -# -#------------------------------------------------------------------------------- - -#------------------------------------------------------------------------------- -# -# FORM CONFIGURATiON -# -#------------------------------------------------------------------------------- - -#------------------------------------------------------------------------------- -# -# GRID CONFIGURATiON -# -#------------------------------------------------------------------------------- - -#------------------------------------------------------------------------------- -# -# STORE CONFIGURATiON -# -#------------------------------------------------------------------------------- diff --git a/models/ui_teams.py b/models/ui_teams.py deleted file mode 100644 index 2a7d7b5c71249a66c424dea2a8ac08d146fa3e36..0000000000000000000000000000000000000000 --- a/models/ui_teams.py +++ /dev/null @@ -1,29 +0,0 @@ -# -*- coding: utf-8 -*- -""" teams widgets - -""" -#------------------------------------------------------------------------------- -# -# FIELDS CONFIGURATiON -# -#------------------------------------------------------------------------------- - -#------------------------------------------------------------------------------- -# -# FORM CONFIGURATiON -# -#------------------------------------------------------------------------------- - -#------------------------------------------------------------------------------- -# -# GRID CONFIGURATiON -# -#------------------------------------------------------------------------------- - -#------------------------------------------------------------------------------- -# -# STORE CONFIGURATiON -# -#------------------------------------------------------------------------------- -storeModifier = dbui.StoreModifier('teams') -storeModifier.orderby(~db.teams.team) diff --git a/models/vt_foo1.py b/models/vt_foo1.py deleted file mode 100644 index 2ab05e8fa0f8f4312e94b744f1eb53bcee18ca38..0000000000000000000000000000000000000000 --- a/models/vt_foo1.py +++ /dev/null @@ -1,44 +0,0 @@ -# -*- coding: utf-8 -*- -""" virtual table foo1 and associated widgets - - -""" -#------------------------------------------------------------------------------- -# -# DEFINITION -# -#------------------------------------------------------------------------------- -tp_string = "tool tip for the string" - -virtdb.define_table("foo1", - Field('my_string', 'string', default="hello", comment=tp_string), - Field('my_int', 'integer', requires=IS_INT_IN_RANGE(0, 100)), - Field('my_date', 'date'), - Field('my_bool', 'boolean', default=True), - Field('my_format', default='html', requires=IS_IN_SET(['html', 'tex', 'pdf'])), - Field('my_axis'), - Field('my_granularity')) - -#------------------------------------------------------------------------------- -# -# FIELDS CONFIGURATiON -# -#------------------------------------------------------------------------------- -fieldsModifier = dbui.FieldsModifier('foo1') -fieldsModifier.configure_field('my_axis', emptyText='axis') -fieldsModifier.configure_field('my_granularity', emptyText='granularity') -fieldsModifier.merge_fields('my_axis', - 'my_granularity', - fieldLabel=T('My_Merge')) - -#------------------------------------------------------------------------------- -# -# FORM CONFIGURATiON -# -#------------------------------------------------------------------------------- - -#------------------------------------------------------------------------------- -# -# GRID CONFIGURATiON -# -#------------------------------------------------------------------------------- diff --git a/models/vt_harvester_selector.py b/models/vt_harvester_selector.py deleted file mode 100644 index 6bee7bb112058f2c3d3e68814ae55c34fd655b1e..0000000000000000000000000000000000000000 --- a/models/vt_harvester_selector.py +++ /dev/null @@ -1,55 +0,0 @@ -# -*- coding: utf-8 -*- -""" XXX table and associated widgets - - -""" -#------------------------------------------------------------------------------- -# -# DEFINITION -# -#------------------------------------------------------------------------------- -virtdb.define_table("harvester_selector", - Field('year_start', 'integer', default=year), - Field('year_end', 'integer'), - Field('id_projects', db.projects, label='Project'), - Field('id_teams', db.teams, label='Team'), - Field('controller', 'string', label='Harvest')) - -virtdb.harvester_selector.id_projects.requires = \ -IS_IN_DB(db, 'projects.project') - -virtdb.harvester_selector.id_teams.requires = \ -IS_IN_DB(db, 'teams.team') - -#------------------------------------------------------------------------------- -# -# FIELDS CONFIGURATiON -# -#------------------------------------------------------------------------------- -fieldsModifier = dbui.FieldsModifier('harvester_selector') -fieldsModifier.configure_field('year_start', flex=1) -fieldsModifier.configure_field('year_end', flex=1) -fieldsModifier.merge_fields('year_start', - 'year_end', - fieldLabel=T('Year')) - -#------------------------------------------------------------------------------- -# -# FORM CONFIGURATiON -# -#------------------------------------------------------------------------------- -formModifier = dbui.FormModifier('harvester_selector') -formModifier.link_comboboxes(master=virtdb.harvester_selector.id_projects, - slave=virtdb.harvester_selector.controller, - masterHasSlaveData='harvesters') - -formModifier = dbui.FormModifier('harvester_selector') -formModifier.link_comboboxes(master=virtdb.harvester_selector.id_projects, - slave=virtdb.harvester_selector.id_teams, - masterHasSlaveData='harvesters') - -#------------------------------------------------------------------------------- -# -# GRID CONFIGURATiON -# -#------------------------------------------------------------------------------- diff --git a/models/vt_report4.py b/models/vt_report4.py deleted file mode 100644 index 5ebd3aa987aa5e13775bb06c48a0abc67859be75..0000000000000000000000000000000000000000 --- a/models/vt_report4.py +++ /dev/null @@ -1,33 +0,0 @@ -# -*- coding: utf-8 -*- -""" report4 - -test the different grouping features of a grid - -""" -#------------------------------------------------------------------------------- -# -# DEFINITION -# -#------------------------------------------------------------------------------- -virtdb.define_table("report4", - Field('grouping', 'boolean', default=False), - Field('grouping_summary', 'boolean', default=False), - Field('summary', 'boolean', default=False)) - -#------------------------------------------------------------------------------- -# -# FIELDS CONFIGURATiON -# -#------------------------------------------------------------------------------- - -#------------------------------------------------------------------------------- -# -# FORM CONFIGURATiON -# -#------------------------------------------------------------------------------- - -#------------------------------------------------------------------------------- -# -# GRID CONFIGURATiON -# -#------------------------------------------------------------------------------- diff --git a/models/widgets_viewport.py b/models/widgets_viewport.py deleted file mode 100644 index 0484e52561cf0af371c3bd75d673c15d891252ed..0000000000000000000000000000000000000000 --- a/models/widgets_viewport.py +++ /dev/null @@ -1,148 +0,0 @@ -# -*- coding: utf-8 -*- -""" widgets viewport - -""" -# helper function translating a tablename into the grid configuration -to_grid = lambda tablename: dbui.to_gridPanel(db[tablename]) - -# short cuts -Node = dbui.Node -Panel = dbui.Panel -PanelWithUrlSelector = dbui.to_panelWithUrlSelector -Window = dbui.Window - -#------------------------------------------------------------------------------- -# -# APPLICATION (preference, CAS, ...) -# -#------------------------------------------------------------------------------- -appNode = Node(T('Application')) -# appNode.add_child(T('preferences'), to_grid('preferences')) - -prefLeaf = Window(closable=True, - items=[{'dbtable': 'preferences', - 'sourceConfig': {'my_date': {'type': 'date'}}, - 'xtype': 'xpreferences', - 'width': 300}], - layout='fit', - title=T("Preferences"), - modal=True) - -appNode.add_child(T('preferences'), prefLeaf) - -#------------------------------------------------------------------------------- -# -# FORM -# -#------------------------------------------------------------------------------- -formNode = Node(T('Forms')) -for tablename in ('categories', 'harvesters', 'publications', 'new_fields'): - - leaf = Window(closable=True, - items=[dbui.to_formPanel(db[tablename])], - layout='fit', - title="Add %s ..." % tablename, - modal=True) - - formNode.add_child(T(tablename), leaf) - -#------------------------------------------------------------------------------- -# -# GRID -# -#------------------------------------------------------------------------------- -gridNode = Node(T('Tables')) -gridNode.add_children(db.tables, func=to_grid) - -#------------------------------------------------------------------------------- -# -# HELP -# -#------------------------------------------------------------------------------- -plugin = PluginManager("dbui").dbui - -loader = dict(autoLoad=True, - renderer='html', - scripts=False, - url=URL('static', plugin.app_about.replace("static/", ""))) - -aboutLeaf = \ - Panel(loader=loader, plugins=['pPanelLoaderException'], autoScroll=True) - -loader = dict(autoLoad=True, - renderer='html', - scripts=True, - url=URL('plugin_dbui', 'documentations_table')) - -docLeafTable = \ - Panel(loader=loader, plugins=['pPanelLoaderException'], autoScroll=True) - -loader = dict(autoLoad=True, - renderer='html', - scripts=True, - url=URL('plugin_dbui', 'documentations_list')) - -docLeafList = \ - Panel(loader=loader, plugins=['pPanelLoaderException'], autoScroll=True) - -loader = dict(autoLoad=True, - renderer='html', - scripts=True, - url=URL('plugin_dbui', 'versions')) - -versionLeaf = Panel(loader=loader, plugins=['pPanelLoaderException']) - -helpNode = Node(T('Help')) -helpNode.add_child(T('about'), aboutLeaf) -helpNode.add_child(T('documentations (table)'), docLeafTable) -helpNode.add_child(T('documentations (list)'), docLeafList) -helpNode.add_child(T('versions'), versionLeaf) - -#------------------------------------------------------------------------------- -# -# REPORT -# -#------------------------------------------------------------------------------- -leaf_1 = Panel(html="salut ma poule") - -leaf_2 = PanelWithUrlSelector(virtdb.foo1, - baseUrl=URL('reports', 'report_2'), - baseParams={'hello': 3}, - extField='my_format', - plugins=['pMathJax']) - -leaf_3 = PanelWithUrlSelector(virtdb.harvester_selector, - baseUrl=URL('reports', 'report_3'), - selectorRegion='east', - selectorTitle='Select a project') - -leaf_4 = PanelWithUrlSelector(virtdb.report4, - 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) - -#------------------------------------------------------------------------------- -# -# VIEWPORT -# -#------------------------------------------------------------------------------- -nodes = [helpNode, - appNode, - formNode, - gridNode, - reportNode] - -viewportModifier = dbui.ViewportModifier() -viewportModifier.configure(tabTitleTpl="{1}") - -viewportModifier.add_node(*nodes) - -# viewportModifier.configure(plugins=['pViewportLogin'], logged=True); - -viewportModifier.default_node(T('Tables'), T('categories')) -# viewportModifier.default_node(T('Tables'), T('new_fields')) -# viewportModifier.default_node(T('Tables'), T('publications')) diff --git a/modules/callbacks.py b/modules/callbacks.py index b53df9827375397d5688e6f9e55d7b884861a690..5b5164a359c5bf61ddfa089663f3d96188cd0a9d 100644 --- a/modules/callbacks.py +++ b/modules/callbacks.py @@ -9,7 +9,7 @@ def country_delete(s): """Inhibit delete. """ - countries = current.globalenv['db']["countries"] + countries = current.globalenv["db"]["countries"] countries[CALLBACK_ERRORS] = "Can't delete a country." return True @@ -18,7 +18,7 @@ def country_insert(f): """Inhibit insert. """ - countries = current.globalenv['db']["countries"] + countries = current.globalenv["db"]["countries"] countries[CALLBACK_ERRORS] = "Can't insert a new Country." return True @@ -27,6 +27,6 @@ def country_update(s, f): """Inhibit update. """ - countries = current.globalenv['db']["countries"] + countries = current.globalenv["db"]["countries"] countries[CALLBACK_ERRORS] = "Cant't update a Country." return True diff --git a/modules/model_core.py b/modules/model_core.py new file mode 100644 index 0000000000000000000000000000000000000000..43ea61b3e345aaa4c41a29a8a00edefadfc61abe --- /dev/null +++ b/modules/model_core.py @@ -0,0 +1,475 @@ +# -*- coding: utf-8 -*- +"""Definitions of the core tables + +""" +from callbacks import (country_delete, + country_insert, + country_update) + +from gluon import current +from gluon.validators import (IS_EMPTY_OR, + IS_FLOAT_IN_RANGE, + IS_IN_DB, + IS_INT_IN_RANGE, + IS_IN_SET, + IS_URL) + +from plugin_dbui import (CLEAN_SPACES, + INHIBIT_DELETE_UNDEF, + INHIBIT_UPDATE_UNDEF, + UNDEF_ID) + +from pydal import Field + +CONTROLLERS = [ + "articles", + "notes", + "preprints", + "proceedings", + "reports", + "talks", + "theses"] + + +class Core(object): + """Create the ``publications`` table and its foreign tables. + + """ + @staticmethod + def define_tables(db, T): + """define the core tables + + Args: + db (pyDAL.DAL): database connection + T (gluon.languages.translator): language translator + + """ + # foreign tables + Core.categories(db, T) + Core.collaborations(db, T) + Core.countries(db, T) + Core.new_fields(db, T) + Core.preferences(db, T) + Core.projects(db, T) + Core.publishers(db, T) + Core.reports(db, T) + Core.teams(db, T) + + # main tables + Core.harvesters(db, T) + Core.publications(db, T) + + @staticmethod + def categories(db, T): + """categories table + + Args: + db (pyDAl.DAL): database connection + T (gluon.languages.translator): language translator + + Returns: + pyDAL.Table + + """ + tp_code = "The code has to be in upper case." + + table = db.define_table( + "categories", + + Field("code", + "string", + comment=tp_code, + notnull=True, + unique=True), + + Field("definition", "text", notnull=True), + migrate="categories.table") + + table._before_delete.append(INHIBIT_DELETE_UNDEF) + table._before_update.append(INHIBIT_UPDATE_UNDEF) + + return table + + @staticmethod + def collaborations(db, T): + """collaborations table + + Args: + db (pyDAl.DAL): database connection + T (gluon.languages.translator): language translator + + Returns: + pyDAL.Table + + """ + table = db.define_table( + "collaborations", + Field("collaboration", "string", notnull=True, unique=True), + migrate="collaborations.table") + + return table + + @staticmethod + def countries(db, T): + """countries table + + Args: + db (pyDAl.DAL): database connection + T (gluon.languages.translator): language translator + + Returns: + pyDAL.Table + + """ + table = db.define_table( + "countries", + Field("country", "string", notnull=True, unique=True), + Field("abbreviation", "string", notnull=True), + migrate="countries.table") + + table._before_delete.append(country_delete) + table._before_insert.append(country_insert) + table._before_update.append(country_update) + + return table + + @staticmethod + def harvesters(db, T): + """harvesters table + + Args: + db (pyDAl.DAL): database connection + T (gluon.languages.translator): language translator + + Returns: + pyDAL.Table + + """ + tp_category = "Publication category associated to the record." + + tp_collections = \ + "List of collections separated by commma: LHCb Papers, LHCb Talks" + + tp_controller = \ + "The name of the web2py controller running the search: " \ + "articles, proceedings,..." + + tp_host = "Address of the invenio store where the search is performed." + + tp_ratio = "Parameter for fuzzy string search." + + table = db.define_table( + "harvesters", + + Field("id_teams", + "reference teams", + default=UNDEF_ID, + label="Team"), + + Field("id_projects", + "reference projects", + default=UNDEF_ID, + label="Project"), + + Field("controller", + "string", + default="articles", + notnull=True, + comment=tp_controller), + + Field("host", + "string", + notnull=True, + default="cdsweb.cern.ch", + label="Store", + comment=tp_host), + + Field("collections", "string", comment=tp_collections), + + Field("ratio", + "double", + notnull=True, + default=1.0, + comment=tp_ratio), + + Field("id_categories", + "reference categories", + default=1, + label="Category", + comment=tp_category), + + migrate="harvesters.table") + + table.controller.requires = IS_IN_SET(CONTROLLERS) + + # TEST THE DIFFERENT SYNTAX DEFINING FOREIGN KEY + table.id_categories.requires = \ + IS_IN_DB(db, "categories.id", "categories.code") + + table.id_projects.requires = IS_IN_DB(db, "projects.project") + + # table.id_teams.requires = \ + # IS_IN_DB(db, "teams.id", "teams.team") + + table.ratio.requires = IS_FLOAT_IN_RANGE(0., 1.0) + + return table + + @staticmethod + def new_fields(db, T): + """new_fields table + + Args: + db (pyDAl.DAL): database connection + T (gluon.languages.translator): language translator + + Returns: + pyDAL.Table + + """ + table = db.define_table( + "new_fields", + Field("string", "string"), + Field("list_string", "list:string"), + Field("dictionary", "json"), + Field("python_code", "text"), + migrate="new_fields.table") + + # NOTE: if we remove the json validator its seem to work ? + table.dictionary.requires = None + + return table + + @staticmethod + def preferences(db, T): + """preferences table + + Args: + db (pyDAl.DAL): database connection + T (gluon.languages.translator): language translator + + Returns: + pyDAL.Table + + """ + table = db.define_table( + "preferences", + Field("property", "string", length=255, notnull=True, unique=True), + Field("value", "json", length=255), + Field("definition", "text", notnull=True), + migrate="preferences.table") + + # NOTE: if we remove the json validator its seem to work ? + table.value.requires = None + + return table + + @staticmethod + def projects(db, T): + """projects table + + Args: + db (pyDAl.DAL): database connection + T (gluon.languages.translator): language translator + + Returns: + pyDAL.Table + + """ + table = db.define_table( + "projects", + Field("project", "string", notnull=True, unique=True), + migrate="projects.table") + + return table + + @staticmethod + def publications(db, T): + """publications table + + Args: + db (pyDAl.DAL): database connection + T (gluon.languages.translator): language translator + + Returns: + pyDAL.Table + + """ + tp_authors = \ + "List of authors separated by commma: J. Doe, P.-Y. Smith " \ + "For large collaboration the first author followed by et al.: " \ + "J. Doe et al.""" + + tp_authors_cppm = \ + "List of authors separated by comma: P.-Y. Doe, J. Smith" + + tp_first = "first page" + tp_last = "last_page" + + tp_report_numbers = \ + "List of report identifier separated by comma: " \ + "LHCb-PROC-2008-04, arXiv:0906.1516 " + + tp_speaker = "The name of the speaker: P.-Y. Smith" + + year = current.request.now.year + + table = db.define_table( + "publications", + Field("title", "text", notnull=True), + Field("authors", "string", notnull=True, comment=tp_authors), + + Field("id_collaborations", + "reference collaborations", + default=UNDEF_ID, + label="Collaboration"), + + Field("id_publishers", + "reference publishers", + default=UNDEF_ID, + label="Publisher"), + + Field("year", + "integer", + notnull=True, + default=year, + requires=IS_INT_IN_RANGE(1900, year+1)), + + Field("doi", "string"), + + Field("volume", + "integer", + requires=IS_EMPTY_OR(IS_INT_IN_RANGE(1, None))), + + Field("first_page", + "integer", + requires=IS_EMPTY_OR(IS_INT_IN_RANGE(1, None)), + comment=tp_first), + + Field("last_page", + "integer", + requires=IS_EMPTY_OR(IS_INT_IN_RANGE(1, None)), + comment=tp_last), + + Field("e_print", "string", requires=IS_EMPTY_OR(IS_URL())), + Field("conference_title", "text", label="Title"), + + Field("conference_url", + "string", + label="url", + requires=IS_EMPTY_OR(IS_URL())), + + Field("conference_start", "date", label="Start date"), + Field("conference_end", "date", label="End date"), + Field("conference_town", "string", label="Town"), + + Field("id_countries", + "reference countries", + default=UNDEF_ID, + label="Country"), + + Field("conference_speaker", + "string", + label="Speaker", + comment=tp_speaker), + + Field("report_numbers", + "string", + comment=tp_report_numbers), + + Field("id_reports", + "reference reports", + default=UNDEF_ID, + label="Report type"), + + Field("authors_cppm", + "text", + notnull=True, + comment=tp_authors_cppm), + + Field("id_teams", + "reference teams", + default=UNDEF_ID, + label="Team"), + + Field("id_projects", + "reference projects", + default=UNDEF_ID, + label="Projects"), + + Field("id_categories", + "reference categories", + default=UNDEF_ID, + label="AERES"), + + migrate="publications.table") + + # use different techniques to define foreign field + table.id_categories.requires = \ + IS_IN_DB(db, "categories.id", "categories.code") + + table.id_publishers.requires = IS_IN_DB(db, "publishers.abbreviation") + + table.id_projects.requires = IS_IN_DB(db, db.projects.project) + + return table + + @staticmethod + def publishers(db, T): + """publishers table + + Args: + db (pyDAl.DAL): database connection + T (gluon.languages.translator): language translator + + Returns: + pyDAL.Table + + """ + table = db.define_table( + "publishers", + Field("publisher", "string", notnull=True, unique=True), + Field("abbreviation", "string", notnull=True), + migrate="publishers.table") + + return table + + @staticmethod + def reports(db, T): + """reports table + + Args: + db (pyDAl.DAL): database connection + T (gluon.languages.translator): language translator + + Returns: + pyDAL.Table + + """ + table = db.define_table( + "reports", + Field("type", "string", notnull=True, unique=True), + migrate="reports.table") + + return table + + @staticmethod + def teams(db, T): + """teams table + + Args: + db (pyDAl.DAL): database connection + T (gluon.languages.translator): language translator + + Returns: + pyDAL.Table + + """ + table = db.define_table( + "teams", + Field("team", "string", notnull=True, unique=True), + migrate="teams.table") + + table.team.filter_in = CLEAN_SPACES + + return table diff --git a/modules/model_selector.py b/modules/model_selector.py new file mode 100644 index 0000000000000000000000000000000000000000..7d0b880dea7e4fc775be3ec46628cdd45d24bbcc --- /dev/null +++ b/modules/model_selector.py @@ -0,0 +1,120 @@ +# -*- coding: utf-8 -*- +"""Definitions of the selector(s) + +""" +from gluon import current + +from gluon.validators import (IS_IN_DB, + IS_INT_IN_RANGE, + IS_IN_SET) + +from pydal import Field + + +class Selector(object): + """Create virtual tables used to generate selector interfaces. + + """ + + @staticmethod + def define_tables(virtdb, db, T): + """Define tables use for selectors. + + Args: + virtdb (pyDAL.DAL): connection to the virtual database + db (pyDAL.DAL): database connection + T (gluon.languages.translator): language translator + + """ + Selector.foo1(virtdb, db, T) + Selector.harvester_selector(virtdb, db, T) + Selector.report4(virtdb, db, T) + + @staticmethod + def foo1(virtdb, db, T): + """foo1 selector. + + Note: + selector table are store in a virtual database. + + Args: + virtdb (pyDAL.DAL): connection to the virtual database + db (pyDAL.DAL): connection to the database of the application + T (gluon.languages.translator): language translator + + Returns: + pyDAL.Table + + """ + tp_string = "tool tip for the string" + + table = virtdb.define_table( + "foo1", + Field("my_string", "string", default="hello", comment=tp_string), + Field("my_int", "integer", requires=IS_INT_IN_RANGE(0, 100)), + Field("my_date", "date"), + Field("my_bool", "boolean", default=True), + + Field("my_format", + default="html", + requires=IS_IN_SET(["html", "tex", "pdf"])), + + Field("my_axis"), + Field("my_granularity")) + + return table + + @staticmethod + def harvester_selector(virtdb, db, T): + """harvester selector. + + Note: + selector table are store in a virtual database. + + Args: + virtdb (pyDAL.DAL): connection to the virtual database + db (pyDAL.DAL): connection to the database of the application + T (gluon.languages.translator): language translator + + Returns: + pyDAL.Table + + """ + year = current.request.now.year + + table = virtdb.define_table( + "harvester_selector", + Field("year_start", "integer", default=year), + Field("year_end", "integer"), + Field("id_projects", db.projects, label="Project"), + Field("id_teams", db.teams, label="Team"), + Field("controller", "string", label="Harvest")) + + table.id_projects.requires = IS_IN_DB(db, "projects.project") + table.id_teams.requires = IS_IN_DB(db, "teams.team") + + return table + + @staticmethod + def report4(virtdb, db, T): + """report4 selector. + + Note: + selector table are store in a virtual database. + + Args: + virtdb (pyDAL.DAL): connection to the virtual database + db (pyDAL.DAL): connection to the database of the application + T (gluon.languages.translator): language translator + + Returns: + pyDAL.Table + + """ + table = virtdb.define_table( + "report4", + Field("grouping", "boolean", default=False), + Field("grouping_summary", "boolean", default=False), + Field("summary", "boolean", default=False)) + + return table diff --git a/modules/plugin_dbui/callback.py b/modules/plugin_dbui/callback.py index faa400c0254c36b00737e947da3ca1fbd9f7c62b..b0f97004a6402195654ff592cb36fd928fcf1da1 100644 --- a/modules/plugin_dbui/callback.py +++ b/modules/plugin_dbui/callback.py @@ -27,7 +27,7 @@ def INHIBIT_DELETE_UNDEF(setrows): return False # inhibit the delete - if field.name == 'id' and setrows.query.second == UNDEF_ID: + if field.name == "id" and setrows.query.second == UNDEF_ID: field._table[CALLBACK_ERRORS] = \ T("You can not delete the row containing the undefined value.") return True @@ -58,7 +58,7 @@ def INHIBIT_UPDATE_UNDEF(setrows, values): return False # inhibit the delete - if field.name == 'id' and int(setrows.query.second) == UNDEF_ID: + if field.name == "id" and int(setrows.query.second) == UNDEF_ID: field._table[CALLBACK_ERRORS] = \ T("You can not update the row containing the undefined value.") return True diff --git a/modules/plugin_dbui/constant.py b/modules/plugin_dbui/constant.py index 02d986a95d00fe1520532c52ebf878d32e3ccff7..2d07438b5290c4a60f030f0232063447fb048265 100644 --- a/modules/plugin_dbui/constant.py +++ b/modules/plugin_dbui/constant.py @@ -3,6 +3,6 @@ """ INLINE_ALERT = '<script>Ext.Msg.alert("%s", "%s");</script>' -UNDEF = 'undefined' +UNDEF = "undefined" UNDEF_ID = 1 -UNKNOWN = '???' \ No newline at end of file +UNKNOWN = "???" diff --git a/modules/plugin_dbui/converter.py b/modules/plugin_dbui/converter.py index 1d3673474b8ac85ee0af3905a6a7fe5e84de05a6..4c5f518f8ad20034ef00d0feb85b13bcc50430dc 100644 --- a/modules/plugin_dbui/converter.py +++ b/modules/plugin_dbui/converter.py @@ -4,7 +4,7 @@ import gluon.dal import re - +from datetime import date, datetime, time from extjs import (Base, CheckBox, ComboBox, @@ -29,6 +29,7 @@ from extjs import (Base, Model, PanelWithUrlSelector) from gluon import current +from gluon.languages import lazyT from gluon.storage import Storage from gluon.tools import PluginManager from gridmodifier import ROW_NUMBERING @@ -43,36 +44,52 @@ from mapper import map_default # Associated gluon.dal.field type with an ExtJS widget # The dictionary contains configuration parameters of the Ext JS widget -FTYPE_TO_XTYPE = {'boolean': (CheckBox, {}), - 'date': (FieldDate, {'format': 'Y-m-d'}), - 'datetime': (FieldDate, {'format': 'Y-m-d H:i:s'}), - 'double': (FieldNumber, {'decimalPrecision': 2, - 'decimalSeparator': '.'}), - 'id': (FieldText, {}), - 'integer': (FieldNumber, {}), - 'json': (FieldDict, {}), - 'list:string': (FieldList, {}), - 'list:integer': (FieldTextArea, {}), - 'password': (FieldText, {'inputType': 'password'}), - 'reference': (ComboBox, {}), - 'string': (FieldText, {}), - 'text': (FieldTextArea, {}), - 'time': (FieldTime, {}), - 'upload': (FieldText, {'inputType': 'file'})} +FTYPE_TO_XTYPE = {"boolean": (CheckBox, {}), + "date": (FieldDate, {"format": "Y-m-d"}), + "datetime": (FieldDate, {"format": "Y-m-d H:i:s"}), + "double": (FieldNumber, {"decimalPrecision": 2, + "decimalSeparator": "."}), + "id": (FieldText, {}), + "integer": (FieldNumber, {}), + "json": (FieldDict, {}), + "list:string": (FieldList, {}), + "list:integer": (FieldTextArea, {}), + "password": (FieldText, {"inputType": "password"}), + "reference": (ComboBox, {}), + "string": (FieldText, {}), + "text": (FieldTextArea, {}), + "time": (FieldTime, {}), + "upload": (FieldText, {"inputType": "file"})} # constant defining a ExtJS store -ROOT = 'records' -NOPAGE = '' -PAGE = 'page' -SUCCESS = 'success' -TOTAL = 'count' - -# list of type which can be converted as a JSON string -JSON_TYPES = (bool, dict, float, int, list, long, str, tuple) +ROOT = "records" +NOPAGE = "" +PAGE = "page" +SUCCESS = "success" +TOTAL = "count" + +# types which can be converted as a JSON string using plugin_dbui.JSONEncoder: +# +# from plugin_dbui import JSONEncode +# s = json.dumps(foo, cls=JSONEncoder) +# +JSON_TYPES = (bool, + date, + datetime, + dict, + float, + int, + lazyT, + list, + long, + str, + time, + tuple, + unicode) # xtype defining linked comboBoxes -X_LINKED_COMBO = ['xcomboboxmaster', 'xcomboboxslave'] +X_LINKED_COMBO = ["xcomboboxmaster", "xcomboboxslave"] def _to_field(field, linkedcombo=True, **kwargs): @@ -129,7 +146,7 @@ def _to_field(field, linkedcombo=True, **kwargs): elif is_set_field(field): cfg = dict(name=f_name, store=get_set_field(field), - xtype='combobox') + xtype="combobox") # other types of fields else: @@ -149,7 +166,7 @@ def _to_field(field, linkedcombo=True, **kwargs): cfg["value"] = default # the checkBox is rendered initially checked - if field.type == 'boolean': + if field.type == "boolean": cfg["checked"] = True # not null @@ -174,7 +191,7 @@ def _to_field(field, linkedcombo=True, **kwargs): hidden = field.name == "id" hidden = hidden or ((not field.readable) and (not field.writable)) - modifier_forms = PluginManager('dbui').dbui.modifier_forms + modifier_forms = PluginManager("dbui").dbui.modifier_forms if tablename in modifier_forms: if fieldname in modifier_forms[tablename].hidden_fields: hidden = True @@ -186,15 +203,15 @@ def _to_field(field, linkedcombo=True, **kwargs): # configuration options set by the field_modifers # at this stage parameter for LinkedComboBox are applied - modifier_fields = PluginManager('dbui').dbui.modifier_fields + modifier_fields = PluginManager("dbui").dbui.modifier_fields if tablename in modifier_fields: if fieldname in modifier_fields[tablename].extjs_fields: extjs = modifier_fields[tablename].extjs_fields[fieldname] process = True - if not linkedcombo and 'xtype' in extjs: - process = not (extjs['xtype'] in X_LINKED_COMBO) + if not linkedcombo and "xtype" in extjs: + process = not (extjs["xtype"] in X_LINKED_COMBO) if process: cfg.update(extjs) @@ -244,7 +261,7 @@ def to_field(field, composite=True, linkedcombo=True, **kwargs): """ table = field.table tablename = field.tablename - modifier_fields = PluginManager('dbui').dbui.modifier_fields + modifier_fields = PluginManager("dbui").dbui.modifier_fields # do we have composite field for this table ? composite_fields = None @@ -309,7 +326,7 @@ def to_fields(table): """ li = [] tablename = table._tablename - modifier_forms = PluginManager('dbui').dbui.modifier_forms + modifier_forms = PluginManager("dbui").dbui.modifier_forms # do we have FieldSets field_sets, modifier_form = None, None @@ -336,7 +353,7 @@ def to_fields(table): cfg.append_items(fieldname) continue - if fieldname == 'id': + if fieldname == "id": id_is_used = True field = table[fieldname] @@ -350,7 +367,7 @@ def to_fields(table): # append the field Id the last field set if not id_is_used: - li[-1].append_items(to_field(table['id'])) + li[-1].append_items(to_field(table["id"])) # Table with Ext.form.Fieldcontainers and/or Ext.form.Fields else: @@ -395,10 +412,10 @@ def to_formPanel(table, **kwargs): # add a store for non dummy database if table._db._uri: - cfg['store'] = get_store_id(tablename) + cfg["store"] = get_store_id(tablename) # configuration options from form modifier - modifier_forms = PluginManager('dbui').dbui.modifier_forms + modifier_forms = PluginManager("dbui").dbui.modifier_forms if tablename in modifier_forms: cfg.update(modifier_forms[tablename].extjs) @@ -459,7 +476,7 @@ def to_gridColumn(field, **kwargs): cfg["xtype"] = "jsoncolumn" # Hide fields request by the grid modifiers - modifier_grids = PluginManager('dbui').dbui.modifier_grids + modifier_grids = PluginManager("dbui").dbui.modifier_grids if tablename in modifier_grids: if fieldname in modifier_grids[tablename].hidden_columns: cfg["hidden"] = True @@ -495,7 +512,7 @@ def to_gridColumnModel(table): row_numbering = ROW_NUMBERING # get modifier requirements - modifier_grids = PluginManager('dbui').dbui.modifier_grids + modifier_grids = PluginManager("dbui").dbui.modifier_grids if tablename in modifier_grids: delete_columns = modifier_grids[tablename].delete_columns template_columns = modifier_grids[tablename].template_columns @@ -554,7 +571,7 @@ def to_gridFilter(table, **kwargs): T = current.T tablename = table._tablename - modifier_grids = PluginManager('dbui').dbui.modifier_grids + modifier_grids = PluginManager("dbui").dbui.modifier_grids if tablename not in modifier_grids: return {} @@ -565,7 +582,7 @@ def to_gridFilter(table, **kwargs): if not grid_filters.filters: return {} - di = GridFilter(title=T('Filter %s' % tablename)) + di = GridFilter(title=T("Filter %s" % tablename)) for i in range(len(grid_filters.filters)): @@ -577,19 +594,19 @@ def to_gridFilter(table, **kwargs): ktablename = m.group(1) kfieldname = m.group(2) field = table._db[ktablename][kfieldname] - name = '[%s.%s]' % (ktablename, kfieldname) + name = "[%s.%s]" % (ktablename, kfieldname) # basic filter rule else: field = table[fieldname] - name = '[%s.%s]' % (tablename, fieldname) + name = "[%s.%s]" % (tablename, fieldname) # .................................................................... # # standalone configuration of the widget from the keyword arguments # extjs_filter = grid_filters.extjs_filters[i] - if 'xtype' in extjs_filter: + if "xtype" in extjs_filter: cfg = Storage(extjs_filter) # .................................................................... @@ -603,28 +620,28 @@ def to_gridFilter(table, **kwargs): cfg = to_field(field, composite=False, linkedcombo=False) # remove field constraints making no sense for a filter - if 'allowBlank' in cfg: + if "allowBlank" in cfg: cfg["allowBlank"] = True - if 'readOnly' in cfg: - cfg['readOnly'] = False + if "readOnly" in cfg: + cfg["readOnly"] = False - if 'value' in cfg: - del cfg['value'] + if "value" in cfg: + del cfg["value"] # Remove the star in the label for required field - if field.notnull and 'afterLabelTextTpl' in cfg: - del cfg['afterLabelTextTpl'] + if field.notnull and "afterLabelTextTpl" in cfg: + del cfg["afterLabelTextTpl"] # replace all textarea by textfield - if cfg['xtype'] == 'xtextarea': - cfg['xtype'] = 'xtextfield' + if cfg["xtype"] == "xtextarea": + cfg["xtype"] = "xtextfield" # combobox can be reset individually # not valid for combobox associated to a set of data - if cfg['xtype'] == 'xcombobox' and not is_set_field(field): - cfg['emptyText'] = T('select...') - cfg['xtype'] = 'xcomboboxuserreset' + if cfg["xtype"] == "xcombobox" and not is_set_field(field): + cfg["emptyText"] = T("select...") + cfg["xtype"] = "xcomboboxuserreset" # field configuration option cfg.update(grid_filters.extjs_filters[i]) @@ -633,16 +650,16 @@ def to_gridFilter(table, **kwargs): # # add dedicated information to customise the filter # - cfg['filterComment'] = comment - cfg['filterOperator'] = operator - cfg['filterType'] = field.type + cfg["filterComment"] = comment + cfg["filterOperator"] = operator + cfg["filterType"] = field.type # prepare the name for the where close [table.field] - cfg['name'] = name + cfg["name"] = name # copy the comment to be used as a tool tip # when the plugin pFormToolTip is used - cfg['tipText'] = comment + cfg["tipText"] = comment di.append_items(cfg) @@ -678,14 +695,14 @@ def to_gridPanel(table, **kwargs): cfg = GridPanel(columns=to_gridColumnModel(table), frame=False, - viewConfig={'forceFit': True}) + viewConfig={"forceFit": True}) # add a store for non dummy database if table._db._uri: - cfg['store'] = get_store_id(tablename) + cfg["store"] = get_store_id(tablename) # configuration option from the grid modifier - modifier_grids = PluginManager('dbui').dbui.modifier_grids + modifier_grids = PluginManager("dbui").dbui.modifier_grids if tablename in modifier_grids: cfg.update(modifier_grids[tablename].extjs) @@ -742,7 +759,7 @@ def to_jsonstore(table, **kwargs): # rather than issuing the request at the end of the current event # handler run. Such behaviour is required by the linked ComboBox # - base_params = {'tableName': tablename, 'dbFields': []} + base_params = {"tableName": tablename, "dbFields": []} cfg = DirectStore(asynchronousLoad=False, autoLoad=False, @@ -756,7 +773,7 @@ def to_jsonstore(table, **kwargs): fieldname = field.name # the field of the table - base_params['dbFields'].append([tablename, fieldname]) + base_params["dbFields"].append([tablename, fieldname]) # NOTE: the store contains all fields of the table. # It also contains the pointing values for foreign keys @@ -765,33 +782,33 @@ def to_jsonstore(table, **kwargs): # in form and in grid. if is_foreign_field(field): - if 'where' not in base_params: - base_params['where'] = [] + if "where" not in base_params: + base_params["where"] = [] # the foreign field k_tablename, k_fieldname, k_key = get_foreign_field(field) - base_params['dbFields'].append([k_tablename, k_fieldname]) + base_params["dbFields"].append([k_tablename, k_fieldname]) # define the where close nt = (tablename, fieldname, k_tablename, k_key) - base_params['where'].append("[%s.%s] == [%s.%s]" % nt) + base_params["where"].append("[%s.%s] == [%s.%s]" % nt) # configuration options from the store modifier # namely the order by directive - modifier_stores = PluginManager('dbui').dbui.modifier_stores + modifier_stores = PluginManager("dbui").dbui.modifier_stores if tablename in modifier_stores: - base_params['orderby'] = [] + base_params["orderby"] = [] for el in modifier_stores[tablename].orderby: if isinstance(el, gluon.dal.Field): - field, direction = el, 'ASC' + field, direction = el, "ASC" elif isinstance(el, gluon.dal.Expression): - field, direction = el.first, 'DESC' + field, direction = el.first, "DESC" li = [field.tablename, field.name, direction] - base_params['orderby'].append(li) + base_params["orderby"].append(li) # Ext JS configuration option from the modifier cfg.update(modifier_stores[tablename].extjs) @@ -823,7 +840,7 @@ def to_model(table): # the field of the table # encode field name - field_cfg = {'name': encode_field(tablename, fieldname)} + field_cfg = {"name": encode_field(tablename, fieldname)} # encode the default value # the default value can be a callable. @@ -833,9 +850,9 @@ def to_model(table): # can be JSONifyied. default = field.default if default is not None and isinstance(default, JSON_TYPES): - field_cfg['defaultValue'] = default + field_cfg["defaultValue"] = default - cfg['fields'].append(field_cfg) + cfg["fields"].append(field_cfg) # NOTE: the store contains all fields of the table. # It also contains the pointing values for foreign keys @@ -847,23 +864,23 @@ def to_model(table): k_tablename, k_fieldname, k_key = get_foreign_field(field) # encode the field name - k_field_cfg = {'name': encode_field(k_tablename, k_fieldname)} - cfg['fields'].append(k_field_cfg) + k_field_cfg = {"name": encode_field(k_tablename, k_fieldname)} + cfg["fields"].append(k_field_cfg) # retrieve the default value for the foreign key if field.default: row = db(db[k_tablename].id == field.default).select().first() if row: - k_field_cfg['defaultValue'] = row[k_fieldname] + k_field_cfg["defaultValue"] = row[k_fieldname] return cfg def to_panelWithUrlSelector( table, - selectorLayout=dict(align='stretch', type='vbox', vertical=True), - selectorPlugins=['pFormToolTip'], - selectorTitle='Select', + selectorLayout=dict(align="stretch", type="vbox", vertical=True), + selectorPlugins=["pFormToolTip"], + selectorTitle="Select", **kwargs): """Build the configuration of the :class:`.PanelWithUrlSelector` widget. @@ -893,8 +910,8 @@ def to_panelWithUrlSelector( BaseException: when the argument ``baseUrl`` is not defined. """ - if 'baseUrl' not in kwargs: - raise BaseException('The keyword argument basseUrl is missing.') + if "baseUrl" not in kwargs: + raise BaseException("The keyword argument basseUrl is missing.") # build the list of fields the table fields = to_fields(table) @@ -926,7 +943,7 @@ def to_treeNodes(): """ cfg = [] - modifier_viewports = PluginManager('dbui').dbui.modifier_viewports + modifier_viewports = PluginManager("dbui").dbui.modifier_viewports if modifier_viewports: nav_nodes = modifier_viewports.nodes @@ -952,13 +969,13 @@ def to_viewport(**kwargs): """ cfg = {} - modifier_viewports = PluginManager('dbui').dbui.modifier_viewports + modifier_viewports = PluginManager("dbui").dbui.modifier_viewports if modifier_viewports: cfg = modifier_viewports.extjs if modifier_viewports.default: - cfg['defaultTabPath'] = modifier_viewports.default + cfg["defaultTabPath"] = modifier_viewports.default # configuration options from the keyword arguments cfg.update(kwargs) diff --git a/modules/plugin_dbui/dbsvc.py b/modules/plugin_dbui/dbsvc.py index d1f6a2725fea43fd86a009e3bf9abd5949a1cdb6..4dfeda9da3bc79d499443646ee3882378ec036dd 100644 --- a/modules/plugin_dbui/dbsvc.py +++ b/modules/plugin_dbui/dbsvc.py @@ -31,12 +31,12 @@ TO_MANY_RECORDS = "To many records !!!" # transform bracket "[table1.field1]" as "db.table1.field1" -REG_BRACKET = re.compile(r'\[(\w+).(\w+)\]') +REG_BRACKET = re.compile(r"\[(\w+).(\w+)\]") # True when the string match the pattern: # "db.publications.id_tablename == db.tablename.id # The first group contains "tablename" -REG_IS_JOIN = re.compile(r'db\.\w+\.id_(?P<ref>\w+) == db\.(?P=ref)\.id') +REG_IS_JOIN = re.compile(r"db\.\w+\.id_(?P<ref>\w+) == db\.(?P=ref)\.id") class DbSvcException(BaseException): @@ -84,7 +84,7 @@ class DbSvc(BaseSvc): Each method return the dictionary:: - {success: True, records:[{blabla}, ..], msg: 'blalbla'} + {success: True, records:[{blabla}, ..], msg: "blalbla"} * The keyword ``success`` is always present. It is mandatory for @@ -99,7 +99,7 @@ class DbSvc(BaseSvc): """ - def _check_request(self, arg, keywords=('tableName', 'records')): + def _check_request(self, arg, keywords=("tableName", "records")): """Check that the transaction data dictionary ``arg`` contains the ``keywords``. @@ -122,7 +122,7 @@ class DbSvc(BaseSvc): if kword not in arg: raise DbSvcException(KEYWORD_MISSING % kword) - table = arg['tableName'] + table = arg["tableName"] self._is_table_in_db(table) def _encode_query(self, li): @@ -170,14 +170,14 @@ class DbSvc(BaseSvc): for el in li: # transform bracket "[table1.field1]" as "db.table1.field1" - s = REG_BRACKET.sub(r'db.\1.\2', el) + s = REG_BRACKET.sub(r"db.\1.\2", el) - # transform contains 'm%' as .contains("m%') + # transform contains "m%" as .contains("m%") # protection against EOL, TAB, ... - for op in ['belongs', 'contains', 'like', 'startswith']: + for op in ["belongs", "contains", "like", "startswith"]: if op in s: - s = s.replace('\n', '').replace('\t', '') - s = re.sub(r" +(%s) +(.+)" % op, r'.\1(\2)', s) + s = s.replace("\n", "").replace("\t", "") + s = re.sub(r" +(%s) +(.+)" % op, r".\1(\2)", s) # separate join from filter queries if REG_IS_JOIN.match(s): @@ -190,13 +190,13 @@ class DbSvc(BaseSvc): query = ("(%s) & (%s)" % (query, s) if query else s) if query: - query = eval(query, {}, {"db": current.globalenv['db']}) + query = eval(query, {}, {"db": current.globalenv["db"]}) if join: - join = eval(join, {}, {"db": current.globalenv['db']}) + join = eval(join, {}, {"db": current.globalenv["db"]}) if fltr: - fltr = eval(fltr, {}, {"db": current.globalenv['db']}) + fltr = eval(fltr, {}, {"db": current.globalenv["db"]}) return (query, join, fltr) @@ -214,7 +214,7 @@ class DbSvc(BaseSvc): The key are encoded as ``Table1Field1``. """ - db = current.globalenv['db'] + db = current.globalenv["db"] record = {} for field in db[table].fields: @@ -241,7 +241,7 @@ class DbSvc(BaseSvc): bool: """ - return field in current.globalenv['db'][table].fields + return field in current.globalenv["db"][table].fields def _is_fields_values_valid(self, table, fields): """Check each ``field`` value against its ``validators``. @@ -260,7 +260,7 @@ class DbSvc(BaseSvc): """ di = {} - db = current.globalenv['db'] + db = current.globalenv["db"] for (field, val) in fields.items(): @@ -290,7 +290,7 @@ class DbSvc(BaseSvc): The method works with regular and alias tables. """ - db = current.globalenv['db'] + db = current.globalenv["db"] tablenames = [table._tablename for table in get_all_tables(db)] if tablename not in tablenames: @@ -327,7 +327,7 @@ class DbSvc(BaseSvc): """ data = Storage(errors=[], records=[]) - table = arg['tableName'] + table = arg["tableName"] for record in arg[ROOT]: fields = {} @@ -339,7 +339,7 @@ class DbSvc(BaseSvc): for table_field in record: tablename, fieldname = decode_field(table_field) if tablename == table: - fields[fieldname.encode('utf8')] = record[table_field] + fields[fieldname.encode("utf8")] = record[table_field] data.errors.append(None) data.records.append(fields) @@ -347,7 +347,7 @@ class DbSvc(BaseSvc): # Validate field contents di = self._is_fields_values_valid(table, fields) if di: - table_id = encode_field(table, 'id') + table_id = encode_field(table, "id") record[table_id] = "" data.records[-1] = record data.errors[-1] = di @@ -361,7 +361,7 @@ class DbSvc(BaseSvc): tablename (str): name of the database table """ - db = current.globalenv['db'] + db = current.globalenv["db"] return db(db[tablename].id > 0).count() def create(self, arg): @@ -402,8 +402,8 @@ class DbSvc(BaseSvc): return {SUCCESS: False, "errors": di, ROOT: data.records[i]} # insert new records - ids, tablename, records = [], arg['tableName'], [] - table = current.globalenv['db'][tablename] + ids, tablename, records = [], arg["tableName"], [] + table = current.globalenv["db"][tablename] for fields in data.records: @@ -429,9 +429,9 @@ class DbSvc(BaseSvc): ids.append(str(rec_id)) records.append(record) - txt = ', '.join(ids) + txt = ", ".join(ids) self.dbg("End DbSvc.create.", RECORDS_INSERTED % txt) - return {SUCCESS: True, 'msg': RECORDS_INSERTED % txt, ROOT: records} + return {SUCCESS: True, "msg": RECORDS_INSERTED % txt, ROOT: records} def destroy(self, arg): """Delete existing records defined by the transaction dictionary *arg*. @@ -466,9 +466,9 @@ class DbSvc(BaseSvc): self._check_request(arg) - ids, tablename, records = [], arg['tableName'], [] - table_id = encode_field(tablename, 'id') - db = current.globalenv['db'] + ids, tablename, records = [], arg["tableName"], [] + table_id = encode_field(tablename, "id") + db = current.globalenv["db"] table = db[tablename] # Abort the transaction is at least one record does not exists @@ -505,7 +505,7 @@ class DbSvc(BaseSvc): ids.append(str(rec_id)) records.append({table_id: rec_id}) - txt = ', '.join(ids) + txt = ", ".join(ids) self.dbg("End DbSvc.destroy") return {"success": True, "msg": RECORDS_DELETED % txt, ROOT: records} @@ -520,7 +520,7 @@ class DbSvc(BaseSvc): * The *optional* key ``where`` is a list of string to build the inner join when handling foreign key:: - ['db.table1.field1 == db.table2.id', ... ] + ["db.table1.field1 == db.table2.id", ... ] The syntax follows the web2py convention ``db.table1.field1 == db.table2.id``. @@ -551,24 +551,24 @@ class DbSvc(BaseSvc): """ self.dbg("Start DbSvc.read") - self._check_request(arg, ('tableName', 'dbFields')) - db = current.globalenv['db'] + self._check_request(arg, ("tableName", "dbFields")) + db = current.globalenv["db"] # build the list of SQLField object fields = [] - for table, field in arg['dbFields']: + for table, field in arg["dbFields"]: if not self._is_field_in_table(table, field): raise DbSvcException(FIELD_NOT_IN_DB % (table, field)) fields.append(db[table][field]) # build the inner join and filter conditions - query, q_join, q_filter = '', '', '' - if 'where' in arg: - query, q_join, q_filter = self._encode_query(arg['where']) + query, q_join, q_filter = "", "", "" + if "where" in arg: + query, q_join, q_filter = self._encode_query(arg["where"]) # Count the total numbers of records in the table # or in the set when filter conditions are applied - tablename = arg['tableName'] + tablename = arg["tableName"] if not q_filter: nrecords = db(db[tablename]).count() @@ -582,40 +582,40 @@ class DbSvc(BaseSvc): # handle paging options kwargs = {} - if 'page' in arg: - start = int(arg['start']) - limit = int(arg['limit']) - kwargs['limitby'] = (start, start + limit) - - # handle the orderby directive ['[table1, field2, dir]', ....] - if 'orderby' in arg: - kwargs['orderby'] = [] - for tablename, fieldname, direction in arg['orderby']: + if "page" in arg: + start = int(arg["start"]) + limit = int(arg["limit"]) + kwargs["limitby"] = (start, start + limit) + + # handle the orderby directive ["[table1, field2, dir]", ....] + if "orderby" in arg: + kwargs["orderby"] = [] + for tablename, fieldname, direction in arg["orderby"]: el = db[tablename][fieldname] - if direction == 'DESC': + if direction == "DESC": el = ~el - kwargs['orderby'].append(el) + kwargs["orderby"].append(el) - if 'sort' in arg: - if 'oderby' not in kwargs: - kwargs['orderby'] = [] + if "sort" in arg: + if "oderby" not in kwargs: + kwargs["orderby"] = [] - for el in arg['sort']: - if 'property' in el: - tablename, fieldname = decode_field(el['property']) + for el in arg["sort"]: + if "property" in el: + tablename, fieldname = decode_field(el["property"]) field = db[tablename][fieldname] - if 'direction' in el and el['direction'] == "DESC": + if "direction" in el and el["direction"] == "DESC": field = ~field - kwargs['orderby'].append(field) + kwargs["orderby"].append(field) # interrogate the database and serialize the records as a list: # [{TableField: value, }, {...}, ...] rows = db(query).select(*fields, **kwargs) li = rows_serializer(rows) - self.dbg('End DbSvc.read', li) + self.dbg("End DbSvc.read", li) return {SUCCESS: True, TOTAL: nrecords, ROOT: li} def update(self, arg): @@ -665,15 +665,15 @@ class DbSvc(BaseSvc): return {SUCCESS: False, "errors": di, ROOT: data.records[i]} # update records - ids, tablename, records = [], arg['tableName'], [] - db = current.globalenv['db'] + ids, tablename, records = [], arg["tableName"], [] + db = current.globalenv["db"] table = db[tablename] for fields in data.records: # the client send modified fields only # update the database accordingly - rec_id = fields['id'] + rec_id = fields["id"] try: rep = db(table.id == rec_id).update(**fields) @@ -696,6 +696,6 @@ class DbSvc(BaseSvc): ids.append(str(rec_id)) records.append(record) - txt = ', '.join(ids) + txt = ", ".join(ids) self.dbg("End DbSvc.update.") return {SUCCESS: True, "msg": RECORDS_UPDATED % txt, ROOT: records} diff --git a/modules/plugin_dbui/directsvc.py b/modules/plugin_dbui/directsvc.py index 94823866c78a0ac84752f5e1d2604be8dd7a5436..695bbc1caed4e7757162b2e00ddc61d2dd635678 100644 --- a/modules/plugin_dbui/directsvc.py +++ b/modules/plugin_dbui/directsvc.py @@ -34,7 +34,7 @@ class JSONEncoder(json.JSONEncoder): sort_keys=False, indent=None, separators=None, - encoding='utf-8', + encoding="utf-8", default=None, use_decimal=False): """ @@ -50,7 +50,7 @@ class JSONEncoder(json.JSONEncoder): self.sort_keys = sort_keys self.use_decimal = use_decimal if isinstance(indent, (int, long)): - indent = ' ' * indent + indent = " " * indent self.indent = indent if separators is not None: self.item_separator, self.key_separator = separators @@ -178,7 +178,7 @@ class DirectSvc(BaseSvc): the input function """ - # a procedure is registered as 'action.method' + # a procedure is registered as "action.method" # The action is equal to Dbui for a function # and to the name of the class for a method action = DBUI diff --git a/modules/plugin_dbui/extjs.py b/modules/plugin_dbui/extjs.py index 8a3569ef5ccc99e9efbc645a05ec2d23e174cef2..f33defa9d69eac3476159769bfc71bea298064b7 100644 --- a/modules/plugin_dbui/extjs.py +++ b/modules/plugin_dbui/extjs.py @@ -30,18 +30,18 @@ class Base(Storage): def __init__(self, **kwargs): - if 'xtype' in kwargs: + if "xtype" in kwargs: raise ExtJSException(MSG_XTYPE) - self['xtype'] = self.xtype + self["xtype"] = self.xtype - items = kwargs.pop('items', None) + items = kwargs.pop("items", None) if items: - self._append('items', items) + self._append("items", items) - plugins = kwargs.pop('plugins', None) + plugins = kwargs.pop("plugins", None) if plugins: - self._append('plugins', plugins) + self._append("plugins", plugins) self.update(kwargs) @@ -60,7 +60,7 @@ class Base(Storage): *args: variable list of widget configuration. """ - self._append('items', args) + self._append("items", args) def append_plugins(self, *args): """Append an plugin configurations to the @@ -70,7 +70,7 @@ class Base(Storage): *args: variable list of plugin configuration. """ - self._append('plugins', args) + self._append("plugins", args) class ArrayStore(Base): @@ -79,7 +79,7 @@ class ArrayStore(Base): .. include:: ../../../docs/api/extjs_links.txt """ - xtype = 'arraystore' + xtype = "arraystore" class CheckBox(Base): @@ -88,7 +88,7 @@ class CheckBox(Base): .. include:: ../../../docs/api/extjs_links.txt """ - xtype = 'checkbox' + xtype = "checkbox" class ComboBox(Base): @@ -97,7 +97,7 @@ class ComboBox(Base): .. include:: ../../../docs/api/extjs_links.txt """ - xtype = 'xcombobox' + xtype = "xcombobox" class DirectStore(Base): @@ -106,7 +106,7 @@ class DirectStore(Base): .. include:: ../../../docs/api/extjs_links.txt """ - xtype = 'xdirectstore' + xtype = "xdirectstore" class Field(Base): @@ -115,7 +115,7 @@ class Field(Base): .. include:: ../../../docs/api/extjs_links.txt """ - xtype = 'field' + xtype = "field" class FieldAceEditor(Base): @@ -124,7 +124,7 @@ class FieldAceEditor(Base): .. include:: ../../../docs/api/extjs_links.txt """ - xtype = 'xaceeditorfield' + xtype = "xaceeditorfield" class FieldContainer(Base): @@ -133,7 +133,7 @@ class FieldContainer(Base): .. include:: ../../../docs/api/extjs_links.txt """ - xtype = 'fieldcontainer' + xtype = "fieldcontainer" class FieldDate(Base): @@ -142,7 +142,7 @@ class FieldDate(Base): .. include:: ../../../docs/api/extjs_links.txt """ - xtype = 'datefield' + xtype = "datefield" class FieldDict(Base): @@ -151,7 +151,7 @@ class FieldDict(Base): .. include:: ../../../docs/api/extjs_links.txt """ - xtype = 'xdictfield' + xtype = "xdictfield" class FieldList(Base): @@ -160,7 +160,7 @@ class FieldList(Base): .. include:: ../../../docs/api/extjs_links.txt """ - xtype = 'xlistfield' + xtype = "xlistfield" class FieldNumber(Base): @@ -169,7 +169,7 @@ class FieldNumber(Base): .. include:: ../../../docs/api/extjs_links.txt """ - xtype = 'numberfield' + xtype = "numberfield" class FieldSet(Base): @@ -178,7 +178,7 @@ class FieldSet(Base): .. include:: ../../../docs/api/extjs_links.txt """ - xtype = 'fieldset' + xtype = "fieldset" class FieldText(Base): @@ -190,10 +190,10 @@ class FieldText(Base): .. include:: ../../../docs/api/extjs_links.txt """ - xtype = 'textfield' + xtype = "textfield" def __init__(self, **kwargs): - self['plugins'] = ['pRegExp'] + self["plugins"] = ["pRegExp"] Base.__init__(self, **kwargs) @@ -206,10 +206,10 @@ class FieldTextArea(Base): .. include:: ../../../docs/api/extjs_links.txt """ - xtype = 'textarea' + xtype = "textarea" def __init__(self, **kwargs): - self['plugins'] = ['pRegExp'] + self["plugins"] = ["pRegExp"] Base.__init__(self, **kwargs) @@ -219,7 +219,7 @@ class FieldTime(Base): .. include:: ../../../docs/api/extjs_links.txt """ - xtype = 'timefield' + xtype = "timefield" class FormPanel(Base): @@ -228,7 +228,7 @@ class FormPanel(Base): .. include:: ../../../docs/api/extjs_links.txt """ - xtype = 'xform' + xtype = "xform" class GridColumn(dict): @@ -256,7 +256,7 @@ class GridFilter(Base): .. include:: ../../../docs/api/extjs_links.txt """ - xtype = 'xgridfilter' + xtype = "xgridfilter" class GridPanel(Base): @@ -265,7 +265,7 @@ class GridPanel(Base): .. include:: ../../../docs/api/extjs_links.txt """ - xtype = 'xgrid' + xtype = "xgrid" class GridRowNumberer(Base): @@ -274,7 +274,7 @@ class GridRowNumberer(Base): .. include:: ../../../docs/api/extjs_links.txt """ - xtype = 'rownumberer' + xtype = "rownumberer" class GridTemplateColumn(Base): @@ -283,7 +283,7 @@ class GridTemplateColumn(Base): .. include:: ../../../docs/api/extjs_links.txt """ - xtype = 'templatecolumn' + xtype = "templatecolumn" class GridWithFilter(Base): @@ -292,7 +292,7 @@ class GridWithFilter(Base): .. include:: ../../../docs/api/extjs_links.txt """ - xtype = 'xgridwithfilter' + xtype = "xgridwithfilter" class JsonStore(Base): @@ -301,7 +301,7 @@ class JsonStore(Base): .. include:: ../../../docs/api/extjs_links.txt """ - xtype = 'jsonstore' + xtype = "jsonstore" class Model(dict): @@ -313,7 +313,7 @@ class Model(dict): def __init__(self, **kwargs): dict.__init__(self, **kwargs) - self['extend'] = 'Ext.data.Model' + self["extend"] = "Ext.data.Model" class Panel(Base): @@ -322,7 +322,7 @@ class Panel(Base): .. include:: ../../../docs/api/extjs_links.txt """ - xtype = 'panel' + xtype = "panel" class PanelWithUrlSelector(Base): @@ -331,7 +331,7 @@ class PanelWithUrlSelector(Base): .. include:: ../../../docs/api/extjs_links.txt """ - xtype = 'xpanelwithurlselector' + xtype = "xpanelwithurlselector" class Store(Base): @@ -340,7 +340,7 @@ class Store(Base): .. include:: ../../../docs/api/extjs_links.txt """ - xtype = 'store' + xtype = "store" class TabPanel(Base): @@ -349,7 +349,7 @@ class TabPanel(Base): .. include:: ../../../docs/api/extjs_links.txt """ - xtype = 'tabpanel' + xtype = "tabpanel" class Viewport(Base): @@ -358,7 +358,7 @@ class Viewport(Base): .. include:: ../../../docs/api/extjs_links.txt """ - xtype = 'xviewport' + xtype = "xviewport" class Window(Base): @@ -367,7 +367,7 @@ class Window(Base): .. include:: ../../../docs/api/extjs_links.txt """ - xtype = 'window' + xtype = "window" class XmlStore(Base): @@ -376,4 +376,4 @@ class XmlStore(Base): .. include:: ../../../docs/api/extjs_links.txt """ - xtype = 'xmlstore' + xtype = "xmlstore" diff --git a/modules/plugin_dbui/fieldsmodifier.py b/modules/plugin_dbui/fieldsmodifier.py index fed87c89605a2904f4fdb93e8b9f50a99f19ed90..70e4335e3ff2c86c6108e26e61a4a4f9ee83078f 100644 --- a/modules/plugin_dbui/fieldsmodifier.py +++ b/modules/plugin_dbui/fieldsmodifier.py @@ -5,7 +5,7 @@ from gluon.storage import Storage from modifier import Modifier -MODIFIER_FIELDS = 'modifier_fields' +MODIFIER_FIELDS = "modifier_fields" class FieldsModifier(Modifier): @@ -39,7 +39,7 @@ class FieldsModifier(Modifier): Modifier.__init__(self, MODIFIER_FIELDS, tablename) - if 'extjs_fields' not in self.data: + if "extjs_fields" not in self.data: self.data.extjs_fields = {} self.data.composite_fields = Storage() @@ -88,8 +88,8 @@ class FieldsModifier(Modifier): .. code-block:: javascript combineLabels = True, - defaults = {'flex': 1}, - layout = 'hbox' + defaults = {"flex": 1}, + layout = "hbox" It can be changed via the keyword arguments. @@ -105,8 +105,8 @@ class FieldsModifier(Modifier): """ # configuration of the FieldContainer cfg = dict(combineLabels=True, - defaults={'flex': 1}, - layout='hbox') + defaults={"flex": 1}, + layout="hbox") cfg.update(kwargs) diff --git a/modules/plugin_dbui/filters.py b/modules/plugin_dbui/filters.py index 2c0ad362b2eabe260b924e1113b96b0e2d784941..5cba282c42bffc46c17fe4b6f7f663d233761db7 100644 --- a/modules/plugin_dbui/filters.py +++ b/modules/plugin_dbui/filters.py @@ -4,12 +4,12 @@ import re -REG_COMMA = re.compile(r'( *, *)+$') +REG_COMMA = re.compile(r"( *, *)+$") def CLEAN_COMMA(value): """Remove trailing comma(s). - Search patterns are: ',' or ', ' or ' ,, ' ... + Search patterns are: "," or ", " or " ,, " ... Args: value (object): @@ -22,7 +22,7 @@ def CLEAN_COMMA(value): if not isinstance(value, (str, unicode)): return value - return re.sub(REG_COMMA, '', value) + return re.sub(REG_COMMA, "", value) def CLEAN_SPACES(value): @@ -40,4 +40,4 @@ def CLEAN_SPACES(value): if not isinstance(value, (str, unicode)): return value - return ' '.join(value.strip().split()) + return " ".join(value.strip().split()) diff --git a/modules/plugin_dbui/formmodifier.py b/modules/plugin_dbui/formmodifier.py index 9e2a3afb56be2b8d767897ed04722b010aaa136f..b268da8ec264f20220b206c8dcf618200fa87f35 100644 --- a/modules/plugin_dbui/formmodifier.py +++ b/modules/plugin_dbui/formmodifier.py @@ -14,7 +14,7 @@ from helper import (encode_field, from modifier import Modifier -MODIFIER_FORMS = 'modifier_forms' +MODIFIER_FORMS = "modifier_forms" def configure_forms(db, **extjs): @@ -81,7 +81,7 @@ class FormModifier(Modifier): Modifier.__init__(self, MODIFIER_FORMS, tablename) - if 'field_sets' not in self.data: + if "field_sets" not in self.data: self.data.field_sets = [] self.data.hidden_fields = [] self.data.mapper = None @@ -112,13 +112,13 @@ class FormModifier(Modifier): * The external table must have the master and slave fields * Several slaves can be attached to the same master:: - fieldsModifier = fieldsModifier('mytable') + fieldsModifier = fieldsModifier("mytable") fieldsModifier.link_comboxes(master=virtdb.mytable.myfield1, slave=virtdb.mytable.myfield2, - masterHasSlaveData='anotherTable') + masterHasSlaveData="anotherTable") fieldsModifier.link_comboxes(master=virtdb.mytable.myfield1, slave=virtdb.mytable.myfield3, - masterHasSlaveData='anotherTable') + masterHasSlaveData="anotherTable") * This method modify deeply the field configuration transforming the :class:`.ComboBox` into ``Dbui.form.LinkedComboBox``. @@ -145,19 +145,19 @@ class FormModifier(Modifier): """ # short cuts - myTable = kwargs['master'].tablename - exTable = kwargs['masterHasSlaveData'] + myTable = kwargs["master"].tablename + exTable = kwargs["masterHasSlaveData"] fieldsModifier = FieldsModifier(myTable) configure_field = fieldsModifier.configure_field # Configure the master field - master = kwargs['master'] + master = kwargs["master"] data = fieldsModifier.data.extjs_fields extjs = {} - if 'masterExtJS' in kwargs: - extjs = kwargs['masterExtJS'] + if "masterExtJS" in kwargs: + extjs = kwargs["masterExtJS"] if is_foreign_field(master): kTable, kField, kId = get_foreign_field(master) @@ -170,8 +170,8 @@ class FormModifier(Modifier): # Skip this step if the master is already defined -- multi slaves is_master = master in data and \ - 'xtype' in data[master] and \ - data[master]['xtype'] == 'xcomboboxmaster' + "xtype" in data[master] and \ + data[master]["xtype"] == "xcomboboxmaster" if not is_master: configure_field(master.name, @@ -179,15 +179,15 @@ class FormModifier(Modifier): displayField=encode_field(kTable, kField), valueField=encode_field(exTable, master.name), refStore=get_store_id(exTable), - xtype='xcomboboxmaster', + xtype="xcomboboxmaster", **extjs) # Configure the slave field extjs = {} - if 'slaveExtJS' in kwargs: - extjs = kwargs['slaveExtJS'] + if "slaveExtJS" in kwargs: + extjs = kwargs["slaveExtJS"] - slave = kwargs['slave'] + slave = kwargs["slave"] if is_foreign_field(slave): kTable, kField, kId = get_foreign_field(slave) @@ -201,7 +201,7 @@ class FormModifier(Modifier): masterItemId=master.name, valueField=encode_field(exTable, slave.name), refStore=get_store_id(exTable), - xtype='xcomboboxslave', + xtype="xcomboboxslave", **extjs) def merge_fields(self, *fields, **kwargs): @@ -216,7 +216,7 @@ class FormModifier(Modifier): """ # by default the field occupies all the field set space - extjs = {'defaults': {'anchor': '100%'}} + extjs = {"defaults": {"anchor": "100%"}} extjs.update(kwargs) di = Storage(fields=fields, extjs=extjs) diff --git a/modules/plugin_dbui/gridmodifier.py b/modules/plugin_dbui/gridmodifier.py index a12ab7505a03d469cf664d989a357ec80cc71d84..9fc07612f9a40a72ce49d32836522fd0ea9644ef 100644 --- a/modules/plugin_dbui/gridmodifier.py +++ b/modules/plugin_dbui/gridmodifier.py @@ -9,12 +9,12 @@ from gluon.storage import Storage from modifier import Modifier -MODIFIER_GRIDS = 'modifier_grids' +MODIFIER_GRIDS = "modifier_grids" -MSG_HEADER_MISSING = 'configuration option header is missing in extjs' -MSG_INVALID_KEYWORD = 'invalid keyword %s' -MSG_POSITION_MISSING = 'keyword argument position is missing' -MSG_TPL_MISSING = 'configuration option tpl is missing in extjs' +MSG_HEADER_MISSING = "configuration option header is missing in extjs" +MSG_INVALID_KEYWORD = "invalid keyword %s" +MSG_POSITION_MISSING = "keyword argument position is missing" +MSG_TPL_MISSING = "configuration option tpl is missing in extjs" # default behaviour for the row numbering ROW_NUMBERING = True @@ -94,7 +94,7 @@ class GridModifier(Modifier): self._tablename = tablename - if 'configure_columns' not in self.data: + if "configure_columns" not in self.data: self.data.configure_columns = {} self.data.delete_columns = [] self.data.grid_filters = Storage(filters=[], @@ -125,8 +125,8 @@ class GridModifier(Modifier): located on the right side of the GridPanel. Args: - fltr (tuple): ``('field1', 'operator', 'comment')`` - or ``('table2.field3', 'operator', 'comment')`` + fltr (tuple): ``("field1", "operator", "comment")`` + or ``("table2.field3", "operator", "comment")`` Keyword Args: **kwargs: any configuration options of the :class:`.Field`. @@ -234,9 +234,9 @@ class GridModifier(Modifier): .. code-block:: python tpl = [ - '<b>{PeopleLast_name}</b><br>', - '{PeopleFirst_name}<br>', - '<tpl if={PeoplePhone_number}>{PeoplePhone_number}</tpl>' + "<b>{PeopleLast_name}</b><br>", + "{PeopleFirst_name}<br>", + "<tpl if={PeoplePhone_number}>{PeoplePhone_number}</tpl>" ] autohide (bool): @@ -253,26 +253,26 @@ class GridModifier(Modifier): of the ``Ext.grid.TemplateColumn``. """ - keywords = ['autohide', 'position'] + keywords = ["autohide", "position"] extjs = dict(kwargs) for key in keywords: if key in extjs: del extjs[key] - if 'position' not in kwargs: + if "position" not in kwargs: raise GridModifierException(MSG_POSITION_MISSING) - if 'header' not in kwargs: + if "header" not in kwargs: raise GridModifierException(MSG_HEADER_MISSING) - if 'tpl' not in kwargs: + if "tpl" not in kwargs: raise GridModifierException(MSG_TPL_MISSING) - di = Storage(extjs=extjs, position=kwargs['position']) + di = Storage(extjs=extjs, position=kwargs["position"]) self.data.template_columns.append(di) - if 'autohide' in kwargs and kwargs['autohide']: + if "autohide" in kwargs and kwargs["autohide"]: self.hide_columns(*fields) def set_rownumbering(self, value=True): diff --git a/modules/plugin_dbui/helper.py b/modules/plugin_dbui/helper.py index 6ff10970db58bcd22b5b85333ca208f6abf2aee0..a62e48109fa99d750eb575da28dc846fef580bd2 100644 --- a/modules/plugin_dbui/helper.py +++ b/modules/plugin_dbui/helper.py @@ -83,7 +83,7 @@ def decode_field(field): return tuple(li) -def dummy_row(table, val=''): +def dummy_row(table, val=""): """Create a dummy ``Row`` for the ``table``. The row contains keys for the table and for the reference tables. Each field are set to ``val``. @@ -140,7 +140,7 @@ def encode_field(*args): """ # NOTE: don't use the method title since foo_faa # becomes Foo_Faa and you want Foo_faa. - return ''.join([el[0].upper() + el[1:].lower() for el in args if len(el)]) + return "".join([el[0].upper() + el[1:].lower() for el in args if len(el)]) def encode_validator_errors(error): @@ -236,21 +236,21 @@ def get_field_validators(field): # date and time validators if isinstance(vdt, IS_DATE_IN_RANGE): - fmt = '%Y-%m-%d' - cfg['minValue'] = vdt.minimum.strftime(fmt) - cfg['maxValue'] = vdt.maximum.strftime(fmt) + fmt = "%Y-%m-%d" + cfg["minValue"] = vdt.minimum.strftime(fmt) + cfg["maxValue"] = vdt.maximum.strftime(fmt) elif isinstance(vdt, IS_DATETIME_IN_RANGE): - fmt = '%Y-%m-%d %H:%M:%S' - cfg['minValue'] = vdt.minimum.strftime(fmt) - cfg['maxValue'] = vdt.maximum.strftime(fmt) + fmt = "%Y-%m-%d %H:%M:%S" + cfg["minValue"] = vdt.minimum.strftime(fmt) + cfg["maxValue"] = vdt.maximum.strftime(fmt) # number validators elif isinstance(vdt, (IS_DECIMAL_IN_RANGE, IS_FLOAT_IN_RANGE, IS_INT_IN_RANGE)): - cfg['minValue'] = vdt.minimum - cfg['maxValue'] = vdt.maximum + cfg["minValue"] = vdt.minimum + cfg["maxValue"] = vdt.maximum # string validator elif isinstance(vdt, IS_MATCH): @@ -361,7 +361,7 @@ def get_foreign_field(field): # IS_IN_DB contains only the parent field. # The key for the left join is the id key of the parent table if len(vdt.fieldnames) == 1: - return (vdt.ktable, vdt.fieldnames[0], 'id') + return (vdt.ktable, vdt.fieldnames[0], "id") # IS_IN_DB contains the key for the join and the parent field else: @@ -370,12 +370,12 @@ def get_foreign_field(field): # IS_IN_DB is not use. # The parent key for the left join is the id key of the parent table # the parent field is the first field of the parent table which differs id - i = field.type.index(' ') + i = field.type.index(" ") ktablename = field.type[i:].strip() for kfield in field._db[ktablename]: - if kfield.name != 'id': - return (ktablename, kfield.name, 'id') + if kfield.name != "id": + return (ktablename, kfield.name, "id") raise Exception @@ -420,7 +420,7 @@ def get_language(): # HTML tag for language: primary-dialect # Extract the primary language and ignore dialect - m = re.match('([a-z]+)(\-([a-zA-Z]*))?', lg) + m = re.match("([a-z]+)(\-([a-zA-Z]*))?", lg) if m: return m.group(1) @@ -443,11 +443,11 @@ def get_plugin_path(plugin_name): server_path, client_path = get_reference_paths() # look for the full name of the plugin directory - p_static = os.path.join(server_path, 'static') + p_static = os.path.join(server_path, "static") for el in os.listdir(p_static): if os.path.isdir(os.path.join(p_static, el)): if el.startswith(plugin_name): - return os.path.join(client_path, 'static', el) + return os.path.join(client_path, "static", el) # Nothing found return None @@ -466,7 +466,7 @@ def get_reference_paths(): ``("applications/myapp", "/myapp")`` """ - server_path = os.path.join('applications', current.request.application) + server_path = os.path.join("applications", current.request.application) client_path = os.path.join(os.path.sep, current.request.application) return (server_path, client_path) @@ -533,7 +533,7 @@ def get_script_path(plugin): script = current.request.vars.script if not script.endswith(".js"): - script = '%s.js' % script + script = "%s.js" % script pdir = os.path.join(server_path, plugin.app_script_dir) @@ -583,50 +583,50 @@ def get_versions(): import matplotlib mpl = matplotlib.__version__ except ImportError: - mpl = T('not install') + mpl = T("not install") # pandas library try: import pandas pnd = pandas.__version__ except ImportError: - pnd = T('not install') + pnd = T("not install") # plugin ace - ace = T('not install') - path = opj(server_path, 'static', 'plugin_ace') + ace = T("not install") + path = opj(server_path, "static", "plugin_ace") if ope(path): - ace = T('install') + ace = T("install") # plugin dbui - fn = opj(server_path, 'static', 'plugin_dbui', 'src', 'Dbui.js') - with open(fn, 'rb') as fi: + fn = opj(server_path, "static", "plugin_dbui", "src", "Dbui.js") + with open(fn, "rb") as fi: s = fi.read() - m = re.match("(.+ version: ')([\w._-]*)('.+)", s, re.DOTALL) + m = re.match('(.+ version: ")([\w._-]*)(".+)', s, re.DOTALL) dbui = m.group(2) # plugin Ext JS - extjs = T('not install') - path = opj(server_path, 'static', 'plugin_extjs') + extjs = T("not install") + path = opj(server_path, "static", "plugin_extjs") if ope(path): - fn = opj(path, 'version.properties') + fn = opj(path, "version.properties") - with open(fn, 'rb') as fi: + with open(fn, "rb") as fi: s = fi.read() m = re.search(r"version.release=(\d+(\.\d+)*)", s) if m: extjs = m.group(1) # plugin mathjax - mathjax = T('not install') - path = opj(server_path, 'static', 'plugin_mathjax') + mathjax = T("not install") + path = opj(server_path, "static", "plugin_mathjax") if ope(path): fn = opj(server_path, - 'static', - 'plugin_mathjax', - 'MathJax.js') + "static", + "plugin_mathjax", + "MathJax.js") - with open(fn, 'rb') as fi: + with open(fn, "rb") as fi: s = fi.read() m = re.match(r'.+MathJax.version="(\d+(\.\d+)*)";', s, re.DOTALL) if m: @@ -643,19 +643,19 @@ def get_versions(): with open(opj(path)) as fi: plugins.append(dict(code=plg, version=fi.read())) else: - plugins.append(dict(code=plg, version=T('install'))) + plugins.append(dict(code=plg, version=T("install"))) # web2py - web2py = '' + web2py = "" val = current.request.env.web2py_version if isinstance(val, str): - m = re.match('\d+\.\d+\.\d+', val) + m = re.match("\d+\.\d+\.\d+", val) if m: web2py = m.group() elif isinstance(val, (tuple, list)): li = [str(plg) for plg in val if isinstance(plg, int)] - web2py = '.'.join(li) + web2py = ".".join(li) # version of the application myapp = T("unknown") @@ -669,7 +669,7 @@ def get_versions(): os.chdir(server_path) myapp = subprocess.check_output(["git", "describe", "--tags"]) - myapp = myapp.strip('\n') + myapp = myapp.strip("\n") os.chdir(ref_path) @@ -753,7 +753,7 @@ def is_mathjax(): bool: """ - return get_plugin_path('plugin_mathjax') != None + return get_plugin_path("plugin_mathjax") is not None def is_set_field(field): @@ -812,8 +812,8 @@ def rows_serializer(rows): """ # regular expressions # A field name can only contains [a_zA-Z0-9_] according to web2py - table_field = re.compile(r'[\w_]+\.[\w_]+') - func_table_field = re.compile(r'([A-Z]+)\(([\w_]+)\.([\w_]+)\)') + table_field = re.compile(r"[\w_]+\.[\w_]+") + func_table_field = re.compile(r"([A-Z]+)\(([\w_]+)\.([\w_]+)\)") # Map between column name and TableField mapping = {} diff --git a/modules/plugin_dbui/mapper.py b/modules/plugin_dbui/mapper.py index 9540979e4a16656dea49674ba154eaf1260290c3..930eac38b79566ce44aac5698069314e839927eb 100644 --- a/modules/plugin_dbui/mapper.py +++ b/modules/plugin_dbui/mapper.py @@ -35,22 +35,22 @@ def map_tabpanel(fieldsets): tabpanel = TabPanel(activeTab=0, enableTabScroll=True, - layout='fit', - defaults={'layout': 'fit'}) + layout="fit", + defaults={"layout": "fit"}) for fieldset in fieldsets: - fieldset['border'] = False + fieldset["border"] = False - title = fieldset['title'] - del fieldset['title'] + title = fieldset["title"] + del fieldset["title"] - tab = {'border': False, - 'collapsible': False, - 'frame': True, - 'items': fieldset, - 'defaults': {'padding': 2}, - 'title': title} + tab = {"border": False, + "collapsible": False, + "frame": True, + "items": fieldset, + "defaults": {"padding": 2}, + "title": title} tabpanel.append_items(tab) diff --git a/modules/plugin_dbui/modifier.py b/modules/plugin_dbui/modifier.py index ab99baa578cdf5407f65eb2f0cceaec50e9fd832..606e6ad5acb4d81dc578c37878f4797d5c4b9a41 100644 --- a/modules/plugin_dbui/modifier.py +++ b/modules/plugin_dbui/modifier.py @@ -25,12 +25,12 @@ class Modifier(object): * The storage can be accessed from anywhere:: - p = PluginManager('dbui') + p = PluginManager("dbui") modifier = p.dbui[dpname] or when the ``tablename`` is defined:: - p = PluginManager('dbui') + p = PluginManager("dbui") modifier = p.dbui[dpname][tablename] Attributes: @@ -44,7 +44,7 @@ class Modifier(object): def __init__(self, dpname, tablename=None): - p = PluginManager('dbui') + p = PluginManager("dbui") if tablename: if dpname not in p.dbui: @@ -83,7 +83,7 @@ class Modifier(object): * A plugin can be defined by a dictionary containing the ``pType`` and the plugin configuration options:: - {'ptype': foo, 'option1': val,...} + {"ptype": foo, "option1": val,...} * The widget associated by default is replaced by a new one when the keyword argument ``xtype`` is used. @@ -91,22 +91,22 @@ class Modifier(object): """ T = current.T - if 'plugins' in extjs: + if "plugins" in extjs: - plugins = extjs['plugins'] + plugins = extjs["plugins"] if isinstance(plugins, str): plugins = [plugins] - if 'plugins' in self.data.extjs: + if "plugins" in self.data.extjs: # list of existing ptypes ptypes = [] - for el in self.data.extjs['plugins']: + for el in self.data.extjs["plugins"]: if isinstance(el, (str, unicode)): ptypes.append(el) elif isinstance(el, dict): - ptypes.append(el['ptype']) + ptypes.append(el["ptype"]) else: raise TypeError(T(MSG_INVALID_TYPE)) @@ -117,19 +117,19 @@ class Modifier(object): if isinstance(plugin, (str, unicode)): ptype = plugin elif isinstance(plugin, dict): - ptype = plugin['ptype'] + ptype = plugin["ptype"] else: raise TypeError(T(MSG_INVALID_TYPE)) if ptype in ptypes: i = ptypes.index(ptype) - self.data.extjs['plugins'][i] = plugin + self.data.extjs["plugins"][i] = plugin else: - self.data.extjs['plugins'].append(plugin) + self.data.extjs["plugins"].append(plugin) else: - self.data.extjs['plugins'] = list(plugins) + self.data.extjs["plugins"] = list(plugins) - del extjs['plugins'] + del extjs["plugins"] self.data.extjs.update(extjs) diff --git a/modules/plugin_dbui/navtree.py b/modules/plugin_dbui/navtree.py index 6aad54dba0cd8e864bc9c0261ac8091babe63794..e51e4826697dd28125179f6891d8b50cc7e74ba8 100644 --- a/modules/plugin_dbui/navtree.py +++ b/modules/plugin_dbui/navtree.py @@ -42,9 +42,9 @@ class Node(object): the widget associated to the leaf """ - di = {'cfg': json.dumps(cfg, cls=JSONEncoder), - 'leaf': True, - 'text': text} + di = {"cfg": json.dumps(cfg, cls=JSONEncoder), + "leaf": True, + "text": text} self.children.append(di) @@ -102,7 +102,7 @@ class Node(object): * **text** (str): name of the leaf """ - return {'text': self.text, 'children': self.children} + return {"text": self.text, "children": self.children} def sort_children(self): """sort children according to alphabetical order. @@ -110,7 +110,7 @@ class Node(object): """ di = {} for child in self.children: - di[child['text']] = child + di[child["text"]] = child names = di.keys() names.sort(cmp=locale.strcoll) diff --git a/modules/plugin_dbui/selector.py b/modules/plugin_dbui/selector.py index f3a5e8c092e7010683d9bb3bf693a88bfc179f38..489769b42f98b0567bed9b9c79333b6dde488bf7 100644 --- a/modules/plugin_dbui/selector.py +++ b/modules/plugin_dbui/selector.py @@ -12,7 +12,7 @@ A powerful mechanism is in place to render the report in different format like HTML, CSV, .... It relies on the Selector class, on the IFRAME and on the view:: - selector = Selector(virtdb.myselector, extfield='format') + selector = Selector(virtdb.myselector, extfield="format") iframe = selector.download() if iframe: @@ -69,7 +69,7 @@ class Selector(Storage): fieldname = t[1] # ignore field id - if fieldname == 'id': + if fieldname == "id": continue val = current.request.vars[key] @@ -81,24 +81,24 @@ class Selector(Storage): # convert the selector value according to field type fieldtype = table[fieldname].type - if fieldtype == 'boolean': - val = val == 'true' or val == 'True' + if fieldtype == "boolean": + val = val == "true" or val == "True" - elif fieldtype == 'date': - ds = datetime.strptime(val, '%Y-%m-%dT%H:%M:%S') + elif fieldtype == "date": + ds = datetime.strptime(val, "%Y-%m-%dT%H:%M:%S") val = date(ds.year, ds.month, ds.day) - elif fieldtype == 'datetime': - val = datetime.strptime(val, '%Y-%m-%dT%H:%M:%S') + elif fieldtype == "datetime": + val = datetime.strptime(val, "%Y-%m-%dT%H:%M:%S") - elif fieldtype == 'double': + elif fieldtype == "double": val = float(val) - elif fieldtype == 'integer': + elif fieldtype == "integer": val = int(val) - elif fieldtype == 'time': - ds = datetime.strptime(val, '%H:%M:%S') + elif fieldtype == "time": + ds = datetime.strptime(val, "%H:%M:%S") val = time(ds.hour, ds.minute, ds.second) self[fieldname] = val @@ -135,7 +135,7 @@ class Selector(Storage): """ li = [] for k in self: - if not k.startswith('_'): + if not k.startswith("_"): li.append(k) return li diff --git a/modules/plugin_dbui/storemodifier.py b/modules/plugin_dbui/storemodifier.py index 7920448b6814fa60ca9bf7d359426a46a4396834..01b5ee9a267b4a00a50db4b316aeb217e53588be 100644 --- a/modules/plugin_dbui/storemodifier.py +++ b/modules/plugin_dbui/storemodifier.py @@ -6,7 +6,7 @@ from helper import get_store_id from modifier import Modifier -MODIFIER_STORES = 'modifier_stores' +MODIFIER_STORES = "modifier_stores" class AddStore(object): @@ -44,10 +44,10 @@ class AddStore(object): def __init__(self, name, **kwargs): - static_stores = PluginManager('dbui').dbui.static_stores + static_stores = PluginManager("dbui").dbui.static_stores storeId = get_store_id(name) - kwargs['storeId'] = storeId + kwargs["storeId"] = storeId static_stores[storeId] = kwargs @@ -74,7 +74,7 @@ class StoreModifier(Modifier): Modifier.__init__(self, MODIFIER_STORES, tablename) - if 'orderby' not in self.data: + if "orderby" not in self.data: self.data.orderby = [] def orderby(self, *fields): diff --git a/modules/plugin_dbui/viewportmodifier.py b/modules/plugin_dbui/viewportmodifier.py index 41cc7f599c46f6e82b30921bc1b7c69062e5328d..8f24be9294db109ee5d5ccf0c625a166fb5080e1 100644 --- a/modules/plugin_dbui/viewportmodifier.py +++ b/modules/plugin_dbui/viewportmodifier.py @@ -5,8 +5,8 @@ from modifier import Modifier from navtree import Node -MSG_INVALID_NODE = 'Node object is not an instance of NodeBase class.' -MODIFIER_VIEWPORTS = 'modifier_viewports' +MSG_INVALID_NODE = "Node object is not an instance of NodeBase class." +MODIFIER_VIEWPORTS = "modifier_viewports" class ViewportModifier(Modifier): @@ -32,10 +32,10 @@ class ViewportModifier(Modifier): Modifier.__init__(self, MODIFIER_VIEWPORTS) - if 'default' not in self.data: + if "default" not in self.data: self.data.default = None - if 'nodes' not in self.data: + if "nodes" not in self.data: self.data.nodes = [] def add_node(self, *args): diff --git a/modules/ui_core.py b/modules/ui_core.py new file mode 100644 index 0000000000000000000000000000000000000000..93435072ad65d86a034adf39f6e00cb0ac7fe2b7 --- /dev/null +++ b/modules/ui_core.py @@ -0,0 +1,417 @@ +# -*- coding: utf-8 -*- +"""User Interface for the core tables + +""" +from gluon import current +from plugin_dbui import (FieldsModifier, + FormModifier, + GridModifier, + StoreModifier, + map_tabpanel) + +TPL = [ + '<b>{PublicationsTitle}</b><br>', + '{PublicationsAuthors}', + '<tpl if="PublicationsId_collaborations > 1">, ', + '{CollaborationsCollaboration}', + '</tpl>', + '<tpl if="PublicationsDoi">, {PublicationsDoi}</tpl>', + '<tpl if="PublicationsId_publishers > 1">, {PublishersAbbreviation}', + '<tpl if="PublicationsVolume"> {PublicationsVolume}</tpl>', + '<tpl if="PublicationsYear"> ({PublicationsYear}) </tpl>', + '<tpl if="PublicationsFirst_page"> {PublicationsFirst_page}</tpl>', + '<tpl if="PublicationsLast_page">-{PublicationsLast_page}</tpl>', + '</tpl>', + '<tpl if="PublicationsConference_title">', + '<br><br>{PublicationsConference_title}', + '<tpl if="PublicationsConference_town">', + '<br>{PublicationsConference_town}', + '</tpl>', + '<tpl if="CountriesCountry">, {CountriesCountry}</tpl>', + '<tpl if="PublicationsConference_start">, ', + '{PublicationsConference_start}', + '</tpl>', + '<tpl if="PublicationsConference_end">', + ' - {PublicationsConference_end}', + '</tpl>', + '<tpl if="PublicationsConference_url">', + '<br>{PublicationsConference_url}' + '</tpl>', + '<br>%s: {PublicationsConference_speaker}' % current.T('Speaker'), + '</tpl>', + '<tpl if="PublicationsReport_numbers"><br><br>', + '<tpl if="PublicationsId_reports > 1">{ReportsType}, </tpl>', + '{PublicationsReport_numbers}', + '</tpl>'] + + +class CoreUI(object): + + @staticmethod + def configure(db, T): + """Configure the user interface for the history table and + its foreign tables, + + Args: + db (pyDAL.DAL): database connection + T (gluon.languages.translator): language translator + + """ + CoreUI.categories(db, T) + CoreUI.collaborations(db, T) + CoreUI.countries(db, T) + CoreUI.harvesters(db, T) + CoreUI.new_fields(db, T) + CoreUI.projects(db, T) + CoreUI.publications(db, T) + CoreUI.publishers(db, T) + CoreUI.reports(db, T) + CoreUI.teams(db, T) + + @staticmethod + def categories(db, T): + """UI for the categories table + + Args: + db (pyDAL.DAL): database connection + T (gluon.languages.translator): language translator + + """ + # .................................................................... + # + # Grid + # + + mdf = GridModifier("categories") + mdf.configure(plugins=["pGridPaging", "pMathJax"]) + + mdf.configure_column("code", width=10) + mdf.set_rownumbering(True) + + mdf.append_filter(("code", "contains", T("bla bla..."))) + + mdf.configure_filters(plugins=["pFormToolTip"], width=300) + mdf.configure_gridWithFilter(selectorTitle="MyFoo") + + # + # Example of buffered rendering + # In that case the full store is loaded but only + # few row are rendered in the grid + # + # plugin = dict(ptype="bufferedrenderer", + # leadingBufferZone=0, + # trailingBufferZone=0) + # mdf.append_plugins(plugin) + + # .................................................................... + # + # Store + # + StoreModifier("categories").orderby(db.categories.code) + + # example of buffered store + # StoreModifier("categories").set_buffered() + + @staticmethod + def collaborations(db, T): + """UI for the collaborations table + + Args: + db (pyDAL.DAL): database connection + T (gluon.languages.translator): language translator + + """ + # .................................................................... + # + # Store + # + mdf = StoreModifier("collaborations") + mdf.orderby(db.collaborations.collaboration) + + @staticmethod + def countries(db, T): + """UI for the countries table + + Args: + db (pyDAL.DAL): database connection + T (gluon.languages.translator): language translator + + """ + # .................................................................... + # + # Store + # + StoreModifier("countries").orderby(db.countries.country) + + @staticmethod + def harvesters(db, T): + """UI for the harvesters table + + Args: + db (pyDAL.DAL): database connection + T (gluon.languages.translator): language translator + + """ + # .................................................................... + # + # Grid + # + mdf = GridModifier("harvesters") + + mdf.append_filter(("id_teams", "==", T("is equal to"))) + # mdf.append_filter(("id_projects", "==", T("is equal to"))) + mdf.append_filter(("controller", "contains", T("contains"))) + # mdf.append_filter(("host", "contains", T("contains"))) + # mdf.append_filter(("id_categories", "==", T("is equal to"))) + + mdf.configure_filters(plugins=["pFormToolTip"], width=300) + mdf.configure_gridWithFilter(selectorTitle="Filter") + + @staticmethod + def new_fields(db, T): + """UI for the harvesters table + + Args: + db (pyDAL.DAL): database connection + T (gluon.languages.translator): language translator + + """ + # .................................................................... + # + # Fields + # + mdf = FieldsModifier("new_fields") + + mdf.configure_field( + "dictionary", + headers=["foo", "faa"], + modifyKeys=True, + value={"string": "test", + "boolean": False, + "integer": 0, + "float": 0.01, + "date": "not implemented"}) + + mdf.configure_field("python_code", xtype="xaceeditorfield") + + # .................................................................... + # + # Form + # + mdf = FormModifier("new_fields") + mdf.configure(width=400) + + @staticmethod + def projects(db, T): + """UI for the projects table + + Args: + db (pyDAL.DAL): database connection + T (gluon.languages.translator): language translator + + """ + # .................................................................... + # + # Store + # + StoreModifier("projects").orderby(db.projects.project) + + @staticmethod + def publications(db, T): + """UI for the publications table + + Args: + db (pyDAL.DAL): database connection + T (gluon.languages.translator): language translator + + """ + year = current.request.now.year + + # .................................................................... + # + # Fields + # + mdf = FieldsModifier("publications") + + mdf.configure_field("conference_start", format="Y-m-d") + mdf.configure_field("conference_end", format="Y-m-d") + mdf.configure_field("year", maxValue=year) + + mdf.merge_fields("first_page", + "last_page", + fieldLabel=T("Pages")) + + mdf.merge_fields("conference_start", + "conference_end", + fieldLabel=T("Dates")) + + # .................................................................... + # + # Form + # + mdf = FormModifier("publications") + + mdf.merge_fields("title", + "authors", + "id_collaborations", + "id_publishers", + "year", + "doi", + "volume", + "first_page", + "e_print", + title=T("General")) + + mdf.merge_fields("conference_title", + "conference_url", + "conference_start", + "conference_town", + "id_countries", + "conference_speaker", + title=T("Conference")) + + mdf.merge_fields("report_numbers", + "id_reports", + title=T("Report")) + + mdf.merge_fields("authors_cppm", + "id_teams", + "id_projects", + "id_categories", + title="CPPM") + + # + # Organise fieldSet within a TabPanel embedded in the publication form + # + mdf.set_mapper(map_tabpanel) + + # + # Polish the look and feel of the publication form + # NOTE: the width/height define the size of the window + # when running the form from the grid. The defaults defines the height + # of the fieldSet allowing a fine tuning of the form layout. + # + mdf.configure(buttonAlign="right", + labelWidth=100, + labelAlign="right", + width=400) + # .................................................................... + # + # Grid + # + mdf = GridModifier("publications") + + mdf.configure( + plugins=["pMathJax", + {"ptype": "pGridRowEditorConfirmDelete", + "resetFields": ["PublicationsId_projects"]}]) + + mdf.merge_columns("title", + "authors", + "id_collaborations", + "id_publishers", + "doi", + "volume", + "first_page", + "last_page", + "conference_title", + "conference_url", + "conference_start", + "conference_end", + "conference_town", + "id_countries", + "conference_speaker", + "report_numbers", + "id_reports", + autohide=True, + header=T("Publication"), + position=0, + tpl=TPL, + width=700) + + mdf.hide_columns( + "authors_cppm", + "e_print") + + # + # Setup a filter panel for the publication grid + # + + mdf.append_filter( + ("year", "==", T("select publication for a given year"))) + + mdf.append_filter( + ("id_teams", "==", T("select publications for a given team"))) + + mdf.append_filter( + ("id_projects", + "==", + T("select publications for a given project"))) + + mdf.append_filter( + ("id_categories", + "==", + T("select publications with a given category code"))) + + mdf.append_filter( + ("authors_cppm", + "contains", + T("select publications for a given CPPM author"))) + + mdf.append_filter( + ("countries.country", "contains", T("blab blab ...."))) + + mdf.configure_filters( + plugins=["pFormToolTip"], + width=300) + + # .................................................................... + # + # Store + # + StoreModifier("publications").orderby(~db.publications.id) + + @staticmethod + def publishers(db, T): + """UI for the publishers table + + Args: + db (pyDAL.DAL): database connection + T (gluon.languages.translator): language translator + + """ + # .................................................................... + # + # Store + # + StoreModifier("publishers").orderby(db.publishers.abbreviation) + + @staticmethod + def reports(db, T): + """UI for the reports table + + Args: + db (pyDAL.DAL): database connection + T (gluon.languages.translator): language translator + + """ + # .................................................................... + # + # Store + # + StoreModifier("reports").orderby(db.reports.type) + + @staticmethod + def teams(db, T): + """UI for the teams table + + Args: + db (pyDAL.DAL): database connection + T (gluon.languages.translator): language translator + + """ + # .................................................................... + # + # Store + # + StoreModifier("teams").orderby(~db.teams.team) diff --git a/modules/ui_selector.py b/modules/ui_selector.py new file mode 100644 index 0000000000000000000000000000000000000000..911846eeae98e81002a69a6356ad5b6922521e3b --- /dev/null +++ b/modules/ui_selector.py @@ -0,0 +1,94 @@ +# -*- coding: utf-8 -*- +"""User Interface for the selector tables + +""" +from plugin_dbui import FieldsModifier, FormModifier + + +class SelectorUI(object): + + @staticmethod + def configure(virtdb, db, T): + """Configure the user interface for the history table and + its foreign tables, + + Args: + virtdb (pyDAL.DAL): connection to the virtual database + db (pyDAL.DAL): database connection + T (gluon.languages.translator): language translator + + """ + SelectorUI.foo1(virtdb, db, T) + SelectorUI.harvester_selector(virtdb, db, T) + SelectorUI.report4(virtdb, db, T) + + @staticmethod + def foo1(virtdb, db, T): + """UI for the foo1 selector table + + Args: + virtdb (pyDAL.DAL): connection to the virtual database + db (pyDAL.DAL): database connection + T (gluon.languages.translator): language translator + + """ + # .................................................................... + # + # Fields + # + mdf = FieldsModifier("foo1") + + mdf.configure_field("my_axis", emptyText="axis") + mdf.configure_field("my_granularity", emptyText="granularity") + + mdf.merge_fields("my_axis", + "my_granularity", + fieldLabel=T("My_Merge")) + + @staticmethod + def harvester_selector(virtdb, db, T): + """UI for the harvester_selector table + + Args: + virtdb (pyDAL.DAL): connection to the virtual database + db (pyDAL.DAL): database connection + T (gluon.languages.translator): language translator + + """ + # .................................................................... + # + # Fields + # + mdf = FieldsModifier("harvester_selector") + + mdf.configure_field("year_start", flex=1) + mdf.configure_field("year_end", flex=1) + + mdf.merge_fields("year_start", + "year_end", + fieldLabel=T("Year")) + + # .................................................................... + # + # Form + # + mdf = FormModifier("harvester_selector") + + mdf.link_comboboxes(master=virtdb.harvester_selector.id_projects, + slave=virtdb.harvester_selector.controller, + masterHasSlaveData="harvesters") + + mdf.link_comboboxes(master=virtdb.harvester_selector.id_projects, + slave=virtdb.harvester_selector.id_teams, + masterHasSlaveData="harvesters") + + @staticmethod + def report4(virtdb, db, T): + """UI for the report4 selector table + + Args: + virtdb (pyDAL.DAL): connection to the virtual database + db (pyDAL.DAL): database connection + T (gluon.languages.translator): language translator + + """ diff --git a/modules/ui_viewport.py b/modules/ui_viewport.py new file mode 100644 index 0000000000000000000000000000000000000000..7fcb7d07211c0a67f41a14ffc4d2e3a994ae830d --- /dev/null +++ b/modules/ui_viewport.py @@ -0,0 +1,246 @@ +# -*- coding: utf-8 -*- +"""Main user interface the viewport + +""" +from gluon import current +from gluon.html import URL +from gluon.tools import PluginManager + +from plugin_dbui import (Node, + Panel, + to_formPanel, + to_gridPanel, + to_panelWithUrlSelector, + ViewportModifier, + Window) + + +def to_grid(tablename): + """helper function to translate a tablename into the grid configuration. + + Args: + tablename (str) + + Return: + dict + + """ + return to_gridPanel(current.db[tablename]) + + +class ViewportUi(object): + + @staticmethod + def configure(virtdb, db, T): + """Configure the viewport. + + Args: + virtdb (pyDAL.DAL): + virtual database with the definition of selectors + db (pyDAL.DAL): database connection + T (gluon.languages.translator): language translator + + """ + nodes = [ + ViewportUi.help_node(db, T), + ViewportUi.app_node(db, T), + ViewportUi.forms_node(db, T), + ViewportUi.tables_node(db, T), + ViewportUi.reports_node(virtdb, db, T)] + + mdf = ViewportModifier() + mdf.add_node(*nodes) + + mdf.configure(tabTitleTpl="{1}") + + # mdf.configure(plugins=["pViewportLogin"], logged=True); + + mdf.default_node(T("Tables"), T("categories")) + # mdf.default_node(T("Tables"), T("new_fields")) + # mdf.default_node(T("Tables"), T("publications")) + + @staticmethod + def app_node(db, T): + """To deal with preferences for the application. + + Args: + db (pyDAL.DAL): database connection + T (gluon.languages.translator): language translator + + Returns: + dbui.Node: + the configuration of a tree node. + + """ + node = Node(T("Application")) + # node.add_child(T("preferences"), to_grid("preferences")) + + window = Window(closable=True, + items=[{"dbtable": "preferences", + "sourceConfig": {"my_date": {"type": "date"}}, + "xtype": "xpreferences", + "width": 300}], + layout="fit", + title=T("Preferences"), + modal=True) + + node.add_child(T("preferences"), window) + + return node + + @staticmethod + def forms_node(db, T): + """To configure forms node. + + Args: + db (pyDAL.DAL): database connection + T (gluon.languages.translator): language translator + + Returns: + dbui.Node: + the configuration of a tree node. + + """ + tables = ("categories", "harvesters", "publications", "new_fields") + node = Node(T("Forms")) + + for tablename in tables: + + leaf = Window(closable=True, + items=[to_formPanel(db[tablename])], + layout="fit", + title="Add %s ..." % tablename, + modal=True) + + node.add_child(T(tablename), leaf) + + return node + + @staticmethod + def tables_node(db, T): + """To configure tables node. + + Args: + db (pyDAL.DAL): database connection + T (gluon.languages.translator): language translator + + Returns: + dbui.Node: + the configuration of a tree node. + + """ + node = Node(T("Tables")) + node.add_children(db.tables, func=to_grid) + + return node + + @staticmethod + def help_node(db, T): + """To configure help node. + + Args: + db (pyDAL.DAL): database connection + T (gluon.languages.translator): language translator + + Returns: + dbui.Node: + the configuration of a tree node. + + """ + plugin = PluginManager("dbui").dbui + + node = Node(T("Help")) + + loader = dict( + autoLoad=True, + renderer="html", + scripts=False, + url=URL("static", plugin.app_about.replace("static/", ""))) + + about_panel = Panel( + loader=loader, + plugins=["pPanelLoaderException"], + autoScroll=True) + + loader = dict( + autoLoad=True, + renderer="html", + scripts=True, + url=URL("plugin_dbui", "documentations_table")) + + doctable_panel = Panel( + loader=loader, + plugins=["pPanelLoaderException"], + autoScroll=True) + + loader = dict( + autoLoad=True, + renderer="html", + scripts=True, + url=URL("plugin_dbui", "documentations_list")) + + doclist_panel = Panel( + loader=loader, + plugins=["pPanelLoaderException"], + autoScroll=True) + + loader = dict( + autoLoad=True, + renderer="html", + scripts=True, + url=URL("plugin_dbui", "versions")) + + version_panel = Panel( + loader=loader, + plugins=["pPanelLoaderException"]) + + node.add_child(T("about"), about_panel) + node.add_child(T("documentations (table)"), doctable_panel) + node.add_child(T("documentations (list)"), doclist_panel) + node.add_child(T("versions"), version_panel) + + return node + + @staticmethod + def reports_node(virtdb, db, T): + """To configure reports nodes. + + Args: + virtdb (pyDAL.DAL): + virtual database with the definition of selectors + db (pyDAL.DAL): database connection + T (gluon.languages.translator): language translator + configuration of the selector panel. + + Returns: + dbui.Node: + the configuration of a tree node. + + """ + node = Node(T("Reports")) + + panel_1 = Panel(html="salut ma poule") + + panel_2 = to_panelWithUrlSelector( + virtdb.foo1, + baseUrl=URL("reports", "report_2"), + baseParams={"hello": 3}, + extField="my_format", + plugins=["pMathJax"]) + + panel_3 = to_panelWithUrlSelector( + virtdb.harvester_selector, + baseUrl=URL("reports", "report_3"), + selectorRegion="east", + selectorTitle="Select a project") + + panel_4 = to_panelWithUrlSelector( + virtdb.report4, + baseUrl=URL("reports", "report_4")) + + node.add_child(T("report_1"), panel_1) + node.add_child(T("report_2"), panel_2) + node.add_child(T("report_3"), panel_3) + node.add_child(T("report_4"), panel_4) + + return node diff --git a/static/plugin_dbui/CHANGELOG b/static/plugin_dbui/CHANGELOG index 7e96e477a377f675450d841af322c69e6193a7c3..ed6d96c6481f84fc22b01e4081fddb2205dbae32 100644 --- a/static/plugin_dbui/CHANGELOG +++ b/static/plugin_dbui/CHANGELOG @@ -2,6 +2,14 @@ HEAD +0.9.8.2 (May 2017) + - Minor release. + - Bug fixed in converters.JSON_TYPES. + - Bug fixed in Ext.form.Panel and Ext.form.field.Property. + - Campaign to replace single by double quote. + - Run pylint checker. + - Factorize the model in classes. + 0.9.8.1 (Apr 2017) - Minor update - Add the method Dbui.registerExtraTypesforField and diff --git a/static/plugin_dbui/VERSION b/static/plugin_dbui/VERSION index 39dcf8797293590e1d2e69ce7eeaffe7ab2de442..0bb69e05321880fb20dd657e0b23e13c5ab5e12a 100644 --- a/static/plugin_dbui/VERSION +++ b/static/plugin_dbui/VERSION @@ -1 +1 @@ -0.9.8.1 \ No newline at end of file +0.9.8.2 \ No newline at end of file diff --git a/static/plugin_dbui/locale/dbui-lang-fr.js b/static/plugin_dbui/locale/dbui-lang-fr.js index 272d84be37822d8eff904812d73d5f81d4660886..4fda8ae824472acf91f8690acb6c793aa16598ab 100644 --- a/static/plugin_dbui/locale/dbui-lang-fr.js +++ b/static/plugin_dbui/locale/dbui-lang-fr.js @@ -3,176 +3,176 @@ * */ -Ext.define('Dbui.local.fr.container.plugin.Login', { - override: 'Dbui.container.plugin.Login', - textChangePwd : 'Changer votre mot de passe', +Ext.define("Dbui.local.fr.container.plugin.Login", { + override: "Dbui.container.plugin.Login", + textChangePwd : "Changer votre mot de passe", textLogin : "S'identifier", textLogout : "Quitter l'application" }); -Ext.define('Dbui.local.fr.form.field.ComboBox', { - override: 'Dbui.form.field.ComboBox', - textSelect: 'Sélectioner un(e) ' +Ext.define("Dbui.local.fr.form.field.ComboBox", { + override: "Dbui.form.field.ComboBox", + textSelect: "Sélectioner un(e) " }); -Ext.define('Dbui.local.fr.form.field.ComboBoxMaster', { - override: 'Dbui.form.field.ComboBoxMaster', - textSelect: 'Sélectioner un(e) ' +Ext.define("Dbui.local.fr.form.field.ComboBoxMaster", { + override: "Dbui.form.field.ComboBoxMaster", + textSelect: "Sélectioner un(e) " }); -Ext.define('Dbui.local.fr.form.field.ComboBoxSlave', { - override: 'Dbui.form.field.ComboBoxSlave', - textSelect: 'Sélectioner un(e) ' +Ext.define("Dbui.local.fr.form.field.ComboBoxSlave", { + override: "Dbui.form.field.ComboBoxSlave", + textSelect: "Sélectioner un(e) " }); -Ext.define('Dbui.local.fr.form.field.Dict', { - override: 'Dbui.form.field.Dict', - textAddMenu : 'Ajouter', - textAddTitle : 'Entrez le nom de la clé', - textDestroyMenu : 'Détruire', - textDestroyTitle : 'Voulez-vous vraiment détruire la clé', - textErrorKey : 'Sélectioner une clé !', - textErrorMsg : 'Cette clé existe déjà !', - textErrorTitle : 'Erreur ...', - textUpdateMenu : 'Modifier', - textUpdateTitle : 'Modifier la clé' +Ext.define("Dbui.local.fr.form.field.Dict", { + override: "Dbui.form.field.Dict", + textAddMenu : "Ajouter", + textAddTitle : "Entrez le nom de la clé", + textDestroyMenu : "Détruire", + textDestroyTitle : "Voulez-vous vraiment détruire la clé", + textErrorKey : "Sélectioner une clé !", + textErrorMsg : "Cette clé existe déjà !", + textErrorTitle : "Erreur ...", + textUpdateMenu : "Modifier", + textUpdateTitle : "Modifier la clé" }); -Ext.define('Dbui.local.fr.form.field.List', { - override: 'Dbui.form.field.List', - textAdd : 'Ajouter un élément', - textDestroy : 'Détruire cet élément', - textDestroytitle : 'Détruire ...', - textDestroyMsg : 'Voulez-vous vraiment détruire cet élément', - textGoDown : 'Déplacer vers le bas', - textGoUp : 'Déplacer vers le haut' +Ext.define("Dbui.local.fr.form.field.List", { + override: "Dbui.form.field.List", + textAdd : "Ajouter un élément", + textDestroy : "Détruire cet élément", + textDestroytitle : "Détruire ...", + textDestroyMsg : "Voulez-vous vraiment détruire cet élément", + textGoDown : "Déplacer vers le bas", + textGoUp : "Déplacer vers le haut" }); -Ext.define('Dbui.local.fr.form.Panel', { - override: 'Dbui.form.Panel', - textCreate : 'Créer', - textDestroy : 'Détruire', - textDuplicate : 'Dupliquer', - textReset : 'Annuler', - textUpdate : 'Actualiser', +Ext.define("Dbui.local.fr.form.Panel", { + override: "Dbui.form.Panel", + textCreate : "Créer", + textDestroy : "Détruire", + textDuplicate : "Dupliquer", + textReset : "Annuler", + textUpdate : "Actualiser", textCreateErrorAction : "L'enregistrement a été détruit.", - textCreateFailed : 'La création a échoué...', + textCreateFailed : "La création a échoué...", textDbAction : "La base de donnée n'a pas été modifiée.", textDeleteErrorAction : "L'enregistrement a été gardé.", - textDeleteFailed : 'La destruction a échouée...', - textError : 'Erreur...', - textServerError : 'Erreur coté serveur.', + textDeleteFailed : "La destruction a échouée...", + textError : "Erreur...", + textServerError : "Erreur coté serveur.", textStoreError : "la zone de skoctage interne n'est pas défini !!!", textUpdateErrorAction : "Les modifications ont été annulées.", - textUpdateFailed : 'La mise à jour a échoué...' + textUpdateFailed : "La mise à jour a échoué..." }); -Ext.define('Dbui.local.fr.grid.button.ExpertMenu', { - override: 'Dbui.grid.button.ExpertMenu', - textExport : 'Exporter dans un fichier CSV', - textMathJax : 'Interpréter les équations', - textReset : 'Reset' +Ext.define("Dbui.local.fr.grid.button.ExpertMenu", { + override: "Dbui.grid.button.ExpertMenu", + textExport : "Exporter dans un fichier CSV", + textMathJax : "Interpréter les équations", + textReset : "Reset" }); -Ext.define('Dbui.local.fr.grid.plugin.Export', { - override: 'Dbui.grid.plugin.Export', - textToCSV : 'Exporter en CSV...', - textToLaTeX : 'Exporter en LaTeX...', - textToPDF : 'Exporter en PDF...' +Ext.define("Dbui.local.fr.grid.plugin.Export", { + override: "Dbui.grid.plugin.Export", + textToCSV : "Exporter en CSV...", + textToLaTeX : "Exporter en LaTeX...", + textToPDF : "Exporter en PDF..." }); -Ext.define('Dbui.local.fr.grid.plugin.Paging', { - override: 'Dbui.grid.plugin.Paging', - textPlus : 'Plus', - textSlider : 'Entrées par page' +Ext.define("Dbui.local.fr.grid.plugin.Paging", { + override: "Dbui.grid.plugin.Paging", + textPlus : "Plus", + textSlider : "Entrées par page" }); -Ext.define('Dbui.local.fr.grid.plugin.Toolbar', { - override: 'Dbui.grid.plugin.Toolbar', - textEntries : 'Entrées', - textPlus : 'Plus' +Ext.define("Dbui.local.fr.grid.plugin.Toolbar", { + override: "Dbui.grid.plugin.Toolbar", + textEntries : "Entrées", + textPlus : "Plus" }); -Ext.define('Dbui.local.fr.grid.plugin.RowEditorAddWizard', { - override: 'Dbui.grid.plugin.RowEditorAddWizard', +Ext.define("Dbui.local.fr.grid.plugin.RowEditorAddWizard", { + override: "Dbui.grid.plugin.RowEditorAddWizard", - textExpert: 'mode expert', - textSimplify: 'mode simplifié', - textTitle: 'Assistant...' + textExpert: "mode expert", + textSimplify: "mode simplifié", + textTitle: "Assistant..." }); -Ext.define('Dbui.local.fr.grid.plugin.RowEditorBase', { - override: 'Dbui.grid.plugin.RowEditorBase', +Ext.define("Dbui.local.fr.grid.plugin.RowEditorBase", { + override: "Dbui.grid.plugin.RowEditorBase", addTitle : "Créer un enregistrement...", deleteTitle : "Détruire un enregistrement...", duplicateTitle : "Dupliquer un enregistrement..", editTitle : "Actualiser un enregistrement...", viewTitle : "Voir un enregistrement...", - textMsg : 'Sélectioner un enregistrement !' + textMsg : "Sélectioner un enregistrement !" }); -Ext.define('Dbui.local.fr.grid.plugin.RowEditorConfirmDelete', { - override: 'Dbui.grid.plugin.RowEditorConfirmDelete', - confirmMsg: 'Voulez-vous vraiment détruire cet élément ?' +Ext.define("Dbui.local.fr.grid.plugin.RowEditorConfirmDelete", { + override: "Dbui.grid.plugin.RowEditorConfirmDelete", + confirmMsg: "Voulez-vous vraiment détruire cet élément ?" }); -Ext.define('Dbui.local.fr.grid.plugin.RowEditorContextMenu', { - override: 'Dbui.grid.plugin.RowEditorContextMenu', - textAdd : 'Ajouter', - textCreate : 'Créer', - textDestroy : 'Détruire', - textDuplicate : 'Dupliquer', - textUpdate : 'Actualiser', - textView : 'Voir' +Ext.define("Dbui.local.fr.grid.plugin.RowEditorContextMenu", { + override: "Dbui.grid.plugin.RowEditorContextMenu", + textAdd : "Ajouter", + textCreate : "Créer", + textDestroy : "Détruire", + textDuplicate : "Dupliquer", + textUpdate : "Actualiser", + textView : "Voir" }); -Ext.define('Dbui.local.fr.grid.property.Preferences', { - override: 'Dbui.grid.property.Preferences', - textDefinition: 'Définition', - textReset : 'Annuler', - textUpdate : 'Actualiser' +Ext.define("Dbui.local.fr.grid.property.Preferences", { + override: "Dbui.grid.property.Preferences", + textDefinition: "Définition", + textReset : "Annuler", + textUpdate : "Actualiser" }); -Ext.define('Dbui.local.fr.panel.BaseWithSelector', { - override: 'Dbui.panel.BaseWithSelector', - textGo : 'Go', - textReset : 'Annuler' +Ext.define("Dbui.local.fr.panel.BaseWithSelector", { + override: "Dbui.panel.BaseWithSelector", + textGo : "Go", + textReset : "Annuler" }); -Ext.define('Dbui.local.fr.panel.GridWithFilter', { - override: 'Dbui.panel.GridWithFilter', - textLoad: 'chargement en cours...' +Ext.define("Dbui.local.fr.panel.GridWithFilter", { + override: "Dbui.panel.GridWithFilter", + textLoad: "chargement en cours..." }); -Ext.define('Dbui.local.fr.panel.plugin.LoaderException', { - override: 'Dbui.panel.plugin.LoaderException', - textError: 'Erreur ...' +Ext.define("Dbui.local.fr.panel.plugin.LoaderException", { + override: "Dbui.panel.plugin.LoaderException", + textError: "Erreur ..." }); -Ext.define('Dbui.local.fr.panel.WithUrlSelector', { - override: 'Dbui.panel.WithUrlSelector', +Ext.define("Dbui.local.fr.panel.WithUrlSelector", { + override: "Dbui.panel.WithUrlSelector", textChrome: "La taille du fichier est trôp grande pour Chrome.<br> Une solution est d'utilisée FireFox!", - textLoad : 'Chargement en cours...', - textProgressBar : 'Fichier en préparation. Soyez patient ...', - textWarning: 'Attention' + textLoad : "Chargement en cours...", + textProgressBar : "Fichier en préparation. Soyez patient ...", + textWarning: "Attention" }); -Ext.define('Dbui.local.fr.plugin.MathJax', { - override: 'Dbui.plugin.MathJax', - textMask: 'Interprétation des équations ...' +Ext.define("Dbui.local.fr.plugin.MathJax", { + override: "Dbui.plugin.MathJax", + textMask: "Interprétation des équations ..." }); -Ext.define('Dbui.local.fr.wizard.Wizard', { - override: 'Dbui.wizard.Wizard', +Ext.define("Dbui.local.fr.wizard.Wizard", { + override: "Dbui.wizard.Wizard", textAttention: "Attention", textClose: [ "<p>L'assistant va être fermé.<br>", "Toutes les données vont être perdues.</p><br>", "Voulez-vous continuer ?" ], - textError: 'Erreur', - textFinish: 'Fin', - textLoading: 'Traitement des données...', - textNext: 'Suivant', - textPrevious: 'Précédent' + textError: "Erreur", + textFinish: "Fin", + textLoading: "Traitement des données...", + textNext: "Suivant", + textPrevious: "Précédent" }); diff --git a/static/plugin_dbui/src/Dbui.js b/static/plugin_dbui/src/Dbui.js index 8c02859c0875cbd677eb96e5d6e72f03f470e92b..1a3869e8fe40106ea371f1bcf0a0b192b466be5e 100644 --- a/static/plugin_dbui/src/Dbui.js +++ b/static/plugin_dbui/src/Dbui.js @@ -1,21 +1,21 @@ /** * Core utilities and functions. */ -Ext.define('Dbui', { +Ext.define("Dbui", { singleton: true, - uses: ['Ext.data.ArrayStore', - 'Ext.data.DirectStore', - 'Ext.data.JsonPStore', - 'Ext.data.JsonStore', - 'Dbui.data.DirectStore', - 'Ext.data.XmlStore'], + uses: ["Ext.data.ArrayStore", + "Ext.data.DirectStore", + "Ext.data.JsonPStore", + "Ext.data.JsonStore", + "Dbui.data.DirectStore", + "Ext.data.XmlStore"], /** * The version of the plugin * @property {String} */ - version: '0.9.8.1', + version: "0.9.8.2", /** * The name of the application @@ -72,14 +72,14 @@ Ext.define('Dbui', { */ extToURI: { - csv: 'data:text/csv;charset=utf-8', - html: 'data:text/html;charset=utf-8', - ods: 'data:application/vnd.oasis.opendocument.spreadsheet;base64', - odt: 'data:application/vnd.oasis.opendocument.text;base64', - pdf: 'data:application/pdf;base64', - png: 'data:image/png;base64', - svg: 'data:image/svg+xml;charset=utf-8', - tex: 'data:application/x-latex;charset=utf-8' + csv: "data:text/csv;charset=utf-8", + html: "data:text/html;charset=utf-8", + ods: "data:application/vnd.oasis.opendocument.spreadsheet;base64", + odt: "data:application/vnd.oasis.opendocument.text;base64", + pdf: "data:application/pdf;base64", + png: "data:image/png;base64", + svg: "data:image/svg+xml;charset=utf-8", + tex: "data:application/x-latex;charset=utf-8" }, /** @@ -291,7 +291,7 @@ Ext.define('Dbui', { fields; // list of field which inherite from Ext.form.field.Base - fields = cmp.query('field'); + fields = cmp.query("field"); // list of field which do not inherited form Ext.form.field.Base me.extraTypesForField.forEach(function(type) { @@ -344,28 +344,28 @@ Ext.define('Dbui', { // instantiate the store switch (cfg.xtype) { - case 'array': - className = 'Ext.data.ArrayStore'; + case "array": + className = "Ext.data.ArrayStore"; break; - case 'direct': - className = 'Ext.data.DirectStore'; + case "direct": + className = "Ext.data.DirectStore"; break; - case 'jsonpstore': - className = 'Ext.data.JsonPStore'; + case "jsonpstore": + className = "Ext.data.JsonPStore"; break; - case 'json': - className = 'Ext.data.JsonStore'; + case "json": + className = "Ext.data.JsonStore"; break; - case 'xdirectstore': - className = 'Dbui.data.DirectStore'; + case "xdirectstore": + className = "Dbui.data.DirectStore"; break; - case 'xml': - className = 'Ext.data.XmlStore'; + case "xml": + className = "Ext.data.XmlStore"; break; default: @@ -401,7 +401,7 @@ Ext.define('Dbui', { var i, plugin; - if (!component.hasOwnProperty('plugins')) { + if (!component.hasOwnProperty("plugins")) { return false; } @@ -417,7 +417,7 @@ Ext.define('Dbui', { return true; } - if ((typeof plugin === 'object') && (plugin.ptype === ptype)) { + if ((typeof plugin === "object") && (plugin.ptype === ptype)) { return true; } } @@ -550,8 +550,8 @@ Ext.define('Dbui', { disableCaching: false, enabled: true, paths: { - 'Dbui': '../static/plugin_dbui/src', - 'Ext': '../static/plugin_extjs/src' + "Dbui": "../static/plugin_dbui/src", + "Ext": "../static/plugin_extjs/src" } }); } diff --git a/static/plugin_dbui/src/button/Download.js b/static/plugin_dbui/src/button/Download.js index 5e6f85f77a318631293b11e81fead2fb5ff22bca..22add545d83bdf15c003b70d04e4f2456d22e6d8 100644 --- a/static/plugin_dbui/src/button/Download.js +++ b/static/plugin_dbui/src/button/Download.js @@ -2,10 +2,10 @@ * A button to download a file from the server * */ -Ext.define('Dbui.button.Download', { +Ext.define("Dbui.button.Download", { - extend: 'Ext.button.Button', - alias: 'widget.xbuttondownload', + extend: "Ext.button.Button", + alias: "widget.xbuttondownload", /** * @cfg{String} @@ -24,7 +24,7 @@ Ext.define('Dbui.button.Download', { me.callParent(arguments); // download when the button is pressed - me.on('click', me.onDownload, me); + me.on("click", me.onDownload, me); }, // jshint strict: true @@ -48,17 +48,17 @@ Ext.define('Dbui.button.Download', { // remove existing iframe try { - Ext.destroy(Ext.get('downloadIframe')); + Ext.destroy(Ext.get("downloadIframe")); } catch (ignore) {} // create a fresh iframe Ext.DomHelper.append(document.body, { - tag: 'iframe', - id: 'downloadIframe', + tag: "iframe", + id: "downloadIframe", frameBorder: 0, width: 0, height: 0, - css: 'display:none;visibility:hidden;height:0px;', + css: "display:none;visibility:hidden;height:0px;", src: me.url }); } diff --git a/static/plugin_dbui/src/container/Viewport.js b/static/plugin_dbui/src/container/Viewport.js index 419fba6c0bd5f4a6a3899684ec2e02fe2b342ed5..31529e66da605e5dd0ceedee05ec1eb66fecc549 100644 --- a/static/plugin_dbui/src/container/Viewport.js +++ b/static/plugin_dbui/src/container/Viewport.js @@ -15,26 +15,26 @@ * In the first case the xtype is *panel* while in the second one is *window*. * */ -Ext.define('Dbui.container.Viewport', { +Ext.define("Dbui.container.Viewport", { - extend: 'Ext.container.Viewport', - alias: 'widget.xviewport', + extend: "Ext.container.Viewport", + alias: "widget.xviewport", requires: [ - 'Dbui.container.plugin.Login', - 'Ext.layout.container.Border', - 'Ext.layout.container.Fit', - 'Ext.tab.Panel', - 'Ext.Template', - 'Ext.tree.Panel' + "Dbui.container.plugin.Login", + "Ext.layout.container.Border", + "Ext.layout.container.Fit", + "Ext.tab.Panel", + "Ext.Template", + "Ext.tree.Panel" ], uses: [ - 'Dbui.form.Panel', - 'Dbui.grid.Panel', - 'Dbui.grid.property.Preferences', - 'Dbui.panel.GridWithFilter', - 'Dbui.panel.WithUrlSelector', - 'Ext.panel.Panel', - 'Ext.window.Window' + "Dbui.form.Panel", + "Dbui.grid.Panel", + "Dbui.grid.property.Preferences", + "Dbui.panel.GridWithFilter", + "Dbui.panel.WithUrlSelector", + "Ext.panel.Panel", + "Ext.window.Window" ], /** * @property {String[]} @@ -84,8 +84,8 @@ Ext.define('Dbui.container.Viewport', { // contains the field cfg in addition to the tree node fields treeStoreCfg = { fields: [{ - name: 'cfg', - type: 'string', + name: "cfg", + type: "string", convert: function (value) { return Ext.JSON.decode(value); } @@ -95,7 +95,7 @@ Ext.define('Dbui.container.Viewport', { children: Dbui.config.treeNodes, text: Dbui.name }, - xtype: 'tree' + xtype: "tree" }; // title of the tree panel @@ -105,41 +105,41 @@ Ext.define('Dbui.container.Viewport', { // predefined configuration of the view port viewportCfg = { - layout: 'border', - title: 'Ext Layout Browser', + layout: "border", + title: "Ext Layout Browser", items: [{ height: 25, hidden: true, - itemId: 'topBar', - region: 'north', - xtype: 'toolbar' + itemId: "topBar", + region: "north", + xtype: "toolbar" }, { collapsible: true, - itemId: 'treePanel', - region: 'west', + itemId: "treePanel", + region: "west", rootVisible: false, split: true, store: treeStoreCfg, title: me.treePanelTitle, width: 200, - xtype: 'treepanel' + xtype: "treepanel" }, { autoDestroy: false, bodyPadding: 1, defaults: { - layout: 'fit' + layout: "fit" }, enableTabScroll: true, - itemId: 'tabPanel', - region: 'center', - tabPosition: 'top', - xtype: 'tabpanel' + itemId: "tabPanel", + region: "center", + tabPosition: "top", + xtype: "tabpanel" }, { height: 25, hidden: true, - itemId: 'bottomBar', - region: 'south', - xtype: 'toolbar' + itemId: "bottomBar", + region: "south", + xtype: "toolbar" }] }; @@ -147,21 +147,21 @@ Ext.define('Dbui.container.Viewport', { Ext.apply(me, viewportCfg); // compile template - me.tabTitleTpl = Ext.create('Ext.Template', me.tabTitleTpl); + me.tabTitleTpl = Ext.create("Ext.Template", me.tabTitleTpl); me.tabTitleTpl.compile(); //initialise the base class me.callParent(arguments); // define short cuts - me.tabPanel = me.getComponent('tabPanel'); - me.treePanel = me.getComponent('treePanel'); + me.tabPanel = me.getComponent("tabPanel"); + me.treePanel = me.getComponent("treePanel"); // Add handler to create tab/window and their widget - me.treePanel.on('itemclick', me.onItemClick, me); + me.treePanel.on("itemclick", me.onItemClick, me); // disable ContextMenu everywhere in the ViewPort - me.getEl().on('contextmenu', me.onContextMenu); + me.getEl().on("contextmenu", me.onContextMenu); // open the default Tab me.openDefaultTab(); @@ -172,8 +172,8 @@ Ext.define('Dbui.container.Viewport', { var me = this; - me.treePanel.un('itemclick', me.onItemClick, me); - me.getEl().un('contextmenu', me.onContextMenu); + me.treePanel.un("itemclick", me.onItemClick, me); + me.getEl().un("contextmenu", me.onContextMenu); me.callParent(arguments); }, @@ -233,18 +233,18 @@ Ext.define('Dbui.container.Viewport', { // Create or activate the tab for a leafs // configuration of the embedded widget - wdgcfg = record.get('cfg'); + wdgcfg = record.get("cfg"); wdgtype = wdgcfg.xtype; // standalone window - if (wdgtype === 'window') { - window = Ext.create('Ext.window.Window', wdgcfg); + if (wdgtype === "window") { + window = Ext.create("Ext.window.Window", wdgcfg); window.show(); return; } // unique tab identifier based on the node path - tabId = record.getPath('text', '_'); + tabId = record.getPath("text", "_"); // strict rule in ExtJS 5.1 for the itemId: [a-zA-Z0-9\-_] // replace invalid character since the itemId is the equal to the tabId @@ -269,7 +269,7 @@ Ext.define('Dbui.container.Viewport', { // embed single panel in the tab panel // other widget as children - if (wdgtype === 'panel') { + if (wdgtype === "panel") { delete wdgcfg.xtype; Ext.apply(cfg, wdgcfg); @@ -294,7 +294,7 @@ Ext.define('Dbui.container.Viewport', { i, node, path = me.defaultTabPath, - treePanel = me.getComponent('treePanel'); + treePanel = me.getComponent("treePanel"); // protection against undefined path if (!path) { @@ -304,7 +304,7 @@ Ext.define('Dbui.container.Viewport', { // get the node of the path node = treePanel.getStore().getRootNode(); for (i = 0; i < path.length; i += 1) { - node = node.findChild('text', path[i]); + node = node.findChild("text", path[i]); } // create the tab for the last one diff --git a/static/plugin_dbui/src/container/plugin/Login.js b/static/plugin_dbui/src/container/plugin/Login.js index f703f957f59d87fc7e61f232ce92d75e53d8f5e3..2bb4a17fafff69440aa2ddccd372ee0dea3f9f46 100644 --- a/static/plugin_dbui/src/container/plugin/Login.js +++ b/static/plugin_dbui/src/container/plugin/Login.js @@ -11,10 +11,10 @@ * @uses Dbui.container.Viewport * */ -Ext.define('Dbui.container.plugin.Login', { +Ext.define("Dbui.container.plugin.Login", { - extend: 'Ext.AbstractPlugin', - alias: 'plugin.pViewportLogin', + extend: "Ext.AbstractPlugin", + alias: "plugin.pViewportLogin", // Private properties for internationalization textChangePwd: "Change password...", @@ -33,7 +33,7 @@ Ext.define('Dbui.container.plugin.Login', { var me = this, inhibit_login = false, inhibit_logout = true, - tbar = viewport.getComponent('topBar'), + tbar = viewport.getComponent("topBar"), url = location.protocol + "//" + location.host + "/" + Dbui.name; if (viewport.logged) { @@ -41,13 +41,13 @@ Ext.define('Dbui.container.plugin.Login', { inhibit_logout = false; } - tbar.add('->', '-'); + tbar.add("->", "-"); tbar.add({ hidden: inhibit_login, href: url + "/admin", hrefTarget: "_self", - iconCls: 'xuser-identity', + iconCls: "xuser-identity", tooltip: me.textLogin }); @@ -60,14 +60,14 @@ Ext.define('Dbui.container.plugin.Login', { }); if (inhibit_login) { - tbar.add('-'); + tbar.add("-"); } tbar.add({ hidden: inhibit_logout, href: url + "/default/user/logout", hrefTarget: "_self", - iconCls: 'xapplication-exit', + iconCls: "xapplication-exit", tooltip: me.textLogout }); diff --git a/static/plugin_dbui/src/data/DirectStore.js b/static/plugin_dbui/src/data/DirectStore.js index baee57345aee3fcca3f495b56fc1792e8993b1f9..405dac6bb47ba6097e29104fa50989be1950152e 100644 --- a/static/plugin_dbui/src/data/DirectStore.js +++ b/static/plugin_dbui/src/data/DirectStore.js @@ -8,11 +8,11 @@ * It also provide a set of method to filter the store passing by the server. * */ -Ext.define('Dbui.data.DirectStore', { +Ext.define("Dbui.data.DirectStore", { - extend: 'Ext.data.Store', - alias: 'widget.xdirectstore', - requires: 'Dbui.data.proxy.Direct', + extend: "Ext.data.Store", + alias: "widget.xdirectstore", + requires: "Dbui.data.proxy.Direct", // private property. // List of the where condition at startup. @@ -35,10 +35,10 @@ Ext.define('Dbui.data.DirectStore', { // the proxy if (!config.proxy) { proxy = { - type: 'xdirect' + type: "xdirect" }; - Ext.copyTo(proxy, config, ['extraParams', 'pageParam']); + Ext.copyTo(proxy, config, ["extraParams", "pageParam"]); config.proxy = proxy; } @@ -75,7 +75,7 @@ Ext.define('Dbui.data.DirectStore', { for (i = 0; i < me.initialWhere.length; i += 1) { conditions.push(me.initialWhere[i]); } - me.proxy.setExtraParam('where', conditions); + me.proxy.setExtraParam("where", conditions); } else { delete me.proxy.extraParams.where; diff --git a/static/plugin_dbui/src/data/proxy/Direct.js b/static/plugin_dbui/src/data/proxy/Direct.js index 84403c8b4bd68845237341f9b901464423515a92..d8f7e67593515c2d918fb09a8a22fd0a266f7286 100644 --- a/static/plugin_dbui/src/data/proxy/Direct.js +++ b/static/plugin_dbui/src/data/proxy/Direct.js @@ -4,7 +4,7 @@ * * **Note**: each operation contains at least 3 parameters: * * - dbFields {Array[]} - * The definition of the database field ['tablename', 'fieldname'] + * The definition of the database field ["tablename", "fieldname"] * * - tableName {String} * The name of the database table. @@ -21,22 +21,22 @@ * @since 0.6.0.0 * */ -Ext.define('Dbui.data.proxy.Direct', { +Ext.define("Dbui.data.proxy.Direct", { - extend: 'Ext.data.proxy.Direct', - alias: 'proxy.xdirect', + extend: "Ext.data.proxy.Direct", + alias: "proxy.xdirect", // predefined JSON reader adapted to the DbSvc service reader: { - type: 'json', - rootProperty: 'records', - successProperty: 'success', - totalProperty: 'count' + type: "json", + rootProperty: "records", + successProperty: "success", + totalProperty: "count" }, // predeined JSON writer adapted to the DbSvc service writer: { - type: 'json', + type: "json", allowSingle: false, writeAllFields: false }, @@ -110,22 +110,22 @@ Ext.define('Dbui.data.proxy.Direct', { params = request.getParams(); switch (action) { - case 'read': + case "read": break; - case 'create': - fieldId = Dbui.encodeField(params.tableName, 'id'); + case "create": + fieldId = Dbui.encodeField(params.tableName, "id"); params.records = request.getJsonData(); for (i = 0; i < params.records.length; i += 1) { delete params.records[i][fieldId]; } break; - case 'update': + case "update": params.records = request.getJsonData(); break; - case 'destroy': + case "destroy": params.records = request.getJsonData(); break; } diff --git a/static/plugin_dbui/src/form/Panel.js b/static/plugin_dbui/src/form/Panel.js index 927b4cc9a0494927fe27a1aa62214b687a7f8c7d..d68595c7f48037bebbd8b0b1327822c98466fe55 100644 --- a/static/plugin_dbui/src/form/Panel.js +++ b/static/plugin_dbui/src/form/Panel.js @@ -16,27 +16,27 @@ * The action associated to the button is set via the #setAction method. * */ -Ext.define('Dbui.form.Panel', { +Ext.define("Dbui.form.Panel", { - extend: 'Ext.form.Panel', - alias: 'widget.xform', + extend: "Ext.form.Panel", + alias: "widget.xform", requires: [ - 'Dbui.form.plugin.RegExp', - 'Dbui.form.plugin.ToolTip' + "Dbui.form.plugin.RegExp", + "Dbui.form.plugin.ToolTip" ], uses: [ - 'Dbui.form.field.AceEditor', - 'Dbui.form.field.ComboBox', - 'Dbui.form.field.ComboBoxMaster', - 'Dbui.form.field.ComboBoxSlave', - 'Dbui.form.field.ComboBoxUserReset', - 'Dbui.form.field.Dict', - 'Dbui.form.field.List', - 'Dbui.form.field.Table', - 'Dbui.form.field.TextPicker', - 'Ext.form.field.Date', - 'Ext.form.field.HtmlEditor', - 'Ext.layout.container.Column' + "Dbui.form.field.AceEditor", + "Dbui.form.field.ComboBox", + "Dbui.form.field.ComboBoxMaster", + "Dbui.form.field.ComboBoxSlave", + "Dbui.form.field.ComboBoxUserReset", + "Dbui.form.field.Dict", + "Dbui.form.field.List", + "Dbui.form.field.Table", + "Dbui.form.field.TextPicker", + "Ext.form.field.Date", + "Ext.form.field.HtmlEditor", + "Ext.layout.container.Column" ], /** * @property {Ext.Button} @@ -58,19 +58,19 @@ Ext.define('Dbui.form.Panel', { store: null, // Predefined configuration options - bodyStyle: 'padding:5px 5px 0', + bodyStyle: "padding:5px 5px 0", buttons: [{ formBind: true, - itemId: 'buttonAction', - text: 'Action' + itemId: "buttonAction", + text: "Action" }, { - itemId: 'buttonReset', - text: 'Reset' + itemId: "buttonReset", + text: "Reset" }], defaults: { - anchor: '100%' + anchor: "100%" }, - defaultType: 'textfield', + defaultType: "textfield", frame: true, // private properties to keep track of current action parameters @@ -82,22 +82,22 @@ Ext.define('Dbui.form.Panel', { currentIndex: undefined, // private properties for internationalization - textCreate: 'Create', - textDestroy: 'Delete', - textDuplicate: 'Duplicate', - textReset: 'Reset', - textUpdate: 'Update', - - textCreateErrorAction: 'The new record(s) is destroyed.', - textCreateFailed: 'Create failed...', - textDbAction: 'The database is not modified.', - textDeleteErrorAction: 'The record(s) is kept.', - textDeleteFailed: 'Delete failed...', - textError: 'Error...', - textServerError: 'Internal server error.', - textStoreError: 'the store is undefined !!!', - textUpdateErrorAction: 'The update record(s) is revert to its original values.', - textUpdateFailed: 'Update failed...', + textCreate: "Create", + textDestroy: "Delete", + textDuplicate: "Duplicate", + textReset: "Reset", + textUpdate: "Update", + + textCreateErrorAction: "The new record(s) is destroyed.", + textCreateFailed: "Create failed...", + textDbAction: "The database is not modified.", + textDeleteErrorAction: "The record(s) is kept.", + textDeleteFailed: "Delete failed...", + textError: "Error...", + textServerError: "Internal server error.", + textStoreError: "the store is undefined !!!", + textUpdateErrorAction: "The update record(s) is revert to its original values.", + textUpdateFailed: "Update failed...", // jshint strict: false @@ -112,20 +112,20 @@ Ext.define('Dbui.form.Panel', { // short cuts toolbar = me.getDockedItems()[0]; - me.buttonAction = toolbar.getComponent('buttonAction'); - me.buttonReset = toolbar.getComponent('buttonReset'); + me.buttonAction = toolbar.getComponent("buttonAction"); + me.buttonReset = toolbar.getComponent("buttonReset"); // button events listeners - me.buttonAction.on('click', me.doAction, me); - me.buttonReset.on('click', me.softReset, me); + me.buttonAction.on("click", me.doAction, me); + me.buttonReset.on("click", me.softReset, me); // link the form to the data store me.store = Dbui.getStore(me.store); - me.store.getProxy().on('exception', me.onProxyException, me); - me.store.on('write', me.softReset, me); + me.store.getProxy().on("exception", me.onProxyException, me); + me.store.on("write", me.softReset, me); // set the default action: create - me.setAction('create'); + me.setAction("create"); me.buttonReset.setText(me.textReset); }, @@ -134,11 +134,11 @@ Ext.define('Dbui.form.Panel', { var me = this; - me.buttonAction.un('click', me.doAction, me); - me.buttonReset.un('click', me.softReset, me); + me.buttonAction.un("click", me.doAction, me); + me.buttonReset.un("click", me.softReset, me); - me.store.getProxy().un('exception', me.onProxyException, me); - me.store.un('write', me.softReset, me); + me.store.getProxy().un("exception", me.onProxyException, me); + me.store.un("write", me.softReset, me); me.callParent(arguments); }, @@ -204,7 +204,7 @@ Ext.define('Dbui.form.Panel', { newRecord; // No action on non-valid form except destroy - if (me.currantAction !== 'destroy' && !form.isValid()) { + if (me.currantAction !== "destroy" && !form.isValid()) { return; } @@ -214,23 +214,23 @@ Ext.define('Dbui.form.Panel', { switch (me.currentAction) { - case 'create': + case "create": newRecord = model.create(); me.updateRecord(newRecord); me.addRecord(newRecord); break; - case 'destroy': + case "destroy": me.store.remove(me.currentRecord); break; - case 'duplicate': + case "duplicate": newRecord = model.create(); me.updateRecord(newRecord); me.addRecord(newRecord); break; - case 'update': + case "update": me.currentRecord.beginEdit(); me.updateRecord(me.currentRecord); me.currentRecord.endEdit(); @@ -322,39 +322,44 @@ Ext.define('Dbui.form.Panel', { switch (action) { - case 'create': + case "create": me.buttonAction.setText(me.textCreate); // load an empty record filled with default values - // NOTE ExtJS 6.0.1 - // - The method record.getData() contains the value the fiels id - // and for the field with default value but not for the others. + // NOTE ExtJS 6x + // - The method record.getData() contains the value for the field + // id and for the field with default value but not for the others. // - The form can contain values for the other fields due to // previous operation. The previous values are not overwritten - // by the methos form.loadRecord or form.setValues. + // by the method form.loadRecord or form.setValues. // - The solution is to defined a data block with values for - // all fields and toload it using form.setValues. - // - The form.reset is required to remove non valid flags. + // all fields and to load it using form.setValues. + // - Clear invalid field newRecord = me.store.getProxy().getModel().create(); data = {}; - fields = newRecord.getFields(); - for (i = 0; i < fields.length; i += 1) { - name = fields[i].getName(); - data[name] = newRecord.get(name); - } + newRecord.getFields().forEach(function (field) { + var name = field.getName(); + data[name] = newRecord.get(name); + }); + form.setValues(data); - form.reset(); + + form.getFields().each(function (field) { + field.clearInvalid(); + return true; + }); + break; - case 'destroy': + case "destroy": me.buttonAction.setText(me.textDestroy); form.loadRecord(record); break; - case 'duplicate': + case "duplicate": me.buttonAction.setText(me.textDuplicate); // create a copy without keeping the reference to internal objects @@ -369,12 +374,12 @@ Ext.define('Dbui.form.Panel', { form.loadRecord(newRecord); break; - case 'update': + case "update": me.buttonAction.setText(me.textUpdate); form.loadRecord(record); break; - case 'view': + case "view": me.buttonReset.hide(); me.buttonAction.hide(); form.loadRecord(record); @@ -418,14 +423,14 @@ Ext.define('Dbui.form.Panel', { // including those encapsulated in complexe field container // which encapsulated grid with cell editing... // - fields = me.query('> field'); - fields = Ext.Array.merge(fields, me.query('fieldset > field')); + fields = me.query("> field"); + fields = Ext.Array.merge(fields, me.query("fieldset > field")); // get the list of field container: // those at the first level and those encapsulated in fieldset - containers = me.query('> fieldcontainer'); - containers = Ext.Array.merge(containers, me.query('fieldset > fieldcontainer')); + containers = me.query("> fieldcontainer"); + containers = Ext.Array.merge(containers, me.query("fieldset > fieldcontainer")); // container handles two type of object: // - composite field merging several standard field @@ -436,8 +441,8 @@ Ext.define('Dbui.form.Panel', { // standard field container merging basic fields: // retrieve all basic fields - if (el.getXType() === 'fieldcontainer') { - Ext.Array.each(el.query('> field'), function (field) { + if (el.getXType() === "fieldcontainer") { + Ext.Array.each(el.query("> field"), function (field) { fields.push(field); }); @@ -465,7 +470,7 @@ Ext.define('Dbui.form.Panel', { // Ext.form.field.Date, used by the interface, is defined in the // property format. - case 'datefield': + case "datefield": if (Ext.isDate(value)) { value = Ext.util.Format.date(value, field.format); } @@ -476,7 +481,7 @@ Ext.define('Dbui.form.Panel', { // the valueField but note the display field. // The next lines append the displayField - case 'xcombobox': + case "xcombobox": combo = field; rec = combo.findRecord(combo.valueField, combo.getValue()); record.set(combo.displayField, rec.get(combo.displayField)); diff --git a/static/plugin_dbui/src/form/field/AceEditor.js b/static/plugin_dbui/src/form/field/AceEditor.js index 6719a61cb984a5cf968e9ba77e284181831bf7a9..62b73f3f8e326f471badc201ba6e3e90f5093ee9 100644 --- a/static/plugin_dbui/src/form/field/AceEditor.js +++ b/static/plugin_dbui/src/form/field/AceEditor.js @@ -9,13 +9,13 @@ * @since 0.4.15.0 * */ -Ext.define('Dbui.form.field.AceEditor', { +Ext.define("Dbui.form.field.AceEditor", { - extend: 'Ext.form.FieldContainer', + extend: "Ext.form.FieldContainer", mixins: { - field: 'Ext.form.field.Field' + field: "Ext.form.field.Field" }, - alias: 'widget.xaceeditorfield', + alias: "widget.xaceeditorfield", /** * @cfg {String} @@ -33,7 +33,7 @@ Ext.define('Dbui.form.field.AceEditor', { * @cfg {String} * The programming language javascript, python, .... */ - language: 'python', + language: "python", /** * @cfg {Number} editorHeight (required) @@ -44,7 +44,7 @@ Ext.define('Dbui.form.field.AceEditor', { /** * @cfg {String} */ - theme: 'crimson_editor', + theme: "crimson_editor", // private property editor: null, @@ -58,12 +58,12 @@ Ext.define('Dbui.form.field.AceEditor', { me.items = [{ height: me.editorHeight, - layout: 'fit', - style: 'border: 1px solid #99BCE8;', - xtype: 'component' + layout: "fit", + style: "border: 1px solid #99BCE8;", + xtype: "component" }]; - me.anchor = '100%'; + me.anchor = "100%"; me.callParent(arguments); me.initField(); @@ -81,9 +81,9 @@ Ext.define('Dbui.form.field.AceEditor', { // instantiate the editor if (!me.editor) { - me.editor = ace.edit(me.child('component').getId()); - me.editor.getSession().setMode('ace/mode/' + me.language); - me.editor.setTheme('ace/theme/' + me.theme); + me.editor = ace.edit(me.child("component").getId()); + me.editor.getSession().setMode("ace/mode/" + me.language); + me.editor.setTheme("ace/theme/" + me.theme); me.editor.setFontSize(me.fontSize); me.editor.setOption("fontFamily", me.fontFamily); } diff --git a/static/plugin_dbui/src/form/field/ComboBox.js b/static/plugin_dbui/src/form/field/ComboBox.js index 3af9cba25bf99cbe1e76eb1a8795bfb56e75fba6..b1716becf6b35b0453794025c80f646599bb766c 100644 --- a/static/plugin_dbui/src/form/field/ComboBox.js +++ b/static/plugin_dbui/src/form/field/ComboBox.js @@ -6,10 +6,10 @@ * in the initialization phase of the component. * */ -Ext.define('Dbui.form.field.ComboBox', { +Ext.define("Dbui.form.field.ComboBox", { - extend: 'Ext.form.field.ComboBox', - alias: 'widget.xcombobox', + extend: "Ext.form.field.ComboBox", + alias: "widget.xcombobox", /** * @cfg {Boolean} @@ -28,11 +28,11 @@ Ext.define('Dbui.form.field.ComboBox', { // In any case the value should belongs to the list. editable: true, forceSelection: true, - queryMode: 'local', - triggerAction: 'all', + queryMode: "local", + triggerAction: "all", // private properties for internationalization - textSelect: 'Select a ', + textSelect: "Select a ", // jshint strict: false @@ -59,7 +59,7 @@ Ext.define('Dbui.form.field.ComboBox', { // select the first value if (me.selectFirst) { - me.on('afterrender', me.selectFirstItem, me); + me.on("afterrender", me.selectFirstItem, me); } }, @@ -69,7 +69,7 @@ Ext.define('Dbui.form.field.ComboBox', { var me = this; if (me.selectFirst) { - me.un('afterrender', me.selectFirstItem, me); + me.un("afterrender", me.selectFirstItem, me); } me.callParent(arguments); @@ -87,7 +87,7 @@ Ext.define('Dbui.form.field.ComboBox', { // the store is not ready, reschedule the request if (!me.store.getCount()) { - me.store.on('load', me.selectFirstItem, me, { + me.store.on("load", me.selectFirstItem, me, { single: true }); return; diff --git a/static/plugin_dbui/src/form/field/ComboBoxMaster.js b/static/plugin_dbui/src/form/field/ComboBoxMaster.js index 938431382c3398713955234deab5111d199ac8eb..ef5c0475267f7980a4eef913d7124bde2ebc8300 100644 --- a/static/plugin_dbui/src/form/field/ComboBoxMaster.js +++ b/static/plugin_dbui/src/form/field/ComboBoxMaster.js @@ -24,11 +24,11 @@ * @since 0.6.0.0 * */ -Ext.define('Dbui.form.field.ComboBoxMaster', { +Ext.define("Dbui.form.field.ComboBoxMaster", { - extend: 'Ext.form.field.ComboBox', - alias: 'widget.xcomboboxmaster', - uses: ['Ext.data.ArrayStore'], + extend: "Ext.form.field.ComboBox", + alias: "widget.xcomboboxmaster", + uses: ["Ext.data.ArrayStore"], /** * @cfg {Ext.data.Store/String} refStore (required) @@ -52,12 +52,12 @@ Ext.define('Dbui.form.field.ComboBoxMaster', { // In any case the value should belongs to the list. editable: true, forceSelection: true, - queryMode: 'local', - triggerAction: 'all', + queryMode: "local", + triggerAction: "all", // private properties model: null, - textSelect: 'Select a ', + textSelect: "Select a ", // jshint strict: false @@ -78,10 +78,10 @@ Ext.define('Dbui.form.field.ComboBoxMaster', { // instantiate the model containing values // its name contains 3 characters generated randomly - modelName = me.displayField + '-'+ Math.round(Math.random()*1000); + modelName = me.displayField + "-"+ Math.round(Math.random()*1000); me.model = Ext.define(modelName, { - extend: 'Ext.data.Model', + extend: "Ext.data.Model", fields: [ me.displayField, me.valueField @@ -89,7 +89,7 @@ Ext.define('Dbui.form.field.ComboBoxMaster', { }); // build the local store containing values - me.store = Ext.create('Ext.data.Store', { + me.store = Ext.create("Ext.data.Store", { model: me.model }); @@ -100,13 +100,13 @@ Ext.define('Dbui.form.field.ComboBoxMaster', { me.createLocalStore(); // Update the local store when the refStore is modified - me.refStore.on('remove', me.createLocalStore, me); - me.refStore.on('update', me.createLocalStore, me); - me.refStore.on('write', me.createLocalStore, me); + me.refStore.on("remove", me.createLocalStore, me); + me.refStore.on("update", me.createLocalStore, me); + me.refStore.on("write", me.createLocalStore, me); // user reset if (me.userReset) { - me.on('select', me.onSelect); + me.on("select", me.onSelect); } }, @@ -115,12 +115,12 @@ Ext.define('Dbui.form.field.ComboBoxMaster', { var me = this; - me.refStore.un('remove', me.createLocalStore, me); - me.refStore.un('update', me.createLocalStore, me); - me.refStore.un('write', me.createLocalStore, me); + me.refStore.un("remove", me.createLocalStore, me); + me.refStore.un("update", me.createLocalStore, me); + me.refStore.un("write", me.createLocalStore, me); if (me.userReset) { - me.un('select', me.onSelect); + me.un("select", me.onSelect); } me.callParent(arguments); diff --git a/static/plugin_dbui/src/form/field/ComboBoxSlave.js b/static/plugin_dbui/src/form/field/ComboBoxSlave.js index bc05ece2567a0448d837598db03fd8e91c00af14..8c3fdd6acc39d1a631a1722b7c3799003b16401d 100644 --- a/static/plugin_dbui/src/form/field/ComboBoxSlave.js +++ b/static/plugin_dbui/src/form/field/ComboBoxSlave.js @@ -4,11 +4,11 @@ * @since 0.6.0.0 * */ -Ext.define('Dbui.form.field.ComboBoxSlave', { +Ext.define("Dbui.form.field.ComboBoxSlave", { - extend: 'Ext.form.field.ComboBox', - alias: 'widget.xcomboboxslave', - uses: ['Ext.data.Model', 'Ext.data.Store'], + extend: "Ext.form.field.ComboBox", + alias: "widget.xcomboboxslave", + uses: ["Ext.data.Model", "Ext.data.Store"], /** @@ -37,12 +37,12 @@ Ext.define('Dbui.form.field.ComboBoxSlave', { // In any case the value should belongs to the list. editable: true, forceSelection: true, - queryMode: 'local', - triggerAction: 'all', + queryMode: "local", + triggerAction: "all", // private properties model: null, - textSelect: 'Select a ', + textSelect: "Select a ", // jshint strict: false @@ -64,11 +64,11 @@ Ext.define('Dbui.form.field.ComboBoxSlave', { // instantiate the model containing values // its name contains 3 characters generated randomly modelName = me.masterValueField + - me.displayField + '-'+ + me.displayField + "-"+ Math.round(Math.random()*1000); me.model = Ext.define(modelName, { - extend: 'Ext.data.Model', + extend: "Ext.data.Model", fields: [ me.masterValueField, me.displayField, @@ -77,7 +77,7 @@ Ext.define('Dbui.form.field.ComboBoxSlave', { }); // build the local store containing values - me.store = Ext.create('Ext.data.Store', { + me.store = Ext.create("Ext.data.Store", { model: me.model }); @@ -89,14 +89,14 @@ Ext.define('Dbui.form.field.ComboBoxSlave', { // Bind the slave to the master widget. // Can only be done when widgets exists. - me.on('afterrender', me.bindToMaster, me, { + me.on("afterrender", me.bindToMaster, me, { single: true }); // update the local store is the refStore is modified - me.refStore.on('remove', me.createLocalStore, me); - me.refStore.on('update', me.createLocalStore, me); - me.refStore.on('write', me.createLocalStore, me); + me.refStore.on("remove", me.createLocalStore, me); + me.refStore.on("update", me.createLocalStore, me); + me.refStore.on("write", me.createLocalStore, me); }, // private method requires by the ExtJS component model @@ -104,9 +104,9 @@ Ext.define('Dbui.form.field.ComboBoxSlave', { var me = this; - me.refStore.un('remove', me.createLocalStore, me); - me.refStore.un('update', me.createLocalStore, me); - me.refStore.un('write', me.createLocalStore, me); + me.refStore.un("remove", me.createLocalStore, me); + me.refStore.un("update", me.createLocalStore, me); + me.refStore.un("write", me.createLocalStore, me); me.callParent(arguments); }, @@ -150,11 +150,11 @@ Ext.define('Dbui.form.field.ComboBoxSlave', { // Find the master widget // Assume that it is above in the widget stack. // Not the optimal way but failed to use this.up(path) ??? - var path = 'xcomboboxmaster[itemId=' + me.masterItemId + ']', + var path = "xcomboboxmaster[itemId=" + me.masterItemId + "]", master = me.getRefOwner().query(path)[0], masterValue = master.getValue(); - master.on('change', me.onMasterChange, me); + master.on("change", me.onMasterChange, me); // initialize the comboBox. me.store.clearFilter(true); diff --git a/static/plugin_dbui/src/form/field/ComboBoxUserReset.js b/static/plugin_dbui/src/form/field/ComboBoxUserReset.js index 26412023c8e4eca4af176f27f44f78e6e5da76f3..031b830480be54cd5df7c667659147a3b127ded6 100644 --- a/static/plugin_dbui/src/form/field/ComboBoxUserReset.js +++ b/static/plugin_dbui/src/form/field/ComboBoxUserReset.js @@ -6,17 +6,17 @@ * @since 0.6.0.6 * */ -Ext.define('Dbui.form.field.ComboBoxUserReset', { +Ext.define("Dbui.form.field.ComboBoxUserReset", { - extend: 'Dbui.form.field.ComboBox', - alias: 'widget.xcomboboxuserreset', + extend: "Dbui.form.field.ComboBox", + alias: "widget.xcomboboxuserreset", /** * @cfg {String} emptyText (required) * Define the content of the first row which is used to reset the ComboBox. * EmptyText matches the displayField while emptyId matches valueField */ - emptyText: 'select...', + emptyText: "select...", /** * @cfg {Number/String} emptyValue (required) @@ -41,12 +41,12 @@ Ext.define('Dbui.form.field.ComboBoxUserReset', { // follow evolution of the reference store me.refStore = me.store; - me.refStore.on('datachanged', me.onRefStoreChange, me); - me.refStore.on('load', me.onRefStoreLoad, me); - me.refStore.on('update', me.onRefStoreChange, me); + me.refStore.on("datachanged", me.onRefStoreChange, me); + me.refStore.on("load", me.onRefStoreLoad, me); + me.refStore.on("update", me.onRefStoreChange, me); // logic to reset the ComboBox when the first item is choosen - me.on('select', me.onSelect, me); + me.on("select", me.onSelect, me); // store is already load if (me.refStore.isLoaded()) { @@ -59,11 +59,11 @@ Ext.define('Dbui.form.field.ComboBoxUserReset', { var me = this; - me.refStore.un('datachanged', me.onRefStoreChange, me); - me.refStore.un('load', me.onRefStoreLoad, me); - me.refStore.un('update', me.onRefStoreChange, me); + me.refStore.un("datachanged", me.onRefStoreChange, me); + me.refStore.un("load", me.onRefStoreLoad, me); + me.refStore.un("update", me.onRefStoreChange, me); - me.on('select', me.onSelect, me); + me.on("select", me.onSelect, me); me.callParent(arguments); }, @@ -117,7 +117,7 @@ Ext.define('Dbui.form.field.ComboBoxUserReset', { }); // create a new local store with the additional item - store = Ext.create('Ext.data.Store', { + store = Ext.create("Ext.data.Store", { model: me.store.model }); diff --git a/static/plugin_dbui/src/form/field/Dict.js b/static/plugin_dbui/src/form/field/Dict.js index 273c0dad003f0a4c4485461f6671b2ba725465e9..db86458e632a27daa02a91657169994ac53a5fbd 100644 --- a/static/plugin_dbui/src/form/field/Dict.js +++ b/static/plugin_dbui/src/form/field/Dict.js @@ -7,7 +7,7 @@ * the configuration option #value: * { * "(name)": "My Object", - * "Created": new Date(Date.parse('10/15/2006')), + * "Created": new Date(Date.parse("10/15/2006")), * "Available": false, * "Version": .01, * "Description": "A test object" diff --git a/static/plugin_dbui/src/form/field/List.js b/static/plugin_dbui/src/form/field/List.js index 8dc1b7d7ae5ea94843755e4e8d6d4bb2dedbd545..f59e1cca7c6a6c5498eddef9b04bf9e2189bf8b0 100644 --- a/static/plugin_dbui/src/form/field/List.js +++ b/static/plugin_dbui/src/form/field/List.js @@ -7,19 +7,19 @@ * @since 0.4.15.0 * */ -Ext.define('Dbui.form.field.List', { +Ext.define("Dbui.form.field.List", { - extend: 'Ext.form.FieldContainer', + extend: "Ext.form.FieldContainer", mixins: { - field: 'Ext.form.field.Field' + field: "Ext.form.field.Field" }, - alias: 'widget.xlistfield', + alias: "widget.xlistfield", uses: [ - 'Ext.data.ArrayStore', - 'Ext.form.field.Text', - 'Ext.grid.Panel', - 'Ext.grid.plugin.CellEditing', - 'Ext.menu.Menu' + "Ext.data.ArrayStore", + "Ext.form.field.Text", + "Ext.grid.Panel", + "Ext.grid.plugin.CellEditing", + "Ext.menu.Menu" ], /** @@ -38,7 +38,7 @@ Ext.define('Dbui.form.field.List', { * @cfg {string} * The label of the column to be shown in the grid widget. */ - header: 'Element', + header: "Element", /** * @cfg {boolean} @@ -69,9 +69,9 @@ Ext.define('Dbui.form.field.List', { */ // Predefined configuration options - layout: 'anchor', + layout: "anchor", defaults: { - anchor: '100%' + anchor: "100%" }, // private short cuts @@ -83,11 +83,11 @@ Ext.define('Dbui.form.field.List', { store: null, // private properties for internationalization - textAdd: 'Insert element', - textDestroy: 'Delete element', - textDestroyTitle: 'Are you sure to destroy the element', - textGoDown: 'Move down', - textGoUp: 'Move up', + textAdd: "Insert element", + textDestroy: "Delete element", + textDestroyTitle: "Are you sure to destroy the element", + textGoDown: "Move down", + textGoUp: "Move up", // jshint strict: false @@ -106,9 +106,9 @@ Ext.define('Dbui.form.field.List', { data.push([]); } - me.store = Ext.create('Ext.data.ArrayStore', { + me.store = Ext.create("Ext.data.ArrayStore", { fields: [{ - name: 'element' + name: "element" }], data: data }); @@ -118,75 +118,75 @@ Ext.define('Dbui.form.field.List', { // when a cell is edited it is not marked dirty me.items = [{ columns: [{ - dataIndex: 'element', - editor: 'textfield', + dataIndex: "element", + editor: "textfield", flex: 1, - itemId: 'element', + itemId: "element", sortable: false, text: me.header }], hideHeaders: me.hideHeader, plugins: { - ptype: 'cellediting', - triggerEvent: 'cellclick' + ptype: "cellediting", + triggerEvent: "cellclick" }, - selType: 'cellmodel', + selType: "cellmodel", store: me.store, viewConfig: { markDirty: false }, - xtype: 'grid' + xtype: "grid" }]; me.callParent(arguments); // instantiate the context menu - me.menu = Ext.create('Ext.menu.Menu', { + me.menu = Ext.create("Ext.menu.Menu", { items: [{ text: me.textAdd, - iconCls: 'xaction-create', - itemId: 'add', + iconCls: "xaction-create", + itemId: "add", handler: me.onAddRow, scope: me - }, '-', { + }, "-", { text: me.textGoUp, - iconCls: 'xaction-go-up', - itemId: 'goUp', + iconCls: "xaction-go-up", + itemId: "goUp", handler: me.onGoUp, scope: me }, { text: me.textGoDown, - iconCls: 'xaction-go-down', - itemId: 'goDown', + iconCls: "xaction-go-down", + itemId: "goDown", handler: me.onGoDown, scope: me - }, '-', { + }, "-", { text: me.textDestroy, - iconCls: 'xaction-destroy', - itemId: 'destroy', + iconCls: "xaction-destroy", + itemId: "destroy", handler: me.onDeleteRow, scope: me }] }); // handler associate to the grid - grid = me.child('grid'); + grid = me.child("grid"); - grid.on('containercontextmenu', me.onContainerContextMenu, me); - grid.on('itemcontextmenu', me.onItemContextMenu, me); + grid.on("containercontextmenu", me.onContainerContextMenu, me); + grid.on("itemcontextmenu", me.onItemContextMenu, me); me.grid = grid; // handler associated to the cellEditing // avoid editing when the menu is visible - cellEditing = grid.findPlugin('cellediting'); - cellEditing.on('beforeedit', me.onBeforeEdit, me); - cellEditing.on('edit', me.onEdit, me); + cellEditing = grid.findPlugin("cellediting"); + cellEditing.on("beforeedit", me.onBeforeEdit, me); + cellEditing.on("edit", me.onEdit, me); me.cellEditing = cellEditing; // handler associated to the store - me.store.on('update', me.onStoreUpdate, me); + me.store.on("update", me.onStoreUpdate, me); // initialize the mixin Field me.initField(); @@ -197,15 +197,15 @@ Ext.define('Dbui.form.field.List', { var me = this; - me.cellEditing.un('beforeedit', me.onBeforeEdit, me); - me.cellEditing.un('edit', me.onEdit, me); + me.cellEditing.un("beforeedit", me.onBeforeEdit, me); + me.cellEditing.un("edit", me.onEdit, me); - me.grid.un('containercontextmenu', me.onContainerContextMenu, me); - me.grid.un('itemcontextmenu', me.onItemContextMenu, me); + me.grid.un("containercontextmenu", me.onContainerContextMenu, me); + me.grid.un("itemcontextmenu", me.onItemContextMenu, me); - Ext.destroyMembers(me, 'grid'); - Ext.destroyMembers(me, 'menu'); - Ext.destroyMembers(me, 'store'); + Ext.destroyMembers(me, "grid"); + Ext.destroyMembers(me, "menu"); + Ext.destroyMembers(me, "store"); me.callParent(arguments); }, @@ -310,9 +310,9 @@ Ext.define('Dbui.form.field.List', { event.stopEvent(); - me.menu.getComponent('destroy').setDisabled(true); - me.menu.getComponent('goDown').setDisabled(true); - me.menu.getComponent('goUp').setDisabled(true); + me.menu.getComponent("destroy").setDisabled(true); + me.menu.getComponent("goDown").setDisabled(true); + me.menu.getComponent("goUp").setDisabled(true); me.rowIndex = -1; me.menu.showAt(event.getXY()); @@ -329,7 +329,7 @@ Ext.define('Dbui.form.field.List', { value = me.record.get("element"); Ext.Msg.confirm(me.textDestroyTitle, value, function (btn) { - if (btn === 'yes') { + if (btn === "yes") { me.store.remove(me.record); } }, me); @@ -365,11 +365,11 @@ Ext.define('Dbui.form.field.List', { recordA = me.store.getAt(me.rowIndex); recordB = me.store.getAt(me.rowIndex + 1); - valueA = recordA.get('element'); - valueB = recordB.get('element'); + valueA = recordA.get("element"); + valueB = recordB.get("element"); - recordA.set('element', valueB); - recordB.set('element', valueA); + recordA.set("element", valueB); + recordB.set("element", valueA); }, /** @@ -388,11 +388,11 @@ Ext.define('Dbui.form.field.List', { recordA = me.store.getAt(me.rowIndex); recordB = me.store.getAt(me.rowIndex - 1); - valueA = recordA.get('element'); - valueB = recordB.get('element'); + valueA = recordA.get("element"); + valueB = recordB.get("element"); - recordA.set('element', valueB); - recordB.set('element', valueA); + recordA.set("element", valueB); + recordB.set("element", valueA); }, /** @@ -424,16 +424,16 @@ Ext.define('Dbui.form.field.List', { me.menu.showAt(event.getXY()); - me.menu.getComponent('destroy').setDisabled(false); - me.menu.getComponent('goDown').setDisabled(false); - me.menu.getComponent('goUp').setDisabled(false); + me.menu.getComponent("destroy").setDisabled(false); + me.menu.getComponent("goDown").setDisabled(false); + me.menu.getComponent("goUp").setDisabled(false); if (index === 0) { - me.menu.getComponent('goUp').setDisabled(true); + me.menu.getComponent("goUp").setDisabled(true); } if (index === me.store.getCount() - 1) { - me.menu.getComponent('goDown').setDisabled(true); + me.menu.getComponent("goDown").setDisabled(true); } }, @@ -447,7 +447,7 @@ Ext.define('Dbui.form.field.List', { "use strict"; var me = this; - me.fireEvent('change', me); + me.fireEvent("change", me); }, /** diff --git a/static/plugin_dbui/src/form/field/Property.js b/static/plugin_dbui/src/form/field/Property.js index b136f4790be899708c79be59164de1afa79891d6..baf42a14df31923aff46d1202dd25bf3c2b7b550 100644 --- a/static/plugin_dbui/src/form/field/Property.js +++ b/static/plugin_dbui/src/form/field/Property.js @@ -129,8 +129,14 @@ Ext.define("Dbui.form.field.Property", { "use strict"; + // NOTE + // The property initalValue is defined by the mixin + // Ext.form.field.Field in the method initValue. + // This property is not public but useful to get the default value + // in sequence like new, actualiser row2, new, .... + // var me = this, - source = value || me.originalValue; + source = value || me.initialValue || {}; me.grid.setSource(source); diff --git a/static/plugin_dbui/src/form/field/Table.js b/static/plugin_dbui/src/form/field/Table.js index 6efe69219439459797774a0bff2a9884b540acd4..a5c5aa25732208aacdeebf7af8de623b1fff4d68 100644 --- a/static/plugin_dbui/src/form/field/Table.js +++ b/static/plugin_dbui/src/form/field/Table.js @@ -11,17 +11,17 @@ * @since 0.9.3 * */ -Ext.define('Dbui.form.field.Table', { +Ext.define("Dbui.form.field.Table", { - extend: 'Ext.form.FieldContainer', + extend: "Ext.form.FieldContainer", mixins: { - field: 'Ext.form.field.Field' + field: "Ext.form.field.Field" }, - alias: 'widget.xtablefield', + alias: "widget.xtablefield", uses: [ - 'Ext.data.ArrayStore', - 'Ext.grid.Panel', - 'Ext.grid.plugin.CellEditing' + "Ext.data.ArrayStore", + "Ext.grid.Panel", + "Ext.grid.plugin.CellEditing" ], /** @@ -60,9 +60,9 @@ Ext.define('Dbui.form.field.Table', { */ // Predefined configuration options - layout: 'anchor', + layout: "anchor", defaults: { - anchor: '100%' + anchor: "100%" }, // private short cuts @@ -88,7 +88,7 @@ Ext.define('Dbui.form.field.Table', { } // instantiate the store - me.store = Ext.create('Ext.data.ArrayStore', { + me.store = Ext.create("Ext.data.ArrayStore", { fields: header, data: me.initData() }); @@ -103,7 +103,7 @@ Ext.define('Dbui.form.field.Table', { name = header[i]; cfgColumns.push({ dataIndex: name, - editor: 'textfield', + editor: "textfield", flex: 1, itemId: name, sortable: false, @@ -119,29 +119,29 @@ Ext.define('Dbui.form.field.Table', { columnLines: true, hideHeaders: me.hideHeader, plugins: { - ptype: 'cellediting', - triggerEvent: 'cellclick' + ptype: "cellediting", + triggerEvent: "cellclick" }, - selType: 'cellmodel', + selType: "cellmodel", store: me.store, viewConfig: { markDirty: false }, - xtype: 'grid' + xtype: "grid" }]; me.callParent(arguments); // handler associate to the grid - grid = me.child('grid'); + grid = me.child("grid"); - grid.on('containercontextmenu', me.onContainerContextMenu, me); - grid.on('itemcontextmenu', me.onItemContextMenu, me); + grid.on("containercontextmenu", me.onContainerContextMenu, me); + grid.on("itemcontextmenu", me.onItemContextMenu, me); me.grid = grid; // handler associated to the store - me.store.on('update', me.onStoreUpdate, me); + me.store.on("update", me.onStoreUpdate, me); // initialize the mixin Field me.initField(); @@ -152,11 +152,11 @@ Ext.define('Dbui.form.field.Table', { var me = this; - me.grid.un('containercontextmenu', me.onContainerContextMenu, me); - me.grid.un('itemcontextmenu', me.onItemContextMenu, me); + me.grid.un("containercontextmenu", me.onContainerContextMenu, me); + me.grid.un("itemcontextmenu", me.onItemContextMenu, me); - Ext.destroyMembers(me, 'grid'); - Ext.destroyMembers(me, 'store'); + Ext.destroyMembers(me, "grid"); + Ext.destroyMembers(me, "store"); me.callParent(arguments); }, @@ -252,7 +252,7 @@ Ext.define('Dbui.form.field.Table', { "use strict"; var me = this; - me.fireEvent('change', me); + me.fireEvent("change", me); }, /** diff --git a/static/plugin_dbui/src/form/field/TextPicker.js b/static/plugin_dbui/src/form/field/TextPicker.js index 3e74b14ed245363030c6fb219c2a03e21526c9d5..6dc73e3cbdf3ff9d07f74953d86043247883f559 100644 --- a/static/plugin_dbui/src/form/field/TextPicker.js +++ b/static/plugin_dbui/src/form/field/TextPicker.js @@ -12,11 +12,11 @@ * @since 0.6.2.4 * */ -Ext.define('Dbui.form.field.TextPicker', { +Ext.define("Dbui.form.field.TextPicker", { - extend: 'Ext.form.field.Picker', - alias: 'widget.xtextpicker', - uses: ['Ext.form.field.TextArea'], + extend: "Ext.form.field.Picker", + alias: "widget.xtextpicker", + uses: ["Ext.form.field.TextArea"], /** * @cfg {Number} @@ -52,7 +52,7 @@ Ext.define('Dbui.form.field.TextPicker', { floating: true, rows: me.rows, shadow: false, - xtype: 'textareafield' + xtype: "textareafield" }; picker = me.picker = Ext.widget(cfg); diff --git a/static/plugin_dbui/src/form/plugin/Mapper.js b/static/plugin_dbui/src/form/plugin/Mapper.js index e8581a23df2edfb6f5307929db99a66265b40a4c..2733350b65866e46af69e1a6bfd7d768821a01c5 100644 --- a/static/plugin_dbui/src/form/plugin/Mapper.js +++ b/static/plugin_dbui/src/form/plugin/Mapper.js @@ -9,18 +9,18 @@ * @since 0.9.5 * */ -Ext.define('Dbui.form.plugin.Mapper', { +Ext.define("Dbui.form.plugin.Mapper", { - extend: 'Ext.AbstractPlugin', - alias: 'plugin.pMapper', + extend: "Ext.AbstractPlugin", + alias: "plugin.pMapper", /** * @cfg {String} layout * The layout for the new organisation of the fields, e.g accordion, card: * * { - * 'type': 'accordion', - * 'titleCollapse': True + * "type": "accordion", + * "titleCollapse": True * } * */ @@ -31,12 +31,12 @@ Ext.define('Dbui.form.plugin.Mapper', { * for example for an accordion layout: * * [{ - * title: 'panel1', - * layout: 'fit', - * items: ['fieldname4', 'fieldname2'] + * title: "panel1", + * layout: "fit", + * items: ["fieldname4", "fieldname2"] * }, { - * title: 'panel2', - * items: ['fieldname3', 'fieldname1'] + * title: "panel2", + * items: ["fieldname3", "fieldname1"] * }] * */ diff --git a/static/plugin_dbui/src/form/plugin/RegExp.js b/static/plugin_dbui/src/form/plugin/RegExp.js index 65c700951cd905bee9cab401d7bb23ad3c2c9ab0..850a701d64758b88774bc772dfaba5d7ed894796 100644 --- a/static/plugin_dbui/src/form/plugin/RegExp.js +++ b/static/plugin_dbui/src/form/plugin/RegExp.js @@ -3,10 +3,10 @@ * by a regular expression object. * */ -Ext.define('Dbui.form.plugin.RegExp', { +Ext.define("Dbui.form.plugin.RegExp", { - extend: 'Ext.AbstractPlugin', - alias: 'plugin.pRegExp', + extend: "Ext.AbstractPlugin", + alias: "plugin.pRegExp", /** * Initialize the plugin. diff --git a/static/plugin_dbui/src/form/plugin/ToolTip.js b/static/plugin_dbui/src/form/plugin/ToolTip.js index 93aa1acdc7c8dd73b4e5711efc0fa8c34f95a73a..3abd7d37a426bfe41660c8e87ff95dc19bb6c0a5 100644 --- a/static/plugin_dbui/src/form/plugin/ToolTip.js +++ b/static/plugin_dbui/src/form/plugin/ToolTip.js @@ -7,10 +7,10 @@ * field configuration option: *tipText*. * */ -Ext.define('Dbui.form.plugin.ToolTip', { +Ext.define("Dbui.form.plugin.ToolTip", { - extend: 'Ext.AbstractPlugin', - alias: 'plugin.pFormToolTip', + extend: "Ext.AbstractPlugin", + alias: "plugin.pFormToolTip", /** * Initialize the plugin. @@ -43,7 +43,7 @@ Ext.define('Dbui.form.plugin.ToolTip', { fields.each(function (field) { if (field.tipText) { - field.on('render', createToolTip); + field.on("render", createToolTip); } }); } diff --git a/static/plugin_dbui/src/grid/Filter.js b/static/plugin_dbui/src/grid/Filter.js index 0c302aef22315ef2735d02f9a00ea79181e71fa0..e11b03e8bcf84006e9fd2ff53897f8a46f3c0584 100644 --- a/static/plugin_dbui/src/grid/Filter.js +++ b/static/plugin_dbui/src/grid/Filter.js @@ -4,11 +4,11 @@ * according to the value defined in the fields. * */ -Ext.define('Dbui.grid.Filter', { +Ext.define("Dbui.grid.Filter", { - extend: 'Ext.form.FieldSet', - alias: 'widget.xgridfilter', - requires: 'Dbui.grid.button.ExpertMenu', + extend: "Ext.form.FieldSet", + alias: "widget.xgridfilter", + requires: "Dbui.grid.button.ExpertMenu", statics: { @@ -59,7 +59,7 @@ Ext.define('Dbui.grid.Filter', { // the enableKeyEvents is mandatory for Ext.form.field.Text // defaults: { - anchor: '100%', + anchor: "100%", enableKeyEvents: true }, @@ -100,15 +100,15 @@ Ext.define('Dbui.grid.Filter', { "use strict"; var me = this, - buttons = grid.query('xgridbuttonexpertmenu'), + buttons = grid.query("xgridbuttonexpertmenu"), buttonReset; me.grid = grid; // clicking the reset button of the grid reset the filter's fields. if (buttons && buttons[0] && buttons[0].menu) { - buttonReset = buttons[0].menu.getComponent('buttonReset'); - buttonReset.on('click', me.onReset, me); + buttonReset = buttons[0].menu.getComponent("buttonReset"); + buttonReset.on("click", me.onReset, me); } }, @@ -127,16 +127,16 @@ Ext.define('Dbui.grid.Filter', { filter, li, property; // build the field identifier for the store - li = field.name.substr(1, field.name.length - 2).split('.'); + li = field.name.substr(1, field.name.length - 2).split("."); property = Dbui.encodeField(li[0], li[1]); // polish the pair operator, value - // contains are not case sensitive → 'i' + // contains are not case sensitive → "i" if (operator === "==") { - operator = '='; + operator = "="; } else if (operator === "contains") { - value = new RegExp(".*" + value + ".*", 'i'); + value = new RegExp(".*" + value + ".*", "i"); operator = undefined; } @@ -168,11 +168,11 @@ Ext.define('Dbui.grid.Filter', { toJSON = Dbui.grid.Filter.valueToJSON, vdict; - if (fieldType === 'datefield' && value instanceof Date) { + if (fieldType === "datefield" && value instanceof Date) { value = Ext.util.Format.date(value, field.format); - } else if (fieldType === 'xdictfield') { + } else if (fieldType === "xdictfield") { // // A dict is a collection of (key, value) pairs @@ -190,7 +190,7 @@ Ext.define('Dbui.grid.Filter', { vdict = ""; Ext.Object.each(value, function (prop, val) { var s = '"' + prop + '": ' + toJSON(val); - vdict += (vdict.length > 0 ? '%' + s : s); + vdict += (vdict.length > 0 ? "%" + s : s); }); // the database is filtered by the LIKE operator, add joker % @@ -343,12 +343,12 @@ Ext.define('Dbui.grid.Filter', { case "xcomboboxmaster": case "xcomboboxslave": case "xcomboboxuserreset": - field.on('select', me.onChange, me); + field.on("select", me.onChange, me); break; case "datefield": case "timefield": - field.on('change', me.onChange, me, { + field.on("change", me.onChange, me, { buffer: 1000 }); break; @@ -357,7 +357,7 @@ Ext.define('Dbui.grid.Filter', { case "textfield": case "textarea": case "textareafield": - field.on('change', me.onChange, me, { + field.on("change", me.onChange, me, { buffer: 500 }); break; @@ -371,7 +371,7 @@ Ext.define('Dbui.grid.Filter', { break; default: - field.on('change', me.onChange, me); + field.on("change", me.onChange, me); } }); } diff --git a/static/plugin_dbui/src/grid/Panel.js b/static/plugin_dbui/src/grid/Panel.js index 01021c1497fb0b5c692afba74fa9dec06971d3bc..8a0aa9335bfbe3d41d139d316d7869f69d997c11 100644 --- a/static/plugin_dbui/src/grid/Panel.js +++ b/static/plugin_dbui/src/grid/Panel.js @@ -9,25 +9,25 @@ * Dbui.grid.plugin.RowEditor, .... * */ -Ext.define('Dbui.grid.Panel', { +Ext.define("Dbui.grid.Panel", { - extend: 'Ext.grid.Panel', - alias: 'widget.xgrid', + extend: "Ext.grid.Panel", + alias: "widget.xgrid", mixins: { - csv: 'Dbui.grid.mixin.ExportCSV', - latex: 'Dbui.grid.mixin.ExportLatex' + csv: "Dbui.grid.mixin.ExportCSV", + latex: "Dbui.grid.mixin.ExportLatex" }, requires: [ - 'Ext.grid.column.*', - 'Ext.grid.feature.*', - 'Dbui.grid.column.Json', - 'Dbui.grid.plugin.Export', - 'Dbui.grid.plugin.Paging', - 'Dbui.grid.plugin.RowEditorConfirmDelete', - 'Dbui.grid.plugin.RowEditorContextMenu', - 'Dbui.grid.plugin.RowEditorDblClick', - 'Dbui.grid.plugin.RowEditorToolbar', - 'Dbui.grid.plugin.Toolbar' + "Ext.grid.column.*", + "Ext.grid.feature.*", + "Dbui.grid.column.Json", + "Dbui.grid.plugin.Export", + "Dbui.grid.plugin.Paging", + "Dbui.grid.plugin.RowEditorConfirmDelete", + "Dbui.grid.plugin.RowEditorContextMenu", + "Dbui.grid.plugin.RowEditorDblClick", + "Dbui.grid.plugin.RowEditorToolbar", + "Dbui.grid.plugin.Toolbar" ], // private properties @@ -54,7 +54,7 @@ Ext.define('Dbui.grid.Panel', { // Set the remote actions for the buffered store if (me.store.buffered) { - me.store.getProxy().pageParam = 'page'; + me.store.getProxy().pageParam = "page"; me.remoteAction = true; } @@ -62,11 +62,11 @@ Ext.define('Dbui.grid.Panel', { // this action depend on the grid properties and plugin. // At that step the plugins are not yet instantiate. // Thus wait the last moment. - me.on('beforerender', me.onBeforeRender, me); + me.on("beforerender", me.onBeforeRender, me); // Reload he store when sort condition changed and // when the remoteAction is true - me.on('sortchange', me.onSort, me); + me.on("sortchange", me.onSort, me); }, // Private method requires by the Ext JS component model @@ -74,8 +74,8 @@ Ext.define('Dbui.grid.Panel', { var me = this; - me.un('beforerender', me.onBeforeRender, me); - me.un('sortchange', me.onSort, me); + me.un("beforerender", me.onBeforeRender, me); + me.un("sortchange", me.onSort, me); // reset the store me.reset(); diff --git a/static/plugin_dbui/src/grid/button/ExpertMenu.js b/static/plugin_dbui/src/grid/button/ExpertMenu.js index 2864767102302bcd78acdcb349ff43f21f7a6f36..13cd117e89911f868e4a93cf26ff06df4c8180d9 100644 --- a/static/plugin_dbui/src/grid/button/ExpertMenu.js +++ b/static/plugin_dbui/src/grid/button/ExpertMenu.js @@ -5,10 +5,10 @@ * This is private class to be used in the Dbui.panel.Grid tool bars. * */ -Ext.define('Dbui.grid.button.ExpertMenu', { +Ext.define("Dbui.grid.button.ExpertMenu", { - extend: 'Ext.button.Split', - alias: 'widget.xgridbuttonexpertmenu', + extend: "Ext.button.Split", + alias: "widget.xgridbuttonexpertmenu", /* * @cfg {Dbui.panel.Grid} grid (required) @@ -18,9 +18,9 @@ Ext.define('Dbui.grid.button.ExpertMenu', { buttonMathJax: null, // Private properties for internationalisation - textExport: 'Export to CSV file', - textMathJax: 'Render equations', - textReset: 'Reset', + textExport: "Export to CSV file", + textMathJax: "Render equations", + textReset: "Reset", // jshint strict: false @@ -35,7 +35,7 @@ Ext.define('Dbui.grid.button.ExpertMenu', { // the menu configuration me.menu = { items: [{ - itemId: 'buttonReset', + itemId: "buttonReset", listeners: { click: me.onReset, scope: me @@ -43,20 +43,20 @@ Ext.define('Dbui.grid.button.ExpertMenu', { text: me.textReset }, { - href: Dbui.csvUrl + '?tableName=' + tableName, - itemId: 'buttonExport', + href: Dbui.csvUrl + "?tableName=" + tableName, + itemId: "buttonExport", text: me.textExport }] }; // add check item to activate deactivate MathJax processing - pMathJax = me.grid.findPlugin('pMathJax'); + pMathJax = me.grid.findPlugin("pMathJax"); if (pMathJax) { me.menu.items.push({ checked: pMathJax.activated, - itemId: 'buttonMathJax', + itemId: "buttonMathJax", text: me.textMathJax, - xtype: 'menucheckitem' + xtype: "menucheckitem" }); } @@ -65,8 +65,8 @@ Ext.define('Dbui.grid.button.ExpertMenu', { // process checkItem event if (pMathJax) { - me.buttonMathJax = me.menu.getComponent('buttonMathJax'); - me.buttonMathJax.on('checkchange', me.onCheckItemChange, pMathJax); + me.buttonMathJax = me.menu.getComponent("buttonMathJax"); + me.buttonMathJax.on("checkchange", me.onCheckItemChange, pMathJax); } }, diff --git a/static/plugin_dbui/src/grid/column/Json.js b/static/plugin_dbui/src/grid/column/Json.js index 0a71829216d4d661f2f92959cc502233d6fe4ca7..da346225eb25d8510b9afe15d096c80230d02ddd 100644 --- a/static/plugin_dbui/src/grid/column/Json.js +++ b/static/plugin_dbui/src/grid/column/Json.js @@ -4,10 +4,10 @@ * @since 0.4.15.0 * */ -Ext.define('Dbui.grid.column.Json', { +Ext.define("Dbui.grid.column.Json", { - extend: 'Ext.grid.column.Column', - alias: 'widget.jsoncolumn', + extend: "Ext.grid.column.Column", + alias: "widget.jsoncolumn", /** * @param {Object} value diff --git a/static/plugin_dbui/src/grid/mixin/ExportBase.js b/static/plugin_dbui/src/grid/mixin/ExportBase.js index d73ec2f1cbad5fbf17a2830ca81353bae7066117..0b64267ec33fb61669db93025a710fb1875642e6 100644 --- a/static/plugin_dbui/src/grid/mixin/ExportBase.js +++ b/static/plugin_dbui/src/grid/mixin/ExportBase.js @@ -4,7 +4,7 @@ * @since 0.6.2 * */ -Ext.define('Dbui.grid.mixin.ExportBase', { +Ext.define("Dbui.grid.mixin.ExportBase", { // // Get the label and the alignment of the visible columns. @@ -26,7 +26,7 @@ Ext.define('Dbui.grid.mixin.ExportBase', { header, labels = []; - container = me.getDockedItems('headercontainer'); + container = me.getDockedItems("headercontainer"); header = container.length === 1 ? container[0] : null; columns = header.getVisibleGridColumns(); @@ -35,7 +35,7 @@ Ext.define('Dbui.grid.mixin.ExportBase', { var align, label; // column alignment - align = column.align || 'left'; + align = column.align || "left"; alignments.push(align); // the label of the RowNumberer column is a non breaking space diff --git a/static/plugin_dbui/src/grid/mixin/ExportCSV.js b/static/plugin_dbui/src/grid/mixin/ExportCSV.js index ab7d606597e03a1d801147a3e6ffd42af53c6759..cdc546b62be9b293d37bd1f7fb7a730e7c097287 100644 --- a/static/plugin_dbui/src/grid/mixin/ExportCSV.js +++ b/static/plugin_dbui/src/grid/mixin/ExportCSV.js @@ -5,9 +5,9 @@ * @since 0.6.2 * */ -Ext.define('Dbui.grid.mixin.ExportCSV', { +Ext.define("Dbui.grid.mixin.ExportCSV", { - extend: 'Dbui.grid.mixin.ExportBase', + extend: "Dbui.grid.mixin.ExportBase", config: { /** @@ -21,7 +21,7 @@ Ext.define('Dbui.grid.mixin.ExportCSV', { * The CSV field separator. * */ - separator: ',' + separator: "," }, diff --git a/static/plugin_dbui/src/grid/mixin/ExportLatex.js b/static/plugin_dbui/src/grid/mixin/ExportLatex.js index 599beed02c5d2b3b3bd72b535c6ea36860816452..0bc88beae0e2627c5487c9c4ef82d0ad1a556f32 100644 --- a/static/plugin_dbui/src/grid/mixin/ExportLatex.js +++ b/static/plugin_dbui/src/grid/mixin/ExportLatex.js @@ -5,9 +5,9 @@ * @since 0.6.2 * */ -Ext.define('Dbui.grid.mixin.ExportLatex', { +Ext.define("Dbui.grid.mixin.ExportLatex", { - extend: 'Dbui.grid.mixin.ExportBase', + extend: "Dbui.grid.mixin.ExportBase", // // Convert the dom Element corresponding to a grid cell into a string. @@ -61,7 +61,7 @@ Ext.define('Dbui.grid.mixin.ExportLatex', { "use strict"; var me = this, - columnsAlignment = '', + columnsAlignment = "", columnHeader, latex = [], trEls, @@ -74,12 +74,12 @@ Ext.define('Dbui.grid.mixin.ExportLatex', { }); // begin table - latex.push('\\begin{longtable}{' + columnsAlignment + '}'); + latex.push("\\begin{longtable}{" + columnsAlignment + "}"); // table header if (!columnHeader.hidden) { - latex.push(columnHeader.labels.join(' & ') + ' \\\\'); - latex.push('\\hline\\hline'); + latex.push(columnHeader.labels.join(" & ") + " \\\\"); + latex.push("\\hline\\hline"); } // table content @@ -101,9 +101,9 @@ Ext.define('Dbui.grid.mixin.ExportLatex', { div = trEl.down(".x-grid-group-title"); if (div) { nColumns = columnHeader.alignments.length; - cmd = '\\multicolumn{' + nColumns + '}{l}{' + me.domToLaTeX(div) + '} \\\\'; + cmd = "\\multicolumn{" + nColumns + "}{l}{" + me.domToLaTeX(div) + "} \\\\"; latex.push(cmd); - latex.push('\\hline'); + latex.push("\\hline"); } // row with standard data cells. It includes summary row. @@ -117,7 +117,7 @@ Ext.define('Dbui.grid.mixin.ExportLatex', { cells.push(me.domToLaTeX(tdEl)); }, me); - row = cells.join(' & ') + ' \\\\'; + row = cells.join(" & ") + " \\\\"; // unfortunately the grand total is the first row (Ext JS 4.2) if (index === 0 && trEl.hasCls("x-grid-row-summary")) { @@ -130,12 +130,12 @@ Ext.define('Dbui.grid.mixin.ExportLatex', { // push the grand total at the end if (total) { - latex.push('\\hline\\hline'); + latex.push("\\hline\\hline"); latex.push(total); } //end table - latex.push('\\end{longtable}'); + latex.push("\\end{longtable}"); return latex; } diff --git a/static/plugin_dbui/src/grid/plugin/ContextMenu.js b/static/plugin_dbui/src/grid/plugin/ContextMenu.js index 4515b00e5a1c6cbd082205b5147a9186425d971b..006d5095f1c8becb7382fcddf5255951b998dd9c 100644 --- a/static/plugin_dbui/src/grid/plugin/ContextMenu.js +++ b/static/plugin_dbui/src/grid/plugin/ContextMenu.js @@ -6,11 +6,11 @@ * @since 0.9.2 * */ -Ext.define('Dbui.grid.plugin.ContextMenu', { +Ext.define("Dbui.grid.plugin.ContextMenu", { - extend: 'Ext.AbstractPlugin', - alias: 'plugin.pGridContextMenu', - uses: ['Ext.menu.Menu'], + extend: "Ext.AbstractPlugin", + alias: "plugin.pGridContextMenu", + uses: ["Ext.menu.Menu"], /** * @cfg {String} menu @@ -31,12 +31,12 @@ Ext.define('Dbui.grid.plugin.ContextMenu', { me.setCmp(grid); - me.menu = Ext.create('Ext.menu.Menu', me.menu); + me.menu = Ext.create("Ext.menu.Menu", me.menu); grid.on({ - 'containercontextmenu': me.onContainerContextMenu, - 'headercontextmenu': me.onHeaderContextMenu, - 'itemcontextmenu': me.onItemContextMenu, + "containercontextmenu": me.onContainerContextMenu, + "headercontextmenu": me.onHeaderContextMenu, + "itemcontextmenu": me.onItemContextMenu, scope: me }); }, @@ -51,11 +51,11 @@ Ext.define('Dbui.grid.plugin.ContextMenu', { var me = this, grid = me.getCmp(); - grid.un('containercontextmenu', me.onContainerContextMenu, me); - grid.un('headercontextmenu', me.onHeaderContextMenu, me); - grid.un('itemcontextmenu', me.onItemContextMenu, me); + grid.un("containercontextmenu", me.onContainerContextMenu, me); + grid.un("headercontextmenu", me.onHeaderContextMenu, me); + grid.un("itemcontextmenu", me.onItemContextMenu, me); - Ext.destroyMembers(me, 'menu'); + Ext.destroyMembers(me, "menu"); }, /** diff --git a/static/plugin_dbui/src/grid/plugin/Export.js b/static/plugin_dbui/src/grid/plugin/Export.js index a40c3c789571c2f612fb1752bf2d1308b0f888f3..70acae52d96d5c4dbb2e5f7e1df5f05ecb8982d5 100644 --- a/static/plugin_dbui/src/grid/plugin/Export.js +++ b/static/plugin_dbui/src/grid/plugin/Export.js @@ -9,11 +9,11 @@ * @since 0.6.1.8 * */ -Ext.define('Dbui.grid.plugin.Export', { +Ext.define("Dbui.grid.plugin.Export", { - extend: 'Ext.AbstractPlugin', - alias: 'plugin.pGridExport', - requires: 'Ext.form.action.StandardSubmit', + extend: "Ext.AbstractPlugin", + alias: "plugin.pGridExport", + requires: "Ext.form.action.StandardSubmit", /** * @cfg {String} @@ -26,7 +26,7 @@ Ext.define('Dbui.grid.plugin.Export', { * @cfg {String} * The new line separator used in the CSV / LaTeX file. */ - newLine: '\n', + newLine: "\n", /** * @cfg {Array} @@ -34,30 +34,30 @@ Ext.define('Dbui.grid.plugin.Export', { * See for example http://fr.wikibooks.org/wiki/LaTeX/Mise_en_page. */ preamble: [ - '\\documentclass{article}', - '\\usepackage[utf8]{inputenc}', - '\\usepackage[T1]{fontenc}', - '\\usepackage{hyperref}', - '\\usepackage{longtable}', - '\\usepackage[landscape,a4paper]{geometry}', - '\\usepackage{fancyhdr}', - '\\geometry{tmargin=2cm,bmargin=2cm,lmargin=1.85cm,rmargin=1.85cm}', - '\\pagestyle{fancy}', - '\\fancyhead{}', - '\\fancyfoot{}', - '\\rfoot{\\thepage}' + "\\documentclass{article}", + "\\usepackage[utf8]{inputenc}", + "\\usepackage[T1]{fontenc}", + "\\usepackage{hyperref}", + "\\usepackage{longtable}", + "\\usepackage[landscape,a4paper]{geometry}", + "\\usepackage{fancyhdr}", + "\\geometry{tmargin=2cm,bmargin=2cm,lmargin=1.85cm,rmargin=1.85cm}", + "\\pagestyle{fancy}", + "\\fancyhead{}", + "\\fancyfoot{}", + "\\rfoot{\\thepage}" ], // private properties for internationalization - textToCSV: 'Export to CSV...', - textToLaTeX: 'Export to LaTeX...', - textToPDF: 'Export to PDF...', + textToCSV: "Export to CSV...", + textToLaTeX: "Export to LaTeX...", + textToPDF: "Export to PDF...", // private short cut menu: null, // Pre-defined configuration - pluginId: 'gridExport', + pluginId: "gridExport", /** * Initialize the plugin @@ -74,20 +74,20 @@ Ext.define('Dbui.grid.plugin.Export', { me.setCmp(grid); // the context menu - me.menu = Ext.create('Ext.menu.Menu', { + me.menu = Ext.create("Ext.menu.Menu", { items : [{ text: me.textToCSV, - iconCls: 'xminetype-csv', + iconCls: "xminetype-csv", handler: me.onCsvExport, scope: me }, { text: me.textToLaTeX, - iconCls: 'xminetype-tex', + iconCls: "xminetype-tex", handler: me.onLatexExport, scope: me }, { text: me.textToPDF, - iconCls: 'xminetype-pdf', + iconCls: "xminetype-pdf", handler: me.onPdfExport, scope: me }] @@ -95,7 +95,7 @@ Ext.define('Dbui.grid.plugin.Export', { // the menu pops up everywhere in the the grid, no context menu outside. // Move from the Ext.component to the Ext.dom.element space. - grid.on('render', function(cmp){ + grid.on("render", function(cmp){ var me = this; @@ -138,13 +138,13 @@ Ext.define('Dbui.grid.plugin.Export', { latex = latex.concat(me.preamble); // begin document - latex.push('\\begin{document}'); + latex.push("\\begin{document}"); // the table latex = latex.concat(me.getCmp().toLaTeX()); // end document - latex.push('\\end{document}'); + latex.push("\\end{document}"); return latex; }, @@ -205,11 +205,11 @@ Ext.define('Dbui.grid.plugin.Export', { // send the latex data to the server. // the method used standardSubmit using a form. - form = Ext.create('Ext.form.Panel', { + form = Ext.create("Ext.form.Panel", { items: [{ - name: 'latex', + name: "latex", value: data, - xtype:'textfield' + xtype:"textfield" }], standardSubmit: true, url: Dbui.latex2pdfUrl diff --git a/static/plugin_dbui/src/grid/plugin/Paging.js b/static/plugin_dbui/src/grid/plugin/Paging.js index 2441695c8fab066bb001a13a0f46746ef10c7174..565745c0472bdaa31aa8f286a4adc3e007d5fa85 100644 --- a/static/plugin_dbui/src/grid/plugin/Paging.js +++ b/static/plugin_dbui/src/grid/plugin/Paging.js @@ -4,15 +4,15 @@ * to fixed the number of rows per page. * */ -Ext.define('Dbui.grid.plugin.Paging', { +Ext.define("Dbui.grid.plugin.Paging", { - extend: 'Ext.AbstractPlugin', - alias: 'plugin.pGridPaging', + extend: "Ext.AbstractPlugin", + alias: "plugin.pGridPaging", requires: [ - 'Dbui.grid.button.ExpertMenu', - 'Ext.slider.Single' + "Dbui.grid.button.ExpertMenu", + "Ext.slider.Single" ], - uses: 'Ext.toolbar.Paging', + uses: "Ext.toolbar.Paging", /* * @cfg {Number} increment @@ -29,8 +29,8 @@ Ext.define('Dbui.grid.plugin.Paging', { slider: null, // Private property for internationalisation - textPlus: 'Plus', - textSlider: 'Entries per page', + textPlus: "Plus", + textSlider: "Entries per page", /** * Initialize the plugin @@ -49,18 +49,18 @@ Ext.define('Dbui.grid.plugin.Paging', { me.setCmp(grid); // create the paging bar tool bar - me.bbar = Ext.create('Ext.toolbar.Paging', { - dock: 'bottom', + me.bbar = Ext.create("Ext.toolbar.Paging", { + dock: "bottom", displayInfo: false, - items: ['-', me.textSlider, { + items: ["-", me.textSlider, { increment: me.increment, minValue: me.pageSize, width: 150, - xtype: 'slider' - }, '-', '->', { + xtype: "slider" + }, "-", "->", { grid: grid, text: me.textPlus, - xtype: 'xgridbuttonexpertmenu' + xtype: "xgridbuttonexpertmenu" }], store: store }); @@ -70,29 +70,29 @@ Ext.define('Dbui.grid.plugin.Paging', { // Set-up the remote action parameters store.pageSize = me.pageSize; - store.getProxy().pageParam = 'page'; + store.getProxy().pageParam = "page"; grid.remoteAction = true; // short cut - me.slider = me.bbar.query('slider')[0]; + me.slider = me.bbar.query("slider")[0]; // disable / enable the slider when loading - store.on('beforeload', function () { + store.on("beforeload", function () { me.slider.disable(true); }, me); - store.on('load', function () { + store.on("load", function () { me.slider.enable(true); }, me); // event related to the slider - me.slider.on('change', me.onSliderChange, me, { + me.slider.on("change", me.onSliderChange, me, { buffer: 700 }); // events related to the store - store.on('filterchange', me.onStoreChange, me); - store.on('load', me.onStoreChange, me); - store.on('write', me.onStoreChange, me); + store.on("filterchange", me.onStoreChange, me); + store.on("load", me.onStoreChange, me); + store.on("write", me.onStoreChange, me); }, /** @@ -106,21 +106,21 @@ Ext.define('Dbui.grid.plugin.Paging', { grid = me.getCmp(), store = grid.getStore(); - store.un('beforeload', function () { + store.un("beforeload", function () { me.slider.disable(true); }, me); - store.un('load', function () { + store.un("load", function () { me.slider.enable(true); }, me); - me.slider.un('change', me.onSliderChange, me, { + me.slider.un("change", me.onSliderChange, me, { buffer: 700 }); // events related to the store - store.un('filterchange', me.onStoreChange, me); - store.un('load', me.onStoreChange, me); - store.un('write', me.onStoreChange, me); + store.un("filterchange", me.onStoreChange, me); + store.un("load", me.onStoreChange, me); + store.un("write", me.onStoreChange, me); }, /** diff --git a/static/plugin_dbui/src/grid/plugin/RowEditorAddWizard.js b/static/plugin_dbui/src/grid/plugin/RowEditorAddWizard.js index cea12b492171a4ba448551af40dc43f9ea7c2219..eb261a2e00ba5766d6a778558777c98ca5ade59b 100644 --- a/static/plugin_dbui/src/grid/plugin/RowEditorAddWizard.js +++ b/static/plugin_dbui/src/grid/plugin/RowEditorAddWizard.js @@ -7,11 +7,11 @@ * @since 0.7.3 * */ -Ext.define('Dbui.grid.plugin.RowEditorAddWizard', { +Ext.define("Dbui.grid.plugin.RowEditorAddWizard", { - extend: 'Ext.AbstractPlugin', - alias: 'plugin.pGridRowEditorAddWizard', - uses: ['Ext.menu.Menu'], + extend: "Ext.AbstractPlugin", + alias: "plugin.pGridRowEditorAddWizard", + uses: ["Ext.menu.Menu"], /** * @cfg {String} @@ -26,8 +26,8 @@ Ext.define('Dbui.grid.plugin.RowEditorAddWizard', { wizard: null, // private properties for internationalization - textExpert: 'mode expert', - textSimplify: 'mode simplified', + textExpert: "mode expert", + textSimplify: "mode simplified", textTitle: "Wizard...", /** @@ -40,7 +40,7 @@ Ext.define('Dbui.grid.plugin.RowEditorAddWizard', { "use strict"; var me = this, - rowEditor = grid.getPlugin('rowEditor'), + rowEditor = grid.getPlugin("rowEditor"), contextMenu, newAddItem, oldAddItem; @@ -49,12 +49,12 @@ Ext.define('Dbui.grid.plugin.RowEditorAddWizard', { // protection if (!rowEditor) { - throw new Error('no grid plugin RowEditor !!!'); + throw new Error("no grid plugin RowEditor !!!"); } - contextMenu = grid.findPlugin('pGridRowEditorContextMenu'); + contextMenu = grid.findPlugin("pGridRowEditorContextMenu"); if (!contextMenu) { - throw new Error('no grid plugin RowEditorContextMenu !!!'); + throw new Error("no grid plugin RowEditorContextMenu !!!"); } contextMenu = contextMenu.menu; @@ -62,16 +62,16 @@ Ext.define('Dbui.grid.plugin.RowEditorAddWizard', { // the new Add item newAddItem = { - text: oldAddItem.text + '...', + text: oldAddItem.text + "...", menu: { items: [{ text: me.textSimplify, - iconCls: 'xaction-wizard', + iconCls: "xaction-wizard", handler: me.onRunWizard, scope: me }, { text: me.textExpert, - iconCls: 'xaction-create', + iconCls: "xaction-create", handler: rowEditor.onAddRow, scope: rowEditor }] @@ -94,10 +94,10 @@ Ext.define('Dbui.grid.plugin.RowEditorAddWizard', { var me = this, window; - window = Ext.create('Ext.window.Window', { + window = Ext.create("Ext.window.Window", { closable: true, items: me.wizard, - layout: 'fit', + layout: "fit", modal: true, title: me.textTitle, width: me.width @@ -106,7 +106,7 @@ Ext.define('Dbui.grid.plugin.RowEditorAddWizard', { // the window is close when the wizard transaction is succesful or // when the user quit. The close event is used to update the grid // content with the new value - window.on('close', me.onWindowClose, me, { + window.on("close", me.onWindowClose, me, { single: true }); diff --git a/static/plugin_dbui/src/grid/plugin/RowEditorBase.js b/static/plugin_dbui/src/grid/plugin/RowEditorBase.js index 0510d89b6f3b40b1f231787b89dc47710cd0a614..d0d43e2b005af6cd87d64e3fbf8748c1545454d0 100644 --- a/static/plugin_dbui/src/grid/plugin/RowEditorBase.js +++ b/static/plugin_dbui/src/grid/plugin/RowEditorBase.js @@ -7,15 +7,15 @@ * **Note**: This plugin limits the number of selected row to one. * */ -Ext.define('Dbui.grid.plugin.RowEditorBase', { +Ext.define("Dbui.grid.plugin.RowEditorBase", { - extend: 'Ext.AbstractPlugin', - alias: 'plugin.pGridRowEditor', + extend: "Ext.AbstractPlugin", + alias: "plugin.pGridRowEditor", requires: [ - 'Ext.layout.container.Fit', - 'Ext.window.Window' + "Ext.layout.container.Fit", + "Ext.window.Window" ], - uses: 'Dbui.form.Panel', + uses: "Dbui.form.Panel", /** * @cfg {Array} [resetFields="TableId"] @@ -27,7 +27,7 @@ Ext.define('Dbui.grid.plugin.RowEditorBase', { resetFields: null, // Pre-defined configuration - pluginId: 'rowEditor', + pluginId: "rowEditor", // Private short cuts formPanel: null, @@ -39,7 +39,7 @@ Ext.define('Dbui.grid.plugin.RowEditorBase', { duplicateTitle: "Duplicate the record...", editTitle: "Update the record...", viewTitle: "View the record...", - textMsg: 'Select a row please', + textMsg: "Select a row please", /** * Initialize the plugin @@ -57,17 +57,17 @@ Ext.define('Dbui.grid.plugin.RowEditorBase', { me.setCmp(grid); // The user can only select one row - grid.getSelectionModel().setSelectionMode('SINGLE'); + grid.getSelectionModel().setSelectionMode("SINGLE"); // Add a listener to hide the window when the transaction is successful // or when the transaction failed - store.on('write', me.onWrite, me); - store.getProxy().on('exception', me.onException, me); + store.on("write", me.onWrite, me); + store.getProxy().on("exception", me.onException, me); // instantiate the window - me.window = Ext.create('Ext.window.Window', { - closeAction: 'hide', - layout: 'fit', + me.window = Ext.create("Ext.window.Window", { + closeAction: "hide", + layout: "fit", modal: true, plain: true }); @@ -81,7 +81,7 @@ Ext.define('Dbui.grid.plugin.RowEditorBase', { if (!me.pluginConfig.resetFields) { me.resetFields = []; } - me.resetFields.push(Dbui.encodeField(table, 'id')); + me.resetFields.push(Dbui.encodeField(table, "id")); }, /** @@ -115,7 +115,7 @@ Ext.define('Dbui.grid.plugin.RowEditorBase', { formCfg = response.result; // instantiate the form - me.formPanel = Ext.create('Dbui.form.Panel', formCfg); + me.formPanel = Ext.create("Dbui.form.Panel", formCfg); me.window.add(me.formPanel); }, @@ -131,11 +131,11 @@ Ext.define('Dbui.grid.plugin.RowEditorBase', { store; store = me.getCmp().getStore(); - store.un('write', me.onWrite, me); - store.getProxy().un('exception', me.onException, me); + store.un("write", me.onWrite, me); + store.getProxy().un("exception", me.onException, me); - Ext.destroyMembers(me, 'formPanel'); - Ext.destroyMembers(me, 'window'); + Ext.destroyMembers(me, "formPanel"); + Ext.destroyMembers(me, "window"); }, /** @@ -154,7 +154,7 @@ Ext.define('Dbui.grid.plugin.RowEditorBase', { selectionModel = me.getCmp().getSelectionModel(); if (selectionModel.getCount() !== 1) { - Ext.MessageBox.alert('Warning', me.textMsg); + Ext.MessageBox.alert("Warning", me.textMsg); return false; } @@ -171,7 +171,7 @@ Ext.define('Dbui.grid.plugin.RowEditorBase', { me.setCurrentIndex(); - me.formPanel.setAction('create'); + me.formPanel.setAction("create"); me.window.setTitle(me.addTitle); me.window.show(); }, @@ -190,7 +190,7 @@ Ext.define('Dbui.grid.plugin.RowEditorBase', { return; } - me.formPanel.setAction('destroy', record); + me.formPanel.setAction("destroy", record); me.window.setTitle(me.deleteTitle); me.formPanel.doAction(); @@ -223,7 +223,7 @@ Ext.define('Dbui.grid.plugin.RowEditorBase', { record.set(field, value, {dirty: false}); } - me.formPanel.setAction('duplicate', record); + me.formPanel.setAction("duplicate", record); me.window.setTitle(me.duplicateTitle); me.window.show(); }, @@ -242,7 +242,7 @@ Ext.define('Dbui.grid.plugin.RowEditorBase', { return; } - me.formPanel.setAction('update', record); + me.formPanel.setAction("update", record); me.window.setTitle(me.editTitle); me.window.show(); }, @@ -284,7 +284,7 @@ Ext.define('Dbui.grid.plugin.RowEditorBase', { return; } - me.formPanel.setAction('view', record); + me.formPanel.setAction("view", record); me.window.setTitle(me.viewTitle); me.window.show(); }, diff --git a/static/plugin_dbui/src/grid/plugin/RowEditorConfirmDelete.js b/static/plugin_dbui/src/grid/plugin/RowEditorConfirmDelete.js index b971de4512195cec0f99324dd50d1973c66cd918..d77aa632738c9547362cf1796fd9b99b34a81451 100644 --- a/static/plugin_dbui/src/grid/plugin/RowEditorConfirmDelete.js +++ b/static/plugin_dbui/src/grid/plugin/RowEditorConfirmDelete.js @@ -2,13 +2,13 @@ * The plugin adding *confirmation on delete* to the Dbui.grid.plugin.RowEditor. * */ -Ext.define('Dbui.grid.plugin.RowEditorConfirmDelete', { +Ext.define("Dbui.grid.plugin.RowEditorConfirmDelete", { - extend: 'Dbui.grid.plugin.RowEditorBase', - alias: 'plugin.pGridRowEditorConfirmDelete', + extend: "Dbui.grid.plugin.RowEditorBase", + alias: "plugin.pGridRowEditorConfirmDelete", // Private property for internationalization - confirmMsg: 'Do you really want to delete this item?', + confirmMsg: "Do you really want to delete this item?", /** * Delete the selected row asking confirmation. @@ -26,8 +26,8 @@ Ext.define('Dbui.grid.plugin.RowEditorConfirmDelete', { } Ext.Msg.confirm(me.deleteTitle, me.confirmMsg, function (rep) { - if (rep === 'yes') { - me.formPanel.setAction('destroy', record); + if (rep === "yes") { + me.formPanel.setAction("destroy", record); me.window.setTitle(me.deleteTitle); me.formPanel.doAction(); } diff --git a/static/plugin_dbui/src/grid/plugin/RowEditorContextMenu.js b/static/plugin_dbui/src/grid/plugin/RowEditorContextMenu.js index 82a045a5b89c213f4a06e1956fe6dee02edcc537..ca5cb34d305b02723b94291fb82d7a4f4910c532 100644 --- a/static/plugin_dbui/src/grid/plugin/RowEditorContextMenu.js +++ b/static/plugin_dbui/src/grid/plugin/RowEditorContextMenu.js @@ -7,18 +7,18 @@ * @uses Dbui.grid.plugin.RowEditorBase * */ -Ext.define('Dbui.grid.plugin.RowEditorContextMenu', { +Ext.define("Dbui.grid.plugin.RowEditorContextMenu", { - extend: 'Dbui.grid.plugin.ContextMenu', - alias: 'plugin.pGridRowEditorContextMenu', + extend: "Dbui.grid.plugin.ContextMenu", + alias: "plugin.pGridRowEditorContextMenu", // private properties for internationalization - textAdd: 'Add', - textCreate: 'Create', - textDestroy: 'Delete', - textDuplicate: 'Duplicate', - textUpdate: 'Update', - textView: 'View', + textAdd: "Add", + textCreate: "Create", + textDestroy: "Delete", + textDuplicate: "Duplicate", + textUpdate: "Update", + textView: "View", // jshint strict: false @@ -30,37 +30,37 @@ Ext.define('Dbui.grid.plugin.RowEditorContextMenu', { init: function (grid) { var me = this, - rowEditor = grid.getPlugin('rowEditor'); + rowEditor = grid.getPlugin("rowEditor"); // protection if (!rowEditor) { - throw new Error('no grid row editor !!!'); + throw new Error("no grid row editor !!!"); } me.menu = { items: [{ text: me.textAdd, - iconCls: 'xaction-create', + iconCls: "xaction-create", handler: rowEditor.onAddRow, scope: rowEditor - }, '-', { + }, "-", { text: me.textDuplicate, - iconCls: 'xaction-duplicate', + iconCls: "xaction-duplicate", handler: rowEditor.onDuplicateRow, scope: rowEditor }, { text: me.textUpdate, - iconCls: 'xaction-update', + iconCls: "xaction-update", handler: rowEditor.onEditRow, scope: rowEditor }, { text: me.textView, - iconCls: 'xaction-view', + iconCls: "xaction-view", handler: rowEditor.onViewRow, scope: rowEditor - }, '-', { + }, "-", { text: me.textDestroy, - iconCls: 'xaction-destroy', + iconCls: "xaction-destroy", handler: rowEditor.onDeleteRow, scope: rowEditor }] diff --git a/static/plugin_dbui/src/grid/plugin/RowEditorDblClick.js b/static/plugin_dbui/src/grid/plugin/RowEditorDblClick.js index e2320b2c85a5f5100423323b2b61739e88c1b715..8d8fd9bf6f534697415ee0a32e4f281888ddf05f 100644 --- a/static/plugin_dbui/src/grid/plugin/RowEditorDblClick.js +++ b/static/plugin_dbui/src/grid/plugin/RowEditorDblClick.js @@ -4,10 +4,10 @@ * * @uses Dbui.grid.plugin.RowEditorBase */ -Ext.define('Dbui.grid.plugin.RowEditorDblClick', { +Ext.define("Dbui.grid.plugin.RowEditorDblClick", { - extend: 'Ext.AbstractPlugin', - alias: 'plugin.pGridRowEditorDblClick', + extend: "Ext.AbstractPlugin", + alias: "plugin.pGridRowEditorDblClick", /** * Initialize the plugin. @@ -19,16 +19,16 @@ Ext.define('Dbui.grid.plugin.RowEditorDblClick', { "use strict"; var me = this, - rowEditor = grid.getPlugin('rowEditor'); + rowEditor = grid.getPlugin("rowEditor"); me.setCmp(grid); // protection if (!rowEditor) { - throw new Error('no grid row editor !!!'); + throw new Error("no grid row editor !!!"); } - grid.on('itemdblclick', rowEditor.onEditRow, rowEditor); + grid.on("itemdblclick", rowEditor.onEditRow, rowEditor); }, /** @@ -40,8 +40,8 @@ Ext.define('Dbui.grid.plugin.RowEditorDblClick', { var me = this, grid = me.getCmp(), - rowEditor = grid.getPlugin('rowEditor'); + rowEditor = grid.getPlugin("rowEditor"); - grid.un('itemdblclick', rowEditor.onEditRow, rowEditor); + grid.un("itemdblclick", rowEditor.onEditRow, rowEditor); } }); \ No newline at end of file diff --git a/static/plugin_dbui/src/grid/plugin/RowEditorToolbar.js b/static/plugin_dbui/src/grid/plugin/RowEditorToolbar.js index 1d5d3472f6eec072b826552d47e7cb3a91bf250e..6e14bff0cf5b718baa97404bd35627e0f0cff415 100644 --- a/static/plugin_dbui/src/grid/plugin/RowEditorToolbar.js +++ b/static/plugin_dbui/src/grid/plugin/RowEditorToolbar.js @@ -5,10 +5,10 @@ * @uses Dbui.grid.plugin.RowEditorBase * */ -Ext.define('Dbui.grid.plugin.RowEditorToolbar', { +Ext.define("Dbui.grid.plugin.RowEditorToolbar", { - extend: 'Ext.AbstractPlugin', - alias: 'plugin.pGridRowEditorToolbar', + extend: "Ext.AbstractPlugin", + alias: "plugin.pGridRowEditorToolbar", /** * Initialize the plugin. @@ -20,40 +20,40 @@ Ext.define('Dbui.grid.plugin.RowEditorToolbar', { "use strict"; var toolbar, - rowEditor = grid.getPlugin('rowEditor'); + rowEditor = grid.getPlugin("rowEditor"); // protection if (!rowEditor) { - throw new Error('no grid row editor !!!'); + throw new Error("no grid row editor !!!"); } toolbar = grid.getTopToolbar(); toolbar.add([{ - text: 'Add', - iconCls: 'silk-add', + text: "Add", + iconCls: "silk-add", handler: rowEditor.onAddRow, scope: rowEditor - }, ' ', { - text: 'Delete', - iconCls: 'silk-delete', + }, " ", { + text: "Delete", + iconCls: "silk-delete", handler: rowEditor.onDeleteRow, scope: rowEditor - }, ' ', { - text: 'Duplicate', - iconCls: 'silk-clone', + }, " ", { + text: "Duplicate", + iconCls: "silk-clone", handler: rowEditor.onDuplicateRow, scope: rowEditor - }, ' ', { - text: 'Update', - iconCls: 'silk-update', + }, " ", { + text: "Update", + iconCls: "silk-update", handler: rowEditor.onEditRow, scope: rowEditor - }, ' ', { - text: 'View', - iconCls: 'silk-view', + }, " ", { + text: "View", + iconCls: "silk-view", handler: rowEditor.onViewRow, scope: rowEditor - }, '-']); + }, "-"]); } }); \ No newline at end of file diff --git a/static/plugin_dbui/src/grid/plugin/Toolbar.js b/static/plugin_dbui/src/grid/plugin/Toolbar.js index 33cbe59e8eb89ea3f05b00b51678d62afe4eaeaf..f4caf3169ea101de12aa598b29ee9e1925e5523d 100644 --- a/static/plugin_dbui/src/grid/plugin/Toolbar.js +++ b/static/plugin_dbui/src/grid/plugin/Toolbar.js @@ -6,19 +6,19 @@ * and the pGridPaging plugins are requested. * */ -Ext.define('Dbui.grid.plugin.Toolbar', { +Ext.define("Dbui.grid.plugin.Toolbar", { - extend: 'Ext.AbstractPlugin', - alias: 'plugin.pGridToolbar', - requires: 'Dbui.grid.button.ExpertMenu', - uses: ['Ext.toolbar.Toolbar'], + extend: "Ext.AbstractPlugin", + alias: "plugin.pGridToolbar", + requires: "Dbui.grid.button.ExpertMenu", + uses: ["Ext.toolbar.Toolbar"], // short cut bbar: null, // Private properties for internationalisation - textEntries: 'Entries', - textPlus: 'Plus', + textEntries: "Entries", + textPlus: "Plus", /** * Initialize the plugin @@ -34,7 +34,7 @@ Ext.define('Dbui.grid.plugin.Toolbar', { store = grid.getStore(); // is pGridPaging ? - if (Dbui.isPlugin(grid, 'pGridPaging')) { + if (Dbui.isPlugin(grid, "pGridPaging")) { return; } @@ -42,16 +42,16 @@ Ext.define('Dbui.grid.plugin.Toolbar', { me.setCmp(grid); // the tool bar - me.bbar = Ext.create('Ext.toolbar.Toolbar', { - dock: 'bottom', + me.bbar = Ext.create("Ext.toolbar.Toolbar", { + dock: "bottom", items: [{ - itemId: 'counter', + itemId: "counter", text: store.count(), - xtype: 'tbtext' - }, me.textEntries, '->', { + xtype: "tbtext" + }, me.textEntries, "->", { grid: grid, text: me.textPlus, - xtype: 'xgridbuttonexpertmenu' + xtype: "xgridbuttonexpertmenu" }] }); @@ -59,9 +59,9 @@ Ext.define('Dbui.grid.plugin.Toolbar', { grid.insertDocked(0, me.bbar); // catch events to update the counter - store.on('filterchange', me.updateCounter, me); - store.on('load', me.updateCounter, me); - store.on('write', me.updateCounter, me); + store.on("filterchange", me.updateCounter, me); + store.on("load", me.updateCounter, me); + store.on("write", me.updateCounter, me); }, /** @@ -74,9 +74,9 @@ Ext.define('Dbui.grid.plugin.Toolbar', { var me = this, store = me.getCmp().getStore(); - store.un('filterchange', me.updateCounter, me); - store.on('load', me.updateCounter, me); - store.on('write', me.updateCounter, me); + store.un("filterchange", me.updateCounter, me); + store.on("load", me.updateCounter, me); + store.on("write", me.updateCounter, me); }, /** @@ -89,6 +89,6 @@ Ext.define('Dbui.grid.plugin.Toolbar', { var me = this, store = me.getCmp().getStore(); - me.bbar.getComponent('counter').setText(store.count()); + me.bbar.getComponent("counter").setText(store.count()); } }); \ No newline at end of file diff --git a/static/plugin_dbui/src/grid/property/Preferences.js b/static/plugin_dbui/src/grid/property/Preferences.js index 592e41106dac6f66c6ef624dbd09a61a17a067a1..6c39e0934939f3f235e4f4bb795d5465fa81b97c 100644 --- a/static/plugin_dbui/src/grid/property/Preferences.js +++ b/static/plugin_dbui/src/grid/property/Preferences.js @@ -12,10 +12,10 @@ * @since 0.7.0 * */ -Ext.define('Dbui.grid.property.Preferences', { +Ext.define("Dbui.grid.property.Preferences", { - extend: 'Ext.grid.property.Grid', - alias: 'widget.xpreferences', + extend: "Ext.grid.property.Grid", + alias: "widget.xpreferences", /** * @cfg {String} dbtable (required) @@ -58,9 +58,9 @@ Ext.define('Dbui.grid.property.Preferences', { refStore: null, // private properties for internationalization - textDefinition: 'Definition', - textReset: 'Reset', - textUpdate: 'Update', + textDefinition: "Definition", + textReset: "Reset", + textUpdate: "Update", // jshint strict: false @@ -71,11 +71,11 @@ Ext.define('Dbui.grid.property.Preferences', { // the bottom tool bar me.dockedItems = [{ - xtype: 'toolbar', - dock: 'bottom', - ui: 'footer', + xtype: "toolbar", + dock: "bottom", + ui: "footer", layout: { - pack: 'end' + pack: "end" }, items: [{ handler: me.onButtonUpdate, @@ -199,7 +199,7 @@ Ext.define('Dbui.grid.property.Preferences', { // close the window housing the preferences widget // simple logic based on the owner container // if it is a window then close it - if (me.ownerCt.getXType() === 'window') { + if (me.ownerCt.getXType() === "window") { me.ownerCt.close(); } } diff --git a/static/plugin_dbui/src/panel/BaseWithSelector.js b/static/plugin_dbui/src/panel/BaseWithSelector.js index 100fa53b7e14ceb0deba2a417ceb2630a7de2128..c36e3174a281c8d3d69cd662148d50b5f29e74d8 100644 --- a/static/plugin_dbui/src/panel/BaseWithSelector.js +++ b/static/plugin_dbui/src/panel/BaseWithSelector.js @@ -23,15 +23,15 @@ * is defined in inherited class. * */ -Ext.define('Dbui.panel.BaseWithSelector', { +Ext.define("Dbui.panel.BaseWithSelector", { - extend: 'Ext.panel.Panel', - alias: 'widget.xpanelwithselector', + extend: "Ext.panel.Panel", + alias: "widget.xpanelwithselector", requires: [ - 'Dbui.panel.plugin.LoaderException', - 'Ext.layout.container.Border', - 'Ext.layout.container.Fit', - 'Ext.layout.container.Form' + "Dbui.panel.plugin.LoaderException", + "Ext.layout.container.Border", + "Ext.layout.container.Fit", + "Ext.layout.container.Form" ], /** @@ -57,7 +57,7 @@ Ext.define('Dbui.panel.BaseWithSelector', { * @cfg {Ext.enums.Layout/Object} * The layout configuration option for the main panel. */ - panelLayout: 'fit', + panelLayout: "fit", /** * @cfg {Ext.ComponentLoader/Object} @@ -72,7 +72,7 @@ Ext.define('Dbui.panel.BaseWithSelector', { * */ panelLoader: { - renderer: 'html', + renderer: "html", scripts: true }, @@ -93,7 +93,7 @@ Ext.define('Dbui.panel.BaseWithSelector', { * The defaults configuration option for the selector. */ selectorDefaults: { - anchor: '100%' + anchor: "100%" }, /** @@ -112,13 +112,13 @@ Ext.define('Dbui.panel.BaseWithSelector', { * @cfg {Ext.enums.Layout/Object} * The layout configuration option for the selector. */ - selectorLayout: 'anchor', + selectorLayout: "anchor", /** * @cfg {String} * Authorized values are east, west, south and north. */ - selectorRegion: 'east', + selectorRegion: "east", /** * @cfg {Boolean} @@ -163,8 +163,8 @@ Ext.define('Dbui.panel.BaseWithSelector', { selectorPanel: null, // Private attribute for internationalization - textGo: 'Go', - textReset: 'Reset', + textGo: "Go", + textReset: "Reset", // jshint strict: false @@ -180,23 +180,23 @@ Ext.define('Dbui.panel.BaseWithSelector', { // predefined configuration cfg = { - layout: 'border', + layout: "border", items: [{ border: me.panelBorder, defaults: me.panelDefaults, - itemId: 'mainPanel', + itemId: "mainPanel", items: me.panelItems, layout: me.panelLayout, loader: me.panelLoader, - plugins: ['pPanelLoaderException'], - region: 'center' + plugins: ["pPanelLoaderException"], + region: "center" }, { - bodyPadding: '0 5 0 0', + bodyPadding: "0 5 0 0", buttons: [{ - itemId: 'goButton', + itemId: "goButton", text: me.textGo }, { - itemId: 'resetButton', + itemId: "resetButton", text: me.textReset }], collapsible: me.selectorCollapsible, @@ -204,7 +204,7 @@ Ext.define('Dbui.panel.BaseWithSelector', { frame: me.selectorFrame, height: me.selectorHeight, layout: me.selectorLayout, - itemId: 'selectorPanel', + itemId: "selectorPanel", items: me.selectorItems, region: me.selectorRegion, split: me.selectorSplit, @@ -220,13 +220,13 @@ Ext.define('Dbui.panel.BaseWithSelector', { me.callParent(arguments); // short cuts - me.mainPanel = me.getComponent('mainPanel'); - me.selectorPanel = me.getComponent('selectorPanel'); + me.mainPanel = me.getComponent("mainPanel"); + me.selectorPanel = me.getComponent("selectorPanel"); // selector buttons toolbar = me.selectorPanel.getDockedItems()[0]; - me.goButton = toolbar.getComponent('goButton'); - me.resetButton = toolbar.getComponent('resetButton'); + me.goButton = toolbar.getComponent("goButton"); + me.resetButton = toolbar.getComponent("resetButton"); } // jshint strict: true diff --git a/static/plugin_dbui/src/panel/plugin/LoaderException.js b/static/plugin_dbui/src/panel/plugin/LoaderException.js index 268d4ce95e5097250a1d47784893cfea20d04503..0859542e959e84618df2a6b75124e10e2aa7360a 100644 --- a/static/plugin_dbui/src/panel/plugin/LoaderException.js +++ b/static/plugin_dbui/src/panel/plugin/LoaderException.js @@ -4,13 +4,13 @@ * @since 0.6.0.0 * */ -Ext.define('Dbui.panel.plugin.LoaderException', { +Ext.define("Dbui.panel.plugin.LoaderException", { - extend: 'Ext.AbstractPlugin', - alias: 'plugin.pPanelLoaderException', + extend: "Ext.AbstractPlugin", + alias: "plugin.pPanelLoaderException", // Private attribute for internationalization - textError: 'Error ...', + textError: "Error ...", /** * Initialize the plugin @@ -23,7 +23,7 @@ Ext.define('Dbui.panel.plugin.LoaderException', { var me = this; me.setCmp(panel); - panel.getLoader().on('exception', me.onLoaderFailure, me); + panel.getLoader().on("exception", me.onLoaderFailure, me); }, /** @@ -34,7 +34,7 @@ Ext.define('Dbui.panel.plugin.LoaderException', { "use strict"; var me = this; - me.getCmp().getLoader().un('exception', me.onLoaderFailure, me); + me.getCmp().getLoader().un("exception", me.onLoaderFailure, me); }, /** diff --git a/static/plugin_dbui/src/wizard/Wizard.js b/static/plugin_dbui/src/wizard/Wizard.js index 66967cedcb470da12a3403685ca8026cce92a098..48e10d8e594397881b82f8cadf18b341e5c3a685 100644 --- a/static/plugin_dbui/src/wizard/Wizard.js +++ b/static/plugin_dbui/src/wizard/Wizard.js @@ -26,12 +26,12 @@ * @since 0.7.3 * */ -Ext.define('Dbui.wizard.Wizard', { +Ext.define("Dbui.wizard.Wizard", { - extend: 'Ext.form.Panel', - alias: 'widget.xwizard', + extend: "Ext.form.Panel", + alias: "widget.xwizard", requires: [ - 'Ext.layout.container.Card' + "Ext.layout.container.Card" ], /** @@ -77,19 +77,19 @@ Ext.define('Dbui.wizard.Wizard', { "All data will be lost.</p><br>", "Would you like to continue?" ], - textError: 'Error', - textFinish: 'Finish', - textLoading: 'Processing the data...', - textNext: 'Next', - textPrevious: 'Previous', + textError: "Error", + textFinish: "Finish", + textLoading: "Processing the data...", + textNext: "Next", + textPrevious: "Previous", // predefine configuration options - bodyStyle: 'padding:15px', + bodyStyle: "padding:15px", defaults: { border: false, - layout: 'column' + layout: "column" }, - layout: 'card', + layout: "card", // jshint strict: false @@ -102,14 +102,14 @@ Ext.define('Dbui.wizard.Wizard', { // the buttons me.buttons = [{ disabled: true, - itemId: 'buttonPrev', + itemId: "buttonPrev", text: me.textPrevious }, { - itemId: 'buttonNext', + itemId: "buttonNext", text: me.textNext }, { formBind: true, - itemId: 'buttonFinish', + itemId: "buttonFinish", text: me.textFinish }]; @@ -118,9 +118,9 @@ Ext.define('Dbui.wizard.Wizard', { // shortcut for the navigation toolbar = me.getDockedItems()[0]; - me.buttonFinish = toolbar.getComponent('buttonFinish'); - me.buttonNext = toolbar.getComponent('buttonNext'); - me.buttonPrev = toolbar.getComponent('buttonPrev'); + me.buttonFinish = toolbar.getComponent("buttonFinish"); + me.buttonNext = toolbar.getComponent("buttonNext"); + me.buttonPrev = toolbar.getComponent("buttonPrev"); // handler for navigation me.buttonNext.setHandler(me.onNext, me); @@ -130,9 +130,9 @@ Ext.define('Dbui.wizard.Wizard', { me.buttonFinish.setHandler(me.onFinish, me); // mask for the viewport - me.mask = Ext.create('Ext.LoadMask', { + me.mask = Ext.create("Ext.LoadMask", { msg: me.textLoading, - target: Ext.ComponentQuery.query('xviewport')[0] + target: Ext.ComponentQuery.query("xviewport")[0] }); // shortcuts @@ -147,10 +147,10 @@ Ext.define('Dbui.wizard.Wizard', { me.callParent(arguments); - me.window = me.up('window'); + me.window = me.up("window"); if (me.window) { - me.window.on('beforeclose', me.onClose, me); + me.window.on("beforeclose", me.onClose, me); } },