Commit Graph
200 Commits
Author SHA1 Message Date
Renaud Thiry 8d99f2f415 [MOV] test_website, web_editor: move test to right module
Some web_editor test was in "test_website" when it could
have simply been in web_editor.

It is moved there and modified to reuse existing imports and pass standard
web linting rules.

task-3741858

closes odoo/odoo#155704

Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2024-03-29 09:12:17 +00:00
Serge Bayet (seba)andRodolpho Lima 6d2daa0013 [FIX] web_editor: address zero-width-space bug in link inner content
This commit resolves a bug related to zero-width spaces within the inner
content of a link. The bug led to a systematic test failure in 17.0
link_tools when comparing the input value with the expected value.
The bug originated from [1] that manipulates zero-width spaces to allow
users to select the edges of the link.

Steps to reproduce:
- Navigate to the Project app and open a random task (create one if none
  exists).
- Select the "Description" tab.
- Enter "/link" and press "Enter" to activate the link tools dialog box.
- In the link label field, input "The Website".
- In the URL or email field, input "localhost:8069".
- Save the changes.
- A new div is generated with the class "note-editable".
- Click on the newly created link.
- Edit the link by clicking on the edit icon in the popover.
- Direct the focus to the link label field at the end of the string "The
  Website".
- Press the "Backspace" key — observe that nothing happens.

This fix is actually a complement to [2].
The test added in [3] eliminates zero-width-spaces prior to asserting
the equality of values. This was appropriately addresses and handled in
this commit.

In version 16.2 [4], they refactored and improved the handling of
zero-width spaces (ZWS). As a result, ZWS in the link are now escaped
when the selection is made, eliminating the need to filter out these
empty characters. So, I added two assertions that provide more
comprehensive test coverage. The previous test only accounted for one
way to open the LinkDialog: selecting a part of the link and clicking on
the toolbox icon. Another method is to simply click on the link. In this
case, a popover appears, allowing link editing via the edit-link icon.
In the latter case, the test fails without the fix.

In version 16.4, the link component was migrated to OWL. So the bug
isn't there anymore. The new test is kept. Note that after this commit's
merge in 16.4, it was patched with [5]. This forward-ported version
includes the patch directly.

[1]: https://github.com/odoo/odoo/commit/99bc9b115dbdfc29260b4ccdb55ffa2ed16dffb3
[2]: https://github.com/odoo/odoo/commit/71feab51f41f0658f4ad61f99386c9c6978c6025
[3]: https://github.com/odoo/odoo/commit/a56586119845969e9d867a220f5330a6c7daa5c2
[4]: https://github.com/odoo/odoo/commit/89b0ce0c74458342fea5e1b093e9383f82e2440f
[5]: https://github.com/odoo/odoo/pull/154644

runbot-44779

closes odoo/odoo#154474

X-original-commit: 9db065e75d7b31febe4a42138308b47d0fa46508
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
Co-authored-by: Rodolpho Lima <rcdl@odoo.com>
2024-02-20 16:35:35 +00:00
dhba 4739433d09 [FIX] web_editor: issue with ctrl+a when banner is first element
Before this commit:

- When a banner was inserted at the first line and Ctrl+A and backspace
  is performed, nothing happens.

After this commit:

- Now, all the content except banner will be selected and removed.

task-3432167

closes odoo/odoo#151735

X-original-commit: 530f102720458e5e1c224bf38073cd763309bf0a
Signed-off-by: Antoine Guenet (age) <age@odoo.com>
2024-02-05 08:34:50 +00:00
dhba e93fa23c29 [FIX] web_editor: should preserve first element inside banner.
Before this commit:

- Performing ctrl+a and backspace inside a banner would unintentionally remove
  its first element, which could be a block tag

After this commit:

- Now performing ctrl+a and backspace inside the banner will no longer remove its
  first element if it's a block tag.

task-3432167

X-original-commit: ddc8587f8a712fdddaa714bee2931cb149c03a38
Part-of: odoo/odoo#151735
2024-02-05 08:34:50 +00:00
dhba f50378db3c [FIX] web_editor: focus issue in banner
Before this commit:

- Inserting a banner did not set focus inside the banner; instead, focus
  was placed after the banner.

