- 체크리스트 섹션에 이미지 썸네일 미리보기 추가 (16x16) - 대시보드 상단 체크리스트 카드에 이미지 미리보기 기능 추가 - 이미지 클릭 시 전체 화면 모달로 확대 보기 - 백엔드 image_url 컬럼을 TEXT 타입으로 변경하여 Base64 이미지 지원 - 파일 업로드를 이미지만 지원하도록 단순화 (file_url, file_name 제거) - 422 validation 오류 해결 및 상세 로깅 추가 - 체크리스트 렌더링 누락 문제 해결
497 lines
21 KiB
HTML
497 lines
21 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="ko">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>체크리스트 - 기한 없는 일들</title>
|
|
<script src="https://cdn.tailwindcss.com"></script>
|
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
|
|
<style>
|
|
:root {
|
|
--primary: #3b82f6; /* 하늘색 */
|
|
--primary-dark: #2563eb; /* 진한 하늘색 */
|
|
--success: #10b981; /* 초록색 */
|
|
--warning: #f59e0b; /* 주황색 */
|
|
--danger: #ef4444; /* 빨간색 */
|
|
--gray-50: #f9fafb; /* 연한 회색 */
|
|
--gray-100: #f3f4f6; /* 회색 */
|
|
--gray-200: #e5e7eb; /* 중간 회색 */
|
|
--gray-300: #d1d5db; /* 진한 회색 */
|
|
}
|
|
|
|
body {
|
|
background-color: var(--gray-50);
|
|
}
|
|
|
|
.btn-primary {
|
|
background-color: var(--primary);
|
|
color: white;
|
|
transition: all 0.2s;
|
|
}
|
|
|
|
.btn-primary:hover {
|
|
background-color: var(--primary-dark);
|
|
transform: translateY(-1px);
|
|
box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
|
|
}
|
|
|
|
.btn-success {
|
|
background-color: var(--success);
|
|
color: white;
|
|
transition: all 0.2s;
|
|
}
|
|
|
|
.btn-success:hover {
|
|
background-color: #059669;
|
|
transform: translateY(-1px);
|
|
box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
|
|
}
|
|
|
|
.checklist-item {
|
|
background: white;
|
|
border-radius: 0.75rem;
|
|
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
|
|
transition: all 0.2s;
|
|
}
|
|
|
|
.checklist-item:hover {
|
|
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
|
|
}
|
|
|
|
.checklist-item.completed {
|
|
opacity: 0.7;
|
|
background-color: #f9fafb;
|
|
}
|
|
|
|
.checklist-item.completed .item-content {
|
|
text-decoration: line-through;
|
|
color: #6b7280;
|
|
}
|
|
|
|
.checkbox-custom {
|
|
width: 20px;
|
|
height: 20px;
|
|
border: 2px solid #d1d5db;
|
|
border-radius: 4px;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
cursor: pointer;
|
|
transition: all 0.2s;
|
|
}
|
|
|
|
.checkbox-custom.checked {
|
|
background-color: #10b981;
|
|
border-color: #10b981;
|
|
color: white;
|
|
}
|
|
|
|
.checkbox-custom:hover {
|
|
border-color: #10b981;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="min-h-screen">
|
|
<!-- 헤더 -->
|
|
<header class="bg-white shadow-sm border-b">
|
|
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
|
|
<div class="flex justify-between items-center h-16">
|
|
<div class="flex items-center">
|
|
<button onclick="goBack()" class="mr-4 text-gray-500 hover:text-gray-700">
|
|
<i class="fas fa-arrow-left text-xl"></i>
|
|
</button>
|
|
<i class="fas fa-check-square text-2xl text-green-500 mr-3"></i>
|
|
<h1 class="text-xl font-semibold text-gray-800">체크리스트</h1>
|
|
<span class="ml-3 text-sm text-gray-500">기한 없는 일들</span>
|
|
</div>
|
|
|
|
<div class="flex items-center space-x-4">
|
|
<button onclick="goToDashboard()" class="text-blue-600 hover:text-blue-800 font-medium">
|
|
<i class="fas fa-chart-line mr-1"></i>대시보드
|
|
</button>
|
|
<span class="text-sm text-gray-600" id="currentUser"></span>
|
|
<button onclick="logout()" class="text-gray-500 hover:text-gray-700">
|
|
<i class="fas fa-sign-out-alt"></i>
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</header>
|
|
|
|
<!-- 메인 컨텐츠 -->
|
|
<main class="max-w-6xl mx-auto px-4 sm:px-6 lg:px-8 py-8">
|
|
<!-- 페이지 설명 -->
|
|
<div class="bg-green-50 rounded-xl p-6 mb-8">
|
|
<div class="flex items-center mb-4">
|
|
<i class="fas fa-check-square text-2xl text-green-600 mr-3"></i>
|
|
<h2 class="text-xl font-semibold text-green-900">체크리스트 관리</h2>
|
|
</div>
|
|
<p class="text-green-800 mb-4">
|
|
기한이 없는 일들을 관리합니다. 언제든 할 수 있는 일들을 체크해나가세요.
|
|
</p>
|
|
<div class="grid grid-cols-1 md:grid-cols-3 gap-4 text-sm">
|
|
<div class="bg-white rounded-lg p-3">
|
|
<div class="font-medium text-green-900 mb-1">📝 할 일</div>
|
|
<div class="text-green-700">아직 완료하지 않은 일들</div>
|
|
</div>
|
|
<div class="bg-white rounded-lg p-3">
|
|
<div class="font-medium text-green-900 mb-1">✅ 완료</div>
|
|
<div class="text-green-700">완료한 일들</div>
|
|
</div>
|
|
<div class="bg-white rounded-lg p-3">
|
|
<div class="font-medium text-green-900 mb-1">📊 진행률</div>
|
|
<div class="text-green-700" id="progressText">0% 완료</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 진행률 표시 -->
|
|
<div class="bg-white rounded-xl shadow-sm p-6 mb-6">
|
|
<div class="flex items-center justify-between mb-4">
|
|
<h3 class="text-lg font-semibold text-gray-800">
|
|
<i class="fas fa-chart-line text-green-500 mr-2"></i>전체 진행률
|
|
</h3>
|
|
<div class="text-sm text-gray-600">
|
|
<span id="completedCount">0</span> / <span id="totalCount">0</span> 완료
|
|
</div>
|
|
</div>
|
|
<div class="w-full bg-gray-200 rounded-full h-3">
|
|
<div id="progressBar" class="bg-green-500 h-3 rounded-full transition-all duration-300" style="width: 0%"></div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 필터 및 정렬 -->
|
|
<div class="bg-white rounded-xl shadow-sm p-6 mb-6">
|
|
<div class="flex flex-col md:flex-row justify-between items-start md:items-center gap-4">
|
|
<div class="flex space-x-1 bg-gray-100 rounded-lg p-1">
|
|
<button onclick="filterChecklist('all')" class="filter-tab active px-4 py-2 rounded text-sm font-medium">전체</button>
|
|
<button onclick="filterChecklist('active')" class="filter-tab px-4 py-2 rounded text-sm font-medium">할 일</button>
|
|
<button onclick="filterChecklist('completed')" class="filter-tab px-4 py-2 rounded text-sm font-medium">완료</button>
|
|
</div>
|
|
|
|
<div class="flex items-center space-x-3">
|
|
<label class="text-sm text-gray-600">정렬:</label>
|
|
<select id="sortBy" class="border border-gray-300 rounded-lg px-3 py-1 text-sm">
|
|
<option value="created_at">등록일 순</option>
|
|
<option value="completed_at">완료일 순</option>
|
|
<option value="alphabetical">가나다 순</option>
|
|
</select>
|
|
<button onclick="clearCompleted()" class="text-sm text-red-600 hover:text-red-800">
|
|
<i class="fas fa-trash mr-1"></i>완료된 항목 삭제
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 체크리스트 목록 -->
|
|
<div class="bg-white rounded-xl shadow-sm">
|
|
<div class="p-6 border-b">
|
|
<h3 class="text-lg font-semibold text-gray-800">
|
|
<i class="fas fa-list text-green-500 mr-2"></i>체크리스트 목록
|
|
</h3>
|
|
</div>
|
|
|
|
<div id="checklistList" class="divide-y divide-gray-100">
|
|
<!-- 체크리스트 항목들이 여기에 동적으로 추가됩니다 -->
|
|
</div>
|
|
|
|
<div id="emptyState" class="p-12 text-center text-gray-500">
|
|
<i class="fas fa-check-square text-4xl mb-4 opacity-50"></i>
|
|
<p>아직 체크리스트 항목이 없습니다.</p>
|
|
<p class="text-sm">메인 페이지에서 기한 없는 항목을 등록해보세요!</p>
|
|
<button onclick="goBack()" class="mt-4 btn-success px-6 py-2 rounded-lg">
|
|
<i class="fas fa-arrow-left mr-2"></i>메인으로 돌아가기
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</main>
|
|
</div>
|
|
|
|
<!-- JavaScript -->
|
|
<script src="static/js/auth.js"></script>
|
|
<script>
|
|
let checklistItems = [];
|
|
|
|
// 페이지 초기화
|
|
document.addEventListener('DOMContentLoaded', () => {
|
|
checkAuthStatus();
|
|
loadChecklistItems();
|
|
});
|
|
|
|
// 뒤로 가기
|
|
function goBack() {
|
|
window.location.href = 'index.html';
|
|
}
|
|
|
|
// 체크리스트 항목 로드
|
|
async function loadChecklistItems() {
|
|
try {
|
|
// API에서 체크리스트 카테고리 항목들만 가져오기
|
|
const items = await TodoAPI.getTodos(null, 'checklist');
|
|
checklistItems = items;
|
|
} catch (error) {
|
|
console.error('체크리스트 항목 로드 실패:', error);
|
|
checklistItems = [];
|
|
}
|
|
|
|
renderChecklistItems(checklistItems);
|
|
updateProgress();
|
|
}
|
|
|
|
// 체크리스트 항목 렌더링
|
|
function renderChecklistItems(items) {
|
|
const checklistList = document.getElementById('checklistList');
|
|
const emptyState = document.getElementById('emptyState');
|
|
|
|
if (items.length === 0) {
|
|
checklistList.innerHTML = '';
|
|
emptyState.classList.remove('hidden');
|
|
return;
|
|
}
|
|
|
|
emptyState.classList.add('hidden');
|
|
|
|
checklistList.innerHTML = items.map(item => `
|
|
<div class="checklist-item p-6 ${item.completed ? 'completed' : ''}">
|
|
<div class="flex items-start space-x-4">
|
|
<!-- 체크박스 -->
|
|
<div class="flex-shrink-0 mt-1">
|
|
<div class="checkbox-custom ${item.completed ? 'checked' : ''}" onclick="toggleComplete('${item.id}')">
|
|
${item.completed ? '<i class="fas fa-check text-xs"></i>' : ''}
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 사진 (있는 경우) -->
|
|
${item.photo ? `
|
|
<div class="flex-shrink-0">
|
|
<img src="${item.photo}" class="w-16 h-16 object-cover rounded-lg" alt="첨부 사진">
|
|
</div>
|
|
` : ''}
|
|
|
|
<!-- 내용 -->
|
|
<div class="flex-1 min-w-0">
|
|
<h4 class="item-content text-gray-900 font-medium mb-2">${item.title}</h4>
|
|
<div class="flex items-center space-x-4 text-sm text-gray-500">
|
|
<span>
|
|
<i class="fas fa-clock mr-1"></i>등록: ${formatDate(item.created_at)}
|
|
</span>
|
|
${item.completed && item.completed_at ? `
|
|
<span class="text-green-600">
|
|
<i class="fas fa-check mr-1"></i>완료: ${formatDate(item.completed_at)}
|
|
</span>
|
|
` : ''}
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 액션 버튼 -->
|
|
<div class="flex-shrink-0 flex space-x-2">
|
|
<!-- 카테고리 변경 버튼 -->
|
|
<div class="relative">
|
|
<button onclick="showCategoryMenu('${item.id}')" class="text-gray-400 hover:text-purple-500" title="카테고리 변경">
|
|
<i class="fas fa-exchange-alt"></i>
|
|
</button>
|
|
<div id="categoryMenu-${item.id}" class="hidden absolute right-0 mt-2 w-48 bg-white rounded-lg shadow-lg border z-10">
|
|
<div class="py-2">
|
|
<button onclick="changeCategory('${item.id}', 'todo')" class="w-full text-left px-4 py-2 text-sm text-gray-700 hover:bg-blue-50 hover:text-blue-600">
|
|
<i class="fas fa-calendar-day mr-2 text-blue-500"></i>Todo로 변경
|
|
</button>
|
|
<button onclick="changeCategory('${item.id}', 'calendar')" class="w-full text-left px-4 py-2 text-sm text-gray-700 hover:bg-orange-50 hover:text-orange-600">
|
|
<i class="fas fa-calendar-times mr-2 text-orange-500"></i>캘린더로 변경
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<button onclick="editChecklist('${item.id}')" class="text-gray-400 hover:text-blue-500" title="수정하기">
|
|
<i class="fas fa-edit"></i>
|
|
</button>
|
|
<button onclick="deleteChecklist('${item.id}')" class="text-gray-400 hover:text-red-500" title="삭제하기">
|
|
<i class="fas fa-trash"></i>
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
`).join('');
|
|
}
|
|
|
|
// 완료 상태 토글
|
|
function toggleComplete(id) {
|
|
const item = checklistItems.find(item => item.id === id);
|
|
if (item) {
|
|
item.completed = !item.completed;
|
|
item.completed_at = item.completed ? new Date().toISOString().split('T')[0] : null;
|
|
|
|
renderChecklistItems(checklistItems);
|
|
updateProgress();
|
|
|
|
// TODO: API 호출하여 상태 업데이트
|
|
console.log('체크리스트 완료 상태 변경:', id, item.completed);
|
|
}
|
|
}
|
|
|
|
// 진행률 업데이트
|
|
function updateProgress() {
|
|
const total = checklistItems.length;
|
|
const completed = checklistItems.filter(item => item.completed).length;
|
|
const percentage = total > 0 ? Math.round((completed / total) * 100) : 0;
|
|
|
|
document.getElementById('totalCount').textContent = total;
|
|
document.getElementById('completedCount').textContent = completed;
|
|
document.getElementById('progressText').textContent = `${percentage}% 완료`;
|
|
document.getElementById('progressBar').style.width = `${percentage}%`;
|
|
}
|
|
|
|
// 완료된 항목 삭제
|
|
function clearCompleted() {
|
|
if (confirm('완료된 모든 항목을 삭제하시겠습니까?')) {
|
|
checklistItems = checklistItems.filter(item => !item.completed);
|
|
renderChecklistItems(checklistItems);
|
|
updateProgress();
|
|
|
|
// TODO: API 호출하여 완료된 항목들 삭제
|
|
console.log('완료된 항목들 삭제');
|
|
}
|
|
}
|
|
|
|
// 체크리스트 편집
|
|
function editChecklist(id) {
|
|
console.log('체크리스트 편집:', id);
|
|
// TODO: 편집 모달 또는 페이지로 이동
|
|
}
|
|
|
|
// 체크리스트 삭제
|
|
function deleteChecklist(id) {
|
|
if (confirm('이 항목을 삭제하시겠습니까?')) {
|
|
checklistItems = checklistItems.filter(item => item.id !== id);
|
|
renderChecklistItems(checklistItems);
|
|
updateProgress();
|
|
|
|
// TODO: API 호출하여 항목 삭제
|
|
console.log('체크리스트 삭제:', id);
|
|
}
|
|
}
|
|
|
|
// 날짜 포맷팅
|
|
function formatDate(dateString) {
|
|
if (!dateString) return '날짜 없음';
|
|
const date = new Date(dateString);
|
|
if (isNaN(date.getTime())) return '날짜 없음';
|
|
return date.toLocaleDateString('ko-KR');
|
|
}
|
|
|
|
// 필터링
|
|
function filterChecklist(filter) {
|
|
let filteredItems = checklistItems;
|
|
|
|
if (filter === 'active') {
|
|
filteredItems = checklistItems.filter(item => !item.completed);
|
|
} else if (filter === 'completed') {
|
|
filteredItems = checklistItems.filter(item => item.completed);
|
|
}
|
|
|
|
renderChecklistItems(filteredItems);
|
|
|
|
// 필터 탭 활성화 상태 업데이트
|
|
document.querySelectorAll('.filter-tab').forEach(tab => {
|
|
tab.classList.remove('active');
|
|
});
|
|
event.target.classList.add('active');
|
|
|
|
console.log('필터:', filter);
|
|
}
|
|
|
|
// 카테고리 메뉴 표시/숨김
|
|
function showCategoryMenu(itemId) {
|
|
// 다른 메뉴들 숨기기
|
|
document.querySelectorAll('[id^="categoryMenu-"]').forEach(menu => {
|
|
if (menu.id !== `categoryMenu-${itemId}`) {
|
|
menu.classList.add('hidden');
|
|
}
|
|
});
|
|
|
|
// 해당 메뉴 토글
|
|
const menu = document.getElementById(`categoryMenu-${itemId}`);
|
|
if (menu) {
|
|
menu.classList.toggle('hidden');
|
|
}
|
|
}
|
|
|
|
// 카테고리 변경
|
|
async function changeCategory(itemId, newCategory) {
|
|
try {
|
|
// 날짜 입력 받기 (todo나 calendar인 경우)
|
|
let dueDate = null;
|
|
if (newCategory === 'todo' || newCategory === 'calendar') {
|
|
const dateInput = prompt(
|
|
newCategory === 'todo' ?
|
|
'시작 날짜를 입력하세요 (YYYY-MM-DD):' :
|
|
'마감 날짜를 입력하세요 (YYYY-MM-DD):'
|
|
);
|
|
|
|
if (!dateInput) {
|
|
return; // 취소
|
|
}
|
|
|
|
if (!/^\d{4}-\d{2}-\d{2}$/.test(dateInput)) {
|
|
alert('올바른 날짜 형식을 입력해주세요 (YYYY-MM-DD)');
|
|
return;
|
|
}
|
|
|
|
dueDate = dateInput + 'T09:00:00Z';
|
|
}
|
|
|
|
// API 호출하여 카테고리 변경
|
|
const updateData = {
|
|
category: newCategory
|
|
};
|
|
|
|
if (dueDate) {
|
|
updateData.due_date = dueDate;
|
|
}
|
|
|
|
await TodoAPI.updateTodo(itemId, updateData);
|
|
|
|
// 성공 메시지
|
|
const categoryNames = {
|
|
'todo': 'Todo',
|
|
'calendar': '캘린더'
|
|
};
|
|
|
|
alert(`항목이 ${categoryNames[newCategory]}로 이동되었습니다!`);
|
|
|
|
// 메뉴 숨기기
|
|
document.getElementById(`categoryMenu-${itemId}`).classList.add('hidden');
|
|
|
|
// 페이지 새로고침하여 변경된 항목 제거
|
|
await loadChecklistItems();
|
|
|
|
} catch (error) {
|
|
console.error('카테고리 변경 실패:', error);
|
|
alert('카테고리 변경에 실패했습니다.');
|
|
}
|
|
}
|
|
|
|
// 대시보드로 이동
|
|
function goToDashboard() {
|
|
window.location.href = 'dashboard.html';
|
|
}
|
|
|
|
// 전역 함수 등록
|
|
window.goToDashboard = goToDashboard;
|
|
window.showCategoryMenu = showCategoryMenu;
|
|
window.changeCategory = changeCategory;
|
|
|
|
// 문서 클릭 시 메뉴 숨기기
|
|
document.addEventListener('click', (e) => {
|
|
if (!e.target.closest('.relative')) {
|
|
document.querySelectorAll('[id^="categoryMenu-"]').forEach(menu => {
|
|
menu.classList.add('hidden');
|
|
});
|
|
}
|
|
});
|
|
</script>
|
|
<script src="static/js/api.js?v=20250921110800"></script>
|
|
<script src="static/js/auth.js?v=20250921110800"></script>
|
|
</body>
|
|
</html>
|