Make binary widget works with non-binary field
The method get_size must be used only if the field has it otherwise the length of the raw data should be used. String must be used for set_client if the field is not Binary. issue5924 review33431002
This commit is contained in:
1 parent
3208eb242d
commit
7ca45ca0c2
2 files changed
+21
-3
No files matched your search
+14
-2
@@ -2881,8 +2881,15 @@
|
||||
var save_file = function() {
|
||||
var reader = new FileReader();
|
||||
reader.onload = function(evt) {
|
||||
var field = this.field();
|
||||
var uint_array = new Uint8Array(reader.result);
|
||||
this.field().set_client(record, uint_array);
|
||||
var value;
|
||||
if (field.get_size) {
|
||||
value = uint_array;
|
||||
} else {
|
||||
value = String.fromCharCode.apply(null, uint_array);
|
||||
}
|
||||
field.set_client(record, value);
|
||||
}.bind(this);
|
||||
reader.onloadend = function(evt) {
|
||||
close();
|
||||
@@ -2993,7 +3000,12 @@
|
||||
this.but_save_as.button('disable');
|
||||
return;
|
||||
}
|
||||
var size = field.get_size(record);
|
||||
var size;
|
||||
if (field.get_size) {
|
||||
size = field.get_size(record);
|
||||
} else {
|
||||
size = field.get(record).length;
|
||||
}
|
||||
var button_sensitive;
|
||||
if (size) {
|
||||
button_sensitive = 'enable';
|
||||
|
||||
+7
-1
@@ -1526,7 +1526,13 @@
|
||||
Sao.View.Tree.BinaryColumn = Sao.class_(Sao.View.Tree.CharColumn, {
|
||||
class_: 'column-binary',
|
||||
update_text: function(cell, record) {
|
||||
cell.text(Sao.common.humanize(this.field.get_size(record)));
|
||||
var size;
|
||||
if (this.field.get_size) {
|
||||
size = this.field.get_size(record);
|
||||
} else {
|
||||
size = this.field.get(record).length;
|
||||
}
|
||||
cell.text(Sao.common.humanize(size));
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in new issue
Block a user