After this commit:

- Now, upon creating a banner, focus is now correctly set inside the
  banner.

task-3432167

X-original-commit: 7327d20626ec9164f47e00f7094a36b8794db5de
Part-of: odoo/odoo#151735
2024-02-05 08:34:50 +00:00
dhba-odoo 1a595779a4 [FIX] web_editor: unable navigate to next line of banner
Before this commit:

- Inserting a banner after already existing content it's impossible to
  go to the next line of the banner.

After this commit:

- It's now possible to navigate to the next line of the banner.

task-3432167

X-original-commit: 05a879f81ac59d47b718abbb5966fd4f8214e1de
Part-of: odoo/odoo#151735
2024-02-05 08:34:50 +00:00
Aaron Bohy 82fd8e7025 [FIX] web: make urgentSave more robust
In form views, when the user closes the tab while having unsaved
changes, and if those changes are valid, we want to save them
automatically before leaving.

Before this commit, there could be situations where the changes
weren't actually saved. For instance, if they involved an heavy
payload for the write rpc, or if the network connection was poor,
it might happen that the xhr is killed. Or at least, browsers do
not offer any guarantee to wait for those xhr to reach the server.

Instead of a classical xhr, we thus use navigator.sendBeacon which
ensures that the data will be sent reliably [1]. There's a drawback
though, as its payload is limited. When the payload is too heavy,
sendBeacon simply returns false and does nothing. In this case,
we prevent the page from unloading and display a notification
suggesting the user to manually save his changes before leaving.

[1] https://developer.mozilla.org/en-US/docs/Web/API/Navigator/sendBeacon

Task 3537838

closes odoo/odoo#151834

X-original-commit: 0b53daa60ee5b370def21c8e0e30a6819597a0e4
Related: odoo/enterprise#55457
Signed-off-by: Francois Georis (fge) <fge@odoo.com>
2024-02-02 09:18:42 +00:00
Mahdi Cheikh Rouhou (macr) 4838909bce [FIX] web_editor: discard changes html field
Issue:
======
Discard changes of form having html field doesn't remove the changes
applied in the html field.

Steps to reproduce the issue:
=============================
- Open any mail template
- Add modification on the template
- Click on discard changes

Origin of the issue:
====================
The function `this.props.update` is responsible of updating `_changes`
and updating the record which is called for usual input_field using
`useInputField` hook, but since this html field isn't of the same format
we didn't use it and it's only called in `commitChanges`

Solution:
=========
We update the value of in `_onWysiwygBlur` in case we are `inlineStyle`
so we don't commit but we save the changes for the discard to work
properly.

task-3453497

closes odoo/odoo#151993

X-original-commit: 1624da6f42561792be816836c6d88bc986c3538a
Signed-off-by: Antoine Guenet (age) <age@odoo.com>
Signed-off-by: Mahdi Cheikh Rouhou (macr) <macr@odoo.com>
2024-02-01 11:20:08 +00:00
Nicolas Bayet 119fa9f974 [FIX] web_editor: fix isDirty check on html fields
The method `getValue` of the wysiwyg could have some cleaning on the
value that will always make it different from the original value.
The _isDirty method of the html field will now make the original value
be processed by the wysiwyg `getValue` to be able to compare it
with the current value.

The sanizite call in `OdooEditor.cleanForSave` had the wrong root. As
we are calling `cleanForSave` for an element that is not inside the
editable, the root cannot be `this.editable`.

task-3679122

closes odoo/odoo#148996

Signed-off-by: Antoine Guenet (age) <age@odoo.com>
2024-01-22 19:01:00 +00:00
Rodolpho Lima 1dc42bc66f [FIX] web_editor: link preview on label change
Before this commit, the link preview in the Link Dialog would not be
updated after changes on the label input field, depending on other
actions to be updated (e.g. picking a different type of link/button or
changing the URL input field).

This commit makes sure the link preview reacts to changes on the label
input field.

task-3580621

closes odoo/odoo#148202

