Commit fe5b49f4 authored by Roque's avatar Roque Committed by Roque

erp5_officejs: reduce calls to getSetting method

parent 2df7e77b
Pipeline #6762 failed with stage
in 0 seconds
......@@ -128,22 +128,13 @@
// declared methods
/////////////////////////////////////////////////////////////////
.declareMethod("getViewAndActionDict", function (portal_type, jio_key) {
.declareMethod("getViewAndActionDict", function (portal_type, app_view,
default_view, app_actions_string, jio_key) {
var gadget = this,
action_info_dict = {view_list: {}, action_list: {}},
query = buildSearchQuery(portal_type),
app_actions,
app_view,
default_view;
return gadget.getSettingList(['app_view_reference',
'default_view_reference',
'app_actions'])
.push(function (result_list) {
app_view = result_list[0];
default_view = result_list[1];
return formatSettingList(result_list[2], portal_type);
})
.push(function (app_actions_result) {
app_actions_result = formatSettingList(app_actions_string, portal_type);
app_actions = app_actions_result.map(function (pair) {
return pair[1];
});
......@@ -153,8 +144,7 @@
for (row in action_list.data.rows) {
if (action_list.data.rows.hasOwnProperty(row)) {
path_for_jio_get_list.push(gadget.jio_get(action_list
.data.rows[row]
.id));
.data.rows[row].id));
}
}
return RSVP.all(path_for_jio_get_list);
......@@ -174,8 +164,7 @@
action_type: action_doc.action_type,
parent_portal_type: portal_type
};
if (view_categorie_list.includes(action_settings
.action_type)) {
if (view_categorie_list.includes(action_settings.action_type)) {
action_settings.page = "ojs_local_controller";
action_info_dict.view_list[action_settings.action] =
action_settings;
......@@ -188,11 +177,9 @@
}
}
action_info_dict.view_list =
filterViewList(action_info_dict.view_list,
app_view, default_view);
filterViewList(action_info_dict.view_list, app_view, default_view);
return action_info_dict;
});
});
})
.declareMethod("getDialogFormDefinition", function (form_name, category) {
......@@ -234,13 +221,22 @@
form_definition,
portal_skin_folder,
app_allowed_sub_types,
app_view,
default_view,
app_actions_string,
form_info,
error;
return gadget.getSettingList([portal_type_dict_setting,
'portal_skin_folder',
'app_allowed_sub_types'])
'app_allowed_sub_types',
'app_view_reference',
'default_view_reference',
'app_actions'])
.push(function (result_list) {
app_allowed_sub_types = result_list[2];
app_view = result_list[3];
default_view = result_list[4];
app_actions_string = result_list[5];
if (!result_list[1]) {
throw new Error("Missing site configuration 'portal_skin_folder'");
}
......@@ -312,7 +308,8 @@
.new_content_dialog_form;
form_definition.new_content_category = portal_type_dict
.new_content_category;
return gadget.getViewAndActionDict(portal_type);
return gadget.getViewAndActionDict(portal_type, app_view,
default_view, app_actions_string);
})
.push(function (action_view_dict) {
form_definition.portal_type_dict.has_more_views =
......
......@@ -269,7 +269,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>979.7531.30512.46370</string> </value>
<value> <string>979.63531.55269.9250</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -287,7 +287,7 @@
</tuple>
<state>
<tuple>
<float>1571065275.72</float>
<float>1574423791.17</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -27,6 +27,8 @@
jio_document,
portal_type,
parent_portal_type,
default_view,
app_action_list,
form_definition,
current_version,
index;
......@@ -36,10 +38,14 @@
current_version = current_version.substr(index);
return gadget.getSettingList(["migration_version",
"app_view_reference",
"parent_portal_type"])
"parent_portal_type",
'default_view_reference',
'app_actions'])
.push(function (setting_list) {
app_view = options.action || setting_list[1];
parent_portal_type = setting_list[2];
default_view = setting_list[3];
app_action_list = setting_list[4];
if (setting_list[0] !== current_version) {
//if app version has changed, force storage selection
return gadget.redirect({
......@@ -82,7 +88,8 @@
})
.push(function (result) {
form_definition = result;
return gadget_util.getViewAndActionDict(portal_type,
return gadget_util.getViewAndActionDict(portal_type, app_view,
default_view, app_action_list,
options.jio_key);
})
.push(function (view_action_dict) {
......
......@@ -228,7 +228,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>979.53364.49548.7526</string> </value>
<value> <string>979.63498.47896.7901</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -246,7 +246,7 @@
</tuple>
<state>
<tuple>
<float>1573813846.58</float>
<float>1574423725.43</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -75,6 +75,7 @@
.declareAcquiredMethod("getUrlFor", "getUrlFor")
.declareAcquiredMethod("getUrlForList", "getUrlForList")
.declareAcquiredMethod("updateHeader", "updateHeader")
.declareAcquiredMethod("getSettingList", "getSettingList")
/////////////////////////////////////////////////////////////////
// declared methods
......@@ -83,7 +84,8 @@
.declareMethod("render", function (options) {
var gadget = this,
portal_type,
document_title;
document_title,
gadget_utils;
return gadget.jio_get(options.jio_key)
.push(function (document) {
document_title = document.title;
......@@ -96,11 +98,17 @@
portal_type = result;
return gadget.declareGadget("gadget_officejs_common_util.html");
})
.push(function (gadget_utils) {
.push(function (result) {
gadget_utils = result;
return gadget.getSettingList(['app_view_reference',
'default_view_reference',
'app_actions']);
})
.push(function (setting_list) {
// TODO views are also listed here
// should views be handled in another gadget like "..tab_office.js" ?
return gadget_utils.getViewAndActionDict(portal_type,
options.jio_key);
return gadget_utils.getViewAndActionDict(portal_type, setting_list[0],
setting_list[1], setting_list[2], options.jio_key);
})
.push(function (action_info_dict) {
return RSVP.all([
......
......@@ -228,7 +228,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>976.41484.14260.5085</string> </value>
<value> <string>979.63524.32203.29269</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -246,7 +246,7 @@
</tuple>
<state>
<tuple>
<float>1561477231.0</float>
<float>1574423701.42</float>
<string>UTC</string>
</tuple>
</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