일정 설정 오류 수정: formatRelativeTime 함수 추가, 기존 일정 수정 지원
This commit is contained in:
@@ -213,10 +213,15 @@ function todosApp() {
|
||||
// 일정 설정 모달 열기
|
||||
openScheduleModal(todo) {
|
||||
this.currentTodo = todo;
|
||||
|
||||
// 기존 값이 있으면 사용, 없으면 기본값
|
||||
this.scheduleForm = {
|
||||
start_date: this.formatDateLocal(new Date()),
|
||||
estimated_minutes: 30
|
||||
start_date: todo.start_date ?
|
||||
new Date(todo.start_date).toISOString().slice(0, 10) :
|
||||
this.formatDateLocal(new Date()),
|
||||
estimated_minutes: todo.estimated_minutes || 30
|
||||
};
|
||||
|
||||
this.showScheduleModal = true;
|
||||
},
|
||||
|
||||
@@ -259,10 +264,22 @@ function todosApp() {
|
||||
// 날짜만 사용하여 해당 날짜의 시작 시간으로 설정
|
||||
const startDate = new Date(this.scheduleForm.start_date + 'T00:00:00');
|
||||
|
||||
const response = await window.api.post(`/todos/${this.currentTodo.id}/schedule`, {
|
||||
start_date: startDate.toISOString(),
|
||||
estimated_minutes: newMinutes
|
||||
});
|
||||
let response;
|
||||
|
||||
// 이미 일정이 설정된 할일인지 확인
|
||||
if (this.currentTodo.status === 'draft') {
|
||||
// 새로 일정 설정
|
||||
response = await window.api.post(`/todos/${this.currentTodo.id}/schedule`, {
|
||||
start_date: startDate.toISOString(),
|
||||
estimated_minutes: newMinutes
|
||||
});
|
||||
} else {
|
||||
// 기존 일정 수정
|
||||
response = await window.api.put(`/todos/${this.currentTodo.id}`, {
|
||||
start_date: startDate.toISOString(),
|
||||
estimated_minutes: newMinutes
|
||||
});
|
||||
}
|
||||
|
||||
// 할일 업데이트
|
||||
const index = this.todos.findIndex(t => t.id === this.currentTodo.id);
|
||||
@@ -305,14 +322,10 @@ function todosApp() {
|
||||
}
|
||||
},
|
||||
|
||||
// 지연 모달 열기 (일정 설정 모달 재사용)
|
||||
// 지연 모달 열기 (일정 설정 모달 재사용) - 더 이상 사용하지 않음
|
||||
openDelayModal(todo) {
|
||||
this.currentTodo = todo;
|
||||
this.scheduleForm = {
|
||||
start_date: this.formatDateLocal(new Date(Date.now() + 24 * 60 * 60 * 1000)), // 내일
|
||||
estimated_minutes: todo.estimated_minutes || 30
|
||||
};
|
||||
this.showScheduleModal = true; // 일정 설정 모달 사용
|
||||
// 일정변경과 동일하게 처리
|
||||
this.openScheduleModal(todo);
|
||||
},
|
||||
|
||||
|
||||
@@ -445,6 +458,24 @@ function todosApp() {
|
||||
return d.toISOString().slice(0, 10);
|
||||
},
|
||||
|
||||
formatRelativeTime(dateString) {
|
||||
if (!dateString) return '';
|
||||
|
||||
const date = new Date(dateString);
|
||||
const now = new Date();
|
||||
const diffMs = now - date;
|
||||
const diffMinutes = Math.floor(diffMs / (1000 * 60));
|
||||
const diffHours = Math.floor(diffMs / (1000 * 60 * 60));
|
||||
const diffDays = Math.floor(diffMs / (1000 * 60 * 60 * 24));
|
||||
|
||||
if (diffMinutes < 1) return '방금 전';
|
||||
if (diffMinutes < 60) return `${diffMinutes}분 전`;
|
||||
if (diffHours < 24) return `${diffHours}시간 전`;
|
||||
if (diffDays < 7) return `${diffDays}일 전`;
|
||||
|
||||
return date.toLocaleDateString('ko-KR');
|
||||
},
|
||||
|
||||
// 햅틱 피드백 (모바일)
|
||||
hapticFeedback(element) {
|
||||
// 진동 API 지원 확인
|
||||
|
||||
Reference in New Issue
Block a user