From cc560531b90057a50d9168cff2841cc14000f87c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9ry=20Debongnie?= Date: Fri, 24 Nov 2017 13:21:11 +0100 Subject: [FIX] web: better support for async field widgets Most field widgets are synchronous, but some of them have to do extra work before being ready (for example, the pad widget, or widget which needs to lazy load JS/CSS files). Because of that, the new views have been well tested with synchronous widgets, but not completely with async widgets. Some code depended upon the fact that the widget was ready immediately after being created. This was incorrect, and is fixed in this commit, by adding a new hook that is called in (basic) views after a widget is ready (meaning, start and willstart are done) --- addons/web/static/src/js/views/basic/basic_renderer.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'addons/web/static/src/js/views/basic/basic_renderer.js') 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 7b5cd87daaa..374479650d5 100644 --- a/addons/web/static/src/js/views/basic/basic_renderer.js +++ b/addons/web/static/src/js/views/basic/basic_renderer.js @@ -327,6 +327,17 @@ var BasicRenderer = AbstractRenderer.extend({ _hasContent: function () { return this.state.count !== 0; }, + /** + * This function is called each time a field widget is created, when it is + * ready (after its willStart and Start methods are complete). This is the + * place where work having to do with $el should be done. + * + * @private + * @param {Widget} widget the field widget instance + * @param {Object} node the attrs coming from the arch + */ + _postProcessField: function (widget, node) { + }, /** * Registers or updates the modifiers data associated to the given node. * This method is quiet complex as it handles all the needs of the basic @@ -495,6 +506,7 @@ var BasicRenderer = AbstractRenderer.extend({ )); }, }, modifiersOptions || {})); + self._postProcessField(widget, node); }); return widget; -- cgit v1.2.3