[FIX] web_editor: restore background videos (new imagepicker UI)

Commit [1] broke the background videos feature. This is because the
'we-imagepicker' widget is now a sub-widget of a new 'we-button-group'
widget, acting as a selection choice (same as we-button in a we-select).
When selecting a selection choice, the appropriate option method is
called, with the selection value and params... but the params were
actually the ones of the 'we-button-group' element and not the ones
of the chosen widget 'we-imagepicker'.

This has never been important for we-select widgets but it could have
been. The problem is only solved here in master, generically for all
selection widgets (currently only 'we-select' and 'we-button-group').
The params received are the ones of the active sub-widget combined with
the ones of the selection widget.

[1]: https://github.com/odoo/odoo/commit/bb0cd4d5c82a9c2311f8c45ced0e9fdc0397d292

closes odoo/odoo#54629

Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
This commit is contained in:
qsm-odoo
2020-07-17 08:45:06 +00:00
parent 31dd984bea
commit a30cc3402d
@@ -700,11 +700,19 @@ const BaseSelectionUserValueWidget = UserValueWidget.extend({
/**
* @override
*/
getValue(methodName) {
let activeWidget = this._userValueWidgets.find(widget => widget.isPreviewed());
getMethodsParams(methodName) {
const params = this._super(...arguments);
const activeWidget = this._getActiveSubWidget();
if (!activeWidget) {
activeWidget = this._userValueWidgets.find(widget => widget.isActive());
return params;
}
return Object.assign(activeWidget.getMethodsParams(...arguments), params);
},
/**
* @override
*/
getValue(methodName) {
const activeWidget = this._getActiveSubWidget();
if (activeWidget) {
return activeWidget.getActiveValue(methodName);
}
@@ -733,6 +741,22 @@ const BaseSelectionUserValueWidget = UserValueWidget.extend({
}
this._super(...arguments);
},
//--------------------------------------------------------------------------
// Private
//--------------------------------------------------------------------------
/**
* @private
* @returns {UserValueWidget|undefined}
*/
_getActiveSubWidget() {
const previewedWidget = this._userValueWidgets.find(widget => widget.isPreviewed());
if (previewedWidget) {
return previewedWidget;
}
return this._userValueWidgets.find(widget => widget.isActive());
},
});
const SelectUserValueWidget = BaseSelectionUserValueWidget.extend({