This commit is contained in:
Simon Genin (ges)
2021-10-11 17:07:52 +02:00
committed by Simon Genin
parent 4331177bb6
commit fd28f72c68
84 changed files with 3316 additions and 3 deletions

View File

@@ -0,0 +1,2 @@
Action Handler Registry
=======================

View File

@@ -0,0 +1,2 @@
Action Registry
===============

View File

@@ -0,0 +1,2 @@
Burger Menu Registry
====================

View File

@@ -0,0 +1,54 @@
Command Category Registry
=========================
Overview
--------
The ``commandCategoryRegistry`` gathers the command categories.
Key Usage
---------
The keys in this registry can be used in two differents ways in order to organize the command palette:
*
when registering a new command: ``useCommand({ category: "key", ... })``.
*
applied as an attribute in the document: ``[data-command-category="key"]``.
N.B.: if an element should appear in the command palette
(e.g. it has a ``[data-hotkey]`` attribute), the closest parent (including itself)
having a ``[data-command-category]`` will provide the category key to seek for in the registry.
Value Type
----------
``{ label?: string }`` where ``label`` is the displayed name of the category in the command palette. Can be undefined.
Available Categories
--------------------
.. list-table::
:header-rows: 1
* - Key
- Sequence
- Description
* - ``main``
- 10
- Main Commands
* - ``app``
- 20
- Current App Commands
* - ``actions``
- 30
- More Actions
* - ``navbar``
- 40
- NavBar
* - ``default``
- 100
- Other commands

View File

@@ -0,0 +1,2 @@
Command Empty List Registry
===========================

View File

@@ -0,0 +1,2 @@
Command Provider Registry
=========================

View File

@@ -0,0 +1,2 @@
Company Menu Registry
=====================

View File

@@ -0,0 +1,2 @@
Debug Registry
==============

View File

@@ -0,0 +1,2 @@
Error Dialogs registry
======================

View File

@@ -0,0 +1,2 @@
Error Handler registry
======================

View File

@@ -0,0 +1,2 @@
Error Notification Registry
===========================

View File

@@ -0,0 +1,2 @@
Favortite Menu Registry
=======================

View File

@@ -0,0 +1,2 @@
Field Registry
==============

View File

@@ -0,0 +1,2 @@
Formatter Registry
==================

View File

@@ -0,0 +1,2 @@
Main Component Registry
=======================

View File

@@ -0,0 +1,2 @@
Parser Registry
===============

View File

@@ -0,0 +1,57 @@
Registries
==========
Overview
--------
The Odoo web client provides many registries, which allow developers to extend
the web client in a safe and structured way.
Here is a list of all registries:
.. list-table::
:header-rows: 1
* - Name
- Description
* - ``actions``
- definition of all available client actions
* - ``Components``
- components (class) that will be instantiated at root of web client
* - ``errorDialogs``
- dialogs (class) that will be instantiated by the crash manager to handle errors
* - ``services``
- definition of all services that will be deployed
* - `systray <../systray.md#adding-a-systray-item>`_
- components (class) that will be display in the systray menu (a part of the navbar)
* - ``views``
- definition of all available views
* - `userMenu <user_menu.md>`_
- definition of all user menu items
Usage
-----
A registry is an owl `EventBus <https://github.com/odoo/owl/blob/master/doc/reference/event_bus.md#-event-bus->`_ with some additional methods (below ``T`` is the type of values to be found in the registry):
* ``add: (key: string, value: T, force: boolean = false) => Registry<T>`` : add an entry ``(key, value)`` to the registry. By default, add
a key already used results in an error. This can be prevented by using the parameter ``force`` , leading to the replacement of the old entry.
The ``add`` method returns the registry itself to allow chaining.
* ``get: (key: string) => T`` : returns a value from the registry. An error is thrown in case the key cannot be found in the registry.
* ``contains: (key: string) => boolean`` : allow to check the presence of a key in the registry.
* ``getAll: () => T[]`` : returns the registry values.
* ``getEntries: () => [string, T][]`` : returns the registry entries.
* ``remove: (key: string)`` : remove an entry from the registry.
Each time an item is added (deleted) via ``add`` (resp. ``delete`` ), an event "UPDATE" is triggered with a payload of type
.. code-block:: ts
interface Payload {
operation: "add" | "delete";
key: string;
value: T;
}

View File

@@ -0,0 +1,2 @@
Sample Server Registry
======================

View File

@@ -0,0 +1,2 @@
Service Registry
================

View File

@@ -0,0 +1,2 @@
Systray Registry
================

View File

@@ -0,0 +1,49 @@
User Menu registry
==================
Overview
--------
The registry ``userMenu`` gathers the ``user menu`` dropdown elements.
Value type
----------
.. code-block:: ts
(env: OdooEnv) => UserMenuItem;
where
.. code-block:: ts
interface UserMenuItem {
description: string;
callback: () => void | Promise<any>;
hide?: boolean;
href?: string;
sequence?: number;
}
Thus each value of the registy is a function taking the `environment <../environment.md>`_ in entry
and returning a plain object with some keys:
* ``description`` : the item text,
* ``href`` : (optional) if given (and truthy), the item text is put in a ``a`` tag with given attribute href,
* ``callback`` : callback to call when the item is clicked on,
* `hide`: (optional) indicates if the item should be hidden (default: false),
* `sequence`: (optional) determines the rank of the item among the other dropwdown items (default: 100).
Example:
.. code-block:: js
env.registry.userMenu.add("key", (env) => {
return {
description: env._t("Technical Settings"),
callback: () => { env.services.action_manager.doAction(3); };
hide: (env.browser.random() < 0.5),
}
}

View File

@@ -0,0 +1,2 @@
View Registry
=============