Commit 8de5eb31 authored by Yusei Tahara's avatar Yusei Tahara Committed by Romain Courteaud

erp5_web_renderjs_ui: Change date separator from a dash to a slash before...

erp5_web_renderjs_ui: Change date separator from a dash to a slash before sending query to Zope. If date separator was a dash, Zope DateTime does not use local timezone and date search does not work.
parent 83f3e1fe
Pipeline #11908 failed with stage
in 0 seconds
......@@ -265,6 +265,15 @@
if (operator_default_list === NUMERIC) {
if (query_dict.key.indexOf("date") !== -1) {
input_type = "date";
if (query_dict.value) {
// Zope DateTime uses local timezone automatically if date seperator
// was a slash like 2020/02/08, but if it was a dash like 2020-02-08,
// Zope DateTime ignores local timezone and timezone become GMT+0.
// Then if server is not located in GMT+0 zone, date search does not
// work. Since HTML5 date input field uses dash as a separator, it
// must be changed to slash before sending query to Zope.
query_dict.value = query_dict.value.replace(/\//g, "-");
}
} else {
input_type = "number";
}
......@@ -392,7 +401,8 @@
select_list,
key,
operator,
value;
value,
input_field;
for (i = 0; i < filter_item_list.length; i += 1) {
select_list = filter_item_list[i].querySelectorAll("select");
......@@ -413,6 +423,16 @@
/*jslint continue: false */
}
value = filter_item_list[i].querySelector("input").value;
input_field = filter_item_list[i].querySelector("input");
if (input_field.type === 'date' && value) {
// Zope DateTime uses local timezone automatically if date seperator
// was a slash like 2020/02/08, but if it was a dash like 2020-02-08,
// Zope DateTime ignores local timezone and timezone become GMT+0.
// Then if server is not located in GMT+0 zone, date search does not
// work. Since HTML5 date input field uses dash as a separator, it
// must be changed to slash before sending query to Zope.
value = value.replace(/-/g, "/");
}
}
state.query_list.push({
type: "simple",
......
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