Add icon of type URL

issue10140
review355171002
This commit is contained in:
Cédric Krier
2021-03-20 12:38:16 +01:00
parent 8a218aa66f
commit 73cce597f1
3 changed files with 50 additions and 20 deletions
+1
View File
@@ -1,3 +1,4 @@
* Support icon of type URL
* Allow sending email with existing attachments
* Add paths and model context to action data
* Add indentation in CSV export of tree
+22 -7
View File
@@ -1078,14 +1078,29 @@ function eval_pyson(value){
var field = record.model.fields[name];
name = field.get(record);
}
Sao.common.ICONFACTORY.get_icon_url(name)
.done(function(url) {
if (url) {
this.img.attr('src', url);
} else {
this.img.removeAttr('src');
if (this.attributes.type == 'url') {
if (name) {
if (this.attributes.url_size) {
var url = new URL(name, window.location);
url.searchParams.set(
this.attributes.url_size,
attributes.size || 48);
name = url.href;
}
}.bind(this));
this.img.attr('src', name);
} else {
this.img.removeAttr('src');
}
} else {
Sao.common.ICONFACTORY.get_icon_url(name)
.done(function(url) {
if (url) {
this.img.attr('src', url);
} else {
this.img.removeAttr('src');
}
}.bind(this));
}
}
});
+27 -13
View File
@@ -2032,20 +2032,34 @@
else {
value = this.icon;
}
Sao.common.ICONFACTORY.get_icon_url(value)
.done(function(url) {
var img_tag;
if (cell.children('img').length) {
img_tag = cell.children('img');
} else {
img_tag = cell;
var img_tag;
if (cell.children('img').length) {
img_tag = cell.children('img');
} else {
img_tag = cell;
}
if (this.attributes.icon_type == 'url') {
if (value) {
if (this.attributes.url_size) {
var url = new URL(value, window.location);
url.searchParams.set(
this.attributes.url_size, 20);
value = url.href;
}
if (url) {
img_tag.attr('src', url);
} else {
img_tag.removeAttr('src');
}
}.bind(this));
img_tag.attr('src', value);
} else {
img_tag.removeAttr('src');
}
} else {
Sao.common.ICONFACTORY.get_icon_url(value)
.done(function(url) {
if (url) {
img_tag.attr('src', url);
} else {
img_tag.removeAttr('src');
}
}.bind(this));
}
} else {
value = this.attributes.string || '';
if (!value) {