Commit 5704998d authored by Xiaowu Zhang's avatar Xiaowu Zhang Committed by Tatuya Kamada

erp5_ace_editor: improve portal callables scripts

Fix error display after save
Fix parameters not recognized
Fix python linting
the same way as ERP5 Script Python
parent 7c3fb2b9
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
div_id string:${id}_ace; div_id string:${id}_ace;
mode python: here.Base_getAceEditorMode(); mode python: here.Base_getAceEditorMode();
container_div_id string:${div_id}_container; container_div_id string:${div_id}_container;
params python: getattr(here, "getParameterSignature", None)
'> '>
<style type="text/css"> <style type="text/css">
.ace_scroller { .ace_scroller {
...@@ -149,6 +150,7 @@ ...@@ -149,6 +150,7 @@
ace_editor_container_div = null; ace_editor_container_div = null;
ace_editor = null; ace_editor = null;
var mode = '${mode}'; var mode = '${mode}';
var params = '${params}';
function maximizeFullscreenRemoveSaveMessage() { function maximizeFullscreenRemoveSaveMessage() {
$('.ace_editor_maximize_fullscreen_message').remove(); $('.ace_editor_maximize_fullscreen_message').remove();
...@@ -391,17 +393,21 @@ ...@@ -391,17 +393,21 @@
ace.require('ace/ext/language_tools'); ace.require('ace/ext/language_tools');
ace_editor.setOptions({ enableBasicAutocompletion: true, enableSnippets: true }); ace_editor.setOptions({ enableBasicAutocompletion: true, enableSnippets: true });
var data_options = {};
if (params !== 'None') {
data_options.bound_names = ['context','container','script','traverse_subpath','printed','same_type','string','sequence','random','DateTime','whrandom','reorder','sets','test','math'],
data_options.params = params;
}
timer = 0; timer = 0;
function checkPythonSourceCode() { function checkPythonSourceCode() {
if (timer) { if (timer) {
window.clearTimeout(timer); window.clearTimeout(timer);
timer = 0; timer = 0;
} }
data_options.code = ace_editor.getSession().getValue();
timer = window.setTimeout(function() { timer = window.setTimeout(function() {
$.post('${portal_url}/ERP5Site_checkPythonSourceCodeAsJSON', $.post('${portal_url}/ERP5Site_checkPythonSourceCodeAsJSON',
{'data': JSON.stringify( {'data': JSON.stringify(data_options)},
{ code: ace_editor.getSession().getValue() })},
function(data){ function(data){
ace_editor.getSession().setAnnotations(data.annotations); ace_editor.getSession().setAnnotations(data.annotations);
} }
......
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