From 7ee79498fcbec203a19d350ef3541cc4599c89f3 Mon Sep 17 00:00:00 2001 From: Suraj Shetty Date: Wed, 22 Aug 2018 12:09:40 +0530 Subject: [PATCH] Hide review option for unregistered user --- erpnext/public/js/hub/components/item_card.js | 6 ++- erpnext/public/js/hub/marketplace.js | 3 +- erpnext/public/js/hub/pages/item.js | 50 +++++++++++-------- 3 files changed, 34 insertions(+), 25 deletions(-) diff --git a/erpnext/public/js/hub/components/item_card.js b/erpnext/public/js/hub/components/item_card.js index a1b0ae022d..f39fb07aca 100644 --- a/erpnext/public/js/hub/components/item_card.js +++ b/erpnext/public/js/hub/components/item_card.js @@ -62,7 +62,9 @@ function get_local_item_card_html(item) { if (rating > 0) { subtitle.push(rating + ``) } - subtitle.push(company_name); + if(company_name) { + subtitle.push(company_name); + } let dot_spacer = ''; subtitle = subtitle.join(dot_spacer); @@ -77,7 +79,7 @@ function get_local_item_card_html(item) {
-
+
${title}
${subtitle}
diff --git a/erpnext/public/js/hub/marketplace.js b/erpnext/public/js/hub/marketplace.js index a7b7761f26..42b2dda763 100644 --- a/erpnext/public/js/hub/marketplace.js +++ b/erpnext/public/js/hub/marketplace.js @@ -254,8 +254,7 @@ erpnext.hub.Marketplace = class Marketplace { register_seller(form_values) { frappe.call({ method: 'erpnext.hub_node.doctype.hub_settings.hub_settings.register_seller', - args: form_values, - btn: $(e.currentTarget) + args: form_values }).then(() => { this.register_dialog.hide(); frappe.set_route('marketplace', 'publish'); diff --git a/erpnext/public/js/hub/pages/item.js b/erpnext/public/js/hub/pages/item.js index 9f40971476..618c9585a8 100644 --- a/erpnext/public/js/hub/pages/item.js +++ b/erpnext/public/js/hub/pages/item.js @@ -57,7 +57,7 @@ erpnext.hub.Item = class Item extends SubPage { unpublish_item() { - if(!this.unpublish_dialog) { + if (!this.unpublish_dialog) { this.unpublish_dialog = new frappe.ui.Dialog({ title: "Edit Your Product", fields: [] @@ -75,14 +75,14 @@ erpnext.hub.Item = class Item extends SubPage { hub_item_code: this.hub_item_code, hub_seller: hub.settings.company_email }) - .then(() => { - $(favourite_button).html('Saved'); - frappe.show_alert(__('Saved to Favourites')); - erpnext.hub.trigger('action:item_favourite'); - }) - .catch(e => { - console.error(e); - }); + .then(() => { + $(favourite_button).html('Saved'); + frappe.show_alert(__('Saved to Favourites')); + erpnext.hub.trigger('action:item_favourite'); + }) + .catch(e => { + console.error(e); + }); } @@ -106,16 +106,16 @@ erpnext.hub.Item = class Item extends SubPage { if (!message) return; hub.call('send_message', { - from_seller: hub.settings.company_email, + from_seller: hub.settings.company_email, to_seller: this.item.hub_seller, hub_item: this.item.hub_item_code, - message + message }) - .then(() => { - d.hide(); - frappe.set_route('marketplace', 'buy', this.item.hub_item_code); - erpnext.hub.trigger('action:send_message') - }); + .then(() => { + d.hide(); + frappe.set_route('marketplace', 'buy', this.item.hub_item_code); + erpnext.hub.trigger('action:send_message') + }); } }); @@ -124,11 +124,19 @@ erpnext.hub.Item = class Item extends SubPage { make_review_area() { - this.comment_area = new frappe.ui.ReviewArea({ - parent: this.$wrapper.find('.timeline-head').empty(), - mentions: [], - on_submit: this.on_submit_review.bind(this) - }); + if (hub.settings.registered) { + this.comment_area = new frappe.ui.ReviewArea({ + parent: this.$wrapper.find('.timeline-head').empty(), + mentions: [], + on_submit: this.on_submit_review.bind(this) + }); + } else { + //TODO: fix UI + this.comment_area = this.$wrapper + .find('.timeline-head') + .empty() + .append('
'); + } }