feat(project): subtask rows and a wide view for the meeting task table

- Subtask rows (one level, parent_id): hover button / right-click to add, Tab to make a row the
  subtask of the row above, Shift+Tab to move it back; inherits the parent's project, no section
- Apply on a subtask row creates the task under the parent row's task (server-checked)
- "크게 열기" moves the same table into a wide window (same rows and saves), Esc/x to close
- Server: PUT parent_id with one-level rules; add rejects grandchildren
- Help + docs; tests (real PostgreSQL rules + parent apply, jsdom rows/Tab/wide view)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-12 16:20:05 +09:00
parent 1bdcd59287
commit 6fd01314d5
17 changed files with 343 additions and 60 deletions
+176 -34
View File
@@ -10667,6 +10667,9 @@
// · 등록된 줄의 [삭제] = 확인 뒤 그 작업도 삭제(휴지통 3개월), 적용 전 줄의 × = 줄만 지움.
// · 30초마다·창을 다시 볼 때 다시 읽는다(입력 중·저장 중엔 건너뜀). 회의 완료면 읽기 전용.
// · 이 브라우저에 남은 예전 표(pj_meet_quick:…)는 처음 열 때 서버로 한 번 옮기고 지운다.
// · 세부 작업 줄(한 단계, 서버 parent_id) — ↳ 버튼·우클릭으로 추가, 제목 칸 Tab = 위 줄의 세부 작업으로, Shift+Tab = 위 단계로.
// 프로젝트는 위 줄을 따르고 섹션은 없다. [적용]은 위 줄이 먼저(서버가 위 줄 작업 밑에 세부 작업으로 만든다).
// · [크게 열기] — 같은 표를 넓은 창으로 옮겨 쓴다(줄·저장 그대로), 닫으면 제자리.
function initMeetQuickTasks() {
const box = el("pj-meet-quick");
if (!box) return;
@@ -10690,22 +10693,37 @@
return url ? '<img class="pj-avatar pj-meet-quick-face" src="' + escapeHtml(url) + '" alt="" referrerpolicy="no-referrer">'
: '<span class="pj-meet-quick-face is-ini">' + escapeHtml(nameOf(email).slice(0, 1)) + "</span>";
};
const blank = function () {
const blank = function (parent) {
return { id: null, title: "", assignee: "", projectId: null, projectName: "", stageId: null, stageName: "",
taskId: null, registered: false, visible: true, taskExists: true, chain: null };
taskId: null, registered: false, visible: true, taskExists: true, chain: null,
parentId: parent && parent.id ? parent.id : null, parentRef: parent || null };
};
function fromServer(t) {
return { id: t.id, title: t.title || "", assignee: t.assignee_email || "", projectId: t.project_id,
projectName: t.project_name || "", stageId: t.stage_id, stageName: t.stage_name || "", taskId: t.task_id,
registered: !!t.registered, visible: t.visible !== false, taskExists: t.task_exists !== false, chain: null };
registered: !!t.registered, visible: t.visible !== false, taskExists: t.task_exists !== false, chain: null,
parentId: t.parent_id || null, parentRef: null };
}
let rows = [];
let ready = false, unavailable = "";
// 세부 작업 줄(한 단계) — 위 줄 = parentRef(아직 서버에 없는 줄) 또는 parentId
function parentOf(r) {
if (r.parentRef && rows.indexOf(r.parentRef) >= 0) return r.parentRef;
if (r.parentId) return rows.find(function (x) { return x.id === r.parentId; }) || null;
return null;
}
function childrenOf(p) { return rows.filter(function (x) { return parentOf(x) === p; }); }
// 화면 순서 = 맨 위 단계 줄(지금 순서) 바로 뒤에 그 세부 작업 줄들
function reorder() {
const tops = rows.filter(function (r) { return !parentOf(r); });
const out = [];
tops.forEach(function (t) { out.push(t); childrenOf(t).forEach(function (c) { out.push(c); }); });
rows = out;
}
function padBlank() {
if (locked) return;
const open = rows.filter(function (r) { return !r.registered; }).length;
const open = rows.filter(function (r) { return !r.registered && !parentOf(r); }).length;
for (let i = open; i < 3; i++) rows.push(blank());
if (!rows.some(function (r) { return !r.registered; })) rows.push(blank());
}
let projects = null;
@@ -10733,28 +10751,35 @@
return stageCache[pid];
}
// ── 저장 — 줄마다 차례대로. 서버에 없는 줄은 처음 채울 때 만든다(지금 칸 전부를 보낸다) ──
// ── 저장 — 줄마다 차례대로. 서버에 없는 줄은 처음 채울 때 만든다(지금 칸 전부 + 위 줄을 보낸다 — 위 줄도 없으면 먼저) ──
let pendingSaves = 0;
function persist(r, patch) {
pendingSaves++;
const run = async function () {
const par = parentOf(r);
if (par && !par.id) await persist(par, {});
if (par && !par.id) throw new Error("위 줄을 저장하지 못했습니다");
if (!r.id) {
const res = await api("POST", listUrl, {
title: r.title, assignee_email: r.assignee, project_id: r.projectId, stage_id: r.stageId,
title: r.title, assignee_email: r.assignee, project_id: par ? null : r.projectId,
stage_id: par ? null : r.stageId, parent_id: par ? par.id : null,
});
r.id = res.task.id;
r.parentId = par ? par.id : null; r.parentRef = null;
} else {
if (patch && Object.prototype.hasOwnProperty.call(patch, "parent_id") && patch.parent_id === undefined) patch.parent_id = par ? par.id : null;
await api("PUT", rowUrl(r.id), patch);
if (patch && Object.prototype.hasOwnProperty.call(patch, "parent_id")) { r.parentId = patch.parent_id; r.parentRef = null; }
}
};
r.chain = (r.chain || Promise.resolve()).then(run).catch(function (e) {
showToast("작업 등록 표 저장 실패: " + e.message, "error");
if (e.status === 409) setTimeout(function () { load(true); }, 0); // 회의 완료·다른 사람이 [적용]함 — 서버 상태로
if (e.status === 409 || e.status === 400) setTimeout(function () { load(true); }, 0); // 서버 상태로 되돌림
}).finally(function () { pendingSaves--; });
return r.chain;
}
function cell(kind, text, placeholder, disabled) {
return '<button type="button" class="pj-meet-pick-cell' + (text ? "" : " is-empty") + '" data-pick="' + kind + '"' +
function cell(kind, text, placeholder, disabled, extra) {
return '<button type="button" class="pj-meet-pick-cell' + (text ? "" : " is-empty") + (extra || "") + '" data-pick="' + kind + '"' +
(disabled ? " disabled" : "") + ">" + escapeHtml(text || placeholder) + "</button>";
}
function render() {
@@ -10762,7 +10787,9 @@
tbody.innerHTML = '<tr><td colspan="5" class="pj-meet-quick-note">' + escapeHtml(unavailable) + "</td></tr>";
return;
}
reorder();
tbody.innerHTML = rows.map(function (r, i) {
const par = parentOf(r);
const ro = locked || r.registered;
let acts;
if (r.registered) {
@@ -10777,22 +10804,38 @@
} else if (locked) {
acts = "";
} else {
acts = '<button type="button" class="pj-meet-quick-apply" data-quick="apply">적용</button>' +
const wait = par && !par.registered;
acts = '<button type="button" class="pj-meet-quick-apply" data-quick="apply"' +
(wait ? ' disabled title="위 줄(상위 작업)을 먼저 [적용]하세요"' : "") + ">적용</button>" +
'<button type="button" class="pj-meet-quick-del" data-quick="remove" title="이 줄 지우기(아직 등록 전)">' +
'<span class="material-symbols-outlined">close</span></button>';
}
return '<tr data-i="' + i + '"' + (r.registered ? ' class="is-done"' : "") + ">" +
'<td><input type="text" data-field="title" maxlength="200" placeholder="작업 제목" value="' + escapeHtml(r.title) + '"' +
(ro ? " readonly" : "") + "></td>" +
// 세부 작업 줄 — ↳ 들여쓰기, 프로젝트는 위 줄을 따르고 섹션은 없다(작업의 세부 작업)
const projCell = par
? '<span class="pj-meet-quick-inherit" title="위 줄의 프로젝트를 따릅니다">' + escapeHtml(par.projectName || "위 줄 따름") + "</span>"
: cell("project", r.projectName, "프로젝트", ro);
const stageCell = par ? '<span class="pj-meet-quick-inherit" title="세부 작업은 섹션이 없습니다">—</span>' : cell("stage", r.stageName, "섹션", ro);
const addSub = !par && !locked && r.visible
? '<button type="button" class="pj-meet-quick-addsub" data-quick="add-sub" title="세부 작업 추가(제목 칸에서 Tab = 위 줄의 세부 작업으로)">' +
'<span class="material-symbols-outlined">subdirectory_arrow_right</span></button>' : "";
return '<tr data-i="' + i + '" class="' + (r.registered ? "is-done " : "") + (par ? "is-sub" : "") + '">' +
'<td class="pj-meet-quick-title">' + (par ? '<span class="pj-meet-quick-submark" aria-hidden="true">↳</span>' : "") +
'<input type="text" data-field="title" maxlength="200" placeholder="' + (par ? "세부 작업 제목" : "작업 제목") + '" value="' + escapeHtml(r.title) + '"' +
(ro ? " readonly" : "") + ">" + addSub + "</td>" +
"<td>" + (r.assignee
? '<button type="button" class="pj-meet-pick-cell is-person" data-pick="assignee"' + (ro ? " disabled" : "") + ">" +
faceHtml(r.assignee) + "<span>" + escapeHtml(nameOf(r.assignee)) + "</span></button>"
: cell("assignee", "", "담당자", ro)) + "</td>" +
"<td>" + cell("project", r.projectName, "프로젝트", ro) + "</td>" +
"<td>" + cell("stage", r.stageName, "섹션", ro) + "</td>" +
"<td>" + projCell + "</td>" +
"<td>" + stageCell + "</td>" +
'<td class="pj-meet-quick-acts">' + acts + "</td></tr>";
}).join("");
}
function focusTitle(r) {
const i = rows.indexOf(r);
const inp = i >= 0 ? tbody.querySelector('tr[data-i="' + i + '"] input[data-field="title"]') : null;
if (inp) { inp.focus(); try { inp.setSelectionRange(inp.value.length, inp.value.length); } catch (_) {} }
}
function menuAt(btn, items) {
const r = btn.getBoundingClientRect();
showContextMenu(r.left, r.bottom + 2, items.length ? items : [{ label: "고를 항목이 없습니다", onClick: function () {} }]);
@@ -10836,8 +10879,9 @@
})));
}
async function pickAssignee(r, btn) {
// 프로젝트를 골랐으면 그 프로젝트 멤버·소유자만(작업을 볼 수 있는 사람), 아니면 프로젝트 권한이 있는 전체 직원
const emails = r.projectId ? await membersOf(r.projectId)
// 프로젝트(세부 작업 줄은 위 줄의 프로젝트)를 골랐으면 그 멤버·소유자만, 아니면 프로젝트 권한이 있는 전체 직원
const par = parentOf(r), pid = par ? par.projectId : r.projectId;
const emails = pid ? await membersOf(pid)
: (window.PJ_MEET_MEMBERS || []).map(function (m) { return String(m.email).toLowerCase(); });
const set = function (e) { r.assignee = e; render(); persist(r, { assignee_email: e }); };
menuAt(btn, [{ label: "담당자 없음", icon: menuIcon("person_off"), checked: !r.assignee, onClick: function () { set(""); } }, null]
@@ -10866,10 +10910,49 @@
return { label: st.name, icon: menuIcon("view_column"), checked: r.stageId === st.id, onClick: function () { set(st); } };
})));
}
// ── 세부 작업 줄 — 추가(↳ 버튼·우클릭), 세부 작업으로(Tab)·위 단계로(Shift+Tab). 한 단계만 ──
function addSub(p) {
if (locked) return;
const kids = childrenOf(p);
const at = rows.indexOf(kids.length ? kids[kids.length - 1] : p);
const c = blank(p);
rows.splice(at + 1, 0, c);
render();
focusTitle(c);
}
function canIndent(r) {
if (locked || r.registered || parentOf(r) || childrenOf(r).length) return null;
const i = rows.indexOf(r);
for (let k = i - 1; k >= 0; k--) { if (!parentOf(rows[k])) return rows[k].visible ? rows[k] : null; }
return null;
}
function indent(r) {
const p = canIndent(r);
if (!p) return false;
r.parentRef = p; r.parentId = p.id || null;
render(); focusTitle(r);
if (r.id || r.title || r.assignee) persist(r, { parent_id: undefined });
return true;
}
function outdent(r) {
const p = parentOf(r);
if (locked || r.registered || !p) return false;
const kids = childrenOf(p);
rows.splice(rows.indexOf(r), 1);
r.parentRef = null; r.parentId = null;
rows.splice(rows.indexOf(kids[kids.length - 1] === r ? p : kids[kids.length - 1]) + 1, 0, r);
render(); focusTitle(r);
if (r.id) persist(r, { parent_id: null });
return true;
}
async function apply(r, btn) {
flushTitle(r);
const par = parentOf(r);
if (!r.title.trim()) { showToast("작업 제목을 쓰세요."); return; }
if (!r.projectId) { showToast("프로젝트를 고르세요."); return; }
if (par && !par.registered) { showToast("위 줄(상위 작업)을 먼저 [적용]하세요."); return; }
if (!par && !r.projectId) { showToast("프로젝트를 고르세요."); return; }
btn.disabled = true;
try {
await r.chain;
@@ -10877,31 +10960,34 @@
if (!r.id) throw new Error("줄을 저장하지 못했습니다");
const res = await api("POST", rowUrl(r.id) + "/apply", {});
Object.assign(r, fromServer(res.task));
showToast(res.created ? "‘" + r.projectName + "’에 작업을 등록했습니다." : "이미 등록된 줄입니다(다른 사람이 먼저 [적용]했습니다).");
showToast(res.created ? "‘" + ((par ? par.projectName : r.projectName) || "프로젝트") + "’에 " + (par ? "세부 작업을" : "작업을") + " 등록했습니다."
: "이미 등록된 줄입니다(다른 사람이 먼저 [적용]했습니다).");
padBlank(); render();
} catch (e) {
btn.disabled = false;
showToast("작업 등록 실패: " + e.message, "error");
}
}
// 등록된 작업 삭제 — 프로젝트에서도 지운다(휴지통). 이미 없으면(다른 곳에서 삭제) 줄만 지운다.
// 등록된 작업 삭제 — 프로젝트에서도 지운다(휴지통, 세부 작업 포함). 이미 없으면(다른 곳에서 삭제) 줄만 지운다.
async function removeTask(r, btn) {
if (r.taskExists && !(await confirm("‘" + (r.title || "작업") + "’ 작업을 ‘" + (r.projectName || "프로젝트") + "’에서도 삭제할까요? 삭제한 작업은 휴지통에 3개월 보관됩니다.",
if (r.taskExists && !(await confirm("‘" + (r.title || "작업") + "’ 작업을 프로젝트에서도 삭제할까요? 세부 작업도 함께, 휴지통에 3개월 보관됩니다.",
{ okText: "삭제", cancelText: "취소" }))) return;
btn.disabled = true;
if (r.taskId && r.taskExists) {
try { await api("DELETE", "/project/api/tasks/" + r.taskId); showToast("작업을 삭제했습니다."); }
catch (e) { if (e.status !== 404) { btn.disabled = false; showToast("작업 삭제 실패: " + e.message, "error"); return; } }
}
dropRow(r);
dropRow(r, true);
}
async function dropRow(r) {
async function dropRow(r, asked) {
const kids = childrenOf(r);
if (!asked && kids.length && !(await confirm("세부 작업 줄 " + kids.length + "개도 함께 지울까요? (이미 [적용]해 만든 작업은 프로젝트에 남습니다)",
{ okText: "지우기", cancelText: "취소" }))) return;
try {
await r.chain;
if (r.id) await api("DELETE", rowUrl(r.id));
if (r.id) await api("DELETE", rowUrl(r.id)); // 서버는 세부 작업 줄도 함께 지운다(CASCADE)
} catch (e) { if (e.status !== 404) { showToast("줄을 지우지 못했습니다: " + e.message, "error"); return; } }
const i = rows.indexOf(r);
if (i >= 0) rows.splice(i, 1);
rows = rows.filter(function (x) { return x !== r && kids.indexOf(x) < 0; });
padBlank(); render();
}
// 제목 — 치는 동안 0.6초 멈추면, 칸을 떠나면 저장
@@ -10912,23 +10998,32 @@
clearTimeout(t); titleTimers.delete(r);
persist(r, { title: r.title });
}
const rowOf = function (node) { const tr = node.closest("tr"); return tr && tr.dataset.i != null ? rows[+tr.dataset.i] : null; };
tbody.addEventListener("input", function (e) {
const inp = e.target.closest("input[data-field=title]");
if (!inp || inp.readOnly) return;
const r = rows[+inp.closest("tr").dataset.i];
const r = rowOf(inp);
r.title = inp.value;
clearTimeout(titleTimers.get(r));
titleTimers.set(r, setTimeout(function () { titleTimers.delete(r); persist(r, { title: r.title }); }, 600));
});
tbody.addEventListener("focusout", function (e) {
const inp = e.target.closest("input[data-field=title]");
if (inp) flushTitle(rows[+inp.closest("tr").dataset.i]);
if (inp) { const r = rowOf(inp); if (r) flushTitle(r); }
});
tbody.addEventListener("keydown", function (e) {
const inp = e.target.closest("input[data-field=title]");
if (inp && !inp.readOnly && e.key === "Enter" && !isImeEnter(e)) {
if (!inp || inp.readOnly || isImeEnter(e)) return;
const r = rowOf(inp);
if (e.key === "Tab") {
// 아사나처럼 — Tab = 위 줄의 세부 작업으로, Shift+Tab = 위 단계로. 할 수 없으면 원래 Tab(다음 칸)
flushTitle(r);
if (e.shiftKey ? outdent(r) : indent(r)) e.preventDefault();
return;
}
if (e.key === "Enter") {
e.preventDefault();
flushTitle(rows[+inp.closest("tr").dataset.i]);
flushTitle(r);
inp.closest("tr").querySelector('[data-pick="assignee"]').click();
}
});
@@ -10938,6 +11033,7 @@
const r = rows[+tr.dataset.i], pick = e.target.closest("[data-pick]");
const del = e.target.closest('[data-quick="delete"], [data-quick="remove"]');
if (del) { if (del.dataset.quick === "delete") removeTask(r, del); else dropRow(r); return; }
if (e.target.closest('[data-quick="add-sub"]')) { addSub(r); return; }
if (r.registered || locked) return;
const fail = function (err) { showToast("목록을 읽지 못했습니다: " + err.message, "error"); };
if (pick) {
@@ -10945,12 +11041,58 @@
({ project: pickProject, assignee: pickAssignee, stage: pickStage })[pick.dataset.pick](r, pick).catch(fail);
} else if (e.target.closest('[data-quick="apply"]')) apply(r, e.target.closest('[data-quick="apply"]'));
});
// 우클릭 — 세부 작업 추가 · 세부 작업으로 · 위 단계로 · 줄 지우기
tbody.addEventListener("contextmenu", function (e) {
const r = rowOf(e.target);
if (!r || locked) return;
e.preventDefault();
const par = parentOf(r);
const items = [];
if (!par && r.visible) items.push({ label: "세부 작업 추가", icon: menuIcon("subdirectory_arrow_right"), onClick: function () { addSub(r); } });
if (canIndent(r)) items.push({ label: "위 줄의 세부 작업으로 (Tab)", icon: menuIcon("format_indent_increase"), onClick: function () { indent(r); } });
if (par && !r.registered) items.push({ label: "위 단계로 (Shift+Tab)", icon: menuIcon("format_indent_decrease"), onClick: function () { outdent(r); } });
if (!r.registered) { if (items.length) items.push(null); items.push({ label: "줄 지우기", danger: true, icon: menuIcon("close"), onClick: function () { dropRow(r); } }); }
if (items.length) showContextMenu(e.clientX, e.clientY, items);
});
const addBtn = box.querySelector('[data-quick="add"]');
if (addBtn) {
if (locked) addBtn.hidden = true;
else addBtn.addEventListener("click", function () { rows.push(blank()); render(); });
else addBtn.addEventListener("click", function () { const b = blank(); rows.push(b); render(); focusTitle(b); });
}
// ── 크게 열기 — 같은 표(같은 줄·같은 저장)를 넓은 창으로 옮겨 쓴다. 닫으면 제자리로 ──
const area = box.querySelector(".pj-meet-area-body");
const expandBtn = box.querySelector('[data-quick="expand"]');
let modal = null;
function closeBig() {
if (!modal) return;
box.appendChild(area);
modal.remove(); modal = null;
document.removeEventListener("keydown", onBigKey, true);
if (expandBtn) expandBtn.focus();
}
function onBigKey(e) {
if (e.key === "Escape" && modal && !document.querySelector(".pj-ctxmenu, .pj-modal:not([hidden])")) { e.preventDefault(); closeBig(); }
}
function openBig() {
if (modal) return;
modal = document.createElement("div");
modal.className = "pj-meet-quick-modal";
modal.innerHTML = '<div class="pj-meet-quick-modal-card" role="dialog" aria-modal="true" aria-label="작업 등록 크게 보기">' +
'<div class="pj-meet-quick-modal-head"><h3></h3><button type="button" class="pj-icon-btn" data-quick="close-big" title="닫기 (Esc)">' +
'<span class="material-symbols-outlined">close</span></button></div></div>';
const wk = box.querySelector(".pj-meet-quick-week");
modal.querySelector("h3").textContent = (wk ? wk.textContent + " " : "") + "작업 등록";
modal.querySelector(".pj-meet-quick-modal-card").appendChild(area);
document.body.appendChild(modal); // 화면 배율(.pj-ui-scale) 밖 — body 에
modal.addEventListener("mousedown", function (e) { if (e.target === modal) closeBig(); });
modal.querySelector('[data-quick="close-big"]').addEventListener("click", closeBig);
document.addEventListener("keydown", onBigKey, true);
const first = area.querySelector('input[data-field="title"]:not([readonly])');
if (first) first.focus();
}
if (expandBtn) expandBtn.addEventListener("click", openBig);
// ── 읽기 — 처음·30초마다·창을 다시 볼 때. 입력 중(제목 칸 포커스·저장 대기)이면 건너뛴다 ──
function busy() {
return titleTimers.size > 0 || pendingSaves > 0 || (document.activeElement && tbody.contains(document.activeElement));
@@ -10959,7 +11101,7 @@
if (!force && busy()) return;
try {
const res = await api("GET", listUrl);
const blanks = rows.filter(function (r) { return !r.id && !r.title && !r.projectId && !r.assignee; }).length;
const blanks = rows.filter(function (r) { return !r.id && !parentOf(r) && !r.title && !r.projectId && !r.assignee; }).length;
rows = (res.tasks || []).map(fromServer);
for (let i = 0; i < blanks; i++) rows.push(blank());
padBlank();
@@ -11003,7 +11145,7 @@
})();
setInterval(function () { if (!document.hidden && ready) load(false); }, 30000);
document.addEventListener("visibilitychange", function () { if (!document.hidden && ready) load(false); });
if (window.__PJ_TEST__) window.__pjMeetQuick = { load: load, rows: function () { return rows; } };
if (window.__PJ_TEST__) window.__pjMeetQuick = { load: load, rows: function () { return rows; }, openBig: openBig, closeBig: closeBig };
}
function initGoalMeeting() {