Commit 65480a09 authored by Tristan Cavelier's avatar Tristan Cavelier

DATETIMEFIELDUPDATE fix for linesfield

parent 98101f69
...@@ -92,6 +92,13 @@ and handling data send&receive. ...@@ -92,6 +92,13 @@ and handling data send&receive.
} }
} }
function ensureComparable(value, field_type) {
// For LinesField, getContent returns string, but we may give an array of strings to the render method.
if (field_type === "LinesField") { return value.join ? value.join("\n") : value; }
if (typeof value === "object") { return JSON.stringify(value); }
return value;
}
function updateErp5DocumentForAfterSave(new_erp5_document, submitted_content, current_content) { function updateErp5DocumentForAfterSave(new_erp5_document, submitted_content, current_content) {
var view = new_erp5_document._embedded._view, var view = new_erp5_document._embedded._view,
content_key_list = Object.keys(current_content), content_key_list = Object.keys(current_content),
...@@ -107,7 +114,8 @@ and handling data send&receive. ...@@ -107,7 +114,8 @@ and handling data send&receive.
for (i = 0; i < content_key_list.length; i += 1) { for (i = 0; i < content_key_list.length; i += 1) {
key = content_key_list[i]; key = content_key_list[i];
if (document_reference_dict[key] && if (document_reference_dict[key] &&
JSON.stringify(submitted_content[key]) === JSON.stringify(document_reference_dict[key].default)) { ensureComparable(submitted_content[key], document_reference_dict[key].type) ===
ensureComparable(document_reference_dict[key].default, document_reference_dict[key].type)) {
document_reference_dict[key].default = current_content[key]; document_reference_dict[key].default = current_content[key];
} }
} }
......
...@@ -228,7 +228,7 @@ ...@@ -228,7 +228,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>975.56533.48127.29525</string> </value> <value> <string>975.56533.48137.29525</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>1558448080.86</float> <float>1558448090.86</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