feat(project): 담당자는 협업자에서 제외·세부 업무 추가 칸 아이콘·내 업무 오른쪽 창

- 협업자 = 담당자 외의 멤버: add_followers 가 담당자를 거르고, 담당자 지정 시 같은 트랜잭션에서 협업자에서 뺌, 담당자 협업자 추가는 400
- 마이그레이션 028: 이미 겹친 task_followers 행 정리(스키마 변경 없음, 멱등)
- 업무 창 세부 업무 추가 칸: 담당자·협업자·마감일을 동그라미 아이콘 버튼으로, 제목 칸을 넓게
- 내 업무 화면: 줄 클릭 시 화면 이동 없이 오른쪽 업무 창(iframe), 닫으면 목록 다시 받기
- 대시보드 "미완료 업무 합계(섹션별)" 카드 삭제

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-13 14:24:51 +09:00
parent 5bd0a5c406
commit f36f7d3ad4
21 changed files with 365 additions and 74 deletions
+156 -48
View File
@@ -973,11 +973,13 @@
}
// 협업자 고르기 메뉴 — 후보 멤버(지금 협업자는 ✓). 고르면 onToggle(email, 켜기?) 를 기다린 뒤 같은 자리에 메뉴를
// 다시 열어 여러 명을 이어서 고른다(Esc·바깥 클릭으로 닫힘). current() = 지금 협업자 목록.
function openFollowerMenu(anchor, emails, current, onToggle) {
// assignee = 그 업무 담당자(함수 가능) — 담당자는 협업자가 아니라 후보에서 뺀다(2026-10-13).
function openFollowerMenu(anchor, emails, current, onToggle, assignee) {
const lower = function (x) { return String(x || "").toLowerCase(); };
const who = lower(typeof assignee === "function" ? assignee() : assignee);
const cur = (current() || []).map(lower);
const cands = [];
(emails || []).concat(cur).forEach(function (e) { e = lower(e); if (e && cands.indexOf(e) < 0) cands.push(e); });
(emails || []).concat(cur).forEach(function (e) { e = lower(e); if (e && e !== who && cands.indexOf(e) < 0) cands.push(e); });
if (!cands.length) { showToast("지정할 수 있는 멤버가 없습니다."); return; }
const r = anchor.getBoundingClientRect();
showContextMenu(r.left, r.bottom + 4, cands.map(function (em) {
@@ -986,7 +988,7 @@
label: idOf(em), icon: personIconHtml(em), checked: on,
onClick: async function () {
const ok = await onToggle(em, !on);
if (ok !== false && anchor.isConnected) openFollowerMenu(anchor, emails, current, onToggle);
if (ok !== false && anchor.isConnected) openFollowerMenu(anchor, emails, current, onToggle, assignee);
},
};
}), { label: "협업자 지정" });
@@ -1005,6 +1007,15 @@
: await api("DELETE", "/project/api/tasks/" + taskId + "/followers/" + encodeURIComponent(email));
return res.followers || [];
}
// 새로 만든 업무의 협업자 = 만든 사람 + 고른 사람(담당자는 빼고) — 서버 _follow·db.add_followers 와 같은 규칙.
function newTaskFollowers(chosen, assignee) {
const who = String(assignee || "").toLowerCase();
const out = [];
[pageMeEmail()].concat(chosen || []).forEach(function (x) {
x = String(x || "").toLowerCase(); if (x && x !== who && out.indexOf(x) < 0) out.push(x);
});
return out;
}
function pageMeEmail() {
const w = document.querySelector(".pj-wrap");
return ((w && w.dataset.me) || "").toLowerCase();
@@ -1033,7 +1044,7 @@
btn.querySelector(".pj-assignee-btn-name").textContent = v ? (opt ? opt.textContent : idOf(v)) : "담당자 없음";
btn.classList.toggle("is-empty", !v);
btn.disabled = sel.disabled;
btn.dataset.tip = v ? "담당자 변경" : "이 업무 배정";
btn.dataset.tip = v ? "담당자: " + (opt ? opt.textContent : idOf(v)) : "담당자 지정";
}
const desc = Object.getOwnPropertyDescriptor(HTMLSelectElement.prototype, "value");
Object.defineProperty(sel, "value", {
@@ -2935,6 +2946,74 @@
// 모아 보여주고, 완료 체크·정렬·필터를 그 자리에서 처리한다. 업무를
// 누르면 그 프로젝트 화면이 열리면서 편집 팝업이 뜬다(?task=).
// ════════════════════════════════════════════════════════════
// 오른쪽 업무 창 — /project/t/{id}?embed=1 을 iframe 패널(.pj-inbox-panel, body 에)로. 수신함·회의록과 같은 방식:
// 다른 업무로 바꾸거나 닫기 전에 창 안 저장을 기다린다(__pjEmbedSettle — 실패면 "버리고 넘어가기 / 계속 편집").
// opts.onOpen(id)·opts.onClose() — 목록 줄 표시·목록 다시 받기.
function createEmbedTaskPanel(opts) {
opts = opts || {};
let panel = null, shown = null, switching = null, wanted;
function isOpen() { return !!panel && panel.classList.contains("is-open"); }
async function settleFrame() {
if (!isOpen()) 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 apply(id) {
if (id == null) {
if (!isOpen()) return;
panel.classList.remove("is-open");
shown = null;
const p = panel;
setTimeout(function () { if (!p.classList.contains("is-open")) p.querySelector("iframe").src = "about:blank"; }, 250);
if (opts.onClose) opts.onClose();
return;
}
if (!panel) {
panel = document.createElement("div");
panel.className = "pj-inbox-panel";
panel.innerHTML = '<iframe title="업무"></iframe>';
document.body.appendChild(panel); // 화면 배율(.pj-ui-scale) 밖 — body 에
try {
const w = parseInt(localStorage.getItem("pj_task_panel_w") || "", 10);
if (w) panel.style.width = "min(" + Math.round(w * uiZoom()) + "px, 92vw)";
} catch (_) {}
}
shown = id;
panel.querySelector("iframe").src = "/project/t/" + encodeURIComponent(id) + "?embed=1";
void panel.offsetWidth;
panel.classList.add("is-open");
if (opts.onOpen) opts.onOpen(id);
}
function request(id) {
wanted = id;
if (switching) return switching;
switching = (async function () {
while (wanted !== undefined) {
const t = wanted;
if ((t == null && !isOpen()) || (t != null && isOpen() && shown === t)) { wanted = undefined; break; }
const ok = await settleFrame();
if (!ok) { wanted = undefined; break; } // 계속 편집 — 창·입력 그대로
if (wanted !== t) continue;
wanted = undefined;
apply(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" && isOpen()) request(null);
});
return {
open: function (id) { return request(id); },
close: function () { return request(null); },
isOpen: isOpen,
shownId: function () { return isOpen() ? shown : null; },
contains: function (n) { return !!panel && panel.contains(n); },
};
}
function initMyTasks() {
const root = document.querySelector(".pj-mytasks-view");
if (!root) return;
@@ -2945,6 +3024,32 @@
// 오늘 = 한국시간 날짜를 그때그때(화면을 밤새 열어 두어도 자정이 지나면 바뀐다).
const todayNow = kstTodayIso;
const me = (root.dataset.me || "").toLowerCase();
// 줄을 누르면 화면은 그대로, 오른쪽에 업무 창(2026-10-13). 닫으면 목록을 다시 받는다(창에서 고친 내용 반영).
// Ctrl·가운데 클릭은 예전처럼 새 탭에서 그 프로젝트 화면.
function markPanelRow(id) {
root.querySelectorAll("tr.is-panel-selected").forEach(function (r) { r.classList.remove("is-panel-selected"); });
if (id != null) {
const tr = root.querySelector('tr.pj-mtk-row[data-task-id="' + id + '"]');
if (tr) tr.classList.add("is-panel-selected");
}
}
const taskPanel = createEmbedTaskPanel({
onOpen: markPanelRow,
onClose: function () { markPanelRow(null); if (softSyncProjectRef) softSyncProjectRef(); },
});
function openTaskHere(id, projectId, e) {
if (e && (e.ctrlKey || e.metaKey || e.button === 1)) {
window.open("/project/p/" + projectId + "?task=" + id, "_blank");
return;
}
taskPanel.open(id);
}
document.addEventListener("keydown", function (e) { if (e.key === "Escape" && taskPanel.isOpen()) taskPanel.close(); });
document.addEventListener("mousedown", function (e) {
if (!taskPanel.isOpen() || taskPanel.contains(e.target)) return;
if (e.target.closest && e.target.closest("tr.pj-mtk-row, .pj-ctxmenu, .pj-modal, .erp-dialog, .pj-alert-pop, .erp-overdue")) return;
taskPanel.close();
});
const table = el("pj-mytasks-table");
const emptyEl = el("pj-mytasks-empty");
@@ -3079,7 +3184,8 @@
function rowContextItems(t) {
return [
{ label: "열기", onClick: function () { location.href = "/project/p/" + t.project_id + "?task=" + t.id; } },
{ label: "열기", onClick: function () { openTaskHere(t.id, t.project_id); } },
{ label: "프로젝트 화면에서 열기", onClick: function () { location.href = "/project/p/" + t.project_id + "?task=" + t.id; } },
{ label: "업무 링크 복사", onClick: function () { shareTaskLink(t.id); } },
{
label: t.completed_at ? "완료 취소" : "완료로 표시",
@@ -3120,10 +3226,12 @@
const chk = tr.querySelector('input[type="checkbox"]');
chk.addEventListener("click", function (e) { e.stopPropagation(); });
chk.addEventListener("change", function () { toggleDone(t, chk.checked); });
if (taskPanel.shownId() === t.id) tr.classList.add("is-panel-selected");
tr.addEventListener("click", function (e) {
if (e.target.closest(".pj-cmt-badge")) return; // 말풍선은 댓글 팝업 담당
location.href = "/project/p/" + t.project_id + "?task=" + t.id;
openTaskHere(t.id, t.project_id, e);
});
tr.addEventListener("auxclick", function (e) { if (e.button === 1) openTaskHere(t.id, t.project_id, e); });
tr.addEventListener("contextmenu", function (e) {
e.preventDefault();
showContextMenu(e.clientX, e.clientY, rowContextItems(t));
@@ -3147,9 +3255,8 @@
'<span class="pj-mtk-parent-name">' + escapeHtml(subtask.parent_title || "(상위 업무)") + "</span>" +
'<span class="pj-mtk-parent-hint">' + (parentIsMine ? "상위 업무" : "다른 담당자의 상위 업무") + "</span>" +
"</td>";
tr.addEventListener("click", function () {
location.href = "/project/p/" + subtask.project_id + "?task=" + subtask.parent_task_id;
});
tr.dataset.taskId = subtask.parent_task_id;
tr.addEventListener("click", function (e) { openTaskHere(subtask.parent_task_id, subtask.project_id, e); });
tbody.appendChild(tr);
}
@@ -5237,6 +5344,9 @@
await api("PUT", "/project/api/tasks/" + sub.id,
{ assignee_email: email, assignee_name: email ? idOf(email) : "" });
sub.assignee_email = email;
if (email && Array.isArray(sub.followers)) { // 담당자는 협업자가 아니다
sub.followers = sub.followers.filter(function (x) { return String(x).toLowerCase() !== String(email).toLowerCase(); });
}
if (box.isConnected) fillCardSubs(box, t);
} catch (e) { showToast("담당자 변경 실패: " + e.message, "error"); }
}
@@ -5407,7 +5517,7 @@
fol.dataset.tip = followerTip(sub.followers);
return true;
} catch (err) { showToast("협업자 변경 실패: " + err.message, "error"); return false; }
});
}, function () { return sub.assignee_email; });
});
const check = row.querySelector(".pj-card-sub-check");
check.addEventListener("click", async function (e) {
@@ -5541,7 +5651,11 @@
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 (email) {
draft.assignee = email || "";
if (draft.assignee) draft.followers = draft.followers.filter(function (x) { return x !== draft.assignee.toLowerCase(); });
paintAv(); paintFol(); refocus();
}
));
});
// 협업자 — 고른 사람은 만들 때 followers 로 같이 보낸다(메뉴는 고를 때마다 다시 열려 여러 명).
@@ -5554,7 +5668,7 @@
draft.followers = on ? draft.followers.concat([em]) : draft.followers.filter(function (x) { return x !== em; });
paintFol();
return true;
});
}, function () { return draft.assignee; });
});
function closeDraft() {
delete subDrafts[t.id];
@@ -5576,13 +5690,7 @@
});
const subs = subsCache[t.id] || (subsCache[t.id] = []);
// 새 줄 협업자 아이콘 — 서버 자동 협업자와 같은 규칙(만든 사람·담당자·고른 협업자)
if (res.task && !Array.isArray(res.task.followers)) {
const fl = [];
[me, res.task.assignee_email].concat(draft.followers).forEach(function (x) {
x = String(x || "").toLowerCase(); if (x && fl.indexOf(x) < 0) fl.push(x);
});
res.task.followers = fl;
}
if (res.task && !Array.isArray(res.task.followers)) res.task.followers = newTaskFollowers(draft.followers, res.task.assignee_email);
subs.push(res.task);
adjustSubCounts(t.id, 1, 0);
// Enter — 다음 세부 작업을 이어서 입력(아사나): 이름만 비우고 줄은 열어 둔다.
@@ -6200,21 +6308,7 @@
const charts = document.createElement("div");
charts.className = "pj-dash-charts";
// 섹션별 미완료 — "이 프로젝트" 스코프면 보드 컬럼과 같은 순서로.
const sectionOrder = viewScope === "project"
? (stagesByProject[projectId] || []).slice().sort(function (a, b) { return a.sort_order - b.sort_order; }).map(function (s) { return s.name; })
: boardStages.slice();
const bySection = {};
incomplete.forEach(function (t) { const k = t.stage_name || "미지정"; bySection[k] = (bySection[k] || 0) + 1; });
const sectionNames = sectionOrder.filter(function (n) { return bySection[n]; });
Object.keys(bySection).forEach(function (n) { if (sectionNames.indexOf(n) < 0) sectionNames.push(n); });
const sectionData = sectionNames.map(function (n) { return { label: n, value: bySection[n] }; });
const sectionCard = document.createElement("div");
sectionCard.className = "pj-dash-card";
sectionCard.innerHTML = '<div class="pj-dash-card-title">미완료 업무 합계(섹션별)</div>';
sectionCard.appendChild(dashBarChart(sectionData));
charts.appendChild(sectionCard);
// "미완료 업무 합계(섹션별)" 카드는 2026-10-13 요청으로 없앴다(dashBarChart 는 남겨 둔다).
// 프로젝트별(2026-10-13) — 업무가 속한 프로젝트마다 완료/전체·완료율 막대. 완료 상태별 카드 바로 왼쪽.
const projectCard = document.createElement("div");
projectCard.className = "pj-dash-card";
@@ -6744,7 +6838,12 @@
}
// 완료 섹션으로 옮기거나 빼면 완료 이력 줄이 생기거나 사라진다.
if (wasDone !== !!res.task.completed_at) loadComments(id);
if (res.task._newly_assigned) loadTaskExtras(res.task); // 새 담당자가 협업자로 들어온다
if (key === "assignee" && followersTask && followersTask.id === id) {
// 담당자는 협업자가 아니다 — 서버가 뺀 것과 맞추고, 참여 버튼도 다시
const a = String(res.task.assignee_email || "").toLowerCase();
followers = followers.filter(function (x) { return x !== a; });
renderFollowers();
}
if (res.mention_skipped && res.mention_skipped.length) warnMentionSkipped(res.mention_skipped);
setAutoState(failedFields.size ? "error" : "saved");
}
@@ -6918,6 +7017,8 @@
const tog = el("pj-follow-toggle");
tog.textContent = followingMe ? "협업자에서 나가기" : "협업자로 참여";
tog.classList.toggle("is-on", followingMe);
// 내가 담당자면 협업자로 참여할 수 없다(담당자는 협업자가 아니다)
tog.hidden = !followingMe && String((el("pj-t-assignee") && el("pj-t-assignee").value) || "").toLowerCase() === me;
}
async function setFollower(email, on) {
if (!followersTask) return;
@@ -6951,8 +7052,9 @@
const r = e.currentTarget.getBoundingClientRect();
let list = [];
try { list = await membersOfProject(followersTask.project_id); } catch (_) {}
const assignee = String((el("pj-t-assignee") && el("pj-t-assignee").value) || "").toLowerCase();
const cands = list.map(function (m) { return (m.user_email || "").toLowerCase(); })
.filter(function (em) { return em && followers.indexOf(em) < 0; });
.filter(function (em) { return em && em !== assignee && followers.indexOf(em) < 0; }); // 담당자는 협업자가 아니다
if (!cands.length) { showToast("추가할 수 있는 멤버가 없습니다."); return; }
showContextMenu(r.left, r.bottom + 4, cands.map(function (em) {
return { label: idOf(em), icon: personIconHtml(em), onClick: function () { setFollower(em, true); } };
@@ -8393,8 +8495,14 @@
'<span class="pj-assignee-btn-name"></span>';
addFolBtn.querySelector(".pj-assignee-btn-name").textContent =
addFollowers.length ? "협업자 " + addFollowers.length + "명" : "협업자 없음";
addFolBtn.title = followerTip(addFollowers);
addFolBtn.removeAttribute("title");
addFolBtn.dataset.tip = followerTip(addFollowers);
}
// 추가 칸 담당자를 고르면 그 사람은 협업자에서 뺀다(담당자는 협업자가 아니다)
if (addAssignee) addAssignee.addEventListener("change", function () {
const a = String(addAssignee.value || "").toLowerCase();
if (a && addFollowers.indexOf(a) >= 0) { addFollowers = addFollowers.filter(function (x) { return x !== a; }); paintAddFol(); }
});
paintAddFol();
if (addFolBtn) addFolBtn.addEventListener("click", async function () {
if (!projectId || readOnly) return;
@@ -8405,10 +8513,11 @@
addFollowers = on ? addFollowers.concat([em]) : addFollowers.filter(function (x) { return x !== em; });
paintAddFol();
return true;
});
}, function () { return addAssignee ? addAssignee.value : ""; });
});
const addDue = el("pj-subtask-add-due");
enhanceDateInput(addDue, { placeholder: "마감일" }); // 아사나식 날짜 팝업
// 아사나식 날짜 팝업 — 추가 칸은 동그라미 아이콘 버튼(날짜가 있으면 아이콘 + 날짜, 2026-10-13)
enhanceDateInput(addDue, { placeholder: "마감일", iconOnly: true });
const addBtn = el("pj-subtask-add");
const formEl = listEl.parentNode ? listEl.parentNode.querySelector(".pj-subtask-form") : null;
let taskId = null, projectId = null, canDeleteFn = function () { return false; }, onChange = null, onOpen = null;
@@ -8550,7 +8659,12 @@
const prev = sub.assignee_email;
sub.assignee_email = v;
renderAv();
if (!(await patch({ assignee_email: v, assignee_name: v ? idOf(v) : "" }))) { sub.assignee_email = prev; renderAv(); }
if (!(await patch({ assignee_email: v, assignee_name: v ? idOf(v) : "" }))) { sub.assignee_email = prev; renderAv(); return; }
// 담당자는 협업자가 아니다 — 서버가 뺀 것과 화면을 맞춘다
if (v && Array.isArray(sub.followers)) {
sub.followers = sub.followers.filter(function (x) { return String(x).toLowerCase() !== String(v).toLowerCase(); });
renderFol();
}
}));
});
// 협업자 — 누르면 멤버 목록(협업자는 ✓). 고르면 넣고/빼고, 메뉴를 다시 열어 여러 명 지정.
@@ -8562,7 +8676,7 @@
renderFol();
return true;
} catch (err) { showToast("협업자 변경 실패: " + err.message, "error"); return false; }
});
}, function () { return sub.assignee_email; });
});
function open() { if (onOpen) onOpen(sub); }
li.querySelector(".pj-subtask-open").addEventListener("click", function (e) { e.stopPropagation(); open(); });
@@ -8688,13 +8802,7 @@
if (addAssignee) addAssignee.value = "";
if (addDue) addDue.value = "";
// 새 줄의 협업자 아이콘 — 만든 사람·담당자·고른 협업자(서버 자동 협업자와 같은 규칙)
if (res.task && !Array.isArray(res.task.followers)) {
const fl = [];
[pageMeEmail(), res.task.assignee_email].concat(addFollowers).forEach(function (x) {
x = String(x || "").toLowerCase(); if (x && fl.indexOf(x) < 0) fl.push(x);
});
res.task.followers = fl;
}
if (res.task && !Array.isArray(res.task.followers)) res.task.followers = newTaskFollowers(addFollowers, res.task.assignee_email);
addFollowers = []; paintAddFol();
const emails = await memberEmails(pid);
if (seq !== ctxSeq) return;