Commit Graph
4198 Commits
Author SHA1 Message Date
Louis Wicket (wil) f1722c7334 [IMP] *: unify sprintf and gettext
Improve gettext to directly handle value injection within translations,
removing the need for sprintf.

closes odoo/odoo#123932

Related: odoo/enterprise#45370
Signed-off-by: Samuel Degueldre (sad) <sad@odoo.com>
2023-08-10 18:14:04 +02:00
Julien Carion (juca) b1b4120f2a [FIX] website: replace notification.notify
This commit replaces notification.notify with notification.add so that
it works without the legacy notification service.

Steps to reproduce:
- go to website settings
- add a new website with any name
- follow the steps and upload an invalid file as the logo

fix for https://github.com/odoo/odoo/commit/caefcb8590301a0ebbe947a875003b33ce7d537a

task-3338012

closes odoo/odoo#131422

X-original-commit: 0d7971e0ed7eee5b5e983c27a13c6a34457f4505
Signed-off-by: Michaël Mattiello (mcm) <mcm@odoo.com>
2023-08-10 09:12:34 +02:00
Stanislas Gueniffeyandqsm-odoo 7880c1599b [FIX] web_editor, *: add system for editable medias in non editable envs
*: website

Some specific media items are meant to be editable even though located
in non-editable environments. The typical case in 15.0 is the website
"Team" snippet: it is made of multiple bootstrap rows, each containing
a column with an image and a column with texts. The columns with the
image are only meant to hold that image, it was therefore marked as
non editable to prevent users adding text in there by mistake... but the
image is still meant to be editable. See [1], later fixed by [2].

The problem now is that the system that [2] had to use is quite messy:
the column is marked non editable thanks to the `o_not_editable` class
but the inner images were to be declared editable via some custom JS
method overrides (`_getContentEditableAreas`). The debate about if we
should keep a class-based system and/or a method-override system will be
left to master. This commit although comes with an uniformisation about
this, introducing a new class to declare "an editable media despite its
non editable environment". This is not a counter-part of the class
`o_not_editable`: we do not want the media to be marked with the
`contenteditable` attribute. Indeed, this is actually required since [2]
was not enough to solve the problem. See those steps:

- Add a company snippet in your page
- Change one of the images by an icon
- (Save / Reenter edit mode)
- Try to change the icon again / edit its options

=> You can't. Indeed [2] relied on the media being an image to re-enable
edition on it... but even if it did not, it would not have been enough.
Indeed, icons are forced to being `contenteditable="false"` by the new
editor library (since 15.0 then), last update on that at [3].
We thus needed a different way to differentiate editable media, hence
the introduction of the new `o_editable_media` class.

Note: this system is not perfect, but so is not the whole system about
determining what is editable or not at the moment. In this case, it may
exist cases of a media marked with the class to be editable but end up
in an environment which is not editable by force (xpath somewhere etc)
... and ends up being editable anyway. Most cases work though and at
worse it will be about a non editable image being editable but not
possible to save in very rare cases. As advertised, the whole system
about what is editable or not should be improved.

[1]: https://github.com/odoo/odoo/commit/30db617bc8ff7727f40d7ef58c6578e84a13f284
[2]: https://github.com/odoo/odoo/commit/61270ee8bffb6e85f8ff0d19c7a3889fdce2f486
[3]: https://github.com/odoo/odoo/commit/7646429e894f28f398b7b212e893822c06c7b03d

task-3226172

closes odoo/odoo#131139

X-original-commit: 436265e815684046a37a8b80e4cd520c2bd637f0
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
Co-authored-by: qsm-odoo <qsm@odoo.com>
2023-08-09 21:01:17 +02:00
Nasreddin Boulif (bon) 070d257fb0 [FIX] website: allow to translate appointment page on website
Steps to reproduce:

  - Install `website_appointment` module
  - Activate a second language on main website
  - Activate debug mode
  - Go to Website -> Configuration -> Online Appointments
  - Share multiple appointment and copy the link
  - Open the link in a new tab
  - Switch to second language
  - Open editor and click on `Translate` button

Issue:

  Traceback is raised.

Cause:

  When sharing multiple appointment and opening the shared link, we are
  redirected on the page to select the right appointment and we have the
  key `filter_appointment_type_ids` (with the IDs of the appointments)
  with the value already encoded.
  e.g: `[1, 3]` => `%5B1%2C+3%5D`.

  When translating a page by redirecting to the same URL (but encoded)
  with param `edit_translations` set to 1, the URL is re-encoded and
  therefore the value of the key `filter_appointment_type_ids` is double
  'encoded' and broken/not possible to parse.
  e.g: `%5B1%2C+3%5D` => `%255B1%252C%2B3%255D`.

Solution:

  Don't re-encode the updated URL; `goToWebsite` is expecting a non
  encoded path and is in charge of the re-encoding it.

opw-3409757

closes odoo/odoo#131150

X-original-commit: 574d7847bda5c6e21934f815f64d0d4ce3f70b8b
Signed-off-by: Romain Derie (rde) <rde@odoo.com>
2023-08-09 03:07:50 +02:00
Pierre Pulinckx (pipu) b1ebe3b6f4 [REF] *: Replace core._t imports
In this commit, _t import from import { _t } from
"@web/legacy/js/services/core" and from
 web/static/src/legacy/js/core/translation.js are replaced by
