Hide review option for unregistered user

This commit is contained in:
Suraj Shetty
2018-08-22 12:09:40 +05:30
parent 831ff42101
commit 7ee79498fc
3 changed files with 34 additions and 25 deletions

View File

@@ -62,7 +62,9 @@ function get_local_item_card_html(item) {
if (rating > 0) { if (rating > 0) {
subtitle.push(rating + `<i class='fa fa-fw fa-star-o'></i>`) subtitle.push(rating + `<i class='fa fa-fw fa-star-o'></i>`)
} }
subtitle.push(company_name); if(company_name) {
subtitle.push(company_name);
}
let dot_spacer = '<span aria-hidden="true"> · </span>'; let dot_spacer = '<span aria-hidden="true"> · </span>';
subtitle = subtitle.join(dot_spacer); subtitle = subtitle.join(dot_spacer);
@@ -77,7 +79,7 @@ function get_local_item_card_html(item) {
<div class="col-md-3 col-sm-4 col-xs-6 hub-card-container"> <div class="col-md-3 col-sm-4 col-xs-6 hub-card-container">
<div class="hub-card is-local ${is_active ? 'active' : ''}" data-id="${id}"> <div class="hub-card is-local ${is_active ? 'active' : ''}" data-id="${id}">
<div class="hub-card-header flex"> <div class="hub-card-header flex">
<div> <div class="ellipsis">
<div class="hub-card-title ellipsis bold">${title}</div> <div class="hub-card-title ellipsis bold">${title}</div>
<div class="hub-card-subtitle ellipsis text-muted">${subtitle}</div> <div class="hub-card-subtitle ellipsis text-muted">${subtitle}</div>
</div> </div>

View File

@@ -254,8 +254,7 @@ erpnext.hub.Marketplace = class Marketplace {
register_seller(form_values) { register_seller(form_values) {
frappe.call({ frappe.call({
method: 'erpnext.hub_node.doctype.hub_settings.hub_settings.register_seller', method: 'erpnext.hub_node.doctype.hub_settings.hub_settings.register_seller',
args: form_values, args: form_values
btn: $(e.currentTarget)
}).then(() => { }).then(() => {
this.register_dialog.hide(); this.register_dialog.hide();
frappe.set_route('marketplace', 'publish'); frappe.set_route('marketplace', 'publish');

View File

@@ -57,7 +57,7 @@ erpnext.hub.Item = class Item extends SubPage {
unpublish_item() { unpublish_item() {
if(!this.unpublish_dialog) { if (!this.unpublish_dialog) {
this.unpublish_dialog = new frappe.ui.Dialog({ this.unpublish_dialog = new frappe.ui.Dialog({
title: "Edit Your Product", title: "Edit Your Product",
fields: [] fields: []
@@ -75,14 +75,14 @@ erpnext.hub.Item = class Item extends SubPage {
hub_item_code: this.hub_item_code, hub_item_code: this.hub_item_code,
hub_seller: hub.settings.company_email hub_seller: hub.settings.company_email
}) })
.then(() => { .then(() => {
$(favourite_button).html('Saved'); $(favourite_button).html('Saved');
frappe.show_alert(__('Saved to <b><a href="#marketplace/favourites">Favourites</a></b>')); frappe.show_alert(__('Saved to <b><a href="#marketplace/favourites">Favourites</a></b>'));
erpnext.hub.trigger('action:item_favourite'); erpnext.hub.trigger('action:item_favourite');
}) })
.catch(e => { .catch(e => {
console.error(e); console.error(e);
}); });
} }
@@ -106,16 +106,16 @@ erpnext.hub.Item = class Item extends SubPage {
if (!message) return; if (!message) return;
hub.call('send_message', { hub.call('send_message', {
from_seller: hub.settings.company_email, from_seller: hub.settings.company_email,
to_seller: this.item.hub_seller, to_seller: this.item.hub_seller,
hub_item: this.item.hub_item_code, hub_item: this.item.hub_item_code,
message message
}) })
.then(() => { .then(() => {
d.hide(); d.hide();
frappe.set_route('marketplace', 'buy', this.item.hub_item_code); frappe.set_route('marketplace', 'buy', this.item.hub_item_code);
erpnext.hub.trigger('action:send_message') erpnext.hub.trigger('action:send_message')
}); });
} }
}); });
@@ -124,11 +124,19 @@ erpnext.hub.Item = class Item extends SubPage {
make_review_area() { make_review_area() {
this.comment_area = new frappe.ui.ReviewArea({ if (hub.settings.registered) {
parent: this.$wrapper.find('.timeline-head').empty(), this.comment_area = new frappe.ui.ReviewArea({
mentions: [], parent: this.$wrapper.find('.timeline-head').empty(),
on_submit: this.on_submit_review.bind(this) mentions: [],
}); on_submit: this.on_submit_review.bind(this)
});
} else {
//TODO: fix UI
this.comment_area = this.$wrapper
.find('.timeline-head')
.empty()
.append('<div></div>');
}
} }