From a74169bb09a7c3089fd36ebec866555cf04a2a75 Mon Sep 17 00:00:00 2001 From: Vincent Schippefilt Date: Wed, 6 Mar 2019 14:02:38 +0100 Subject: [PATCH] [REF] website_sale_wishlist: adapt code after jQuery update Part of task 1896658 Co-authored-by: Aaron Bohy Co-authored-by: Christophe Matthieu Co-authored-by: Mathieu Duckerts-Antoine Co-authored-by: David Monjoie Co-authored-by: Martin Geubelle Co-authored-by: svs-odoo Co-authored-by: Vincent Schippefilt --- .../static/src/js/website_sale_wishlist.js | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/addons/website_sale_wishlist/static/src/js/website_sale_wishlist.js b/addons/website_sale_wishlist/static/src/js/website_sale_wishlist.js index 59172ac6457..53f821c28c1 100644 --- a/addons/website_sale_wishlist/static/src/js/website_sale_wishlist.js +++ b/addons/website_sale_wishlist/static/src/js/website_sale_wishlist.js @@ -42,7 +42,7 @@ publicWidget.registry.ProductWishlist = publicWidget.Widget.extend(ProductConfig self.wishlistProductIDs = JSON.parse(res); }); - return $.when(def, wishDef); + return Promise.all([def, wishDef]); }, /** * Updates the wishlist view (navbar) & the wishlist button (product page). @@ -95,7 +95,7 @@ publicWidget.registry.ProductWishlist = publicWidget.Widget.extend(ProductConfig false ); - productReady.done(function (productId) { + productReady.then(function (productId) { productId = parseInt(productId, 10); if (productId && !_.contains(self.wishlistProductIDs, productId)) { @@ -108,11 +108,11 @@ publicWidget.registry.ProductWishlist = publicWidget.Widget.extend(ProductConfig self.wishlistProductIDs.push(productId); self._updateWishlistView(); wSaleUtils.animateClone($('#my_wish'), $el.closest('form'), 25, 40); - }).fail(function () { + }).guardedCatch(function () { $el.prop("disabled", false).removeClass('disabled'); }); } - }).fail(function () { + }).guardedCatch(function () { $el.prop("disabled", false).removeClass('disabled'); }); }, @@ -138,16 +138,17 @@ publicWidget.registry.ProductWishlist = publicWidget.Widget.extend(ProductConfig this._rpc({ route: '/shop/wishlist/remove/' + wish, - }).done(function () { + }).then(function () { $(tr).hide(); }); this.wishlistProductIDs = _.without(this.wishlistProductIDs, product); if (this.wishlistProductIDs.length === 0) { - deferred_redirect = deferred_redirect ? deferred_redirect : $.Deferred(); - deferred_redirect.then(function () { - self._redirectNoWish(); - }); + if (deferred_redirect) { + deferred_redirect.then(function () { + self._redirectNoWish(); + }); + } } this._updateWishlistView(); },