X-original-commit: c7954225e8680821a46c9628e5e05df2ae575da7
Signed-off-by: Nicolas Bayet (nby) <nby@odoo.com>
Signed-off-by: Rodolpho Cammarosano de Lima (rcdl) <rcdl@odoo.com>
2024-01-05 15:14:35 +00:00
Rodolpho Lima df18b57e53 [FIX] web_editor: embed video on paste URL
Before this commit, pasting a URL as plain text followed by picking
"Embed Youtube Video" in the command bar failed to embed the video,
inserting the following text instead: "[object Promise]".

This happened because [1], which is the result of a forward-port, failed
to `await` the call to getYoutubeVideoElement, which is an async
function since version 15.2.

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

task-3611566

closes odoo/odoo#146653

X-original-commit: 4891359210e2f921dbfb6d7c870ec5cf1b60d3f5
Signed-off-by: Nicolas Bayet (nby) <nby@odoo.com>
2023-12-19 09:36:54 +00:00
shsa-odoo 836151f38c [FIX] web_editor: add and update link test cases
Before this commit:

No test cases were there for dialog box based link creation.

After thi commit:

Added Qunit test cases for various scenarios

Cases Covered:

* Making links with hotkeys.
* Typing valid url + space should make link.
* Making link with powerbox.
* Selecting text and link button on the toolbar.

task-3087957

closes odoo/odoo#144120

Signed-off-by: Nicolas Bayet (nby) <nby@odoo.com>
2023-11-30 14:48:12 +00:00
Nicolas Bayet 6f599655e4 [FIX] web_editor: prevent the avatar to be loaded
In some undeterministic circumstances the tests in
`test_wysiwyg_collaboration.js` tried to load an image with a wrong
url (`/web/image?model=res.users&field=avatar_128&id=undefined`). It
is `undefined` because in the testing context, `this.getSession().uid`
is `undefined`.
It is not necessary to load these images in these tests so this commit
prevents the loading of these images.

runbot-24600
task-3566600

closes odoo/odoo#139958

Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
Signed-off-by: Nicolas Bayet (nby) <nby@odoo.com>
2023-11-14 13:49:18 +00:00
Antoine Guenet 8f1d33ac42 [FIX] web_editor: wait for selectionchange on set test selection
The selectionchange event is triggered one tick after the selection
changes so we need to wait for it to be triggered before moving forward
with testing.

Doing this implied correcting a test: as we were not waiting for the
selectionchange event, we were not taking advantage of some corrections
applied there.

Part-of: odoo/odoo#141303
2023-11-07 21:02:24 +00:00
Lucas Perais af970abf89 [FIX] web_editor: QWebPlugin select parent of a qweb field
Follows commit: ffef01e327.
It caused an issue in Firefox:
On the sale order form view (with the field "notes" handled by the OdooEditor),
clicking on a Many2one made the browser crash because the method getSelection
did not exist on the target which was the input element.

It did not crash in chrome as the event's target was always the Document.

The added test actually tests the feature of the referenced commit, and checks, as much
as possible, that there is no crash.

closes odoo/odoo#140143

Signed-off-by: Lucas Perais (lpe) <lpe@odoo.com>
2023-10-30 09:01:01 +00:00
Adrien Dieudonné e6c747b43b [REF] *: keyboard: replace deprecated charCode, keyCode and which properties
These properties are deprecated.

We should consider to use `KeyboardEvent.key` or `KeyboardEvent.code` for new code.
Note that we prefer to use the `key` property as multiple physical keys
can send the same value (e.g. Enter can also be sent by the numeric pad).
We should only use `code` when we explicitly want to target a single physical
key on the keyboard.

By doing this, we can now remove the dependency of `jQuery.ui.keyCode`
that was used as mapping of key code descriptions to their numeric values.

References:
https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/charCode (deprecated)
https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/keyCode (deprecated)
https://developer.mozilla.org/en-US/docs/Web/API/UIEvent/which (deprecated)

https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/code
https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key

https://api.jqueryui.com/1.12/jQuery.ui.keyCode/

Some links that helps:
https://w3c.github.io/uievents/tools/key-event-viewer.html
https://www.toptal.com/developers/keycode/table

closes odoo/odoo#139809

Related: odoo/enterprise#49591
Signed-off-by: Pierre Paridans (app) <app@odoo.com>
2023-10-26 08:46:00 +00:00
abd-msyukyu-odoo 2994c7589f [FIX] web_editor: don't set the sync as finished on error
When `_resetFromClient` returns an error, `_historySyncFinished` should not be
set to true since the history was not updated from the requested snapshot.

