댓글 수정중
This commit is contained in:
parent
4720e61958
commit
3678b40e1c
@ -21,8 +21,9 @@
|
||||
<input
|
||||
type="password"
|
||||
class="form-control"
|
||||
v-model="password"
|
||||
:value="password"
|
||||
placeholder="비밀번호 입력"
|
||||
@input="$emit('update:password', $event.target.value.trim())"
|
||||
/>
|
||||
<button class="btn btn-primary" @click="logPasswordAndEmit">확인</button>
|
||||
</div>
|
||||
@ -42,7 +43,7 @@
|
||||
</div>
|
||||
|
||||
<PlusButton v-if="isPlusButton" @click="toggleComment" class="mt-6"/>
|
||||
<BoardCommentArea v-if="isComment" :unknown="unknown" @submitComment="submitComment"/>
|
||||
<BoardCommentArea v-if="isComment" :unknown="unknown" :commentAlert="commentAlert" :passwordAlert="passwordAlert" @submitComment="submitComment"/>
|
||||
|
||||
<!-- 대댓글 -->
|
||||
<ul v-if="comment.children && comment.children.length" class="list-unstyled">
|
||||
@ -60,13 +61,18 @@
|
||||
:isCommentAuthor="child.isCommentAuthor"
|
||||
:isCommentPassword="isCommentPassword"
|
||||
:currentPasswordCommentId="currentPasswordCommentId"
|
||||
:passwordCommentAlert="passwordCommentAlert"
|
||||
:password="password"
|
||||
:commentAlert="commentAlert"
|
||||
:passwordAlert="passwordAlert"
|
||||
@editClick="handleReplyEditClick"
|
||||
@deleteClick="$emit('deleteClick', child)"
|
||||
@submitEdit="(comment, editedContent) => $emit('submitEdit', comment, editedContent)"
|
||||
@cancelEdit="$emit('cancelEdit', child)"
|
||||
@submitComment="submitComment"
|
||||
@updateReaction="handleUpdateReaction"
|
||||
@submitPassword="logPasswordAndEmit"
|
||||
@submitPassword="$emit('submitPassword', child, password)"
|
||||
@update:password="$emit('update:password', $event)"
|
||||
/>
|
||||
</li>
|
||||
</ul>
|
||||
@ -115,13 +121,21 @@ const props = defineProps({
|
||||
},
|
||||
currentPasswordCommentId: {
|
||||
type: Number
|
||||
},
|
||||
password:{
|
||||
type: String
|
||||
},
|
||||
commentAlert: {
|
||||
type: String,
|
||||
},
|
||||
passwordAlert: {
|
||||
type: String,
|
||||
}
|
||||
});
|
||||
|
||||
// emits 정의
|
||||
const emit = defineEmits(['submitComment', 'updateReaction', 'editClick', 'deleteClick', 'submitPassword', 'submitEdit', 'cancelEdit']);
|
||||
const emit = defineEmits(['submitComment', 'updateReaction', 'editClick', 'deleteClick', 'submitPassword', 'submitEdit', 'cancelEdit', 'update:password']);
|
||||
|
||||
const password = ref('');
|
||||
const localEditedContent = ref(props.comment.content);
|
||||
|
||||
// 댓글 입력 창 토글
|
||||
@ -148,9 +162,8 @@ const handleUpdateReaction = (reactionData) => {
|
||||
|
||||
// 비밀번호 확인
|
||||
const logPasswordAndEmit = () => {
|
||||
console.log('비밀번호 확인',password.value)
|
||||
emit('submitPassword', props.comment, password.value);
|
||||
password.value = "";
|
||||
console.log('비밀번호 확인',props.password)
|
||||
emit('submitPassword', props.comment, props.password);
|
||||
};
|
||||
|
||||
watch(() => props.comment.isEditTextarea, (newVal) => {
|
||||
|
||||
@ -13,6 +13,9 @@
|
||||
:isCommentPassword="isCommentPassword"
|
||||
:passwordCommentAlert="passwordCommentAlert || ''"
|
||||
:currentPasswordCommentId="currentPasswordCommentId"
|
||||
:password="password"
|
||||
:commentAlert="commentAlert"
|
||||
:passwordAlert="passwordAlert"
|
||||
@editClick="handleEditClick"
|
||||
@deleteClick="handleDeleteClick"
|
||||
@submitPassword="submitPassword"
|
||||
@ -20,6 +23,7 @@
|
||||
@submitEdit="handleSubmitEdit"
|
||||
@cancelEdit="handleCancelEdit"
|
||||
@updateReaction="(reactionData) => handleUpdateReaction(reactionData, comment.commentId, comment.boardId)"
|
||||
@update:password="updatePassword"
|
||||
/>
|
||||
</li>
|
||||
</ul>
|
||||
@ -57,10 +61,19 @@ const props = defineProps({
|
||||
},
|
||||
currentPasswordCommentId: {
|
||||
type: Number
|
||||
},
|
||||
password:{
|
||||
type: String
|
||||
},
|
||||
commentAlert: {
|
||||
type: String,
|
||||
},
|
||||
passwordAlert: {
|
||||
type: String,
|
||||
}
|
||||
});
|
||||
|
||||
const emit = defineEmits(['submitComment', 'updateReaction', 'editClick', 'deleteClick', 'submitPassword', 'clearPassword','submitEdit']);
|
||||
const emit = defineEmits(['submitComment', 'updateReaction', 'editClick', 'deleteClick', 'submitPassword', 'clearPassword','submitEdit', 'update:password']);
|
||||
|
||||
const submitComment = (replyData) => {
|
||||
emit('submitComment', replyData);
|
||||
@ -107,4 +120,8 @@ const handleCancelEdit = (comment) => {
|
||||
emit('cancelEdit', comment); // 댓글 수정 취소
|
||||
}
|
||||
};
|
||||
|
||||
const updatePassword = (newPassword) => {
|
||||
emit('update:password', newPassword);
|
||||
};
|
||||
</script>
|
||||
|
||||
@ -95,7 +95,7 @@ const props = defineProps({
|
||||
isLike: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
}
|
||||
});
|
||||
|
||||
const emit = defineEmits(['updateReaction', 'editClick', 'deleteClick']);
|
||||
|
||||
@ -27,6 +27,7 @@
|
||||
class="form-control"
|
||||
v-model="password"
|
||||
placeholder="비밀번호 입력"
|
||||
@input="password = password.replace(/\s/g, '')"
|
||||
/>
|
||||
<button class="btn btn-primary" @click="submitPassword">확인</button>
|
||||
</div>
|
||||
@ -103,6 +104,9 @@
|
||||
:isEditTextarea="isEditTextarea"
|
||||
:passwordCommentAlert="passwordCommentAlert"
|
||||
:currentPasswordCommentId="currentPasswordCommentId"
|
||||
:password="password"
|
||||
:commentAlert="commentAlert"
|
||||
:passwordAlert="passwordAlert"
|
||||
@editClick="editComment"
|
||||
@deleteClick="deleteComment"
|
||||
@updateReaction="handleCommentReaction"
|
||||
@ -111,6 +115,7 @@
|
||||
@commentDeleted="handleCommentDeleted"
|
||||
@cancelEdit="handleCancelEdit"
|
||||
@submitEdit="handleSubmitEdit"
|
||||
@update:password="updatePassword"
|
||||
/>
|
||||
<Pagination
|
||||
v-if="pagination.pages"
|
||||
@ -180,7 +185,11 @@ const currentPasswordCommentId = ref(null);
|
||||
const lastClickedButton = ref("");
|
||||
const lastCommentClickedButton = ref("");
|
||||
const isEditTextarea = ref(false);
|
||||
const commentAlert = ref('')
|
||||
const commentAlert = ref('');
|
||||
|
||||
const updatePassword = (newPassword) => {
|
||||
password.value = newPassword;
|
||||
};
|
||||
|
||||
const pagination = ref({
|
||||
currentPage: 1,
|
||||
@ -489,7 +498,6 @@ const deleteComment = async (comment) => {
|
||||
|
||||
// 익명 비밀번호 창 토글
|
||||
const toggleCommentPassword = (comment, button) => {
|
||||
console.log(comment.commentId)
|
||||
if (lastCommentClickedButton.value === button && currentPasswordCommentId.value === comment.commentId) {
|
||||
currentPasswordCommentId.value = null; // 비밀번호 창 닫기
|
||||
} else {
|
||||
@ -510,7 +518,7 @@ const togglePassword = (button) => {
|
||||
|
||||
// 게시글 비밀번호 제출
|
||||
const submitPassword = async () => {
|
||||
if (!password.value) {
|
||||
if (!password.value.trim()) {
|
||||
passwordAlert.value = "비밀번호를 입력해주세요.";
|
||||
return;
|
||||
}
|
||||
@ -620,7 +628,6 @@ const deletePost = async () => {
|
||||
|
||||
// 댓글 삭제 (대댓글 포함)
|
||||
const deleteReplyComment = async (comment) => {
|
||||
console.log('지금 여기')
|
||||
if (!confirm("정말 이 댓글을 삭제하시겠습니까?")) return;
|
||||
|
||||
try {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user