@web/core/l10n/translation.js.

task-3292454

closes odoo/odoo#130865

Related: odoo/enterprise#45270
Signed-off-by: Michaël Mattiello (mcm) <mcm@odoo.com>
2023-08-09 00:13:08 +02:00
Michael (mcm) 00d8aef1c7 [REF] web, *: remove legacy patch
This commit removes legacy patch/unpatch functions and adapts their use
by using the modern patch. There was also a custom patch function used
in tests which has been replaced too.

closes odoo/odoo#130867

Related: odoo/design-themes#685
Related: odoo/enterprise#45271
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2023-08-07 10:58:48 +02:00
Aaron Bohy 435834915e [REF] web, website: move initAutoMoreMenu to website
There's a single usecase left for this helper, which is in website.
This commit directly moves the function definition in the file
using it.

Part of task~3439226

closes odoo/odoo#130843

Signed-off-by: Jorge Pinna Puissant (jpp) <jpp@odoo.com>
2023-08-04 16:34:51 +02:00
Aaron Bohy 6774530101 [REF] web,*: remove KeyboardNavigationMixin from website
This mixin was still applied on the RootWidget but was useless
since the website relies on the hotkey service [1].

This commit ends the life of the frontend_legacy asset.

[1] https://github.com/odoo/odoo/commit/daf5963845a8dda4d669e512a4ef6dcfebdd8813#diff-fe005825c9360edbc616517111aa67926161221c42003cad29f88a0214cd909eR13

Part of task~3439226

Part-of: odoo/odoo#130843
2023-08-04 16:34:50 +02:00
Arthur Detroux (ard) 67d26ab8b1 [IMP] website: warn users when a website has no domain
Prior to this commit, if a website does not have a domain, nothing tells
the user that this is a misconfiguration that can lead to broken
behaviours. For example, here are the steps to reproduce:

- Have two website (X and Y)
- Website Y does not have a domain
- Tab 1 has Website X selected
- User opens a new tab
- Tab 2 has Website X selected as well
- User switches tab 2 to Website Y
- No redirection happens
- User switches back to tab 1
- User opens the HTML editor for Website X
- Website X content is displayed
- User saves
- Content is saved on Website Y

This is pretty hard to fix as a lot of the python flow for Website uses
`get_current_website` which will uses the session's "force_website_id"
in priority.

In any case, we consider having multiple websites sharing the same
domain (or having no domains at all) a misconfiguration. Therefore, we
should warn the user of so.

This commit adds a tooltip on the website switcher for websites that do
not have a domain set. It also adds a notification recommending users
close other tabs if they switch website.

opw-3374214

closes odoo/odoo#130448

X-original-commit: bc0c33e3d0026a14af40ed683fe27092a97e71a7
Related: odoo/design-themes#684
Signed-off-by: Romain Derie (rde) <rde@odoo.com>
Signed-off-by: Arthur Detroux (ard) <ard@odoo.com>
2023-08-03 10:43:04 +02:00
Michael (mcm) 9d6b380a24 [REF] *: adapt patches after new patch function
In the commit [1], the patch has been refactored to support the
native keyword `super`. The current commit just adapts the codebase
to that change.

task 3410198

[1]: 19ea1ac08043e22a811630968e44715cc3bfc495

Part-of: odoo/odoo#125716
2023-08-02 17:29:05 +02:00
Pierre Pulinckx (pipu) 09535ef5e6 [REF] website_*: Change registerTours of tour_utils
As steps are encapsuled in an arrow function from
69a5d8e3ce47238 for steps tour definition to avoid
direct Markup(_t()) interpretation, the same is done
for registerWebsitePreviewTour() of
"odoo/addons/website/static/src/js/tours/tour_utils.js"
in this commit.

This is done in anticipation of the use of
_t() (import from @web/core/l10n/translation) with
registerWebsitePreviewTour().

task-3292454

closes odoo/odoo#130248

Related: odoo/design-themes#678
Signed-off-by: Luca Vitali (luvi) <luvi@odoo.com>
2023-08-02 13:20:23 +02:00
Guillaume (gdi) ca10ad3c2a [FIX] website: ignore carousel slides for history step
When you drop a block containing a carousel, you can change the slide.
Unfortunately, in edit mode, changing the slide creates a step in the
history (you slide in the other direction by pressing CTRL-Z). This is
not what you want.

task-3356629

closes odoo/odoo#130417

X-original-commit: 5c68489c4220fe50c26168f2fb98546626b36e78
Signed-off-by: Colin Louis (loco) <loco@odoo.com>
Signed-off-by: Guillaume Dieleman (gdi) <gdi@odoo.com>
2023-08-02 06:18:43 +02:00
Guillaume (gdi) 952c9b4c73 [FIX] website: fix theme previews in right to left languages
Since Odoo 16.0, the configurator is translated in the user language.
Unfortunately, the theme previews are not yet translated in the user
language, so the user sees the theme previews in the default language
(English) but on a rtl page which causes alignment issues on the themes
previews. This commit fixes this issue by forcing the SVG containers
to be in ltr.

Steps to reproduce the issue fixed by this commit:
- Set the Arabic (Syria) language for an internal user
- With the internal user, create a new website
- Follow the configurator (in Arabic) until the theme selection step

