Commit Graph
73 Commits
Author SHA1 Message Date
Sébastien Geelen (sge) 2623b4591d [FIX] mail,web: Change command palette shortcut
Change the command palette shrotcut from CTRL+K to CTRL+M,
in order to avoid conflict with link creation shortcut in editor.

task-2635043

closes odoo/odoo#75828

Signed-off-by: Bruno Boi <brboi@users.noreply.github.com>
2021-09-02 03:42:51 +00:00
Francois (fge) aa797792ca [IMP] web: menu providers command in command palette
Adds the possibility to search an app/menu from the command palette .
It allows for fuzzy-searching apps and their submenus as shortcuts to directly
enter the right app and submenu and execute the corresponding action.

The comamnd is initiated by typing "/" in the command palette.

closes odoo/odoo#75396

Task-id: 2622952
Related: odoo/enterprise#20447
Signed-off-by: Lucas Perais (lpe) <lpe@odoo.com>
2021-08-30 13:27:58 +00:00
Francois (fge) dca9ca6464 [IMP] web: refactor debug commands
Rename `Debug Menu` => `Debug tools...`
Remove `Debug tools...` hotkey

The commands in the debug category need to have a search value
to be displayed.

Task-id: 2622240
Part-of: odoo/odoo#74933
2021-08-26 13:56:14 +00:00
Francois (fge) 8b856c6699 [IMP] web: refactor command palette
This commit is a refactoring of the command palette. It aims to improve
its design and make it very easily configurable. For this, we added the
config props allowing the command palette to know what to display.

The config of a palette command is composed of:
- categoriesByNamespace?: list containing all categories according
  to their namespace;
- emptyMessageByNamespace?: dictionary having for key a namespace and
  for value the message to display if there is no choice available;
- footerTemplate?: template to display in the footer;
- namespace?: namespace to add in the search bar;
- placeholder?: placeholder of the searcher;
- providers: list containing all the providers generating the commands
  to display;
The providers are the only information needed in the config. The rest of
the config is optional.

This commit also adds the possibility to open a custom command palette
using the command service. For this, you just have to call openPalette
and give it the required config.

If the command action returns a config, the command palette  will
not be close and will use this new config.

Task-id: 2622240
Part-of: odoo/odoo#74933
2021-08-26 13:56:14 +00:00
Francois (fge) aa12e9853e [IMP] web: improved api of commands generated by a provider 2021-08-11 08:38:10 +00:00
Bruno Boi 0bb93b272c [FIX] web: various dropdown style issues
Various styling fixes.
Issues were brought by odoo/odoo@3b73095302

closes odoo/odoo#74752

Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2021-08-10 12:58:02 +00:00
Aaron Bohy f6c57577fd [FIX] web: correctly put load_views rpc result in cache
In the "view" service, there is a cache s.t. we don't do the
load_views rpc each time we enter an act_window action. However,
before this commit, we never did cache hits because we modified
(in place) the "views" key inside the action, which is used to
generate the cache key.

closes odoo/odoo#74783

Signed-off-by: Bruno Boi <brboi@users.noreply.github.com>
2021-08-06 11:48:10 +00:00
Aaron Bohy ff6e89052d [REF] web,*: regroup custom hooks in core/utils/hooks
*base_automation,iap,im_livechat,point_of_sale

This commit introduces a new file in core/utils: hooks.js
This file contains custom hooks (useEffect, useService, useBus...).

The useHotkey hook is tightly related to hotkeys, so it has been
moved to core/hotkeys.

closes odoo/odoo#74535

Related: odoo/enterprise#20003
Signed-off-by: Lucas Perais (lpe) <lpe@odoo.com>
2021-08-02 11:13:52 +00:00
Lucas Perais (lpe) 83eb9f9ebd [FIX] web: action_service: onClose callback can execute history-back
Have an action in the breadcrumb (A)

