Commit 9e85ed0b authored by Roque's avatar Roque

erp5_officejs: minor fixes and code cleanup-refactor on controller rendering

parent e99adb0e
...@@ -88,11 +88,15 @@ ...@@ -88,11 +88,15 @@
// This is the custom code to handle this specific reply action // This is the custom code to handle this specific reply action
// it should be somewhere else to keep the controller generic // it should be somewhere else to keep the controller generic
if (action_reference == "reply") { if (action_reference == "reply") {
var doc = { var doc, title = document.title;
title: "Re: " + document.title, if (! title.startsWith("Re: ")) {
portal_type: document.portal_type, title = "Re: " + document.title;
parent_relative_url: document.parent_relative_url }
}; doc = {
title: title,
portal_type: document.portal_type,
parent_relative_url: document.parent_relative_url
};
return gadget.jio_post(doc) return gadget.jio_post(doc)
.push(function (id) { .push(function (id) {
jio_key = id; jio_key = id;
...@@ -113,7 +117,7 @@ ...@@ -113,7 +117,7 @@
return gadget.jio_allDocs({query: query}) return gadget.jio_allDocs({query: query})
.push(function (data) { .push(function (data) {
if (data.data.rows.length === 0) { if (data.data.rows.length === 0) {
throw "Can not find action for portal type " + portal_type; throw "Can not find action " + action_reference + " for portal type " + portal_type;
} }
return gadget.jio_get(data.data.rows[0].id); return gadget.jio_get(data.data.rows[0].id);
}) })
...@@ -207,7 +211,7 @@ ...@@ -207,7 +211,7 @@
return gadget.handleAction(options.jio_key, document, view_parameters); return gadget.handleAction(options.jio_key, document, view_parameters);
}) })
.push(function (result_list) { .push(function (result_list) {
return gadget.getFormDefinition(document.portal_type, result_list[2])//action_reference) return gadget.getFormDefinition(document.portal_type, result_list[2])
.push(function (form_definition) { .push(function (form_definition) {
return gadget.changeState({ return gadget.changeState({
jio_key: result_list[0], jio_key: result_list[0],
...@@ -215,7 +219,11 @@ ...@@ -215,7 +219,11 @@
child_gadget_url: child_gadget_url, child_gadget_url: child_gadget_url,
form_definition: form_definition, form_definition: form_definition,
editable: options.editable, editable: options.editable,
view: result_list[2] view: result_list[2],
//HARDCODED: following fields should be indicated by the configuration
has_more_views: false,
has_more_actions: result_list[2] == default_view,
is_form_list: false
}); });
}); });
}); });
...@@ -264,9 +272,8 @@ ...@@ -264,9 +272,8 @@
]); ]);
}) })
.push(function (result_list) { .push(function (result_list) {
var is_form_list = false, //TODO: configuration must indicate if is a form or list view var url_list = result_list[0], header_dict;
url_list = result_list[0], header_dict; if (gadget.state.is_form_list) {
if (is_form_list) {
header_dict = { header_dict = {
panel_action: true, panel_action: true,
jump_url: "", jump_url: "",
...@@ -282,14 +289,14 @@ ...@@ -282,14 +289,14 @@
next_url: url_list[4], next_url: url_list[4],
page_title: gadget.state.doc.title page_title: gadget.state.doc.title
}; };
if (false) { //TODO: configuration must indicate if there are more views if (gadget.state.has_more_views) {
header_dict.tab_url = url_list[0]; header_dict.tab_url = url_list[0];
} }
if (gadget.state.editable === "true") { if (gadget.state.editable === "true") {
header_dict.save_action = true; header_dict.save_action = true;
} }
} }
if (true) { //TODO: configuration must indicate if there are more actions if (gadget.state.has_more_actions) {
header_dict.actions_url = url_list[1]; header_dict.actions_url = url_list[1];
} }
if (url_list[7]) { if (url_list[7]) {
......
...@@ -225,7 +225,7 @@ ...@@ -225,7 +225,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>974.51831.61563.42956</string> </value> <value> <string>974.51886.25651.1723</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -243,7 +243,7 @@ ...@@ -243,7 +243,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1554320403.23</float> <float>1554323825.38</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