Also await the result of `get_client_avatar` and `get_client_name` during
`rtc_data_channel_open` so that no error is produced during tests after calling
`removePeers` without properly awaiting those promises.

Export collaborative test utils for usage in Knowledge.

task-3551505

closes odoo/odoo#139040

X-original-commit: fb389213078e96c97b7187248dfdf79ad331db9f
Related: odoo/enterprise#49170
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
Signed-off-by: Damien Abeloos (abd) <abd@odoo.com>
2023-10-20 14:59:21 +00:00
Nicolas Bayet ce36c49680 [FIX] web_editor: reconnect peers after when reconnecting internet
Prior to this commit, when the user experienced an internet
disconnection, after few seconds the PeerToPeer connection state would
change to "closed" and the PeerToPeer connection would be removed
permanently. Consequently, when the user reestablished their internet
connection, the peers would remain disconnected to each other.

With this commit, peers are now re-connecting to each other.

task-3488166

closes odoo/odoo#138510

X-original-commit: b9d96629df5adf37f362eb63107fa5a9a6cd3e0d
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2023-10-16 10:39:57 +00:00
Michael (mcm) e062e6f483 [IMP] web,*: remove legacy env
This commit removes all the legacy envs (common_env, env, public_env)
as well as the files used to set up them.

task 3439226

closes odoo/odoo#138348

Related: odoo/enterprise#48781
Signed-off-by: Mathieu Duckerts-Antoine (dam) <dam@odoo.com>
2023-10-13 09:17:45 +00:00
abd-msyukyu-odoo 5a2ee50798 [FIX] web_editor: change oe-id when switching record
Add a test to ensure that the `MediaDialog` is opened with the correct record
`resId` (to properly link files to that record) inside an html field.

task-3502797

closes odoo/odoo#138525

X-original-commit: 5184bed2efd9923c0371d5e117a7915415ceee5a
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2023-10-12 17:20:46 +00:00
Rodolpho Lima c74d01279e [IMP] web_editor: add document parameter to parseHTML
This commit changes the public `parseHTML` utility function's signature,
in order to allow the use of the editor's document to create a document
fragment.

This aims to avoid mismatches in the prototype chain of HTML elements
created by such util and the ones present in the editable when the
editor is mounted in an iframe. This is of particular relevance for the
'insert' command, in which the node to be inserted is tested for
`instanceof` the editor's document global `Node` object.

task-3526134

closes odoo/odoo#136984

Related: odoo/enterprise#48108
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2023-10-02 08:03:44 +00:00
Nicolas Bayet 2d05f703d7 [FIX] web_editor: strengthen collab stale detection & recovery
Before this commit, the stale document detection was imprecise and
incomplete.

The stale document could happen in different scenario:
1)  Client B save when client A is disconnected (therefore client A
    should be notified that the document is stale upon reconnection):

    - For that scenario, the code had a heuristic to detect if the
    internet connection disconnected and reconnected but was imprecise
    as the browser api is not 100% reliable on all browser and
    platforms. That made the code under-checking or over-checking with
    the server.

2)  The user has not yet focused on the element and before this
    commit, the stale document was not detected.

3) If there is a partition in the peer to peer network and a member of
   another partition that save, all other partition will not be aware
   that they are working on a stale document.

4) The stale document happen before 2 peers could be fully connected.

For any of those scenarios, if a stale document was not detected and
the user tried to save changes, only then, a popup would inform that
the version was stale. And if the user closed the tab thinking the
document would automatically save, the change would not be saved
(without warning).

This commit:
1) improve detection of stale document
To detect the document this commit add a message in the odoo bus.bus
for the channel of the record for each write. That will ensure the
message to be received as soon as a user is connected to odoo.

2) improve recovery from stale document
Before this commit, the recovery was only made from the server.

As a detection is now direct (rather than delayed by the previous
heuristic), a document could be detected stale before receiving a step
that would not make it stale. Therefore, we cannot just reset from the
server as a recovery mechanism.

To recover, this commit first tries to reset from missing steps from
all peers. If unsuccessful, it will tries to reset from a snapshot. If
unsuccessful, it will reset from the server.

