Commit e80cc4d6 authored by Roque's avatar Roque

erp5_officejs: header rendering generic for form and list views

- things in post list view are still hardcoded, but controller contemplates form lists now
parent 8c832785
...@@ -49,7 +49,8 @@ ...@@ -49,7 +49,8 @@
.declareAcquiredMethod("jio_get", "jio_get") .declareAcquiredMethod("jio_get", "jio_get")
.declareAcquiredMethod("jio_put", "jio_put") .declareAcquiredMethod("jio_put", "jio_put")
.declareAcquiredMethod("jio_allDocs", "jio_allDocs") .declareAcquiredMethod("jio_allDocs", "jio_allDocs")
.declareAcquiredMethod("getUrlFor", "getUrlFor") .declareAcquiredMethod("isDesktopMedia", "isDesktopMedia")
.declareAcquiredMethod("getSetting", "getSetting")
.declareAcquiredMethod("getUrlForList", "getUrlForList") .declareAcquiredMethod("getUrlForList", "getUrlForList")
.declareAcquiredMethod('getUrlParameter', 'getUrlParameter') .declareAcquiredMethod('getUrlParameter', 'getUrlParameter')
.declareAcquiredMethod("updateHeader", "updateHeader") .declareAcquiredMethod("updateHeader", "updateHeader")
...@@ -168,6 +169,7 @@ ...@@ -168,6 +169,7 @@
}) })
.declareMethod("renderSubGadget", function (gadget, subgadget, form_json) { .declareMethod("renderSubGadget", function (gadget, subgadget, form_json) {
var erp5_document = form_json.erp5_document;
return subgadget.render({ return subgadget.render({
jio_key: gadget.state.jio_key, jio_key: gadget.state.jio_key,
doc: gadget.state.doc, doc: gadget.state.doc,
...@@ -185,21 +187,33 @@ ...@@ -185,21 +187,33 @@
{command: 'history_previous'}, {command: 'history_previous'},
{command: 'selection_previous'}, {command: 'selection_previous'},
{command: 'selection_next'}, {command: 'selection_next'},
{command: 'change', options: {page: "export"}} {command: 'change', options: {page: "export"}},
{command: 'display', options: {}}
]; ];
if (form_json.erp5_document._links.action_object_new_content_action) { erp5_document = form_json.erp5_document;
url_for_parameter_list.push({command: 'change', options: { if (erp5_document._links && erp5_document._links.action_object_new_content_action) {
view: form_json.erp5_document._links.action_object_new_content_action.href, url_for_parameter_list.push({command: 'change', options: erp5_document._links.action_object_new_content_action});
editable: true
}});
} }
return RSVP.all([ return RSVP.all([
subgadget.getUrlForList(url_for_parameter_list), gadget.getUrlForList(url_for_parameter_list),
subgadget.isDesktopMedia() gadget.isDesktopMedia(),
gadget.getSetting('document_title_plural'),
gadget.getSetting('upload_dict', false)
]); ]);
}) })
.push(function (result_list) { .push(function (result_list) {
var url_list = result_list[0], var is_form_list = false, //TODO: configuration must indicate if is a form or list view
url_list = result_list[0], header_dict;
if (is_form_list) {
header_dict = {
panel_action: true,
jump_url: "",
fast_input_url: "",
front_url: url_list[6],
filter_action: true,
page_title: result_list[2]
};
} else {
header_dict = { header_dict = {
selection_url: url_list[2], selection_url: url_list[2],
previous_url: url_list[3], previous_url: url_list[3],
...@@ -209,20 +223,21 @@ ...@@ -209,20 +223,21 @@
if (false) { //TODO: configuration must indicate if there are more views if (false) { //TODO: configuration must indicate if there are more views
header_dict.tab_url = url_list[0]; header_dict.tab_url = url_list[0];
} }
if (gadget.state.editable === "true") {
header_dict.save_action = true;
}
}
if (true) { //TODO: configuration must indicate if there are more actions if (true) { //TODO: configuration must indicate if there are more actions
header_dict.actions_url = url_list[1]; header_dict.actions_url = url_list[1];
} }
if (url_list[6]) { if (url_list[7]) {
header_dict.add_url = url_list[6]; header_dict.add_url = url_list[7];
}
if (gadget.state.editable === "true") {
header_dict.save_action = true;
} }
if (result_list[1]) { if (result_list[1]) {
header_dict.export_url = ( header_dict.export_url = (
form_json.erp5_document._links.action_object_jio_report || erp5_document._links.action_object_jio_report ||
form_json.erp5_document._links.action_object_jio_exchange || erp5_document._links.action_object_jio_exchange ||
form_json.erp5_document._links.action_object_jio_print erp5_document._links.action_object_jio_print
) ? url_list[5] : ''; ) ? url_list[5] : '';
} }
return gadget.updateHeader(header_dict); return gadget.updateHeader(header_dict);
......
...@@ -225,7 +225,7 @@ ...@@ -225,7 +225,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>974.44255.46695.13363</string> </value> <value> <string>974.48727.12042.43076</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>1553865642.95</float> <float>1554135448.09</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -9,7 +9,8 @@ ...@@ -9,7 +9,8 @@
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
.declareAcquiredMethod("updateHeader", "updateHeader") .declareAcquiredMethod("updateHeader", "updateHeader")
.declareAcquiredMethod("getUrlParameter", "getUrlParameter") .declareAcquiredMethod("getUrlParameter", "getUrlParameter")
.declareAcquiredMethod("getUrlFor", "getUrlFor") .declareAcquiredMethod("isDesktopMedia", "isDesktopMedia")
.declareAcquiredMethod("getUrlForList", "getUrlForList")
.declareAcquiredMethod("getSetting", "getSetting") .declareAcquiredMethod("getSetting", "getSetting")
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
...@@ -50,7 +51,7 @@ ...@@ -50,7 +51,7 @@
}, },
action: "Base_edit", action: "Base_edit",
update_action: "", update_action: "",
_links: { "type": { name: "" } } _links: { "type": { name: "" }, "action_object_new_content_action": {"page": "ojs_add_post"} }
}, },
form_json = { form_json = {
erp5_document: { erp5_document: {
...@@ -90,7 +91,8 @@ ...@@ -90,7 +91,8 @@
}) })
.declareMethod("render", function () { .declareMethod("render", function () {
var gadget = this; var gadget = this,
erp5_document;
return new RSVP.Queue() return new RSVP.Queue()
.push(function () { .push(function () {
return RSVP.all([ return RSVP.all([
...@@ -99,25 +101,73 @@ ...@@ -99,25 +101,73 @@
]); ]);
}) })
.push(function (result) { .push(function (result) {
erp5_document = result[1].erp5_document;
return result[0].render(result[1]); return result[0].render(result[1]);
}) })
// render the header
.push(function () { .push(function () {
var url_for_parameter_list = [
{command: 'change', options: {page: "tab"}},
{command: 'change', options: {page: "action"}},
{command: 'history_previous'},
{command: 'selection_previous'},
{command: 'selection_next'},
{command: 'change', options: {page: "export"}},
{command: 'display', options: {}}
];
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});
}
return RSVP.all([ return RSVP.all([
gadget.getUrlFor({command: "change", options: {"page": "ojs_add_post"}}), gadget.getUrlForList(url_for_parameter_list),
gadget.isDesktopMedia(),
gadget.getSetting('document_title_plural'), gadget.getSetting('document_title_plural'),
gadget.getSetting('upload_dict', false) gadget.getSetting('upload_dict', false)
]); ]);
}) })
.push(function (result) { .push(function (result_list) {
var header = { var is_form_list = true, //TODO: configuration must indicate if is a form or list view
page_title: result[1], url_list = result_list[0], header_dict;
if (is_form_list) {
header_dict = {
panel_action: true,
jump_url: "",
fast_input_url: "",
front_url: url_list[6],
filter_action: true, filter_action: true,
add_url: result[0] page_title: result_list[2]
}; };
if (result[3]) { if (result_list[4]) {
header.upload_url = result[2]; header_dict.upload_url = result_list[3];
}
} else {
header_dict = {
selection_url: url_list[2],
previous_url: url_list[3],
next_url: url_list[4],
page_title: gadget.state.doc.title
};
if (false) { //TODO: configuration must indicate if there are more views
header_dict.tab_url = url_list[0];
}
if (gadget.state.editable === "true") {
header_dict.save_action = true;
}
}
if (true) { //TODO: configuration must indicate if there are more actions
header_dict.actions_url = url_list[1];
}
if (url_list[7]) {
header_dict.add_url = url_list[7];
}
if (result_list[1]) {
header_dict.export_url = (
erp5_document._links.action_object_jio_report ||
erp5_document._links.action_object_jio_exchange ||
erp5_document._links.action_object_jio_print
) ? url_list[5] : '';
} }
return gadget.updateHeader(header); return gadget.updateHeader(header_dict);
}); });
}); });
}(window, rJS, RSVP)); }(window, rJS, RSVP));
\ No newline at end of file
...@@ -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.24170.51028.9062</string> </value> <value> <string>974.48772.58946.52906</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>1552660552.06</float> <float>1554136650.89</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