Commit be73a5c4 authored by Romain Courteaud's avatar Romain Courteaud

Release 3.27.0

Add support for ERP5's selection_dmain
parent a06b3b4b
......@@ -7540,6 +7540,7 @@ return new Parser;
* @param {String} [param.dataType=""] The data type to retrieve
* @param {String} param.url The url
* @param {Any} [param.data] The data to send
* @param {Number} param.timeout The request timeout value
* @param {Function} [param.beforeSend] A function called just before the
* send request. The first parameter of this function is the XHR object.
* @return {Promise} The promise
......@@ -7572,6 +7573,12 @@ return new Parser;
}
}
}
if (param.timeout !== undefined && param.timeout !== 0) {
xhr.timeout = param.timeout;
xhr.ontimeout = function () {
return reject(new jIO.util.jIOError("Gateway Timeout", 504));
};
}
if (typeof param.beforeSend === 'function') {
param.beforeSend(xhr);
}
......@@ -7632,6 +7639,9 @@ return new Parser;
if (obj === undefined) {
return undefined;
}
if (obj === null) {
return 'null';
}
if (obj.constructor === Object) {
key_list = Object.keys(obj).sort();
result_list = [];
......@@ -10528,6 +10538,8 @@ return new Parser;
} else {
this._catch_error = false;
}
// If timeout not set, use 0 for no timeout value
this._timeout = spec.timeout || 0;
}
HttpStorage.prototype.get = function (id) {
......@@ -10536,7 +10548,8 @@ return new Parser;
.push(function () {
return jIO.util.ajax({
type: 'HEAD',
url: id
url: id,
timeout: context._timeout
});
})
.push(undefined, function (error) {
......@@ -10586,7 +10599,8 @@ return new Parser;
return jIO.util.ajax({
type: 'GET',
url: id,
dataType: "blob"
dataType: "blob",
timeout: context._timeout
});
})
.push(undefined, function (error) {
......@@ -12142,12 +12156,26 @@ return new Parser;
function isSingleLocalRoles(parsed_query) {
if ((parsed_query instanceof SimpleQuery) &&
(parsed_query.operator === undefined) &&
(parsed_query.key === 'local_roles')) {
// local_roles:"Assignee"
return parsed_query.value;
}
}
function isSingleDomain(parsed_query) {
if ((parsed_query instanceof SimpleQuery) &&
(parsed_query.operator === undefined) &&
(parsed_query.key !== undefined) &&
(parsed_query.key.indexOf('selection_domain_') === 0)) {
// domain_region:"europe/france"
var result = {};
result[parsed_query.key.slice('selection_domain_'.length)] =
parsed_query.value;
return result;
}
}
function isMultipleLocalRoles(parsed_query) {
var i,
sub_query,
......@@ -12159,6 +12187,7 @@ return new Parser;
for (i = 0; i < parsed_query.query_list.length; i += 1) {
sub_query = parsed_query.query_list[i];
if ((sub_query instanceof SimpleQuery) &&
(sub_query.key !== undefined) &&
(sub_query.key === 'local_roles')) {
local_role_list.push(sub_query.value);
} else {
......@@ -12182,19 +12211,26 @@ return new Parser;
.push(function (site_hal) {
var query = options.query,
i,
key,
parsed_query,
sub_query,
result_list,
local_roles,
local_role_found = false,
selection_domain,
sort_list = [];
if (options.query) {
parsed_query = jIO.QueryFactory.create(options.query);
result_list = isSingleLocalRoles(parsed_query);
if (result_list) {
query = undefined;
local_roles = result_list;
} else {
result_list = isSingleDomain(parsed_query);
if (result_list) {
query = undefined;
selection_domain = result_list;
} else {
result_list = isMultipleLocalRoles(parsed_query);
if (result_list) {
......@@ -12204,29 +12240,49 @@ return new Parser;
(parsed_query.operator === 'AND')) {
// portal_type:"Person" AND local_roles:"Assignee"
// AND selection_domain_region:"europe/france"
for (i = 0; i < parsed_query.query_list.length; i += 1) {
sub_query = parsed_query.query_list[i];
if (!local_role_found) {
result_list = isSingleLocalRoles(sub_query);
if (result_list) {
local_roles = result_list;
parsed_query.query_list.splice(i, 1);
query = jIO.Query.objectToSearchText(parsed_query);
i = parsed_query.query_list.length;
local_role_found = true;
} else {
result_list = isMultipleLocalRoles(sub_query);
if (result_list) {
local_roles = result_list;
parsed_query.query_list.splice(i, 1);
query = jIO.Query.objectToSearchText(parsed_query);
i = parsed_query.query_list.length;
local_role_found = true;
}
}
}
result_list = isSingleDomain(sub_query);
if (result_list) {
parsed_query.query_list.splice(i, 1);
query = jIO.Query.objectToSearchText(parsed_query);
if (selection_domain) {
for (key in result_list) {
if (result_list.hasOwnProperty(key)) {
selection_domain[key] = result_list[key];
}
}
} else {
selection_domain = result_list;
}
i -= 1;
}
}
}
}
}
}
if (options.sort_on) {
for (i = 0; i < options.sort_on.length; i += 1) {
......@@ -12234,6 +12290,10 @@ return new Parser;
}
}
if (selection_domain) {
selection_domain = JSON.stringify(selection_domain);
}
return jIO.util.ajax({
"type": "GET",
"url": UriTemplate.parse(site_hal._links.raw_search.href)
......@@ -12243,7 +12303,8 @@ return new Parser;
select_list: options.select_list || ["title", "reference"],
limit: options.limit,
sort_on: sort_list,
local_roles: local_roles
local_roles: local_roles,
selection_domain: selection_domain
}),
"xhrFields": {
withCredentials: true
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
{
"name": "jio",
"version": "v3.26.0",
"version": "v3.27.0",
"license": "LGPLv3",
"author": "Nexedi SA",
"contributors": [
......
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