Commit 56e895a4 authored by Lu Xu's avatar Lu Xu 👀

erp5_officejs: implement Smart Assistant front end

parent 2d013090
......@@ -16,6 +16,7 @@
<string>Associate</string>
<string>Auditor</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
......@@ -58,6 +59,7 @@
<string>Associate</string>
<string>Auditor</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
......
......@@ -16,6 +16,7 @@
<string>Associate</string>
<string>Auditor</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
......@@ -58,6 +59,7 @@
<string>Associate</string>
<string>Auditor</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
......
......@@ -14,9 +14,12 @@
<script src="gadget_erp5_page_ojs_smart_assistant_home.js"></script>
</head>
<body>
<form class="save_form ui-body-c" novalidate>
<div data-gadget-url="gadget_erp5_form.html"
data-gadget-scope="form_view_upload_audio"
......@@ -31,6 +34,12 @@
class='ui-flex-center'>
</div>
</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>
</html>
......@@ -273,7 +273,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>967.17859.46531.61866</string> </value>
<value> <string>976.22725.48476.52138</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -291,7 +291,7 @@
</tuple>
<state>
<tuple>
<float>1525278837.04</float>
<float>1560351706.09</float>
<string>UTC</string>
</tuple>
</state>
......
/*global window, rJS, jIO, Handlebars, RSVP, Blob*/
/*jslint indent:2, maxlen: 80, nomen: true */
(function (window, rJS, jIO, RSVP) {
(function (window, rJS, jIO, RSVP, SimpleQuery, ComplexQuery, Query) {
"use strict";
rJS(window)
......@@ -18,8 +18,59 @@
.declareAcquiredMethod("notifyChange", "notifyChange")
.declareAcquiredMethod("notifySubmitted", "notifySubmitted")
.declareAcquiredMethod("getUrlFor", "getUrlFor")
.declareAcquiredMethod("getUrlParameter", "getUrlParameter")
.declareAcquiredMethod("jio_allDocs", "jio_allDocs")
//added
.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;
});
})
// good for now
/*
.allowPublicAcquisition('notifySubmit', function () {
return this.triggerSubmit();
})
.declareMethod("triggerSubmit", function () {
var argument_list = arguments;
return this.getDeclaredGadget('form_list')
.push(function (gadget) {
return gadget.triggerSubmit.apply(gadget, argument_list);
});
})
*/
.allowPublicAcquisition('updateHeader', function () {
return;
......@@ -98,8 +149,12 @@
};
});
})
.declareMethod("render", function () {
var gadget = this;
this.getDeclaredGadget('form_list');
return gadget.getSetting('jio_storage_name')
.push(function (result) {
if (!result) {
......@@ -110,10 +165,40 @@
.push(function () {
return RSVP.all([
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) {
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([
result[0].render({
erp5_document: {"_embedded": {"_view": {
......@@ -143,60 +228,100 @@
name: ""
}
}},
form_definition: {
group_list: [[
"left",
[["upload"]]
], [
"right",
[["audio"]]
]]
}
}),
result[1].render({
erp5_document: {"_embedded": {"_view": {
"image": {
"editable": 1,
"key": "image",
"css_class":
"ui-view-only-label ui-label-circle ui-label-icon-camera",
"capture": "camera",
"title": " ",
"accept": "image/*",
"type": "FileField"
},
"text": {
"editable": 1,
"required": 1,
"key": "",
"css_class":
"invisible ui-a-circle ui-a-icon-pencil-square-o",
"title": " ",
"default": {"target": "smart_assistant_text",
"target_type": "text"},
"url": "gadget_erp5_page_ojs_link_field.html",
"type": "GadgetField"
form_definition: {
group_list: [[
"left",
[["upload"]]
], [
"right",
[["audio"]]
]]
}
}},
}),
result[1].render({
erp5_document: {"_embedded": {"_view": {
"image": {
"editable": 1,
"key": "image",
"css_class":
"ui-view-only-label ui-label-circle ui-label-icon-camera",
"capture": "camera",
"title": " ",
"accept": "image/*",
"type": "FileField"
},
"text": {
"editable": 1,
"required": 1,
"key": "",
"css_class":
"invisible ui-a-circle ui-a-icon-pencil-square-o",
"title": " ",
"default": {"target": "smart_assistant_text",
"target_type": "text"},
"url": "gadget_erp5_page_ojs_link_field.html",
"type": "GadgetField"
}
/*
*/
}},
"_links": {
"type": {
// form_list display portal_type in header
name: ""
}
}},
form_definition: {
group_list: [[
"left",
[["image"]]
], [
"right",
[["text"]]
]]
}
})
]);
form_definition: {
group_list: [[
"left",
[["image"]]
], [
"right",
[["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"]]
]]
}
})
]);
})
.push(function () {
return RSVP.all([
gadget.getSetting('document_title_plural'),
......@@ -216,4 +341,4 @@
});
}(window, rJS, jIO, RSVP));
\ No newline at end of file
}(window, rJS, jIO, RSVP, SimpleQuery, ComplexQuery, Query));
\ No newline at end of file
......@@ -73,6 +73,10 @@
<none/>
</value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>text/x-rst</string> </value>
</item>
<item>
<key> <string>creators</string> </key>
<value>
......@@ -269,7 +273,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>967.20676.40581.32768</string> </value>
<value> <string>976.23735.43866.48571</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -287,7 +291,7 @@
</tuple>
<state>
<tuple>
<float>1525444169.16</float>
<float>1560412497.82</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -12,7 +12,8 @@
.declareAcquiredMethod("getUrlFor", "getUrlFor")
.declareAcquiredMethod("updateDocument", "updateDocument")
.declareAcquiredMethod("notifySubmitting", "notifySubmitting")
.declareAcquiredMethod("notifySubmitted", 'notifySubmitted')
.declareAcquiredMethod("notifySubmitted", "notifySubmitted")
.declareAcquiredMethod("redirect", "redirect")
.declareAcquiredMethod("jio_get", "jio_get")
......@@ -63,14 +64,10 @@
return form_gadget.getContent();
})
.push(function (result) {
title = result.title;
if (result.text_ === "") {
result.text_ = " ";
}
//xxxxxxxxxx add title
var reply = result.reply;
return gadget.updateDocument({
'text_content': result.text_,
title: title
'text_content': gadget.state.content.text_content + "\n" + reply
});
})
.push(function () {
......@@ -78,6 +75,9 @@
"message": "Data Updated",
"status": "success"
});
})
.push(function () {
return gadget.redirect({command: 'reload'});
});
})
.declareMethod("triggerSubmit", function () {
......@@ -104,15 +104,25 @@
"hidden": 0,
"type": "StringField"
},
"my_text": {
"default": gadget.state.text,
"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": "XXX",
"css_class": "",
"required": 0,
"editable": 1,
"key": "text_",
"key": "reply",
"hidden": 0,
"renderjs_extra": '{"editor": "fck_editor",' +
'"maximize": "auto"}',
"renderjs_extra": '{"editor": "fck_editor"}',
"type": "GadgetField",
"url": "gadget_editor.html",
"sandbox": "public"
......@@ -130,9 +140,12 @@
group_list: [[
"left",
[["my_title"]]
], [
"center",
[["my_text_content"]]
], [
"bottom",
[["my_text"]]
[["my_reply"]]
]]
}
});
......
......@@ -239,7 +239,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>966.50123.54319.23415</string> </value>
<value> <string>976.14136.13409.18312</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -257,7 +257,7 @@
</tuple>
<state>
<tuple>
<float>1523439452.07</float>
<float>1559836335.8</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -85,7 +85,7 @@
return form_gadget.render({
erp5_document: {
"_embedded": {"_view": {
"my_content": {
"my_text_content": {
"default": "",
"css_class": "",
"required": 0,
......@@ -118,7 +118,7 @@
[["my_description"]]
], [
"bottom",
[["my_content"]]
[["my_text_content"]]
]]
}
});
......
......@@ -239,7 +239,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>967.17930.59246.1075</string> </value>
<value> <string>976.14145.4153.46813</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -257,7 +257,7 @@
</tuple>
<state>
<tuple>
<float>1525279476.09</float>
<float>1559836938.79</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -72,6 +72,10 @@
<none/>
</value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>text/html</string> </value>
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>gadget_erp5_ojs_panel_smart_assistant.js</string> </value>
......@@ -233,7 +237,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>966.14275.9143.23296</string> </value>
<value> <string>975.47634.40473.58043</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -251,7 +255,7 @@
</tuple>
<state>
<tuple>
<float>1522761698.8</float>
<float>1557914924.67</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -16,6 +16,7 @@
<string>Associate</string>
<string>Auditor</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
......@@ -55,6 +56,7 @@
<string>Associate</string>
<string>Auditor</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
......
......@@ -16,6 +16,7 @@
<string>Associate</string>
<string>Auditor</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
......@@ -58,6 +59,7 @@
<string>Associate</string>
<string>Auditor</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
......
......@@ -16,6 +16,7 @@
<string>Associate</string>
<string>Auditor</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
......@@ -58,6 +59,7 @@
<string>Associate</string>
<string>Auditor</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
......
......@@ -16,6 +16,7 @@
<string>Associate</string>
<string>Auditor</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
......@@ -58,6 +59,7 @@
<string>Associate</string>
<string>Auditor</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
......
......@@ -16,6 +16,7 @@
<string>Associate</string>
<string>Auditor</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
......@@ -58,6 +59,7 @@
<string>Associate</string>
<string>Auditor</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
......
......@@ -16,6 +16,7 @@
<string>Associate</string>
<string>Auditor</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
......@@ -58,6 +59,7 @@
<string>Associate</string>
<string>Auditor</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
......
......@@ -16,6 +16,7 @@
<string>Associate</string>
<string>Auditor</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
......@@ -58,6 +59,7 @@
<string>Associate</string>
<string>Auditor</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
......
......@@ -16,6 +16,7 @@
<string>Associate</string>
<string>Auditor</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
......@@ -58,6 +59,7 @@
<string>Associate</string>
<string>Auditor</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
......
......@@ -16,6 +16,7 @@
<string>Associate</string>
<string>Auditor</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
......@@ -58,6 +59,7 @@
<string>Associate</string>
<string>Auditor</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
......
......@@ -16,6 +16,7 @@
<string>Associate</string>
<string>Auditor</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
......@@ -58,6 +59,7 @@
<string>Associate</string>
<string>Auditor</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
......
......@@ -230,7 +230,7 @@
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="WebSectionTraversalHook" module="Products.ERP5.Document.WebSection"/>
<global name="StaticWebSectionTraversalHook" module="erp5.component.document.erp5_version.StaticWebSection"/>
</pickle>
<pickle>
<dictionary/>
......
......@@ -411,7 +411,7 @@
</item>
<item>
<key> <string>skin_selection_name</string> </key>
<value> <string>RJS</string> </value>
<value> <string>Officejs</string> </value>
</item>
<item>
<key> <string>static_language_selection</string> </key>
......
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