Commit 140a196f authored by Romain Courteaud's avatar Romain Courteaud

WIP [erp5storage] Allow toquery the catalog with the group_by parameter

parent 657f7610
...@@ -474,6 +474,7 @@ ...@@ -474,6 +474,7 @@
if (context.hasCapacity("list") && if (context.hasCapacity("list") &&
((options.query === undefined) || context.hasCapacity("query")) && ((options.query === undefined) || context.hasCapacity("query")) &&
((options.sort_on === undefined) || context.hasCapacity("sort")) && ((options.sort_on === undefined) || context.hasCapacity("sort")) &&
((options.group_by === undefined) || context.hasCapacity("group")) &&
((options.select_list === undefined) || ((options.select_list === undefined) ||
context.hasCapacity("select")) && context.hasCapacity("select")) &&
((options.include_docs === undefined) || ((options.include_docs === undefined) ||
......
...@@ -420,7 +420,7 @@ ...@@ -420,7 +420,7 @@
ERP5Storage.prototype.hasCapacity = function (name) { ERP5Storage.prototype.hasCapacity = function (name) {
return ((name === "list") || (name === "query") || return ((name === "list") || (name === "query") ||
(name === "select") || (name === "limit") || (name === "select") || (name === "limit") ||
(name === "sort")); (name === "sort") || (name === "group"));
}; };
function isSingleLocalRoles(parsed_query) { function isSingleLocalRoles(parsed_query) {
...@@ -488,7 +488,8 @@ ...@@ -488,7 +488,8 @@
local_roles, local_roles,
local_role_found = false, local_role_found = false,
selection_domain, selection_domain,
sort_list = []; sort_list = [],
group_list = [];
if (options.query) { if (options.query) {
parsed_query = jIO.QueryFactory.create(options.query); parsed_query = jIO.QueryFactory.create(options.query);
result_list = isSingleLocalRoles(parsed_query); result_list = isSingleLocalRoles(parsed_query);
...@@ -554,10 +555,8 @@ ...@@ -554,10 +555,8 @@
} }
} }
if (options.sort_on) { if (options.group_by) {
for (i = 0; i < options.sort_on.length; i += 1) { group_list = options.group_by;
sort_list.push(JSON.stringify(options.sort_on[i]));
}
} }
if (selection_domain) { if (selection_domain) {
...@@ -573,6 +572,7 @@ ...@@ -573,6 +572,7 @@
select_list: options.select_list || ["title", "reference"], select_list: options.select_list || ["title", "reference"],
limit: options.limit, limit: options.limit,
sort_on: sort_list, sort_on: sort_list,
group_by: group_list,
local_roles: local_roles, local_roles: local_roles,
selection_domain: selection_domain selection_domain: selection_domain
}) })
......
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