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 ...@@ -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%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%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%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 \n
gadget_erp5_field_listbox.html\n gadget_erp5_field_listbox.html\n
gadget_erp5_field_listbox.js\n gadget_erp5_field_listbox.js\n
...@@ -741,7 +741,7 @@ NETWORK:\n ...@@ -741,7 +741,7 @@ NETWORK:\n
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>974.64716.44616.56832</string> </value> <value> <string>975.4607.38713.16742</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -759,7 +759,7 @@ NETWORK:\n ...@@ -759,7 +759,7 @@ NETWORK:\n
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1555095850.49</float> <float>1555421020.18</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -121,7 +121,7 @@ hateoas/ERP5Document_getHateoas?mode=traverse&relative_url=portal_skins%2Ferp5_o ...@@ -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%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%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%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 \n
NETWORK:\n NETWORK:\n
* *
...@@ -267,7 +267,7 @@ NETWORK:\n ...@@ -267,7 +267,7 @@ NETWORK:\n
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>974.50440.27268.56285</string> </value> <value> <string>974.64630.63649.43178</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -285,7 +285,7 @@ NETWORK:\n ...@@ -285,7 +285,7 @@ NETWORK:\n
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1555088098.27</float> <float>1555418535.58</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -20,7 +20,16 @@ ...@@ -20,7 +20,16 @@
.declareMethod("generateJsonRenderForm", function (gadget) { .declareMethod("generateJsonRenderForm", function (gadget) {
//this will be the id of the thread that contains this post list //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), 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 = { form_definition = {
_debug: "traverse", _debug: "traverse",
pt: "form_view", pt: "form_view",
...@@ -53,7 +62,7 @@ ...@@ -53,7 +62,7 @@
}, },
action: "Base_edit", action: "Base_edit",
update_action: "", 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 = { form_json = {
erp5_document: { erp5_document: {
......
...@@ -269,7 +269,7 @@ ...@@ -269,7 +269,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>974.64716.929.1945</string> </value> <value> <string>975.4587.35735.7611</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>1555093212.0</float> <float>1555417799.99</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -55,11 +55,12 @@ ...@@ -55,11 +55,12 @@
.declareMethod("render", function (options) { .declareMethod("render", function (options) {
var gadget = this, var gadget = this,
action_info_list = [], action_info_list = [],
document_title; document_title, portal_type;
return gadget.jio_get(options.jio_key) return gadget.jio_get(options.jio_key)
.push(function (document) { .push(function (document) {
var parent = "portal_types/" + document.portal_type, var parent = "portal_types/" + document.portal_type,
query = 'portal_type: "Action Information" AND parent_relative_url: "' + parent + '"'; query = 'portal_type: "Action Information" AND parent_relative_url: "' + parent + '"';
portal_type = document.portal_type;
document_title = document.title; document_title = document.title;
return gadget.jio_allDocs({query: query}); return gadget.jio_allDocs({query: query});
}) })
...@@ -74,7 +75,7 @@ ...@@ -74,7 +75,7 @@
}) })
.push(function (action_document_list) { .push(function (action_document_list) {
var url_for_parameter_list = [], i = 0, 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) { for (action_key in action_document_list) {
if (action_document_list.hasOwnProperty(action_key)) { if (action_document_list.hasOwnProperty(action_key)) {
page = "handle_action"; page = "handle_action";
...@@ -82,7 +83,14 @@ ...@@ -82,7 +83,14 @@
if (action_doc.reference === "view" || action_doc.reference === "jio_view") { if (action_doc.reference === "view" || action_doc.reference === "jio_view") {
page = "ojs_controller"; 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}; action_info_list[i] = { reference: action_doc.reference, title: action_doc.title};
i += 1; i += 1;
} }
......
...@@ -228,7 +228,7 @@ ...@@ -228,7 +228,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>974.63448.18577.4829</string> </value> <value> <string>975.4589.24119.47394</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -246,7 +246,7 @@ ...@@ -246,7 +246,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1555096738.2</float> <float>1555418496.64</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
/*global window, rJS, RSVP */ /*global window, rJS, RSVP */
/*jslint nomen: true, indent: 2, maxerr: 3 */ /*jslint nomen: true, indent: 2, maxerr: 3 */
/*jslint evil: true */
(function (document, window, rJS, RSVP) { (function (document, window, rJS, RSVP) {
"use strict"; "use strict";
...@@ -25,12 +26,15 @@ ...@@ -25,12 +26,15 @@
var gadget = this, var gadget = this,
child_gadget_url = 'gadget_erp5_pt_form_view_editable.html', child_gadget_url = 'gadget_erp5_pt_form_view_editable.html',
portal_type, parent_portal_type, portal_type, parent_portal_type,
parent_relative_url, form_definition; parent_relative_url, form_definition, action_type;
return RSVP.Queue() return RSVP.Queue()
.push(function () { .push(function () {
return RSVP.all([ return RSVP.all([
gadget.getUrlParameter("action"), 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('portal_type'),
gadget.getSetting('parent_relative_url'), gadget.getSetting('parent_relative_url'),
gadget.getSetting('parent_portal_type'), gadget.getSetting('parent_portal_type'),
...@@ -39,18 +43,26 @@ ...@@ -39,18 +43,26 @@
}) })
.push(function (result) { .push(function (result) {
action_reference = result[0]; action_reference = result[0];
portal_type = result[1]; action_type = result[1];
parent_relative_url = result[2]; portal_type = result[2] || result[5];
parent_portal_type = result[3]; parent_portal_type = result[3] || result[6];
gadget_utils = result[4]; parent_relative_url = result[4] || result[7];
gadget_utils = result[8];
// This is the custom code to handle each specific action // This is the custom code to handle each specific action
if (action_reference === "new") { if (action_reference === "new") {
var doc_options = {}; var doc_options = {};
doc_options.portal_type = portal_type; doc_options.portal_type = portal_type;
doc_options.parent_relative_url = parent_relative_url; 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) { .push(function (result) {
form_definition = 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); return gadget_utils.createDocument(doc_options);
}) })
.push(function (jio_key) { .push(function (jio_key) {
......
...@@ -269,7 +269,7 @@ ...@@ -269,7 +269,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>974.64758.23503.51456</string> </value> <value> <string>975.4605.37710.17527</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>1555096705.62</float> <float>1555418811.51</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