Commit 50b9ddf9 authored by Boxiang Sun's avatar Boxiang Sun

erp5_officejs_support_request_ui: Switch back to ckeditor with lesser buttons in toolbar.

Use ckeditor in "basic" form which has lesser buttons in toolbar.
Use basic ckeditor in the discussble page and use original ckeditor in fast input dialog.
parent dd3a03a4
......@@ -238,7 +238,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>962.26853.29747.36369</string> </value>
<value> <string>962.43041.12240.55637</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -256,7 +256,7 @@
</tuple>
<state>
<tuple>
<float>1506672340.09</float>
<float>1507621084.49</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -28,7 +28,7 @@
<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" id="comment-title" name="comment-title">&nbsp;Post a comment</h3>
<textarea id="comment" name="comment" placeholder="Enter your comment here..."></textarea>
<div class='editor'></div>
<div id="file_upload_div">
<input value="" name="attachment" id="attachment" type="file" title="Upload">
</div>
......
......@@ -252,7 +252,7 @@
</tuple>
<state>
<tuple>
<float>1506616673.69</float>
<float>1507215649.43</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -150,7 +150,7 @@
})
.push(function (result_list) {
var s = '', i, comments = gadget.element.querySelector("#post_list"),
plain_content, post_list = result_list.pop();
post_list = result_list.pop();
if (post_list.length) {
for (i = 0; i < post_list.length; i += 1) {
s += '<li>' +
......@@ -160,14 +160,13 @@
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 += plain_content + '<strong>Attachment: </strong>' +
s += post_list[i][2] + '<strong>Attachment: </strong>' +
'<a href=\"' +
post_list[i][3] + '\">' + post_list[i][4] +
'</a>';
} else {
s += plain_content;
s += post_list[i][2];
}
} else {
if (post_list[i][3]) {
......@@ -184,40 +183,69 @@
}
});
})
.declareService(function () {
var gadget = this;
return gadget.declareGadget("officejs_ckeditor_gadget/basic/",
{
element: gadget.element.querySelector('.editor'),
sandbox: 'iframe',
scope: 'editor'
})
.push(function () {
return gadget.getDeclaredGadget('editor');
})
.push(function (editor) {
return editor.render({});
});
})
.onEvent('submit', function () {
var gadget = this,
editor = gadget.element.querySelector('#comment');
if (editor.value === '') {
return gadget.notifySubmitted("Post content can not be empty!");
}
editor_gadget;
return gadget.notifySubmitted("Comment added")
.push(function () {
var choose_file_html_element = gadget.element.querySelector('#attachment'),
file_blob = choose_file_html_element.files[0],
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
return jIO.util.ajax({
"type": "POST",
"url": url,
"data": data,
"xhrFields": {
withCredentials: true
}
});
return gadget.getDeclaredGadget('editor')
.push(function (text_content_gadget) {
editor_gadget = text_content_gadget;
return text_content_gadget.getContent();
})
.push(function () {
editor.value = '';
return gadget.redirect({command: 'reload'});
.push(function (comment_content) {
if (comment_content.undefined === '') {
return gadget.notifySubmitted("Post content can not be empty!");
}
return gadget.notifySubmitted("Comment added")
.push(function () {
var post_content = Object.values(comment_content)[0],
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) {
// 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,
"data": data,
"xhrFields": {
withCredentials: true
}
});
})
.push(function () {
return RSVP.all([
editor_gadget.render({}),
gadget.redirect({command: 'reload'})
]);
});
});
});
}(window, rJS, RSVP, calculatePageTitle));
\ No newline at end of file
......@@ -230,7 +230,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>962.26841.11048.12373</string> </value>
<value> <string>962.44172.10672.28142</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -248,7 +248,7 @@
</tuple>
<state>
<tuple>
<float>1506671693.93</float>
<float>1507625618.81</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -2,7 +2,7 @@
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="TextAreaField" module="Products.Formulator.StandardFields"/>
<global name="GadgetField" module="Products.ERP5Form.GadgetField"/>
</pickle>
<pickle>
<dictionary>
......@@ -18,22 +18,6 @@
<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>
......@@ -49,6 +33,10 @@
<key> <string>css_class</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>data_url</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>default</string> </key>
<value> <string></string> </value>
......@@ -74,7 +62,7 @@
<value> <string></string> </value>
</item>
<item>
<key> <string>height</string> </key>
<key> <string>gadget_url</string> </key>
<value> <string></string> </value>
</item>
<item>
......@@ -82,37 +70,13 @@
<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>
<key> <string>js_sandbox</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>
......@@ -128,6 +92,10 @@
<key> <string>css_class</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>data_url</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>default</string> </key>
<value> <string></string> </value>
......@@ -153,45 +121,23 @@
<value> <string></string> </value>
</item>
<item>
<key> <string>height</string> </key>
<value> <string></string> </value>
<key> <string>gadget_url</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</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>
<key> <string>js_sandbox</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>
......@@ -207,6 +153,10 @@
<key> <string>css_class</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>data_url</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>default</string> </key>
<value> <string></string> </value>
......@@ -225,56 +175,60 @@
</item>
<item>
<key> <string>external_validator</string> </key>
<value> <string></string> </value>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>extra</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>height</string> </key>
<value> <int>5</int> </value>
<key> <string>gadget_url</string> </key>
<value> <string></string> </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>1</int> </value>
<key> <string>js_sandbox</string> </key>
<value> <string>iframe</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<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>
</item>
</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>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="Method" module="Products.Formulator.MethodField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>method_name</string> </key>
<value> <string>SupportRequest_fastInputDialogDescriptionValidator</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>*args</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>SupportRequest_fastInputDialogDescriptionValidator</string> </value>
</item>
</dictionary>
</pickle>
</record>
</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