Merge branch 'feat/project-followers-overdue'

This commit is contained in:
2026-10-13 13:10:59 +09:00
24 changed files with 628 additions and 53 deletions
+1 -1
View File
File diff suppressed because one or more lines are too long
@@ -2,7 +2,7 @@
{% block head_extra %}
{# 프로젝트 화면 부품(설명 편집기·날짜 팝업·멤버 고르기)을 그대로 쓴다 — project.js 는 PJ_LIB_ONLY 로 부품만 #}
<link rel="stylesheet" href="/static/project.css?v=20261013a" />
<link rel="stylesheet" href="/static/project.css?v=20261013b" />
<link rel="stylesheet" href="/static/vendor/material-symbols/material-symbols.css" />
<script>window.PJ_LIB_ONLY = true; window.PJ_HOLIDAYS = {{ (pj_kr_holidays or {}) | tojson }};</script>
{% endblock %}
@@ -64,7 +64,7 @@
</section>
</div>
<script>window.NTC_PEOPLE = {{ people | tojson }};</script>
<script src="/static/project.js?v=20261013a" defer></script>
<script src="/static/project.js?v=20261013b" defer></script>
<script src="/static/erp-notice-admin.js?v=20261012b" defer></script>
{% endif %}
{% endblock %}
+15
View File
@@ -1835,6 +1835,21 @@ class ProjectStore:
).fetchall()
return [dict(r) for r in rows]
def list_my_overdue(self, *, assignee_email: str, today: Any, limit: int = 200) -> list[dict[str, Any]]:
"""내가 담당인 미완료 업무 중 마감일이 오늘 이전인 것(세부 업무 포함, 마감 오래된 것부터)."""
with self._pool.connection() as conn:
rows = conn.execute(
"SELECT t.id, t.title, t.due_date, t.project_id, t.parent_task_id, "
" p.name AS project_name, p.color AS project_color, pt.title AS parent_title "
"FROM tasks t JOIN projects p ON p.id = t.project_id "
"LEFT JOIN tasks pt ON pt.id = t.parent_task_id "
"WHERE t.assignee_email = %s AND t.completed_at IS NULL "
" AND t.due_date IS NOT NULL AND t.due_date < %s "
"ORDER BY t.due_date ASC, t.id ASC LIMIT %s",
(store.norm_str(assignee_email, lower=True), today, int(limit)),
).fetchall()
return [self._serialize(r) for r in rows]
def list_my_open_refs(self, *, assignee_email: str) -> list[dict[str, Any]]:
"""내가 담당인 미완료 작업 전부의 (id, project_id) — "내 작업" 배지를 제한 없이 정확히 센다."""
with self._pool.connection() as conn:
+28 -2
View File
@@ -1448,6 +1448,18 @@ def api_my_tasks(request: Request) -> JSONResponse:
return JSONResponse({"tasks": _my_visible_tasks(st, user)})
@router.get("/api/my-overdue")
def api_my_overdue(request: Request) -> JSONResponse:
"""마감이 지난 내 미완료 업무(마감일이 오늘(한국시간) 이전) — ERP 모든 화면 위쪽 알림(static/erp-overdue.js)이 쓴다.
지금 볼 수 있는 업무만, 마감이 오래된 것부터."""
user = _require_user(request)
st = _db_or_503(request)
today = today_kst()
rows = access.filter_visible_tasks(st, user, st.list_my_overdue(assignee_email=user["email"], today=today))
keys = ("id", "title", "due_date", "project_id", "project_name", "project_color", "parent_task_id", "parent_title")
return JSONResponse({"today": today.isoformat(), "tasks": [{k: t.get(k) for k in keys} for t in rows]})
@router.get("/api/my-tasks/open-count")
def api_my_open_count(request: Request) -> JSONResponse:
"""사이드바 "내 업무" 배지 숫자만 — 목록 전체를 받지 않는다."""
@@ -1480,6 +1492,7 @@ def _create_task_for(
if project is None:
raise HTTPException(status_code=404, detail="프로젝트를 찾을 수 없습니다.")
_check_assignee(st, payload.get("assignee_email"), project_id)
followers = _check_followers(st, payload.get("followers"), project_id)
try:
task = st.create_task(
project_id=project_id,
@@ -1501,8 +1514,8 @@ def _create_task_for(
raise HTTPException(status_code=400, detail=str(exc))
except KeyError as exc:
raise HTTPException(status_code=404, detail=str(exc))
# 만든 사람·담당자는 자동 팔로워(아사나와 같은 규칙)
_follow(st, task["id"], [user["email"], task.get("assignee_email") or ""])
# 만든 사람·담당자는 자동 팔로워(아사나와 같은 규칙) + 만들 때 고른 협업자(세부 업무 추가 칸 등)
_follow(st, task["id"], [user["email"], task.get("assignee_email") or ""] + followers)
# 생성과 동시에 담당자 지정 시 관리자 메일 + 담당자 인앱 알림
if task.get("assignee_email"):
_notify(
@@ -1541,6 +1554,19 @@ def _create_task_for(
_ASSIGNEE_DENIED = "담당자는 이 프로젝트를 볼 수 있는 사람(멤버·소유자·관리자)이어야 합니다."
def _check_followers(st: Any, raw: Any, project_id: int) -> list[str]:
"""업무를 만들 때 같이 고른 협업자 — 협업자 추가 API 와 같은 기준(그 프로젝트를 볼 수 있는 사람만, 아니면 400)."""
if not raw:
return []
if not isinstance(raw, list):
raise HTTPException(status_code=400, detail="협업자 목록이 올바르지 않습니다.")
emails = store.normalize_emails([str(e) for e in raw])
for em in emails:
if not access.can_assign(st, em, project_id):
raise HTTPException(status_code=400, detail="이 프로젝트 멤버만 협업자로 추가할 수 있습니다.")
return emails
def _check_assignee(st: Any, email: Any, project_id: int, *, previous: str = "") -> None:
"""새로 지정하는 담당자가 그 프로젝트를 볼 수 있는지 — 권한 없는 사람에게 배정 알림(작업 제목
등)이 가지 않게. 비우거나 그대로 두는 건 검사하지 않는다(멤버에서 빠진 예전 담당자 보존)."""
@@ -1,7 +1,7 @@
{% extends "project/_meeting_content_base.html" if meeting_embedded else "erp_base.html" %}
{% block head_extra %}
<link rel="stylesheet" href="/static/project.css?v=20261013a" />
<link rel="stylesheet" href="/static/project.css?v=20261013b" />
<link rel="stylesheet" href="/static/vendor/material-symbols/material-symbols.css" />
{% endblock %}
@@ -298,5 +298,5 @@
<script src="/static/project-goal-text.js?v=20261003d" defer></script>
<script src="/static/project-meeting-cells.js?v=20261012a" defer></script>
<script src="/static/project.js?v=20261013a" defer></script>
<script src="/static/project.js?v=20261013b" defer></script>
{% endblock %}
@@ -1,7 +1,7 @@
{% extends "erp_base.html" %}
{% block head_extra %}
<link rel="stylesheet" href="/static/project.css?v=20261013a" />
<link rel="stylesheet" href="/static/project.css?v=20261013b" />
<link rel="stylesheet" href="/static/vendor/material-symbols/material-symbols.css" />
{% endblock %}
@@ -207,5 +207,5 @@
{% include "project/_member_tasks_modal.html" %}
<script src="/static/project-goal-text.js?v=20261003d" defer></script>
<script src="/static/project.js?v=20261013a" defer></script>
<script src="/static/project.js?v=20261013b" defer></script>
{% endblock %}
@@ -1,7 +1,7 @@
{% extends "erp_base.html" %}
{% block head_extra %}
<link rel="stylesheet" href="/static/project.css?v=20261013a" />
<link rel="stylesheet" href="/static/project.css?v=20261013b" />
<link rel="stylesheet" href="/static/project-help.css?v=20261003a" />
<link rel="stylesheet" href="/static/vendor/material-symbols/material-symbols.css" />
{% endblock %}
@@ -1,7 +1,7 @@
{% extends "erp_base.html" %}
{% block head_extra %}
<link rel="stylesheet" href="/static/project.css?v=20261013a" />
<link rel="stylesheet" href="/static/project.css?v=20261013b" />
<link rel="stylesheet" href="/static/vendor/material-symbols/material-symbols.css" />
{% endblock %}
@@ -102,5 +102,5 @@
{% include "project/_side_modals.html" %}
{% include "project/_member_tasks_modal.html" %}
<script src="/static/project.js?v=20261013a" defer></script>
<script src="/static/project.js?v=20261013b" defer></script>
{% endblock %}
@@ -1,7 +1,7 @@
{% extends "erp_base.html" %}
{% block head_extra %}
<link rel="stylesheet" href="/static/project.css?v=20261013a" />
<link rel="stylesheet" href="/static/project.css?v=20261013b" />
<link rel="stylesheet" href="/static/vendor/material-symbols/material-symbols.css" />
{% endblock %}
@@ -100,5 +100,5 @@
"today": {{ today | tojson }}
}
</script>
<script src="/static/project.js?v=20261013a" defer></script>
<script src="/static/project.js?v=20261013b" defer></script>
{% endblock %}
@@ -1,7 +1,7 @@
{% extends "erp_base.html" %}
{% block head_extra %}
<link rel="stylesheet" href="/static/project.css?v=20261013a" />
<link rel="stylesheet" href="/static/project.css?v=20261013b" />
<link rel="stylesheet" href="/static/vendor/material-symbols/material-symbols.css" />
{% endblock %}
@@ -108,5 +108,5 @@
});
})();
</script>
<script src="/static/project.js?v=20261013a" defer></script>
<script src="/static/project.js?v=20261013b" defer></script>
{% endblock %}
@@ -1,7 +1,7 @@
{% extends "erp_base.html" %}
{% block head_extra %}
<link rel="stylesheet" href="/static/project.css?v=20261013a" />
<link rel="stylesheet" href="/static/project.css?v=20261013b" />
<!-- 구글 머티리얼 심볼(담당자 아이콘 등) — self-host -->
<link rel="stylesheet" href="/static/vendor/material-symbols/material-symbols.css" />
<!-- 타임라인 vis-timeline — self-host -->
@@ -365,6 +365,7 @@
<div class="pj-subtask-form">
<input type="text" id="pj-subtask-input" placeholder="세부 업무 제목…" autocomplete="off" />
<select id="pj-subtask-add-assignee"><option value="">담당자 없음</option></select>
<button type="button" class="pj-assignee-btn is-empty pj-subtask-add-fol" id="pj-subtask-add-followers" title="협업자 지정">협업자 없음</button>
<input type="date" id="pj-subtask-add-due" />
<button type="button" class="pj-btn pj-btn-primary" id="pj-subtask-add">추가</button>
</div>
@@ -468,5 +469,5 @@
</script>
<script src="/static/vendor/vis-timeline/vis-timeline-graph2d.min.js"></script>
<script src="/static/project.js?v=20261013a" defer></script>
<script src="/static/project.js?v=20261013b" defer></script>
{% endblock %}
@@ -1,7 +1,7 @@
{% extends "erp_base.html" %}
{% block head_extra %}
<link rel="stylesheet" href="/static/project.css?v=20261013a" />
<link rel="stylesheet" href="/static/project.css?v=20261013b" />
<link rel="stylesheet" href="/static/vendor/material-symbols/material-symbols.css" />
{% endblock %}
@@ -70,5 +70,5 @@
{% include "project/_side_modals.html" %}
{% include "project/_member_tasks_modal.html" %}
<script src="/static/project.js?v=20261013a" defer></script>
<script src="/static/project.js?v=20261013b" defer></script>
{% endblock %}
+33
View File
@@ -0,0 +1,33 @@
/* 마감 지난 내 업무 알림 — ERP 모든 화면 위쪽 가운데(erp-overdue.js). body 에 붙어 화면 배율(.erp-app zoom) 밖. 긴급 공지(6000)보다 아래. */
.erp-overdue {
position: fixed; top: 12px; left: 50%; transform: translateX(-50%); z-index: 5500;
width: min(560px, calc(100vw - 32px)); box-sizing: border-box;
padding: 12px 14px 10px; border-radius: 12px; background: #fff; color: #1e1f21;
border: 1px solid #f3c5c6; border-top: 4px solid #e5484d;
box-shadow: 0 12px 36px rgba(16, 24, 40, .22);
font-size: 13.5px; animation: erp-overdue-in .22s ease-out;
}
.erp-overdue[hidden] { display: none; }
@keyframes erp-overdue-in { from { opacity: 0; transform: translate(-50%, -10px); } to { opacity: 1; transform: translate(-50%, 0); } }
.erp-overdue-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.erp-overdue-head b { flex: 1 1 auto; font-size: 14.5px; color: #c62a2f; }
.erp-overdue-ic { font-size: 17px; }
.erp-overdue-close {
flex: none; border: 1px solid #d8dce2; background: #fff; color: #4b5059; border-radius: 8px;
padding: 4px 10px; font: inherit; font-size: 12px; cursor: pointer;
}
.erp-overdue-close:hover { background: #f3f4f6; }
.erp-overdue-list { display: flex; flex-direction: column; max-height: 50vh; overflow-y: auto; }
.erp-overdue-item {
display: flex; align-items: center; gap: 10px; padding: 7px 6px; border-radius: 8px;
color: inherit; text-decoration: none;
}
.erp-overdue-item:hover { background: #fdf2f2; }
.erp-overdue-dot { flex: none; width: 9px; height: 9px; border-radius: 3px; }
.erp-overdue-text { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.erp-overdue-text b, .erp-overdue-text small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.erp-overdue-text b { font-weight: 600; }
.erp-overdue-text small { color: #6b7079; font-size: 11.5px; }
.erp-overdue-late { flex: none; color: #c62a2f; font-size: 12px; font-weight: 700; white-space: nowrap; }
.erp-overdue-more { padding: 6px; font-size: 12px; color: #3b6fd8; text-decoration: none; }
.erp-overdue-more:hover { text-decoration: underline; }
+106
View File
@@ -0,0 +1,106 @@
// 마감 지난 내 업무 알림 — ERP 모든 화면 위쪽 가운데(2026-10-13).
// · GET /project/api/my-overdue — 내가 담당인 미완료 업무 중 마감일이 오늘(한국시간) 이전인 것(지금 볼 수 있는 것만).
// · [닫기] 하면 1시간 동안 다시 띄우지 않는다(이 브라우저의 모든 탭 — localStorage). 1시간이 지나면 다시 나타난다.
// 단, 닫을 때 없던 업무가 새로 마감을 넘기면 1시간을 기다리지 않고 바로 띄운다.
// · 5분마다·창을 다시 볼 때 확인. 다 완료하면 알림은 사라진다.
// · Project 권한이 없거나(403) 로그아웃(401)·모듈 미설정(503)이면 조용히 멈춘다. iframe(수신함 업무 창 등) 안에서는 돌지 않는다.
(function () {
"use strict";
if (window.top !== window) return;
const POLL_MS = 5 * 60 * 1000;
const SNOOZE_MS = 60 * 60 * 1000;
const KEY = "erp_overdue_snooze"; // {until: ms, ids: [업무 id]}
const MAX_ROWS = 5;
let box = null, timer = 0, busy = false, stopped = false, last = [], memSnooze = null;
function esc(s) {
return String(s == null ? "" : s).replace(/[&<>"']/g, function (c) {
return { "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;", "'": "&#39;" }[c];
});
}
function readSnooze() {
try { return JSON.parse(localStorage.getItem(KEY) || "null") || memSnooze; } catch (_) { return memSnooze; }
}
function writeSnooze(v) {
memSnooze = v;
try { localStorage.setItem(KEY, JSON.stringify(v)); } catch (_) {}
}
// 닫은 지 1시간이 안 됐고, 지금 목록이 닫을 때 본 업무뿐이면 쉰다.
function snoozed(tasks) {
const s = readSnooze();
if (!s || !(Date.now() < s.until)) return false;
const seen = s.ids || [];
return tasks.every(function (t) { return seen.indexOf(t.id) >= 0; });
}
function daysLate(due, today) {
const a = Date.parse(String(due).slice(0, 10) + "T00:00:00Z"), b = Date.parse(String(today).slice(0, 10) + "T00:00:00Z");
return isNaN(a) || isNaN(b) ? 0 : Math.round((b - a) / 86400000);
}
function md(due) {
const m = /^(\d{4})-(\d{2})-(\d{2})/.exec(due || "");
return m ? parseInt(m[2], 10) + "/" + parseInt(m[3], 10) : "";
}
function schedule() { clearTimeout(timer); if (!stopped) timer = setTimeout(poll, POLL_MS); }
async function poll() {
if (busy || stopped) return;
if (document.hidden) { schedule(); return; }
busy = true;
try {
const res = await fetch("/project/api/my-overdue", { headers: { Accept: "application/json" }, credentials: "same-origin" });
if (res.status === 401 || res.status === 403 || res.status === 404 || res.status === 503) { stopped = true; hide(); return; }
if (!res.ok) return;
const data = await res.json();
last = Array.isArray(data.tasks) ? data.tasks : [];
if (!last.length || snoozed(last)) hide();
else show(last, data.today || "");
} catch (_) {
// 네트워크 오류는 다음 주기에 다시
} finally {
busy = false;
schedule();
}
}
function show(tasks, today) {
if (!box) {
box = document.createElement("div");
box.className = "erp-overdue";
box.setAttribute("role", "alert");
document.body.appendChild(box); // 화면 배율(.erp-app zoom) 밖 — 늘 화면 위쪽 가운데
box.addEventListener("click", function (e) {
if (e.target.closest("[data-overdue-close]")) dismiss();
});
}
const rows = tasks.slice(0, MAX_ROWS).map(function (t) {
const late = daysLate(t.due_date, today);
const where = [t.project_name, t.parent_title ? "상위: " + t.parent_title : ""].filter(Boolean).join(" · ");
return '<a class="erp-overdue-item" href="/project/t/' + encodeURIComponent(t.id) + '">' +
'<span class="erp-overdue-dot" style="background:' + esc(t.project_color || "#e5484d") + '"></span>' +
'<span class="erp-overdue-text"><b>' + esc(t.title || "(제목 없음)") + "</b><small>" + esc(where) + "</small></span>" +
'<span class="erp-overdue-late">마감 ' + esc(md(t.due_date)) + (late > 0 ? " · " + late + "일 지남" : "") + "</span></a>";
}).join("");
const more = tasks.length > MAX_ROWS
? '<a class="erp-overdue-more" href="/project/">그 밖에 ' + (tasks.length - MAX_ROWS) + "건 — 내 업무에서 보기</a>" : "";
box.innerHTML =
'<div class="erp-overdue-head"><span class="erp-overdue-ic" aria-hidden="true">⏰</span>' +
'<b>마감이 지난 내 업무 ' + tasks.length + "건</b>" +
'<button type="button" class="erp-overdue-close" data-overdue-close title="닫으면 1시간 뒤에 다시 알려 드립니다">닫기 (1시간 뒤 다시)</button></div>' +
'<div class="erp-overdue-list">' + rows + more + "</div>";
box.hidden = false;
}
function hide() { if (box) box.hidden = true; }
function dismiss() {
writeSnooze({ until: Date.now() + SNOOZE_MS, ids: last.map(function (t) { return t.id; }) });
hide();
// 1시간 뒤 바로 다시 확인(5분 주기를 기다리지 않게)
setTimeout(poll, SNOOZE_MS + 1000);
}
// 다른 탭에서 닫으면 이 탭도 닫는다.
window.addEventListener("storage", function (e) { if (e.key === KEY && last.length && snoozed(last)) hide(); });
document.addEventListener("visibilitychange", function () { if (!document.hidden) poll(); });
if (window.__ERP_OVERDUE_TEST__) window.__erpOverdue = { poll: poll, state: function () { return { last: last, stopped: stopped, box: box }; } };
if (document.readyState === "loading") document.addEventListener("DOMContentLoaded", poll);
else poll();
})();
+41 -3
View File
@@ -1275,6 +1275,18 @@ html.pj-ui-scale #pj-timeline { zoom: calc(1 / var(--pj-z)); --tz: var(--pj-z);
.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-sub-fol {
flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center; gap: 1px;
min-width: 24px; height: 24px; padding: 0 2px; border-radius: 12px; cursor: pointer; color: #6d6e6f;
}
.pj-card-sub-fol img.pj-person-ic { width: 20px; height: 20px; border-radius: 50%; }
.pj-card-sub-fol .pj-gicon { font-size: 20px; }
.pj-card-sub-fol > svg { width: 20px; height: 20px; }
.pj-card-sub-fol:not(.is-empty):hover { background: #eceef0; }
.pj-card-sub-fol.is-empty { opacity: 0; transition: opacity .12s; }
.pj-card-sub:hover .pj-card-sub-fol.is-empty { opacity: 1; }
.pj-card-sub-fol.is-empty:hover { color: #1e1f21; background: #eceef0; }
/* 카드 하위 작업 맨 아래 "+ 하위 작업 추가"와 새 줄 입력(아사나) */
.pj-card-subnew {
display: flex; align-items: center; gap: 6px; min-height: 36px; padding: 2px 4px;
@@ -1287,9 +1299,10 @@ html.pj-ui-scale #pj-timeline { zoom: calc(1 / var(--pj-z)); --tz: var(--pj-z);
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-subnew .pj-card-sub-av.is-empty,
.pj-card-subnew .pj-card-sub-fol.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;
@@ -1457,7 +1470,8 @@ label.pj-desc-fmtbtn {
.pj-subtask-fol .pj-gicon { font-size: 22px; }
.pj-subtask-fol-n { font-size: 11px; font-weight: 600; color: var(--pj-ink-soft); }
.pj-subtask-fol:not(.is-empty):hover { background: #eceef0; }
.pj-subtask-fol.is-empty { opacity: 0; transition: opacity .12s; }
.pj-subtask-fol > svg { width: 22px; height: 22px; }
.pj-subtask-fol.is-empty { opacity: .5; transition: opacity .12s; } /* 비어 있어도 늘 보인다(옅게) */
.pj-subtask-row:hover .pj-subtask-fol.is-empty { opacity: 1; }
.pj-subtask-fol.is-empty:hover { color: #1e1f21; background: #eceef0; }
/* 하위 작업 열기(›) — 줄에 마우스를 올리면 진해진다 */
@@ -1572,6 +1586,14 @@ img.pj-person-ic { width: 22px; height: 22px; }
flex: 0 0 auto; width: 110px; font-size: 12px; font-weight: 500; padding: 3px 6px;
border-color: #d8dce2; border-radius: 8px; background: #fff;
}
.pj-assignee-btn.pj-subtask-add-fol {
flex: 0 0 auto; width: 110px; font-size: 12px; font-weight: 500; padding: 3px 6px;
border-color: #d8dce2; border-radius: 8px; background: #fff;
}
.pj-assignee-btn.pj-subtask-add-fol img.pj-person-ic { width: 18px; height: 18px; }
.pj-assignee-btn.pj-subtask-add-fol .pj-person-ic svg,
.pj-assignee-btn.pj-subtask-add-fol > svg { width: 18px; height: 18px; flex: 0 0 auto; }
.pj-assignee-btn.pj-subtask-add-fol .pj-subtask-fol-n { margin-left: -2px; }
.pj-assignee-btn.pj-subtask-assignee img.pj-person-ic,
.pj-assignee-btn[data-for="pj-subtask-add-assignee"] img.pj-person-ic { width: 18px; height: 18px; }
.pj-assignee-btn.pj-subtask-assignee .pj-person-ic svg,
@@ -1594,6 +1616,21 @@ img.pj-person-ic { width: 22px; height: 22px; }
box-shadow: var(--pj-card-shadow); padding: 18px 20px 20px; min-width: 0;
}
.pj-dash-card-wide { grid-column: 1 / -1; }
/* 업무 합계(프로젝트별) — 가로 막대 줄(채움 = 완료율) */
.pj-dash-projbars { display: flex; flex-direction: column; gap: 4px; max-height: 210px; overflow-y: auto; margin: 0 -6px; }
.pj-dash-projrow {
display: grid; grid-template-columns: 10px minmax(0, 1fr) minmax(70px, 1.2fr) auto; align-items: center; gap: 8px;
padding: 6px; border-radius: 8px; color: var(--pj-ink); text-decoration: none; font-size: 12.5px;
}
.pj-dash-projrow:hover { background: #f5f6f8; }
.pj-dash-projdot { width: 10px; height: 10px; border-radius: 3px; }
.pj-dash-projname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.pj-dash-projtrack { position: relative; height: 10px; border-radius: 5px; background: #e6e3f7; overflow: hidden; }
.pj-dash-projtrack i {
position: absolute; left: 0; top: 0; bottom: 0; width: 0; border-radius: 5px;
background: var(--color-success-green, #2e9e5b); transition: width .6s cubic-bezier(.22,.9,.3,1);
}
.pj-dash-projval { color: var(--pj-ink-soft); font-variant-numeric: tabular-nums; white-space: nowrap; font-size: 12px; }
/* 담당자별 작업 합계 — 사람마다 메인·하위 세로 막대. 막대 = 그 작업 전체(100%), 초록 채움 = 완료율. 누르면 오른쪽 업무 목록 패널 */
.pj-wl-legend { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin: -6px 0 14px; font-size: 12px; color: var(--pj-ink-soft); }
.pj-wl-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
@@ -1709,6 +1746,7 @@ img.pj-person-ic { width: 22px; height: 22px; }
.pj-dash-stats .pj-dash-stat:nth-child(4) { animation-delay: .12s; }
.pj-dash-charts .pj-dash-card:nth-child(2) { animation-delay: .06s; }
.pj-dash-charts .pj-dash-card:nth-child(3) { animation-delay: .12s; }
.pj-dash-charts .pj-dash-card:nth-child(4) { animation-delay: .18s; }
@keyframes pj-dash-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
@media (max-width: 900px) { .pj-dash-stats { grid-template-columns: repeat(2, 1fr); } }
+183 -30
View File
@@ -968,6 +968,47 @@
});
return items;
}
// 협업자 고르기 메뉴 — 후보 멤버(지금 협업자는 ✓). 고르면 onToggle(email, 켜기?) 를 기다린 뒤 같은 자리에 메뉴를
// 다시 열어 여러 명을 이어서 고른다(Esc·바깥 클릭으로 닫힘). current() = 지금 협업자 목록.
function openFollowerMenu(anchor, emails, current, onToggle) {
const lower = function (x) { return String(x || "").toLowerCase(); };
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); });
if (!cands.length) { showToast("지정할 수 있는 멤버가 없습니다."); return; }
const r = anchor.getBoundingClientRect();
showContextMenu(r.left, r.bottom + 4, cands.map(function (em) {
const on = cur.indexOf(em) >= 0;
return {
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);
},
};
}), { label: "협업자 지정" });
}
// 협업자 아이콘 — 없으면 점선 원 두 사람, 있으면 첫 사람 아이콘 + "+N".
function followerIconHtml(list) {
list = list || [];
return list.length
? personIconHtml(list[0]) + (list.length > 1 ? '<span class="pj-subtask-fol-n">+' + (list.length - 1) + "</span>" : "")
: FOLLOWER_EMPTY_ICON_SVG;
}
// 세부 업무 협업자 넣기/빼기 → 그 업무의 협업자 목록.
async function setTaskFollower(taskId, email, on) {
const res = on
? await api("POST", "/project/api/tasks/" + taskId + "/followers", { email: email })
: await api("DELETE", "/project/api/tasks/" + taskId + "/followers/" + encodeURIComponent(email));
return res.followers || [];
}
function pageMeEmail() {
const w = document.querySelector(".pj-wrap");
return ((w && w.dataset.me) || "").toLowerCase();
}
function followerTip(list) {
return list && list.length ? "협업자: " + list.map(idOf).join(", ") : "협업자 지정";
}
// <select> 담당자 칸을 "아이콘 + 이름" 버튼으로 바꿔 보여준다. select 는 숨겨
// 값 저장소로 그대로 둔다 — 기존 코드의 sel.value 읽기/쓰기, change 이벤트,
// selectedOptions 가 그대로 동작. 코드가 sel.value 를 바꾸거나 옵션을 다시
@@ -5039,6 +5080,11 @@
? '<span class="pj-card-sub-av" data-tip="' + escapeHtml(idOf(sub.assignee_email)) + '">' +
avatarHtml(sub.assignee_email, "pj-gicon-sm") + "</span>"
: '<span class="pj-card-sub-av is-empty" data-tip="이 업무 배정">' + ASSIGN_EMPTY_ICON_SVG + "</span>") +
// 협업자 — 담당자 오른쪽(편집 권한자, 서버가 followers 를 준 경우만). 누르면 멤버 메뉴.
(canManage && Array.isArray(sub.followers)
? '<span class="pj-card-sub-fol' + (sub.followers.length ? "" : " is-empty") + '" data-tip="' +
escapeHtml(followerTip(sub.followers)) + '">' + followerIconHtml(sub.followers) + "</span>"
: "") +
"</div>";
}
// 담당자 미지정 아이콘(아사나 모양: 점선 원 안의 사람).
@@ -5213,6 +5259,24 @@
const r = av.getBoundingClientRect();
openSubAssigneePicker(t, sub, box, r.left, r.bottom + 4);
});
const fol = row.querySelector(".pj-card-sub-fol");
if (fol) fol.addEventListener("click", async function (e) {
e.stopPropagation();
let list;
try { list = await membersOfProject(t.project_id); }
catch (err) { showToast("멤버 조회 실패: " + err.message, "error"); return; }
openFollowerMenu(fol, list.map(function (m) { return m.user_email; }), function () { return sub.followers; },
async function (em, on) {
try {
sub.followers = await setTaskFollower(sub.id, em, on);
// 메뉴가 같은 아이콘에 다시 붙도록 목록을 다시 그리지 않고 이 아이콘만 바꾼다.
fol.classList.toggle("is-empty", !sub.followers.length);
fol.innerHTML = followerIconHtml(sub.followers);
fol.dataset.tip = followerTip(sub.followers);
return true;
} catch (err) { showToast("협업자 변경 실패: " + err.message, "error"); return false; }
});
});
const check = row.querySelector(".pj-card-sub-check");
check.addEventListener("click", async function (e) {
e.stopPropagation();
@@ -5249,6 +5313,7 @@
'<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>' +
'<span class="pj-card-sub-fol pj-card-subnew-fol"></span>' +
"</div>";
}
wrap.insertAdjacentHTML("beforeend",
@@ -5260,7 +5325,7 @@
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 };
if (!subDrafts[t.id]) subDrafts[t.id] = { title: "", due: null, assignee: "", followers: [], focused: true };
else subDrafts[t.id].focused = true;
refillSubs(box, t);
});
@@ -5269,6 +5334,8 @@
const inp = wrap.querySelector(".pj-card-subnew-title");
const dueEl = wrap.querySelector(".pj-card-subnew-due");
const avEl = wrap.querySelector(".pj-card-subnew-av");
const folEl = wrap.querySelector(".pj-card-subnew-fol");
if (!draft.followers) draft.followers = [];
inp.value = draft.title;
function paintDue() {
const di = dueInfo(draft.due, false);
@@ -5281,7 +5348,12 @@
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 paintFol() {
folEl.className = "pj-card-sub-fol pj-card-subnew-fol" + (draft.followers.length ? "" : " is-empty");
folEl.innerHTML = followerIconHtml(draft.followers);
folEl.dataset.tip = followerTip(draft.followers);
}
paintDue(); paintAv(); paintFol();
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; });
@@ -5293,7 +5365,7 @@
draft.focused = document.activeElement === inp;
// 날짜 팝업·담당자 메뉴를 쓰는 중이면 닫지 않는다.
if (draft.focused || datePopEl || ctxMenuEl) return;
if (!draft.title.trim() && !draft.due && !draft.assignee) closeDraft();
if (!draft.title.trim() && !draft.due && !draft.assignee && !draft.followers.length) closeDraft();
}, 150);
});
inp.addEventListener("keydown", function (e) {
@@ -5324,7 +5396,7 @@
if (subDrafts[t.id] !== draft) return;
if (inp.isConnected) draft.title = inp.value;
if (draft.title.trim()) createFromDraft(false);
else if (!draft.due && !draft.assignee) closeDraft();
else if (!draft.due && !draft.assignee && !draft.followers.length) closeDraft();
}, 0);
}
if (subOutsideDown[t.id]) document.removeEventListener("pointerdown", subOutsideDown[t.id], true);
@@ -5340,6 +5412,18 @@
function (email) { draft.assignee = email || ""; paintAv(); refocus(); }
));
});
// 협업자 — 고른 사람은 만들 때 followers 로 같이 보낸다(메뉴는 고를 때마다 다시 열려 여러 명).
folEl.addEventListener("click", async function () {
let list;
try { list = await membersOfProject(t.project_id); }
catch (e) { showToast("멤버 조회 실패: " + e.message, "error"); return; }
openFollowerMenu(folEl, list.map(function (m) { return m.user_email; }), function () { return draft.followers; },
function (em, on) {
draft.followers = on ? draft.followers.concat([em]) : draft.followers.filter(function (x) { return x !== em; });
paintFol();
return true;
});
});
function closeDraft() {
delete subDrafts[t.id];
if (box.isConnected) refillSubs(box, t);
@@ -5356,14 +5440,23 @@
due_date: draft.due || null,
assignee_email: draft.assignee || "",
assignee_name: draft.assignee ? idOf(draft.assignee) : "",
followers: draft.followers,
});
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;
}
subs.push(res.task);
adjustSubCounts(t.id, 1, 0);
// Enter — 다음 세부 작업을 이어서 입력(아사나): 이름만 비우고 줄은 열어 둔다.
// 바깥 누름 — 줄을 닫는다.
if (keepOpen === false) delete subDrafts[t.id];
else subDrafts[t.id] = { title: "", due: null, assignee: "", focused: true };
else subDrafts[t.id] = { title: "", due: null, assignee: "", followers: [], focused: true };
renderBoard(); // 카드의 "N ⤷" 숫자까지 맞춘다
} catch (e) {
showToast("세부 업무 추가 실패: " + e.message, "error");
@@ -5436,7 +5529,7 @@
tog.classList.add("is-open");
// 세부 작업이 없는 카드 — 펼치면 곧바로 이름 입력 줄(아사나의 "세부 작업 추가")
if (!t.subtask_total && canManage && !subDrafts[t.id]) {
subDrafts[t.id] = { title: "", due: null, assignee: "", focused: true };
subDrafts[t.id] = { title: "", due: null, assignee: "", followers: [], focused: true };
}
loadCardSubs(t).then(function (changed) { // 펼칠 때마다 최신으로
if (changed) { renderBoard(); return; }
@@ -5820,6 +5913,39 @@
animateCount(valEl, value, 700);
return tile;
}
// 프로젝트별 완료 막대 — 줄마다 색 점·프로젝트 이름(누르면 그 프로젝트)·막대(채움 = 완료율)·완료/전체(%).
// 업무 수가 많은 프로젝트부터. 넘치면 카드 안에서 세로 스크롤.
function dashProjectBars(list) {
const by = {};
list.forEach(function (t) {
const k = String(t.project_id);
const p = by[k] || (by[k] = { id: t.project_id, name: t.project_name || "프로젝트", color: t.project_color || "", done: 0, total: 0 });
p.total++;
if (t.completed_at) p.done++;
});
const rows = Object.keys(by).map(function (k) { return by[k]; })
.sort(function (a, b) { return b.total - a.total || String(a.name).localeCompare(String(b.name), "ko"); });
const wrap = document.createElement("div");
wrap.className = "pj-dash-projbars";
if (!rows.length) { wrap.innerHTML = "<div class='pj-empty-sm'>데이터가 없습니다.</div>"; return wrap; }
rows.forEach(function (p) {
const pct = p.total ? Math.round(p.done / p.total * 100) : 0;
const row = document.createElement("a");
row.className = "pj-dash-projrow";
row.href = "/project/p/" + encodeURIComponent(p.id);
row.title = p.name + " — 완료 " + p.done + " / " + p.total + " (" + pct + "%)";
row.innerHTML = '<span class="pj-dash-projdot"></span><span class="pj-dash-projname"></span>' +
'<span class="pj-dash-projtrack"><i></i></span><span class="pj-dash-projval"></span>';
row.querySelector(".pj-dash-projdot").style.background = p.color || "var(--pj-accent)";
row.querySelector(".pj-dash-projname").textContent = p.name;
row.querySelector(".pj-dash-projval").textContent = p.done + "/" + p.total + " · " + pct + "%";
const fill = row.querySelector(".pj-dash-projtrack i");
fill.dataset.pct = String(pct);
requestAnimationFrame(function () { requestAnimationFrame(function () { fill.style.width = pct + "%"; }); });
wrap.appendChild(row);
});
return wrap;
}
// 세로 막대 그래프 — 섹션별/담당자별 공용. data = [{label, value}].
function dashBarChart(data) {
const wrap = document.createElement("div");
@@ -5955,6 +6081,13 @@
sectionCard.appendChild(dashBarChart(sectionData));
charts.appendChild(sectionCard);
// 프로젝트별(2026-10-13) — 업무가 속한 프로젝트마다 완료/전체·완료율 막대. 완료 상태별 카드 바로 왼쪽.
const projectCard = document.createElement("div");
projectCard.className = "pj-dash-card";
projectCard.innerHTML = '<div class="pj-dash-card-title">업무 합계(프로젝트별)</div>';
projectCard.appendChild(dashProjectBars(vis));
charts.appendChild(projectCard);
// 완료 상태별 — 2구간 도넛(완료=초록, 미완료=포인트 컬러).
const statusCard = document.createElement("div");
statusCard.className = "pj-dash-card";
@@ -8116,6 +8249,30 @@
const input = el("pj-subtask-input");
const addAssignee = el("pj-subtask-add-assignee");
enhanceAssigneeSelect(addAssignee);
// 추가 칸 협업자(담당자 오른쪽) — 고른 사람은 [추가] 때 followers 로 같이 보낸다.
const addFolBtn = el("pj-subtask-add-followers");
let addFollowers = [];
function paintAddFol() {
if (!addFolBtn) return;
addFolBtn.classList.toggle("is-empty", !addFollowers.length);
addFolBtn.innerHTML = (addFollowers.length ? followerIconHtml(addFollowers) : personIconHtml("")) +
'<span class="pj-assignee-btn-name"></span>';
addFolBtn.querySelector(".pj-assignee-btn-name").textContent =
addFollowers.length ? "협업자 " + addFollowers.length + "명" : "협업자 없음";
addFolBtn.title = followerTip(addFollowers);
}
paintAddFol();
if (addFolBtn) addFolBtn.addEventListener("click", async function () {
if (!projectId || readOnly) return;
const seq = ctxSeq;
const emails = await memberEmails(projectId);
if (seq !== ctxSeq) return;
openFollowerMenu(addFolBtn, emails, function () { return addFollowers; }, function (em, on) {
addFollowers = on ? addFollowers.concat([em]) : addFollowers.filter(function (x) { return x !== em; });
paintAddFol();
return true;
});
});
const addDue = el("pj-subtask-add-due");
enhanceDateInput(addDue, { placeholder: "마감일" }); // 아사나식 날짜 팝업
const addBtn = el("pj-subtask-add");
@@ -8207,10 +8364,8 @@
const f = sub.followers;
folEl.hidden = false;
folEl.className = "pj-subtask-fol" + (f.length ? "" : " is-empty");
folEl.innerHTML = f.length
? personIconHtml(f[0]) + (f.length > 1 ? '<span class="pj-subtask-fol-n">+' + (f.length - 1) + "</span>" : "")
: FOLLOWER_EMPTY_ICON_SVG;
folEl.title = f.length ? "협업자: " + f.map(idOf).join(", ") : "협업자 지정";
folEl.innerHTML = followerIconHtml(f);
folEl.title = followerTip(f);
}
renderCheck(); renderDue(); renderAv(); renderFol();
@@ -8267,26 +8422,13 @@
// 협업자 — 누르면 멤버 목록(협업자는 ✓). 고르면 넣고/빼고, 메뉴를 다시 열어 여러 명 지정.
folEl.addEventListener("click", function (e) {
e.stopPropagation();
const r = folEl.getBoundingClientRect();
const cur = (sub.followers || []).map(function (x) { return String(x).toLowerCase(); });
const cands = emails.slice();
cur.forEach(function (x) { if (cands.map(function (c) { return String(c).toLowerCase(); }).indexOf(x) < 0) cands.push(x); });
if (!cands.length) { showToast("지정할 수 있는 멤버가 없습니다."); return; }
showContextMenu(r.left, r.bottom + 4, cands.map(function (em) {
const on = cur.indexOf(String(em).toLowerCase()) >= 0;
return {
label: idOf(em), icon: personIconHtml(em), checked: on,
onClick: async function () {
try {
const res = on
? await api("DELETE", "/project/api/tasks/" + sub.id + "/followers/" + encodeURIComponent(em))
: await api("POST", "/project/api/tasks/" + sub.id + "/followers", { email: em });
sub.followers = res.followers || [];
renderFol();
} catch (err) { showToast("협업자 변경 실패: " + err.message, "error"); }
},
};
}), { label: "협업자 지정" });
openFollowerMenu(folEl, emails, function () { return sub.followers; }, async function (em, on) {
try {
sub.followers = (await setTaskFollower(sub.id, em, on)) || [];
renderFol();
return true;
} catch (err) { showToast("협업자 변경 실패: " + err.message, "error"); return false; }
});
});
function open() { if (onOpen) onOpen(sub); }
li.querySelector(".pj-subtask-open").addEventListener("click", function (e) { e.stopPropagation(); open(); });
@@ -8405,11 +8547,21 @@
assignee_email: addAssignee ? addAssignee.value : "",
assignee_name: assigneeOpt ? assigneeOpt.textContent : "",
due_date: addDue ? (addDue.value || null) : null,
followers: addFollowers,
});
if (seq !== ctxSeq) return; // 다른 작업 창으로 바뀌었다 — 그 창의 목록·입력칸은 건드리지 않는다
input.value = "";
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;
}
addFollowers = []; paintAddFol();
const emails = await memberEmails(pid);
if (seq !== ctxSeq) return;
const empty = listEl.querySelector(".pj-empty-sm");
@@ -8437,6 +8589,7 @@
if (input) input.value = "";
if (addAssignee) addAssignee.value = "";
if (addDue) addDue.value = "";
addFollowers = []; paintAddFol();
},
setContext: function (opts) {
const seq = ++ctxSeq;
+2
View File
@@ -343,5 +343,7 @@
{# 긴급 공지 — erp_base 를 쓰지 않는 화면도 같이(app/modules/notice) #}
<link rel="stylesheet" href="/static/erp-notice.css?v=20261012c" />
<script src="/static/erp-notice.js?v=20261012a" defer></script>
<link rel="stylesheet" href="/static/erp-overdue.css?v=20261013a" />
<script src="/static/erp-overdue.js?v=20261013a" defer></script>
</body>
</html>
+3
View File
@@ -9,6 +9,7 @@
<link rel="stylesheet" href="/static/erp-attach-viewer.css" />
<link rel="stylesheet" href="/static/erp-dialog.css?v=20260930a" />
<link rel="stylesheet" href="/static/erp-notice.css?v=20261012c" />
<link rel="stylesheet" href="/static/erp-overdue.css?v=20261013a" />
{% block head_extra %}{% endblock %}
</head>
<body class="erp-body erp-app-body">
@@ -192,6 +193,8 @@
<script src="/static/erp-attach-viewer.js" defer></script>
{# 긴급 공지 — 로그인한 모든 화면 가운데(받는 사람이 [확인] 전까지). app/modules/notice #}
{% if user %}<script src="/static/erp-notice.js?v=20261012a" defer></script>{% endif %}
{# 마감 지난 내 업무 — 로그인한 모든 화면 위쪽(닫으면 1시간 뒤 다시). Project 권한이 없으면 조용히 멈춘다. #}
{% if user %}<script src="/static/erp-overdue.js?v=20261013a" defer></script>{% endif %}
{% block scripts %}{% endblock %}
</body>
</html>
+2
View File
@@ -170,5 +170,7 @@
{# 긴급 공지 — erp_base 를 쓰지 않는 화면도 같이(app/modules/notice) #}
<link rel="stylesheet" href="/static/erp-notice.css?v=20261012c" />
<script src="/static/erp-notice.js?v=20261012a" defer></script>
<link rel="stylesheet" href="/static/erp-overdue.css?v=20261013a" />
<script src="/static/erp-overdue.js?v=20261013a" defer></script>
</body>
</html>
+21
View File
@@ -1263,6 +1263,27 @@ Windows 트레이 프로그램 **DBX 알림**(`desktop/notifier/`, C# .NET Frame
- 검증: `tests/test_project_module.py::test_subtask_followers_and_reaction_alert`(실제 PG), `tests/js/project_ui.test.js`
([섹션 담당자]·[세부 업무 협업자]·[대시보드 담당자별] 패널 왼쪽·[전체 보기] 기본 대시보드).
## 6-17. 세부 업무 만들 때 협업자 · 카드 세부 업무 협업자 · 대시보드 프로젝트별 · 마감 지난 업무 위쪽 알림 (2026-10-13, 마이그레이션 없음)
- **만들 때 협업자** — `POST /api/projects/{id}/tasks` 에 `followers: [이메일]`(선택). `_check_followers` 가 협업자 추가 API 와 같은 기준
(`access.can_assign` — 그 프로젝트를 볼 수 있는 사람)으로 먼저 검사해 하나라도 안 되면 400(업무를 만들지 않음), 목록이 아니어도 400.
만든 뒤 자동 협업자(만든 사람·담당자)와 함께 `_follow`. 화면:
· 업무 창 세부 업무 추가 칸 — 담당자 오른쪽 **[협업자 없음 / 협업자 N명]** 버튼(`#pj-subtask-add-followers`), [추가] 뒤·다른 업무를 열면 비움.
· 보드 카드 "+ 세부 업무 추가" 새 줄 — 담당자 오른쪽 협업자 아이콘(`.pj-card-subnew-fol`, 초안 `followers`). 협업자만 고른 줄은 바깥 클릭으로 닫히지 않는다.
- **이미 있는 세부 업무** — 업무 창 줄(`.pj-subtask-fol`, 6-16)은 비어 있어도 늘 옅게 보이게(예전엔 마우스를 올릴 때만), 보드 카드 펼친 세부 업무 줄에도
협업자 아이콘(`.pj-card-sub-fol`, 편집 권한자, 비어 있으면 줄 hover 때만). 셋 다 공용 `openFollowerMenu`(멤버 메뉴, 협업자 ✓, 고를 때마다
같은 자리에 다시 열려 여러 명) · `followerIconHtml` · `setTaskFollower`.
- **대시보드 업무 합계(프로젝트별)** — 완료 상태별 카드 바로 왼쪽(`dashProjectBars`). 지금 범위의 메인 업무를 원 소속 프로젝트별로 묶어
색 점·이름·가로 막대(채움 = 완료율)·완료/전체 · %, 업무 많은 순, 줄을 누르면 그 프로젝트(`/project/p/{id}`). 넘치면 카드 안 세로 스크롤.
- **마감 지난 내 업무 알림** — `static/erp-overdue.js`·`erp-overdue.css`, ERP 모든 화면(`erp_base.html`·`main.html`·`admin.html`) 위쪽 가운데
(body 에 붙음, z 5500 — 긴급 공지 6000 아래). `GET /project/api/my-overdue` = 내가 담당인 미완료 업무(세부 포함) 중 마감일 < 오늘(KST),
지금 볼 수 있는 것만(`access.filter_visible_tasks`), 마감 오래된 순 최대 200건(`db.list_my_overdue`). 알림은 최대 5줄 + "그 밖에 N건 — 내 업무에서 보기",
줄 = `/project/t/{id}`(마감 M/D · N일 지남). **[닫기 (1시간 뒤 다시)]** = localStorage `erp_overdue_snooze`({until, ids}) — 이 브라우저 모든 탭이
1시간 쉬고, 닫을 때 없던 업무가 새로 마감을 넘기면 바로 다시 띄운다. 5분마다·창을 다시 볼 때 확인, 다 완료하면 사라짐.
401·403(Project 권한 없음)·404·503 이면 조용히 멈춤, iframe 안에서는 안 돈다. 새 환경변수·DB 변경 없음.
- 검증: `tests/test_project_module.py::test_create_with_followers_and_my_overdue`(실제 PG), `tests/js/project_ui.test.js`
([세부 추가 협업자]·[카드 세부 협업자]·[카드 새 세부 협업자]·[대시보드 프로젝트별]), `tests/js/overdue_ui.test.js`.
## 7. 추후 단계
작업 라벨(태그 분류) · 반복 작업 · 템플릿 · 작업 의존성.
+8
View File
@@ -14,6 +14,14 @@ node tests/js/box_calc_ui.test.js
성공하면 마지막 줄에 `ALL PASS`, 실패하면 실패한 항목명이 출력되고 종료코드 1.
# 마감 지난 내 업무 알림 테스트 (jsdom)
`static/erp-overdue.js` — 위쪽 알림·최대 5줄·닫으면 1시간 쉼·새로 지난 업무는 바로·다 완료하면 사라짐·권한 없으면(403) 멈춤.
```bash
node tests/js/overdue_ui.test.js # jsdom 필요(npm install jsdom 또는 NODE_PATH)
```
# 연간 목표·주간 회의록 UI 테스트 (jsdom)
`goals.html`·`goal_meeting.html` + `static/project.js` — 칸 저장 직렬화·늦은 응답·503·초안 보호·구조 변경 중단·이번주 실적 %·
+74
View File
@@ -0,0 +1,74 @@
// 마감 지난 내 업무 알림(static/erp-overdue.js) — jsdom. 위쪽 알림·닫으면 1시간 쉼·새로 지난 업무는 바로·권한 없으면 멈춤.
// NODE_PATH=<jsdom 경로> node tests/js/overdue_ui.test.js
const fs = require("fs"), path = require("path");
const { JSDOM } = require("jsdom");
const JS = fs.readFileSync(path.join(__dirname, "..", "..", "app", "static", "erp-overdue.js"), "utf8");
const fails = [];
function check(name, cond, extra) {
if (cond) console.log("PASS " + name);
else { console.log("FAIL " + name + (extra !== undefined ? " → " + JSON.stringify(extra) : "")); fails.push(name); }
}
const settle = function () { return new Promise(function (r) { let i = 0; (function s() { if (i++ > 30) return r(); setImmediate(s); })(); }); };
function env(opts) {
const dom = new JSDOM("<!doctype html><body><main>화면</main></body>", { runScripts: "dangerously", pretendToBeVisual: true, url: "http://localhost/cupang/" });
const w = dom.window;
w.__ERP_OVERDUE_TEST__ = true;
const e = { w: w, d: w.document, calls: 0, tasks: opts.tasks || [], status: opts.status || 200 };
if (opts.now) { const base = opts.now; w.Date.now = function () { return base + (e.shift || 0); }; }
w.fetch = async function (url) {
e.calls++;
if (url !== "/project/api/my-overdue") return { ok: false, status: 404, json: async function () { return {}; } };
if (e.status >= 400) return { ok: false, status: e.status, json: async function () { return {}; } };
return { ok: true, status: 200, json: async function () { return { today: "2026-10-13", tasks: e.tasks }; } };
};
w.eval(JS);
return e;
}
const T = function (id, title, due, extra) {
return Object.assign({ id: id, title: title, due_date: due, project_id: 1, project_name: "P1", project_color: "#4573d2" }, extra || {});
};
(async function () {
{
const many = [T(1, "보고서", "2026-10-10"), T(2, "세부<b>", "2026-10-12", { parent_title: "상위" })]
.concat([3, 4, 5, 6, 7].map(function (i) { return T(i, "업무 " + i, "2026-10-11"); }));
const e = env({ tasks: many, now: Date.UTC(2026, 9, 13, 3) });
await settle();
const box = e.d.querySelector(".erp-overdue");
check("[마감 알림] 마감 지난 업무가 있으면 body 에 위쪽 알림(배율 밖)", !!box && box.parentElement === e.d.body && !box.hidden);
check("[마감 알림] 건수·최대 5줄·나머지 '내 업무에서 보기'", /마감이 지난 내 업무 7건/.test(box.textContent) &&
box.querySelectorAll(".erp-overdue-item").length === 5 && /그 밖에 2건/.test(box.querySelector(".erp-overdue-more").textContent));
const first = box.querySelector(".erp-overdue-item");
check("[마감 알림] 줄 = 업무 링크·마감일·며칠 지남", first.getAttribute("href") === "/project/t/1" && /마감 10\/10 · 3일 지남/.test(first.textContent));
check("[마감 알림] 제목은 글자로(HTML 아님)·상위 업무 표시", !box.querySelector(".erp-overdue-item b b") && /상위: 상위/.test(box.textContent));
box.querySelector("[data-overdue-close]").click(); await settle();
check("[마감 알림] 닫기 → 숨김·1시간 쉼 기록", box.hidden && JSON.parse(e.w.localStorage.getItem("erp_overdue_snooze")).ids.length === 7);
await e.w.__erpOverdue.poll(); await settle();
check("[마감 알림] 1시간 안 다시 확인 — 같은 업무면 안 띄움", box.hidden);
e.tasks = many.concat([T(8, "새로 지남", "2026-10-12")]);
await e.w.__erpOverdue.poll(); await settle();
check("[마감 알림] 새로 마감이 지난 업무가 생기면 바로 다시", !box.hidden && /8건/.test(box.textContent));
box.querySelector("[data-overdue-close]").click(); await settle();
e.shift = 60 * 60 * 1000 + 5;
await e.w.__erpOverdue.poll(); await settle();
check("[마감 알림] 1시간이 지나면 다시 나타남", !box.hidden);
e.tasks = [];
await e.w.__erpOverdue.poll(); await settle();
check("[마감 알림] 다 완료하면 사라짐", box.hidden);
}
{
const e = env({ tasks: [T(1, "x", "2026-10-10")], status: 403 });
await settle();
const n = e.calls;
await e.w.__erpOverdue.poll(); await settle();
check("[마감 알림] Project 권한 없음(403) — 창 없이 멈춤", !e.d.querySelector(".erp-overdue") && e.calls === n && e.w.__erpOverdue.state().stopped);
}
{
const e = env({ tasks: [] });
await settle();
check("[마감 알림] 지난 업무 없으면 창 없음", !e.d.querySelector(".erp-overdue"));
}
console.log(fails.length ? "\nFAILED: " + fails.join(", ") : "\nALL PASS");
process.exit(fails.length ? 1 : 0);
})().catch(function (err) { console.error(err); process.exit(1); });
+62
View File
@@ -770,6 +770,68 @@ function titleVal(d) { return d.getElementById("pj-t-title").value; }
fp.click(); await settle();
check("[세부 업무 협업자] 고르면 그 세부 업무 협업자 POST·아이콘 갱신", folPosts.length === 1 && folPosts[0].email === "me@test.local" &&
!fol.classList.contains("is-empty"), [folPosts, fol.className]);
check("[세부 업무 협업자] 고른 뒤 메뉴가 다시 열려 이어서 고름", !!d.querySelector(".pj-ctxmenu"));
d.dispatchEvent(new env.w.KeyboardEvent("keydown", { key: "Escape", bubbles: true })); await settle();
}
// ── 세부 업무를 만들 때 협업자 같이(업무 창 추가 칸·보드 카드 새 줄) · 카드 기존 줄 협업자 · 대시보드 프로젝트별(2026-10-13) ──
{
const env = makeEnv(); baseRoutes(env);
const posts = [], folPosts = [];
env.route("GET", /\/project\/api\/tasks\/101$/, function () {
return { body: { task: detail(101, "작업 A", { subtasks: [{ id: 911, title: "카드 세부", project_id: 1, parent_task_id: 101, followers: [] }] }) } };
});
env.route("POST", /\/project\/api\/projects\/1\/tasks$/, function (u, b) {
posts.push(b); return { body: { task: detail(960 + posts.length, b.title, { parent_task_id: b.parent_task_id }) } };
});
env.route("POST", /\/project\/api\/tasks\/911\/followers$/, function (u, b) { folPosts.push(b); return { body: { followers: [b.email] } }; });
const P = await boot(env); const d = env.d, w = env.w;
const pickMe = async function () {
const b = Array.from(d.querySelectorAll(".pj-ctxmenu-item")).find(function (x) { return /me/i.test(x.textContent); });
if (b) b.click();
await settle();
d.dispatchEvent(new w.KeyboardEvent("keydown", { key: "Escape", bubbles: true })); await settle();
return !!b;
};
// 업무 창 추가 칸
await P.openTaskModal(taskOf(P, 101)); await settle();
const addFol = d.getElementById("pj-subtask-add-followers");
check("[세부 추가 협업자] 업무 창 추가 칸에 협업자 버튼(담당자 오른쪽)", !!addFol && /협업자 없음/.test(addFol.textContent));
addFol.click(); await settle();
check("[세부 추가 협업자] 멤버 메뉴에서 고름", await pickMe());
check("[세부 추가 협업자] 버튼에 협업자 1명", /협업자 1명/.test(addFol.textContent), addFol.textContent);
d.getElementById("pj-subtask-input").value = "새 세부";
d.getElementById("pj-subtask-add").click(); await settle(); await settle();
check("[세부 추가 협업자] [추가] 요청에 followers, 끝나면 칸 비움",
posts.length === 1 && JSON.stringify(posts[0].followers) === '["me@test.local"]' && /협업자 없음/.test(addFol.textContent), [posts, addFol.textContent]);
d.querySelector("#pj-modal-task [data-close]") && d.querySelector("#pj-modal-task [data-close]").click();
await wait(400); await settle();
// 보드 카드 — 기존 세부 업무 줄 협업자 + 새 줄 협업자
d.querySelector('.pj-tab[data-view="board"]').click(); await settle();
d.querySelector('.pj-card[data-task-id="101"] .pj-card-subtoggle').click(); await settle(); await settle();
const cardFol = d.querySelector('.pj-card[data-task-id="101"] .pj-card-sub[data-sub-id="911"] .pj-card-sub-fol');
check("[카드 세부 협업자] 기존 줄 담당자 오른쪽 협업자 아이콘", !!cardFol && cardFol.classList.contains("is-empty"));
cardFol.click(); await settle(); await pickMe();
check("[카드 세부 협업자] 고르면 POST·아이콘 갱신", folPosts.length === 1 && folPosts[0].email === "me@test.local" && !cardFol.classList.contains("is-empty"), folPosts);
d.querySelector('.pj-card[data-task-id="101"] .pj-card-subadd').click(); await settle();
const nf = d.querySelector('.pj-card[data-task-id="101"] .pj-card-subnew-fol');
check("[카드 새 세부 협업자] 새 줄에 협업자 아이콘", !!nf);
nf.click(); await settle(); await pickMe();
const ni = d.querySelector('.pj-card[data-task-id="101"] .pj-card-subnew-title');
ni.value = "카드 새 세부"; ni.dispatchEvent(new w.Event("input", { bubbles: true }));
ni.dispatchEvent(new w.KeyboardEvent("keydown", { key: "Enter", bubbles: true })); await settle(); await settle();
const last = posts[posts.length - 1];
check("[카드 새 세부 협업자] Enter → 요청에 followers", posts.length === 2 && last.title === "카드 새 세부" &&
JSON.stringify(last.followers) === '["me@test.local"]', posts);
// 대시보드 — 업무 합계(프로젝트별) 카드, 완료 상태별 카드 바로 왼쪽
P.state().tasks.forEach(function (t) { if (t.id === 101) t.completed_at = "2026-09-29T10:00:00+09:00"; });
d.querySelector('.pj-tab[data-view="dashboard"]').click(); await settle();
const titles = Array.from(d.querySelectorAll("#pj-dash .pj-dash-card-title")).map(function (n) { return n.textContent; });
const pi = titles.indexOf("업무 합계(프로젝트별)");
check("[대시보드 프로젝트별] 카드가 완료 상태별 바로 왼쪽", pi >= 0 && titles[pi + 1] === "업무 합계(완료 상태별)", titles);
const prow = Array.from(d.querySelectorAll("#pj-dash .pj-dash-projrow")).map(function (r) {
return r.querySelector(".pj-dash-projname").textContent + "|" + r.querySelector(".pj-dash-projval").textContent;
});
check("[대시보드 프로젝트별] 프로젝트마다 완료/전체·%", prow.length >= 1 && /\|1\/2 · 50%$/.test(prow[0]), prow);
}
// ── 나를 태그·작업 배정 알림 팝업 — 본 것 이후 새 알림만, 깜박이는 팝업, 닫기 전까지 유지 ──
{
+31
View File
@@ -1387,6 +1387,37 @@ def test_subtask_followers_and_reaction_alert():
assert _count(q, ALICE, t["id"]) == 1
def test_create_with_followers_and_my_overdue():
"""세부 업무를 만들 때 협업자 같이 등록(비멤버면 400, 아무것도 안 만듦) + 마감 지난 내 업무 API(2026-10-13)."""
p = _project("P-crfol", ADMIN, (ALICE, BOB))
s = _stage(p["id"], by=ADMIN)
t = ST.create_task(project_id=p["id"], title="부모", stage_id=s["id"], created_by=ALICE)
url = f"/project/api/projects/{p['id']}/tasks"
r = req("POST", url, ALICE, json={"title": "세부-협업", "parent_task_id": t["id"], "followers": [BOB, BOB.upper()]})
assert r.status_code == 201
assert sorted(ST.list_followers(task_id=r.json()["task"]["id"])) == sorted([ALICE, BOB])
n_before = _count("SELECT COUNT(*) AS n FROM tasks WHERE parent_task_id=%s", t["id"])
assert req("POST", url, ALICE, json={"title": "x", "parent_task_id": t["id"], "followers": [DAVE]}).status_code == 400
assert req("POST", url, ALICE, json={"title": "x", "parent_task_id": t["id"], "followers": "bob"}).status_code == 400
assert _count("SELECT COUNT(*) AS n FROM tasks WHERE parent_task_id=%s", t["id"]) == n_before
# 마감 지난 내 업무 — 어제 마감 미완료(세부 포함)만, 오늘·완료·남의 업무·볼 수 없게 된 업무는 빠짐
y = (today_kst() - timedelta(days=1)).isoformat()
old = ST.create_task(project_id=p["id"], title="지난-메인", stage_id=s["id"], assignee_email=BOB, due_date=y, created_by=ALICE)
sub = ST.create_task(project_id=p["id"], title="지난-세부", parent_task_id=t["id"], assignee_email=BOB, due_date=y, created_by=ALICE)
ST.create_task(project_id=p["id"], title="오늘", stage_id=s["id"], assignee_email=BOB, due_date=today_kst().isoformat(), created_by=ALICE)
done = ST.create_task(project_id=p["id"], title="끝난", stage_id=s["id"], assignee_email=BOB, due_date=y, created_by=ALICE)
ST.update_task(task_id=done["id"], fields={"completed": True}, actor=ALICE)
ST.create_task(project_id=p["id"], title="남의", stage_id=s["id"], assignee_email=ALICE, due_date=y, created_by=ALICE)
got = req("GET", "/project/api/my-overdue", BOB).json()
mine = {x["id"]: x for x in got["tasks"] if x["project_id"] == p["id"]}
assert set(mine) == {old["id"], sub["id"]}, mine
assert mine[sub["id"]]["parent_title"] == "부모" and got["today"] == today_kst().isoformat()
assert req("GET", "/project/api/my-overdue", EVE).status_code == 403 # Project 권한 없음 → 화면 알림은 조용히 멈춤
ST.remove_member(project_id=p["id"], user_email=BOB)
assert not [x for x in req("GET", "/project/api/my-overdue", BOB).json()["tasks"] if x["project_id"] == p["id"]]
if __name__ == "__main__":
if not ENABLED:
print("SKIP: PROJECT_TEST_DB_URL(localhost) not set")