From a5a86c4d1149f0b34f2d9eb4cdfea6e27437424b Mon Sep 17 00:00:00 2001 From: Romain Derie Date: Fri, 12 Oct 2018 15:16:49 +0000 Subject: [PATCH] [FIX] website_sale_wishlist: prevent product to be added more than once The add to wishlist button will only be disabled once the RPC gets back to the client. Thus, the button being grayed out will occur depending of the connection speed. If the RPC does not get back almost instantaneous, the user will be able to click multiple times on the button and add the product more than once. This commit fixes that behavior by disabling the button when the user click on it. Closes #27489, closes #27735 --- .../static/src/js/website_sale_wishlist.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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 295d1382f1d..60557854b62 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 @@ -62,6 +62,7 @@ sAnimations.registry.ProductWishlist = sAnimations.Class.extend(ProductConfigura productID = parseInt(productID, 10); } + $el.prop("disabled", true).addClass('disabled'); var productReady = this.selectOrCreateProduct( $el.closest('form'), productID, @@ -82,9 +83,12 @@ sAnimations.registry.ProductWishlist = sAnimations.Class.extend(ProductConfigura self.wishlistProductIDs.push(productId); self._updateWishlistView(); wSaleUtils.animateClone($('#my_wish'), $el.closest('form'), 25, 40); - $el.prop("disabled", true).addClass('disabled'); + }).fail(function () { + $el.prop("disabled", false).removeClass('disabled'); }); } + }).fail(function () { + $el.prop("disabled", false).removeClass('disabled'); }); }, /**