=> Some text in the theme previews are not aligned correctly.

task-3398707

closes odoo/odoo#130325

X-original-commit: 1d0671a22582f423e55aad2907340700697c966e
Signed-off-by: Benjamin Vray (bvr) <bvr@odoo.com>
Signed-off-by: Guillaume Dieleman (gdi) <gdi@odoo.com>
2023-08-02 05:11:03 +02:00
Benoit Socias cd46857b15 [FIX] web_editor, website: use dataset mimetype when modifying images
Since [1] the mimetype used when calling `modify_image` was obtained
from the data URL contained in the `src` attribute instead of the
dataset. This is wrong for background images because they do not have an
`src` attribute.
Thanks to [2] which repaired the value contained in `dataset.mimetype`,
this value can be used as it was before [1].

[1]: https://github.com/odoo/odoo/commit/0449fe85cb0e1d639a4e1aeba26e90906f79254d
[2]: https://github.com/odoo/odoo/commit/40811e72c50faf146ccdf9f26c332db9ebc69fa9

task-3446438

closes odoo/odoo#130322

X-original-commit: e3221fe5d5efa824365210f040e93654e0a30309
Signed-off-by: Romain Derie (rde) <rde@odoo.com>
Signed-off-by: Benoit Socias (bso) <bso@odoo.com>
2023-08-02 05:10:48 +02:00
Rodolpho Lima cdc8e4daad [FIX] web_editor: images stored as base64-encoded sources
Commit [1] introduced an option in the Wysiwyg widget to save pasted
and dropped images as attachments instead of keeping them as inline
base64-encoded sources.

In order to prevent records from having excessively large sizes in their
html field content, this commit makes such option the default one for
the Wysiwyg class.

task-3289061

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

closes odoo/odoo#130213

X-original-commit: 7e06b40ea58f58069729f881f7d4559d17778fe7
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2023-08-01 13:51:40 +02:00
Rodolpho Lima eca5bfae0f [FIX] website: missing super call in _getEditorOptions
Since the refactor done in [1], the default Wysiwyg options is not
applied to the final options object when the website's
WysiwygAdapterComponent is instantiated. This happened because the
`_getEditorOptions` method is overriden without calling `super`.

As a result, before this commit, commands like "video" or "image" were
no longer available when editing text in website, as the options that
enable such commands were missing.

This commit fixes it by calling super in the overriding method.

[1]: https://github.com/odoo/odoo/pull/118966/commits/fed6569c9671c61269ed7ffa3bfcdb919a0daf14

X-original-commit: 9f2ebb7ffa3742d7da369f5020d57317c5a1794a
Part-of: odoo/odoo#130213
2023-08-01 13:51:40 +02:00
Pierre Pulinckx (pipu) 60fe2e9b17 [REF] *: remove _lt()
In a previous commit 8bfa76a, _lt() returns _t().
So, in this commit, all usages of _lt() are replaced by _t().

task-3292454

closes odoo/odoo#130179

Related: odoo/enterprise#44906
Signed-off-by: Luca Vitali (luvi) <luvi@odoo.com>
2023-08-01 13:51:17 +02:00
Nasreddin Boulif (bon) cbff652b10 [FIX] website[_slides]: Unhide conditional elements in fullscreen
Steps to reproduce:

  - Install `website_slides` module
  - Create a course and add a slide of type `Article`
  - Go to frontend and edit the slide
  - Add a text element and edit conditional visibility
    (e.g. visible only if user logged in)
  - Save and open the slide in fullscreen mode (with any logged user)

Issue:

  The text block is missing.

Cause:

  The slide is rendered in lazy load after that the code that unhide
  conditional elements is already executed (on event `DOMContentLoaded`)

Solution:

  Extract the concerned code so it can be called and re-executed after
  the slide is rendered also in fullscreen.

opw-3225444

closes odoo/odoo#129646

X-original-commit: 553702c99cbd90edfb509ca9e7ab0c99c73a96e6
Signed-off-by: Nasreddin Boulif (bon) <bon@odoo.com>
2023-07-31 16:10:58 +02:00
divy-odoo 9a189c6eb0 [FIX] website: image gallery snippet arrow visibility
This commit solves the visibility issue of an arrow in the image gallery
snippet. Before this commit, an arrow was not visible over the white
background.

In this PR[1], we adapted directional odoo icons by replacing font
awesome but there were some CSS directly targeting the `fa` class that
also should be replaced by the `oi` to target the `oi` class. So adding
the CSS selector `oi`.
- Keeping 'fa' too, as this still can be used by the already dropped
snippet.

[1]: https://github.com/odoo/odoo/commit/418413e4997a6b65eb7ad9e9ef8aba42805f1c0c

task-3339169

closes odoo/odoo#129939

X-original-commit: 59c7a371c9389135ff6fa9778e6f5adea9a97aea
Signed-off-by: Benjamin Vray (bvr) <bvr@odoo.com>
Signed-off-by: Divyesh Vyas (divy) <divy@odoo.com>
2023-07-28 06:45:11 +02:00
Rithwik 41e08479c8 [FIX] website: implements contains for hidden_condition_no_text_opt
Multiple field visibility was not working properly while using
Multiple Checkbox field as visibility condition. Only "is equal to"
and "is not equal to" was implemented for Multiple Checkbox. The
"is equal to" uses formData.get which only retrieves the first
value from Multiple Checkbox. The Multiple Checkbox was not having
"contains" option which was already available for some other
fields.

