✨ 주요 기능 추가: - 다중 이미지 업로드 지원 (최대 5개) - 체크리스트 완료 시 자동 사라짐 기능 - 캘린더 상세 모달에서 다중 이미지 표시 - Todo 변환 시 기존 이미지 보존 및 새 이미지 추가 🔧 백엔드 수정: - Todo 모델: image_url → image_urls (JSON 배열) - API 엔드포인트: 다중 이미지 직렬화/역직렬화 - 새 엔드포인트: POST /todos/{id}/add-image (이미지 추가) - 데이터베이스 마이그레이션 스크립트 추가 🎨 프론트엔드 개선: - 대시보드: 실제 API 데이터 연동, 다중 이미지 표시 - 업로드 모달: 다중 파일 선택, 실시간 미리보기, 5개 제한 - 체크리스트: 완료 시 1.5초 후 자동 제거, 토스트 메시지 - 캘린더 모달: 2x2 그리드 이미지 표시, 클릭 확대 - Todo 변환: 기존 이미지 + 새 이미지 합치기 🐛 버그 수정: - currentPhoto 변수 오류 해결 - 이미지 표시 문제 (단일 → 다중 지원) - 완료 처리 로컬/백엔드 동기화 - 새로고침 시 완료 항목 재출현 문제
354 lines
16 KiB
HTML
354 lines
16 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="ko">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Todo - 시작 날짜가 있는 일들</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);
|
|
}
|
|
|
|
.todo-item {
|
|
background: white;
|
|
border-radius: 0.75rem;
|
|
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
|
|
transition: all 0.2s;
|
|
}
|
|
|
|
.todo-item:hover {
|
|
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
|
|
}
|
|
</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-calendar-day text-2xl text-blue-500 mr-3"></i>
|
|
<h1 class="text-xl font-semibold text-gray-800">Todo</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-blue-50 rounded-xl p-6 mb-8">
|
|
<div class="flex items-center mb-4">
|
|
<i class="fas fa-calendar-day text-2xl text-blue-600 mr-3"></i>
|
|
<h2 class="text-xl font-semibold text-blue-900">Todo 관리</h2>
|
|
</div>
|
|
<p class="text-blue-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-blue-900 mb-1">📅 시작 예정</div>
|
|
<div class="text-blue-700">아직 시작하지 않은 일들</div>
|
|
</div>
|
|
<div class="bg-white rounded-lg p-3">
|
|
<div class="font-medium text-blue-900 mb-1">🔥 진행 중</div>
|
|
<div class="text-blue-700">현재 작업 중인 일들</div>
|
|
</div>
|
|
<div class="bg-white rounded-lg p-3">
|
|
<div class="font-medium text-blue-900 mb-1">✅ 완료</div>
|
|
<div class="text-blue-700">완료된 일들</div>
|
|
</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="filterTodos('all')" class="filter-tab active px-4 py-2 rounded text-sm font-medium">전체</button>
|
|
<button onclick="filterTodos('scheduled')" class="filter-tab px-4 py-2 rounded text-sm font-medium">시작 예정</button>
|
|
<button onclick="filterTodos('active')" class="filter-tab px-4 py-2 rounded text-sm font-medium">진행 중</button>
|
|
<button onclick="filterTodos('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="start_date">시작일 순</option>
|
|
<option value="created_at">등록일 순</option>
|
|
<option value="priority">우선순위 순</option>
|
|
</select>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Todo 목록 -->
|
|
<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-blue-500 mr-2"></i>Todo 목록
|
|
</h3>
|
|
</div>
|
|
|
|
<div id="todoList" class="divide-y divide-gray-100">
|
|
<!-- Todo 항목들이 여기에 동적으로 추가됩니다 -->
|
|
</div>
|
|
|
|
<div id="emptyState" class="p-12 text-center text-gray-500">
|
|
<i class="fas fa-calendar-day text-4xl mb-4 opacity-50"></i>
|
|
<p>아직 시작 날짜가 설정된 일이 없습니다.</p>
|
|
<p class="text-sm">메인 페이지에서 항목을 등록하고 시작 날짜를 설정해보세요!</p>
|
|
<button onclick="goBack()" class="mt-4 btn-primary 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>
|
|
// 페이지 초기화
|
|
document.addEventListener('DOMContentLoaded', () => {
|
|
checkAuthStatus();
|
|
loadTodoItems();
|
|
});
|
|
|
|
// 뒤로 가기
|
|
function goBack() {
|
|
window.location.href = 'index.html';
|
|
}
|
|
|
|
// Todo 항목 로드
|
|
async function loadTodoItems() {
|
|
try {
|
|
// API에서 Todo 카테고리 항목들만 가져오기
|
|
const items = await TodoAPI.getTodos(null, 'todo');
|
|
renderTodoItems(items);
|
|
} catch (error) {
|
|
console.error('Todo 항목 로드 실패:', error);
|
|
renderTodoItems([]);
|
|
}
|
|
}
|
|
|
|
// Todo 항목 렌더링
|
|
function renderTodoItems(items) {
|
|
const todoList = document.getElementById('todoList');
|
|
const emptyState = document.getElementById('emptyState');
|
|
|
|
if (items.length === 0) {
|
|
todoList.innerHTML = '';
|
|
emptyState.classList.remove('hidden');
|
|
return;
|
|
}
|
|
|
|
emptyState.classList.add('hidden');
|
|
|
|
todoList.innerHTML = items.map(item => `
|
|
<div class="todo-item p-6">
|
|
<div class="flex items-start space-x-4">
|
|
<!-- 상태 아이콘 -->
|
|
<div class="flex-shrink-0 mt-1">
|
|
<div class="w-8 h-8 rounded-full flex items-center justify-center ${getStatusColor(item.status)}">
|
|
<i class="fas ${getStatusIcon(item.status)} text-sm"></i>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 사진 (있는 경우) -->
|
|
${item.image_urls && item.image_urls.length > 0 ? `
|
|
<div class="flex-shrink-0">
|
|
<div class="flex space-x-2">
|
|
${item.image_urls.slice(0, 3).map(url => `
|
|
<img src="${url}" class="w-16 h-16 object-cover rounded-lg" alt="첨부 사진">
|
|
`).join('')}
|
|
${item.image_urls.length > 3 ? `
|
|
<div class="w-16 h-16 bg-gray-100 rounded-lg flex items-center justify-center">
|
|
<span class="text-xs text-gray-500">+${item.image_urls.length - 3}</span>
|
|
</div>
|
|
` : ''}
|
|
</div>
|
|
</div>
|
|
` : ''}
|
|
|
|
<!-- 내용 -->
|
|
<div class="flex-1 min-w-0">
|
|
<h4 class="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-calendar mr-1"></i>마감일: ${formatDate(item.due_date)}
|
|
</span>
|
|
<span>
|
|
<i class="fas fa-clock mr-1"></i>등록: ${formatDate(item.created_at)}
|
|
</span>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 액션 버튼 -->
|
|
<div class="flex-shrink-0 flex space-x-2">
|
|
${item.status !== 'completed' ? `
|
|
<button onclick="delayTodo('${item.id}')" class="text-orange-500 hover:text-orange-700" title="지연하기">
|
|
<i class="fas fa-clock"></i>
|
|
</button>
|
|
<button onclick="completeTodo('${item.id}')" class="text-green-500 hover:text-green-700" title="완료하기">
|
|
<i class="fas fa-check"></i>
|
|
</button>
|
|
<button onclick="splitTodo('${item.id}')" class="text-purple-500 hover:text-purple-700" title="분할하기">
|
|
<i class="fas fa-cut"></i>
|
|
</button>
|
|
` : ''}
|
|
<button onclick="editTodo('${item.id}')" class="text-gray-400 hover:text-blue-500" title="수정하기">
|
|
<i class="fas fa-edit"></i>
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
`).join('');
|
|
}
|
|
|
|
// 상태별 색상
|
|
function getStatusColor(status) {
|
|
const colors = {
|
|
scheduled: 'bg-blue-100 text-blue-600',
|
|
active: 'bg-orange-100 text-orange-600',
|
|
completed: 'bg-green-100 text-green-600'
|
|
};
|
|
return colors[status] || 'bg-gray-100 text-gray-600';
|
|
}
|
|
|
|
// 상태별 아이콘
|
|
function getStatusIcon(status) {
|
|
const icons = {
|
|
scheduled: 'fa-calendar',
|
|
active: 'fa-play',
|
|
completed: 'fa-check'
|
|
};
|
|
return icons[status] || 'fa-circle';
|
|
}
|
|
|
|
// 날짜 포맷팅
|
|
function formatDate(dateString) {
|
|
if (!dateString) return '날짜 없음';
|
|
const date = new Date(dateString);
|
|
if (isNaN(date.getTime())) return '날짜 없음';
|
|
return date.toLocaleDateString('ko-KR');
|
|
}
|
|
|
|
// Todo 지연
|
|
function delayTodo(id) {
|
|
const newDate = prompt('새로운 시작 날짜를 입력하세요 (YYYY-MM-DD):');
|
|
if (newDate && /^\d{4}-\d{2}-\d{2}$/.test(newDate)) {
|
|
// TODO: API 호출하여 due_date 업데이트
|
|
console.log('Todo 지연:', id, '새 날짜:', newDate);
|
|
alert(`할 일이 ${newDate}로 지연되었습니다.`);
|
|
loadTodoItems(); // 목록 새로고침
|
|
} else if (newDate) {
|
|
alert('올바른 날짜 형식을 입력해주세요 (YYYY-MM-DD)');
|
|
}
|
|
}
|
|
|
|
// Todo 완료
|
|
async function completeTodo(id) {
|
|
try {
|
|
// TODO: API 호출하여 상태를 'completed'로 변경
|
|
console.log('Todo 완료:', id);
|
|
alert('할 일이 완료되었습니다!');
|
|
loadTodoItems(); // 목록 새로고침
|
|
} catch (error) {
|
|
console.error('완료 처리 실패:', error);
|
|
alert('완료 처리에 실패했습니다.');
|
|
}
|
|
}
|
|
|
|
// Todo 분할
|
|
function splitTodo(id) {
|
|
const splitCount = prompt('몇 개로 분할하시겠습니까? (2-5개):');
|
|
const count = parseInt(splitCount);
|
|
|
|
if (count >= 2 && count <= 5) {
|
|
const subtasks = [];
|
|
for (let i = 1; i <= count; i++) {
|
|
const subtask = prompt(`${i}번째 세부 작업을 입력하세요:`);
|
|
if (subtask) {
|
|
subtasks.push(subtask.trim());
|
|
}
|
|
}
|
|
|
|
if (subtasks.length > 0) {
|
|
// TODO: API 호출하여 원본 삭제 후 세부 작업들 생성
|
|
console.log('Todo 분할:', id, '세부 작업들:', subtasks);
|
|
alert(`할 일이 ${subtasks.length}개의 세부 작업으로 분할되었습니다.`);
|
|
loadTodoItems(); // 목록 새로고침
|
|
}
|
|
} else if (splitCount) {
|
|
alert('2-5개 사이의 숫자를 입력해주세요.');
|
|
}
|
|
}
|
|
|
|
// Todo 편집
|
|
function editTodo(id) {
|
|
console.log('Todo 편집:', id);
|
|
// TODO: 편집 모달 또는 페이지로 이동
|
|
alert('편집 기능은 준비 중입니다.');
|
|
}
|
|
|
|
// 필터링
|
|
function filterTodos(filter) {
|
|
console.log('필터:', filter);
|
|
// TODO: 필터에 따라 목록 재로드
|
|
}
|
|
|
|
// 대시보드로 이동
|
|
function goToDashboard() {
|
|
window.location.href = 'dashboard.html';
|
|
}
|
|
|
|
// 전역 함수 등록
|
|
window.goToDashboard = goToDashboard;
|
|
</script>
|
|
<script src="static/js/api.js?v=20250921110800"></script>
|
|
<script src="static/js/auth.js?v=20250921110800"></script>
|
|
</body>
|
|
</html>
|