documentation/content/developer/reference/javascript/services/title_service.rst
Simon Genin (ges) fd28f72c68 wip
2021-10-12 12:06:37 +02:00

73 lines
1.4 KiB
ReStructuredText

Title Service
=============
.. list-table::
:header-rows: 1
* - Technical name
- Dependencies
* - ``title``
- None
Overview
--------
The ``title service`` offers a simple API that allows to read/modify the document title.
API
---
The ``title service`` exports two methods and a value:
* ``current (string)`` ,
* ``getParts(): Parts`` ,
* ``setParts(parts: Parts): void`` ,
where the type ``Parts`` is:
.. code-block:: ts
interface Parts {
[key: string]: string | null;
}
The ``getParts`` method returns a copy of an object ``titleParts`` maintained by the tilte service.
The value ``current`` is structured in the following way: ``value_1 - ... - value_n`` where
``value_1,...,value_n`` are the values (all not null) found in the object ``titleParts``.
The ``setParts`` method allow to add/replace/delete several parts of the title. Delete a part (a value) is done
by setting the associated key value to null;
Example:
If the title is composed of the following parts:
.. code-block:: ts
{
odoo: "Odoo",
action: "Import",
}
with ``current`` value being ``Odoo - Import`` ,
.. code-block:: ts
setParts({
odoo: "Open ERP",
action: null,
chat: "Sauron"
});
will give the title ``Open ERP - Sauron`` and ``getParts`` will return
.. code-block:: ts
{
odoo: "Open ERP",
chat: "Sauron",
}