{ "version": 3, "sources": ["../../../../../apps/erpnext/erpnext/public/js/website_utils.js", "../../../../../apps/erpnext/erpnext/public/js/wishlist.js", "../../../../../apps/erpnext/erpnext/public/js/shopping_cart.js", "../../../../../apps/erpnext/erpnext/public/js/customer_reviews.js", "../../../../../apps/erpnext/erpnext/e_commerce/product_ui/list.js", "../../../../../apps/erpnext/erpnext/e_commerce/product_ui/views.js", "../../../../../apps/erpnext/erpnext/e_commerce/product_ui/grid.js", "../../../../../apps/erpnext/erpnext/e_commerce/product_ui/search.js"], "sourcesContent": ["// Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors\n// License: GNU General Public License v3. See license.txt\n\nif (!window.erpnext) window.erpnext = {};\n\n// Add / update a new Lead / Communication\n// subject, sender, description\nfrappe.send_message = function (opts, btn) {\n\treturn frappe.call({\n\t\ttype: \"POST\",\n\t\tmethod: \"erpnext.templates.utils.send_message\",\n\t\tbtn: btn,\n\t\targs: opts,\n\t\tcallback: opts.callback,\n\t});\n};\n\nerpnext.subscribe_to_newsletter = function (opts, btn) {\n\treturn frappe.call({\n\t\ttype: \"POST\",\n\t\tmethod: \"frappe.email.doctype.newsletter.newsletter.subscribe\",\n\t\tbtn: btn,\n\t\targs: { email: opts.email },\n\t\tcallback: opts.callback,\n\t});\n};\n\n// for backward compatibility\nerpnext.send_message = frappe.send_message;\n", "frappe.provide(\"erpnext.e_commerce.wishlist\");\nvar wishlist = erpnext.e_commerce.wishlist;\n\nfrappe.provide(\"erpnext.e_commerce.shopping_cart\");\nvar shopping_cart = erpnext.e_commerce.shopping_cart;\n\n$.extend(wishlist, {\n\tset_wishlist_count: function (animate = false) {\n\t\t// set badge count for wishlist icon\n\t\tvar wish_count = frappe.get_cookie(\"wish_count\");\n\t\tif (frappe.session.user === \"Guest\") {\n\t\t\twish_count = 0;\n\t\t}\n\n\t\tif (wish_count) {\n\t\t\t$(\".wishlist\").toggleClass(\"hidden\", false);\n\t\t}\n\n\t\tvar $wishlist = $(\".wishlist-icon\");\n\t\tvar $badge = $wishlist.find(\"#wish-count\");\n\n\t\tif (parseInt(wish_count) === 0 || wish_count === undefined) {\n\t\t\t$wishlist.css(\"display\", \"none\");\n\t\t} else {\n\t\t\t$wishlist.css(\"display\", \"inline\");\n\t\t}\n\t\tif (wish_count) {\n\t\t\t$badge.html(wish_count);\n\t\t\tif (animate) {\n\t\t\t\t$wishlist.addClass(\"cart-animate\");\n\t\t\t\tsetTimeout(() => {\n\t\t\t\t\t$wishlist.removeClass(\"cart-animate\");\n\t\t\t\t}, 500);\n\t\t\t}\n\t\t} else {\n\t\t\t$badge.remove();\n\t\t}\n\t},\n\n\tbind_move_to_cart_action: function () {\n\t\t// move item to cart from wishlist\n\t\t$(\".page_content\").on(\"click\", \".btn-add-to-cart\", (e) => {\n\t\t\tconst $move_to_cart_btn = $(e.currentTarget);\n\t\t\tlet item_code = $move_to_cart_btn.data(\"item-code\");\n\n\t\t\tshopping_cart.shopping_cart_update({\n\t\t\t\titem_code,\n\t\t\t\tqty: 1,\n\t\t\t\tcart_dropdown: true,\n\t\t\t});\n\n\t\t\tlet success_action = function () {\n\t\t\t\tconst $card_wrapper = $move_to_cart_btn.closest(\".wishlist-card\");\n\t\t\t\t$card_wrapper.addClass(\"wish-removed\");\n\t\t\t};\n\t\t\tlet args = { item_code: item_code };\n\t\t\tthis.add_remove_from_wishlist(\"remove\", args, success_action, null, true);\n\t\t});\n\t},\n\n\tbind_remove_action: function () {\n\t\t// remove item from wishlist\n\t\tlet me = this;\n\n\t\t$(\".page_content\").on(\"click\", \".remove-wish\", (e) => {\n\t\t\tconst $remove_wish_btn = $(e.currentTarget);\n\t\t\tlet item_code = $remove_wish_btn.data(\"item-code\");\n\n\t\t\tlet success_action = function () {\n\t\t\t\tconst $card_wrapper = $remove_wish_btn.closest(\".wishlist-card\");\n\t\t\t\t$card_wrapper.addClass(\"wish-removed\");\n\t\t\t\tif (frappe.get_cookie(\"wish_count\") == 0) {\n\t\t\t\t\t$(\".page_content\").empty();\n\t\t\t\t\tme.render_empty_state();\n\t\t\t\t}\n\t\t\t};\n\t\t\tlet args = { item_code: item_code };\n\t\t\tthis.add_remove_from_wishlist(\"remove\", args, success_action);\n\t\t});\n\t},\n\n\tbind_wishlist_action() {\n\t\t// 'wish'('like') or 'unwish' item in product listing\n\t\t$(\".page_content\").on(\"click\", \".like-action, .like-action-list\", (e) => {\n\t\t\tconst $btn = $(e.currentTarget);\n\t\t\tthis.wishlist_action($btn);\n\t\t});\n\t},\n\n\twishlist_action(btn) {\n\t\tconst $wish_icon = btn.find(\".wish-icon\");\n\t\tlet me = this;\n\n\t\tif (frappe.session.user === \"Guest\") {\n\t\t\tif (localStorage) {\n\t\t\t\tlocalStorage.setItem(\"last_visited\", window.location.pathname);\n\t\t\t}\n\t\t\tthis.redirect_guest();\n\t\t\treturn;\n\t\t}\n\n\t\tlet success_action = function () {\n\t\t\terpnext.e_commerce.wishlist.set_wishlist_count(true);\n\t\t};\n\n\t\tif ($wish_icon.hasClass(\"wished\")) {\n\t\t\t// un-wish item\n\t\t\tbtn.removeClass(\"like-animate\");\n\t\t\tbtn.addClass(\"like-action-wished\");\n\t\t\tthis.toggle_button_class($wish_icon, \"wished\", \"not-wished\");\n\n\t\t\tlet args = { item_code: btn.data(\"item-code\") };\n\t\t\tlet failure_action = function () {\n\t\t\t\tme.toggle_button_class($wish_icon, \"not-wished\", \"wished\");\n\t\t\t};\n\t\t\tthis.add_remove_from_wishlist(\"remove\", args, success_action, failure_action);\n\t\t} else {\n\t\t\t// wish item\n\t\t\tbtn.addClass(\"like-animate\");\n\t\t\tbtn.addClass(\"like-action-wished\");\n\t\t\tthis.toggle_button_class($wish_icon, \"not-wished\", \"wished\");\n\n\t\t\tlet args = { item_code: btn.data(\"item-code\") };\n\t\t\tlet failure_action = function () {\n\t\t\t\tme.toggle_button_class($wish_icon, \"wished\", \"not-wished\");\n\t\t\t};\n\t\t\tthis.add_remove_from_wishlist(\"add\", args, success_action, failure_action);\n\t\t}\n\t},\n\n\ttoggle_button_class(button, remove, add) {\n\t\tbutton.removeClass(remove);\n\t\tbutton.addClass(add);\n\t},\n\n\tadd_remove_from_wishlist(action, args, success_action, failure_action, async = false) {\n\t\t/*\tAJAX call to add or remove Item from Wishlist\n\t\t\taction: \"add\" or \"remove\"\n\t\t\targs: args for method (item_code, price, formatted_price),\n\t\t\tsuccess_action: method to execute on successs,\n\t\t\tfailure_action: method to execute on failure,\n\t\t\tasync: make call asynchronously (true/false).\t*/\n\t\tif (frappe.session.user === \"Guest\") {\n\t\t\tif (localStorage) {\n\t\t\t\tlocalStorage.setItem(\"last_visited\", window.location.pathname);\n\t\t\t}\n\t\t\tthis.redirect_guest();\n\t\t} else {\n\t\t\tlet method = \"erpnext.e_commerce.doctype.wishlist.wishlist.add_to_wishlist\";\n\t\t\tif (action === \"remove\") {\n\t\t\t\tmethod = \"erpnext.e_commerce.doctype.wishlist.wishlist.remove_from_wishlist\";\n\t\t\t}\n\n\t\t\tfrappe.call({\n\t\t\t\tasync: async,\n\t\t\t\ttype: \"POST\",\n\t\t\t\tmethod: method,\n\t\t\t\targs: args,\n\t\t\t\tcallback: function (r) {\n\t\t\t\t\tif (r.exc) {\n\t\t\t\t\t\tif (failure_action && typeof failure_action === \"function\") {\n\t\t\t\t\t\t\tfailure_action();\n\t\t\t\t\t\t}\n\t\t\t\t\t\tfrappe.msgprint({\n\t\t\t\t\t\t\tmessage: __(\"Sorry, something went wrong. Please refresh.\"),\n\t\t\t\t\t\t\tindicator: \"red\",\n\t\t\t\t\t\t\ttitle: __(\"Note\"),\n\t\t\t\t\t\t});\n\t\t\t\t\t} else if (success_action && typeof success_action === \"function\") {\n\t\t\t\t\t\tsuccess_action();\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t});\n\t\t}\n\t},\n\n\tredirect_guest() {\n\t\tfrappe.call(\"erpnext.e_commerce.api.get_guest_redirect_on_action\").then((res) => {\n\t\t\twindow.location.href = res.message || \"/login\";\n\t\t});\n\t},\n\n\trender_empty_state() {\n\t\t$(\".page_content\").append(`\n\t\t\t
\n\t\t\t\t\t\t\t\t${__(review.review_title)}\n\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t \n\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t${__(review.comment)}\n\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\n\t\t\t\t${item.item_group} | Item Code : ${item.item_code}\n\t\t\t
\n\t\t\t