From a3441cfb566f7274e049ec3eab803a909bd40f5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9ry=20Debongnie?= Date: Tue, 23 May 2017 17:20:43 +0200 Subject: [FIX] web: handle 'required' attribute in x2many+onchange Before doing an onchange in a x2many, the basic model tries to evaluate if the line is valid or not. In that computation, we used the field.required property instead of using the required modifier. This commit had to move the modifier handling from the BasicRenderer to the BasicModel, in order to use it in the _isX2ManyValid method. --- .../static/src/js/views/basic/basic_renderer.js | 22 ++-------------------- 1 file changed, 2 insertions(+), 20 deletions(-) (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 907ea7ddc07..2e36a4cac55 100644 --- a/addons/web/static/src/js/views/basic/basic_renderer.js +++ b/addons/web/static/src/js/views/basic/basic_renderer.js @@ -268,22 +268,6 @@ var BasicRenderer = AbstractRenderer.extend({ var modifiers = this._getEvaluatedModifiers(widget.__node, widget.record); return widget.isValid() && (widget.isSet() || !modifiers.required); }, - /** - * Updates the modifiers evaluation associated to a given modifiers data and - * a given record. This only updates the modifiers values. To see associated - * DOM updates: @see _updateAllModifiers @see _applyModifiers. - * - * @private - * @param {Object} modifiersData - * @param {Object} record - */ - _computeModifiers: function (modifiersData, record) { - var evalContext = record.evalContext; - modifiersData.evaluatedModifiers[record.id] - = _.mapObject(modifiersData.modifiers, function (modifier) { - return new Domain(modifier, evalContext).compute(evalContext); - }); - }, /** * Destroys a given widget associated to the given record and removes it * from internal referencing. @@ -342,7 +326,6 @@ var BasicRenderer = AbstractRenderer.extend({ * record. This allows nodes that will produce an AbstractField instance * to have their modifiers registered before this field creation as we * need the readonly modifier to be able to instantiate the AbstractField. - * (@see _computeModifiers). * * - On additional registrations, if the node was already registered but the * record is different, we evaluate the modifiers for this record and @@ -399,7 +382,7 @@ var BasicRenderer = AbstractRenderer.extend({ // Evaluate if necessary if (!modifiersData.evaluatedModifiers[record.id]) { - this._computeModifiers(modifiersData, record); + modifiersData.evaluatedModifiers[record.id] = record.evalModifiers(modifiersData.modifiers); } // Element might not be given yet (a second call to the function can @@ -569,7 +552,6 @@ var BasicRenderer = AbstractRenderer.extend({ * 2) Updates the rendering of the view elements associated to the given * record to match the new modifiers. * - * @see _computeModifiers * @see _applyModifiers * * @private @@ -582,7 +564,7 @@ var BasicRenderer = AbstractRenderer.extend({ var defs = []; this.defs = defs; // Potentially filled by widget rerendering _.each(this.allModifiersData, function (modifiersData) { - self._computeModifiers(modifiersData, record); + modifiersData.evaluatedModifiers[record.id] = record.evalModifiers(modifiersData.modifiers); self._applyModifiers(modifiersData, record); }); delete this.defs; -- cgit v1.2.3 From dcde0aaf30fa52f59341edb274bab02e8e9aea88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9ry=20Debongnie?= Date: Fri, 26 May 2017 11:36:00 +0200 Subject: [FIX] web: recompute decoration classnames when necesssary Before this commit, row decorations were only computed at the initial rendering for a list view, then never recomputed. Most of the time, it is not an issue, but list view can be edited, and in that case, it may be a problem. With this commit, we just override the confirmChange method to recompute the various decorations. Note that in bonus, decorations now works in realtime, when editing a list view (in saas-15, they simply did not work when editing a record) Also, we now use the same evaluation context as everything else in the web client: the eval context from the record, not some custom handmade context like before. --- addons/web/static/src/js/views/basic/basic_renderer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (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 2e36a4cac55..8bbf9ae45a4 100644 --- a/addons/web/static/src/js/views/basic/basic_renderer.js +++ b/addons/web/static/src/js/views/basic/basic_renderer.js @@ -91,7 +91,7 @@ var BasicRenderer = AbstractRenderer.extend({ var record = state.id === id ? state : _.findWhere(state.data, {id: id}); if (!record) { - return this._render(); + return this._render().then(_.constant([])); } var defs = []; -- cgit v1.2.3