This commit will implement "contains" for all the input types
which comes under hidden_condition_no_text_opt in the file
s_website_form.xml. These include radio, checkbox and Multiple
Checkbox. The fields which comes under hidden_condition_no_text_opt
which does not require multiple inputs can use "contains" and
"doesn't contain" interchangeably with "is equal to" and
"is not equal to"

Fixes #120631

closes odoo/odoo#129853

X-original-commit: 696d74e5304bd48e965a1c5f5fc0b5a5205f5d49
Signed-off-by: Romain Derie (rde) <rde@odoo.com>
2023-07-27 14:47:27 +02:00
Benoit Socias 36623d1687 [FIX] website: fix website text edition test
Since [1] the `website_text_edition` tour fails because it manages to
change tab, drop a block, select a paragraph and click on a button
before the bundle reload happens.

This commit makes sure `updateOptionsUI` is awaited and that any
subsequent call is only queued afterwards.

task-3370939

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

closes odoo/odoo#129855

X-original-commit: 81abdb96aeb95e492230d39000e28c0d239840de
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
Signed-off-by: Benoit Socias (bso) <bso@odoo.com>
2023-07-27 13:25:10 +02:00
Bastien PIERRE 65242e31e9 [IMP] *: Remove alias in JS files
Rename all imports with alias old system to the new js module system
Task ID: 3266759

closes odoo/odoo#127414

Related: odoo/design-themes#671
Related: odoo/enterprise#43716
Signed-off-by: Bastien Pierre (ipb) <ipb@odoo.com>
2023-07-27 11:58:34 +02:00
Benjamin Vray c8a40b9025 [FIX] website: add test for popup and scrollbar
Add test to verify scrollbar behavior for page and popups with or
without backdrop. The expected behavior is that the page scrollbar
should not be present when a modal with a backdrop is open, and that the
page scrollbar should be displayed if the popup does not have a
backdrop, such as a cookie bar. However, if a modal without a backdrop
itself has a scrollbar, the page scrollbar should not be displayed to
prevent the two scrollbars from overlapping, which prevents scrolling of
the popup on Chrome (when clicking on the scrollbar instead of using the
mouse wheel).

In addition to that, this commit includes a test to confirm the proper
functionality of snippet animations when a cookie bar is displayed on
the page. Moreover, it also verifies that the snippet animations perform
correctly within a popup.

During the forward port of this commit (Master branch), the test failed
due to missing braces around 'throttleForAnimation' in the '000.js' file
of 's_popup'. These were directly added in this commit.

task-2983901

closes odoo/odoo#128914

X-original-commit: 4dd462f20ccb29923e5a053e0ed4c08545f82ae7
Signed-off-by: Romain Derie (rde) <rde@odoo.com>
Signed-off-by: Benjamin Vray (bvr) <bvr@odoo.com>
2023-07-25 10:35:43 +02:00
Guillaume (gdi) 24f7849d77 [FIX] website: let default images if the industry is unknown
Since [this commit], when the user configures a new website, he can
set an unknown industry. Unfortunately, if he does so, by default, we
set the industry to abbey, which is not very good for the default images
the user will see and for internal IAP stats. This commit permits to use
the new industry called Unknown, which is used for unidentified
industries. When the industry is unknown, we leave the default theme
images.

[this commit]: https://github.com/odoo/odoo/commit/e82a1cb2ef1bcb413d99e7eb7521405d1d2e88d2

IAP PR: https://github.com/odoo/iap-apps/pull/635

task-3337894

closes odoo/odoo#129154

X-original-commit: 17dd3a84d9d9d42b04fde9aac708c032a472b13b
Signed-off-by: Romain Derie (rde) <rde@odoo.com>
Signed-off-by: Guillaume Dieleman (gdi) <gdi@odoo.com>
2023-07-24 10:14:25 +02:00
Benjamin Vray cc6cf9ef13 [FIX] web_editor, *: fix replacing an image with shape by another media
*: test_website, website

Steps to reproduce the bug:
- Drag and drop a text-image snippet onto the page.
- Add a shape to the image of the snippet by selecting the shape from
the options.
- Click on the "replace" button in the options of the image.
- In the media dialog, navigate to the "icons" tab.
- Choose an icon.
- Inspect the HTML code of the icon in the DOM.
- Bug: The 'data-shape' attribute with a value is still present.

After this commit, when replacing media, the transfer of element
attributes specific to "shape" elements only occurs towards an image and
no longer towards other media (e.g. icons).

We also prevent adding shapes to images that don't support it (e.g. SVG
files). Before this commit, when replacing a .jpeg image that had
a shape with a SVG image, the shape was not removed.

This commit also adds tests to prevent these bugs from reappearing.

task-3420533

closes odoo/odoo#129079

X-original-commit: 023b0b3124a7181fdf486df8c830bb16edd10aa6
Signed-off-by: Soukéina Bojabza (sobo) <sobo@odoo.com>
2023-07-20 10:07:25 +02:00
Pierre Pulinckx (pipu) 8bfa76a842 [REF] *: Unify _t and _lt
The goal of this commit is to prepare ground to remove
lazytranslate function _lt() and keep only _t()
for a better understanding of the use of the translation function.

