[FIX] web_editor: hide the "no column" option for snippets with columns
Commit [1] which occurred in 13.X for the upcoming release of the 14.0 version introduced a "No column" option for snippets whose only column was removed but that we wanted having the possibility to switch to a multi-columns layout. At the time: Title, Text and Cover snippets. That "None" option was meant to be hidden (as it was at the time) for other snippets already in a multi-columns layout. Indeed the "No column" and "1 column" options are very similar: "No column" is just an optimization for experienced users. The problem here was that [2] broke the behavior. Indeed [1] marked the code in charge to hide that "No column" option as "To improve" as the system was limited to do that at the time... [2] actually improved the system to allow hiding sub-widgets, but did not adapt [1], making the "No column" option always visible. While working and not harmful, that "No column" option may be confusing as at best you don't see the difference with the "One column" option and at worst, removing the column removes nice style that you cannot restore by choosing a multi-column layout again afterwards. While not entirely stable (in the end we never released a major version where [1] was working as intended), this commit restores the idea behind [1] anyway to avoid further confusion and tickets. Choosing "One column" instead of "None" most of the time leads to a better UX anyway. [1]: https://github.com/odoo/odoo/commit/b293ccc7c3c5ca9a55092afd2e4a7b88c7b93fc8 [2]: https://github.com/odoo/odoo/commit/ecefd51b63ed8c933243b4a2d26381d05ac288d2 Related to task-3106301 closes odoo/odoo#108757 X-original-commit: 1ff8c9a6a907b4e60f86efc27c82727b288f0947 Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
This commit is contained in:
@@ -4909,17 +4909,6 @@ registry.Box = SnippetOptionWidget.extend({
|
||||
|
||||
|
||||
registry.layout_column = SnippetOptionWidget.extend({
|
||||
/**
|
||||
* @override
|
||||
*/
|
||||
start: function () {
|
||||
// Needs to be done manually for now because _computeWidgetVisibility
|
||||
// doesn't go through this option for buttons inside of a select.
|
||||
// TODO: improve this.
|
||||
this.$el.find('we-button[data-name="zero_cols_opt"]')
|
||||
.toggleClass('d-none', !this.$target.is('.s_allow_columns'));
|
||||
return this._super(...arguments);
|
||||
},
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Options
|
||||
@@ -5085,6 +5074,20 @@ registry.layout_column = SnippetOptionWidget.extend({
|
||||
}
|
||||
return this._super(...arguments);
|
||||
},
|
||||
/**
|
||||
* @override
|
||||
*/
|
||||
_computeWidgetVisibility(widgetName, params) {
|
||||
if (widgetName === 'zero_cols_opt') {
|
||||
// Note: "s_allow_columns" indicates containers which may have
|
||||
// bare content (without columns) and are allowed to have columns.
|
||||
// By extension, we only show the "None" option on elements that
|
||||
// were marked as such as they were allowed to have bare content in
|
||||
// the first place.
|
||||
return this.$target.is('.s_allow_columns');
|
||||
}
|
||||
return this._super(...arguments);
|
||||
},
|
||||
/**
|
||||
* Adds new columns which are clones of the last column or removes the
|
||||
* last x columns.
|
||||
|
||||
Reference in New Issue
Block a user