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>
......
...@@ -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