In this commit,

the translate function _t() has been updated to return the translation
if they are loaded. If not, it throws an error.
the lazytranslate function _lt() returns _t() function.
Corollaries :
Steps in test tours are now a function that returns an array of steps
to avoid any interpolation of _t in this ones before translations has
been loaded.

Example :

registry.category("web_tour.tours").add("example", {
    test: true,
    steps: () => [
        {...},
        {...},
    ],
});

task-3292454

closes odoo/odoo#124157

Related: odoo/enterprise#43153
Signed-off-by: Samuel Degueldre (sad) <sad@odoo.com>
2023-07-19 13:13:16 +02:00
Robin Lejeune (role) ab6564be94 [IMP] website: improve UX of the WebsiteLoader
When the loader takes a long time before having a website ready to be
shown (due to many features selected), it is confusing for users who
think the page stopped working. They tend to refresh the page, provoking
bugs. To improve the UX, this commit adds:

- a browser warning to prevent the user from closing the tab/refreshing
- several waiting sentences, depending on the features chosen by the
user (the screen switches between them every 10 seconds)
- a loading bar whose progression shows the number of installed modules
- a solid background instead of a transparent one as there is no value
in seeing the preceding background at that point

This commit also removes the secondary loader, once the website has been
created, to avoid the bad UX of having one long loading, then a refresh,
then another loading with the same look.

task-3100223

closes odoo/odoo#118525

Signed-off-by: Soukéina Bojabza (sobo) <sobo@odoo.com>
2023-07-19 13:13:02 +02:00
Benoit Socias 567e5b58d5 [IMP] base, tools, web_editor, *: use original image if size increases
*: web_tour, website

When no transformation is applied on an image, changing the quality
sometimes increases its storage size.

This commit makes sure that the original image remains used if only the
image quality is modified and if this makes its storage size bigger.

Fixes #61619
task-2835144

closes odoo/odoo#103398

Signed-off-by: Romain Derie (rde) <rde@odoo.com>
2023-07-19 13:12:51 +02:00
Nicolas Bayet d7245d2abf [REF] web_editor,*: convert wysiwyg to owl
The goal of this commit is to remove all dependency to legacy in the
wysiwyg because the wysiwyg has to be loaded on a lot of form view
(through the html_field).

To remove the dependencies, all the legacy widget that the wysiwyg
uses had to be converted to owl. In order to finish the PR faster,
only a partial conversion of the widgets is done, changing only the
part of the code that was necessary for it to work instead of
rewriting the whole widget from scratch. Another pass should be done
to convert all those widgets to fully embrace the owl paradigm.

task-3175256

Part-of: odoo/odoo#118966
2023-07-19 11:39:44 +02:00
Nicolas Bayet a2dab27700 [REF] web_editor,*: move media_dialog_wrapper to its own file
For organisation purpose, move the media_dialog_wrapper to its own file.

task-3175256

Part-of: odoo/odoo#118966
2023-07-19 11:39:44 +02:00
Romain Derie 8692250d2a [IMP] website, website_mass_mailing: make btn-primary close popup
Before this commit, only the cross icon "x" top right of the popup would
be able to properly close the popup and set a cookie to prevent that
popup to open again later.

There is no way through the UI to make a button in the popup do the same
behavior.

This commit now add this behavior to any `.btn-primary` element inside
the popup, except a few ones like the newsletter input group button and
the website form submit one.

Note that we have a way in stable to do that, but it's through code.
People have to add the `js_close_popup` class to the button. This class
is there for this reason, but it's obviously limited to tech people
only or our support.

task-3377306
opw-3328135

closes odoo/odoo#124432

Signed-off-by: Arthur Detroux (ard) <ard@odoo.com>
2023-07-19 10:23:56 +02:00
David Monjoie 17ee75a84d [IMP] web_editor: use o_editable and o_not_editable as markers
Before this commit, the o_not_editable class was used as a way to
dynamically set contentEditable on a node. This was little more
than  a convulated way to write `node.contentEditable = false`.
Moreover, the o_editable class was not treated the same way and
did not set contentEditable to true.

This commit turns those two classes into markers for contentEditable
values in html. Once those classes are set, the contentEditable
attribute is updated accordingly. It is not updated dynamically
afterwards. For dynamically setting a node as editable or not, use
the contentEditable attribute directly.

Task-2782426

Part-of: odoo/odoo#120690
2023-07-18 19:27:53 +02:00
Benoit Socias d5703d8d33 [IMP] website: test the images wall snippet
This commit separates the test that was added together with the "not
move images twice within image wall" fix because it requires additional
fixes for working in 16.0.

task-2990053

closes odoo/odoo#125758

X-original-commit: f4e8ca1eca1193a72a0b1d21cbc4af5093907ca9
Signed-off-by: Arthur Detroux (ard) <ard@odoo.com>
2023-07-18 16:58:57 +02:00
Benoit Socias 3e8a690d10 [FIX] website, *: wait images when setting masonry images wall layout
*: web_editor

During the masonry layout calculation of the images wall snippet, the
image height is used to determine into which column each image is
inserted. Their height is zero until they are actually loaded. Because
of this, the column into which an image is inserted can be wrong.

