changeset 1d6b2b454462 in sao:default
details: https://hg.tryton.org/sao?cmd=changeset&node=1d6b2b454462
description:
Do not stringify binary data
For the identify only the size matter to refresh the display.
And to detect change, we can compare the Uint8Array between them or
with the
size.
issue10994
review360581002
diffstat:
src/model.js | 17 +++++++++++++----
1 files changed, 13 insertions(+), 4 deletions(-)
diffs (44 lines):
diff -r d51a9a45a77a -r 1d6b2b454462 src/model.js
--- a/src/model.js Tue Dec 21 23:11:23 2021 +0100
+++ b/src/model.js Tue Dec 21 23:24:05 2021 +0100
@@ -1423,7 +1423,11 @@
Object.keys(this._values).reduce(function(values, name) {
var field = this.model.fields[name];
if (field) {
- values[name] = field.get(this);
+ if (field instanceof Sao.field.Binary) {
+ values[name] = field.get_size(this);
+ } else {
+ values[name] = field.get(this);
+ }
}
return values;
}.bind(this), {}));
@@ -1556,12 +1560,14 @@
}
return value;
},
+ _has_changed: function(previous, value) {
+ // Use stringify to compare object instance like Number for Decimal
+ return JSON.stringify(previous) != JSON.stringify(value);
+ },
set_client: function(record, value, force_change) {
var previous_value = this.get(record);
this.set(record, value);
- // Use stringify to compare object instance like Number for Decimal
- if (JSON.stringify(previous_value) !=
- JSON.stringify(this.get(record))) {
+ if (this._has_changed(previous_value, this.get(record))) {
record._changed[this.name] = true;
this.changed(record);
record.validate(null, true, false, true);
@@ -2733,6 +2739,9 @@
Sao.field.Binary = Sao.class_(Sao.field.Field, {
_default: null,
+ _has_changed: function(previous, value) {
+ return previous != value;
+ },
get_size: function(record) {
var data = record._values[this.name] || 0;
if (data instanceof Uint8Array) {