From a706cb2a2d40d37460175e17d760daa11d497921 Mon Sep 17 00:00:00 2001 From: Guewen Baconnier Date: Fri, 10 Jan 2020 10:08:35 +0100 Subject: [PATCH] Remove support of dynamic colors on The 'colors' and 'options' fields are not supported by the RelaxNG schema of the element. Remove the support until we find a good solution for this. --- .../demo/res_users.xml | 3 -- .../readme/DESCRIPTION.rst | 7 ----- .../readme/ROADMAP.rst | 5 +++ .../readme/USAGE.rst | 12 ------- .../src/js/web_tree_dynamic_colored_field.js | 31 ------------------- 5 files changed, 5 insertions(+), 53 deletions(-) create mode 100644 web_tree_dynamic_colored_field/readme/ROADMAP.rst diff --git a/web_tree_dynamic_colored_field/demo/res_users.xml b/web_tree_dynamic_colored_field/demo/res_users.xml index dd8afbb00..de8aeb41c 100644 --- a/web_tree_dynamic_colored_field/demo/res_users.xml +++ b/web_tree_dynamic_colored_field/demo/res_users.xml @@ -4,9 +4,6 @@ res.users - - {"color_field": "lang"} - { "bg_color": "#9e1635: login_date == False", diff --git a/web_tree_dynamic_colored_field/readme/DESCRIPTION.rst b/web_tree_dynamic_colored_field/readme/DESCRIPTION.rst index c9ae98dcf..1568429d5 100644 --- a/web_tree_dynamic_colored_field/readme/DESCRIPTION.rst +++ b/web_tree_dynamic_colored_field/readme/DESCRIPTION.rst @@ -1,15 +1,8 @@ This module aims to add support for dynamically coloring fields in tree view according to data in the record. -It provides attributes on fields with a similar syntax as the ``colors`` attribute -in tree tags. - -Further, it provides a ``color_field`` attribute on tree tags's ``options`` to use -a field's value as color. - Features ======== * Add attribute ``bg_color`` on field's ``options`` to color background of a cell in tree view * Add attribute ``fg_color`` on field's ``options`` to change text color of a cell in tree view -* Add attribute ``color_field`` on the tree element's ``options`` to use as color diff --git a/web_tree_dynamic_colored_field/readme/ROADMAP.rst b/web_tree_dynamic_colored_field/readme/ROADMAP.rst new file mode 100644 index 000000000..4d068a177 --- /dev/null +++ b/web_tree_dynamic_colored_field/readme/ROADMAP.rst @@ -0,0 +1,5 @@ +* Before version 13.0, this module had a feature allowing to change the color of + a line depending on a field, using a ``colors`` attribute with the name of the + field on the ```` element. Since 13.0, the ``colors`` attribute is no + longer in the RelaxNG schema of the tree view, so we can't use it anymore. + This feature has then been dropped, but could be reimplement in another way. diff --git a/web_tree_dynamic_colored_field/readme/USAGE.rst b/web_tree_dynamic_colored_field/readme/USAGE.rst index 101802d9b..2be4517c5 100644 --- a/web_tree_dynamic_colored_field/readme/USAGE.rst +++ b/web_tree_dynamic_colored_field/readme/USAGE.rst @@ -26,18 +26,6 @@ With this example, column which renders 'name' field will have its text colored in white on a customer records. -* In the tree view declaration, use ``options='{"color_field": "my_color"}'`` attribute in the ``tree`` tag:: - - ... - - - ... - - ... - - - ... - * If you want to use more than one color, you can split the attributes using ';': .. code:: diff --git a/web_tree_dynamic_colored_field/static/src/js/web_tree_dynamic_colored_field.js b/web_tree_dynamic_colored_field/static/src/js/web_tree_dynamic_colored_field.js index f2a4f99a6..6f2239d03 100644 --- a/web_tree_dynamic_colored_field/static/src/js/web_tree_dynamic_colored_field.js +++ b/web_tree_dynamic_colored_field/static/src/js/web_tree_dynamic_colored_field.js @@ -5,31 +5,6 @@ odoo.define('web_tree_dynamic_colored_field', function (require) { var pyUtils = require("web.py_utils"); ListRenderer.include({ - /** - * Look up for a `color_field` parameter in tree `colors` attribute - * - * @override - */ - _renderBody: function () { - if (this.arch.attrs.options) { - var archOptions = this.arch.attrs.options; - if (!_.isObject(archOptions)) { - archOptions = pyUtils.py_eval(archOptions); - } - var colorField = archOptions.color_field; - if (colorField) { - // Validate the presence of that field in tree view - if (this.state.data.length && colorField in this.state.data[0].data) { - this.colorField = colorField; - } else { - console.warn( - "No field named '" + colorField + "' present in view." - ); - } - } - } - return this._super(); - }, /** * Colorize a cell during it's render * @@ -49,12 +24,6 @@ odoo.define('web_tree_dynamic_colored_field', function (require) { * @param {Object} node an XML node (must be a ) */ applyColorize: function ($td, record, node, ctx) { - // safely resolve value of `color_field` given in - var treeColor = record.data[this.colorField]; - if (treeColor) { - $td.css('color', treeColor); - } - // apply 's own `options` if (!node.attrs.options) { return; } if (node.tag !== 'field') { return; } var nodeOptions = node.attrs.options;