Skip to content

Commit

Permalink
put Mandatory message inside the current modal instead of a new modal
Browse files Browse the repository at this point in the history
  • Loading branch information
leemyongpakvn committed Jan 21, 2024
1 parent fea6fa7 commit 10ddd32
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
6 changes: 6 additions & 0 deletions views/css/productcomments.css
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,12 @@
font-weight: bold;
}

#ratingNotChosen {
font-size: smaller;
color: #ff0000;
text-align: center;
}

#post-product-comment-form input.error,
#post-product-comment-form textarea.error {
background-color: #f2dede;
Expand Down
18 changes: 12 additions & 6 deletions views/js/post-comment.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ jQuery(document).ready(function () {
const commentPostedModal = $('#product-comment-posted-modal');
const commentPostErrorModal = $('#product-comment-post-error');

const criterionsList = $('#criterions_list');
criterionsList.append('<div id="ratingNotChosen">* ' + productCommentMandatoryMessage + '</div>');
$('#ratingNotChosen').hide();

function showPostCommentModal() {
commentPostedModal.modal('hide');
commentPostErrorModal.modal('hide');
Expand Down Expand Up @@ -122,12 +126,14 @@ jQuery(document).ready(function () {
$(fieldSelector).removeClass('error');
$(fieldSelector).addClass('valid');
}
});

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

if (!ratingChosen) {
$('#ratingNotChosen').show();
isValid = false;
} else {
$('#ratingNotChosen').hide();
}
});

return isValid;
}
Expand Down
2 changes: 1 addition & 1 deletion views/templates/hook/post-comment-modal.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

<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 productCommentMandatoryMessage = '{l s='Please choose a rating for your review.' d='Modules.Productcomments.Shop' js=1}';
var ratingChosen = false;
</script>

Expand Down

0 comments on commit 10ddd32

Please sign in to comment.