[FIX] web: enable zoom tooltip for ImageField in edit mode

Steps to reproduce
==================

- Set the zoom option on an image field (You can do it with studio
  starting from 16.3)
- Go to a record and hover over the image

=> Nothing happens

Cause of the issue
==================

The tooltip is only displayed in readonly,
but with https://github.com/odoo/odoo/pull/100570 ,
the readonly mode has been removed.
So it only applies for views with the readonly attribute.

Solution
========

Always display the tooltip

opw-3646005

closes odoo/odoo#148534

X-original-commit: e0f9a7eedfb91ea46969490cf261548835844907
Signed-off-by: Hubert Van De Walle <huvw@odoo.com>
Signed-off-by: Francois Georis (fge) <fge@odoo.com>
This commit is contained in:
Hubert Van De Walle
2024-01-10 06:12:27 +00:00
parent 759fad4472
commit 796cb061d0
2 changed files with 12 additions and 4 deletions
@@ -88,7 +88,7 @@ export class ImageField extends Component {
}
get hasTooltip() {
return (
this.props.enableZoom && this.props.readonly && this.props.record.data[this.props.name]
this.props.enableZoom && this.props.record.data[this.props.name]
);
}
get tooltipAttributes() {
@@ -517,7 +517,8 @@ QUnit.module("Fields", (hooks) => {
});
QUnit.test("ImageField: zoom and zoom_delay options (edit)", async function (assert) {
serverData.models.partner.records[0].document = MY_IMAGE;
serverData.models.partner.records[0].document = "3 kb";
serverData.models.partner.records[0].write_date = "2022-08-05 08:37:00";
await makeView({
type: "form",
@@ -531,8 +532,15 @@ QUnit.module("Fields", (hooks) => {
});
assert.ok(
!target.querySelector(".o_field_image img").dataset["tooltipInfo"],
"the tooltip is not present in edition"
JSON.parse(
target.querySelector(".o_field_image img").dataset["tooltipInfo"]
).url.endsWith("/web/image?model=partner&id=1&field=document&unique=1659688620000"),
"tooltip show the full image from the field value"
);
assert.strictEqual(
target.querySelector(".o_field_image img").dataset["tooltipDelay"],
"600",
"tooltip has the right delay"
);
});