From b2bf8c62a16b452898bed841974f64de605bb2b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Souk=C3=A9ina=20Bojabza?= Date: Thu, 22 Jun 2023 11:35:15 +0000 Subject: [PATCH] [FIX] web_editor: re-allow hiding column count widget if specified class When the `s_nb_column_fixed` class is present on the row, it should not be possible to change the number of columns in the "Columns" option (the option is supposed to be hidden). However, since commit [1], this behavior is broken. It happened because the "Columns" option needs to always be displayed in order to display correctly the "Grid" option and this class was therefore ignored. This commit restores this class behavior by hiding only the widget changing the number of columns and not the complete "Columns" option, in order to still be able to toggle between the grid and the normal modes. [1]: https://github.com/odoo/odoo/commit/84d684d8bdf43d3db11defd8174dee44775085c2 task-3369847 closes odoo/odoo#127144 X-original-commit: 8148521f052268877f36947e0533843a25d17b83 Signed-off-by: Quentin Smetz (qsm) --- addons/web_editor/static/src/js/editor/snippets.options.js | 4 ++++ addons/website/views/snippets/snippets.xml | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/addons/web_editor/static/src/js/editor/snippets.options.js b/addons/web_editor/static/src/js/editor/snippets.options.js index fff87e99883..feafcd135c3 100644 --- a/addons/web_editor/static/src/js/editor/snippets.options.js +++ b/addons/web_editor/static/src/js/editor/snippets.options.js @@ -5266,6 +5266,10 @@ registry.layout_column = SnippetOptionWidget.extend({ // were marked as such as they were allowed to have bare content in // the first place. return this.$target.is('.s_allow_columns'); + } else if (widgetName === "column_count_opt") { + // Hide the selectCount widget if the `s_nb_column_fixed` class is + // on the row. + return !this.$target[0].querySelector(":scope > .row.s_nb_column_fixed"); } return this._super(...arguments); }, diff --git a/addons/website/views/snippets/snippets.xml b/addons/website/views/snippets/snippets.xml index e47ca2bd3bc..d660b4cb705 100644 --- a/addons/website/views/snippets/snippets.xml +++ b/addons/website/views/snippets/snippets.xml @@ -492,7 +492,7 @@
- + None 1 2 @@ -528,7 +528,7 @@ Grid Cols - + None 1 2