From e652ab5f05d395a9cb56d2045cda599cae9a8dff Mon Sep 17 00:00:00 2001 From: Suraj Shetty Date: Thu, 3 Feb 2022 20:06:24 +0530 Subject: [PATCH 1/2] fix: Load control & dialog assets with cart.js Previously, control & dialog assets were getting loaded only on visiting "/cart", but since cart.js sets up various events on homepage, dialog related assets are required up-front. --- erpnext/public/js/cart.js | 3 ++- erpnext/templates/pages/cart.html | 2 -- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/erpnext/public/js/cart.js b/erpnext/public/js/cart.js index 69357ee6ef..14a5ac3a4c 100644 --- a/erpnext/public/js/cart.js +++ b/erpnext/public/js/cart.js @@ -1,6 +1,7 @@ // Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors // License: GNU General Public License v3. See license.txt - +import "../../../../frappe/frappe/public/js/controls.bundle"; +import "../../../../frappe/frappe/public/js/dialog.bundle"; // js inside blog page // shopping cart diff --git a/erpnext/templates/pages/cart.html b/erpnext/templates/pages/cart.html index 2b7d9e3523..89bc2993b7 100644 --- a/erpnext/templates/pages/cart.html +++ b/erpnext/templates/pages/cart.html @@ -127,6 +127,4 @@ {% block base_scripts %} {{ include_script("frappe-web.bundle.js") }} -{{ include_script("controls.bundle.js") }} -{{ include_script("dialog.bundle.js") }} {% endblock %} From 017a882f9051bf4099a213ab1fd09dcf144d5ea8 Mon Sep 17 00:00:00 2001 From: marination Date: Thu, 3 Feb 2022 21:34:48 +0530 Subject: [PATCH 2/2] fix: Remove `cart.js` from erpnext-web bundle - Due to it being in the bundle, controls bundle was required for Dialogs used in cart - But this is exclusively used in `cart.html` - It has no reason to load and break the login page - Moved it back to where the html is, it is now back to being tightly coupled with its html --- erpnext/public/js/erpnext-web.bundle.js | 1 - erpnext/templates/pages/cart.html | 2 ++ erpnext/{public/js => templates/pages}/cart.js | 5 +---- 3 files changed, 3 insertions(+), 5 deletions(-) rename erpnext/{public/js => templates/pages}/cart.js (98%) diff --git a/erpnext/public/js/erpnext-web.bundle.js b/erpnext/public/js/erpnext-web.bundle.js index 576abd2686..cbe899dc06 100644 --- a/erpnext/public/js/erpnext-web.bundle.js +++ b/erpnext/public/js/erpnext-web.bundle.js @@ -1,7 +1,6 @@ import "./website_utils"; import "./wishlist"; import "./shopping_cart"; -import "./cart"; import "./customer_reviews"; import "../../e_commerce/product_ui/list"; import "../../e_commerce/product_ui/views"; diff --git a/erpnext/templates/pages/cart.html b/erpnext/templates/pages/cart.html index 89bc2993b7..2b7d9e3523 100644 --- a/erpnext/templates/pages/cart.html +++ b/erpnext/templates/pages/cart.html @@ -127,4 +127,6 @@ {% block base_scripts %} {{ include_script("frappe-web.bundle.js") }} +{{ include_script("controls.bundle.js") }} +{{ include_script("dialog.bundle.js") }} {% endblock %} diff --git a/erpnext/public/js/cart.js b/erpnext/templates/pages/cart.js similarity index 98% rename from erpnext/public/js/cart.js rename to erpnext/templates/pages/cart.js index 14a5ac3a4c..fb2d159dcf 100644 --- a/erpnext/public/js/cart.js +++ b/erpnext/templates/pages/cart.js @@ -1,10 +1,7 @@ // Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors // License: GNU General Public License v3. See license.txt -import "../../../../frappe/frappe/public/js/controls.bundle"; -import "../../../../frappe/frappe/public/js/dialog.bundle"; -// js inside blog page -// shopping cart +// JS exclusive to /cart page frappe.provide("erpnext.e_commerce.shopping_cart"); var shopping_cart = erpnext.e_commerce.shopping_cart;