[IMP] web_editor, *: allow editor widgets to depend on ancestor ones
*: website The visibility dependencies are now searched in the current SnippetEditor instance but also in all its ancestors. Part of https://github.com/odoo/odoo/pull/68149 task-2368576 Part-of: odoo/odoo#68149
This commit is contained in:
@@ -1061,14 +1061,17 @@ var SnippetEditor = Widget.extend({
|
||||
* @param {Event} ev
|
||||
*/
|
||||
_onUserValueWidgetRequest: function (ev) {
|
||||
ev.stopPropagation();
|
||||
for (const key of Object.keys(this.styles)) {
|
||||
const widget = this.styles[key].findWidget(ev.data.name);
|
||||
if (widget) {
|
||||
ev.stopPropagation();
|
||||
ev.data.onSuccess(widget);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (!ev.data.allowParentOption) {
|
||||
ev.stopPropagation();
|
||||
}
|
||||
},
|
||||
/**
|
||||
* Called when the 'mouse wheel' is used when hovering over the overlay.
|
||||
|
||||
@@ -3364,7 +3364,7 @@ const SnippetOptionWidget = Widget.extend({
|
||||
depName = depName.substr(1);
|
||||
}
|
||||
|
||||
const widget = this._requestUserValueWidgets(depName)[0];
|
||||
const widget = this._requestUserValueWidgets(depName, true)[0];
|
||||
if (widget) {
|
||||
dependenciesData.push({
|
||||
widget: widget,
|
||||
@@ -3719,15 +3719,25 @@ const SnippetOptionWidget = Widget.extend({
|
||||
/**
|
||||
* @private
|
||||
* @param {...string} widgetNames
|
||||
* @param {boolean} [allowParentOption=false]
|
||||
* @returns {UserValueWidget[]}
|
||||
*/
|
||||
_requestUserValueWidgets: function (...widgetNames) {
|
||||
_requestUserValueWidgets: function (...args) {
|
||||
const widgetNames = args;
|
||||
let allowParentOption = false;
|
||||
const lastArg = args[args.length - 1];
|
||||
if (typeof lastArg === 'boolean') {
|
||||
widgetNames.pop();
|
||||
allowParentOption = lastArg;
|
||||
}
|
||||
|
||||
const widgets = [];
|
||||
for (const widgetName of widgetNames) {
|
||||
let widget = null;
|
||||
this.trigger_up('user_value_widget_request', {
|
||||
name: widgetName,
|
||||
onSuccess: _widget => widget = _widget,
|
||||
allowParentOption: allowParentOption,
|
||||
});
|
||||
if (widget) {
|
||||
widgets.push(widget);
|
||||
|
||||
@@ -2686,11 +2686,7 @@ options.registry.CoverProperties = options.Class.extend({
|
||||
this.$target[0].dataset.coverClass = coverClass;
|
||||
this.$target[0].dataset.textAlignClass = this.$el.find('[data-cover-opt-name="text_align"] we-button.active').data('selectClass') || '';
|
||||
this.$target[0].dataset.filterValue = this.$filterValueOpts.filter('.active').data('filterValue') || 0.0;
|
||||
let colorPickerWidget = null;
|
||||
this.trigger_up('user_value_widget_request', {
|
||||
name: 'bg_color_opt',
|
||||
onSuccess: _widget => colorPickerWidget = _widget,
|
||||
});
|
||||
const colorPickerWidget = this._requestUserValueWidgets('bg_color_opt')[0];
|
||||
// TODO there is probably a better way and this should be refactored to
|
||||
// use more standard colorpicker+imagepicker structure
|
||||
const ccValue = colorPickerWidget._ccValue;
|
||||
|
||||
Reference in New Issue
Block a user