Commit 9f30e982 authored by Roque's avatar Roque

erp5_officejs: fix on post module view action and refactoring

- preparing refactoring on ojs_post_list: it will be a front page gadget with very few custom functionallity, and it will call controller for generic post module rendering
parent 3ed54eae
...@@ -120,7 +120,7 @@ ...@@ -120,7 +120,7 @@
portal_type: "HTML Post", portal_type: "HTML Post",
source_reference: extra_params.source_reference source_reference: extra_params.source_reference
}; };
form_definition.has_more_actions = false; //form_definition.has_more_actions = false;
} }
return form_definition; return form_definition;
}); });
......
...@@ -287,7 +287,7 @@ ...@@ -287,7 +287,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1557340907.82</float> <float>1557406082.03</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -25,13 +25,28 @@ ...@@ -25,13 +25,28 @@
// declared methods // declared methods
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
.declareMethod("getPortalType", function (jio_document, options) {
var gadget = this;
if (jio_document) {
if (jio_document.portal_type === undefined) {
throw new Error('Can not display document: ' + options.jio_key);
}
return jio_document.portal_type;
}
if (options.portal_type) {
return options.portal_type;
}
return gadget.getSetting('parent_portal_type');
})
.declareMethod("render", function (options) { .declareMethod("render", function (options) {
var gadget = this, var gadget = this,
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_view_editable.html', child_gadget_url = 'gadget_erp5_pt_form_view_editable.html',
gadget_utils, gadget_utils,
jio_document; jio_document,
portal_type;
return gadget.declareGadget(common_utils_gadget_url) return gadget.declareGadget(common_utils_gadget_url)
.push(function (result) { .push(function (result) {
gadget_utils = result; gadget_utils = result;
...@@ -39,21 +54,33 @@ ...@@ -39,21 +54,33 @@
}) })
.push(function (result) { .push(function (result) {
jio_document = result; jio_document = result;
if (jio_document.portal_type === undefined) { }, function (error) {})
throw new Error('Can not display document: ' + options.jio_key); .push(function () {
} return gadget.getPortalType(jio_document, options);
return gadget_utils.getFormDefinition(jio_document.portal_type, default_view); })
.push(function (result) {
portal_type = result;
return gadget_utils.getFormDefinition(portal_type, default_view);
}) })
.push(function (form_definition) { .push(function (form_definition) {
var form_type = 'page', front_page = false;
if (form_definition.action_type === "object_list") {
form_type = 'list';
child_gadget_url = 'gadget_erp5_pt_form_list.html';
//TODO: when refactoring is done in ojs_post_list (front-page), this will come from options
front_page = true;
}
return gadget.changeState({ return gadget.changeState({
jio_key: options.jio_key, jio_key: options.jio_key,
doc: jio_document, doc: jio_document,
portal_type: portal_type,
//TODO child_gadget_url should be decided in utils.getFormDefinition based on form type //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: 'page', form_type: form_type,
editable: false, editable: false,
view: options.view, view: options.view,
front_page: front_page, //options.front_page
has_more_views: form_definition.has_more_views, has_more_views: form_definition.has_more_views,
has_more_actions: form_definition.has_more_actions has_more_actions: form_definition.has_more_actions
}); });
......
...@@ -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.36709.247.14950</string> </value> <value> <string>975.39226.38744.26965</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>1557340899.6</float> <float>1557409603.33</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -114,7 +114,8 @@ ...@@ -114,7 +114,8 @@
}) })
.declareMethod("renderSubGadget", function (options, subgadget, form_json) { .declareMethod("renderSubGadget", function (options, subgadget, form_json) {
var this_gadget = this, erp5_document = form_json.erp5_document, add_url; var this_gadget = this, erp5_document = form_json.erp5_document,
page_title = options.portal_type, add_url;
return subgadget.render({ return subgadget.render({
jio_key: options.jio_key, jio_key: options.jio_key,
doc: options.doc, doc: options.doc,
...@@ -135,6 +136,9 @@ ...@@ -135,6 +136,9 @@
{command: 'change', options: {page: "export"}}, {command: 'change', options: {page: "export"}},
{command: 'display', options: {}} {command: 'display', options: {}}
]; ];
if (options.doc) {
page_title = options.doc.title;
}
erp5_document = form_json.erp5_document; erp5_document = form_json.erp5_document;
if (erp5_document._links && erp5_document._links.action_object_new_content_action) { if (erp5_document._links && erp5_document._links.action_object_new_content_action) {
url_for_parameter_list.push({command: 'change', options: erp5_document._links.action_object_new_content_action}); url_for_parameter_list.push({command: 'change', options: erp5_document._links.action_object_new_content_action});
...@@ -151,7 +155,7 @@ ...@@ -151,7 +155,7 @@
var url_list = result_list[0], header_dict; var url_list = result_list[0], header_dict;
if (options.form_type === 'dialog') { if (options.form_type === 'dialog') {
header_dict = { header_dict = {
page_title: options.doc.title, page_title: page_title,
//TODO: find correct url //TODO: find correct url
cancel_url: url_list[6] cancel_url: url_list[6]
}; };
...@@ -173,7 +177,7 @@ ...@@ -173,7 +177,7 @@
selection_url: url_list[2], selection_url: url_list[2],
previous_url: url_list[3], previous_url: url_list[3],
next_url: url_list[4], next_url: url_list[4],
page_title: options.doc.title page_title: page_title
}; };
if (options.form_definition.has_more_views) { if (options.form_definition.has_more_views) {
header_dict.tab_url = url_list[0]; header_dict.tab_url = url_list[0];
......
...@@ -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.36690.25762.27101</string> </value> <value> <string>975.39213.26027.31914</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>1557340270.78</float> <float>1557408888.25</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -70,6 +70,7 @@ ...@@ -70,6 +70,7 @@
portal_type: portal_type portal_type: portal_type
}; };
//TODO find a better way to handle "add" actions (how to get child portal type?) //TODO find a better way to handle "add" actions (how to get child portal type?)
//'parent' and 'child' portal_types will be in the custom code of action gadgets
if (action_doc.reference === "new") { if (action_doc.reference === "new") {
return gadget.getSetting('portal_type') return gadget.getSetting('portal_type')
.push(function (child_portal_type) { .push(function (child_portal_type) {
...@@ -116,6 +117,7 @@ ...@@ -116,6 +117,7 @@
} }
//if portal_type has both view and jio_view, remove classic 'view' //if portal_type has both view and jio_view, remove classic 'view'
//TODO use action type instead of reference //TODO use action type instead of reference
//is the 'classic view' action needed at all here? -maybe don't add it in appcache manifest
if (action_info_dict.views.hasOwnProperty("view") && action_info_dict.views.hasOwnProperty("jio_view")) { if (action_info_dict.views.hasOwnProperty("view") && action_info_dict.views.hasOwnProperty("jio_view")) {
delete action_info_dict.views.view; delete action_info_dict.views.view;
} }
......
...@@ -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.36707.15008.32256</string> </value> <value> <string>975.38143.43945.1706</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>1557340236.58</float> <float>1557344637.28</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