Commit b6dbfb28 authored by Boxiang Sun's avatar Boxiang Sun Committed by Eteri

erp5_officejs_support_request_ui: Switch from ckeditor 4.5.3 to textarea for now.

ckeditor 4.5.3 cannot work properly on Android and iPhone. Before update it to latest
version. We need to check the compatibility issue of other officejs. For now, just use
textarea instead buggy ckeditor.

And update the test for textarea.
parent 2df8e1a4
...@@ -238,7 +238,7 @@ ...@@ -238,7 +238,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>960.22665.29363.19012</string> </value> <value> <string>962.25896.19672.42530</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -256,7 +256,7 @@ ...@@ -256,7 +256,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1498653669.27</float> <float>1506615149.84</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
hr#post_item { hr#post_item {
border-color: #0E81C2; border-color: #0E81C2;
} }
#comment-title {
margin-top: 20px;
}
#comment {
margin-top: 20px;
margin-bottom: 20px;
}
\ No newline at end of file
...@@ -242,7 +242,7 @@ ...@@ -242,7 +242,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>961.52427.49644.32460</string> </value> <value> <string>962.25927.37961.31180</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -260,7 +260,7 @@ ...@@ -260,7 +260,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1504274901.65</float> <float>1506616796.9</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -27,8 +27,8 @@ ...@@ -27,8 +27,8 @@
<form> <form>
<p style="background-color:#0E81C2;color:white;margin:1em 0;padding:0.5em">Comments:</p> <p style="background-color:#0E81C2;color:white;margin:1em 0;padding:0.5em">Comments:</p>
<ol id="post_list"></ol> <ol id="post_list"></ol>
<h3 class="ui-content-title ui-body-c ui-icon ui-icon-custom ui-icon-random">&nbsp;Post a comment</h3> <h3 class="ui-content-title ui-body-c ui-icon ui-icon-custom ui-icon-random" id="comment-title" name="comment-title">&nbsp;Post a comment</h3>
<div class='editor'></div> <textarea id="comment" name="comment" placeholder="Enter your comment here..."></textarea>
<div id="file_upload_div"> <div id="file_upload_div">
<input value="" name="attachment" id="attachment" type="file" title="Upload"> <input value="" name="attachment" id="attachment" type="file" title="Upload">
</div> </div>
......
...@@ -234,7 +234,7 @@ ...@@ -234,7 +234,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>961.56866.43597.46421</string> </value> <value> <string>962.25925.39167.29235</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -252,7 +252,7 @@ ...@@ -252,7 +252,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1504599826.73</float> <float>1506616673.69</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -150,7 +150,7 @@ ...@@ -150,7 +150,7 @@
}) })
.push(function (result_list) { .push(function (result_list) {
var s = '', i, comments = gadget.element.querySelector("#post_list"), var s = '', i, comments = gadget.element.querySelector("#post_list"),
post_list = result_list.pop(); plain_content, post_list = result_list.pop();
if (post_list.length) { if (post_list.length) {
for (i = 0; i < post_list.length; i += 1) { for (i = 0; i < post_list.length; i += 1) {
s += '<li>' + s += '<li>' +
...@@ -160,13 +160,14 @@ ...@@ -160,13 +160,14 @@
post_list[i][3] = result_list[i]; post_list[i][3] = result_list[i];
} }
if (post_list[i][2]) { if (post_list[i][2]) {
plain_content = "<p>" + post_list[i][2].replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/\n/g, "<br/>") + "</p>";
if (post_list[i][3]) { if (post_list[i][3]) {
s += post_list[i][2] + '<strong>Attachment: </strong>' + s += plain_content + '<strong>Attachment: </strong>' +
'<a href=\"' + '<a href=\"' +
post_list[i][3] + '\">' + post_list[i][4] + post_list[i][3] + '\">' + post_list[i][4] +
'</a>'; '</a>';
} else { } else {
s += post_list[i][2]; s += plain_content;
} }
} else { } else {
if (post_list[i][3]) { if (post_list[i][3]) {
...@@ -183,43 +184,28 @@ ...@@ -183,43 +184,28 @@
} }
}); });
}) })
.declareService(function () {
var gadget = this;
return gadget.declareGadget("officejs_ckeditor_gadget/app/",
{
element: gadget.element.querySelector('.editor'),
sandbox: 'iframe',
scope: 'editor'
});
})
.onEvent('submit', function () { .onEvent('submit', function () {
var gadget = this, var gadget = this,
editor_gadget; editor = gadget.element.querySelector('#comment');
return gadget.getDeclaredGadget('editor') if (editor.value === '') {
.push(function (text_content_gadget) { return gadget.notifySubmitted("Post content can not be empty!");
editor_gadget = text_content_gadget; }
return text_content_gadget.getContent();
}) return gadget.notifySubmitted("Comment added")
.push(function (data) { .push(function () {
var post_content = Object.values(data)[0], var choose_file_html_element = gadget.element.querySelector('#attachment'),
choose_file_html_element = gadget.element.querySelector('#attachment'),
file_blob = choose_file_html_element.files[0], file_blob = choose_file_html_element.files[0],
file_upload_div = gadget.element.querySelector('#file_upload_div'); url = gadget.hateoas_url + "post_module/PostModule_createHTMLPost",
file_upload_div.innerHTML = file_upload_div.innerHTML; data = new FormData();
return [post_content, file_blob]; data.append("follow_up", gadget.options.jio_key);
}) data.append("predecessor", '');
.push(function (result) { data.append("data", editor.value);
data.append("file", file_blob);
// XXX: Hack, call jIO.util.ajax directly to pass the file blob // XXX: Hack, call jIO.util.ajax directly to pass the file blob
// Because the jio_putAttachment will call readBlobAsText, which // Because the jio_putAttachment will call readBlobAsText, which
// will broke the binary file. Call the jIO.util.ajax directly // will broke the binary file. Call the jIO.util.ajax directly
// will not touch the blob // will not touch the blob
var url = gadget.hateoas_url + "post_module/PostModule_createHTMLPost",
data = new FormData();
data.append("follow_up", gadget.options.jio_key);
data.append("predecessor", '');
data.append("data", result[0]);
data.append("file", result[1]);
return jIO.util.ajax({ return jIO.util.ajax({
"type": "POST", "type": "POST",
"url": url, "url": url,
...@@ -230,12 +216,7 @@ ...@@ -230,12 +216,7 @@
}); });
}) })
.push(function () { .push(function () {
return RSVP.all([ editor.value = '';
editor_gadget.render({}),
gadget.notifySubmitted("Comment added")
]);
})
.push(function () {
return gadget.redirect({command: 'reload'}); return gadget.redirect({command: 'reload'});
}); });
}); });
......
...@@ -230,7 +230,7 @@ ...@@ -230,7 +230,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>961.52427.23351.30344</string> </value> <value> <string>962.26841.11048.12373</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -248,7 +248,7 @@ ...@@ -248,7 +248,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1504277022.09</float> <float>1506671693.93</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -2,21 +2,10 @@ ...@@ -2,21 +2,10 @@
<ZopeData> <ZopeData>
<record id="1" aka="AAAAAAAAAAE="> <record id="1" aka="AAAAAAAAAAE=">
<pickle> <pickle>
<global name="ProxyField" module="Products.ERP5Form.ProxyField"/> <global name="TextAreaField" module="Products.Formulator.StandardFields"/>
</pickle> </pickle>
<pickle> <pickle>
<dictionary> <dictionary>
<item>
<key> <string>delegated_list</string> </key>
<value>
<list>
<string>enabled</string>
<string>gadget_url</string>
<string>js_sandbox</string>
<string>title</string>
</list>
</value>
</item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>my_description</string> </value> <value> <string>my_description</string> </value>
...@@ -29,6 +18,22 @@ ...@@ -29,6 +18,22 @@
<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>Please provide a description for this support request.</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>
...@@ -37,15 +42,75 @@ ...@@ -37,15 +42,75 @@
<value> <value>
<dictionary> <dictionary>
<item> <item>
<key> <string>field_id</string> </key> <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> <value> <string></string> </value>
</item> </item>
<item> <item>
<key> <string>form_id</string> </key> <key> <string>description</string> </key>
<value> <string></string> </value> <value> <string></string> </value>
</item> </item>
<item> <item>
<key> <string>target</string> </key> <key> <string>editable</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>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>
...@@ -55,36 +120,78 @@ ...@@ -55,36 +120,78 @@
<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>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>editable</string> </key>
<value> <string></string> </value>
</item>
<item> <item>
<key> <string>enabled</string> </key> <key> <string>enabled</string> </key>
<value> <string></string> </value> <value> <string></string> </value>
</item> </item>
<item> <item>
<key> <string>field_id</string> </key> <key> <string>external_validator</string> </key>
<value> <string></string> </value> <value> <string></string> </value>
</item> </item>
<item> <item>
<key> <string>form_id</string> </key> <key> <string>extra</string> </key>
<value> <string></string> </value> <value> <string></string> </value>
</item> </item>
<item> <item>
<key> <string>gadget_url</string> </key> <key> <string>height</string> </key>
<value> <value> <string></string> </value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent> </item>
</value> <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>
<item> <item>
<key> <string>js_sandbox</string> </key> <key> <string>max_lines</string> </key>
<value> <string></string> </value> <value> <string></string> </value>
</item> </item>
<item> <item>
<key> <string>target</string> </key> <key> <string>required</string> </key>
<value> <string></string> </value> <value> <string></string> </value>
</item> </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>
...@@ -92,49 +199,80 @@ ...@@ -92,49 +199,80 @@
<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>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>editable</string> </key>
<value> <int>1</int> </value>
</item>
<item> <item>
<key> <string>enabled</string> </key> <key> <string>enabled</string> </key>
<value> <int>1</int> </value> <value> <int>1</int> </value>
</item> </item>
<item> <item>
<key> <string>field_id</string> </key> <key> <string>external_validator</string> </key>
<value> <string>my_gadget_field</string> </value> <value> <string></string> </value>
</item> </item>
<item> <item>
<key> <string>form_id</string> </key> <key> <string>extra</string> </key>
<value> <string>Base_viewFieldLibrary</string> </value> <value> <string></string> </value>
</item> </item>
<item> <item>
<key> <string>gadget_url</string> </key> <key> <string>height</string> </key>
<value> <int>5</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> <value> <string></string> </value>
</item> </item>
<item> <item>
<key> <string>js_sandbox</string> </key> <key> <string>max_linelength</string> </key>
<value> <string>iframe</string> </value> <value> <string></string> </value>
</item>
<item>
<key> <string>max_lines</string> </key>
<value> <string></string> </value>
</item> </item>
<item> <item>
<key> <string>target</string> </key> <key> <string>required</string> </key>
<value> <string>Click to edit the target</string> </value> <value> <int>1</int> </value>
</item> </item>
<item> <item>
<key> <string>title</string> </key> <key> <string>title</string> </key>
<value> <string>Description</string> </value> <value> <string>my_description</string> </value>
</item> </item>
</dictionary> <item>
</value> <key> <string>unicode</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>whitespace_preserve</string> </key>
<value> <int>0</int> </value>
</item> </item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="TALESMethod" module="Products.Formulator.TALESField"/>
</pickle>
<pickle>
<dictionary>
<item> <item>
<key> <string>_text</string> </key> <key> <string>width</string> </key>
<value> <string>python: field.restrictedTraverse("officejs_ckeditor_gadget/app").absolute_url() + "/"</string> </value> <value> <int>40</int> </value>
</item>
</dictionary>
</value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
......
...@@ -51,9 +51,14 @@ ...@@ -51,9 +51,14 @@
</tr> </tr>
<tr> <tr>
<td>waitForElementPresent</td> <td>waitForElementPresent</td>
<td>//body[@class='cke_editable cke_editable_themed cke_contents_ltr cke_show_borders']</td> <td>//textarea[@id='field_my_description']</td>
<td></td> <td></td>
</tr> </tr>
<tr>
<td>type</td>
<td>//textarea[@id='field_my_description']</td>
<td>Post test</td>
</tr>
<tr> <tr>
<td>click</td> <td>click</td>
<td>//input[@data-i18n='[value]Proceed']</td> <td>//input[@data-i18n='[value]Proceed']</td>
......
...@@ -51,9 +51,14 @@ ...@@ -51,9 +51,14 @@
</tr> </tr>
<tr> <tr>
<td>waitForElementPresent</td> <td>waitForElementPresent</td>
<td>//body[@class='cke_editable cke_editable_themed cke_contents_ltr cke_show_borders']</td> <td>//textarea[@id='field_my_description']</td>
<td></td> <td></td>
</tr> </tr>
<tr>
<td>type</td>
<td>//textarea[@id='field_my_description']</td>
<td>Post test 1</td>
</tr>
<tr> <tr>
<td>waitForElementPresent</td> <td>waitForElementPresent</td>
<td>//input[@data-i18n='[value]Proceed']</td> <td>//input[@data-i18n='[value]Proceed']</td>
...@@ -71,13 +76,13 @@ ...@@ -71,13 +76,13 @@
</tr> </tr>
<tr> <tr>
<td>waitForElementPresent</td> <td>waitForElementPresent</td>
<td>//div[@id="cke_editor1"]</td> <td>//textarea[@id='comment']</td>
<td></td> <td></td>
</tr> </tr>
<tr> <tr>
<td>waitForElementPresent</td> <td>type</td>
<td>//body[@class='cke_editable cke_editable_themed cke_contents_ltr cke_show_borders']</td> <td>//textarea[@id='comment']</td>
<td></td> <td>Post test 2</td>
</tr> </tr>
<tr> <tr>
<td>click</td> <td>click</td>
......
...@@ -26,9 +26,14 @@ ...@@ -26,9 +26,14 @@
</tr> </tr>
<tr> <tr>
<td>waitForElementPresent</td> <td>waitForElementPresent</td>
<td>//body[@class='cke_editable cke_editable_themed cke_contents_ltr cke_show_borders']</td> <td>//textarea[@id='field_my_description']</td>
<td></td> <td></td>
</tr> </tr>
<tr>
<td>type</td>
<td>//textarea[@id='field_my_description']</td>
<td>Post test</td>
</tr>
<tr> <tr>
<td>type</td> <td>type</td>
<td>//input[@name='field_your_title']</td> <td>//input[@name='field_your_title']</td>
......
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