diff --git a/system3-nonconformance/web/issues-management.html b/system3-nonconformance/web/issues-management.html index 36f6ffc..5f8a2fc 100644 --- a/system3-nonconformance/web/issues-management.html +++ b/system3-nonconformance/web/issues-management.html @@ -349,6 +349,6 @@ - + diff --git a/system3-nonconformance/web/static/js/pages/issues-management.js b/system3-nonconformance/web/static/js/pages/issues-management.js index dc1f3cf..2be57de 100644 --- a/system3-nonconformance/web/static/js/pages/issues-management.js +++ b/system3-nonconformance/web/static/js/pages/issues-management.js @@ -427,25 +427,37 @@ function createInProgressRow(issue, project) {
${(() => { - const photos = [ + const photoSlots = [ issue.photo_path, issue.photo_path2, issue.photo_path3, issue.photo_path4, issue.photo_path5 - ].filter(p => p); + ]; + const filled = photoSlots.filter(p => p); + const emptyCount = 5 - filled.length; - if (photos.length === 0) { - return '
사진 없음
'; - } + const existing = filled.length === 0 + ? '
사진 없음
' + : `
+ ${filled.map((path, idx) => ` + 업로드 사진 ${idx + 1} + `).join('')} +
`; - return ` -
- ${photos.map((path, idx) => ` - 업로드 사진 ${idx + 1} - `).join('')} + // 사진 보충 UI (빈 슬롯에만 채움, 저장 버튼 클릭 시 업로드) + const uploadUi = isPendingCompletion ? '' : (emptyCount > 0 ? ` +
+ + +

※ 비어있는 슬롯에만 자동으로 채워집니다 (기존 사진은 유지). 저장 버튼 클릭 시 업로드.

- `; + ` : '

5장 모두 찬 상태입니다

'); + + return existing + uploadUi; })()}
@@ -909,6 +921,36 @@ async function saveIssueChanges(issueId) { } } + // 원본 사진 보충 — 빈 슬롯에만 자동 채움 (기존 사진 유지) + const originalPhotoInput = document.getElementById(`original_photo_${issueId}`); + if (originalPhotoInput && originalPhotoInput.files && originalPhotoInput.files.length > 0) { + const currentIssue = issues.find(i => i.id === issueId); + if (currentIssue) { + const slotKeys = ['photo_path', 'photo_path2', 'photo_path3', 'photo_path4', 'photo_path5']; + const emptySlots = []; + slotKeys.forEach((key, idx) => { + if (!currentIssue[key]) emptySlots.push(idx + 1); + }); + + if (emptySlots.length === 0) { + alert('원본 사진 슬롯이 가득 찼습니다. 보충할 수 없습니다.'); + return; + } + + const files = Array.from(originalPhotoInput.files).slice(0, emptySlots.length); + if (originalPhotoInput.files.length > emptySlots.length) { + alert(`빈 슬롯은 ${emptySlots.length}개인데 ${originalPhotoInput.files.length}개를 선택하셨습니다. 처음 ${emptySlots.length}장만 업로드됩니다.`); + } + + for (let i = 0; i < files.length; i++) { + const slotNum = emptySlots[i]; + const base64 = await fileToBase64(files[i]); + const fieldName = slotNum === 1 ? 'photo' : `photo${slotNum}`; + updates[fieldName] = base64; + } + } + } + // API 호출 const response = await fetch(`/api/issues/${issueId}/management`, { method: 'PUT',