This becomes more obvious in 16.0 because since [1] the image selection
is lost when moving it within an Image Wall because it is replaced by a
clone when using masonry mode.

This commit makes sure that the images are loaded before taking their
height into account when building the masonry layout.

This involves two changes:

1. By awaiting `wUtils.onceAllImagesLoaded(this.$target)` after the
insertion of each cloned image, we are sure that the reached height of
each column is available before deciding where to insert the next image.

2. Before re-selecting the previously selected image, we need to be
sure that it is loaded. Therefore we keep track of the last masonry
layout operation and await for it. This way, we rely on the await of
the last image as described in point 1.

Additionally, as of 16.0, there is a race condition with
`snippet_option_update`: in some situations, `notify` is called before
`snippet_option_update` is completed, and before the masonry layout is
applied.  To make sure it is completed, the whole notify is run within
the mutex through a `snippet_edition_request` event.

To uphold the stable policy, making `mode` async will only be done in
master.
In stable, a new `_modeWithImageWait` is added which is called only
for the situations that causing an issue, and which enables the fix
of the masonry layout.
In 14.0, it is used when computing the layout from `start` and
`addImages`.
In 16.0, it is also used in `notify` when images are removed or moved
around - because masonry clones the images.
In master, it is always applied.

Steps to reproduce:
- Drop an Images Wall.
- Add four images, the first one being taller than the others.

=> The fourth image sometimes appeared below the tall image.

[1]: https://github.com/odoo/odoo/commit/0d43aec24baad6420e0fe150a9c19d33c0b74198

task-2990053

X-original-commit: 9605d9ba7b26885d66e861e0e5c7dff7489031f9
Part-of: odoo/odoo#125758
2023-07-18 16:58:56 +02:00
Benoit Socias c1c20dcd08 [FIX] website, web_editor: not move images twice within image wall
Since [1] the "Images Add/Remove All" buttons are on top of the
background options in order to appear as the first option for the
"Image Wall" snippet.
This makes the JS related to the handling of the options of that
snippet created twice: once for the buttons above and once for the
options below.
Because of this, events are registered by both instances and they both
get notified on option update. Therefore, when an image is moved, it is
moved twice instead of once.

This commit differentiates both instances, and makes the one that
handles the "Add" and "Remove All" buttons be the only one that works on
the images.
In stable the differentiation is done with conditional statements.
In master the instances should be of distinct classes.

Steps to reproduce:
- Drop an "Images Wall" block.
- Switch the "Mode" option to "Grid" instead of "Masonry".
- Select the wine glass image in the third column.
- Click on "Move to previous".

=> The wine glass image ended up in the first column because it was
moved twice.

This commit also fixes a typo in the `reoder_items` name introduced
by [2].

[1]: https://github.com/odoo/odoo/commit/b6494fcf284edcddaa36b5fcfd407a6d7186fbd7
[2]: https://github.com/odoo/odoo/commit/e8713dc078b5c1799917f238a4c32b4289aceb8a

task-2990053

X-original-commit: f8724b55162b2550734dbe6e0454c406d6e4241c
Part-of: odoo/odoo#125758
2023-07-18 16:58:56 +02:00
Benoit Socias 4053ff4caa [FIX] website: neutralize sub-pixel height difference in images wall
Inside the Images Wall snippet, images are dispatched to columns
depending on the height already reached by each column. This computation
relies on a sub-pixel height which leads to a confusing behavior.

This commit rounds the sub-pixel height to a visible pixel height to
avoid the confusion.

Steps to reproduce:
In the default images of the Images Wall snippet, the third image (sign)
is one pixel taller than the other ones.
- Drop an Images Wall snippet.
- Select the "sign" image.
- Move it to the first position.
(Because of another bug involving a race condition with the loading of
images, you might observe a different behavior. Move to first position
again to recompute the layout several times.)

=> The compass image moved to the first column.

task-2990053

X-original-commit: d0c15abd17e151a8861cc950116b11111d694bb3
Part-of: odoo/odoo#125758
2023-07-18 16:58:56 +02:00
Benjamin Vray 8423c0dd90 [FIX] web_editor, website: fix image link option broken
Since this commit [1], when clicking on an image that is not a link and
then clicking on an image that is a link, the first image that is not a
link becomes a link.

This issue occurred because we were triggering
'activate_image_link_tool' in 'toggleLinkTools' before the options for
the selected image were ready. As a result, 'activate_image_link_tool'
was being triggered on the previous image (the one that is not a link),
causing it to become a link.

To fix this, we now only trigger 'activate_image_link_tool' if the URL
input needs to be focused (e.g., when clicking on the "edit link" button
in the image popover).

Steps to reproduce the bug:
- Drag and drop a "Columns" Snippet onto the page.
- Click on the image of the first column.
- Click on the button to create a link in the options of the image.
- Type "/" in the url input.
- Click on the image of the second column.
- Click on the image of the first column.
- Click on the image of the second column.
- Bug: a link is added on the image of the second column.

This commit also modifies the "link_tools" test to avoid this bug
reappears.

[1]: https://github.com/odoo/odoo/commit/11ee7d5520c3a14a381b3f5b973114670f1e2edb

task-3422238

closes odoo/odoo#128806

