Merge branch 'hub-redesign' of https://github.com/frappe/erpnext into hub-redesign
diff --git a/erpnext/public/js/hub/components/DetailView.vue b/erpnext/public/js/hub/components/DetailView.vue
index 0e9e3f2..70ec94c 100644
--- a/erpnext/public/js/hub/components/DetailView.vue
+++ b/erpnext/public/js/hub/components/DetailView.vue
@@ -28,7 +28,7 @@
<div class="row margin-bottom">
<div class="col-md-3">
<div class="hub-item-image">
- <img :src="image">
+ <img v-img-src="image">
</div>
</div>
<div class="col-md-8">
diff --git a/erpnext/public/js/hub/pages/Item.vue b/erpnext/public/js/hub/pages/Item.vue
index 74a4647..48fde20 100644
--- a/erpnext/public/js/hub/pages/Item.vue
+++ b/erpnext/public/js/hub/pages/Item.vue
@@ -55,6 +55,11 @@
menu_items: [
{
+ label: __('Save Item'),
+ condition: !this.is_own_item,
+ action: this.add_to_saved_items
+ },
+ {
label: __('Report this Product'),
condition: !this.is_own_item,
action: this.report_item
@@ -127,11 +132,29 @@
}
},
created() {
- this.get_profile();
+ this.get_item_details();
+ },
+ mounted() {
+ // To record a single view per session, (later)
+ // erpnext.hub.item_view_cache = erpnext.hub.item_view_cache || [];
+ // if (erpnext.hub.item_view_cache.includes(this.hub_item_name)) {
+ // return;
+ // }
+
+ this.item_received.then(() => {
+ setTimeout(() => {
+ hub.call('add_item_view', {
+ hub_item_name: this.hub_item_name
+ })
+ // .then(() => {
+ // erpnext.hub.item_view_cache.push(this.hub_item_name);
+ // });
+ }, 5000);
+ });
},
methods: {
- get_profile() {
- hub.call('get_item_details', { hub_item_name: this.hub_item_name })
+ get_item_details() {
+ this.item_received = hub.call('get_item_details', { hub_item_name: this.hub_item_name })
.then(item => {
this.init = false;
this.item = item;
@@ -163,6 +186,21 @@
//
},
+ add_to_saved_items() {
+ hub.call('add_item_to_seller_saved_items', {
+ hub_item_name: this.hub_item_name,
+ hub_seller: hub.settings.company_email
+ })
+ .then(() => {
+ const saved_items_link = `<b><a href="#marketplace/saved-products">${__('Saved')}</a></b>`
+ frappe.show_alert(saved_items_link);
+ erpnext.hub.trigger('action:item_save');
+ })
+ .catch(e => {
+ console.error(e);
+ });
+ },
+
contact_seller() {
const d = new frappe.ui.Dialog({
title: __('Send a message'),
diff --git a/erpnext/public/js/hub/pages/SavedProducts.vue b/erpnext/public/js/hub/pages/SavedProducts.vue
index d55e9dc..ddcbcdc 100644
--- a/erpnext/public/js/hub/pages/SavedProducts.vue
+++ b/erpnext/public/js/hub/pages/SavedProducts.vue
@@ -38,11 +38,8 @@
methods: {
get_items() {
hub.call(
- 'get_favourite_items_of_seller',
- {
- hub_seller: hub.settings.company_email
- },
- 'action:item_favourite'
+ 'get_saved_items_of_seller', {},
+ 'action:item_save'
)
.then((items) => {
this.items = items;
@@ -65,7 +62,9 @@
return false;
}
- alert = frappe.show_alert(__(`<span>${hub_item_name} removed.
+ const item_name = this.items.filter(item => item.hub_item_name === hub_item_name);
+
+ alert = frappe.show_alert(__(`<span>${item_name} removed.
<a href="#" data-action="undo-remove"><b>Undo</b></a></span>`),
grace_period/1000,
{
@@ -83,8 +82,8 @@
},
remove_item_from_saved_products(hub_item_name) {
- erpnext.hub.trigger('action:item_favourite');
- hub.call('remove_item_from_seller_favourites', {
+ erpnext.hub.trigger('action:item_save');
+ hub.call('remove_item_from_seller_saved_items', {
hub_item_name,
hub_seller: hub.settings.company_email
})
diff --git a/erpnext/public/js/hub/pages/item.js b/erpnext/public/js/hub/pages/item.js
index c77f57b..cbbdfcf 100644
--- a/erpnext/public/js/hub/pages/item.js
+++ b/erpnext/public/js/hub/pages/item.js
@@ -78,7 +78,7 @@
.then(() => {
$(favourite_button).html('Saved');
frappe.show_alert(__('Saved to <b><a href="#marketplace/favourites">Favourites</a></b>'));
- erpnext.hub.trigger('action:item_favourite');
+ erpnext.hub.trigger('action:item_save');
})
.catch(e => {
console.error(e);