documentation/wowl_markdown_doc/services/title.md
Géry Debongnie eff7c05465 [DOC] add master-wowl doc (UNFINISHED)
I know, the doc is still in md, it was only temporary. we will convert
it to rst someday
2021-05-31 15:29:27 +02:00

1.2 KiB

Title service

Technical name Dependencies
title

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:

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:

{
    odoo: "Odoo",
    action: "Import",
}

with current value being Odoo - Import,

setParts({
    odoo: "Open ERP",
    action: null,
    chat: "Sauron"
});

will give the title Open ERP - Sauron and getParts will return

{
    odoo: "Open ERP",
    chat: "Sauron",
}