X-original-commit: fef32aa339177a2ca008ab988cb0ac0a670c110c
Signed-off-by: Benoit Socias (bso) <bso@odoo.com>
2023-07-18 10:20:05 +02:00
Arthur Detroux (ard) 4da1e0e0f0 [REF] website: update the dashboard widget to OWL
This commit converts the Website Dashboard to OWL.
The main goal of the Website Dashboard is to display the Plausible
Dashboard inside an iframe. Most of the code from the legacy widget was
actually used by website_sale and not website. Since Website Sale
dashboard is to be re-done in the dashboard app (by task-3222991), a lot
of the logic could be removed and simplified.

task-3164163

closes odoo/odoo#112819

Related: odoo/enterprise#44087
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2023-07-17 12:05:58 +02:00
Arthur Detroux (ard) caa5ee0e0b [MOV] website: move the dashboard template for future OWL conversion
Prepare for OWL conversion while keeping the template's history, as
some of its code can be re-used in the new OWL Component.

task-3164163

Part-of: odoo/odoo#112819
2023-07-17 12:05:57 +02:00
Benoit Socias 8a20ae9b4a [IMP] web_editor: make all headings color only inherit from main heading
Colors of headings are inherited between levels. (E.g. if no color is
defined for `<h4>`, it uses the color of `<h3>`)

This commit changes it so that all levels only inherit from `<h1>`.

task-3140991

closes odoo/odoo#111621

Related: odoo/design-themes#633
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2023-07-17 10:40:33 +02:00
Benoit Socias c2a7e58585 [IMP] website: add a way to revert to the default font
Before this commit, when a heading font was selected, it was not
possible to deselect it (so that the H1 font gets applied again).

After this commit, the font selector has an extra "Reset" button to
restore the default state if it has a specified value.

task-3140991

Part-of: odoo/odoo#111621
2023-07-17 10:40:32 +02:00
Benoit Socias e55c126770 [REF] website: customize several website variables in one rpc
Before this commit, customizing the theme option's background image or a
theme option's button style required several RPCs and refreshes of the
assets bundle.

After this commit those options are updated through a single RPC call
and a single refresh of the assets bundle.

task-3140991

Part-of: odoo/odoo#111621
2023-07-17 10:40:32 +02:00
Benoit Socias 388e4bb2bf [IMP] website, web_editor: relayout theme options
This commit reorganizes the theme options to make them easier to find.
It also adds the following options:
- 'Font size' for each of the six headings
- 'Font (family)' for each of the six headings
- 'Margins' (top & bottom) for paragraph & the 6 headings
- 'Line Height' for paragraph & the 6 headings
- Harmonize buttons options with the custom button ones

task-3140991

Part-of: odoo/odoo#111621
2023-07-17 10:40:31 +02:00
Benjamin Vray d96aa1784f [FIX] website: fix anchor selector not updating
Steps to reproduce the bugs:

- Add a banner on the homepage
- Click on the "create a link to target this section" button.
- Edit the anchor name to "bannerAnchor".
- Drop the image-text snippet.
- Double click on the button inside the snippet.
- Choose the homepage as the URL ("/")
- Open the "Page Anchor" select, choose "#bannerAnchor"
- Validate the changes.
- Double Click on the snippet button again.
- First bug: The URL properly shows "/#bannerAnchor" but the page anchor
select does not show anything.
- Open the page anchor select again.
- Second Bug: the "bannerAnchor" option does not appear as a choice.

This commit fixes the two bugs described above.

task-3378864

closes odoo/odoo#128345

X-original-commit: 62ed601bcf53fd6572118e742a5e27f7f3c7b6f6
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
Signed-off-by: Benjamin Vray (bvr) <bvr@odoo.com>
2023-07-13 10:46:16 +02:00
Romain Derie aca9a4e9da [FIX] website: hide optimize seo menu when model is not seo capable
When user creates a new 'livechat channel' in website, and click on
'Optimize SEO' a traceback will appear.

Step to reproduce:
- Install 'website' and 'im_livechat' module
- Go to 'website' module
- Click on 'NEW' and then create a new 'Livechat Widget'
- Go to 'Site' and click on 'Optimize SEO'

Error: A traceback appears: Invalid field 'website_meta_title' on model
'im_livechat.channel'

The menu should not be shown for such model which do not inherit the
SEO mixin. This commit ensures that.

sentry-4241511888

closes odoo/odoo#128187

X-original-commit: b2bcf950bd62872fe5dc9455636256d9213b58dc
Signed-off-by: Colin Louis (loco) <loco@odoo.com>
Signed-off-by: Romain Derie (rde) <rde@odoo.com>
2023-07-13 00:46:05 +02:00
Julien (jula) cf187ab43e [FIX] website_form: prevent crashing while parsing python dict in JS
__Description of the issue:__
- The `replace` method in JS only replace the first occurrence of a
string (unless `g` flag is used in the regex)
- There could be an apostrophe (`‘`) in a string value which would be
replaced by a quote (`“`)
- There could be “None”, “False” in a string value which would be
replaced too
- “True” is not taken into account

__Description of the fix:__
Those regex are meant to deal with more edge cases when transforming a
python dict to a JSON in JS. However there are still ways it could go
wrong. For the forward port in master, it could be a good idea to
consider converting dictionnaries directly in the backend using the
`json` python library.

