feat(project): 보드 카드 하위 작업 목록에 "+ 하위 작업 추가"(아사나식 인라인 입력)

- 펼친 하위 작업 맨 아래 "+ 하위 작업 추가" — 누르면 새 줄(작업 이름 입력 ·
  마감일 점선 달력 · 담당자 점선 아이콘)이 열리고 Enter 로 바로 생성, 줄은 열린
  채 다음 입력. Esc/빈 채로 벗어나면 닫힘
- 8초 실시간 새로고침으로 보드가 다시 그려져도 입력값·포커스 유지(subDrafts)
- fix: 날짜 팝업·우클릭 메뉴가 열린 직후(같은 틱) 닫히면 문서 리스너가 남아
  이후 Esc 를 계속 삼키던 경쟁 조건 — 등록 전에 이미 닫혔는지 확인
- 정적 파일 버전 20260925k

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-09-25 22:11:01 +09:00
parent 87c73c65af
commit 6acf69ba29
7 changed files with 163 additions and 8 deletions
@@ -1,7 +1,7 @@
{% extends "erp_base.html" %}
{% block head_extra %}
<link rel="stylesheet" href="/static/project.css?v=20260925j" />
<link rel="stylesheet" href="/static/project.css?v=20260925k" />
<link rel="stylesheet" href="/static/vendor/material-symbols/material-symbols.css" />
{% endblock %}
@@ -99,5 +99,5 @@
{% include "project/_side_modals.html" %}
{% include "project/_member_tasks_modal.html" %}
<script src="/static/project.js?v=20260925j" defer></script>
<script src="/static/project.js?v=20260925k" defer></script>
{% endblock %}
@@ -1,7 +1,7 @@
{% extends "erp_base.html" %}
{% block head_extra %}
<link rel="stylesheet" href="/static/project.css?v=20260925j" />
<link rel="stylesheet" href="/static/project.css?v=20260925k" />
<link rel="stylesheet" href="/static/vendor/material-symbols/material-symbols.css" />
{% endblock %}
@@ -98,5 +98,5 @@
"today": {{ today | tojson }}
}
</script>
<script src="/static/project.js?v=20260925j" defer></script>
<script src="/static/project.js?v=20260925k" defer></script>
{% endblock %}
@@ -1,7 +1,7 @@
{% extends "erp_base.html" %}
{% block head_extra %}
<link rel="stylesheet" href="/static/project.css?v=20260925j" />
<link rel="stylesheet" href="/static/project.css?v=20260925k" />
<!-- 구글 머티리얼 심볼(담당자 아이콘 등) — self-host -->
<link rel="stylesheet" href="/static/vendor/material-symbols/material-symbols.css" />
<!-- 타임라인 vis-timeline — self-host -->
@@ -465,5 +465,5 @@
</script>
<script src="/static/vendor/vis-timeline/vis-timeline-graph2d.min.js"></script>
<script src="/static/project.js?v=20260925j" defer></script>
<script src="/static/project.js?v=20260925k" defer></script>
{% endblock %}
@@ -1,7 +1,7 @@
{% extends "erp_base.html" %}
{% block head_extra %}
<link rel="stylesheet" href="/static/project.css?v=20260925j" />
<link rel="stylesheet" href="/static/project.css?v=20260925k" />
<link rel="stylesheet" href="/static/vendor/material-symbols/material-symbols.css" />
{% endblock %}
@@ -68,5 +68,5 @@
{% include "project/_side_modals.html" %}
{% include "project/_member_tasks_modal.html" %}
<script src="/static/project.js?v=20260925j" defer></script>
<script src="/static/project.js?v=20260925k" defer></script>
{% endblock %}
+22
View File
@@ -886,6 +886,28 @@
.pj-card-sub:hover .pj-card-sub-av.is-empty { opacity: 1; }
.pj-card-sub-av.is-empty:hover { color: #1e1f21; background: #eceef0; }
.pj-card-sub-empty { padding: 8px 4px; font-size: 12px; color: #9aa1a9; }
/* 카드 하위 작업 맨 아래 "+ 하위 작업 추가"와 새 줄 입력(아사나) */
.pj-card-subnew {
display: flex; align-items: center; gap: 6px; min-height: 36px; padding: 2px 4px;
border-bottom: 2px solid var(--pj-accent, #4573d2); font-size: 13px; color: var(--pj-ink);
}
.pj-card-sub-check.is-ghost { cursor: default; color: #b8bdc4; }
.pj-card-sub-check.is-ghost:hover { color: #b8bdc4; }
.pj-card-subnew-title {
flex: 1 1 0; min-width: 0; border: none; outline: none; background: transparent;
padding: 4px 0; font-size: 13px; font-family: inherit; color: var(--pj-ink);
}
.pj-card-subnew-title::placeholder { color: #9aa1a9; }
/* 새 줄의 마감일·담당자 아이콘은 늘 보인다(기존 줄은 마우스를 올릴 때만) */
.pj-card-subnew .pj-card-sub-due.is-empty,
.pj-card-subnew .pj-card-sub-av.is-empty { opacity: 1; }
.pj-card-subadd {
display: inline-flex; align-items: center; gap: 4px; margin: 6px 0 2px; padding: 4px 6px;
border: none; background: transparent; border-radius: 6px; cursor: pointer;
font-size: 12.5px; font-weight: 600; color: #6d6e6f; font-family: inherit;
}
.pj-card-subadd .material-symbols-outlined { font-size: 17px; }
.pj-card-subadd:hover { background: #f1f2f4; color: var(--pj-ink); }
/* 프로젝트 스코프 토글(이 프로젝트 / 전체 프로젝트) — 뷰 탭과 같은 모양 재사용 */
#pj-scope-toggle { margin-left: auto; }
+129
View File
@@ -131,6 +131,7 @@
menu.style.left = Math.max(8, left) + "px";
menu.style.top = Math.max(8, top) + "px";
setTimeout(function () {
if (ctxMenuEl !== menu) return; // 그 사이 닫혔으면 문서 리스너를 남기지 않는다
document.addEventListener("mousedown", onCtxDocDown, true);
document.addEventListener("keydown", onCtxKeyDown, true);
window.addEventListener("scroll", closeContextMenu, true);
@@ -381,6 +382,9 @@
render();
place();
setTimeout(function () {
// 그 사이에 이미 닫혔으면 걸지 않는다 — 안 그러면 닫힌 팝업의 Esc 처리가
// 문서에 남아 이후 모든 Esc 를 삼킨다(정리 함수는 이미 지나갔으므로).
if (datePopEl !== pop) return;
document.addEventListener("mousedown", onDown, true);
document.addEventListener("keydown", onKey, true);
}, 0);
@@ -3427,8 +3431,133 @@
} catch (err) { showToast("변경 실패: " + err.message, "error"); }
});
});
renderSubAdd(box, t);
}
// ── 카드 하위 작업 목록 맨 아래 "+ 하위 작업 추가"(아사나) — 누르면 그 자리에
// 새 줄(✓ · 작업 이름 입력 · 마감일 · 담당자)이 열리고 Enter 로 바로 만든다.
// 만든 뒤에도 줄은 열린 채로 다음 하위 작업을 이어서 입력(아사나와 같음).
// Esc 또는 빈 채로 다른 곳을 누르면 닫힌다. 보드는 8초마다 다시 그려지므로
// 입력 중인 값·포커스는 subDrafts 에 두고 다시 그릴 때 되살린다.
const subDrafts = {};
function renderSubAdd(box, t) {
if (!canManage) return;
const draft = subDrafts[t.id];
const wrap = document.createElement("div");
wrap.className = "pj-card-subadd-wrap";
if (draft) {
wrap.innerHTML =
'<div class="pj-card-subnew">' +
'<span class="pj-card-sub-check is-ghost"><span class="material-symbols-outlined">check_circle</span></span>' +
'<input type="text" class="pj-card-subnew-title" placeholder="작업 이름 입력" autocomplete="off" />' +
'<span class="pj-card-sub-due pj-card-subnew-due"></span>' +
'<span class="pj-card-sub-av pj-card-subnew-av"></span>' +
"</div>";
}
wrap.insertAdjacentHTML("beforeend",
'<button type="button" class="pj-card-subadd">' +
'<span class="material-symbols-outlined">add</span>하위 작업 추가</button>');
box.appendChild(wrap);
const card = box.closest(".pj-card");
// 카드 클릭(작업 팝업 열기)·카드 드래그가 이 영역에서는 안 일어나게.
wrap.addEventListener("click", function (e) { e.stopPropagation(); });
wrap.addEventListener("mousedown", function () { if (card) card.draggable = false; });
wrap.querySelector(".pj-card-subadd").addEventListener("click", function () {
if (!subDrafts[t.id]) subDrafts[t.id] = { title: "", due: null, assignee: "", focused: true };
else subDrafts[t.id].focused = true;
refillSubs(box, t);
});
if (!draft) return;
const inp = wrap.querySelector(".pj-card-subnew-title");
const dueEl = wrap.querySelector(".pj-card-subnew-due");
const avEl = wrap.querySelector(".pj-card-subnew-av");
inp.value = draft.title;
function paintDue() {
const di = dueInfo(draft.due, false);
dueEl.className = "pj-card-sub-due pj-card-subnew-due" + (di ? " " + di.cls : " is-empty");
dueEl.innerHTML = di ? escapeHtml(di.text) : DUE_EMPTY_ICON_SVG;
dueEl.dataset.tip = di ? "마감일 변경" : "마감일 지정";
}
function paintAv() {
avEl.className = "pj-card-sub-av pj-card-subnew-av" + (draft.assignee ? "" : " is-empty");
avEl.innerHTML = draft.assignee ? avatarHtml(draft.assignee, "pj-gicon-sm") : ASSIGN_EMPTY_ICON_SVG;
avEl.dataset.tip = draft.assignee ? idOf(draft.assignee) : "담당자 지정";
}
paintDue(); paintAv();
function refocus() { if (inp.isConnected) inp.focus(); }
inp.addEventListener("input", function () { draft.title = inp.value; });
inp.addEventListener("focus", function () { draft.focused = true; if (card) card.draggable = false; });
inp.addEventListener("blur", function () {
if (card) card.draggable = canManage;
// 다시 그리느라 없어진 칸이면 무시(되살릴 때 포커스를 돌려준다).
setTimeout(function () {
if (!inp.isConnected) return;
draft.focused = document.activeElement === inp;
// 날짜 팝업·담당자 메뉴를 쓰는 중이면 닫지 않는다.
if (draft.focused || datePopEl || ctxMenuEl) return;
if (!draft.title.trim() && !draft.due && !draft.assignee) closeDraft();
}, 150);
});
inp.addEventListener("keydown", function (e) {
if (e.isComposing) return;
if (e.key === "Enter") { e.preventDefault(); createFromDraft(); }
else if (e.key === "Escape") { e.preventDefault(); e.stopPropagation(); closeDraft(); }
});
dueEl.addEventListener("click", function () {
openDatePopover(dueEl, {
due: draft.due, allowStart: false,
onChange: function (patch) { draft.due = patch.due_date || null; paintDue(); },
});
});
avEl.addEventListener("click", async function () {
let list;
try { list = await membersOfProject(t.project_id); }
catch (e) { showToast("멤버 조회 실패: " + e.message, "error"); return; }
const r = avEl.getBoundingClientRect();
showContextMenu(r.left, r.bottom + 4, assigneeMenuItems(
list.map(function (m) { return m.user_email; }), draft.assignee,
function (email) { draft.assignee = email || ""; paintAv(); refocus(); }
));
});
function closeDraft() {
delete subDrafts[t.id];
if (box.isConnected) refillSubs(box, t);
}
let saving = false;
async function createFromDraft() {
const title = draft.title.trim();
if (!title || saving) return;
saving = true;
try {
const res = await api("POST", "/project/api/projects/" + t.project_id + "/tasks", {
title: title, parent_task_id: t.id,
due_date: draft.due || null,
assignee_email: draft.assignee || "",
assignee_name: draft.assignee ? idOf(draft.assignee) : "",
});
const subs = subsCache[t.id] || (subsCache[t.id] = []);
subs.push(res.task);
adjustSubCounts(t.id, 1, 0);
// 다음 하위 작업을 이어서 입력(아사나) — 이름만 비우고 줄은 열어 둔다.
subDrafts[t.id] = { title: "", due: null, assignee: "", focused: true };
renderBoard(); // 카드의 "N ⤷" 숫자까지 맞춘다
} catch (e) {
showToast("하위 작업 추가 실패: " + e.message, "error");
} finally { saving = false; }
}
// 포커스 되살리기 — 보드를 다시 그릴 땐 카드가 아직 화면에 붙기 전이라
// 바로 focus() 하면 무시된다. 그리기가 끝난 뒤로 미룬다.
if (draft.focused) setTimeout(function () {
if (!inp.isConnected || subDrafts[t.id] !== draft) return;
inp.focus();
const n = inp.value.length;
try { inp.setSelectionRange(n, n); } catch (_) {}
}, 0);
}
// 하위 작업 목록만 다시 그린다(펼침 높이 애니메이션 없이 그 카드 안에서만).
function refillSubs(box, t) { fillCardSubs(box, t); }
// 하위 업무 한 줄을 다른 상위 업무(카드)로 옮긴다 — 보드에서 드래그해 놓았을 때.
// 같은 업무가 여러 프로젝트 맥락 행으로 tasks 에 들어 있을 수 있어(멀티호밍)
// 개수는 같은 id 의 행 모두에서 맞춘다.
+4
View File
@@ -48,6 +48,10 @@
펼친 하위 작업 한 줄을 다른 카드로 드래그하면 그 작업의 하위 작업으로 옮겨진다
(`POST /api/tasks/{id}/move-parent` `{parent_task_id}` → `db.move_subtask`, 활동 `subtask_moved`).
받는 쪽은 **같은 프로젝트의 최상위 작업만**(순환 방지), 하위 작업의 하위 작업은 함께 따라간다.
펼친 하위 작업 목록 맨 아래 **"+ 하위 작업 추가"**(아사나, `renderSubAdd`) — 누르면 그 자리에 새 줄
(✓ · "작업 이름 입력" · 점선 달력 · 점선 사람)이 열려 Enter 로 바로 만들고, 줄은 열린 채 다음 입력으로.
Esc 또는 빈 채로 다른 곳을 누르면 닫힘. 보드가 8초마다 다시 그려져도 입력 중인 값·포커스는
`subDrafts` 에서 되살린다.
**하위 작업도 작업과 같은 팝업에서 똑같이 편집**(아사나식) — 보드 카드의 하위 작업 줄 클릭·우클릭 "열기",
작업 팝업 하위 작업 줄의 › 버튼, 공유 링크로 연다(`openTaskById`). 제목 위에 상위 작업 경로
(`#pj-t-parent`, 누르면 상위 작업으로 — `GET /api/tasks/{id}` 가 `parent_title` 을 준다),