3) add a mechanism for aborting requests
To prevent unexpected concurrency behavior, this commit add a mechanism
to abort requests.

4) a framework for testing the collaboration of the wysiwyg
As it could be quite tedious and error prone to manually tests
concurrency issues related to the wysiwyg, this commit add a framework
for testing the collaboration of the wysiwyg and test the detection
and recovery of stale document.

task-3217965

Part-of: odoo/odoo#136277
2023-09-27 14:57:13 +00:00
Rodolpho Lima 26f447a072 [FIX] web_editor: missing record info for converted images
When the Wysiwyg is used by website, multiple editable elements are
possible, and each of them carry the related record's model and id in
the element's dataset.

On the other hand, when the Wysiwyg is used by the html field, there's
only one root editable element, and such information is not present in
the editable's dataset, but in the widget's options object.

Before this commit, when saving the content of an html field, modified
images were converted to attachments without the correct reference to
the record's model and id.

This commit makes sure that such information is passed to the route that
handles attachment creation.

task-3495668

closes odoo/odoo#135806

Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
Signed-off-by: Antoine Guenet (age) <age@odoo.com>
2023-09-18 23:31:39 +00:00
Rodolpho Lima 00701977ad [FIX] web_editor: skipped image conversion to attachment in HtmlField
Commit [1] added a check for the closest ".o_dirty" editable element in
order to define which editable is used for obtaining the model and id
reference from its dataset, and also to avoid multiple attachment
creation for the same image.

But such check for the closest ".o-dirty" element evaluates to null when
the Wysiwyg is used by the HtmlField component, as such class is not
added to editable when saving/committing changes. This resulted in
skipping the attachment creation for pasted, dropped or modified images.

After this commit, attachment creation for modified images is not
skipped if an element with the ".o_dirty" class does not exist.

task-3495668

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

Part-of: odoo/odoo#135806
2023-09-18 23:31:39 +00:00
Louis (loco) f34540c535 [FIX] web_editor: save an image with the correct parameters
Steps to reproduce the problem:
- Go on the "Courses" application and select a course.
- Edit.
- Replace the main image of the course with one of your own.
- Save.

-> The function route `/web_editor/modify_image/` is called two times
leading to the creation of two attachments instead of one.

The `savePendingImages()` function iterates through editable elements
and calls `/web_editor/modify_image/` (through `_saveModifiedImage()`)
for each image with a `o_modified_image_to_save` class inside those
elements. In our case, the image has an editable element parent that has
itself an editable element parent. Because since [1], the
`o_modified_image_to_save` class is removed after the `rpc` call, this
class is not removed while the `savePendingImages()` loops on the
second editable element parent of the image. As a result,
`/web_editor/modify_image/` is called two times. Note that before [1],
the process was partially wrong as well. `/web_editor/modify_image/` was
indeed called only once but with the wrong arguments. This is now fixed
by ensuring that `_saveModifiedImage()` is called with the arguments
coming from the closest editable element. The same logic is applied for
the call of the `_saveB64Image()` function.

[1]: https://github.com/odoo/odoo/commit/8872aab2d108ff3e2ec06ca4579479898c87738c

task-3451349

closes odoo/odoo#134189

X-original-commit: 8ff0151cf06c37e8ee2e344bc96c063b4921ce43
Signed-off-by: Robin Lejeune (role) <role@odoo.com>
2023-09-05 12:22:20 +00:00
Jorge Pinna Puissant ebd538a194 [IMP] web, *: optimize save record from webclient
This commit, adds a new python method (`web_save`) to save a record, and
optionally read-it again in one rpc call. This optimizes the current
behavior that is to save a record in one rpc, and read-it in a second
rpc.

web_save, will receive the list of IDs of the records to save (if this
list is empty it will create the records, if not, it will write on the
existing records), the list of changed fields, and the unity
specification as optional argument to read the created/modified records
(if the specification is not set, the function will return a list of IDs
of the created/modified records).

closes odoo/odoo#133021