__Steps to reproduce the issue:__
1. Edit the view `website.contactus`
(If `website_crm` is installed, either uninstall it or disable the
`website_crm.contactus_form` view)
2. At line 5, change the attribute `t-att-data-values` to a more
complicated dict like:
```
"{'email_to': res_company.email, 'name': 'Alice True', 'age': None, 'active': True, 'attr1': None , 'attr2': False , 'attr3': 'let\'s go'}"
```
3. Go to `/contactus` on the website
↳ Traceback

opw-3328690
task-3340946

closes odoo/odoo#128127

X-original-commit: 5360e10dcd89bdbae6d01a0f6597571c8592301f
Signed-off-by: Romain Derie (rde) <rde@odoo.com>
2023-07-12 13:58:06 +02:00
Benjamin Vray 529fdea32c [FIX] website: fix image gallery arrows hidden after click
Steps to reproduce the bug:

- Drag and drop an Image Gallery Snippet onto the page.
- Add an image in the Gallery.
- Click on the "right" arrows.
- The arrow is gone.

A bug similar to this one had already been fixed by the commit [1] that
added the "o_not_editable" class to the "carousel-control" elements of
the "s_image_gallery" snippet. However, it was also necessary to make
this change in the QWeb template used when the slideshow is regenerated
upon adding an image.

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

task-3414584

closes odoo/odoo#128133

X-original-commit: 0983553f4df2b027290082c03142db4bfb5f288c
Signed-off-by: Colin Louis (loco) <loco@odoo.com>
Signed-off-by: Benjamin Vray (bvr) <bvr@odoo.com>
2023-07-12 11:19:55 +02:00
divy-odoo f88e827126 [IMP] web_editor: open internal link in edit mode
Before this commit, when the user was clicking on a link to another page
of the website, it was opening in another tab but in frontend mode.
However, in most cases the user actually wanted it to open in backend
mode.

Here is an example of users who started an eCommerce trial. They are
editing their homepage and want to create a product. They open the
"/shop" page using popover but because they are in the frontend, they
don't see the "+NEW" button. This behaviour seems a little odd.

Therefore, this commit aims to open internal links in the edit(backend)
mode instead of the frontend mode.

task-3177126

closes odoo/odoo#128114

X-original-commit: f7dacce18bf44914972da292ff041505289d1e16
Signed-off-by: Divyesh Vyas (divy) <divy@odoo.com>
Signed-off-by: Romain Derie (rde) <rde@odoo.com>
2023-07-12 07:40:29 +02:00
Benoit Socias bbd1a48083 [FIX] web_editor, website: use theme colors on shapes in options panel
Since the edited website pages are inside an iframe, the options panel
cannot base its display on the CSS rules of the page. When changing the
theme colors, only the edited page's CSS is reloaded, not the option
one. Because of this, the background shapes are displayed using an
obsolete color palette inside the options panel.
This causes colors to be forced on background shapes within the iframe
because their default colors do not match the ones inside the options
panel when different theme colors are set. Once forced, the colors of
the background shapes within the content do not follow the theme
palette changes anymore.

This commit forces the background shapes displayed in the options panel
to use the current palette.
This is done by recovering the current edited page's shape background
images from the CSS rules. This approach was chosen as opposed to
adding a `d-none` version of the shape `div` to the edited page and
getting the background image from its computed style.
This fixes the color comparison between the background shapes of the
content and the ones of the options panel, thus not forcing colors if
the theme colors are used.

Steps to reproduce:
- Edit a website page.
- Drop a "Banner" block.
- Enable background shapes.
- Go to the theme tab.
- Select a different theme color palette.
- Select the "Banner" block.
- Open the "Shape" option's menu.

=> The shapes were displayed with the old color palette and if selected
were applied with the old color palette.

Additionally, to avoid a race condition when leaving a theme color
picker by either clicking on the BLOCKS tab or re-selecting the
snippet with a shape, a re-rendering of the existing snippet editors
is requested and the shape cache is invalidated if the palette has
changed in the meantime.

task-3370939

closes odoo/odoo#127951

X-original-commit: c511e100cad2febc0ebb9ce61b5eb52232e60f7d
Signed-off-by: Soukéina Bojabza (sobo) <sobo@odoo.com>
2023-07-12 07:39:51 +02:00
Guillaume (gdi) 39b4d16f10 [FIX] website: format price according to client locale
Since [this commit], we have a range input to select a price filter for
products. This input displays a min and max price that the visitor can
select. The problem is that the price is not formatted according to the
visitor locale. This commit fixes this issue.

Steps to reproduce the bug:
- With English as language, go to the shop page
- Go to Customize and activate filter by price
- Install French on the website
- Visit /shop in French

=> The price is not formatted according to the French locale. For
example, we can see a price of a thousand euros displayed as 1,000.00
but in French, it should be displayed as 1 000,00.

[this commit]: https://github.com/odoo/odoo/commit/41f7c7bc6428050d4c7956edca26b7c1bd2d8e04

task-3414455

closes odoo/odoo#127881

X-original-commit: 683b7edf0ce1f098757aa1e38ee6dc5d4e255272
Signed-off-by: Louis Wicket (wil) <wil@odoo.com>
Signed-off-by: Guillaume Dieleman (gdi) <gdi@odoo.com>
Signed-off-by: Romain Derie (rde) <rde@odoo.com>
2023-07-12 07:39:48 +02:00