diff options
| author | qsm-odoo <qsm@odoo.com> | 2020-08-06 15:56:39 +0000 |
|---|---|---|
| committer | qsm-odoo <qsm@odoo.com> | 2020-08-07 08:51:23 +0000 |
| commit | 315ba1cfeb737c378ee6828cc6f612f1ab91fa71 (patch) | |
| tree | 8b62494370bf610171d20de1a77bc2e515de605c /addons/website/static/src/js | |
| parent | 7385ac9e41e051b72a8597db6cc6f0d9df9d62b6 (diff) | |
[IMP] web_editor, *: simplify UserValueWidget updates
*: website
Before this commit, editor widgets were updated by 3 successive calls
to methods 'setValue', 'updateUI' and '_updateUI'. The last two were
in charge of updating the UI depending of the value that was set, only
in specific condition (like "if the widget is not focused", "or not
previewed", ...).
This is now in fact useless: 'setValue' can be in charge of the UI
update. Indeed, when a value is set on a widget there is no reason to
not update its UI anymore. This was useful when the UI was updated on
preview, which is not the case anymore. This could also be useful for
widget with multiple options attached to them... but in those rare cases
updating the UI multiple times (one time per option method) should not
be a problem.
Part of https://github.com/odoo/odoo/pull/55588
Diffstat (limited to 'addons/website/static/src/js')
| -rw-r--r-- | addons/website/static/src/js/editor/snippets.options.js | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/addons/website/static/src/js/editor/snippets.options.js b/addons/website/static/src/js/editor/snippets.options.js index 552c53ccd18..be7a55f8111 100644 --- a/addons/website/static/src/js/editor/snippets.options.js +++ b/addons/website/static/src/js/editor/snippets.options.js @@ -113,13 +113,13 @@ const FontFamilyPickerUserValueWidget = SelectUserValueWidget.extend({ }, //-------------------------------------------------------------------------- - // Private + // Public //-------------------------------------------------------------------------- /** * @override */ - _updateUI: async function () { + async setValue() { await this._super(...arguments); for (const className of this.menuTogglerEl.classList) { @@ -269,15 +269,10 @@ const GPSPicker = InputUserValueWidget.extend({ getMethodsParams: function (methodName) { return Object.assign({gmapPlace: this._gmapPlace || {}}, this._super(...arguments)); }, - - //-------------------------------------------------------------------------- - // Private - //-------------------------------------------------------------------------- - /** * @override */ - _updateUI: async function () { + async setValue() { await this._super(...arguments); await new Promise(resolve => { @@ -320,6 +315,7 @@ const GPSPicker = InputUserValueWidget.extend({ }); this.inputEl.value = this._gmapPlace.formatted_address; }, + //-------------------------------------------------------------------------- // Handlers //-------------------------------------------------------------------------- |
