Commit dd04e44e authored by Romain Courteaud's avatar Romain Courteaud

[erp5_web_renderjs_ui] Use RSVP.hash

parent f13693b3
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
*/ */
function modifyBreadcrumbList(gadget, parent_link, breadcrumb_action_list) { function modifyBreadcrumbList(gadget, parent_link, breadcrumb_action_list) {
if (parent_link === undefined) { if (parent_link === undefined) {
return; return breadcrumb_action_list;
} }
var uri = new URI(parent_link.href), var uri = new URI(parent_link.href),
jio_key = uri.segment(2); jio_key = uri.segment(2);
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
title: "ERP5", title: "ERP5",
link: "#" link: "#"
}); });
return; return breadcrumb_action_list;
} }
// Parent is an ERP5 document // Parent is an ERP5 document
...@@ -78,77 +78,66 @@ ...@@ -78,77 +78,66 @@
.onStateChange(function () { .onStateChange(function () {
var gadget = this, var gadget = this,
view_list = [], erp5_document;
tab_list = [],
jump_action_list = [],
breadcrumb_action_list = [],
erp5_document,
tab_title = "Views",
tab_icon = "eye",
jump_list;
return gadget.jio_getAttachment(gadget.state.jio_key, "links") return gadget.jio_getAttachment(gadget.state.jio_key, "links")
.push(function (result) { .push(function (result) {
var i,
promise_list = [];
erp5_document = result; erp5_document = result;
view_list = ensureArray(erp5_document._links.view);
jump_list = ensureArray(erp5_document._links.action_object_jump); var i,
tab_promise_list = [],
jump_action_promise_list = [],
view_list = ensureArray(erp5_document._links.view)
.concat(ensureArray(erp5_document._links.action_object_jio_view)),
jump_list = ensureArray(erp5_document._links.action_object_jump);
for (i = 0; i < view_list.length; i += 1) { for (i = 0; i < view_list.length; i += 1) {
promise_list.push(gadget.getUrlFor({command: 'display_with_history', options: { tab_promise_list.push(RSVP.hash({
jio_key: gadget.state.jio_key,
view: view_list[i].href,
page: undefined // Views in ERP5 must be forms but because of
// OfficeJS we keep it empty for different default
}}));
}
for (i = 0; i < jump_list.length; i += 1) {
promise_list.push(gadget.getUrlFor({command: 'push_history', options: {
extended_search: new URI(jump_list[i].href).query(true).query,
page: 'search'
}}));
}
promise_list.push(
modifyBreadcrumbList(gadget,
erp5_document._links.parent || "#",
breadcrumb_action_list)
);
return RSVP.all(promise_list);
})
.push(function (all_result) {
var i, j;
j = 0;
for (i = 0; i < view_list.length; i += 1) {
tab_list.push({
title: view_list[i].title, title: view_list[i].title,
i18n: view_list[i].title, i18n: view_list[i].title,
link: all_result[j] link: gadget.getUrlFor({command: 'display_with_history', options: {
}); jio_key: gadget.state.jio_key,
j += 1; view: view_list[i].href,
page: undefined // Views in ERP5 must be forms but because of
// OfficeJS we keep it empty for different default
}})
}));
} }
for (i = 0; i < jump_list.length; i += 1) { for (i = 0; i < jump_list.length; i += 1) {
jump_action_list.push({ jump_action_promise_list.push(RSVP.hash({
title: jump_list[i].title, title: jump_list[i].title,
link: all_result[j], i18n: jump_list[i].title,
i18n: jump_list[i].title link: gadget.getUrlFor({command: 'push_history', options: {
}); extended_search: new URI(jump_list[i].href).query(true).query,
j += 1; page: 'search'
}})
}));
} }
return RSVP.hash({
tab_list: RSVP.all(tab_promise_list),
jump_action_list: RSVP.all(jump_action_promise_list),
breadcrumb_action_list: modifyBreadcrumbList(gadget,
erp5_document._links.parent || "#",
[])
});
})
.push(function (result_dict) {
return gadget.translateHtml(table_template({ return gadget.translateHtml(table_template({
definition_title: tab_title, definition_title: "Views",
definition_i18n: tab_title, definition_i18n: "Views",
definition_icon: tab_icon, definition_icon: "eye",
documentlist: tab_list documentlist: result_dict.tab_list
}) + table_template({ }) + table_template({
definition_title: "Jumps", definition_title: "Jumps",
documentlist: jump_action_list, documentlist: result_dict.jump_action_list,
definition_icon: "plane", definition_icon: "plane",
definition_i18n: "Jumps" definition_i18n: "Jumps"
}) + table_template({ }) + table_template({
definition_title: "Breadcrumb", definition_title: "Breadcrumb",
documentlist: breadcrumb_action_list, documentlist: result_dict.breadcrumb_action_list,
definition_icon: "ellipsis-v", definition_icon: "ellipsis-v",
definition_i18n: "Breadcrumb" definition_i18n: "Breadcrumb"
})); }));
...@@ -156,18 +145,12 @@ ...@@ -156,18 +145,12 @@
.push(function (my_translated_html) { .push(function (my_translated_html) {
gadget.element.innerHTML = my_translated_html; gadget.element.innerHTML = my_translated_html;
return RSVP.all([ return RSVP.hash({
gadget.getUrlFor({command: 'cancel_dialog_with_history'}), back_url: gadget.getUrlFor({command: 'cancel_dialog_with_history'}),
calculatePageTitle(gadget, erp5_document) page_title: calculatePageTitle(gadget, erp5_document)
]); });
}) })
.push(function (url_list) { .push(gadget.updateHeader.bind(gadget));
var dict = {
back_url: url_list[0],
page_title: url_list[1]
};
return gadget.updateHeader(dict);
});
}) })
.declareMethod("triggerSubmit", function () { .declareMethod("triggerSubmit", function () {
return; return;
......
...@@ -148,171 +148,183 @@ ...@@ -148,171 +148,183 @@
</record> </record>
<record id="3" aka="AAAAAAAAAAM="> <record id="3" aka="AAAAAAAAAAM=">
<pickle> <pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/> <global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle> </pickle>
<pickle> <pickle>
<tuple> <dictionary>
<none/> <item>
<list> <key> <string>_log</string> </key>
<dictionary> <value>
<item> <list>
<key> <string>action</string> </key> <dictionary>
<value> <string>publish_alive</string> </value> <item>
</item> <key> <string>action</string> </key>
<item> <value> <string>publish_alive</string> </value>
<key> <string>actor</string> </key> </item>
<value> <string>romain</string> </value> <item>
</item> <key> <string>actor</string> </key>
<item> <value> <string>romain</string> </value>
<key> <string>comment</string> </key> </item>
<value> <string></string> </value> <item>
</item> <key> <string>comment</string> </key>
<item> <value> <string></string> </value>
<key> <string>error_message</string> </key> </item>
<value> <string></string> </value> <item>
</item> <key> <string>error_message</string> </key>
<item> <value> <string></string> </value>
<key> <string>time</string> </key> </item>
<value> <item>
<object> <key> <string>time</string> </key>
<klass> <value>
<global name="DateTime" module="DateTime.DateTime"/> <object>
</klass> <klass>
<tuple> <global name="DateTime" module="DateTime.DateTime"/>
<none/> </klass>
</tuple> <tuple>
<state> <none/>
<tuple> </tuple>
<float>1411723496.44</float> <state>
<string>GMT</string> <tuple>
</tuple> <float>1411723496.44</float>
</state> <string>GMT</string>
</object> </tuple>
</value> </state>
</item> </object>
<item> </value>
<key> <string>validation_state</string> </key> </item>
<value> <string>published_alive</string> </value> <item>
</item> <key> <string>validation_state</string> </key>
</dictionary> <value> <string>published_alive</string> </value>
</list> </item>
</tuple> </dictionary>
</list>
</value>
</item>
</dictionary>
</pickle> </pickle>
</record> </record>
<record id="4" aka="AAAAAAAAAAQ="> <record id="4" aka="AAAAAAAAAAQ=">
<pickle> <pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/> <global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle> </pickle>
<pickle> <pickle>
<tuple> <dictionary>
<none/> <item>
<list> <key> <string>_log</string> </key>
<dictionary> <value>
<item> <list>
<key> <string>action</string> </key> <dictionary>
<value> <string>edit</string> </value> <item>
</item> <key> <string>action</string> </key>
<item> <value> <string>edit</string> </value>
<key> <string>actor</string> </key> </item>
<value> <string>zope</string> </value> <item>
</item> <key> <string>actor</string> </key>
<item> <value> <string>zope</string> </value>
<key> <string>comment</string> </key> </item>
<value> <item>
<none/> <key> <string>comment</string> </key>
</value> <value>
</item> <none/>
<item> </value>
<key> <string>error_message</string> </key> </item>
<value> <string></string> </value> <item>
</item> <key> <string>error_message</string> </key>
<item> <value> <string></string> </value>
<key> <string>serial</string> </key> </item>
<value> <string>975.28771.29128.25958</string> </value> <item>
</item> <key> <string>serial</string> </key>
<item> <value> <string>980.35570.30592.53077</string> </value>
<key> <string>state</string> </key> </item>
<value> <string>current</string> </value> <item>
</item> <key> <string>state</string> </key>
<item> <value> <string>current</string> </value>
<key> <string>time</string> </key> </item>
<value> <item>
<object> <key> <string>time</string> </key>
<klass> <value>
<global name="DateTime" module="DateTime.DateTime"/> <object>
</klass> <klass>
<tuple> <global name="DateTime" module="DateTime.DateTime"/>
<none/> </klass>
</tuple> <tuple>
<state> <none/>
<tuple> </tuple>
<float>1556782424.57</float> <state>
<string>UTC</string> <tuple>
</tuple> <float>1576591900.86</float>
</state> <string>UTC</string>
</object> </tuple>
</value> </state>
</item> </object>
</dictionary> </value>
</list> </item>
</tuple> </dictionary>
</list>
</value>
</item>
</dictionary>
</pickle> </pickle>
</record> </record>
<record id="5" aka="AAAAAAAAAAU="> <record id="5" aka="AAAAAAAAAAU=">
<pickle> <pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/> <global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle> </pickle>
<pickle> <pickle>
<tuple> <dictionary>
<none/> <item>
<list> <key> <string>_log</string> </key>
<dictionary> <value>
<item> <list>
<key> <string>action</string> </key> <dictionary>
<value> <string>detect_converted_file</string> </value> <item>
</item> <key> <string>action</string> </key>
<item> <value> <string>detect_converted_file</string> </value>
<key> <string>actor</string> </key> </item>
<value> <string>romain</string> </value> <item>
</item> <key> <string>actor</string> </key>
<item> <value> <string>romain</string> </value>
<key> <string>comment</string> </key> </item>
<value> <string></string> </value> <item>
</item> <key> <string>comment</string> </key>
<item> <value> <string></string> </value>
<key> <string>error_message</string> </key> </item>
<value> <string></string> </value> <item>
</item> <key> <string>error_message</string> </key>
<item> <value> <string></string> </value>
<key> <string>external_processing_state</string> </key> </item>
<value> <string>converted</string> </value> <item>
</item> <key> <string>external_processing_state</string> </key>
<item> <value> <string>converted</string> </value>
<key> <string>serial</string> </key> </item>
<value> <string>0.0.0.0</string> </value> <item>
</item> <key> <string>serial</string> </key>
<item> <value> <string>0.0.0.0</string> </value>
<key> <string>time</string> </key> </item>
<value> <item>
<object> <key> <string>time</string> </key>
<klass> <value>
<global name="DateTime" module="DateTime.DateTime"/> <object>
</klass> <klass>
<tuple> <global name="DateTime" module="DateTime.DateTime"/>
<none/> </klass>
</tuple> <tuple>
<state> <none/>
<tuple> </tuple>
<float>1411723463.29</float> <state>
<string>GMT</string> <tuple>
</tuple> <float>1411723463.29</float>
</state> <string>GMT</string>
</object> </tuple>
</value> </state>
</item> </object>
</dictionary> </value>
</list> </item>
</tuple> </dictionary>
</list>
</value>
</item>
</dictionary>
</pickle> </pickle>
</record> </record>
</ZopeData> </ZopeData>
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