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