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 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>960.22665.29363.19012</string> </value>
<value> <string>962.25896.19672.42530</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -256,7 +256,7 @@
</tuple>
<state>
<tuple>
<float>1498653669.27</float>
<float>1506615149.84</float>
<string>UTC</string>
</tuple>
</state>
......
hr#post_item {
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 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>961.52427.49644.32460</string> </value>
<value> <string>962.25927.37961.31180</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -260,7 +260,7 @@
</tuple>
<state>
<tuple>
<float>1504274901.65</float>
<float>1506616796.9</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -27,8 +27,8 @@
<form>
<p style="background-color:#0E81C2;color:white;margin:1em 0;padding:0.5em">Comments:</p>
<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>
<div class='editor'></div>
<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>
<textarea id="comment" name="comment" placeholder="Enter your comment here..."></textarea>
<div id="file_upload_div">
<input value="" name="attachment" id="attachment" type="file" title="Upload">
</div>
......
......@@ -234,7 +234,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>961.56866.43597.46421</string> </value>
<value> <string>962.25925.39167.29235</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -252,7 +252,7 @@
</tuple>
<state>
<tuple>
<float>1504599826.73</float>
<float>1506616673.69</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -150,7 +150,7 @@
})
.push(function (result_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) {
for (i = 0; i < post_list.length; i += 1) {
s += '<li>' +
......@@ -160,13 +160,14 @@
post_list[i][3] = result_list[i];
}
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]) {
s += post_list[i][2] + '<strong>Attachment: </strong>' +
s += plain_content + '<strong>Attachment: </strong>' +
'<a href=\"' +
post_list[i][3] + '\">' + post_list[i][4] +
'</a>';
} else {
s += post_list[i][2];
s += plain_content;
}
} else {
if (post_list[i][3]) {
......@@ -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 () {
var gadget = this,
editor_gadget;
editor = gadget.element.querySelector('#comment');
return gadget.getDeclaredGadget('editor')
.push(function (text_content_gadget) {
editor_gadget = text_content_gadget;
return text_content_gadget.getContent();
})
.push(function (data) {
var post_content = Object.values(data)[0],
choose_file_html_element = gadget.element.querySelector('#attachment'),
if (editor.value === '') {
return gadget.notifySubmitted("Post content can not be empty!");
}
return gadget.notifySubmitted("Comment added")
.push(function () {
var choose_file_html_element = gadget.element.querySelector('#attachment'),
file_blob = choose_file_html_element.files[0],
file_upload_div = gadget.element.querySelector('#file_upload_div');
file_upload_div.innerHTML = file_upload_div.innerHTML;
return [post_content, file_blob];
})
.push(function (result) {
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", editor.value);
data.append("file", file_blob);
// XXX: Hack, call jIO.util.ajax directly to pass the file blob
// Because the jio_putAttachment will call readBlobAsText, which
// will broke the binary file. Call the jIO.util.ajax directly
// 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({
"type": "POST",
"url": url,
......@@ -230,12 +216,7 @@
});
})
.push(function () {
return RSVP.all([
editor_gadget.render({}),
gadget.notifySubmitted("Comment added")
]);
})
.push(function () {
editor.value = '';
return gadget.redirect({command: 'reload'});
});
});
......
......@@ -230,7 +230,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>961.52427.23351.30344</string> </value>
<value> <string>962.26841.11048.12373</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -248,7 +248,7 @@
</tuple>
<state>
<tuple>
<float>1504277022.09</float>
<float>1506671693.93</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -51,9 +51,14 @@
</tr>
<tr>
<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>
</tr>
<tr>
<td>type</td>
<td>//textarea[@id='field_my_description']</td>
<td>Post test</td>
</tr>
<tr>
<td>click</td>
<td>//input[@data-i18n='[value]Proceed']</td>
......
......@@ -51,9 +51,14 @@
</tr>
<tr>
<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>
</tr>
<tr>
<td>type</td>
<td>//textarea[@id='field_my_description']</td>
<td>Post test 1</td>
</tr>
<tr>
<td>waitForElementPresent</td>
<td>//input[@data-i18n='[value]Proceed']</td>
......@@ -71,13 +76,13 @@
</tr>
<tr>
<td>waitForElementPresent</td>
<td>//div[@id="cke_editor1"]</td>
<td>//textarea[@id='comment']</td>
<td></td>
</tr>
<tr>
<td>waitForElementPresent</td>
<td>//body[@class='cke_editable cke_editable_themed cke_contents_ltr cke_show_borders']</td>
<td></td>
<td>type</td>
<td>//textarea[@id='comment']</td>
<td>Post test 2</td>
</tr>
<tr>
<td>click</td>
......
......@@ -26,9 +26,14 @@
</tr>
<tr>
<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>
</tr>
<tr>
<td>type</td>
<td>//textarea[@id='field_my_description']</td>
<td>Post test</td>
</tr>
<tr>
<td>type</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