From 86897ca167338ca434e62827fa09f44ddbce324c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9ry=20Debongnie?= Date: Wed, 11 Apr 2018 10:36:25 +0200 Subject: [PATCH] [REF] web: remove updateModifiersValue from widget The keyboard shortcut branch recently added a method updateModifiersValue on the widget class, which is used to make a widget aware of its modifier status (in particular, if it is required). This is necessary for the proper navigation behaviour on field widgets, but should not be on the widget class. The proper fix is, in my opinion, to introduce a AbstractViewWidget class which would be used for AbstractField and all custom widgets in views. Meanwhile, this commit simply protects the call to that method. This is a refactoring, but can be merged in saas-11.3. --- addons/web/static/src/js/core/widget.js | 10 ---------- addons/web/static/src/js/views/basic/basic_renderer.js | 2 +- 2 files changed, 1 insertion(+), 11 deletions(-) diff --git a/addons/web/static/src/js/core/widget.js b/addons/web/static/src/js/core/widget.js index bd868596546..5e23c3f2c47 100644 --- a/addons/web/static/src/js/core/widget.js +++ b/addons/web/static/src/js/core/widget.js @@ -284,16 +284,6 @@ var Widget = core.Class.extend(mixins.PropertiesMixin, ServicesMixin, { return this; }, - - /** - * Update the modifiers with the newest value. - * Now this.attrs.modifiersValue can be used consistantly even with - * conditional modifiers - * - * @param {Object} modifiers the updated modifiers - */ - updateModifiersValue: function(modifiers) { - }, //-------------------------------------------------------------------------- // Private diff --git a/addons/web/static/src/js/views/basic/basic_renderer.js b/addons/web/static/src/js/views/basic/basic_renderer.js index 55a6c7a6c94..80cdd05bff5 100644 --- a/addons/web/static/src/js/views/basic/basic_renderer.js +++ b/addons/web/static/src/js/views/basic/basic_renderer.js @@ -278,7 +278,7 @@ var BasicRenderer = AbstractRenderer.extend({ element.$el.toggleClass("o_readonly_modifier", !!modifiers.readonly); element.$el.toggleClass("o_required_modifier", !!modifiers.required); - if (element.widget) { + if (element.widget && element.widget.updateModifiersValue) { element.widget.updateModifiersValue(modifiers); }