diff --git a/resources/views/daily-logs/index.blade.php b/resources/views/daily-logs/index.blade.php index 3a6050d9..82fbec01 100644 --- a/resources/views/daily-logs/index.blade.php +++ b/resources/views/daily-logs/index.blade.php @@ -289,8 +289,22 @@ class="bg-white rounded-lg shadow-sm overflow-hidden">
- 담당자 -

+ + + + + + + @foreach($assignees['teams'] ?? [] as $team) + + @endforeach + @foreach($assignees['users'] ?? [] as $user) + + @endforeach +
@@ -819,35 +833,9 @@ function deleteTableEntry(logId, entryId) { } } - // 테이블 빠른 항목 추가 + // 테이블 빠른 항목 추가 - 미완료 항목 수정 모달 사용 function openQuickAddTableEntry(logId) { - const content = prompt('업무 내용을 입력하세요:'); - if (content && content.trim()) { - const assigneeName = prompt('담당자 이름을 입력하세요:'); - if (assigneeName && assigneeName.trim()) { - fetch(`/api/admin/daily-logs/${logId}/entries`, { - method: 'POST', - headers: { - 'Content-Type': 'application/json', - 'X-CSRF-TOKEN': '{{ csrf_token() }}' - }, - body: JSON.stringify({ - assignee_type: 'user', - assignee_name: assigneeName.trim(), - content: content.trim(), - status: 'todo' - }) - }) - .then(res => res.json()) - .then(result => { - if (result.success) { - loadTableAccordionContent(logId); - } else { - alert(result.message || '오류가 발생했습니다.'); - } - }); - } - } + openQuickAddModal(logId); } // HTMX 로드 완료 후 테이블 아코디언 상태 리셋 @@ -977,13 +965,18 @@ class="p-0.5 text-green-500 hover:bg-green-50 rounded" title="완료"> // ======================================== let pendingEditEntries = []; let pendingEditAssigneeName = ''; + let pendingEditFromAccordion = null; // 아코디언에서 열렸으면 logId 저장 - // 모달 열기 + // 모달 열기 (기존 항목 수정) function openPendingEditModal(entriesJson, assigneeName) { pendingEditEntries = entriesJson; pendingEditAssigneeName = assigneeName; + pendingEditFromAccordion = null; // 기존 항목 수정 모드 - document.getElementById('pendingEditAssigneeName').textContent = assigneeName; + // 담당자 텍스트 표시, 입력 필드 숨김 + document.getElementById('pendingEditAssigneeNameText').textContent = assigneeName; + document.getElementById('pendingEditAssigneeNameText').classList.remove('hidden'); + document.getElementById('pendingEditAssigneeNameInput').classList.add('hidden'); // 컨테이너 초기화 및 항목 추가 const container = document.getElementById('pendingEditEntriesContainer'); @@ -996,11 +989,37 @@ function openPendingEditModal(entriesJson, assigneeName) { document.getElementById('pendingEditModal').classList.remove('hidden'); } + // 모달 열기 (새 항목 추가 - 아코디언에서) + function openQuickAddModal(logId) { + pendingEditEntries = [{ id: '', content: '', status: 'todo', daily_log_id: logId }]; + pendingEditAssigneeName = ''; + pendingEditFromAccordion = logId; + + // 담당자 입력 필드 표시, 텍스트 숨김 + document.getElementById('pendingEditAssigneeNameText').classList.add('hidden'); + const assigneeInput = document.getElementById('pendingEditAssigneeNameInput'); + assigneeInput.value = ''; + assigneeInput.classList.remove('hidden'); + + // 컨테이너 초기화 및 빈 항목 추가 + const container = document.getElementById('pendingEditEntriesContainer'); + container.innerHTML = ''; + addPendingEntryRow({ id: '', content: '', status: 'todo', daily_log_id: logId }, 0); + + document.getElementById('pendingEditModal').classList.remove('hidden'); + + // 담당자 입력 필드에 포커스 + setTimeout(() => { + assigneeInput.focus(); + }, 100); + } + // 모달 닫기 function closePendingEditModal() { document.getElementById('pendingEditModal').classList.add('hidden'); pendingEditEntries = []; pendingEditAssigneeName = ''; + pendingEditFromAccordion = null; } // 항목 행 추가 @@ -1012,6 +1031,12 @@ function addPendingEntryRow(entry = null, index = null) { const currentStatus = entry?.status || 'todo'; + // 새 항목인 경우 기존 항목의 daily_log_id 사용 + let dailyLogId = entry?.daily_log_id || ''; + if (!dailyLogId && pendingEditEntries.length > 0) { + dailyLogId = pendingEditEntries[0].daily_log_id || ''; + } + const html = `
@@ -1039,7 +1064,7 @@ class="w-full px-3 py-1.5 text-sm border border-gray-300 rounded-lg focus:ring-2 placeholder="업무 내용">${escapeHtml(entry?.content || '')}
- +