Merge pull request #15227 from surajshetty3416/fixes-and-improvements

Remove occurrences of hub_item_code and replace some hub_item_code -> hub_item_name
diff --git a/erpnext/public/js/hub/components/item_card.js b/erpnext/public/js/hub/components/item_card.js
index fdf2690..41ab33a 100644
--- a/erpnext/public/js/hub/components/item_card.js
+++ b/erpnext/public/js/hub/components/item_card.js
@@ -7,7 +7,7 @@
 	const content = strip_html(message.content)
 
 	// route
-	item.route = `marketplace/buying/${item.hub_item_code}`
+	item.route = `marketplace/buying/${item.name}`
 
 	const item_html = `
 		<div class="col-md-7">
@@ -38,7 +38,7 @@
 
 	// route
 	if (!item.route) {
-		item.route = `marketplace/item/${item.hub_item_code}`
+		item.route = `marketplace/item/${item.name}`
 	}
 
 	let received_messages = '';
diff --git a/erpnext/public/js/hub/pages/BuyingMessages.vue b/erpnext/public/js/hub/pages/BuyingMessages.vue
index 63a746a..6f1a4c5 100644
--- a/erpnext/public/js/hub/pages/BuyingMessages.vue
+++ b/erpnext/public/js/hub/pages/BuyingMessages.vue
@@ -47,8 +47,8 @@
 		}
 	},
 	created() {
-		const hub_item_code = this.get_hub_item_code();
-		this.get_item_details(hub_item_code)
+		const hub_item_name = this.get_hub_item_name();
+		this.get_item_details(hub_item_name)
 			.then(item_details => {
 				this.item_details = item_details;
 				this.get_messages(item_details)
@@ -68,21 +68,21 @@
 			hub.call('send_message', {
 				from_seller: hub.settings.company_email,
 				to_seller: this.item_details.hub_seller,
-				hub_item: this.item_details.hub_item_code,
+				hub_item: this.item_details.name,
 				message
 			});
 		},
-		get_item_details(hub_item_code) {
-			return hub.call('get_item_details', { hub_item_code })
+		get_item_details(hub_item_name) {
+			return hub.call('get_item_details', { hub_item_name })
 		},
 		get_messages() {
 			if (!this.item_details) return [];
 			return hub.call('get_messages', {
 				against_seller: this.item_details.hub_seller,
-				against_item: this.item_details.hub_item_code
+				against_item: this.item_details.name
 			});
 		},
-		get_hub_item_code() {
+		get_hub_item_name() {
 			return frappe.get_route()[2];
 		}
 	}
diff --git a/erpnext/public/js/hub/pages/Category.vue b/erpnext/public/js/hub/pages/Category.vue
index 2a521f4..c11972d 100644
--- a/erpnext/public/js/hub/pages/Category.vue
+++ b/erpnext/public/js/hub/pages/Category.vue
@@ -29,7 +29,7 @@
 			page_name: frappe.get_route()[1],
 			category: frappe.get_route()[2],
 			items: [],
-			item_id_fieldname: 'hub_item_code',
+			item_id_fieldname: 'name',
 
 			// Constants
 			empty_state_message: __(`No products in this category yet.`)
@@ -55,8 +55,8 @@
 			})
 		},
 
-		go_to_item_details_page(hub_item_code) {
-			frappe.set_route(`marketplace/item/${hub_item_code}`);
+		go_to_item_details_page(hub_item_name) {
+			frappe.set_route(`marketplace/item/${hub_item_name}`);
 		}
 	}
 }
diff --git a/erpnext/public/js/hub/pages/Home.vue b/erpnext/public/js/hub/pages/Home.vue
index 1d1973c..d09058d 100644
--- a/erpnext/public/js/hub/pages/Home.vue
+++ b/erpnext/public/js/hub/pages/Home.vue
@@ -41,7 +41,7 @@
 	data() {
 		return {
 			page_name: frappe.get_route()[1],
-			item_id_fieldname: 'hub_item_code',
+			item_id_fieldname: 'name',
 			search_value: '',
 
 			sections: [],
@@ -87,8 +87,8 @@
 			})
 		},
 
-		go_to_item_details_page(hub_item_code) {
-			frappe.set_route(`marketplace/item/${hub_item_code}`);
+		go_to_item_details_page(hub_item_name) {
+			frappe.set_route(`marketplace/item/${hub_item_name}`);
 		},
 
 		set_search_route() {
diff --git a/erpnext/public/js/hub/pages/PublishedProducts.vue b/erpnext/public/js/hub/pages/PublishedProducts.vue
index db9057d..586d701 100644
--- a/erpnext/public/js/hub/pages/PublishedProducts.vue
+++ b/erpnext/public/js/hub/pages/PublishedProducts.vue
@@ -28,7 +28,7 @@
 		return {
 			page_name: frappe.get_route()[1],
 			items: [],
-			item_id_fieldname: 'hub_item_code',
+			item_id_fieldname: 'name',
 
 			// Constants
 			page_title: __('Published Products'),
@@ -51,8 +51,8 @@
 			})
 		},
 
-		go_to_item_details_page(hub_item_code) {
-			frappe.set_route(`marketplace/item/${hub_item_code}`);
+		go_to_item_details_page(hub_item_name) {
+			frappe.set_route(`marketplace/item/${hub_item_name}`);
 		}
 	}
 }
diff --git a/erpnext/public/js/hub/pages/SavedProducts.vue b/erpnext/public/js/hub/pages/SavedProducts.vue
index f113a20..e83bfd5 100644
--- a/erpnext/public/js/hub/pages/SavedProducts.vue
+++ b/erpnext/public/js/hub/pages/SavedProducts.vue
@@ -27,7 +27,7 @@
 		return {
 			page_name: frappe.get_route()[1],
 			items: [],
-			item_id_fieldname: 'hub_item_code',
+			item_id_fieldname: 'name',
 
 			// Constants
 			page_title: __('Saved Products'),
@@ -54,23 +54,23 @@
 			})
 		},
 
-		go_to_item_details_page(hub_item_code) {
-			frappe.set_route(`marketplace/item/${hub_item_code}`);
+		go_to_item_details_page(hub_item_name) {
+			frappe.set_route(`marketplace/item/${hub_item_name}`);
 		},
 
-		on_item_remove(hub_item_code) {
+		on_item_remove(hub_item_name) {
 			const grace_period = 5000;
 			let reverted = false;
 			let alert;
 
 			const undo_remove = () => {
-				this.toggle_item(hub_item_code);;
+				this.toggle_item(hub_item_name);;
 				reverted = true;
 				alert.hide();
 				return false;
 			}
 
-			alert = frappe.show_alert(__(`<span>${hub_item_code} removed.
+			alert = frappe.show_alert(__(`<span>${hub_item_name} removed.
 				<a href="#" data-action="undo-remove"><b>Undo</b></a></span>`),
 				grace_period/1000,
 				{
@@ -78,19 +78,19 @@
 				}
 			);
 
