Commit 336c6649 authored by Lu Xu's avatar Lu Xu 👀

erp5_officejs: Implement Smart Assistant App on OfficeJSAdded

Query Module for Smart Assistant as reply
Omit unnecessary modifications
parent 3402d7e3
......@@ -104,6 +104,12 @@
"message": "Data created",
"status": "success"
});
})
.push(function () {
return gadget.redirect({
command: 'display',
options: {page: "ojs_smart_assistant_document_list"}
});
});
}
});
......@@ -156,12 +162,13 @@
})
.push(function (result) {
var column_list = [
['title', 'Title'],
['agent_title', 'Title'],
['description', 'Reply'],
['modification_date', 'Modification Date'],
['validation_state', 'Validation State']
],
portal_type = result[3].split(','),
portal_type = ["Query"],
query = "urn:jio:allDocs?query=",
i,
jio_query_list = [];
......@@ -273,7 +280,7 @@
"editable": 1,
"editable_column_list": [],
"key": "field_listbox",
"lines": 30,
"lines": 10,
"list_method": "portal_catalog",
"query": query,
"portal_type": [],
......
......@@ -239,7 +239,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>967.18863.15987.54067</string> </value>
<value> <string>977.26301.26400.65501</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -257,7 +257,7 @@
</tuple>
<state>
<tuple>
<float>1525355118.62</float>
<float>1564413494.29</float>
<string>UTC</string>
</tuple>
</state>
......
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>OfficeJS Jio Query View</title>
<script src="rsvp.js"></script>
<script src="renderjs.js"></script>
<script src="gadget_officejs_jio_smart_assistant_query_view.js"></script>
</head>
<body>
<form class="save_form ui-body-c" novalidate>
<button type="submit" class="ui-btn ui-btn-b ui-btn-inline
ui-icon-edit ui-btn-icon-right ui-screen-hidden"></button>
<div data-gadget-url="gadget_erp5_form.html"
data-gadget-scope="form_view"
data-gadget-sandbox="public">
</div>
</form>
</body>
</html>
/*global window, rJS, RSVP, jIO, Blob*/
/*jslint indent:2, maxlen: 80, nomen: true */
(function (window, rJS, RSVP) {
"use strict";
rJS(window)
/////////////////////////////////////////////////////////////////
// Acquired methods
/////////////////////////////////////////////////////////////////
.declareAcquiredMethod("updateHeader", "updateHeader")
.declareAcquiredMethod("getUrlFor", "getUrlFor")
.declareAcquiredMethod("updateDocument", "updateDocument")
.declareAcquiredMethod("notifySubmitting", "notifySubmitting")
.declareAcquiredMethod("notifySubmitted", 'notifySubmitted')
.declareAcquiredMethod("redirect", "redirect")
.declareAcquiredMethod("jio_getAttachment", "jio_getAttachment")
.declareAcquiredMethod("jio_putAttachment", "jio_putAttachment")
.declareAcquiredMethod("jio_get", "jio_get")
/////////////////////////////////////////////////////////////////
// declared methods
/////////////////////////////////////////////////////////////////
.declareMethod("render", function (options) {
var gadget = this,
state = {
title: options.doc.title,
text_content: options.doc.text_content,
owner: options.doc.owner,
agent_title: options.doc.agent_title,
validation_state: options.doc.validation_state,
description: options.doc.description,
modification_date: options.doc.modification_date,
relative_url: options.doc.agent_relative_url,
jio_key: options.jio_key
};
gadget.type = options.doc.type;
return gadget.jio_get(options.jio_key)
.push(function () {
return RSVP.all([
gadget.getUrlFor({command: 'history_previous'}),
gadget.getUrlFor({command: 'selection_previous'}),
gadget.getUrlFor({command: 'selection_next'}),
gadget.changeState(state)
]);
})
.push(function (url_list) {
return gadget.updateHeader({
page_title: "Smart Assistant",
save_action: true,
selection_url: url_list[0],
previous_url: url_list[1],
next_url: url_list[2]
});
});
})
.onEvent('submit', function () {
var gadget = this;
return gadget.notifySubmitting()
.push(function () {
return gadget.getDeclaredGadget('form_view');
})
.push(function (form_gadget) {
return form_gadget.getContent();
})
.push(function (result) {
return gadget.updateDocument({text_content: result.text_content});
})
.push(function () {
return gadget.notifySubmitted({
"message": "Data updated",
"status": "success"
});
})
.push(function () {
return gadget.redirect({command: 'reload'});
});
})
.declareMethod("triggerSubmit", function () {
return this.element.querySelector('button[type="submit"]').click();
})
.onStateChange(function () {
var gadget = this;
return gadget.getDeclaredGadget('form_view')
.push(function (form_gadget) {
return form_gadget.render({
erp5_document: {
"_embedded": {
"_view": {
"my_title": {
"description": "",
"title": "Smart Asisstant Type",
"default": gadget.state.title,
"css_class": "",
"required": 1,
"editable": 0,
"key": "title",
"hidden": 0,
"type": "StringField"
},
"my_owner": {
"description": "",
"title": "Owner",
"default": gadget.state.owner,
"css_class": "",
"required": 1,
"editable": 0,
"key": "owner",
"hidden": 0,
"type": "StringField"
},
"my_agent_title": {
"relation_item_relative_url":
[gadget.state.relative_url],
"type": "RelationStringField",
"label": true,
"sort": [],
"relation_item_key":
"subfield_field_my_agent_title_item",
"description": "",
"catalog_index": "title",
"editable": 0,
"allow_creation": 0,
"allow_jump": 1,
"key": "agent_title",
"translated_portal_types": ["Category"],
"title": "Context",
"default": [gadget.state.agent_title],
"css_class": "",
"relation_field_id":
"subfield_field_my_agent_title_relation",
"required": 1,
"url": "agent_title",
"hidden": 0,
"portal_types": ["Category"],
"view": "view"
},
"your_modification_date": {
"description": "",
"title": "Modification Date",
"default": gadget.state.modification_date,
"css_class": "",
"required": 1,
"editable": 0,
"key": "modification_date",
"hidden": 0,
"timezone_style": 1,
"date_only": 0,
"type": "DateTimeField"
},
"your_validation_state": {
"description": "",
"title": "Validation State",
"default": gadget.state.validation_state,
"css_class": "",
"required": 1,
"editable": 0,
"key": "validation_state",
"hidden": 0,
"type": "StringField"
},
"my_description": {
"description": "",
"title": "Reply",
"default": gadget.state.description,
"css_class": "",
"required": 1,
"editable": 0,
"key": "description",
"hidden": 0,
"type": "TextAreaField"
},
"my_text_content": {
"description": "",
"title": "Answer",
"default": gadget.state.text_content,
"css_class": "",
"required": 1,
"editable": 1,
"key": "text_content",
"hidden": 0,
"type": "TextAreaField"
}
}
},
"_links": {
"type": {
name: ""
}
}
},
form_definition: {
group_list: [[
"left",
[["my_agent_title"], ["my_title"]]
], [
"right",
[
["your_validation_state"],
["your_modification_date"],
["my_owner"]
]], [
"center",
[["my_description"],
["my_text_content"]]
]]
}
});
});
});
}(window, rJS, RSVP));
\ No newline at end of file
......@@ -239,7 +239,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>966.51362.22678.44731</string> </value>
<value> <string>977.46113.23747.32802</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -257,7 +257,7 @@
</tuple>
<state>
<tuple>
<float>1523439507.26</float>
<float>1566392656.96</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -12,8 +12,7 @@
.declareAcquiredMethod("getUrlFor", "getUrlFor")
.declareAcquiredMethod("updateDocument", "updateDocument")
.declareAcquiredMethod("notifySubmitting", "notifySubmitting")
.declareAcquiredMethod("notifySubmitted", "notifySubmitted")
.declareAcquiredMethod("redirect", "redirect")
.declareAcquiredMethod("notifySubmitted", 'notifySubmitted')
.declareAcquiredMethod("jio_get", "jio_get")
......@@ -53,7 +52,8 @@
})
.onEvent('submit', function () {
var gadget = this;
var gadget = this,
title;
return gadget.notifySubmitting()
.push(function () {
......@@ -63,9 +63,14 @@
return form_gadget.getContent();
})
.push(function (result) {
var reply = result.reply;
title = result.title;
if (result.text_ === "") {
result.text_ = " ";
}
return gadget.updateDocument({
'text_content': gadget.state.content.text_content + "\n" + reply
'text_content': result.text_,
title: title
});
})
.push(function () {
......@@ -73,9 +78,6 @@
"message": "Data Updated",
"status": "success"
});
})
.push(function () {
return gadget.redirect({command: 'reload'});
});
})
.declareMethod("triggerSubmit", function () {
......@@ -102,23 +104,12 @@
"hidden": 0,
"type": "StringField"
},
"my_text_content": {
"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",
"my_text": {
"default": gadget.state.text,
"css_class": "",
"required": 0,
"editable": 1,
"key": "reply",
"key": "text_",
"hidden": 0,
"renderjs_extra": '{"editor": "fck_editor"}',
"type": "GadgetField",
......@@ -138,12 +129,9 @@
group_list: [[
"left",
[["my_title"]]
], [
"center",
[["my_text_content"]]
], [
"bottom",
[["my_reply"]]
[["my_text"]]
]]
}
});
......
......@@ -239,7 +239,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>976.31373.10382.14609</string> </value>
<value> <string>977.59321.6121.85</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -257,7 +257,7 @@
</tuple>
<state>
<tuple>
<float>1560873588.93</float>
<float>1566393268.59</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -239,7 +239,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>976.14145.4153.46813</string> </value>
<value> <string>977.59316.41089.18466</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -257,7 +257,7 @@
</tuple>
<state>
<tuple>
<float>1559836938.79</float>
<float>1566393678.62</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -727,7 +727,7 @@ NETWORK:\n
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>973.23494.2134.9352</string> </value>
<value> <string>977.60873.936.24507</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -745,7 +745,7 @@ NETWORK:\n
</tuple>
<state>
<tuple>
<float>1549009768.6</float>
<float>1566486306.96</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -78,10 +78,11 @@
.push(function (result) {
var column_list = [
['title', 'Title'],
['modification_date', 'Modification Date']
['modification_date', 'Modification Date'],
['portal_type', 'Smart Assistant Type']
],
portal_type = result[1].split(','),
portal_type = ["Smart Assistant Text", "Smart Assistant Sound", "Smart Assistant Image", "Smart Assistant File" ],
query = "urn:jio:allDocs?query=",
i,
jio_query_list = [];
......
......@@ -269,7 +269,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>967.17965.31026.10137</string> </value>
<value> <string>977.53561.59080.44134</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -287,7 +287,7 @@
</tuple>
<state>
<tuple>
<float>1525337356.71</float>
<float>1566394190.39</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -14,8 +14,8 @@
</head>
<body>
<script data-renderjs-configuration="portal_type" type="text/x-renderjs-configuration">Smart Assistant Text,Smart Assistant Image,Smart Assistant Sound,Smart Assistant File</script>
<script data-renderjs-configuration="parent_relative_url" type="text/x-renderjs-configuration">smart_assistant_text_module,smart_assistant_image_module,smart_assistant_sound_module,smart_assistant_file_module</script>
<script data-renderjs-configuration="portal_type" type="text/x-renderjs-configuration">Smart Assistant Text,Smart Assistant Image,Smart Assistant Sound,Smart Assistant File,Query</script>
<script data-renderjs-configuration="parent_relative_url" type="text/x-renderjs-configuration">smart_assistant_text_module,smart_assistant_image_module,smart_assistant_sound_module,smart_assistant_file_module,query_module</script>
<script data-renderjs-configuration="document_title" type="text/x-renderjs-configuration">Smart Assistant</script>
<script data-renderjs-configuration="document_title_plural" type="text/x-renderjs-configuration">Smart Assistant</script>
<script data-renderjs-configuration="erp5_attachment_synchro" type="text/x-renderjs-configuration">/{+id}/Base_downloadWithCors</script>
......
......@@ -243,7 +243,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>966.33997.15609.22101</string> </value>
<value> <string>977.57825.44431.51217</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -261,7 +261,7 @@
</tuple>
<state>
<tuple>
<float>1522420879.36</float>
<float>1566303568.38</float>
<string>UTC</string>
</tuple>
</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