feat(inout,project): 남은 수량 채우기 되돌리기 · 업무 창/보드 카드에 파일 끌어 놓아 첨부
[입출고] [남은 수량 모두 채우기]를 한 번 더 누르면 채우기 전 값으로([채운 수량 되돌리기]) [프로젝트] 업무 창 아무 곳·보드 메인 업무 카드에 파일을 놓으면 첨부(여러 개), 받는 곳 밖에 놓쳐도 화면 이동 없음 [프로젝트] [파일 추가] 여러 개 선택, 도움말 갱신 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+102
-8
@@ -6251,6 +6251,36 @@
|
||||
e.preventDefault();
|
||||
showContextMenu(e.clientX, e.clientY, taskContextItems(t));
|
||||
});
|
||||
// 파일을 카드에 끌어 놓으면 이 업무에 첨부(2026-10-19) — 카드 끌기(text/plain)·세부 업무 끌기와는 종류("Files")로 구분
|
||||
let fileDepth = 0;
|
||||
card.addEventListener("dragenter", function (e) {
|
||||
if (!dragHasFiles(e)) return;
|
||||
e.preventDefault();
|
||||
fileDepth++;
|
||||
card.classList.add("is-file-drop");
|
||||
});
|
||||
card.addEventListener("dragover", function (e) {
|
||||
if (!dragHasFiles(e)) return;
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
e.dataTransfer.dropEffect = "copy";
|
||||
});
|
||||
card.addEventListener("dragleave", function (e) {
|
||||
if (!dragHasFiles(e)) return;
|
||||
if (--fileDepth <= 0) { fileDepth = 0; card.classList.remove("is-file-drop"); }
|
||||
});
|
||||
card.addEventListener("drop", async function (e) {
|
||||
if (!dragHasFiles(e)) return;
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
fileDepth = 0;
|
||||
card.classList.remove("is-file-drop");
|
||||
card.classList.add("is-file-uploading");
|
||||
const out = await uploadTaskFiles(t.id, e.dataTransfer.files);
|
||||
card.classList.remove("is-file-uploading");
|
||||
reportUpload(out, t.title || "");
|
||||
if (currentTaskId === t.id && !taskModal.hidden) loadAttachments(t.id); // 열려 있는 업무 창도 바로
|
||||
});
|
||||
}
|
||||
return card;
|
||||
}
|
||||
@@ -7768,18 +7798,82 @@
|
||||
});
|
||||
} catch (e) { ul.innerHTML = "<li class='pj-empty-sm'>불러오기 실패</li>"; }
|
||||
}
|
||||
// 업무에 파일 올리기(여러 개는 하나씩 차례로) — [파일 추가]·업무 창에 끌어 놓기·보드 카드에 끌어 놓기 공용.
|
||||
// 반환 { ok: 올린 수, errors: ["파일 이름: 이유"] }
|
||||
async function uploadTaskFiles(taskId, files) {
|
||||
const out = { ok: 0, errors: [] };
|
||||
for (const f of Array.prototype.slice.call(files || [])) {
|
||||
const fd = new FormData();
|
||||
fd.append("file", f);
|
||||
try {
|
||||
const res = await fetch("/project/api/tasks/" + taskId + "/attachments", { method: "POST", body: fd });
|
||||
if (!res.ok) { let m = res.statusText; try { m = (await res.json()).detail; } catch (_) {} throw new Error(m); }
|
||||
out.ok++;
|
||||
} catch (e) { out.errors.push(f.name + ": " + e.message); }
|
||||
}
|
||||
return out;
|
||||
}
|
||||
function reportUpload(out, where) {
|
||||
if (out.ok) showToast((where ? "‘" + where + "’에 " : "") + "파일 " + out.ok + "개를 첨부했습니다.");
|
||||
if (out.errors.length) showToast("업로드 실패 — " + out.errors.join(" / "), "error");
|
||||
}
|
||||
// 끌고 있는 것이 "파일"인가(카드 끌기·글자 끌기와 구분)
|
||||
function dragHasFiles(e) {
|
||||
return !!(e.dataTransfer && Array.prototype.indexOf.call(e.dataTransfer.types || [], "Files") >= 0);
|
||||
}
|
||||
const attachInput = el("pj-attach-input");
|
||||
if (attachInput) attachInput.addEventListener("change", async function () {
|
||||
if (!currentTaskId || !attachInput.files.length) return;
|
||||
const fd = new FormData();
|
||||
fd.append("file", attachInput.files[0]);
|
||||
try {
|
||||
const res = await fetch("/project/api/tasks/" + currentTaskId + "/attachments", { method: "POST", body: fd });
|
||||
if (!res.ok) { let m = res.statusText; try { m = (await res.json()).detail; } catch (_) {} throw new Error(m); }
|
||||
attachInput.value = "";
|
||||
loadAttachments(currentTaskId);
|
||||
} catch (e) { alert("업로드 실패: " + e.message); }
|
||||
const out = await uploadTaskFiles(currentTaskId, attachInput.files);
|
||||
attachInput.value = "";
|
||||
if (out.errors.length) alert("업로드 실패: " + out.errors.join("\n"));
|
||||
loadAttachments(currentTaskId);
|
||||
});
|
||||
// ── 업무 창 아무 곳에나 파일을 끌어 놓으면 첨부(2026-10-19) — 창 전체에 점선 안내가 뜨고, 놓으면 [첨부 파일]에 올라간다.
|
||||
// 설명칸에 놓아도 글에 끼워 넣지 않고 첨부로. 아직 저장 전인 새 업무·읽기 전용이면 안내만.
|
||||
(function wireTaskFileDrop() {
|
||||
const card = taskModal && taskModal.querySelector(".pj-task-modal-card");
|
||||
if (!card) return;
|
||||
let depth = 0;
|
||||
const clear = function () { depth = 0; card.classList.remove("is-file-over"); };
|
||||
card.addEventListener("dragenter", function (e) {
|
||||
if (!dragHasFiles(e)) return;
|
||||
e.preventDefault();
|
||||
depth++;
|
||||
card.classList.add("is-file-over");
|
||||
card.classList.toggle("is-file-blocked", !currentTaskId || !canManage || taskReadOnly);
|
||||
});
|
||||
card.addEventListener("dragover", function (e) {
|
||||
if (!dragHasFiles(e)) return;
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
e.dataTransfer.dropEffect = (!currentTaskId || !canManage || taskReadOnly) ? "none" : "copy";
|
||||
});
|
||||
card.addEventListener("dragleave", function (e) {
|
||||
if (!dragHasFiles(e)) return;
|
||||
if (--depth <= 0) clear();
|
||||
});
|
||||
card.addEventListener("drop", async function (e) {
|
||||
if (!dragHasFiles(e)) return;
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
clear();
|
||||
if (!canManage || taskReadOnly) { showToast("이 업무에는 파일을 첨부할 수 없습니다(읽기 전용).", "error"); return; }
|
||||
if (!currentTaskId) { showToast("업무 이름을 먼저 넣어 업무를 만든 뒤 파일을 끌어 놓으세요.", "error"); return; }
|
||||
const taskId = currentTaskId;
|
||||
const out = await uploadTaskFiles(taskId, e.dataTransfer.files);
|
||||
reportUpload(out, "");
|
||||
if (currentTaskId === taskId) loadAttachments(taskId);
|
||||
});
|
||||
window.addEventListener("dragend", clear);
|
||||
})();
|
||||
// 파일을 받는 곳(업무 창·보드 카드) 밖에 놓쳐도 브라우저가 그 파일을 열어 화면을 떠나지 않게 — 받는 곳은 위에서 stopPropagation
|
||||
document.addEventListener("dragover", function (e) {
|
||||
if (!dragHasFiles(e) || e.defaultPrevented) return;
|
||||
e.preventDefault();
|
||||
e.dataTransfer.dropEffect = "none";
|
||||
});
|
||||
document.addEventListener("drop", function (e) { if (dragHasFiles(e) && !e.defaultPrevented) e.preventDefault(); });
|
||||
|
||||
// ── 댓글 ──
|
||||
// 댓글 목록(아사나식) — 댓글·완료 이력을 시간순으로, 답글은 원 댓글 아래 들여쓰기.
|
||||
|
||||
Reference in New Issue
Block a user