Task-id: 3453184
Related: odoo/enterprise#46559
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2023-09-04 09:19:06 +00:00
Nicolas Bayet 645b6b2c10 [FIX] web_editor: properly fetching of colorpicker template
As described in #129974, the colorpicker cannot cache a promise
protected by `useService`. #129974 fixes the issue by through non
idiomatic practice (calling a service that is not protected by
`useService`). This commit fixes the issue idiomatically.

This commit caches the promise directly from a service and removes the
caching code from the `ColorPalette`.

task-3446691

closes odoo/odoo#130789

X-original-commit: 1d2e54088b0f0e28464ab6aa884fb2e1110e8e04
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2023-08-10 06:17:03 +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 850427e4ba [REF] web,mail: remove legacy MockServer and related utils
This commit removes the legacy implementation of the MockServer
and test utils making it available in the test environment (e.g.
addMockEnvironment).

Part of task~3439226

closes odoo/odoo#130671

Related: odoo/enterprise#45141
Signed-off-by: Francois Georis (fge) <fge@odoo.com>
2023-08-04 09:43:08 +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
Nicolas Bayet 1feeeda8b8 [FIX] web_editor: synchronise fields with oe_unremovable
When the mechanism that synchronise odoo fields contained an
unremovable, even though no unremovable got removed, the Odoo editor
would rollback as the syncing mechanism would set innerHTML to the
synced nodes, which would remove the unremovable. To prevent the
rollback in that kind of circumstance, this commit introduce a new
method on the OdooEditor `withoutRollback`.

task-3436834

closes odoo/odoo#129320

Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2023-08-01 15:09:24 +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
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
abd-msyukyu-odoo c6fb5793c5 [FIX] web_editor: make urgent commitChanges quasi synchronous
In the context of an urgent htmlField `commitChanges`, there is no time to wait
the response of `rpc` calls, therefore this commit proposes to use the same
strategy as `_toInline` for `savePendingImages`  and not await the result of
the promises before a first `updateValue` if the commit is `urgent`.
This will allow to save most of the changes during a `beforeunload` scenario.

ENTERPRISE PR: https://github.com/odoo/enterprise/pull/42644

task-3372343

closes odoo/odoo#128949

X-original-commit: ba94629cb7fd1381871c37d34104f2511a4d4863
Related: odoo/enterprise#44307
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2023-07-18 21:48:36 +02:00
Rodolpho Lima d01a1bd382 [FIX] web_editor: readonly links opening in the same tab
Before this commit, when viewing the content of an html field in
readonly mode, internal links (same origin or relative links) that did
not have the target attribute set to "_blank" would be opened in the
same browser tab. This is undesired, and particularly disturbing when
the content is inside an iframe.

This commit ensures that, in readonly mode, all links are opened
in a new tab.

task-3323602

closes odoo/odoo#125382

X-original-commit: cb84f993bbf38130482c1f50e550bfdf94a60845
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2023-06-16 13:41:20 +02:00
qsm-odoo c8016d8c80 [FIX] web_editor: properly allow to reset bg/fg text colors
Steps to reproduce:
- Go on a backend HTML field (project task description for instance)
- Write and select some text
- Open the text background color colorpicker
- Hit the "reset" button (the trash icon)
=> The text becomes black (or white in dark mode)

This was because of [1] which indirectly removed the CSS variables
`--black` and `--white`, on which the colorpalette relies.

Note: the test update made by the original commit was lost in the
forward-port because [2] removed the test. It will be restored at some
point thanks to task-3177674.

[1]: https://github.com/odoo/odoo/commit/28444a5792b9929f5250e38f3f864694e22e9370
[2]: https://github.com/odoo/odoo/commit/49297bc7bba75541ca139e6c84e0d3b311765145

closes odoo/odoo#125131

X-original-commit: 907c5b6cc24e0b86c219cda1299a87b7901f4e76
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2023-06-15 18:51:52 +02:00
Antoine Guenet 18b172e821 [FIX] web_editor: properly inline and inherit body line-height from var
Before this commit, the line-height of the body was not properly
inherited where it should. It is defined as a CSS variable and its value
was incorrectly retrieved (if the value is 1.5 and the font-size is
10px, `getComputedStyle` returns 15px instead of 1.5). Other properties
related to fonts were likewise improperly inherited.

