Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 
 
 

89 řádky
2.4 KiB

  1. {% from "erpnext/templates/includes/macros.html" import user_review, ratings_summary %}
  2. <div class="mt-4 ratings-reviews-section">
  3. <!-- Title and Action -->
  4. <div class="w-100 mt-4 mb-2 d-flex">
  5. <div class="reviews-header col-9">
  6. {{ _("Customer Reviews") }}
  7. </div>
  8. <div class="write-a-review-btn col-3">
  9. <!-- Write a Review for legitimate users -->
  10. {% if frappe.session.user != "Guest" and user_is_customer %}
  11. <button class="btn btn-write-review"
  12. data-web-item="{{ doc.name }}">
  13. {{ _("Write a Review") }}
  14. </button>
  15. {% endif %}
  16. </div>
  17. </div>
  18. <!-- Summary -->
  19. {{ ratings_summary(reviews, reviews_per_rating, average_rating, average_whole_rating, for_summary=True, total_reviews=total_reviews) }}
  20. <!-- Reviews and Comments -->
  21. <div class="mt-8">
  22. {% if reviews %}
  23. {{ user_review(reviews) }}
  24. {% if total_reviews > 4 %}
  25. <div class="mt-6 mb-6"style="color: var(--primary);">
  26. <a href="/customer_reviews?web_item={{ doc.name }}">{{ _("View all reviews") }}</a>
  27. </div>
  28. {% endif %}
  29. {% else %}
  30. <h6 class="text-muted mt-6">
  31. {{ _("No Reviews") }}
  32. </h6>
  33. {% endif %}
  34. </div>
  35. </div>
  36. <script>
  37. frappe.ready(() => {
  38. $('.page_content').on('click', '.btn-write-review', (e) => {
  39. // Bind action on write a review button
  40. const $btn = $(e.currentTarget);
  41. let d = new frappe.ui.Dialog({
  42. title: __("Write a Review"),
  43. fields: [
  44. {fieldname: "title", fieldtype: "Data", label: "Headline", reqd: 1},
  45. {fieldname: "rating", fieldtype: "Rating", label: "Overall Rating", reqd: 1},
  46. {fieldtype: "Section Break"},
  47. {fieldname: "comment", fieldtype: "Small Text", label: "Your Review"}
  48. ],
  49. primary_action: function() {
  50. var data = d.get_values();
  51. frappe.call({
  52. method: "erpnext.e_commerce.doctype.item_review.item_review.add_item_review",
  53. args: {
  54. web_item: "{{ doc.name }}",
  55. title: data.title,
  56. rating: data.rating,
  57. comment: data.comment
  58. },
  59. freeze: true,
  60. freeze_message: __("Submitting Review ..."),
  61. callback: function(r) {
  62. if(!r.exc) {
  63. frappe.msgprint({
  64. message: __("Thank you for the review"),
  65. title: __("Review Submitted"),
  66. indicator: "green"
  67. });
  68. d.hide();
  69. location.reload();
  70. }
  71. }
  72. });
  73. },
  74. primary_action_label: __('Submit')
  75. });
  76. d.show();
  77. });
  78. });
  79. </script>