Do an action (B) that has a button which spawns a dialog with a onClose callback executing an`history-back` event.
This may be useful when the action (B) acts as a selection buffer between (A) and the dialog.
(e.g. stock_barcode: execute `stock_barcode_client_action` from a picking)

Before this commit, the history-back event just closed the dialog without going back to the action (A)
This was because the wrong condition was used to determine if the dialog was still alive or not.

After this commit, the action (A) is displayed when closing the dialog from any point.
2021-08-02 07:55:52 +00:00
Francois (fge) bfa2d9c205 [IMP] web: refactor Command palette
The purpose of this commit is to make the palette command customizable.

From now, it will be possible to add spaceNames to modify the commands
displayed in the command palette.
For example, if I add the spaceName '@' and associate a provide function
with it, then when I type "@" in the search bar of the command palette,
the commands generated by provide will be displayed.

const commandProviderRegistry = registry.category("command_provider");
commandProviderRegistry.add("example", {
	nameSpace: "@" ,
    provide: (env, options = {}) => {
        return [{name: "myCommand", action: () => ()}]
    },
});

It will be possible to define several provide functions for the same
namespace. This will make it easy to add new commands when installing
a new addon.

Now it is possible to define commands that modify the state of the
command palette. This allows a command to change the placeholder
and commands displayed in the command palette.

closes odoo/odoo#73750

Related: odoo/enterprise#19970
Signed-off-by: Géry Debongnie (ged) <ged@openerp.com>
2021-07-30 08:26:09 +00:00
Samuel Degueldre 4c7ef96974 [REF] web: refactor debug menu to use context in env instead of service
This makes the debug menu more natural to use, and makes the difference
between the "in-dialog" and "out-of-dialog" debug contexts explicit.

closes odoo/odoo#74346

Related: odoo/enterprise#19967
Signed-off-by: Géry Debongnie (ged) <ged@openerp.com>
2021-07-30 06:01:42 +00:00
Samuel Degueldre 1eeab1e418 [REF] web: remove legacy rainbowman
The frontend code was still using the legacy RainbowMan, with the wowl
webclient, we rewrote this RainbowMan and started using that one
instead, but because the frontend code had no access to the wowl
environment, the legacy version was still used in the frontend. Since
the frontend now has access to the wowl environment, the old code can be
removed and the calls can go through the new effect service.

closes odoo/odoo#74148

Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2021-07-23 12:14:10 +00:00
Francois (fge) b3de6f43d5 [FIX] web: display commands in the palette command
This commit avoids displaying commands associated with the wrong active
element in the palette command.

closes odoo/odoo#74149

Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2021-07-23 09:50:28 +00:00
Francois (fge) 55dab0e7d1 [IMP] web: use of a default OS for tests
The purpose of this commit is to have a test environment
that does not depend on the OS of the machine
on which the Odoo server is deployed.

Because the navigator.platform is deprecated, we will use the
navigator.userAgent to identify the OS.
2021-07-19 09:07:09 +00:00
Samuel Degueldre 61dd61b6eb [FIX] web: avoid pushing state when ActionAdapter is in dialog
Previously, push_state events triggered from withing window actions
inside dialogs would bubble push their state into the URL even while
within a dialog, this is undesirable as this can cause the URL to become
invalid (eg by pushing the id of a record from an entirely different
model)

This commit fixes that by simply checking whether we are in a dialog
within the adapter before calling pushState.

task-2602458

closes odoo/odoo#73720

Signed-off-by: Lucas Perais (lpe) <lpe@odoo.com>
2021-07-15 08:38:47 +00:00
Aaron Bohy d85df9c50e [FIX] web: test: ensure to wait for dialog to be opened
Before this commit, the modified test sometimes failed on runbot.
We need to wait for an extra tick, because the dialog might be
rendered in another animation frame that the crashing client
action.

closes odoo/odoo#73675