X-original-commit: 12ae698bd9aff8466d69819e0b849752f967c126
Part-of: odoo/odoo#124465
2023-06-09 17:01:41 +02:00
Antoine Guenet 2361bc62e9 [FIX] web_editor: fix general column responsiveness issues
Several issues were found regarding the responsiveness of columns,
especially in the Masonry snippet. This implements a new, more robust
approach to responsiveness of columns, based on article [1], where each
column is wrapped inside a new table, itself wrapped in an inline-block
div element, and all adjacent wrapped columns are in turn wrapped in a
common table cell:

```html
<.container>
    <.row>
        <.col id="A">
        <.col id="B">
    </.row>
</.container>
```
becomes something like:
```html
<table>
    <tbody>
        <tr>
            <td>
                <div style="display: inline-block;">
                    <table>
                        <tbody>
                            <tr>
                                <td id="A">
                            </tr>
                        </tbody>
                    </table>
                </div>
                <div style="display: inline-block;">
                    <table>
                        <tbody>
                            <tr>
                                <td id="B">
                            </tr>
                        </tbody>
                    </table>
                </div>
            </td>
        </tr>
    </tbody>
</table>
```
with some additional attributes and styles to make it work.

[1]: https://www.litmus.com/blog/mobile-responsive-email-stacking/

task-3184107

X-original-commit: 3ddba4dbd57891c2d9fc80fb7aa0dd08338fe3f6
Part-of: odoo/odoo#124465
2023-06-09 17:01:38 +02:00
Renaud Thiry ef37dce5fa [FIX] web_editor: _blank href for readonlyIframe
The "readonly iframe" mode of html_editor does not do
the processing required to ensure all links target a new tab when
the setup is called more than once.

As this happens often, links effectively did not redirect to a new tab.

Additionally sandboxedIframe did not allow new tabs to open.
We add `allow-popups` and `allow-popups-to-escape-sandbox`
to the sandbox attributes.

This is safe as the popup will not have access to the odoo window.
Which should mean it's as safe as opening a link without the sandbox.

opw-3337670

closes odoo/odoo#124395

X-original-commit: 61b6b6bf6181fe703cd3d455dba9004e1fad7135
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
Signed-off-by: Thiry Renaud (reth) <reth@odoo.com>
2023-06-09 10:55:02 +02:00
Renaud Thiry bb542f8374 [FIX] mail: allow editing of mail mail
As it holds full HTML documents, mail.mail often encounters issues with
the html editor.

We piggy-back off the intoduction of the switching
behavior between code-view and readonly-view behavior introduced in
a5c0085ce91570c6c961e3293dfe50f4faba6043

The 'sandboxed preview' mode can now be enabled with an option
and will ensure all content can only be viewed in a sandboxed iframe
or in the code editor.

This re-introduces editing, which was mistakenly fully disabled in the
usability fix that introduced body_content here:
5055b374c3bac0126f441dad61afd7e0b68b1370

Some tests are added to ensure the key points of this commit remain
the same. Tests are re-ordered alphabetically to match the order
of execution, making debugging easier.

task-3255777

closes odoo/odoo#121976

X-original-commit: 062569ef042f3b01044c5e4cdbd8b71e96bfd39d
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2023-05-23 16:32:13 +02:00
Renaud Thiry 5ee99c04ce [FIX] web_editor: hide codeview when readonly
In 2389f77c25f3c4dcfd609a8674dc673703cac6a1
containsComplexHTML was added to allow editing of html content
that would otherwise break when inserted as-is in a DOM

For this we added a rule to always display the code view toggle button.
This should not be the case when the field is marked as readonly.

Switching to the code view in readonly mode will cause a traceback.

task-3255777

X-original-commit: 243b7879ecad229aaefed3cdf0c64e7ae434d8ec
Part-of: odoo/odoo#121976
2023-05-23 16:32:12 +02:00
Pulinckx Pierre (PIPU) f4f0f78318 [REF] *: Replace underscore.js function by native JS
Before this commit : The library underscore.js and
underscore.string.js were used in the ODOO solution.
After this commit : Every usages of a function from
underscore.js lib has been replaced with native javascript.
The goal is to remove all usages of underscore.js and to
not use anymore this library in ODOO.
---
TaskId : 3246238

closes odoo/odoo#120437

