Skip to content

Commit

Permalink
make rating mandatory
Browse files Browse the repository at this point in the history
  • Loading branch information
leemyongpakvn committed Jan 20, 2024
1 parent 40614d2 commit fea6fa7
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions views/js/jquery.rating.plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
5 changes: 5 additions & 0 deletions views/js/post-comment.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,11 @@ jQuery(document).ready(function () {
}
});

if (!ratingChosen) {
showPostErrorModal(productCommentRatingNotChosen);
isValid = false;
}

return isValid;
}

Expand Down
2 changes: 2 additions & 0 deletions views/templates/hook/post-comment-modal.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@

<script type="text/javascript">
var productCommentPostErrorMessage = '{l s='Sorry, your review cannot be posted.' d='Modules.Productcomments.Shop' js=1}';
var productCommentRatingNotChosen = '{l s='Please choose a rating for your review.' d='Modules.Productcomments.Shop' js=1}';
var ratingChosen = false;
</script>

<div id="post-product-comment-modal" class="modal fade product-comment-modal" role="dialog" aria-hidden="true">
Expand Down

0 comments on commit fea6fa7

Please sign in to comment.