feat(project): 실시간 저장·댓글 답글/반응·완료 이력·수신함 오른쪽 작업 창·화면 배율 토글

- 작업 창 저장 버튼 제거 → 칸별 실시간 저장(새 작업은 제목 입력 시 생성)
- 댓글 답글·이모티콘 반응(마이그레이션 012), @태그 아이콘+이름 칩, 이모티콘 선택기
- 작업 완료 시 댓글 사이에 "OO 님이 이 작업을 완료했습니다" 이력 표시
- 수신함 "확인" → 페이지 이동 없이 오른쪽 패널(iframe embed)에 작업 창
- 프로젝트 제목 클릭 수정, 긴 작업 제목 자동 줄바꿈
- 상단 바 화면 배율 토글(2880x1620·200%용, .erp-app zoom .75)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-09-28 18:11:34 +09:00
parent 3882dd7ad3
commit 4fb8b37d9c
13 changed files with 1337 additions and 144 deletions
+113 -11
View File
@@ -832,7 +832,7 @@ class ProjectStore:
# task_mentions·task_attachments 의 comment_id 가 댓글을 가리키므로 댓글 먼저.
# 알림(project_notifications)은 되살리면 수신함에 옛 알림이 다시 쌓여 제외.
TRASH_CHILD_TABLES = (
"task_comments", "task_followers", "task_mentions", "task_attachments",
"task_comments", "task_comment_reactions", "task_followers", "task_mentions", "task_attachments",
"task_project_links", "project_activity", "task_reminders",
)
@@ -1087,15 +1087,94 @@ class ProjectStore:
# ════════════════════════════════════════════════════════════
# 댓글 (task_comments)
# ════════════════════════════════════════════════════════════
def comment_features(self) -> dict[str, bool]:
"""답글(parent_id)·반응 테이블이 있는지(마이그레이션 012). 한 번 켜지면 기억."""
cached = getattr(self, "_comment_features", None)
if cached and cached["replies"] and cached["reactions"]:
return cached
with self._pool.connection() as conn:
col = conn.execute(
"SELECT 1 FROM information_schema.columns WHERE table_schema = 'public' "
"AND table_name = 'task_comments' AND column_name = 'parent_id'"
).fetchone()
feats = {
"replies": bool(col),
"reactions": self._table_exists(conn, "task_comment_reactions"),
}
self._comment_features = feats
return feats
def list_comments(self, *, task_id: int) -> list[dict[str, Any]]:
"""댓글(작성순). 012 가 있으면 각 댓글에 reactions=[{emoji, users}] 를 붙인다."""
feats = self.comment_features()
with self._pool.connection() as conn:
rows = conn.execute(
"SELECT * FROM task_comments WHERE task_id = %s "
"ORDER BY created_at ASC, id ASC",
(task_id,),
).fetchall()
reacts: list[dict[str, Any]] = []
if feats["reactions"]:
reacts = conn.execute(
"SELECT comment_id, emoji, array_agg(user_email ORDER BY created_at) AS users "
"FROM task_comment_reactions WHERE task_id = %s "
"GROUP BY comment_id, emoji ORDER BY MIN(created_at)",
(task_id,),
).fetchall()
by_comment: dict[int, list[dict[str, Any]]] = {}
for r in reacts:
by_comment.setdefault(int(r["comment_id"]), []).append(
{"emoji": r["emoji"], "users": list(r["users"] or [])}
)
out = []
for r in rows:
c = self._serialize(r)
c.setdefault("parent_id", None)
c["reactions"] = by_comment.get(int(c["id"]), [])
out.append(c)
return out
def list_completion_events(self, *, task_id: int) -> list[dict[str, Any]]:
"""이 작업의 '완료' 이력 — 댓글 목록에 "OO 님이 이 작업을 완료했습니다"로 끼워 보인다."""
with self._pool.connection() as conn:
rows = conn.execute(
"SELECT actor_email, created_at FROM project_activity "
"WHERE task_id = %s AND action = %s ORDER BY created_at ASC, id ASC",
(task_id, store.ACTION_COMPLETED),
).fetchall()
return [self._serialize(r) for r in rows]
def toggle_reaction(
self, *, comment_id: int, user_email: str, emoji: str
) -> list[dict[str, Any]]:
"""반응 켜기/끄기 → 그 댓글의 반응 목록. 댓글이 없으면 KeyError."""
email = store.norm_str(user_email, lower=True)
with self._pool.connection() as conn:
with conn.transaction():
c = conn.execute(
"SELECT task_id FROM task_comments WHERE id = %s", (comment_id,)
).fetchone()
if not c:
raise KeyError(comment_id)
gone = conn.execute(
"DELETE FROM task_comment_reactions "
"WHERE comment_id = %s AND user_email = %s AND emoji = %s RETURNING 1",
(comment_id, email, emoji),
).fetchone()
if not gone:
conn.execute(
"INSERT INTO task_comment_reactions (comment_id, task_id, user_email, emoji) "
"VALUES (%s,%s,%s,%s) ON CONFLICT DO NOTHING",
(comment_id, c["task_id"], email, emoji),
)
rows = conn.execute(
"SELECT emoji, array_agg(user_email ORDER BY created_at) AS users "
"FROM task_comment_reactions WHERE comment_id = %s "
"GROUP BY emoji ORDER BY MIN(created_at)",
(comment_id,),
).fetchall()
return [{"emoji": r["emoji"], "users": list(r["users"] or [])} for r in rows]
def get_comment(self, *, comment_id: int) -> dict[str, Any] | None:
with self._pool.connection() as conn:
row = conn.execute(
@@ -1105,20 +1184,37 @@ class ProjectStore:
def add_comment(
self, *, task_id: int, author_email: str, author_name: str, body: str,
allow_empty: bool = False,
allow_empty: bool = False, parent_id: int | None = None,
) -> dict[str, Any]:
"""allow_empty — 채팅 팝업에서 파일/이미지만 보내는 메시지(본문 없음)를
허용할 때 True. 일반 댓글 입력은 여전히 빈 값을 막는다."""
허용할 때 True. 일반 댓글 입력은 여전히 빈 값을 막는다.
parent_id — 답글(012). 같은 작업의 댓글이어야 하고, 답글에 단 답글은
원 댓글에 붙인다(한 단계). 없는 댓글이면 ValueError."""
text = store.norm_str(body)
if not text and not allow_empty:
raise ValueError("댓글 내용이 비었습니다.")
with self._pool.connection() as conn:
row = conn.execute(
"INSERT INTO task_comments (task_id, author_email, author_name, body) "
"VALUES (%s,%s,%s,%s) RETURNING *",
(task_id, store.norm_str(author_email, lower=True),
store.norm_str(author_name), text),
).fetchone()
if parent_id:
p = conn.execute(
"SELECT id, task_id, parent_id FROM task_comments WHERE id = %s", (parent_id,)
).fetchone()
if not p or int(p["task_id"]) != int(task_id):
raise ValueError("답글을 달 댓글을 찾을 수 없습니다.")
root = int(p["parent_id"] or p["id"])
row = conn.execute(
"INSERT INTO task_comments (task_id, author_email, author_name, body, parent_id) "
"VALUES (%s,%s,%s,%s,%s) RETURNING *",
(task_id, store.norm_str(author_email, lower=True),
store.norm_str(author_name), text, root),
).fetchone()
else:
row = conn.execute(
"INSERT INTO task_comments (task_id, author_email, author_name, body) "
"VALUES (%s,%s,%s,%s) RETURNING *",
(task_id, store.norm_str(author_email, lower=True),
store.norm_str(author_name), text),
).fetchone()
return self._serialize(row)
def update_comment(
@@ -1155,9 +1251,15 @@ class ProjectStore:
raise KeyError(comment_id)
if not is_admin and row["author_email"] != store.norm_str(requester, lower=True):
raise PermissionError("본인 댓글만 삭제할 수 있습니다.")
# 답글(012)도 CASCADE 로 같이 지워지므로 답글의 첨부 파일도 모은다.
reply_clause = (
" OR comment_id IN (SELECT id FROM task_comments WHERE parent_id = %s)"
if self.comment_features()["replies"] else ""
)
files = conn.execute(
"SELECT task_id, stored_name FROM task_attachments WHERE comment_id = %s",
(comment_id,),
"SELECT task_id, stored_name FROM task_attachments WHERE comment_id = %s"
+ reply_clause,
(comment_id, comment_id) if reply_clause else (comment_id,),
).fetchall()
conn.execute("DELETE FROM task_comments WHERE id = %s", (comment_id,))
return [dict(f) for f in files]