Commit c77f68fc authored by Roque's avatar Roque

erp5_officejs: turning custom code into generic

parent 39043dbc
...@@ -43,11 +43,13 @@ ...@@ -43,11 +43,13 @@
return gadget.jio_post(doc); return gadget.jio_post(doc);
}) })
.declareMethod("getFormDefinition", function (portal_type, action_reference) { .declareMethod("getFormDefinition", function (portal_type, action_reference, extra_params) {
var gadget = this, var gadget = this,
parent = "portal_types/" + portal_type, parent = "portal_types/" + portal_type,
query = 'portal_type: "Action Information" AND reference: "' + action_reference + '" AND parent_relative_url: "' + parent + '"', query = 'portal_type: "Action Information" AND reference: "' + action_reference + '" AND parent_relative_url: "' + parent + '"',
action_type, action_title; action_type, action_title;
//TODO: check all actions to set has_more_views and has_more_actions flags in form def
//also check if there is a "new" action for object_list.action_info
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) {
...@@ -63,6 +65,18 @@ ...@@ -63,6 +65,18 @@
.push(function (form_result) { .push(function (form_result) {
form_result.form_definition.action_type = action_type; form_result.form_definition.action_type = action_type;
form_result.form_definition.title = action_title; form_result.form_definition.title = action_title;
if (action_type === "object_list") {
//TODO: get child_portal_type from form_definition (listbox->portal_type).
var child_portal_type = "HTML Post",
action_info = {
page: "handle_action",
action: "new",
portal_type: child_portal_type,
parent_portal_type: portal_type,
my_source_reference: extra_params.source_reference
};
form_result.form_definition._links.action_object_new_content_action = action_info;
}
return form_result.form_definition; return form_result.form_definition;
}); });
}); });
......
...@@ -269,7 +269,7 @@ ...@@ -269,7 +269,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>975.23763.60402.39680</string> </value> <value> <string>975.35539.1795.20002</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -287,7 +287,7 @@ ...@@ -287,7 +287,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1556568356.85</float> <float>1557188582.39</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -22,15 +22,8 @@ ...@@ -22,15 +22,8 @@
default_view = "jio_view", default_view = "jio_view",
common_utils_gadget_url = "gadget_officejs_common_utils.html", common_utils_gadget_url = "gadget_officejs_common_utils.html",
child_gadget_url = 'gadget_erp5_pt_form_list.html', child_gadget_url = 'gadget_erp5_pt_form_list.html',
//HARDCODED NEW ACTION INFORMATION - TODO: get like in action_offline gadget (refactor/reuse code) //In a future, the post list will be within a thread. For now:
fake_thread_uid = "thread-" + ("0000" + ((Math.random() * Math.pow(36, 4)) | 0).toString(36)).slice(-4), fake_thread_uid = "thread-" + ("0000" + ((Math.random() * Math.pow(36, 4)) | 0).toString(36)).slice(-4);
action_info = {
page: "handle_action",
action: "new",
portal_type: "HTML Post",
parent_portal_type: "Post Module",
my_source_reference: fake_thread_uid
};
return RSVP.Queue() return RSVP.Queue()
.push(function () { .push(function () {
return RSVP.all([ return RSVP.all([
...@@ -39,21 +32,21 @@ ...@@ -39,21 +32,21 @@
]); ]);
}) })
.push(function (result) { .push(function (result) {
return result[1].getFormDefinition(result[0], default_view); return result[1].getFormDefinition(result[0], default_view, {source_reference: fake_thread_uid});
}) })
.push(function (form_definition) { .push(function (form_definition) {
//HARDCODED ACTION INFORMATION
form_definition._links.action_object_new_content_action = action_info;
return gadget.changeState({ return gadget.changeState({
jio_key: options.jio_key, jio_key: options.jio_key,
//TODO child_gadget_url should be decided in utils.getFormDefinition based on form type
child_gadget_url: child_gadget_url, child_gadget_url: child_gadget_url,
form_definition: form_definition, form_definition: form_definition,
form_type: 'list', form_type: 'list',
editable: false, editable: false,
view: default_view, view: default_view,
front_page: true, front_page: true,
has_more_views: false, //this should come from form_def //TODO: get following 2 values from form_def in utils.getFormDefinition
has_more_actions: false //this should come from form_def has_more_views: false,
has_more_actions: false
}); });
}); });
}) })
......
...@@ -269,7 +269,7 @@ ...@@ -269,7 +269,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>975.35049.45064.43076</string> </value> <value> <string>975.35544.63874.25224</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -287,7 +287,7 @@ ...@@ -287,7 +287,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1557158988.51</float> <float>1557188776.18</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