diff options
| author | David Monjoie <dmo@odoo.com> | 2017-04-13 14:11:03 +0200 |
|---|---|---|
| committer | David Monjoie <dmo@odoo.com> | 2017-05-02 15:24:54 +0200 |
| commit | e02cee4ea694d9a1f85db8c6c2286ea0480298aa (patch) | |
| tree | 7053c7336197efe6cdf3da0b806c212262a41a10 /addons/web/static/src | |
| parent | 4e4c89969c88c1b4d1fd4814b54b80ae2312e8a3 (diff) | |
[FIX] web: fix missing idForLabel on some widgets
Widgets which manipulates their dom in _renderEdit were left out
from the previous implementation since this processing was done
only once when the widget is rendered the first time. If the
widget regenerates a new input upon reset for example, then it
would lack the idForLabel.
Diffstat (limited to 'addons/web/static/src')
| -rw-r--r-- | addons/web/static/src/js/views/form/form_renderer.js | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/addons/web/static/src/js/views/form/form_renderer.js b/addons/web/static/src/js/views/form/form_renderer.js index 75c2b987a8f..20244f12e95 100644 --- a/addons/web/static/src/js/views/form/form_renderer.js +++ b/addons/web/static/src/js/views/form/form_renderer.js @@ -53,6 +53,23 @@ var FormRenderer = BasicRenderer.extend({ return fieldNames; }, /** + * @see BasicRenderer.confirmChange + * + * We need to reapply the idForLabel postprocessing since some widgets may + * have recomputed their dom entirely. + * + * @override + */ + confirmChange: function (state, id, fields, e) { + var self = this; + return this._super.apply(this, arguments).then(function (resetWidgets) { + _.each(resetWidgets, function (widget) { + self._setIDForLabel(widget, self.idsForLabels[widget.name]); + }); + return resetWidgets + }); + }, + /** * returns the active tab pages for each notebook * * @todo currently, this method is unused... @@ -256,7 +273,7 @@ var FormRenderer = BasicRenderer.extend({ }, modifiersOptions || {}); var widget = this._super(node, record, options, modifiersOptions); - widget.getFocusableElement().attr('id', this._getIDForLabel(node.attrs.name)); + this._setIDForLabel(widget, this._getIDForLabel(node.attrs.name)); widget.$el.addClass(FIELD_CLASSES[record.fields[node.attrs.name].type]); this._addFieldClassNames(widget); @@ -730,6 +747,16 @@ var FormRenderer = BasicRenderer.extend({ focusWidget.activate(true); } }, + /** + * Sets id attribute of given widget to idForLabel + * + * @private + * @param {AbstractField} widget + * @param {idForLabel} string + */ + _setIDForLabel: function (widget, idForLabel) { + widget.getFocusableElement().attr('id', idForLabel); + }, //-------------------------------------------------------------------------- // Handlers |
