[IMP] reference: rewrite and move views documentation to user_interface/

The documentation of the views is redone in order to be up to date and
has allowed a better visualization of the task on the modifiers.

task-2495504
This commit is contained in:
Gorash
2023-01-17 16:25:44 +01:00
parent ccc9bc4bc5
commit f6622b1da0
44 changed files with 5111 additions and 2610 deletions

View File

@@ -306,7 +306,7 @@ Here is an example of a basic counter widget:
For this example, assume that the template *some.template* (and is properly
loaded: the template is in a file, which is properly defined in the assets of
the module manifest ``'assets': {'web.assets_qweb': [...]}``, see
the module manifest, see
:ref:`assets <reference/assets>`.) is given by:
.. code-block:: xml
@@ -438,20 +438,6 @@ Widget API
initialized but before it has been started. The root element generated by
the template will be set as the DOM root of the widget.
.. attribute:: Widget.xmlDependencies
List of paths to xml files that need to be loaded before the
widget can be rendered. This will not induce loading anything that has already
been loaded. This is useful when you want to load your templates lazily,
or if you want to share a widget between the website and the web client
interface.
.. code-block:: javascript
var EditorMenuBar = Widget.extend({
xmlDependencies: ['/web_editor/static/src/xml/editor.xml'],
...
.. attribute:: Widget.events
Events are a mapping of an event selector (an event name and an optional
@@ -630,36 +616,8 @@ override the *renderElement* method to do something else).
The Qweb JS template engine is based on XML, and is mostly compatible with the
python implementation.
Now, let us explain how the templates are loaded. Whenever the web client
starts, a rpc is made to the */web/webclient/qweb* route. The server will then
return a list of all templates defined in data files for each installed modules.
The correct files are listed in the *web.assets_qweb* entry in each module
manifest. It is also possible to lazy-load another bundle's templates by calling
this same route and giving it the corresponding "bundle" query parameter.
The web client will wait for that list of template to be loaded, before starting
its first widget.
This mechanism works quite well for our needs, but sometimes, we want to lazy
load a template. For example, imagine that we have a widget which is rarely
used. In that case, maybe we prefer to not load its template in the main file,
in order to make the web client slightly lighter. In that case, we can use the
*xmlDependencies* key of the Widget:
.. code-block:: javascript
var Widget = require('web.Widget');
var Counter = Widget.extend({
template: 'some.template',
xmlDependencies: ['/myaddon/path/to/my/file.xml'],
...
});
With this, the *Counter* widget will load the xmlDependencies files in its
*willStart* method, so the template will be ready when the rendering is performed.
The web client will wait for that list of template (included into the current asset)
to be loaded, before starting its first widget.
Event system
============