Signed-off-by: Lucas Perais (lpe) <lpe@odoo.com>
2021-07-14 08:34:14 +00:00
Aaron Bohy 09bc301387 [FIX] web: prevent test from failing randomly
Since [1], the modified test was failing randomly on runbot. Here
is what happened when it failed:
 - the initial action crashed
 - we toggled the menu dropdown
 - an error dialog was displayed -> the active element changed
 - the dropdown was closed (due to commit [1])
 - we asserted that the dropdown contained 3 items, but it was
   closed, so test failed.

[1] https://github.com/odoo/odoo/commit/300ef9ac6fc92bcfd9c37a6088df650e0af32018
2021-07-14 08:32:18 +00:00
Francois (fge) e95080792a [IMP] web, mail: Command palette
The purpose of this commit is to:
- Improve the design of the command palette
- Add few data-command-category and data-hotkey
- Scrolling through the command palette dropdown with the up/down arrows
should loop
- Moving the mouse over the palette command no longer causes scrolling

Task-2590390
2021-07-13 07:32:09 +00:00
Aaron Bohy 4b3dc07b52 [FIX] web: better handle error in actions
Before this commit, if there was a crash in a view or client
action during an update (i.e. the action is already in the DOM,
but an update triggers a re-rendering), the error was caught by
the action service, it wasn't displayed to the user, and the
action was re-rendered again (which could obviously result in the
same error being thrown again and again).

With this commit, we properly show the error, and we do not try
to re-render the action.

closes odoo/odoo#73507

Signed-off-by: Géry Debongnie (ged) <ged@openerp.com>
2021-07-12 13:40:26 +00:00
Aaron Bohy a8976144fe [FIX] web: correctly call dialog service 2021-07-12 13:40:26 +00:00
Francois (fge)andSergey Shebanin 7f10ca0d7c [IMP] web: make the hotkey service overlay modifier customizable
From this commit:
- It is possible to modify the overlayModifier allowing to display the
overlay and to access the data-hotkeys defined in the Dom.
- Adding a hotkey using the service or hook does not add the
overlayModifier anymore.

closes odoo/odoo#73279

Signed-off-by: Géry Debongnie (ged) <ged@openerp.com>
Co-authored-by: Sergey Shebanin <sergey@shebanin.ru>
2021-07-09 09:16:57 +00:00
Francois (fge) 20e157dd01 [FIX] web: doesn't apply the invisible data-hotkey
The purpose of this commit is to prevent the activation of data-hotkeys
associated with hidden elements of the dom.

Task-2591069 - BUG 1
2021-07-09 09:13:58 +00:00
Lucas Perais (lpe) a935096e51 [FIX] web: webclient: remove bootstrap tooltips more accurately
Before this commit, when hovering a button with a bootstrap tooltip set on it
(form view with header button in debug mode) and then clicking while staying hover
the tooltip was not destroyed and there was no easy means to destroy it.

After this commit, any click within a legacy context remove any bootstrap tooltip from the DOM,
since popper and tooltip are not meant to be used in the future in a wowl setting.

closes odoo/odoo#73447

Signed-off-by: Géry Debongnie (ged) <ged@openerp.com>
2021-07-08 15:28:01 +00:00
Jorge Pinna Puissant 54e9527ec2 [IMP] web, *: read session information from a module
* google_recaptcha, mail, partner_autocomplete, point_of_sale, website

Now, to read session information, the module "@web/session" must be
imported. Not that, there is also the user service with all the user
information.

closes odoo/odoo#73201

Related: odoo/enterprise#19434
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2021-07-08 14:13:39 +00:00
Lucas Perais (lpe) 4fa4ff685a [FIX] web: load_state_tests: avoid undeterministic asserts
Before this commit, two tests had undeterministic outcomes:
they wanted to assert something in DOM was present at the same tiome as an owl rendering

After this commit, the problematic asserts are removed and the tests behave deterministically.

closes odoo/odoo#73379

