mirror of
https://github.com/OCA/web.git
synced 2025-02-22 13:21:25 +02:00
[IMP] web_tree_image_tooltip :
* Add the possibility to define an alternative image field for the tooltip image to reduce the bandwidth used * Add image in the description of the module * Add demo data for the res.users tree view
This commit is contained in:
@@ -2,14 +2,36 @@ odoo.define('web_tree_image_tooltip.web_tree_image_tooltip',
|
||||
function (require) {
|
||||
"use strict";
|
||||
|
||||
var session = require('web.session');
|
||||
var field_utils = require('web.field_utils');
|
||||
var FieldBinaryImage = require('web.basic_fields').FieldBinaryImage;
|
||||
var ListRenderer = require('web.ListRenderer');
|
||||
|
||||
FieldBinaryImage.include({
|
||||
_render: function () {
|
||||
this._super();
|
||||
if (this.nodeOptions.tooltip_image) {
|
||||
var image_src = session.url('/web/image', {
|
||||
model: this.model,
|
||||
id: JSON.stringify(this.res_id),
|
||||
field: this.nodeOptions.tooltip_image,
|
||||
// unique forces a reload of the image when the record has been updated
|
||||
unique: field_utils.format.datetime(this.recordData.__last_update).replace(/[^0-9]/g, ''),
|
||||
})
|
||||
this.$('.img-fluid')[0].setAttribute("tooltip-image-src", image_src);
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
ListRenderer.include({
|
||||
events: _.extend({}, ListRenderer.prototype.events, {
|
||||
'mouseover tbody tr td .o_field_image': '_onHoverRecord_img',
|
||||
}),
|
||||
_onHoverRecord_img: function (event) {
|
||||
var img_src =
|
||||
$(event.currentTarget).children('.img-fluid').attr('src')
|
||||
$(event.currentTarget).children('.img-fluid').attr('tooltip-image-src') ||
|
||||
$(event.currentTarget).children('.img-fluid').attr('src');
|
||||
|
||||
$(event.currentTarget).tooltip({
|
||||
title: "<img src="+img_src+" class='tooltip_image' />",
|
||||
delay: 0,
|
||||
|
||||
Reference in New Issue
Block a user