diff --git a/admin/themes/clear/theme.css b/admin/themes/clear/theme.css index e7a4f494a..e7ad821c4 100644 --- a/admin/themes/clear/theme.css +++ b/admin/themes/clear/theme.css @@ -247,11 +247,17 @@ UL.thumbnails li.rank-of-image {background-color: #ddd;} font-weight: bold; } -#batchManagerGlobal #applyFilter,#batchManagerGlobal .addFilter-button { +#batchManagerGlobal #applyFilter,#batchManagerGlobal .addFilter-button, +.buttonSecondary { color: #3C3C3C; background-color: #ececec; } +.buttonSecondary:hover { + color: #3C3C3C; + background-color: #aaa; +} + #batchManagerGlobal #applyFilter:hover, #batchManagerGlobal .addFilter-button:hover { color: #111; background-color: #ff9b32 ; diff --git a/admin/themes/default/js/comments.js b/admin/themes/default/js/comments.js index f7254c1bb..ca4844ffc 100644 --- a/admin/themes/default/js/comments.js +++ b/admin/themes/default/js/comments.js @@ -110,6 +110,12 @@ $(function() { commentsClearFilters(); }); + $(window).on('keydown', function(e) { + if (e.key === 'Escape') { + closeModalViewComment(); + } + }); + // get comments and set display commentsParams.per_page = window.localStorage.getItem('adminCommentsNB') ?? 5 updateNbComments(commentsParams.per_page); @@ -320,8 +326,8 @@ function commentsDisplayFilters(filters) { // reset here to let decide filterAuthor onChange updateAuthorId = true; - const minDate = filters.started_at.split(' ')[0] ?? ''; - const maxDate = filters.ended_at.split(' ')[0] ?? '' + const minDate = filters.started_at?.split(' ')[0] ?? ''; + const maxDate = filters.ended_at?.split(' ')[0] ?? '' filterDateStart.val(minDate).attr({ 'min': minDate, 'max': maxDate }); filterDateEnd.val(maxDate).attr({ 'max': maxDate, 'min': minDate }); @@ -404,14 +410,34 @@ function showModalViewComment(id) { `); modalViewComment.find('.comments-modal-body').html(comment.content) + const validBtn = modalViewComment.find('.comments-modal-validate'); + if (comment.is_pending) { + validBtn.show(); + $('#commentsModalValidate').off('click').on('click', function() { + validateComment([id]); + closeModalViewComment(); + }); + } else { + validBtn.hide(); + } + + $('#commentsModalDelete').off('click').on('click', function() { + deleteComment([id]); + closeModalViewComment(); + }); + modalViewComment.fadeIn(); } function closeModalViewComment() { modalViewComment.fadeOut(); + $('#commentsModalValidate').off('click'); + $('#commentsModalDelete').off('click') } function validateComment(id) { + const idLenght = id.length ?? 1; + $.ajax({ url: 'ws.php?format=json&method=pwg.userComments.validate', type: 'POST', @@ -424,7 +450,7 @@ function validateComment(id) { if (res.stat === 'ok') { $.alert({ ...{ - title: str_comment_validated, + title: idLenght > 1 ? str_comments_validated : str_comment_validated, content: "", }, ...jConfirm_alert_options @@ -454,8 +480,10 @@ function validateComment(id) { } function deleteComment(id) { + const idLenght = id.length ?? 1; + $.confirm({ - title: str_delete.replace("%s", id), + title: idLenght > 1 ? str_deletes.replace("%d", idLenght) : str_delete.replace("%s", id), draggable: false, titleClass: "jconfirmDeleteConfirm", theme: "modern", diff --git a/admin/themes/default/template/comments.tpl b/admin/themes/default/template/comments.tpl index de680e204..7070b31e6 100644 --- a/admin/themes/default/template/comments.tpl +++ b/admin/themes/default/template/comments.tpl @@ -5,11 +5,13 @@ {footer_script} const str_yes_delete_confirmation = "{'Yes, delete'|@translate|@escape:'javascript'}" const str_no_delete_confirmation = "{"No, I have changed my mind"|@translate|@escape:'javascript'}" -const str_delete = "{'Are you sure you want to delete comment "%s"?'|@translate|@escape:'javascript'}" +const str_delete = "{'Are you sure you want to delete comment #%s?'|@translate|@escape:'javascript'}" +const str_deletes = "{'Are you sure you want to delete "%d" comments?'|@translate|@escape:'javascript'}" const str_no_comments_selected = "{'No comments selected, no actions possible.'|@translate|@escape:'javascript'}" const pwg_token = "{$PWG_TOKEN}" const str_an_error_has = "{"An error has occured"|@translate|@escape:'javascript'}" const str_comment_validated = "{"The comment has been validated."|@translate|@escape:'javascript'}" +const str_comments_validated = "{"The comments have been validated."|@translate|@escape:'javascript'}" const str_and_others = "{"and %s others"|@translate}" {/footer_script}