Commit 417c07be authored by Jérome Perrin's avatar Jérome Perrin

SQL hint wip

parent 8ee1f4cd
......@@ -78,6 +78,8 @@
<script type="text/javascript" src="&dtml-portal_url;/codemirror/mode/xml/xml.js"></script>\n
<script type="text/javascript" src="&dtml-portal_url;/codemirror/mode/javascript/javascript.js"></script>\n
<script type="text/javascript" src="&dtml-portal_url;/codemirror/mode/css/css.js"></script>\n
<dtml-elif expr="mode == \'sql\'">\n
<script type="text/javascript" src="&dtml-portal_url;/codemirror/addon/hint/sql-hint.js"></script>\n
</dtml-if>\n
\n
<style type="text/css">\n
......@@ -515,6 +517,14 @@
if(parent_height !== undefined && parent_height > (300 * 0.8)) {\n
cm.setSize(undefined, parent_height);\n
}\n
\n
<dtml-if sql_hint>\n
CodeMirror.commands.autocomplete = function(cm) {\n
CodeMirror.showHint(cm, CodeMirror.hint.sql, {\n
tables: <dtml-var sql_hint>\n
} );\n
}\n
</dtml-if>\n
\n
updateErrorWarningMessageDivWithJump();\n
\n
......
......@@ -39,6 +39,7 @@ def manage_page_footer(self):
live_check_python_script = 0 # Check python scripts on the fly
bound_names = 'undefined'
sql_hint = None
if document.meta_type in ('DTML Document', 'DTML Method'):
if document.getId().endswith('.js'):
......@@ -70,6 +71,8 @@ def manage_page_footer(self):
elif document.meta_type in ('Z SQL Method', ):
mode = 'sql'
textarea_selector = 'textarea[name="template:text"]'
sql_hint = json.dumps({"catalog": ["uid", ], "stock": ["aggregate_uid", "node_uid"]})
print sql_hint
elif document.meta_type in ('Z MySQL Database Connection', ):
mode = 'sql'
textarea_selector = 'textarea[name="query:text"]'
......@@ -94,7 +97,8 @@ def manage_page_footer(self):
portal.code_mirror_support(textarea_selector=textarea_selector,
portal_url=portal_url,
bound_names=bound_names,
mode=mode))
mode=mode,
sql_hint=sql_hint))
else:
return '''
<script type="text/javascript" src="%(portal_url)s/jquery/core/jquery.min.js"></script>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment