Commit 3d350c00 authored by Roque's avatar Roque

erp5_officejs: action page handles new configuration fields

parent e59a7e4d
...@@ -38,6 +38,16 @@ ...@@ -38,6 +38,16 @@
); );
} }
function filterViews(views_dict, app_view, default_view) {
//TODO: there must be only one "View" action (title = "View")
// this is for scenarios were the portal type has several "View" (like view, jio_view, custom_view)
// priority: app_view ; default_view ; other (reference=view)
// if views_dict contains app_view -> remove all "View" entries
// else if contains default_view -> remove all "View" entries
// else get first "View" and remove all other "View" entries
return views_dict;
}
gadget_klass gadget_klass
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
// Acquired methods // Acquired methods
...@@ -90,19 +100,26 @@ ...@@ -90,19 +100,26 @@
action_info_dict = {views: {}, actions: {}}, action_info_dict = {views: {}, actions: {}},
//TODO use Query to avoid strings //TODO use Query to avoid strings
query = 'portal_type: "Action Information" AND parent_relative_url: "portal_types/' + portal_type + '"', query = 'portal_type: "Action Information" AND parent_relative_url: "portal_types/' + portal_type + '"',
app_actions; app_actions,
app_view,
default_view;
return RSVP.Queue() return RSVP.Queue()
.push(function () { .push(function () {
return RSVP.all([ return RSVP.all([
gadget.declareGadget("gadget_officejs_common_utils.html"), gadget.declareGadget("gadget_officejs_common_utils.html"),
gadget.getSetting('app_view_reference'),
gadget.getSetting('default_view_reference') gadget.getSetting('default_view_reference')
]); ]);
}) })
.push(function (result_list) { .push(function (result_list) {
app_view = result_list[1];
default_view = result_list[2];
return result_list[0].getAppActions(portal_type); return result_list[0].getAppActions(portal_type);
}) })
.push(function (app_actions_result) { .push(function (app_actions_result) {
app_actions = app_actions_result; app_actions = app_actions_result.map(function (pair) {
return pair[1];
});
return gadget.jio_allDocs({query: query}) return gadget.jio_allDocs({query: query})
.push(function (action_list) { .push(function (action_list) {
var path_for_jio_get_list = [], row; var path_for_jio_get_list = [], row;
...@@ -114,30 +131,31 @@ ...@@ -114,30 +131,31 @@
return RSVP.all(path_for_jio_get_list); return RSVP.all(path_for_jio_get_list);
}) })
.push(function (action_document_list) { .push(function (action_document_list) {
var action_settings_list = [], page, action_key, action_doc, key, action_settings; var page, action_key, action_doc, key, action_settings;
for (action_key in action_document_list) { for (action_key in action_document_list) {
//TODO filter actions: discard actions that are not in getSettings("app_actions")
//there must be one "View" action. If not, use default view (like jio_view in getsettings)
if (action_document_list.hasOwnProperty(action_key)) { if (action_document_list.hasOwnProperty(action_key)) {
action_doc = action_document_list[action_key]; action_doc = action_document_list[action_key];
action_settings = { if (app_actions.includes(action_doc.reference)) {
page: undefined, action_settings = {
jio_key: options.jio_key, page: undefined,
title: action_doc.title, jio_key: options.jio_key,
action: action_doc.reference, title: action_doc.title,
reference: action_doc.reference, action: action_doc.reference,
action_type: action_doc.action_type, reference: action_doc.reference,
parent_portal_type: portal_type action_type: action_doc.action_type,
}; parent_portal_type: portal_type
if (view_categories.includes(action_settings.action_type)) { };
action_settings.page = "ojs_local_controller"; if (view_categories.includes(action_settings.action_type)) {
action_info_dict.views[action_settings.action] = action_settings; action_settings.page = "ojs_local_controller";
} else { action_info_dict.views[action_settings.action] = action_settings;
action_settings.page = "handle_action"; } else {
action_info_dict.actions[action_settings.action] = action_settings; action_settings.page = "handle_action";
action_info_dict.actions[action_settings.action] = action_settings;
}
} }
} }
} }
action_info_dict.views = filterViews(action_info_dict.views, app_view, default_view);
return action_info_dict; return action_info_dict;
}); });
}); });
......
...@@ -228,7 +228,7 @@ ...@@ -228,7 +228,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>976.31000.44303.9591</string> </value> <value> <string>976.31395.21170.7816</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>1560848207.92</float> <float>1560871889.71</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