Commit c7a632f1 authored by Roque's avatar Roque

erp5_officejs: removing hardcoded values and refactoring

parent 776fe66e
...@@ -51,26 +51,6 @@ ...@@ -51,26 +51,6 @@
return [form_type, child_gadget_url]; return [form_type, child_gadget_url];
}) })
.declareMethod("createDocument", function (options) {
var gadget = this,
doc = {
title: "Untitled Document",
portal_type: options.portal_type,
parent_relative_url: options.parent_relative_url
},
key,
doc_key;
for (key in options) {
if (options.hasOwnProperty(key)) {
if (key.startsWith("my_")) {
doc_key = key.replace("my_", "");
doc[doc_key] = options[key];
}
}
}
return gadget.jio_post(doc);
})
.declareMethod("checkMoreActions", function (portal_type, action_category) { .declareMethod("checkMoreActions", function (portal_type, action_category) {
var gadget = this, var gadget = this,
has_more_dict = {views: {}, actions: {}}, has_more_dict = {views: {}, actions: {}},
...@@ -133,20 +113,6 @@ ...@@ -133,20 +113,6 @@
//view and actions are managed by same actions-gadget-page //view and actions are managed by same actions-gadget-page
form_definition.has_more_views = false; form_definition.has_more_views = false;
form_definition.has_more_actions = has_more_dict.has_more_actions; form_definition.has_more_actions = has_more_dict.has_more_actions;
//for backward compatibility (header add button - '+' icon)
if (form_definition.action_type === "object_list") {
form_definition._links.action_object_new_content_action = {
page: "handle_action",
title: "New Post",
action: "new_html_post",
reference: "new_html_post",
action_type: "object_jio_js_script",
parent_portal_type: "Post Module",
portal_type: "HTML Post",
source_reference: source_reference
};
//form_definition.has_more_actions = false;
}
return form_definition; return 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.39673.49091.10956</string> </value> <value> <string>975.40669.15893.6946</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>1557436563.26</float> <float>1557496163.64</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -61,6 +61,19 @@ ...@@ -61,6 +61,19 @@
}) })
.push(function (result) { .push(function (result) {
form_definition = result; form_definition = result;
//TODO: solve add button
//for backward compatibility (header add button - '+' icon)
if (form_definition.action_type === "object_list") {
form_definition._links.action_object_new_content_action = {
page: "handle_action",
title: "New Post",
action: "new_html_post",
reference: "new_html_post",
action_type: "object_jio_js_script",
parent_portal_type: "Post Module",
source_reference: "for-future-thread-id"
};
}
return gadget_utils.getFormInfo(form_definition); return gadget_utils.getFormInfo(form_definition);
}) })
.push(function (form_info) { .push(function (form_info) {
......
...@@ -225,7 +225,7 @@ ...@@ -225,7 +225,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>975.39691.34802.60091</string> </value> <value> <string>975.40671.20077.18653</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>1557437553.02</float> <float>1557496397.35</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -106,20 +106,13 @@ ...@@ -106,20 +106,13 @@
if (view_categories.includes(action_doc.action_type)) { if (view_categories.includes(action_doc.action_type)) {
page = "ojs_controller"; page = "ojs_controller";
} }
//TODO (how to get child portal type?)
//'parent' and 'child' portal_types will be in the custom code of action gadgets
var child_portal_type = portal_type;
if (action_doc.reference === "new_html_post") {
child_portal_type = "HTML Post";
}
action_settings_list.push({ action_settings_list.push({
page: page, page: page,
title: action_doc.title, title: action_doc.title,
action: action_doc.reference, action: action_doc.reference,
reference: action_doc.reference, reference: action_doc.reference,
action_type: action_doc.action_type, action_type: action_doc.action_type,
parent_portal_type: portal_type, parent_portal_type: portal_type
portal_type: child_portal_type
}); });
} }
} }
......
...@@ -228,7 +228,7 @@ ...@@ -228,7 +228,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>975.39646.60719.8601</string> </value> <value> <string>975.39736.64982.14762</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>1557436194.5</float> <float>1557489660.39</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -24,13 +24,12 @@ ...@@ -24,13 +24,12 @@
.push(function () { .push(function () {
return RSVP.all([ return RSVP.all([
gadget.getUrlParameter("parent_portal_type"), gadget.getUrlParameter("parent_portal_type"),
gadget.getSetting('parent_portal_type'),
gadget.declareGadget("gadget_officejs_common_utils.html") gadget.declareGadget("gadget_officejs_common_utils.html")
]); ]);
}) })
.push(function (result) { .push(function (result) {
parent_portal_type = result[0] || result[1]; parent_portal_type = result[0];
return result[2].getFormDefinition(parent_portal_type, action_reference); return result[1].getFormDefinition(parent_portal_type, action_reference);
}); });
}) })
...@@ -41,17 +40,15 @@ ...@@ -41,17 +40,15 @@
return RSVP.all([ return RSVP.all([
gadget.getUrlParameter('portal_type'), gadget.getUrlParameter('portal_type'),
gadget.getUrlParameter('parent_relative_url'), gadget.getUrlParameter('parent_relative_url'),
gadget.getSetting('portal_type'),
gadget.getSetting('parent_relative_url'),
gadget.getUrlParameter("action"), gadget.getUrlParameter("action"),
gadget.declareGadget("gadget_officejs_common_utils.html") gadget.declareGadget("gadget_officejs_common_utils.html")
]); ]);
}) })
.push(function (result) { .push(function (result) {
action_reference = result[4]; if (result[0] !== undefined) { options.portal_type = result[0]; }
if (result[0] !== undefined) {options.portal_type = result[0]; } else {options.portal_type = result[2]; } if (result[1] !== undefined) { options.parent_relative_url = result[1]; }
if (result[1] !== undefined) {options.parent_relative_url = result[1]; } else {options.parent_relative_url = result[3]; } action_reference = result[2];
gadget_utils = result[5]; gadget_utils = result[3];
return gadget.getActionFormDefinition(action_reference); return gadget.getActionFormDefinition(action_reference);
}) })
.push(function (result) { .push(function (result) {
...@@ -67,7 +64,7 @@ ...@@ -67,7 +64,7 @@
form_definition.fields_raw_properties.hasOwnProperty("gadget_field_action_js_script"), form_definition.fields_raw_properties.hasOwnProperty("gadget_field_action_js_script"),
state_options = { state_options = {
doc: {}, doc: {},
parent_options: options, action_options: options,
child_gadget_url: child_gadget_url, child_gadget_url: child_gadget_url,
form_type: form_type, form_type: form_type,
form_definition: form_definition, form_definition: 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.39692.31170.31266</string> </value> <value> <string>975.40675.7475.8960</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>1557437551.19</float> <float>1557496526.16</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