Merge branch 'main' into vacation

This commit is contained in:
dyhj625 2025-03-20 13:40:40 +09:00
commit c3ef423b16
3 changed files with 91 additions and 64 deletions

View File

@ -4,7 +4,7 @@
:unknown="comment.author === '익명'"
:isCommentAuthor="isCommentAuthor"
:boardId="comment.boardId"
:profileName="comment.author"
:profileName="comment.nickname ? comment.nickname : comment.author"
:date="comment.createdAt"
:comment="comment"
:profileImg="comment.profileImg"
@ -17,7 +17,7 @@
@updateReaction="handleUpdateReaction"
/>
<!-- 댓글 비밀번호 입력창 (익명일 경우) -->
<div v-if="currentPasswordCommentId === comment.commentId && unknown && comment.author == '익명'" class="mt-3 w-20 ms-auto">
<div v-if="currentPasswordCommentId === comment.commentId && unknown && comment.author == '익명'" class="mt-3 w-px-200 ms-auto">
<div class="input-group">
<input
type="password"

View File

@ -3,69 +3,71 @@
<div class="card-body">
<!-- 댓글 입력 섹션 -->
<div class="d-flex justify-content-start align-items-top">
<!-- 프로필섹션 -->
<!-- <div class="avatar-wrapper">
<div v-if="!unknown" class="avatar me-4">
<img src="/img/avatars/11.png" alt="Avatar" class="rounded-circle">
</div>
</div> -->
<!-- 텍스트박스 -->
<div class="w-100">
<textarea
class="form-control mb-2"
class="form-control mb-1"
placeholder="댓글 달기"
rows="3"
:maxlength="maxLength"
v-model="comment"
@input="alertTextHandler"
@input="clearAlert('comment')"
></textarea>
<span v-if="commentAlert" class="invalid-feedback d-inline text-start ms-2 mb-2">{{ commentAlert }}</span>
<span v-else class="invalid-feedback d-inline text-start ms-2">{{ textAlert }}</span>
<span v-else class="invalid-feedback d-inline">{{ textAlert }}</span>
</div>
</div>
<!-- 옵션 버튼 섹션 -->
<div class="d-flex justify-content-between mt-1">
<div class="row g-2">
<div class="d-flex flex-wrap align-items-center mb-2">
<!-- 익명 체크박스 (익명게시판일 경우에만)-->
<div v-if="unknown" class="form-check form-check-inline mb-0 me-4 d-flex align-items-center">
<input
class="form-check-input me-2"
type="checkbox"
:id="`checkboxAnnonymous${commnetId}`"
v-model="isCheck"
@change="pwd2AlertHandler"
/>
<label class="form-check-label" :for="`checkboxAnnonymous${commnetId}`">익명</label>
</div>
<div class="d-flex justify-content-between align-items-center mt-1 pb-4">
<!-- 왼쪽: 익명 체크박스 -->
<div v-if="unknown" class="form-check form-check-inline mb-0 me-2">
<input
class="form-check-input"
type="checkbox"
:id="`checkboxAnnonymous${commnetId}`"
v-model="isCheck"
@change="pwd2AlertHandler"
/>
<label class="form-check-label text-nowrap" :for="`checkboxAnnonymous${commnetId}`">익명</label>
</div>
<!-- 비밀번호 입력 필드 (익명이 선택된 경우에만 표시) -->
<template v-if="isCheck">
<div class="d-flex align-items-center col">
<input
type="password"
id="basic-default-password"
class="form-control w-80"
autocomplete="new-password"
v-model="password"
placeholder="비밀번호 입력"
@input="passwordAlertTextHandler"
/>
</div>
</template>
<!-- 중앙: 닉네임 & 비밀번호 입력 필드 (가로 정렬) -->
<div v-if="isCheck" class="d-flex flex-grow-1 gap-2">
<!-- 닉네임 입력 영역 -->
<div class="position-relative">
<input
type="text"
class="form-control mb-1"
v-model="nickname"
placeholder="닉네임"
@input="clearAlert('nickname')"
/>
<!-- 닉네임 경고 메시지 -->
<div v-if="nicknameAlert" class="position-absolute text-danger small top-100 start-0" >
{{ nicknameAlert }}
</div>
</div>
<div class="row">
<div style="width: 70px"></div>
<div class="col">
<span v-if="passwordAlert" class="invalid-feedback d-inline">{{ passwordAlert }}</span>
<span v-else class="invalid-feedback d-inline">{{ passwordAlert2 }}</span>
<!-- 비밀번호 입력 영역 -->
<div class="position-relative">
<input
type="password"
id="basic-default-password"
class="form-control mb-1"
autocomplete="new-password"
v-model="password"
placeholder="비밀번호"
@input="clearAlert('password')"
/>
<!-- 비밀번호 경고 메시지 -->
<div v-if="passwordAlert2" class="position-absolute text-danger small top-100 start-0">
{{ passwordAlert2 }}
</div>
</div>
</div>
<!-- 답변 쓰기 버튼 -->
<div class="ms-auto mt-3 mt-md-0">
<!-- 오른쪽: 답변 쓰기 버튼 -->
<div class="ms-auto">
<SaveBtn class="btn btn-primary" @click="handleCommentSubmit"></SaveBtn>
</div>
</div>
@ -108,37 +110,54 @@
const password = ref('');
const isCheck = ref(false);
const textAlert = ref('');
const nicknameAlert = ref('');
const passwordAlert2 = ref('');
const nickname = ref('');
const emit = defineEmits(['submitComment']);
const alertTextHandler = () => {
textAlert.value = '';
};
const passwordAlertTextHandler = event => {
event.target.value = event.target.value.replace(/\s/g, '');
passwordAlert2.value = '';
//
const clearAlert = field => {
if (field === 'comment') textAlert.value = '';
if (field === 'nickname') nicknameAlert.value = '';
if (field === 'password') passwordAlert2.value = '';
};
const handleCommentSubmit = () => {
let isValid = true;
//
if (!$common.isNotEmpty(comment.value)) {
textAlert.value = '댓글을 입력하세요';
return false;
textAlert.value = '댓글을 입력해주세요.';
isValid = false;
} else {
textAlert.value = '';
}
if (isCheck.value && !$common.isNotEmpty(password.value)) {
passwordAlert2.value = '비밀번호를 입력하세요';
return false;
} else {
passwordAlert2.value = '';
// &
if (isCheck.value) {
if (!$common.isNotEmpty(nickname.value)) {
nicknameAlert.value = '닉네임을 입력해주세요.';
isValid = false;
} else {
nicknameAlert.value = '';
}
if (!$common.isNotEmpty(password.value)) {
passwordAlert2.value = '비밀번호를 입력해주세요.';
isValid = false;
} else {
passwordAlert2.value = '';
}
}
//
if (!isValid) return;
//
emit('submitComment', {
comment: comment.value,
nickname: isCheck.value ? nickname.value : '',
password: isCheck.value ? password.value : '',
isCheck: isCheck.value,
LOCBRDTYP: isCheck.value ? '300102' : null, // '300102'
@ -148,15 +167,19 @@
resetCommentForm();
};
//
// &
const pwd2AlertHandler = () => {
if (isCheck.value === false) passwordAlert2.value = '';
if (!isCheck.value) {
passwordAlert2.value = '';
nicknameAlert.value = '';
}
};
//
const resetCommentForm = () => {
comment.value = '';
password.value = '';
nickname.value = '';
isCheck.value = false;
};

View File

@ -21,7 +21,7 @@
/>
<!-- 비밀번호 입력창 (익명일 경우) -->
<div v-if="isPassword && unknown" class="mt-3 w-25 ms-auto">
<div v-if="isPassword && unknown" class="mt-3 w-px-200 ms-auto">
<div class="input-group">
<input
type="password"
@ -322,6 +322,7 @@
likeCount: comment.likeCount || 0,
dislikeCount: comment.dislikeCount || 0,
profileImg: comment.profileImg || '',
nickname: comment.LOCCMTNIC,
likeClicked: comment.likeClicked || false,
dislikeClicked: comment.dislikeClicked || false,
createdAtRaw: comment.LOCCMTRDT, //
@ -351,6 +352,7 @@
parentId: reply.LOCCMTPNT, // ID
content: reply.LOCCMTRPY || '내용 없음',
createdAtRaw: reply.LOCCMTRDT,
nickname: reply.LOCCMTNIC,
// createdAt: formattedDate(reply.LOCCMTRDT),
//createdAtRaw: new Date(reply.LOCCMTUDT),
createdAt: formattedDate(reply.LOCCMTUDT) + (reply.LOCCMTUDT !== reply.LOCCMTRDT ? ' (수정됨)' : ''),
@ -413,6 +415,7 @@
LOCCMTRPY: comment,
LOCCMTPWD: isCheck ? password : '',
LOCCMTPNT: 1,
LOCCMTNIC: data.isCheck ? data.nickname : null,
LOCBRDTYP: isCheck ? '300102' : null,
});
@ -432,6 +435,7 @@
LOCCMTRPY: reply.comment,
LOCCMTPWD: reply.password || null,
LOCCMTPNT: reply.parentId,
LOCCMTNIC: data.isCheck ? data.nickname : null,
LOCBRDTYP: reply.isCheck ? '300102' : null,
});