Display image widget in tree view

issue3729
review4001003
This commit is contained in:
Nicolas Évrard committed 2014-09-19 17:09:43 +02:00
1 parent 2a62da8358
commit 3a7238698e
2 files changed
+40

No files matched your search

+2
View File
@@ -18,6 +18,8 @@
Sao.common.SELECTION_SINGLE = 2; // Not implemented yet
Sao.common.SELECTION_MULTIPLE = 3;
Sao.common.BIG_IMAGE_SIZE = Math.pow(10, 6);
Sao.common.compare = function(arr1, arr2) {
if (arr1.length != arr2.length) {
return false;
+38
View File
@@ -77,6 +77,8 @@
return Sao.View.Tree.IntegerColumn;
case 'boolean':
return Sao.View.Tree.BooleanColumn;
case 'image':
return Sao.View.Tree.ImageColumn;
default:
return Sao.View.Tree.CharColumn;
}
@@ -1070,6 +1072,42 @@
}
});
Sao.View.Tree.ImageColumn = Sao.class_(Sao.View.Tree.CharColumn, {
class_: 'column-image',
get_cell: function() {
var cell = jQuery('<img/>');
cell.addClass(this.class_);
cell.css('width', '100%');
return cell;
},
render: function(record) {
var cell = this.get_cell();
record.load(this.attributes.name).done(function() {
var value = this.field.get_client(record);
if (value) {
if (value > Sao.common.BIG_IMAGE_SIZE) {
value = jQuery.when(null);
} else {
value = this.field.get_data(record);
}
} else {
value = jQuery.when(null);
}
value.done(function(data) {
var img_url, blob;
if (!data) {
img_url = null;
} else {
blob = new Blob([data[0][this.field.name]]);
img_url = window.URL.createObjectURL(blob);
}
cell.attr('src', img_url);
}.bind(this));
}.bind(this));
return cell;
}
});
Sao.View.Tree.ButtonColumn = Sao.class_(Object, {
init: function(screen, attributes) {
this.screen = screen;