feat(project): meeting task table - pick an existing task to add a subtask; title opens task panel
- New "작업" column (migration 026 parent_task_id): empty = new task in the section, chosen task = register as its subtask (candidates = open main tasks of that section) - Server validates the task belongs to the project, clears it when the project changes, and rejects apply if the chosen task was deleted/moved - Removed the in-table subtask rows (hover button, Tab/Shift+Tab, right-click) from UI/API - Registered row title opens the task editor on the right (iframe ?embed=1, waits for the task window to save before switching/closing, like the inbox panel) - Help + docs (DEPLOYMENT 026); tests (real PostgreSQL, jsdom) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+12
-16
@@ -2549,11 +2549,13 @@ html.pj-goal-selecting, html.pj-goal-selecting * { user-select: none !important;
|
||||
}
|
||||
.pj-ctxmenu-ic .pj-meet-quick-face { width: 20px; height: 20px; }
|
||||
.pj-member-pick.is-owner { opacity: .75; }
|
||||
.pj-meet-quick-table th:nth-child(1) { width: 30%; }
|
||||
.pj-meet-quick-table th:nth-child(2) { width: 17%; }
|
||||
.pj-meet-quick-table th:nth-child(3) { width: 19%; }
|
||||
.pj-meet-quick-table th:nth-child(4) { width: 15%; }
|
||||
.pj-meet-quick-table th:nth-child(5) { width: 19%; }
|
||||
/* 제목·담당자·프로젝트·섹션·작업(세부 작업으로 넣을 작업)·버튼 */
|
||||
.pj-meet-quick-table th:nth-child(1) { width: 24%; }
|
||||
.pj-meet-quick-table th:nth-child(2) { width: 15%; }
|
||||
.pj-meet-quick-table th:nth-child(3) { width: 15%; }
|
||||
.pj-meet-quick-table th:nth-child(4) { width: 12%; }
|
||||
.pj-meet-quick-table th:nth-child(5) { width: 15%; }
|
||||
.pj-meet-quick-table th:nth-child(6) { width: 19%; }
|
||||
.pj-meet-quick-acts { white-space: nowrap; text-align: right; }
|
||||
.pj-meet-quick-del {
|
||||
display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; margin-left: 4px; vertical-align: middle;
|
||||
@@ -3057,21 +3059,15 @@ html[data-pj-font="nanum-square-round"] { --pj-font: "NanumSquareRound", var(--p
|
||||
/* 회의록 작업 등록 — 제목 앞 주차(N주차 작업 등록, 주차마다 따로 기억) */
|
||||
.pj-meet-quick-week { color: var(--pj-accent); }
|
||||
.pj-meet-quick-note { padding: 10px 8px; color: #8a9099; font-size: 12.5px; }
|
||||
/* 작업 등록 — 세부 작업 줄(↳ 들여쓰기)·줄 위 ↳ 추가 버튼·[크게 열기] 창(같은 표를 옮겨 쓴다) */
|
||||
/* 작업 등록 — [크게 열기] 창(같은 표를 옮겨 쓴다)·등록된 제목(누르면 오른쪽 작업 창) */
|
||||
.pj-meet-quick h3 { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
|
||||
.pj-meet-quick-expand { margin-left: auto; order: 2; display: inline-flex; align-items: center; gap: 3px; }
|
||||
.pj-meet-quick h3 small { order: 3; flex-basis: 100%; margin-left: 0; } /* 한 줄: 제목 + [크게 열기], 그 아래 안내 */
|
||||
.pj-meet-quick-expand .material-symbols-outlined { font-size: 15px; }
|
||||
.pj-meet-quick-title { position: relative; }
|
||||
.pj-meet-quick-table tr.is-sub .pj-meet-quick-title { padding-left: 20px; }
|
||||
.pj-meet-quick-submark { position: absolute; left: 6px; top: 50%; transform: translateY(-50%); color: #9aa1a9; font-size: 13px; pointer-events: none; }
|
||||
.pj-meet-quick-addsub {
|
||||
position: absolute; right: 2px; top: 50%; transform: translateY(-50%); width: 22px; height: 22px; padding: 0;
|
||||
display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--pj-border, #e3e5e8); border-radius: 5px;
|
||||
background: #fff; color: var(--pj-ink-soft); cursor: pointer; opacity: 0; transition: opacity .12s;
|
||||
}
|
||||
.pj-meet-quick-addsub .material-symbols-outlined { font-size: 15px; }
|
||||
.pj-meet-quick-table tr:hover .pj-meet-quick-addsub, .pj-meet-quick-addsub:focus { opacity: 1; }
|
||||
.pj-meet-quick-open { display: block; width: 100%; padding: 2px 6px; border: none; background: none; text-align: left; font: inherit;
|
||||
color: var(--pj-ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; border-radius: 5px; }
|
||||
button.pj-meet-quick-open:hover { background: #f1f3f5; color: var(--pj-accent-dark, #2f5bb7); text-decoration: underline; }
|
||||
.pj-meet-quick-open.is-plain { cursor: default; color: var(--pj-ink-soft); }
|
||||
.pj-meet-quick-inherit { display: block; padding: 0 4px; color: #9aa1a9; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: center; }
|
||||
.pj-meet-quick-modal { position: fixed; inset: 0; z-index: 2100; /* 고르기 메뉴(.pj-ctxmenu 2200)가 그 위에 */ display: flex; align-items: center; justify-content: center;
|
||||
padding: 16px; box-sizing: border-box; background: rgba(15, 17, 21, .4); }
|
||||
|
||||
+155
-144
@@ -10667,8 +10667,8 @@
|
||||
// · 등록된 줄의 [삭제] = 확인 뒤 그 작업도 삭제(휴지통 3개월), 적용 전 줄의 × = 줄만 지움.
|
||||
// · 30초마다·창을 다시 볼 때 다시 읽는다(입력 중·저장 중엔 건너뜀). 회의 완료면 읽기 전용.
|
||||
// · 이 브라우저에 남은 예전 표(pj_meet_quick:…)는 처음 열 때 서버로 한 번 옮기고 지운다.
|
||||
// · 세부 작업 줄(한 단계, 서버 parent_id) — ↳ 버튼·우클릭으로 추가, 제목 칸 Tab = 위 줄의 세부 작업으로, Shift+Tab = 위 단계로.
|
||||
// 프로젝트는 위 줄을 따르고 섹션은 없다. [적용]은 위 줄이 먼저(서버가 위 줄 작업 밑에 세부 작업으로 만든다).
|
||||
// · 작업 칸(026 parent_task_id) — 비우면 그 섹션에 새 작업, 이미 있는 작업을 고르면 [적용] 때 그 작업의 세부 작업으로(섹션 없음).
|
||||
// · 등록된 줄의 제목을 누르면 오른쪽에 작업 창(편집, 수신함과 같은 iframe·저장 대기).
|
||||
// · [크게 열기] — 같은 표를 넓은 창으로 옮겨 쓴다(줄·저장 그대로), 닫으면 제자리.
|
||||
function initMeetQuickTasks() {
|
||||
const box = el("pj-meet-quick");
|
||||
@@ -10693,41 +10693,26 @@
|
||||
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 (parent) {
|
||||
const blank = function () {
|
||||
return { id: null, title: "", assignee: "", projectId: null, projectName: "", stageId: null, stageName: "",
|
||||
taskId: null, registered: false, visible: true, taskExists: true, chain: null,
|
||||
parentId: parent && parent.id ? parent.id : null, parentRef: parent || null };
|
||||
parentTaskId: null, parentTaskTitle: "", taskId: null, registered: false, visible: true, taskExists: true, chain: 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,
|
||||
parentId: t.parent_id || null, parentRef: null };
|
||||
projectName: t.project_name || "", stageId: t.stage_id, stageName: t.stage_name || "",
|
||||
parentTaskId: t.parent_task_id || null, parentTaskTitle: t.parent_task_title || "", taskId: t.task_id,
|
||||
registered: !!t.registered, visible: t.visible !== false, taskExists: t.task_exists !== false, chain: 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 && !parentOf(r); }).length;
|
||||
const open = rows.filter(function (r) { return !r.registered; }).length;
|
||||
for (let i = open; i < 3; i++) rows.push(blank());
|
||||
}
|
||||
|
||||
let projects = null;
|
||||
const memberCache = {}, stageCache = {};
|
||||
const memberCache = {}, stageCache = {}, taskCache = {};
|
||||
async function loadProjects() {
|
||||
if (projects) return projects;
|
||||
const res = await api("GET", "/project/api/projects");
|
||||
@@ -10750,26 +10735,27 @@
|
||||
stageCache[pid] = (res.stages || []).slice().sort(function (a, b) { return a.sort_order - b.sort_order; });
|
||||
return stageCache[pid];
|
||||
}
|
||||
// 작업 칸 후보 — 그 프로젝트의 (그 섹션) 미완료 메인 작업. 고르면 [적용] 때 그 작업의 세부 작업으로 만든다.
|
||||
async function tasksOf(pid) {
|
||||
if (taskCache[pid]) return taskCache[pid];
|
||||
const res = await api("GET", "/project/api/projects/" + pid + "/tasks");
|
||||
taskCache[pid] = (res.tasks || []).filter(function (t) { return t.project_id === pid && !t.completed_at && !t.parent_task_id; });
|
||||
return taskCache[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: par ? null : r.projectId,
|
||||
stage_id: par ? null : r.stageId, parent_id: par ? par.id : null,
|
||||
title: r.title, assignee_email: r.assignee, project_id: r.projectId, stage_id: r.stageId,
|
||||
parent_task_id: r.parentTaskId,
|
||||
});
|
||||
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) {
|
||||
@@ -10778,24 +10764,22 @@
|
||||
}).finally(function () { pendingSaves--; });
|
||||
return r.chain;
|
||||
}
|
||||
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 cell(kind, text, placeholder, disabled, title) {
|
||||
return '<button type="button" class="pj-meet-pick-cell' + (text ? "" : " is-empty") + '" data-pick="' + kind + '"' +
|
||||
(title ? ' title="' + escapeHtml(title) + '"' : "") + (disabled ? " disabled" : "") + ">" + escapeHtml(text || placeholder) + "</button>";
|
||||
}
|
||||
function render() {
|
||||
if (unavailable) {
|
||||
tbody.innerHTML = '<tr><td colspan="5" class="pj-meet-quick-note">' + escapeHtml(unavailable) + "</td></tr>";
|
||||
tbody.innerHTML = '<tr><td colspan="6" 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) {
|
||||
const label = !r.taskExists ? "작업 삭제됨" : "등록됨";
|
||||
const link = r.visible && r.taskId && r.taskExists
|
||||
? '<a href="/project/t/' + r.taskId + '" target="_blank" rel="noopener">' + label + "</a>" : "<span>" + label + "</span>";
|
||||
? '<a href="/project/t/' + r.taskId + '" target="_blank" rel="noopener" title="새 탭에서 열기">' + label + "</a>" : "<span>" + label + "</span>";
|
||||
acts = '<span class="pj-meet-quick-done"><span class="material-symbols-outlined" style="font-size:16px">check_circle</span>' +
|
||||
link + "</span>" + (!locked && r.visible
|
||||
? '<button type="button" class="pj-meet-quick-del" data-quick="delete" title="' +
|
||||
@@ -10804,44 +10788,40 @@
|
||||
} else if (locked) {
|
||||
acts = "";
|
||||
} else {
|
||||
const wait = par && !par.registered;
|
||||
acts = '<button type="button" class="pj-meet-quick-apply" data-quick="apply"' +
|
||||
(wait ? ' disabled title="위 줄(상위 작업)을 먼저 [적용]하세요"' : "") + ">적용</button>" +
|
||||
acts = '<button type="button" class="pj-meet-quick-apply" data-quick="apply">적용</button>' +
|
||||
'<button type="button" class="pj-meet-quick-del" data-quick="remove" title="이 줄 지우기(아직 등록 전)">' +
|
||||
'<span class="material-symbols-outlined">close</span></button>';
|
||||
}
|
||||
// 세부 작업 줄 — ↳ 들여쓰기, 프로젝트는 위 줄을 따르고 섹션은 없다(작업의 세부 작업)
|
||||
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>" +
|
||||
// 제목 — 등록된 줄은 누르면 오른쪽에 작업 창(편집), 아니면 입력칸
|
||||
const titleCell = r.registered
|
||||
? (r.visible && r.taskId && r.taskExists
|
||||
? '<button type="button" class="pj-meet-quick-open" data-quick="open" title="오른쪽에 작업 창 열기(편집)">' + escapeHtml(r.title || "(제목 없음)") + "</button>"
|
||||
: '<span class="pj-meet-quick-open is-plain">' + escapeHtml(r.title || "(제목 없음)") + "</span>")
|
||||
: '<input type="text" data-field="title" maxlength="200" placeholder="' + (r.parentTaskId ? "세부 작업 제목" : "작업 제목") + '" value="' +
|
||||
escapeHtml(r.title) + '"' + (ro ? " readonly" : "") + ">";
|
||||
// 작업 칸 — 비우면 그 섹션에 새 작업, 고르면 그 작업의 세부 작업(↳ 표시)
|
||||
const taskCell = r.parentTaskId
|
||||
? cell("task", "↳ " + (r.parentTaskTitle || "작업"), "", ro, "이 작업의 세부 작업으로 등록")
|
||||
: cell("task", "", r.registered ? "—" : "새 작업", ro || !r.projectId, r.projectId ? "고르면 그 작업의 세부 작업으로 등록(비우면 섹션에 새 작업)" : "프로젝트를 먼저 고르세요");
|
||||
return '<tr data-i="' + i + '"' + (r.registered ? ' class="is-done"' : "") + ">" +
|
||||
'<td class="pj-meet-quick-title">' + titleCell + "</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>" + projCell + "</td>" +
|
||||
"<td>" + stageCell + "</td>" +
|
||||
"<td>" + cell("project", r.projectName, "프로젝트", ro) + "</td>" +
|
||||
"<td>" + (r.parentTaskId ? '<span class="pj-meet-quick-inherit" title="세부 작업은 섹션이 없습니다(상위 작업을 따름)">—</span>'
|
||||
: cell("stage", r.stageName, "섹션", ro)) + "</td>" +
|
||||
"<td>" + taskCell + "</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 () {} }]);
|
||||
}
|
||||
async function chooseProject(r, p) {
|
||||
if (r.projectId !== p.id) { r.stageId = null; r.stageName = ""; }
|
||||
if (r.projectId !== p.id) { r.stageId = null; r.stageName = ""; r.parentTaskId = null; r.parentTaskTitle = ""; }
|
||||
r.projectId = p.id; r.projectName = p.name;
|
||||
try {
|
||||
const [mem, stages] = await Promise.all([membersOf(p.id), stagesOf(p.id)]);
|
||||
@@ -10866,6 +10846,7 @@
|
||||
if (projects) projects.push(p);
|
||||
memberCache[p.id] = [String(p.owner_email || "").toLowerCase()].filter(Boolean);
|
||||
stageCache[p.id] = [];
|
||||
taskCache[p.id] = [];
|
||||
showToast("프로젝트 ‘" + p.name + "’를 만들었습니다.");
|
||||
await chooseProject(r, p);
|
||||
} catch (e) { showToast("프로젝트 만들기 실패: " + e.message, "error"); }
|
||||
@@ -10879,9 +10860,8 @@
|
||||
})));
|
||||
}
|
||||
async function pickAssignee(r, btn) {
|
||||
// 프로젝트(세부 작업 줄은 위 줄의 프로젝트)를 골랐으면 그 멤버·소유자만, 아니면 프로젝트 권한이 있는 전체 직원
|
||||
const par = parentOf(r), pid = par ? par.projectId : r.projectId;
|
||||
const emails = pid ? await membersOf(pid)
|
||||
// 프로젝트를 골랐으면 그 프로젝트 멤버·소유자만(작업을 볼 수 있는 사람), 아니면 프로젝트 권한이 있는 전체 직원
|
||||
const emails = r.projectId ? await membersOf(r.projectId)
|
||||
: (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]
|
||||
@@ -10893,7 +10873,12 @@
|
||||
if (!r.projectId) { showToast("프로젝트를 먼저 고르세요."); return; }
|
||||
const stages = await stagesOf(r.projectId);
|
||||
const pid = r.projectId;
|
||||
const set = function (st) { r.stageId = st.id; r.stageName = st.name; render(); persist(r, { project_id: pid, stage_id: st.id }); };
|
||||
const set = function (st) {
|
||||
r.stageId = st.id; r.stageName = st.name;
|
||||
const keepTask = r.parentTaskId && (taskCache[pid] || []).some(function (t) { return t.id === r.parentTaskId && t.stage_id === st.id; });
|
||||
if (!keepTask) { r.parentTaskId = null; r.parentTaskTitle = ""; }
|
||||
render(); persist(r, { project_id: pid, stage_id: st.id, parent_task_id: r.parentTaskId });
|
||||
};
|
||||
// 목록 맨 위 "+ 새 섹션" — 그 프로젝트 멤버 누구나(서버 POST …/stages). 만든 섹션을 바로 고른다.
|
||||
const head = [{ label: "새 섹션", icon: menuIcon("add"), onClick: async function () {
|
||||
const name = await prompt("‘" + r.projectName + "’에 만들 섹션 이름", "");
|
||||
@@ -10910,58 +10895,43 @@
|
||||
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 pickTask(r, btn) {
|
||||
if (!r.projectId) { showToast("프로젝트를 먼저 고르세요."); return; }
|
||||
const pid = r.projectId;
|
||||
const all = await tasksOf(pid);
|
||||
const list = r.stageId ? all.filter(function (t) { return t.stage_id === r.stageId; }) : all;
|
||||
const set = function (t) {
|
||||
r.parentTaskId = t ? t.id : null; r.parentTaskTitle = t ? t.title : "";
|
||||
if (t && t.stage_id) {
|
||||
const st = (stageCache[pid] || []).find(function (x) { return x.id === t.stage_id; });
|
||||
if (st) { r.stageId = st.id; r.stageName = st.name; }
|
||||
}
|
||||
render(); persist(r, { parent_task_id: r.parentTaskId, stage_id: r.stageId });
|
||||
};
|
||||
menuAt(btn, [{ label: "새 작업" + (r.stageName ? " (‘" + r.stageName + "’ 섹션에)" : ""), icon: menuIcon("add_task"),
|
||||
checked: !r.parentTaskId, onClick: function () { set(null); } }, null]
|
||||
.concat(list.length ? list.map(function (t) {
|
||||
return { label: t.title, icon: menuIcon("subdirectory_arrow_right"), checked: r.parentTaskId === t.id, onClick: function () { set(t); } };
|
||||
}) : [{ label: r.stageName ? "이 섹션에 진행 중인 작업이 없습니다" : "진행 중인 작업이 없습니다", onClick: function () {} }]));
|
||||
}
|
||||
|
||||
async function apply(r, btn) {
|
||||
flushTitle(r);
|
||||
const par = parentOf(r);
|
||||
if (!r.title.trim()) { showToast("작업 제목을 쓰세요."); return; }
|
||||
if (par && !par.registered) { showToast("위 줄(상위 작업)을 먼저 [적용]하세요."); return; }
|
||||
if (!par && !r.projectId) { showToast("프로젝트를 고르세요."); return; }
|
||||
if (!r.projectId) { showToast("프로젝트를 고르세요."); return; }
|
||||
btn.disabled = true;
|
||||
try {
|
||||
await r.chain;
|
||||
if (!r.id) await persist(r, {});
|
||||
if (!r.id) throw new Error("줄을 저장하지 못했습니다");
|
||||
const res = await api("POST", rowUrl(r.id) + "/apply", {});
|
||||
const sub = !!r.parentTaskId;
|
||||
Object.assign(r, fromServer(res.task));
|
||||
showToast(res.created ? "‘" + ((par ? par.projectName : r.projectName) || "프로젝트") + "’에 " + (par ? "세부 작업을" : "작업을") + " 등록했습니다."
|
||||
if (sub && taskCache[r.projectId]) delete taskCache[r.projectId];
|
||||
showToast(res.created ? (sub ? "‘" + r.parentTaskTitle + "’의 세부 작업으로 등록했습니다." : "‘" + r.projectName + "’에 작업을 등록했습니다.")
|
||||
: "이미 등록된 줄입니다(다른 사람이 먼저 [적용]했습니다).");
|
||||
delete taskCache[r.projectId]; // 새 작업이 작업 칸 후보에 보이게
|
||||
padBlank(); render();
|
||||
} catch (e) {
|
||||
btn.disabled = false;
|
||||
@@ -10977,19 +10947,76 @@
|
||||
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, true);
|
||||
dropRow(r);
|
||||
}
|
||||
async function dropRow(r, asked) {
|
||||
const kids = childrenOf(r);
|
||||
if (!asked && kids.length && !(await confirm("세부 작업 줄 " + kids.length + "개도 함께 지울까요? (이미 [적용]해 만든 작업은 프로젝트에 남습니다)",
|
||||
{ okText: "지우기", cancelText: "취소" }))) return;
|
||||
async function dropRow(r) {
|
||||
try {
|
||||
await r.chain;
|
||||
if (r.id) await api("DELETE", rowUrl(r.id)); // 서버는 세부 작업 줄도 함께 지운다(CASCADE)
|
||||
if (r.id) await api("DELETE", rowUrl(r.id));
|
||||
} catch (e) { if (e.status !== 404) { showToast("줄을 지우지 못했습니다: " + e.message, "error"); return; } }
|
||||
rows = rows.filter(function (x) { return x !== r && kids.indexOf(x) < 0; });
|
||||
const i = rows.indexOf(r);
|
||||
if (i >= 0) rows.splice(i, 1);
|
||||
padBlank(); render();
|
||||
}
|
||||
|
||||
// ── 오른쪽 작업 창 — 등록된 줄의 제목을 누르면 그 작업 편집 창(프로젝트 화면 ?embed=1 을 iframe 에, 수신함과 같은 방식).
|
||||
// 다른 작업으로 바꾸거나 닫기 전에 작업 창 안의 저장을 기다린다(__pjEmbedSettle — 실패면 "버리고 넘어가기 / 계속 편집").
|
||||
let panel = null, panelTask = null, switching = null, wanted;
|
||||
function panelOpen() { return !!panel && panel.classList.contains("is-open"); }
|
||||
async function settleFrame() {
|
||||
if (!panelOpen()) return true;
|
||||
let fn = null;
|
||||
try { fn = panel.querySelector("iframe").contentWindow.__pjEmbedSettle; } catch (_) { fn = null; }
|
||||
if (typeof fn !== "function") return true;
|
||||
try { return !!(await fn()); } catch (_) { return false; }
|
||||
}
|
||||
function showPanel(taskId) {
|
||||
if (taskId == null) {
|
||||
if (!panelOpen()) return;
|
||||
panel.classList.remove("is-open");
|
||||
panelTask = null;
|
||||
const p = panel;
|
||||
setTimeout(function () { if (!p.classList.contains("is-open")) p.querySelector("iframe").src = "about:blank"; }, 250);
|
||||
load(true); // 작업 창에서 제목 등을 바꿨을 수 있다
|
||||
return;
|
||||
}
|
||||
if (!panel) {
|
||||
panel = document.createElement("div");
|
||||
panel.className = "pj-inbox-panel pj-meet-task-panel";
|
||||
panel.innerHTML = '<iframe title="작업"></iframe>';
|
||||
document.body.appendChild(panel); // 화면 배율(.pj-ui-scale) 밖 — body 에
|
||||
}
|
||||
panelTask = taskId;
|
||||
panel.querySelector("iframe").src = "/project/t/" + taskId + "?embed=1";
|
||||
void panel.offsetWidth;
|
||||
panel.classList.add("is-open");
|
||||
}
|
||||
function requestPanel(taskId) {
|
||||
wanted = taskId;
|
||||
if (switching) return switching;
|
||||
switching = (async function () {
|
||||
while (wanted !== undefined) {
|
||||
const t = wanted;
|
||||
if ((t === null && !panelOpen()) || (t !== null && panelOpen() && panelTask === t)) { wanted = undefined; break; }
|
||||
const ok = await settleFrame();
|
||||
if (!ok) { wanted = undefined; break; }
|
||||
if (wanted !== t) continue;
|
||||
wanted = undefined;
|
||||
showPanel(t);
|
||||
}
|
||||
})().finally(function () { switching = null; });
|
||||
return switching;
|
||||
}
|
||||
window.addEventListener("message", function (e) {
|
||||
if (e.origin === location.origin && e.data && e.data.type === "pj-embed-close" && panelOpen()) requestPanel(null);
|
||||
});
|
||||
document.addEventListener("keydown", function (e) { if (e.key === "Escape" && panelOpen() && !modal) requestPanel(null); });
|
||||
document.addEventListener("mousedown", function (e) {
|
||||
if (!panelOpen() || panel.contains(e.target)) return;
|
||||
if (e.target.closest && e.target.closest('[data-quick="open"], .pj-ctxmenu, .pj-modal, .erp-dialog')) return;
|
||||
requestPanel(null);
|
||||
});
|
||||
|
||||
// 제목 — 치는 동안 0.6초 멈추면, 칸을 떠나면 저장
|
||||
const titleTimers = new Map();
|
||||
function flushTitle(r) {
|
||||
@@ -11013,17 +11040,9 @@
|
||||
});
|
||||
tbody.addEventListener("keydown", function (e) {
|
||||
const inp = e.target.closest("input[data-field=title]");
|
||||
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") {
|
||||
if (inp && !inp.readOnly && e.key === "Enter" && !isImeEnter(e)) {
|
||||
e.preventDefault();
|
||||
flushTitle(r);
|
||||
flushTitle(rowOf(inp));
|
||||
inp.closest("tr").querySelector('[data-pick="assignee"]').click();
|
||||
}
|
||||
});
|
||||
@@ -11033,31 +11052,22 @@
|
||||
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 (e.target.closest('[data-quick="open"]')) { if (modal) closeBig(); requestPanel(r.taskId); return; }
|
||||
if (r.registered || locked) return;
|
||||
const fail = function (err) { showToast("목록을 읽지 못했습니다: " + err.message, "error"); };
|
||||
if (pick) {
|
||||
e.stopPropagation();
|
||||
({ project: pickProject, assignee: pickAssignee, stage: pickStage })[pick.dataset.pick](r, pick).catch(fail);
|
||||
({ project: pickProject, assignee: pickAssignee, stage: pickStage, task: pickTask })[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 () { const b = blank(); rows.push(b); render(); focusTitle(b); });
|
||||
else addBtn.addEventListener("click", function () {
|
||||
const b = blank(); rows.push(b); render();
|
||||
const inp = tbody.querySelector('tr[data-i="' + rows.indexOf(b) + '"] input[data-field="title"]');
|
||||
if (inp) inp.focus();
|
||||
});
|
||||
}
|
||||
|
||||
// ── 크게 열기 — 같은 표(같은 줄·같은 저장)를 넓은 창으로 옮겨 쓴다. 닫으면 제자리로 ──
|
||||
@@ -11072,7 +11082,7 @@
|
||||
if (expandBtn) expandBtn.focus();
|
||||
}
|
||||
function onBigKey(e) {
|
||||
if (e.key === "Escape" && modal && !document.querySelector(".pj-ctxmenu, .pj-modal:not([hidden])")) { e.preventDefault(); closeBig(); }
|
||||
if (e.key === "Escape" && modal && !document.querySelector(".pj-ctxmenu, .pj-modal:not([hidden])")) { e.preventDefault(); e.stopPropagation(); closeBig(); }
|
||||
}
|
||||
function openBig() {
|
||||
if (modal) return;
|
||||
@@ -11101,7 +11111,7 @@
|
||||
if (!force && busy()) return;
|
||||
try {
|
||||
const res = await api("GET", listUrl);
|
||||
const blanks = rows.filter(function (r) { return !r.id && !parentOf(r) && !r.title && !r.projectId && !r.assignee; }).length;
|
||||
const blanks = rows.filter(function (r) { return !r.id && !r.title && !r.projectId && !r.assignee; }).length;
|
||||
rows = (res.tasks || []).map(fromServer);
|
||||
for (let i = 0; i < blanks; i++) rows.push(blank());
|
||||
padBlank();
|
||||
@@ -11143,9 +11153,10 @@
|
||||
await load(true);
|
||||
if (!unavailable && !locked) { await migrateLocal(); await load(true); }
|
||||
})();
|
||||
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; }, openBig: openBig, closeBig: closeBig };
|
||||
setInterval(function () { if (!document.hidden && ready && !panelOpen()) load(false); }, 30000);
|
||||
document.addEventListener("visibilitychange", function () { if (!document.hidden && ready && !panelOpen()) load(false); });
|
||||
if (window.__PJ_TEST__) window.__pjMeetQuick = { load: load, rows: function () { return rows; }, openBig: openBig, closeBig: closeBig,
|
||||
settling: function () { return switching || Promise.resolve(); } };
|
||||
}
|
||||
|
||||
function initGoalMeeting() {
|
||||
|
||||
Reference in New Issue
Block a user