-			this.toggle_item(hub_item_code, false);
+			this.toggle_item(hub_item_name, false);
 
 			setTimeout(() => {
 				if(!reverted) {
-					this.remove_item_from_saved_products(hub_item_code);
+					this.remove_item_from_saved_products(hub_item_name);
 				}
 			}, grace_period);
 		},
 
-		remove_item_from_saved_products(hub_item_code) {
+		remove_item_from_saved_products(hub_item_name) {
 			erpnext.hub.trigger('action:item_favourite');
 			hub.call('remove_item_from_seller_favourites', {
-				hub_item_code,
+				hub_item_name,
 				hub_seller: hub.settings.company_email
 			})
 			.then(() => {
@@ -102,9 +102,9 @@
 		},
 
 		// By default show
-		toggle_item(hub_item_code, show=true) {
+		toggle_item(hub_item_name, show=true) {
 			this.items = this.items.map(item => {
-				if(item.hub_item_code === hub_item_code) {
+				if(item.name === hub_item_name) {
 					item.seen = show;
 				}
 				return item;
diff --git a/erpnext/public/js/hub/pages/Search.vue b/erpnext/public/js/hub/pages/Search.vue
index a7fbffc..b9ddc0d 100644
--- a/erpnext/public/js/hub/pages/Search.vue
+++ b/erpnext/public/js/hub/pages/Search.vue
@@ -38,7 +38,7 @@
 			page_name: frappe.get_route()[1],
 			items: [],
 			search_value: frappe.get_route()[2],
-			item_id_fieldname: 'hub_item_code',
+			item_id_fieldname: 'name',
 
 			// Constants
 			search_placeholder: __('Search for anything ...'),
@@ -68,8 +68,8 @@
 			this.get_items();
 		},
 
-		go_to_item_details_page(hub_item_code) {
-			frappe.set_route(`marketplace/item/${hub_item_code}`);
+		go_to_item_details_page(hub_item_name) {
+			frappe.set_route(`marketplace/item/${hub_item_name}`);
 		}
 	}
 }
diff --git a/erpnext/public/js/hub/pages/Seller.vue b/erpnext/public/js/hub/pages/Seller.vue
index 5a35812..04c9de1 100644
--- a/erpnext/public/js/hub/pages/Seller.vue
+++ b/erpnext/public/js/hub/pages/Seller.vue
@@ -43,7 +43,7 @@
 
 			profile: null,
 			items:[],
-			item_id_fieldname: 'hub_item_code',
+			item_id_fieldname: 'name',
 
 			title: null,
 			subtitles: [],
@@ -89,8 +89,8 @@
 			});
 		},
 
-		go_to_item_details_page(hub_item_code) {
-			frappe.set_route(`marketplace/item/${hub_item_code}`);
+		go_to_item_details_page(hub_item_name) {
+			frappe.set_route(`marketplace/item/${hub_item_name}`);
 		}
 	}
 }
diff --git a/erpnext/public/js/hub/pages/item.js b/erpnext/public/js/hub/pages/item.js
index f15d1be..c77f57b 100644
--- a/erpnext/public/js/hub/pages/item.js
+++ b/erpnext/public/js/hub/pages/item.js
@@ -6,11 +6,11 @@
 erpnext.hub.Item = class Item extends SubPage {
 	refresh() {
 		this.show_skeleton();
-		this.hub_item_code = frappe.get_route()[2];
+		this.hub_item_name = frappe.get_route()[2];
 
 		this.own_item = false;
 
-		this.get_item(this.hub_item_code)
+		this.get_item(this.hub_item_name)
 			.then(item => {
 				this.own_item = item.hub_seller === hub.settings.company_email;
 				this.item = item;
@@ -24,9 +24,9 @@
 	}
 
 
-	get_item(hub_item_code) {
+	get_item(hub_item_name) {
 		return hub.call('get_item_details', {
-			hub_item_code
+			hub_item_name
 		});
 	}
 
@@ -72,7 +72,7 @@
 		$(favourite_button).addClass('disabled');
 
 		hub.call('add_item_to_seller_favourites', {
-			hub_item_code: this.hub_item_code,
+			hub_item_name: this.hub_item_name,
 			hub_seller: hub.settings.company_email
 		})
 			.then(() => {
@@ -108,12 +108,12 @@
 				hub.call('send_message', {
 					from_seller: hub.settings.company_email,
 					to_seller: this.item.hub_seller,
-					hub_item: this.item.hub_item_code,
+					hub_item: this.item.hub_item_name,
 					message
 				})
 					.then(() => {
 						d.hide();
-						frappe.set_route('marketplace', 'buy', this.item.hub_item_code);
+						frappe.set_route('marketplace', 'buy', this.item.hub_item_name);
 						erpnext.hub.trigger('action:send_message')
 					});
 			}
@@ -145,7 +145,7 @@
 		values.username = frappe.session.user_fullname;
 
 		hub.call('add_item_review', {
-			hub_item_code: this.hub_item_code,
+			hub_item_name: this.hub_item_name,
 			review: JSON.stringify(values)
 		})
 		.then(this.push_review_in_review_area.bind(this));
@@ -162,7 +162,7 @@
 
 
 	get_reviews() {
-		return hub.call('get_item_reviews', { hub_item_code: this.hub_item_code }).catch(() => {});
+		return hub.call('get_item_reviews', { hub_item_name: this.hub_item_name }).catch(() => {});
 	}