Commit 47a8c892 authored by Sebastien Robin's avatar Sebastien Robin

erp5_*: Migrate code editor to renderJS gadget fields on Python Scripts

It requires to include codemirror python syntax highlighting
parent 6ce83989
...@@ -67,6 +67,7 @@ ...@@ -67,6 +67,7 @@
<script type="text/javascript" src="codemirror/mode/xml/xml.js"></script> <script type="text/javascript" src="codemirror/mode/xml/xml.js"></script>
<script type="text/javascript" src="codemirror/mode/javascript/javascript.js"></script> <script type="text/javascript" src="codemirror/mode/javascript/javascript.js"></script>
<script type="text/javascript" src="codemirror/mode/python/python.js"></script>
<script type="text/javascript" src="codemirror/mode/css/css.js"></script> <script type="text/javascript" src="codemirror/mode/css/css.js"></script>
<script type="text/javascript" src="codemirror/mode/htmlmixed/htmlmixed.js"></script> <script type="text/javascript" src="codemirror/mode/htmlmixed/htmlmixed.js"></script>
......
...@@ -78,6 +78,9 @@ ...@@ -78,6 +78,9 @@
mode = 'javascript'; mode = 'javascript';
} else if (options.portal_type === 'Web Style') { } else if (options.portal_type === 'Web Style') {
mode = 'css'; mode = 'css';
} else if (options.portal_type === 'Python Script') {
console.log("switch to mode python");
Please register or sign in to reply
mode = 'python';
} }
state_dict.mode = mode; state_dict.mode = mode;
state_dict.value = options.value || ""; state_dict.value = options.value || "";
......
...@@ -140,6 +140,7 @@ codemirror/addon/lint/javascript-lint.js\n ...@@ -140,6 +140,7 @@ codemirror/addon/lint/javascript-lint.js\n
csslint.js\n csslint.js\n
codemirror/addon/lint/css-lint.js\n codemirror/addon/lint/css-lint.js\n
codemirror/mode/xml/xml.js\n codemirror/mode/xml/xml.js\n
codemirror/mode/python/python.js\n
codemirror/mode/javascript/javascript.js\n codemirror/mode/javascript/javascript.js\n
codemirror/mode/css/css.js\n codemirror/mode/css/css.js\n
codemirror/mode/htmlmixed/htmlmixed.js\n codemirror/mode/htmlmixed/htmlmixed.js\n
...@@ -272,7 +273,7 @@ NETWORK:\n ...@@ -272,7 +273,7 @@ NETWORK:\n
</item> </item>
<item> <item>
<key> <string>actor</string> </key> <key> <string>actor</string> </key>
<value> <string>zope</string> </value> <value> <string>superseb</string> </value>
</item> </item>
<item> <item>
<key> <string>comment</string> </key> <key> <string>comment</string> </key>
...@@ -286,7 +287,7 @@ NETWORK:\n ...@@ -286,7 +287,7 @@ NETWORK:\n
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>962.48895.14326.63948</string> </value> <value> <string>963.2052.23883.60586</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -304,8 +305,8 @@ NETWORK:\n ...@@ -304,8 +305,8 @@ NETWORK:\n
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1507908439.82</float> <float>1509031162.48</float>
<string>UTC</string> <string>GMT+2</string>
</tuple> </tuple>
</state> </state>
</object> </object>
......
...@@ -2,10 +2,19 @@ ...@@ -2,10 +2,19 @@
<ZopeData> <ZopeData>
<record id="1" aka="AAAAAAAAAAE="> <record id="1" aka="AAAAAAAAAAE=">
<pickle> <pickle>
<global name="EditorField" module="Products.ERP5Form.EditorField"/> <global name="ProxyField" module="Products.ERP5Form.ProxyField"/>
</pickle> </pickle>
<pickle> <pickle>
<dictionary> <dictionary>
<item>
<key> <string>delegated_list</string> </key>
<value>
<list>
<string>description</string>
<string>title</string>
</list>
</value>
</item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>my_body</string> </value> <value> <string>my_body</string> </value>
...@@ -18,22 +27,6 @@ ...@@ -18,22 +27,6 @@
<key> <string>external_validator_failed</string> </key> <key> <string>external_validator_failed</string> </key>
<value> <string>The input failed the external validator.</string> </value> <value> <string>The input failed the external validator.</string> </value>
</item> </item>
<item>
<key> <string>line_too_long</string> </key>
<value> <string>A line was too long.</string> </value>
</item>
<item>
<key> <string>required_not_found</string> </key>
<value> <string>Input is required but no input given.</string> </value>
</item>
<item>
<key> <string>too_long</string> </key>
<value> <string>You entered too many characters.</string> </value>
</item>
<item>
<key> <string>too_many_lines</string> </key>
<value> <string>You entered too many lines.</string> </value>
</item>
</dictionary> </dictionary>
</value> </value>
</item> </item>
...@@ -42,79 +35,15 @@ ...@@ -42,79 +35,15 @@
<value> <value>
<dictionary> <dictionary>
<item> <item>
<key> <string>alternate_name</string> </key> <key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>css_class</string> </key>
<value> <string></string> </value> <value> <string></string> </value>
</item> </item>
<item> <item>
<key> <string>default</string> </key> <key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value> <value> <string></string> </value>
</item> </item>
<item> <item>
<key> <string>editable</string> </key> <key> <string>target</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>enabled</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>external_validator</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>extra</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>height</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>hidden</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>max_length</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>max_linelength</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>max_lines</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>required</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>text_editor</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>unicode</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>whitespace_preserve</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>width</string> </key>
<value> <string></string> </value> <value> <string></string> </value>
</item> </item>
</dictionary> </dictionary>
...@@ -124,36 +53,16 @@ ...@@ -124,36 +53,16 @@
<key> <string>tales</string> </key> <key> <string>tales</string> </key>
<value> <value>
<dictionary> <dictionary>
<item>
<key> <string>alternate_name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>css_class</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>default</string> </key>
<value> <string></string> </value>
</item>
<item> <item>
<key> <string>description</string> </key> <key> <string>description</string> </key>
<value> <string></string> </value> <value> <string></string> </value>
</item> </item>
<item> <item>
<key> <string>editable</string> </key> <key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>enabled</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>external_validator</string> </key>
<value> <string></string> </value> <value> <string></string> </value>
</item> </item>
<item> <item>
<key> <string>extra</string> </key> <key> <string>form_id</string> </key>
<value> <string></string> </value> <value> <string></string> </value>
</item> </item>
<item> <item>
...@@ -161,47 +70,13 @@ ...@@ -161,47 +70,13 @@
<value> <string></string> </value> <value> <string></string> </value>
</item> </item>
<item> <item>
<key> <string>hidden</string> </key> <key> <string>target</string> </key>
<value> <string></string> </value> <value> <string></string> </value>
</item> </item>
<item>
<key> <string>max_length</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>max_linelength</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>max_lines</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>required</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>text_editor</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item> <item>
<key> <string>title</string> </key> <key> <string>title</string> </key>
<value> <string></string> </value> <value> <string></string> </value>
</item> </item>
<item>
<key> <string>unicode</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>whitespace_preserve</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>width</string> </key>
<value> <string></string> </value>
</item>
</dictionary> </dictionary>
</value> </value>
</item> </item>
...@@ -209,81 +84,29 @@ ...@@ -209,81 +84,29 @@
<key> <string>values</string> </key> <key> <string>values</string> </key>
<value> <value>
<dictionary> <dictionary>
<item>
<key> <string>alternate_name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>css_class</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>default</string> </key>
<value> <string></string> </value>
</item>
<item> <item>
<key> <string>description</string> </key> <key> <string>description</string> </key>
<value> <string></string> </value> <value> <string>Script code</string> </value>
</item> </item>
<item> <item>
<key> <string>editable</string> </key> <key> <string>field_id</string> </key>
<value> <int>1</int> </value> <value> <string>my_text_content</string> </value>
</item> </item>
<item> <item>
<key> <string>enabled</string> </key> <key> <string>form_id</string> </key>
<value> <int>1</int> </value> <value> <string>Base_viewWebFieldLibrary</string> </value>
  • Base_viewWebFieldLibrary is in erp5_web, but this form is in erp5_core.

    On an ERP5 instance where erp5_web is not installed, I have:

    Could not get a field from a proxy field my_body in SQLCatalog_makeQuickSearchQuery

    error in the log and no field is displayed.

    Edited by Jérome Perrin