Signed-off-by: Géry Debongnie (ged) <ged@openerp.com>
2021-07-07 14:31:04 +00:00
Lucas Perais (lpe) 23da5621f3 [FIX] web: router_service: concurrent hashchange
Do an action that will change the hash.
During this, change the url hash to load another action

Before this commit, the hash taken to load the second action was wrong, because the first
action pushed its state instants before the hashchange event is actually triggered.
This is because the hashchange event is triggered in a non blocking stack
(https://html.spec.whatwg.org/multipage/browsing-the-web.html#scroll-to-fragid)

After this commit, the right action is loaded with the right hash

closes odoo/odoo#72878

Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2021-07-07 09:16:38 +00:00
Francois (fge) 1e5a0dfc0a [FIX] web: display shortcuts correctly on the command palette
closes odoo/odoo#73048

Signed-off-by: Géry Debongnie (ged) <ged@openerp.com>
2021-07-01 11:37:45 +00:00
Xavier Morel 3985edd5da [FIX] web: missing action id warnings
* Add test name when logging missing action ids, makes finding out
  which test causes the issue much simpler.
* Suppress the warning emission in the one remaining test which
  triggers it, as testing invalid action IDs is exactly the purpose of
  the test.
2021-06-29 05:34:16 +00:00
Francois (fge) f92bd09244 [IMP] web: add shortcuts access from the command palette
This commit adds the possibility to use a shortcut from the command
palette. When a shortcut is called from the command palette, the palette
will be close and the action related to the shortcut will be apply.

closes odoo/odoo#72831

Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2021-06-28 12:06:26 +00:00
Lucas Perais (lpe) 0cec54b92c [FIX] web: action_service: better error handling
on a legacy form view, do an action in target new
The view in target new should, during its onchange, trigger a ValidationError

Before this commit, the dialog_container was stuck in an error loop.
This was because the received error was never an instance of Error, rather it was
a legacy error event. So it was never transmitted upstream were the ErrorHandler could remove
the dialog in error from is dialog array.

After this commit, the ValidationError mesage is displayed.

This commit additionally fixes another issue:
An action in target main that failed to render erased the whole DOM. This is not what we want,
at least for now. Imagine a list view, open a record, this record fails to load. We still want to be
on the list view, not in a blank state.
2021-06-23 15:47:56 +00:00
Lucas Perais (lpe) 77a59f8d6a [FIX] web: action_service: do not commit a dialog that has failed
Open a action in target new that you'll know will fail to open.
Make sure you put an onClose callback when executing doAction.

Open another action in target new, that will succeed.

Before this commit, the onClose of the first dialog is executed, while it should not.
Indeed, if the dialog fails, the whole business flow is invalid altogether
and no more business operation (in the onClose) should be executed

After this commit, the onClose callback of the failing dialog is not executed.
2021-06-23 15:47:55 +00:00
Mathieu Duckerts-AntoineandLucas Perais db2092d8d3 [REF] web,mail: action_service: doAction passes props to component
Before this commit the doAction method of the action_service did not support
to pass props directly to the Component. Only a few ad-hoc options were passed though.

After this commit, doAction can take a key "props" in options, that will be passed to the Component
(a View or a ClientAction)

the new API becomes
```ts

interface Options {
  props: { [key: string]: any };
  ...
}

doAction(action: ActionRequest, options: Options);

Note that some props (like withFilters) are set by the action service
and cannot be set via the key "props".

Alongside the change mentioned above, we take the opportunity to align the
terminology used in action service to the one used server side: we know use
the terms resModel, resId, and resIds instead of model, recordId, and recordIds.

```

closes odoo/odoo#72397

Related: odoo/enterprise#19127
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
Co-authored-by: Lucas Perais <lpe@odoo.com>
Co-authored-by: Mathieu Duckerts-Antoine <dam@odoo.com>
2021-06-21 13:21:53 +00:00
Michael Mattiello (mcm) 9ecadd06ac [IMP] web: add messageIsHtml option for rainbowman
Before this commit, rainbowman message was displayed using
`t-raw` in template.
Now, the message is escaped by default and needs to be marked as
HTML to be displayed as well.

closes odoo/odoo#72392

Task-id: 2575435
Related: odoo/enterprise#19121
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2021-06-22 08:06:07 +00:00
Aaron Bohy e07bda1d4d [FIX] web: actions in target="new" should not update title
Before this commit, all actions, even those executed in target
"new" (i.e. in dialogs) updated the document's title. Actions in
dialog should not do that.

closes odoo/odoo#72526

Signed-off-by: Lucas Perais (lpe) <lpe@odoo.com>
2021-06-22 11:37:52 +00:00
Simon Genin (ges) e7e409baad [FIX] web: make activities systray item work
The activities systray item didn't work anymore. Nothing happened on
click.

It was because the do action event was never caught. The systray item
logic had a different flow and didn't go through the ViewAdapter code.

We fix this by adding a listener on window (through legacy service
provider) to execute this code when the do_action bubbles up.
Instead of using the legacy service provided, we could have done this
in the SystrayItemAdapter, but we then have the legacy environment and
would need more work for the same result.

closes odoo/odoo#72406

Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2021-06-22 08:33:04 +00:00
Lucas Perais (lpe) 13a6c13666 [FIX] web: legacy client action push state
Before this commit, the push state from client actions to the URL did
not work properly:
1. the action.params key was ignored
2. some "reserved" keys (active_id) were not handled properly
3. within a legacy client action, the call to parent.do_push_state did not work

After this commit, all of those work properly letting discuss in particular have the right URL

It is worth noting that in the full wowl stack, that the right way to push something
in the URL from a component is always to call the router service's pushState when the component is mounted

closes odoo/odoo#72408

Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2021-06-21 12:37:43 +00:00
Géry Debongnie 4e308bfdab [IMP] web: properly handle errors in action controllers
Before this commit, an error in the rendering of a client action or view
would not be properly cleaned: the action container did not catch any
error, so owl would destroy the UI.

With this commit, we simply catch the error, and empty the content of
the action container.
2021-06-18 21:31:34 +02:00
Francois (fge) ea0a718fb4 [FIX] web: add the missing views in legacy_views
Before this commit, the switch from a multiple view (list, kanban, ...)
to a custom form view was not correctly done. The form view displayed
was not the custom version but the default one.

This problem is caused by the filter applied on viewSwitcherEntries
which removes the form views because they are not a multiple view.

To solve this problem, we will add the missing form view in the
actions.views given to the legacy view.

closes odoo-dev/odoo#958

Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2021-06-18 21:31:34 +02:00
Aaron Bohy 8b057a7671 [REF] web: move setup_tests to env_tests
To better reflect the prod file structure in the tests.
2021-06-18 21:31:34 +02:00
Michael Mattiello (mcm) aa819f892d [REF] web: change effect service API
Before this commit, effect service provided two functions:
  create(type, params)
  rainbowMan(params)

Now, it provides one function add which is create but renamed
rainbowMan function can be called by doing:
  service.add("rainbowman", ...);

closes odoo-dev/odoo#969

Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2021-06-18 21:31:34 +02:00
Francois (fge) 2d1316bfe6 [FIX] web: residual rename create to add 2021-06-18 21:31:34 +02:00
Lucas Perais (lpe) 832ce8d1f9 [FIX] web, mail: test helpers: fix legacy interactions
The new execution environment of wowl tests has to take into account that legacy objects
can be spawned below it and around it, in particular in mail tests where mail has to create
an owl environment with the right keys.

This commit aims at making this work namely by being to pass an already formed legacyEnv
to the createWebClient helper
2021-06-18 21:31:34 +02:00
Francois (fge) 2aca56f0f0 [FIX] web: doAction supports controllerState passed in option
In legacy, doAction can be passed the `controllerState` key, which contains `searchModel`
and `searchPanel`, that an AbstractController can export.

This commit re-implements this in the action service.
2021-06-18 21:31:33 +02:00
Lucas Perais (lpe) c65e57e17b [REF] web: ui_service and block UI in @web/core/ui/
closes odoo-dev/odoo#925

Related: odoo-dev/enterprise#166
Signed-off-by: Géry Debongnie (ged) <ged@openerp.com>
2021-06-18 21:31:33 +02:00
Lucas Perais (lpe) 694e3f5904 [REF] web: services register their own component
Some services are coupled with a Component. Usually the service
handles the state of the system, and the Component displays or uses it.

To enable the communication between the service and the component
while making it private, the services should add themselves their
Component in the relevant registry, with the proper means of communication
passed in props.

This mechanism relies on c1d49d494e0ae3a94b3943186eb6d1ebd7b98a6e
2021-06-18 21:31:33 +02:00
Bruno Boi 47acba560a [FIX] web: open menus in new tab
Before this commit, menus in navbar and clickable elements on the home
menu were not openable in a new tab through a ctrl-click or through the
middlemouse button.

In order to achieve that, we now use default behavior of <a href/> elements.

As such default behaviour would conflict with <DropdownItem/> clicks,
a global click handler is added in the WebClient constructor which stops
the click event propagation under these specific circumstances
(ctrl-click inside an <a href/> element).

Besides this work, it has been found that the <Dropdown/> root element
should not always be a <div/> as it was, but sometimes it has to be
another HTML element in order to comply with the W3C specs. E.g. a
<Dropdown/> component as a first level child of an <ul/> element must
have a <li/> root element instead of a <div/> one.

Thus, a new prop is added to the <Dropdown/> component (`tag`) allowing
the developer to choose another root element: `<Dropdown tag="'li'"/>`.

closes odoo-dev/odoo#913

Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2021-06-18 21:31:33 +02:00
Simon Genin (ges) b124343d21 [REF] web: linting 2021-06-18 21:31:33 +02:00
stefanorigano (SRI) 1fb2cd9af7 [FIX] web, *: drop o_dropdown_toggler_btnclasses
Drop `o_dropdown_toggler_btn` class in favor of `o_dropdown_toggler`.
o_dropdown_toggler_btn was initially introduced in ~13.3, but it's now
obsolete.
2021-06-18 21:31:32 +02:00
Simon Genin (ges) 276228010e [FIX] web: fix legacy views form no id
BUG: Begin on a multi record view (list, kaban), change the url param "view_type" to form. A controller
adapter component would fail to mount and and promise would be pending for ever, freezing the webclient.

WHY: The new webclient, in the specified case described above, would set the recordId to false when switching
to the single record view without providing a record id in the url. However, the legacy views expected a value
of undefined.

FIX: In an adapter layer, the legacy views adapter, we check for the recordId being set to false. When it is,
update this value to undefined.

closes odoo-dev/odoo#933

Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2021-06-18 21:31:32 +02:00
Aaron Bohy 840f914a4e [FIX] web: concurrency issue when opening form view
From a list or kanban view, quickly click multiple times on a
record or on the Create button: a lot of bad stuff could happen
from there (e.g. crashes, form view that could not be open
anymore afterward).

The reason was that we destroyed the legacy form view whereas we
shouldn't, as it was still used. In more details, when we clicked
first on a record to open it, we created an owl Component to
instantiate and wrap the form view (legacy). When we clicked a
second time, we another owl Component was instantiated and the
first one was destroyed. As an unwanted side-effect, the legacy
form view was destroyed as well, but the new controller wanted to
reuse it. From that point, anything bad could happen as we were
trying to use a destroyed widget.

closes odoo-dev/odoo#941

Signed-off-by: Géry Debongnie (ged) <ged@openerp.com>
2021-06-18 21:31:32 +02:00