비밀번호 입력창 초기화

This commit is contained in:
kimdaae328 2025-02-28 12:18:09 +09:00
parent 3678b40e1c
commit 785df5c51f
3 changed files with 21 additions and 26 deletions

View File

@ -43,7 +43,7 @@
</div> </div>
<PlusButton v-if="isPlusButton" @click="toggleComment" class="mt-6"/> <PlusButton v-if="isPlusButton" @click="toggleComment" class="mt-6"/>
<BoardCommentArea v-if="isComment" :unknown="unknown" :commentAlert="commentAlert" :passwordAlert="passwordAlert" @submitComment="submitComment"/> <BoardCommentArea v-if="isComment" :unknown="unknown" @submitComment="submitComment"/>
<!-- 대댓글 --> <!-- 대댓글 -->
<ul v-if="comment.children && comment.children.length" class="list-unstyled"> <ul v-if="comment.children && comment.children.length" class="list-unstyled">
@ -63,8 +63,6 @@
:currentPasswordCommentId="currentPasswordCommentId" :currentPasswordCommentId="currentPasswordCommentId"
:passwordCommentAlert="passwordCommentAlert" :passwordCommentAlert="passwordCommentAlert"
:password="password" :password="password"
:commentAlert="commentAlert"
:passwordAlert="passwordAlert"
@editClick="handleReplyEditClick" @editClick="handleReplyEditClick"
@deleteClick="$emit('deleteClick', child)" @deleteClick="$emit('deleteClick', child)"
@submitEdit="(comment, editedContent) => $emit('submitEdit', comment, editedContent)" @submitEdit="(comment, editedContent) => $emit('submitEdit', comment, editedContent)"
@ -125,12 +123,6 @@ const props = defineProps({
password:{ password:{
type: String type: String
}, },
commentAlert: {
type: String,
},
passwordAlert: {
type: String,
}
}); });
// emits // emits

View File

@ -14,8 +14,6 @@
:passwordCommentAlert="passwordCommentAlert || ''" :passwordCommentAlert="passwordCommentAlert || ''"
:currentPasswordCommentId="currentPasswordCommentId" :currentPasswordCommentId="currentPasswordCommentId"
:password="password" :password="password"
:commentAlert="commentAlert"
:passwordAlert="passwordAlert"
@editClick="handleEditClick" @editClick="handleEditClick"
@deleteClick="handleDeleteClick" @deleteClick="handleDeleteClick"
@submitPassword="submitPassword" @submitPassword="submitPassword"
@ -65,12 +63,6 @@ const props = defineProps({
password:{ password:{
type: String type: String
}, },
commentAlert: {
type: String,
},
passwordAlert: {
type: String,
}
}); });
const emit = defineEmits(['submitComment', 'updateReaction', 'editClick', 'deleteClick', 'submitPassword', 'clearPassword','submitEdit', 'update:password']); const emit = defineEmits(['submitComment', 'updateReaction', 'editClick', 'deleteClick', 'submitPassword', 'clearPassword','submitEdit', 'update:password']);

View File

@ -105,8 +105,6 @@
:passwordCommentAlert="passwordCommentAlert" :passwordCommentAlert="passwordCommentAlert"
:currentPasswordCommentId="currentPasswordCommentId" :currentPasswordCommentId="currentPasswordCommentId"
:password="password" :password="password"
:commentAlert="commentAlert"
:passwordAlert="passwordAlert"
@editClick="editComment" @editClick="editComment"
@deleteClick="deleteComment" @deleteClick="deleteComment"
@updateReaction="handleCommentReaction" @updateReaction="handleCommentReaction"
@ -459,8 +457,12 @@ const findCommentById = (commentId, commentsList) => {
return null; return null;
}; };
// // ( )
const editComment = (comment) => { const editComment = (comment) => {
password.value = '';
passwordCommentAlert.value = '';
currentPasswordCommentId.value = null;
const targetComment = findCommentById(comment.commentId, comments.value); const targetComment = findCommentById(comment.commentId, comments.value);
if (!targetComment) { if (!targetComment) {
@ -496,12 +498,16 @@ const deleteComment = async (comment) => {
} }
}; };
// //
const toggleCommentPassword = (comment, button) => { const toggleCommentPassword = (comment, button) => {
if (lastCommentClickedButton.value === button && currentPasswordCommentId.value === comment.commentId) { if (lastCommentClickedButton.value === button && currentPasswordCommentId.value === comment.commentId) {
currentPasswordCommentId.value = null; // currentPasswordCommentId.value = null; //
password.value = '';
passwordCommentAlert.value = '';
} else { } else {
currentPasswordCommentId.value = comment.commentId; // currentPasswordCommentId.value = comment.commentId; //
password.value = '';
passwordCommentAlert.value = '';
} }
lastCommentClickedButton.value = button; lastCommentClickedButton.value = button;
@ -557,7 +563,7 @@ const submitPassword = async () => {
} }
}; };
// ( ) // ( )
const submitCommentPassword = async (comment, password) => { const submitCommentPassword = async (comment, password) => {
if (!password) { if (!password) {
passwordCommentAlert.value = "비밀번호를 입력해주세요."; passwordCommentAlert.value = "비밀번호를 입력해주세요.";
@ -573,20 +579,25 @@ const submitCommentPassword = async (comment, password) => {
}); });
if (response.data.code === 200 && response.data.data === true) { if (response.data.code === 200 && response.data.data === true) {
passwordCommentAlert.value = ""; passwordCommentAlert.value = '';
comment.isCommentPassword = false; comment.isCommentPassword = false;
//
if (lastCommentClickedButton.value === "edit") { if (lastCommentClickedButton.value === "edit") {
if (targetComment) { if (targetComment) {
currentPasswordCommentId.value = null;
password.value = '';
passwordCommentAlert.value = '';
targetComment.isEditTextarea = true; targetComment.isEditTextarea = true;
passwordCommentAlert.value = "";
} else { } else {
alert("수정 취소를 실패했습니다."); alert("수정 취소를 실패했습니다.");
} }
//
} else if (lastCommentClickedButton.value === "delete") { } else if (lastCommentClickedButton.value === "delete") {
passwordCommentAlert.value = ""; passwordCommentAlert.value = '';
deleteReplyComment(comment) deleteReplyComment(comment)
} }