From fea6fa7191ce99a914f8548dd031d72b4d310cc4 Mon Sep 17 00:00:00 2001 From: leemyong pakvn <3759923+leemyongpakvn@users.noreply.github.com> Date: Sat, 20 Jan 2024 18:21:19 +0700 Subject: [PATCH 1/6] make rating mandatory --- views/js/jquery.rating.plugin.js | 1 + views/js/post-comment.js | 5 +++++ views/templates/hook/post-comment-modal.tpl | 2 ++ 3 files changed, 8 insertions(+) diff --git a/views/js/jquery.rating.plugin.js b/views/js/jquery.rating.plugin.js index b466e9fd..755dbdbc 100644 --- a/views/js/jquery.rating.plugin.js +++ b/views/js/jquery.rating.plugin.js @@ -96,6 +96,7 @@ jQuery.fn.rating = function(generalOptions) { newStar.on('click', function selectGrade() { var selectedGrade = $(this).data('grade'); ratingInput.val(selectedGrade); + ratingChosen = true; }); fullStars.append(newStar); } diff --git a/views/js/post-comment.js b/views/js/post-comment.js index 3601f882..26a28bbb 100644 --- a/views/js/post-comment.js +++ b/views/js/post-comment.js @@ -124,6 +124,11 @@ jQuery(document).ready(function () { } }); + if (!ratingChosen) { + showPostErrorModal(productCommentRatingNotChosen); + isValid = false; + } + return isValid; } diff --git a/views/templates/hook/post-comment-modal.tpl b/views/templates/hook/post-comment-modal.tpl index 81a75659..c559a594 100644 --- a/views/templates/hook/post-comment-modal.tpl +++ b/views/templates/hook/post-comment-modal.tpl @@ -25,6 +25,8 @@