Please register or sign in to reply
</item>
<item>
<key> <string>external_validator</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>extra</string> </key>
<value> <string>style="width: 100%"</string> </value>
</item> </item>
<item> <item>
<key> <string>height</string> </key> <key> <string>height</string> </key>
<value> <int>20</int> </value> <value> <int>40</int> </value>
</item>
<item>
<key> <string>hidden</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>max_length</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>max_linelength</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>max_lines</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>required</string> </key>
<value> <int>0</int> </value>
</item> </item>
<item> <item>
<key> <string>text_editor</string> </key> <key> <string>target</string> </key>
<value> <string>text_area</string> </value> <value> <string>Click to edit the target</string> </value>
</item> </item>
<item> <item>
<key> <string>title</string> </key> <key> <string>title</string> </key>
<value> <string>Body</string> </value> <value> <string>Script</string> </value>
</item>
<item>
<key> <string>unicode</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>whitespace_preserve</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>width</string> </key>
<value> <int>60</int> </value>
</item> </item>
</dictionary> </dictionary>
</value> </value>
...@@ -291,17 +114,4 @@ ...@@ -291,17 +114,4 @@
</dictionary> </dictionary>
</pickle> </pickle>
</record> </record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="TALESMethod" module="Products.Formulator.TALESField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>python: here.portal_preferences.getPreferredSourceCodeEditor()</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData> </ZopeData>
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