From 2aac59a72c00164b49578647d1638e9c05bf0d7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Mombereau?= Date: Mon, 12 Jan 2026 14:29:29 -0300 Subject: [PATCH] [IMP] dynamic color based on other field's value in list view --- web_tree_dynamic_colored_field/README.rst | 18 ++++++++++++++++++ .../readme/USAGE.md | 15 +++++++++++++++ .../static/description/index.html | 19 +++++++++++++++++++ .../static/src/js/list_renderer.esm.js | 5 +++++ 4 files changed, 57 insertions(+) diff --git a/web_tree_dynamic_colored_field/README.rst b/web_tree_dynamic_colored_field/README.rst index 13c1e46e9200..054b0c3d75cb 100644 --- a/web_tree_dynamic_colored_field/README.rst +++ b/web_tree_dynamic_colored_field/README.rst @@ -124,6 +124,24 @@ Example: the options doesn't follow the JSON format, the options string will be evaluated using py.eval()** +- You can use another field's label referring to a color too... In the + tree view declaration, put + ``options="{'fg_color': 'my_other_color_field'}"`` attribute in the + ``field`` tag: + + :: + + ... + + + ... + + + ... + + + ... + Known issues / Roadmap ====================== diff --git a/web_tree_dynamic_colored_field/readme/USAGE.md b/web_tree_dynamic_colored_field/readme/USAGE.md index b5950598ff01..a60ede0b4565 100644 --- a/web_tree_dynamic_colored_field/readme/USAGE.md +++ b/web_tree_dynamic_colored_field/readme/USAGE.md @@ -68,3 +68,18 @@ Example: **Note that you can use single or normal quotes. If the declaration of the options doesn't follow the JSON format, the options string will be evaluated using py.eval()** + +- You can use another field's label referring to a color too... In the tree view declaration, put + `options="{'fg_color': 'my_other_color_field'}"` + attribute in the `field` tag: + + ... + + + ... + + + ... + + + ... \ No newline at end of file diff --git a/web_tree_dynamic_colored_field/static/description/index.html b/web_tree_dynamic_colored_field/static/description/index.html index 946fa0bb26d9..e53250da00ff 100644 --- a/web_tree_dynamic_colored_field/static/description/index.html +++ b/web_tree_dynamic_colored_field/static/description/index.html @@ -465,6 +465,25 @@

Usage

Note that you can use single or normal quotes. If the declaration of the options doesn’t follow the JSON format, the options string will be evaluated using py.eval()

+

Known issues / Roadmap

diff --git a/web_tree_dynamic_colored_field/static/src/js/list_renderer.esm.js b/web_tree_dynamic_colored_field/static/src/js/list_renderer.esm.js index 76612d4cb711..9b799afdb876 100644 --- a/web_tree_dynamic_colored_field/static/src/js/list_renderer.esm.js +++ b/web_tree_dynamic_colored_field/static/src/js/list_renderer.esm.js @@ -54,6 +54,11 @@ patch(ListRenderer.prototype, { } } } + // 'definition' can be a field's label referring to a color + if (definition in record.data && record.data[definition]) { + result = record.data[definition]; + } + return result || undefined; } },