Commit 7783be22 authored by Boxiang Sun's avatar Boxiang Sun Committed by Tristan Cavelier

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 a27ecf00
......@@ -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>
......
......@@ -2,21 +2,10 @@
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ProxyField" module="Products.ERP5Form.ProxyField"/>
<global name="TextAreaField" module="Products.Formulator.StandardFields"/>
</pickle>
<pickle>
<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>
<key> <string>id</string> </key>
<value> <string>my_description</string> </value>
......@@ -29,6 +18,22 @@
<key> <string>external_validator_failed</string> </key>
<value> <string>The input failed the external validator.</string> </value>
</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>
</value>
</item>
......@@ -37,15 +42,75 @@
<value>
<dictionary>
<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>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<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>form_id</string> </key>
<key> <string>height</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<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>
</item>
</dictionary>
......@@ -55,36 +120,78 @@
<key> <string>tales</string> </key>
<value>
<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>
<key> <string>enabled</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>field_id</string> </key>
<key> <string>external_validator</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<key> <string>extra</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>gadget_url</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
<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>js_sandbox</string> </key>
<key> <string>max_lines</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<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>
</item>
</dictionary>
</value>
</item>
......@@ -92,33 +199,77 @@
<key> <string>values</string> </key>
<value>
<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>
<key> <string>enabled</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>field_id</string> </key>
<value> <string>my_gadget_field</string> </value>
<key> <string>external_validator</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string>Base_viewFieldLibrary</string> </value>
<key> <string>extra</string> </key>
<value> <string></string> </value>
</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>
</item>
<item>
<key> <string>js_sandbox</string> </key>
<value> <string>iframe</string> </value>
<key> <string>max_linelength</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string>Click to edit the target</string> </value>
<key> <string>max_lines</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>required</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Description</string> </value>
<value> <string>my_description</string> </value>
</item>
<item>
<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>
<key> <string>width</string> </key>
<value> <int>40</int> </value>
</item>
</dictionary>
</value>
......@@ -126,17 +277,4 @@
</dictionary>
</pickle>
</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: field.restrictedTraverse("officejs_ckeditor_gadget/app").absolute_url() + "/"</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -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