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