Commit 88a12aab authored by Roque's avatar Roque

erp5_officejs: preparing custom js code in configuration side

- new post module action temporarily removed
parent 321a90cf
......@@ -254,7 +254,7 @@ hateoas/ERP5Document_getHateoas?mode=traverse&relative_url=portal_skins%2Ferp5_o
hateoas/ERP5Document_getHateoas?mode=traverse&relative_url=portal_types%2FHTML%20Post%2F1&view=view&appcache=1\n
hateoas/ERP5Document_getHateoas?mode=traverse&relative_url=portal_types%2FHTML%20Post%2F2&view=view&appcache=1\n
hateoas/ERP5Document_getHateoas?mode=traverse&relative_url=portal_types%2FHTML%20Post%2F3&view=view&appcache=1\n
hateoas/ERP5Document_getHateoas?mode=traverse&relative_url=portal_types%2FPost%20Module%2F2&view=view&appcache=1\n
#hateoas/ERP5Document_getHateoas?mode=traverse&relative_url=portal_types%2FPost%20Module%2F2&view=view&appcache=1\n
\n
gadget_erp5_field_listbox.html\n
gadget_erp5_field_listbox.js\n
......@@ -741,7 +741,7 @@ NETWORK:\n
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>974.64716.44616.56832</string> </value>
<value> <string>975.4607.38713.16742</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -759,7 +759,7 @@ NETWORK:\n
</tuple>
<state>
<tuple>
<float>1555095850.49</float>
<float>1555421020.18</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -121,7 +121,7 @@ hateoas/ERP5Document_getHateoas?mode=traverse&relative_url=portal_skins%2Ferp5_o
hateoas/ERP5Document_getHateoas?mode=traverse&relative_url=portal_types%2FHTML%20Post%2F1&view=view&appcache=1\n
hateoas/ERP5Document_getHateoas?mode=traverse&relative_url=portal_types%2FHTML%20Post%2F2&view=view&appcache=1\n
hateoas/ERP5Document_getHateoas?mode=traverse&relative_url=portal_types%2FHTML%20Post%2F3&view=view&appcache=1\n
hateoas/ERP5Document_getHateoas?mode=traverse&relative_url=portal_types%2FPost%20Module%2F2&view=view&appcache=1\n
#hateoas/ERP5Document_getHateoas?mode=traverse&relative_url=portal_types%2FPost%20Module%2F2&view=view&appcache=1\n
\n
NETWORK:\n
*
......@@ -267,7 +267,7 @@ NETWORK:\n
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>974.50440.27268.56285</string> </value>
<value> <string>974.64630.63649.43178</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -285,7 +285,7 @@ NETWORK:\n
</tuple>
<state>
<tuple>
<float>1555088098.27</float>
<float>1555418535.58</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -20,7 +20,16 @@
.declareMethod("generateJsonRenderForm", function (gadget) {
//this will be the id of the thread that contains this post list
var fake_thread_uid = "thread-" + ("0000" + ((Math.random() * Math.pow(36, 4)) | 0).toString(36)).slice(-4),
//hardcoded form_definition (this should come from erp5 form)
// get these (portal_type, etc) from getSettings
action_info = {
page: "handle_action",
action: "new",
action_type: "object_jio_js_script",
portal_type: "HTML Post",
parent_portal_type: "Post Module",
my_source_reference: fake_thread_uid
},
//hardcoded form_definition (this should come from erp5 form)
form_definition = {
_debug: "traverse",
pt: "form_view",
......@@ -53,7 +62,7 @@
},
action: "Base_edit",
update_action: "",
_links: { "type": { name: "" }, "action_object_new_content_action": {page: "handle_action", action: "new", my_source_reference: fake_thread_uid} }
_links: { "type": { name: "" }, "action_object_new_content_action": action_info }
},
form_json = {
erp5_document: {
......
......@@ -269,7 +269,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>974.64716.929.1945</string> </value>
<value> <string>975.4587.35735.7611</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -287,7 +287,7 @@
</tuple>
<state>
<tuple>
<float>1555093212.0</float>
<float>1555417799.99</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -55,11 +55,12 @@
.declareMethod("render", function (options) {
var gadget = this,
action_info_list = [],
document_title;
document_title, portal_type;
return gadget.jio_get(options.jio_key)
.push(function (document) {
var parent = "portal_types/" + document.portal_type,
query = 'portal_type: "Action Information" AND parent_relative_url: "' + parent + '"';
portal_type = document.portal_type;
document_title = document.title;
return gadget.jio_allDocs({query: query});
})
......@@ -74,7 +75,7 @@
})
.push(function (action_document_list) {
var url_for_parameter_list = [], i = 0,
page, action_key, action_doc;
page, action_key, action_doc, action_settings;
for (action_key in action_document_list) {
if (action_document_list.hasOwnProperty(action_key)) {
page = "handle_action";
......@@ -82,7 +83,14 @@
if (action_doc.reference === "view" || action_doc.reference === "jio_view") {
page = "ojs_controller";
}
url_for_parameter_list.push({command: 'change', options: {page: page, action: action_doc.reference}});
action_settings = {
page: page,
action: action_doc.reference,
action_type: action_doc.action_type,
parent_portal_type: portal_type,
portal_type: portal_type
};
url_for_parameter_list.push({ command: 'change', options: action_settings });
action_info_list[i] = { reference: action_doc.reference, title: action_doc.title};
i += 1;
}
......
......@@ -228,7 +228,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>974.63448.18577.4829</string> </value>
<value> <string>975.4589.24119.47394</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -246,7 +246,7 @@
</tuple>
<state>
<tuple>
<float>1555096738.2</float>
<float>1555418496.64</float>
<string>UTC</string>
</tuple>
</state>
......
/*global window, rJS, RSVP */
/*jslint nomen: true, indent: 2, maxerr: 3 */
/*jslint evil: true */
(function (document, window, rJS, RSVP) {
"use strict";
......@@ -25,12 +26,15 @@
var gadget = this,
child_gadget_url = 'gadget_erp5_pt_form_view_editable.html',
portal_type, parent_portal_type,
parent_relative_url, form_definition;
parent_relative_url, form_definition, action_type;
return RSVP.Queue()
.push(function () {
return RSVP.all([
gadget.getUrlParameter("action"),
//maybe these settings should come as url parameters too
gadget.getUrlParameter("action_type"),
gadget.getUrlParameter("portal_type"),
gadget.getUrlParameter("parent_portal_type"),
gadget.getUrlParameter("parent_relative_url"),
gadget.getSetting('portal_type'),
gadget.getSetting('parent_relative_url'),
gadget.getSetting('parent_portal_type'),
......@@ -39,18 +43,26 @@
})
.push(function (result) {
action_reference = result[0];
portal_type = result[1];
parent_relative_url = result[2];
parent_portal_type = result[3];
gadget_utils = result[4];
action_type = result[1];
portal_type = result[2] || result[5];
parent_portal_type = result[3] || result[6];
parent_relative_url = result[4] || result[7];
gadget_utils = result[8];
// This is the custom code to handle each specific action
if (action_reference === "new") {
var doc_options = {};
doc_options.portal_type = portal_type;
doc_options.parent_relative_url = parent_relative_url;
return gadget_utils.getFormDefinition(parent_portal_type, action_reference)
// Temporarily hardcoded until new action in post module is fixed
return gadget_utils.getFormDefinition("HTML Post", "jio_view") //parent_portal_type, action_reference)
.push(function (result) {
form_definition = result;
// custom code will come from configuration side (action form)
if (action_type === "object_jio_js_script") {
if (form_definition.fields_raw_properties.hasOwnProperty("gadget_field_action_js_script")) {
eval(form_definition.fields_raw_properties.gadget_field_action_js_script.values.renderjs_extra[0][0]);
}
}
return gadget_utils.createDocument(doc_options);
})
.push(function (jio_key) {
......
......@@ -269,7 +269,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>974.64758.23503.51456</string> </value>
<value> <string>975.4605.37710.17527</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -287,7 +287,7 @@
</tuple>
<state>
<tuple>
<float>1555096705.62</float>
<float>1555418811.51</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