Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add doc for node type decorator #20

Merged
merged 3 commits into from
Feb 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/developer/nodes-system/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ Node system
intro
node_types
node_type_fields
node_type_decorators
nodes
103 changes: 103 additions & 0 deletions src/developer/nodes-system/node_type_decorators.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
.. _node_type_decorators:


Node-type Decorators
====================

Roadiz allows you to customize any node-types and node-type fields **non-structural** properties.
This can be handy if you need to change node-types appearence (display names, colors) in Back-office without needing to update your project configuration or emptying caches.

Entity representation
---------------------

This decoration is represented by the NodeTypeDecorator entity, which contains three fields :

- ``path``
- ``property``
- ``value``

``path`` property :
^^^^^^^^^^^^^^^^^^^

This property is used to define the *node type* or *node type field* we want to customize.

It consists of the ``node type name`` and the ``node type field name`` separated by a ``dot``.

.. note::
Exemple of ``path`` for the content field of a Page :

``Page.content``

.. warning::
For decorate an property of a node type simply leave empty after the dot. :

``Page.``


``property`` property :
^^^^^^^^^^^^^^^^^^^

This property is used to define the *node type property* or *node type field property* we want to customize.

It consists of a ``Enum`` which depends on the path containing a field or not.

**List of the property for node type :**

#. displayName
#. description
#. color

**List of the property for node type field :**

#. field_label
#. field_universal
#. field_description
#. field_placeholder
#. field_visible
#. field_min_length
#. field_max_length

.. note::
Example of ``property`` for the content field of a Page :

``field_label``

.. warning::
You can't attribute a ``node type`` property to a ``path`` with field
(exemple: path = ``Page.`` and property = ``field_label``)

You can't attribute a ``node type field`` property to a ``path`` without field
(exemple: path = ``Page.content`` and property = ``displayName``)

``value`` property :
^^^^^^^^^^^^^^^^^^^

This property is used to override the default value. Default values come from your `node_types/*.yaml` files.

It consists of a string linked to its property type.

List of the property type :

- **display_name** => text type
- **description** => text type
- **color** => hexadecimal color type
- **field_label** => text type
- **field_universal** => boolean type
- **field_description** => text type
- **field_placeholder** => text type
- **field_visible** => boolean type
- **field_min_length** => integer type
- **field_max_length** => integer type

.. note::
Exemple of ``value`` on the ``field_label`` property :
``'A text Label'``

Exemple of ``value`` on the ``field_visible`` property :
``'true'``

Exemple of ``value`` on the ``color`` property :
``'#FF1185'``

Exemple of ``value`` on the ``field_max_length`` property :
``'15'``