feat(inout,project): 남은 수량 채우기 되돌리기 · 업무 창/보드 카드에 파일 끌어 놓아 첨부

[입출고] [남은 수량 모두 채우기]를 한 번 더 누르면 채우기 전 값으로([채운 수량 되돌리기])
[프로젝트] 업무 창 아무 곳·보드 메인 업무 카드에 파일을 놓으면 첨부(여러 개), 받는 곳 밖에 놓쳐도 화면 이동 없음
[프로젝트] [파일 추가] 여러 개 선택, 도움말 갱신

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-19 14:41:26 +09:00
parent cc3e702204
commit a29854b2cb
21 changed files with 188 additions and 38 deletions
+2
View File
@@ -317,3 +317,5 @@
.io-ordercc-form { margin: 0 0 14px; max-width: 640px; }
.io-ordercc-row { display: flex; gap: 8px; align-items: center; }
.io-ordercc-row .io-in { flex: 1 1 auto; }
/* [남은 수량 모두 채우기] 를 누른 뒤 = 되돌리기 모드 */
.io-receipt-bar #io-fill-remaining.is-filled { border-color: #1e7a34; color: #1e7a34; background: #f3fbf5; }
+25 -4
View File
@@ -242,11 +242,32 @@
if (total) total.textContent = t ? "(" + fmt(t) + "개)" : "";
};
recvForm.addEventListener("input", paintTotal);
// [남은 수량 모두 채우기] — 한 번 더 누르면 채우기 전 값으로 되돌린다(2026-10-19). 채운 뒤 손으로 고친 칸도 되돌림.
const fill = document.getElementById("io-fill-remaining");
if (fill) fill.addEventListener("click", function () {
inputs.forEach(function (i) { if (!i.value.trim() && num(i.dataset.remaining)) i.value = i.dataset.remaining; });
paintTotal();
});
if (fill) {
const fillLabel = fill.textContent;
let before = null; // 채우기 직전 칸 값들 — 있으면 다음 클릭은 되돌리기
const setMode = function (filled) {
before = filled ? before : null;
fill.textContent = filled ? "채운 수량 되돌리기" : fillLabel;
fill.setAttribute("aria-pressed", filled ? "true" : "false");
fill.classList.toggle("is-filled", filled);
};
fill.addEventListener("click", function () {
if (before) {
inputs.forEach(function (i, k) { i.value = before[k]; });
setMode(false);
} else {
const snap = inputs.map(function (i) { return i.value; });
let changed = false;
inputs.forEach(function (i) {
if (!i.value.trim() && num(i.dataset.remaining)) { i.value = i.dataset.remaining; changed = true; }
});
if (changed) { before = snap; setMode(true); }
}
paintTotal();
});
}
paintTotal();
}
+17
View File
@@ -466,6 +466,23 @@ html.pj-side-resizing, html.pj-side-resizing * { cursor: col-resize !important;
.pj-card-sub.pj-sub-drop-before { box-shadow: inset 0 2px var(--pj-accent); }
.pj-card-sub.pj-sub-drop-after { box-shadow: inset 0 -2px var(--pj-accent); }
.pj-card.is-sub-drop { outline: 2px solid var(--pj-accent); outline-offset: -2px; background: var(--pj-accent-tint); }
/* 파일을 카드에 끌어 놓기 = 이 업무에 첨부(2026-10-19) — 점선 + "놓으면 첨부" 안내, 올리는 동안 흐리게 */
.pj-card.is-file-drop { position: relative; outline: 2px dashed var(--pj-accent); outline-offset: -2px; background: var(--pj-accent-tint); }
.pj-card.is-file-drop::after {
content: "놓으면 이 업무에 첨부"; position: absolute; right: 8px; bottom: 6px; padding: 2px 8px; border-radius: 999px;
background: var(--pj-accent); color: #fff; font-size: 11px; font-weight: 700; pointer-events: none;
}
.pj-card.is-file-uploading { opacity: .6; animation: pj-file-up 1s ease-in-out infinite alternate; }
@keyframes pj-file-up { from { opacity: .45; } to { opacity: .8; } }
/* 업무 창 아무 곳에 파일 끌어 놓기 — 창 전체 점선 안내(읽기 전용·저장 전 새 업무는 회색 안내) */
.pj-task-modal-card.is-file-over::after {
content: "여기에 놓으면 첨부 파일로 올라갑니다"; position: absolute; inset: 8px; z-index: 60; pointer-events: none;
display: flex; align-items: center; justify-content: center; border: 3px dashed var(--pj-accent); border-radius: 12px;
background: rgba(241, 238, 255, .88); color: var(--pj-accent); font-size: 16px; font-weight: 700;
}
.pj-task-modal-card.is-file-over.is-file-blocked::after {
content: "이 업무에는 지금 첨부할 수 없습니다(저장 전·읽기 전용)"; border-color: #9ca3af; color: #6b7280; background: rgba(243, 244, 246, .9);
}
.pj-card.is-done .pj-card-title { color: #9aa1a9; }
.pj-card-title { font-size: var(--pj-text-size); font-weight: 400; color: var(--pj-ink); line-height: var(--pj-text-leading); }
.pj-card-meta { display: flex; align-items: center; gap: 6px; margin-top: 10px; }
+102 -8
View File
@@ -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(); });
// ── 댓글 ──
// 댓글 목록(아사나식) — 댓글·완료 이력을 시간순으로, 답글은 원 댓글 아래 들여쓰기.