Commit f31f08bd authored by Lu Xu's avatar Lu Xu 👀

erp5_officejs:implement App on officeJS

parent cfb9d0cc
...@@ -31,6 +31,12 @@ ...@@ -31,6 +31,12 @@
class='ui-flex-center'> class='ui-flex-center'>
</div> </div>
</form> </form>
<form class="save_form ui-body-c" novalidate>
<div data-gadget-url="gadget_erp5_pt_form_list.html"
data-gadget-scope="form_list"
data-gadget-sandbox="public"
class='ui-flex-bottom'>
</div>
</form>
</body> </body>
</html> </html>
...@@ -273,7 +273,7 @@ ...@@ -273,7 +273,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>967.17859.46531.61866</string> </value> <value> <string>976.22725.48476.52138</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -291,7 +291,7 @@ ...@@ -291,7 +291,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1525278837.04</float> <float>1560351706.09</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
/*global window, rJS, jIO, Handlebars, RSVP, Blob*/ /*global window, rJS, jIO, Handlebars, RSVP, Blob, SimpleQuery, ComplexQuery, Query*/
/*jslint indent:2, maxlen: 80, nomen: true */ /*jslint indent:2, maxlen: 80, nomen: true */
(function (window, rJS, jIO, RSVP) { (function (window, rJS, jIO, RSVP, SimpleQuery, ComplexQuery, Query) {
"use strict"; "use strict";
rJS(window) rJS(window)
...@@ -18,8 +18,44 @@ ...@@ -18,8 +18,44 @@
.declareAcquiredMethod("notifyChange", "notifyChange") .declareAcquiredMethod("notifyChange", "notifyChange")
.declareAcquiredMethod("notifySubmitted", "notifySubmitted") .declareAcquiredMethod("notifySubmitted", "notifySubmitted")
.declareAcquiredMethod("getUrlFor", "getUrlFor") .declareAcquiredMethod("getUrlFor", "getUrlFor")
.declareAcquiredMethod("getUrlParameter", "getUrlParameter")
.declareAcquiredMethod("jio_allDocs", "jio_allDocs")
.allowPublicAcquisition("jio_allDocs", function (param_list) {
var gadget = this;
return gadget.jio_allDocs(param_list[0])
.push(function (result) {
var i, date, len = result.data.total_rows;
for (i = 0; i < len; i += 1) {
if (result.data.rows[i].value.hasOwnProperty("modification_date")) {
date = new Date(result.data.rows[i].value.modification_date);
result.data.rows[i].value.modification_date = {
field_gadget_param: {
allow_empty_time: 0,
ampm_time_style: 0,
css_class: "date_field",
date_only: 0,
description: "The Date",
editable: 0,
hidden: 0,
hidden_day_is_last_day: 0,
"default": date.toUTCString(),
key: "modification_date",
required: 0,
timezone_style: 0,
title: "Modification Date",
type: "DateTimeField"
}
};
result.data.rows[i].value["listbox_uid:list"] = {
key: "listbox_uid:list",
value: 2713
};
}
}
return result;
});
})
.allowPublicAcquisition('updateHeader', function () { .allowPublicAcquisition('updateHeader', function () {
return; return;
...@@ -98,8 +134,11 @@ ...@@ -98,8 +134,11 @@
}; };
}); });
}) })
.declareMethod("render", function () { .declareMethod("render", function () {
var gadget = this; var gadget = this;
this.getDeclaredGadget('form_list');
return gadget.getSetting('jio_storage_name') return gadget.getSetting('jio_storage_name')
.push(function (result) { .push(function (result) {
if (!result) { if (!result) {
...@@ -110,10 +149,38 @@ ...@@ -110,10 +149,38 @@
.push(function () { .push(function () {
return RSVP.all([ return RSVP.all([
gadget.getDeclaredGadget('form_view_upload_audio'), gadget.getDeclaredGadget('form_view_upload_audio'),
gadget.getDeclaredGadget('form_view_image_text') gadget.getDeclaredGadget('form_view_image_text'),
gadget.getDeclaredGadget('form_list'),//added
gadget.getSetting("portal_type")
]); ]);
}) })
.push(function (result) { .push(function (result) {
var column_list = [
['title', 'Title'],
['modification_date', 'Modification Date'],
['validation_state', 'Validation State']
],
portal_type = result[3].split(','),
query = "urn:jio:allDocs?query=",
i,
jio_query_list = [];
for (i = 0; i < portal_type.length; i += 1) {
jio_query_list.push(new SimpleQuery({
key: "portal_type",
operator: "",
type: "simple",
value: portal_type[i]
}));
}
query += Query.objectToSearchText(new ComplexQuery({
operator: "OR",
query_list: jio_query_list,
type: "complex"
}));
return RSVP.all([ return RSVP.all([
result[0].render({ result[0].render({
erp5_document: {"_embedded": {"_view": { erp5_document: {"_embedded": {"_view": {
...@@ -194,6 +261,42 @@ ...@@ -194,6 +261,42 @@
[["text"]] [["text"]]
]] ]]
} }
}),
result[2].render({
erp5_document: {
"_embedded": {"_view": {
"listbox": {
"column_list": column_list,
"show_anchor": 0,
"default_params": {},
"editable": 1,
"editable_column_list": [],
"key": "field_listbox",
"lines": 30,
"list_method": "portal_catalog",
"query": query,
"portal_type": [],
"search_column_list": column_list,
"sort_column_list": column_list,
"sort": [['modification_date', 'descending']],
"title": "Notification",
"type": "ListBox"
}
}},
"_links": {
"type": {
// form_list display portal_type in header
name: ""
}
}
},
form_definition: {
group_list: [[
"bottom",
[["listbox"]]
]]
}
}) })
]); ]);
}) })
...@@ -216,4 +319,4 @@ ...@@ -216,4 +319,4 @@
}); });
}(window, rJS, jIO, RSVP)); }(window, rJS, jIO, RSVP, SimpleQuery, ComplexQuery, Query));
\ No newline at end of file
...@@ -58,29 +58,12 @@ ...@@ -58,29 +58,12 @@
</tuple> </tuple>
</value> </value>
</item> </item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>contributor/person_module/1</string>
<string>classification/collaborative/team</string>
</tuple>
</value>
</item>
<item> <item>
<key> <string>content_md5</string> </key> <key> <string>content_md5</string> </key>
<value> <value>
<none/> <none/>
</value> </value>
</item> </item>
<item>
<key> <string>creators</string> </key>
<value>
<tuple>
<string>cedric.le.ninivin</string>
</tuple>
</value>
</item>
<item> <item>
<key> <string>default_reference</string> </key> <key> <string>default_reference</string> </key>
<value> <string>gadget_erp5_page_ojs_smart_assistant_home.js</string> </value> <value> <string>gadget_erp5_page_ojs_smart_assistant_home.js</string> </value>
...@@ -101,25 +84,6 @@ ...@@ -101,25 +84,6 @@
<none/> <none/>
</value> </value>
</item> </item>
<item>
<key> <string>modification_date</string> </key>
<value>
<object>
<klass>
<global name="DateTime" module="DateTime.DateTime"/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>1455284352.18</float>
<string>UTC</string>
</tuple>
</state>
</object>
</value>
</item>
<item> <item>
<key> <string>portal_type</string> </key> <key> <string>portal_type</string> </key>
<value> <string>Web Script</string> </value> <value> <string>Web Script</string> </value>
...@@ -134,12 +98,6 @@ ...@@ -134,12 +98,6 @@
<key> <string>title</string> </key> <key> <string>title</string> </key>
<value> <string>Gadget Smart Assistant JS</string> </value> <value> <string>Gadget Smart Assistant JS</string> </value>
</item> </item>
<item>
<key> <string>url_string</string> </key>
<value>
<none/>
</value>
</item>
<item> <item>
<key> <string>version</string> </key> <key> <string>version</string> </key>
<value> <string>001</string> </value> <value> <string>001</string> </value>
...@@ -224,7 +182,7 @@ ...@@ -224,7 +182,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1519634719.01</float> <float>1562159205.06</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
...@@ -269,7 +227,7 @@ ...@@ -269,7 +227,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>967.20676.40581.32768</string> </value> <value> <string>976.54308.37653.52753</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -287,7 +245,7 @@ ...@@ -287,7 +245,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1525444169.16</float> <float>1562162159.44</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
...@@ -344,7 +302,7 @@ ...@@ -344,7 +302,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1519633924.76</float> <float>1562158825.48</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -12,7 +12,8 @@ ...@@ -12,7 +12,8 @@
.declareAcquiredMethod("getUrlFor", "getUrlFor") .declareAcquiredMethod("getUrlFor", "getUrlFor")
.declareAcquiredMethod("updateDocument", "updateDocument") .declareAcquiredMethod("updateDocument", "updateDocument")
.declareAcquiredMethod("notifySubmitting", "notifySubmitting") .declareAcquiredMethod("notifySubmitting", "notifySubmitting")
.declareAcquiredMethod("notifySubmitted", 'notifySubmitted') .declareAcquiredMethod("notifySubmitted", "notifySubmitted")
.declareAcquiredMethod("redirect", "redirect")
.declareAcquiredMethod("jio_get", "jio_get") .declareAcquiredMethod("jio_get", "jio_get")
...@@ -52,8 +53,7 @@ ...@@ -52,8 +53,7 @@
}) })
.onEvent('submit', function () { .onEvent('submit', function () {
var gadget = this, var gadget = this;
title;
return gadget.notifySubmitting() return gadget.notifySubmitting()
.push(function () { .push(function () {
...@@ -63,14 +63,9 @@ ...@@ -63,14 +63,9 @@
return form_gadget.getContent(); return form_gadget.getContent();
}) })
.push(function (result) { .push(function (result) {
title = result.title; var reply = result.reply;
if (result.text_ === "") {
result.text_ = " ";
}
return gadget.updateDocument({ return gadget.updateDocument({
'text_content': result.text_, 'text_content': gadget.state.content.text_content + "\n" + reply
title: title
}); });
}) })
.push(function () { .push(function () {
...@@ -78,6 +73,9 @@ ...@@ -78,6 +73,9 @@
"message": "Data Updated", "message": "Data Updated",
"status": "success" "status": "success"
}); });
})
.push(function () {
return gadget.redirect({command: 'reload'});
}); });
}) })
.declareMethod("triggerSubmit", function () { .declareMethod("triggerSubmit", function () {
...@@ -104,15 +102,25 @@ ...@@ -104,15 +102,25 @@
"hidden": 0, "hidden": 0,
"type": "StringField" "type": "StringField"
}, },
"my_text": { "my_text_content": {
"default": gadget.state.text, "default": gadget.state.content.text_content,
"css_class": "",
"required": 0,
"editable": 0,
"key": "text_content",
"hidden": 0,
"title": 'History',
"type": "TextAreaField"
},
"my_reply": {
"default": "",
"title": "Reply",
"css_class": "", "css_class": "",
"required": 0, "required": 0,
"editable": 1, "editable": 1,
"key": "text_", "key": "reply",
"hidden": 0, "hidden": 0,
"renderjs_extra": '{"editor": "fck_editor",' + "renderjs_extra": '{"editor": "fck_editor"}',
'"maximize": "auto"}',
"type": "GadgetField", "type": "GadgetField",
"url": "gadget_editor.html", "url": "gadget_editor.html",
"sandbox": "public" "sandbox": "public"
...@@ -130,9 +138,12 @@ ...@@ -130,9 +138,12 @@
group_list: [[ group_list: [[
"left", "left",
[["my_title"]] [["my_title"]]
], [
"center",
[["my_text_content"]]
], [ ], [
"bottom", "bottom",
[["my_text"]] [["my_reply"]]
]] ]]
} }
}); });
......
...@@ -239,7 +239,7 @@ ...@@ -239,7 +239,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>966.50123.54319.23415</string> </value> <value> <string>976.31373.10382.14609</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -257,7 +257,7 @@ ...@@ -257,7 +257,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1523439452.07</float> <float>1560873588.93</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -85,7 +85,7 @@ ...@@ -85,7 +85,7 @@
return form_gadget.render({ return form_gadget.render({
erp5_document: { erp5_document: {
"_embedded": {"_view": { "_embedded": {"_view": {
"my_content": { "my_text_content": {
"default": "", "default": "",
"css_class": "", "css_class": "",
"required": 0, "required": 0,
...@@ -118,7 +118,7 @@ ...@@ -118,7 +118,7 @@
[["my_description"]] [["my_description"]]
], [ ], [
"bottom", "bottom",
[["my_content"]] [["my_text_content"]]
]] ]]
} }
}); });
......
...@@ -239,7 +239,7 @@ ...@@ -239,7 +239,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>967.17930.59246.1075</string> </value> <value> <string>976.14145.4153.46813</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -257,7 +257,7 @@ ...@@ -257,7 +257,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1525279476.09</float> <float>1559836938.79</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -58,20 +58,16 @@ ...@@ -58,20 +58,16 @@
</tuple> </tuple>
</value> </value>
</item> </item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>classification/collaborative/team</string>
</tuple>
</value>
</item>
<item> <item>
<key> <string>content_md5</string> </key> <key> <string>content_md5</string> </key>
<value> <value>
<none/> <none/>
</value> </value>
</item> </item>
<item>
<key> <string>content_type</string> </key>
<value> <string>application/javascript</string> </value>
</item>
<item> <item>
<key> <string>default_reference</string> </key> <key> <string>default_reference</string> </key>
<value> <string>gadget_erp5_ojs_panel_smart_assistant.js</string> </value> <value> <string>gadget_erp5_ojs_panel_smart_assistant.js</string> </value>
...@@ -88,7 +84,9 @@ ...@@ -88,7 +84,9 @@
</item> </item>
<item> <item>
<key> <string>language</string> </key> <key> <string>language</string> </key>
<value> <string>en</string> </value> <value>
<none/>
</value>
</item> </item>
<item> <item>
<key> <string>portal_type</string> </key> <key> <string>portal_type</string> </key>
...@@ -188,7 +186,7 @@ ...@@ -188,7 +186,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1520002302.38</float> <float>1562163551.28</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
...@@ -233,7 +231,7 @@ ...@@ -233,7 +231,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>966.14275.9143.23296</string> </value> <value> <string>976.54306.32835.10854</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -251,7 +249,7 @@ ...@@ -251,7 +249,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1522761698.8</float> <float>1562160158.27</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
...@@ -274,7 +272,9 @@ ...@@ -274,7 +272,9 @@
<dictionary> <dictionary>
<item> <item>
<key> <string>action</string> </key> <key> <string>action</string> </key>
<value> <string>detect_converted_file</string> </value> <value>
<none/>
</value>
</item> </item>
<item> <item>
<key> <string>actor</string> </key> <key> <string>actor</string> </key>
...@@ -290,7 +290,7 @@ ...@@ -290,7 +290,7 @@
</item> </item>
<item> <item>
<key> <string>external_processing_state</string> </key> <key> <string>external_processing_state</string> </key>
<value> <string>converted</string> </value> <value> <string>empty</string> </value>
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
...@@ -308,7 +308,7 @@ ...@@ -308,7 +308,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1520001217.02</float> <float>1562159899.76</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
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