Signed-off-by: Géry Debongnie <ged@odoo.com>
2023-05-15 09:37:48 +02:00
Pulinckx Pierre (PIPU) 608e90e998 [REF] *: Replace underscore functions by native JS
Replace _.map(), _.flatten(), _.delay(), _.contains(), _.pluck(), _.isUndefined(), _.isEmpty(), _.isString(), _.isEqual(), _.isBoolean(), _.memoize(), _.invoke(), _.bind(), _.escape(), _.debounce(),
_.str.sprintf(), _.str.repeat(), _.str.startswith(), _.str.trim(),
_.str.escapeHTML(), _.str.escapeRegExp(), _.str.startsWith(), _.str.include()

closes odoo/odoo#118012

Signed-off-by: Lucas Perais (lpe) <lpe@odoo.com>
2023-04-20 11:57:29 +02:00
Renaud Thiry c5bb2d0838 [FIX] web_editor: prevent editing of header
The way the live HTML editor for html_field works means the header
(and other nodes that should only appear once) are removed
and the content inserted inside the body.
This results in values being edited without the user being aware.

For emails, this results in any email using 'style' in the header
to break on GMail and other clients that do not support 'style'
outside of the header.

When an html_field is passed a value containing a header
the html_field appears readonly and the user is able to toggle
the code view. Which enables them to edit the 'raw' HTML and see changes
while preventing the presentation view from affecting the database value

task - 3035163

closes odoo/odoo#118920

Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
Signed-off-by: Thiry Renaud (reth) <reth@odoo.com>
2023-04-18 18:29:08 +02:00
Pulinckx Pierre (PIPU) 800223ae7c [REF] *: Replace underscore _.each() by native JS
Replaced _.each() functions (average 235 occurences)

Description of the refactoring this PR addresses:

Current behavior before PR:

There are underscore.js function enumerated above used in odoo.

Desired behavior after PR is merged:

These functions has been replaced by native javascript
prototypes/methods/functions.

TaskId : 3246238

closes odoo/odoo#118565

Signed-off-by: Georis François (fge) <fge@odoo.com>
2023-04-18 15:38:54 +02:00
Pulinckx Pierre (PIPU) 614de86989 [REF] *: Replace underscore function by native JS
Replace _.isNumber(), _.filter(), _.reject(), _.unique(), _.indexOf(), _.lastIndexOf(), _.findIndex(), _.range()
_.keys(), _.values(), _.str.sprintf() and some _.each()

closes odoo/odoo#118003

Signed-off-by: Géry Debongnie <ged@odoo.com>
2023-04-13 16:40:11 +02:00
Pulinckx Pierre (PIPU) 29d55e4403 [REF] *: Replace underscore functions by native JS
Replace _.last, _find, _.extend, _.some, _.every

Taskid 3246238

closes odoo/odoo#117319

Signed-off-by: Bruno Boi (boi) <boi@odoo.com>
2023-04-05 12:50:43 +02:00
Michael (mcm) ff0d6dd580 [REF] *: replace odoo module by native one
This commit converts almost all odoo module by native module.
The goal is to deprecate odoo.define in favor of native module and then
simplify boot.js by removing the regexp that finds module dependencies.

task id: 3162300

closes odoo/odoo#117305

Related: odoo/enterprise#39118
Signed-off-by: Géry Debongnie <ged@odoo.com>
2023-04-03 17:07:24 +02:00
Antoine Guenet f3b4a2948e [REF] web_editor: abstract convert to grid tests, remove jquery
This removes calls to JQuery in the convert to grid tests and the
functions they test. In the process, these tests are abstracted for
better readability and maintainability.

closes odoo/odoo#113784

X-original-commit: 3eafc2d3425365bfb25b0540de95aab4e7d89ebf
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2023-02-27 18:12:24 +01:00
Antoine Guenet f3c4f77f68 [REF] web_editor: abstract cell creation in bootstrap grid inliner tests
This commit abstracts the cell creation in the bootstrap grid inliner
tests so as to make it less wordy, easier to read, and easier to write.

X-original-commit: beceaf05f333596816623417f827ea8cdabc7097
Part-of: odoo/odoo#113784
2023-02-27 18:12:23 +01:00