수정버튼 누르면 초기화

This commit is contained in:
kimdaae328 2025-02-28 14:12:33 +09:00
parent c68e8839b3
commit 86a6e5b27b

View File

@ -473,16 +473,44 @@ const editComment = (comment) => {
const isAnonymous = comment.author === "익명"; const isAnonymous = comment.author === "익명";
if (isMyComment) { if (isMyComment) {
targetComment.isEditTextarea = !targetComment.isEditTextarea; if (targetComment.isEditTextarea) {
lastCommentClickedButton.value = "edit"; //
targetComment.isEditTextarea = false;
currentPasswordCommentId.value = comment.commentId;
} else {
//
closeAllEditTextareas();
//
targetComment.isEditTextarea = true;
}
} else if (isAnonymous) { } else if (isAnonymous) {
if (targetComment.isEditTextarea) return; if (currentPasswordCommentId.value === comment.commentId) {
toggleCommentPassword(comment, "edit"); //
return;
} else {
//
closeAllEditTextareas();
//
targetComment.isEditTextarea = false;
toggleCommentPassword(comment, "edit");
}
} else { } else {
alert("수정이 불가능합니다"); alert("수정이 불가능합니다");
} }
} }
//
const closeAllEditTextareas = () => {
comments.value.forEach(comment => {
comment.isEditTextarea = false;
comment.children.forEach(reply => {
reply.isEditTextarea = false;
});
});
};
// //
const deleteComment = async (comment) => { const deleteComment = async (comment) => {
const isMyComment = comment.authorId === currentUserId.value; const isMyComment = comment.authorId === currentUserId.value;
@ -587,7 +615,9 @@ const submitCommentPassword = async (comment, password) => {
if (lastCommentClickedButton.value === "edit") { if (lastCommentClickedButton.value === "edit") {
if (targetComment) { if (targetComment) {
// input //
closeAllEditTextareas();
targetComment.isEditTextarea = true; targetComment.isEditTextarea = true;
passwordCommentAlert.value = ""; passwordCommentAlert.value = "";
currentPasswordCommentId.value = null; currentPasswordCommentId.value = null;