brotherton-erpnext/erpnext/templates/generators/item/item_reviews.html

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

83 lines
2.3 KiB
HTML
Raw Normal View History

{% from "erpnext/templates/includes/macros.html" import user_review, ratings_summary %}
<div class="mt-12 ratings-reviews-section" style="display: flex;">
<div class="col-md-4 order-md-1 mt-8" style="max-width: 300px;">
{{ ratings_summary(reviews, reviews_per_rating, average_rating, average_whole_rating) }}
<!-- Write a Review for legitimate users -->
{% if frappe.session.user != "Guest" and user_is_customer %}
<button class="btn btn-light btn-write-review mr-2 mt-4 mb-4 w-100"
data-web-item="{{ doc.name }}">
{{ _("Write a Review") }}
</button>
{% endif %}
</div>
<!-- Reviews and Comments -->
<div class="col-12 order-2 col-md-9 order-md-2 mt-8 ml-16">
<h2 class="reviews-header">
{{ _("Reviews") }}
</h2>
{% if reviews %}
{{ user_review(reviews) }}
{% if total_reviews > 4 %}
<div class="mt-6 mb-6"style="color: var(--primary);">
<a href="/customer_reviews?item_code={{ doc.item_code }}">{{ _("View all reviews") }}</a>
</div>
{% endif %}
{% else %}
<h6 class="text-muted mt-6">
{{ _("No Reviews") }}
</h6>
{% endif %}
</div>
</div>
<script>
frappe.ready(() => {
$('.page_content').on('click', '.btn-write-review', (e) => {
// Bind action on write a review button
const $btn = $(e.currentTarget);
let d = new frappe.ui.Dialog({
title: __("Write a Review"),
fields: [
{fieldname: "title", fieldtype: "Data", label: "Headline", reqd: 1},
{fieldname: "rating", fieldtype: "Rating", label: "Overall Rating", reqd: 1},
{fieldtype: "Section Break"},
{fieldname: "comment", fieldtype: "Small Text", label: "Your Review"}
],
primary_action: function() {
var data = d.get_values();
frappe.call({
method: "erpnext.e_commerce.doctype.item_review.item_review.add_item_review",
args: {
web_item: "{{ doc.name }}",
title: data.title,
rating: data.rating,
comment: data.comment
},
freeze: true,
freeze_message: __("Submitting Review ..."),
callback: function(r) {
if(!r.exc) {
frappe.msgprint({
message: __("Thank you for submitting your review"),
title: __("Review Submitted"),
indicator: "green"
});
d.hide();
location.reload();
}
}
});
},
primary_action_label: __('Submit')
});
d.show();
});
});
</script>