[FIX] web_editor: fix image cropping not working

Since this commit [1], the image cropping feature is no longer
functioning properly. The modification of the "activateCropper" function
code to remove the use of underscore has resulted in a change in the
"data" parameter value passed to the cropper compared to before. This
alteration is the cause of the issue.

Steps to reproduce the bugs:

- Open the homepage in Website edit mode.
- Drag and drop a text-image snippet onto the page.
- Click on the image in the text-image snippet.
- Click on the "Crop Image" button in the image options.
- Change the aspect ratio of the image by clicking on the "4:3" button.
- Click on the "Apply" button to apply the changes.
- Bug: The changes are not being applied.

[1]: https://github.com/odoo/odoo/commit/f4f0f783183507df8227b37fe1234c256325df6d

task-3339518

closes odoo/odoo#122996

X-original-commit: d42070b6abe5ca65d43ae4f2426619684c7aec4d
Signed-off-by: Colin Louis (loco) <loco@odoo.com>
This commit is contained in:
Benjamin Vray
2023-05-31 14:23:29 +02:00
parent 3db548c76f
commit 3a2288dc28
@@ -408,7 +408,8 @@ async function activateCropper(image, aspectRatio, dataset) {
dragMode: 'move',
autoCropArea: 1.0,
aspectRatio: aspectRatio,
data: Object.values(pick(dataset, ...cropperDataFields)).map((value) => parseFloat(value)),
data: Object.fromEntries(Object.entries(pick(dataset, ...cropperDataFields))
.map(([key, value]) => [key, parseFloat(value)])),
// Can't use 0 because it's falsy and cropperjs will then use its defaults (200x100)
minContainerWidth: 1,
minContainerHeight: 1,