feat(project): 보드 가로 스크롤 · 카드 인라인 편집 · 내 업무 사이드 메뉴 · @태그
- 보드: 매이슨리 절대배치 제거 → 아사나식 flex 가로 배치. 세션이 늘어나면
아래로 접히지 않고 계속 오른쪽으로 이어지고, 보드가 가로로 스크롤된다
(막대는 attachHScrollIndicator 가 직접 그린다). 긴 세션은 컬럼 안에서 세로 스크롤.
- 카드: 담당자/마감일을 클릭하면 팝업을 열지 않고 그 자리에서 바꾼다.
값이 없는 칩은 카드 호버 시 흐리게 나타나 바로 지정할 수 있다.
- 내 업무: 화면 오른쪽 상시 패널을 없애고 좌측 사이드바의 접이식 메뉴로 이전
(기본 접힘, 업무를 고르면 팝업이 열리며 다시 접힘). 레이아웃 3열 → 2열.
- 설명란: 웹주소를 붙여넣으면 자동 링크(target=_blank), 클릭하면 새 탭으로 연다.
contenteditable 은 브라우저가 링크를 기본으로 열지 않아 클릭을 직접 받는다.
- @태그: 설명란·댓글에서 @ 로 멤버를 고른다. 설명란은 멘션 칩(data-email),
댓글은 화면이 고른 이메일을 함께 전송. 서버는 설명란의 경우 저장될 HTML 에서
직접 이메일을 뽑는다(화면이 보낸 목록을 믿지 않는다).
태그된 사람은 수신함(/project/inbox)에서 그 업무를 리스트로 본다.
DB: 마이그레이션 006(task_mentions) 신규 — 배포 시 적용 필요.
미적용 환경에서도 화면이 죽지 않게 멘션 조회/기록은 모두 감쌌다.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -36,7 +36,7 @@ Claude Code는 이 저장소에서 작업을 시작하기 전에 **반드시 아
|
||||
- 말레이시아 창고 재고관리 (`app/modules/malaysia/`, `malaysia_stock_db`) — 낱개(MT/MX/MZ) 입출고·조정, 세트(MY) BOM, 일일 재고조사(세트→낱개 자동 분해), 현재고 현황. 뚜껑(MD-)은 재고 집계 제외 — 단, 창고 랙에는 위치 확인용으로 배치 가능(`store.LID_ITEMS`). 상품은 `itemcode_db` 읽기 전용. 권한키 `malaysia`
|
||||
- 말레이시아 배송 (`app/modules/dispatch/`, `dispatch_db`) — TikTok·Shopee 출고관리. 플랫폼별 데이터 엑셀 업로드(TikTok=03_TikTok_Order_Export.xlsx, Shopee=Packing List.Doorstep Delivery.xlsx) → 1상자=1카드 출고 작업 리스트·SKU 피킹 요약·Kagayaku 전달표 자동 생성. 1상자 묶음 기준 Package ID > Tracking ID > Order ID, 같은 상자 같은 SKU 합산. 작업 상태 토글(`dispatch_logs` 기록). 받는 사람 이름/전화/주소는 상자 단위로 저장(작업 카드 표시 + 출고 엑셀 생성용 — 개인정보). 배치 다운로드 zip 에 업로드 원본 + 취합 출고 엑셀(`YYYY.MM.DD(Ddd)_tictoc|shopee.xlsx`) 포함. 엑셀은 openpyxl 파싱/생성. 권한키 `dispatch`. 상세는 `docs/DISPATCH_MODULE.md`
|
||||
- 카페24 상품관리 (`app/modules/cafe24/`, `cafe24_db`) — 카페24 관리자에 들어가지 않고 상품 상세페이지(description HTML) 조회·편집·즉시적용·예약적용·버전 이력. 3분할 화면(목록 | HTML 편집기 | 상품 정보 패널). 정보 패널(`routes_product_info.py`, `_side.html`)에서 상품명·판매가·공급가·소비자가, 대표이미지(업로드 → `POST /admin/products/images` → PUT `detail_image`+`image_upload_type=A`), 옵션(생성/이름·썸네일·표시방식 수정/삭제)·품목(자체코드·추가금액·진열·판매)을 수정. 카페24 OAuth/API 클라이언트는 향후 주문관리와 공유하기 위해 **공통 계층 `app/integrations/cafe24/`** 에 둔다 — 라우터에서 `httpx`/`requests` 직접 호출 금지. 토큰은 Fernet 암호화 저장(`CAFE24_TOKEN_SECRET`), 로그/화면에 토큰·시크릿 절대 미출력. 쓰기 직전 항상 카페24 현재 HTML 을 다시 읽어 `BACKUP` revision 생성(로컬 값을 현재값으로 가정 금지). **카페24 관리자 API 는 PUT 뒤 한동안 GET 에서 예전 값을 돌려준다(읽기 지연)** — 우리 캐시 문제가 아니다. 그래서 "마지막 쓰기가 권위": 상세설명은 카페24 값이 최근 revision 중 하나와 같으면 지연으로 보고 마지막 MANUAL/SCHEDULED 를 표시·지문 기준으로 쓰고(`store.resolve_description`), 스칼라(상품명·가격·이미지·진열/판매)는 PUT 응답 스냅샷(`cafe24_products.last_write_snapshot`, 마이그레이션 004)과 GET 의 `updated_date` 를 비교해 덮어씌운다(`store.overlay_recent_write`). 유예시간 `CAFE24_READ_LAG_GRACE_MIN`(기본 360분). 쓰기 후 화면은 PUT 응답으로 그리고 다시 GET 하지 않는다. 예약은 DB 저장 + 별도 worker(`app/modules/cafe24/worker.py`, compose 서비스 `dbx-cafe24-worker`)가 처리 — 웹 프로세스에서 대기하지 않는다. 권한키 `cafe24`(연결/해제는 admin 전용). 상세는 `docs/CAFE24_MODULE.md`
|
||||
- 프로젝트 관리 (`app/modules/project/`, `project_db`) — 아사나식. 프로젝트/서브프로젝트(self-FK `parent_id`, CASCADE)·업무(`tasks`: 담당자·우선순위·시작/마감)·진행단계(`project_stages` 칸반, 생성시 기본 4단계 seed)·멤버 배정(`project_members`)·활동이력(`project_activity`). 메인 뷰 달력(FullCalendar)/타임라인(vis-timeline) 버튼 토글 + 보드(드래그로 단계 이동)/리스트. 진입 권한키 `project`(관리자 페이지 토글로 직원별 부여, admin 자동). 프로젝트 생성/삭제·사용자 배정은 `is_admin` 만, 배정 멤버(또는 owner)는 서브프로젝트/업무/단계 CRUD. 멤버 배정 후보는 `project` 권한 보유 등록 사용자에서 자동 목록(`GET /project/api/assignable-users`). 업무 배정·완료 시 관리자에게 메일(`app/mail.py` stdlib smtplib, `SMTP_*`+`PROJECT_NOTIFY_EMAIL` env, 미설정 시 조용히 skip, `BackgroundTasks` 비동기). 상세는 `docs/PROJECT_MODULE.md`
|
||||
- 프로젝트 관리 (`app/modules/project/`, `project_db`) — 아사나식. 프로젝트/서브프로젝트(self-FK `parent_id`, CASCADE)·업무(`tasks`: 담당자·우선순위·시작/마감)·진행단계(`project_stages` 칸반, 생성시 기본 4단계 seed)·멤버 배정(`project_members`)·활동이력(`project_activity`). 메인 뷰 달력(FullCalendar)/타임라인(vis-timeline) 버튼 토글 + 보드/리스트. 보드는 아사나처럼 세션이 가로로 계속 늘어나고(넘치면 가로 스크롤) 카드의 담당자·마감일을 클릭해 그 자리에서 바꾼다. 좌측 사이드바에 수신함·내 업무(접이식) 메뉴. 설명란은 주소 붙여넣기 시 자동 링크, 설명란·댓글에서 @로 멤버를 태그하면 (`task_mentions`, 마이그레이션 006) 수신함에 그 업무가 쌓인다. 진입 권한키 `project`(관리자 페이지 토글로 직원별 부여, admin 자동). 프로젝트 생성/삭제·사용자 배정은 `is_admin` 만, 배정 멤버(또는 owner)는 서브프로젝트/업무/단계 CRUD. 멤버 배정 후보는 `project` 권한 보유 등록 사용자에서 자동 목록(`GET /project/api/assignable-users`). 업무 배정·완료 시 관리자에게 메일(`app/mail.py` stdlib smtplib, `SMTP_*`+`PROJECT_NOTIFY_EMAIL` env, 미설정 시 조용히 skip, `BackgroundTasks` 비동기). 상세는 `docs/PROJECT_MODULE.md`
|
||||
|
||||
상세는 `docs/PROJECT_OVERVIEW.md`.
|
||||
|
||||
|
||||
@@ -922,6 +922,90 @@ class ProjectStore:
|
||||
)
|
||||
return cur.rowcount or 0
|
||||
|
||||
# ════════════════════════════════════════════════════════════
|
||||
# 멘션(@태그) — task_mentions
|
||||
#
|
||||
# 설명란/댓글에서 @로 지정된 사람. 수신함의 "나를 태그한 업무" 목록이
|
||||
# 이걸 읽는다. 같은 자리(설명란=comment_id NULL, 또는 같은 댓글)에서 같은
|
||||
# 사람을 두 번 저장하지 않는다(마이그레이션 006 의 UNIQUE 인덱스).
|
||||
# ════════════════════════════════════════════════════════════
|
||||
def add_mentions(
|
||||
self, *, task_id: int, emails: list[str], actor_email: str = "",
|
||||
comment_id: int | None = None, source: str = "description",
|
||||
) -> list[str]:
|
||||
"""멘션을 기록하고 '이번에 새로 추가된' 이메일만 돌려준다(알림 대상)."""
|
||||
actor = store.norm_str(actor_email, lower=True)
|
||||
targets = [e for e in store.normalize_emails(emails) if e != actor]
|
||||
if not targets:
|
||||
return []
|
||||
added: list[str] = []
|
||||
with self._pool.connection() as conn:
|
||||
for email in targets:
|
||||
cur = conn.execute(
|
||||
"INSERT INTO task_mentions "
|
||||
"(task_id, comment_id, mentioned_email, actor_email, source) "
|
||||
"VALUES (%s,%s,%s,%s,%s) ON CONFLICT DO NOTHING",
|
||||
(task_id, comment_id, email, actor, source),
|
||||
)
|
||||
if cur.rowcount:
|
||||
added.append(email)
|
||||
return added
|
||||
|
||||
def list_mentioned_tasks(
|
||||
self, *, mentioned_email: str, limit: int = 100
|
||||
) -> list[dict[str, Any]]:
|
||||
"""내가 태그된 업무 목록(업무 1건당 1행, 가장 최근 태그 기준 정렬)."""
|
||||
email = store.norm_str(mentioned_email, lower=True)
|
||||
with self._pool.connection() as conn:
|
||||
rows = conn.execute(
|
||||
"""
|
||||
SELECT t.*, p.name AS project_name, p.color AS project_color,
|
||||
s.name AS stage_name,
|
||||
m.last_at AS mentioned_at,
|
||||
m.unread AS unread_mentions,
|
||||
m.last_actor AS mention_actor
|
||||
FROM (
|
||||
SELECT task_id,
|
||||
MAX(created_at) AS last_at,
|
||||
COUNT(*) FILTER (WHERE NOT is_read) AS unread,
|
||||
(ARRAY_AGG(actor_email ORDER BY created_at DESC))[1] AS last_actor
|
||||
FROM task_mentions
|
||||
WHERE mentioned_email = %s
|
||||
GROUP BY task_id
|
||||
) m
|
||||
JOIN tasks t ON t.id = m.task_id
|
||||
JOIN projects p ON p.id = t.project_id
|
||||
LEFT JOIN project_stages s ON s.id = t.stage_id
|
||||
ORDER BY m.last_at DESC
|
||||
LIMIT %s
|
||||
""",
|
||||
(email, int(limit)),
|
||||
).fetchall()
|
||||
return [self._serialize(r) for r in rows]
|
||||
|
||||
def count_unread_mentions(self, *, mentioned_email: str) -> int:
|
||||
with self._pool.connection() as conn:
|
||||
row = conn.execute(
|
||||
"SELECT COUNT(*) AS n FROM task_mentions "
|
||||
"WHERE mentioned_email = %s AND is_read = FALSE",
|
||||
(store.norm_str(mentioned_email, lower=True),),
|
||||
).fetchone()
|
||||
return int(row["n"] or 0)
|
||||
|
||||
def mark_mentions_read(
|
||||
self, *, mentioned_email: str, task_id: int | None = None
|
||||
) -> int:
|
||||
clause = "WHERE mentioned_email = %s AND is_read = FALSE"
|
||||
params: list[Any] = [store.norm_str(mentioned_email, lower=True)]
|
||||
if task_id is not None:
|
||||
clause += " AND task_id = %s"
|
||||
params.append(task_id)
|
||||
with self._pool.connection() as conn:
|
||||
cur = conn.execute(
|
||||
f"UPDATE task_mentions SET is_read = TRUE {clause}", params
|
||||
)
|
||||
return cur.rowcount or 0
|
||||
|
||||
# ════════════════════════════════════════════════════════════
|
||||
# 실시간 새로고침 — 프로젝트/업무/댓글/멤버/단계 중 가장 최근 변경 시각
|
||||
# ════════════════════════════════════════════════════════════
|
||||
@@ -933,7 +1017,8 @@ class ProjectStore:
|
||||
" COALESCE((SELECT MAX(updated_at) FROM tasks), 'epoch'::timestamptz),"
|
||||
" COALESCE((SELECT MAX(created_at) FROM task_comments), 'epoch'::timestamptz),"
|
||||
" COALESCE((SELECT MAX(created_at) FROM project_members), 'epoch'::timestamptz),"
|
||||
" COALESCE((SELECT MAX(created_at) FROM project_stages), 'epoch'::timestamptz)"
|
||||
" COALESCE((SELECT MAX(created_at) FROM project_stages), 'epoch'::timestamptz),"
|
||||
" COALESCE((SELECT MAX(created_at) FROM task_mentions), 'epoch'::timestamptz)"
|
||||
") AS ts"
|
||||
).fetchone()
|
||||
ts = row["ts"] if row else None
|
||||
|
||||
@@ -171,6 +171,37 @@ def _inbox(
|
||||
logger.warning("알림 생성 실패: %s", r)
|
||||
|
||||
|
||||
def _record_mentions(
|
||||
st: Any, *, task: dict[str, Any], emails: list[str], actor: str,
|
||||
comment_id: int | None = None, source: str = "description",
|
||||
project_name: str = "",
|
||||
) -> None:
|
||||
"""@태그를 기록하고 새로 태그된 사람에게만 알림을 만든다.
|
||||
|
||||
태그는 부가 기능이라 여기서 실패해도(예: 006 마이그레이션 미적용) 본
|
||||
저장/등록은 막지 않는다 — 로그만 남긴다.
|
||||
"""
|
||||
if not emails:
|
||||
return
|
||||
try:
|
||||
added = st.add_mentions(
|
||||
task_id=task["id"], emails=emails, actor_email=actor,
|
||||
comment_id=comment_id, source=source,
|
||||
)
|
||||
except Exception: # noqa: BLE001
|
||||
logger.warning("멘션 기록 실패: task=%s", task.get("id"))
|
||||
return
|
||||
if not added:
|
||||
return
|
||||
where = "댓글" if source == "comment" else "설명"
|
||||
_inbox(
|
||||
st, recipients=added, actor=actor,
|
||||
project_id=task["project_id"], task_id=task["id"], ntype="mention",
|
||||
title=f"나를 태그함: {task['title']}",
|
||||
body=f"{project_name or task.get('project_name') or ''} · {where}",
|
||||
)
|
||||
|
||||
|
||||
def _render_config_needed(request: Request, user: dict[str, Any]) -> HTMLResponse:
|
||||
from app.main import build_erp_nav, render_template # noqa: WPS433
|
||||
from app.store import is_admin # noqa: WPS433
|
||||
@@ -454,6 +485,8 @@ async def index(request: Request) -> HTMLResponse:
|
||||
t["due_label"] = _fmt_date_kr(t.get("due_date"))
|
||||
# 내 업무를 프로젝트별로 묶어 트리로 표시(전체/진행/완료 개수 포함)
|
||||
my_projects = _group_my_tasks(my_tasks)
|
||||
my_open_total = sum(g["open"] for g in my_projects)
|
||||
mention_unread = _safe_mention_unread(st, user["email"])
|
||||
|
||||
# 홈 화면 카드/내업무에 노출된 업무 전체(id→업무) — 클릭 시 페이지 이동 없이
|
||||
# 팝업으로 편집하기 위해 필요한 원본 데이터를 그대로 클라이언트에 넘긴다.
|
||||
@@ -610,6 +643,8 @@ async def project_page(request: Request, project_id: int) -> HTMLResponse:
|
||||
"current_project_id": project_id,
|
||||
"my_projects": my_projects,
|
||||
"my_tasks": my_tasks,
|
||||
"my_open_total": my_open_total,
|
||||
"mention_unread": mention_unread,
|
||||
"nav_projects": nav_projects,
|
||||
"stages": stages,
|
||||
"tasks": all_tasks,
|
||||
@@ -985,6 +1020,11 @@ async def api_create_task(
|
||||
title=f"업무 배정: {task['title']}",
|
||||
body=f"{project['name']} · 마감 {task.get('due_date') or '-'}",
|
||||
)
|
||||
_record_mentions(
|
||||
st, task=task,
|
||||
emails=store.extract_mentions_from_html(task.get("description") or ""),
|
||||
actor=user["email"], project_name=project["name"],
|
||||
)
|
||||
return JSONResponse({"task": task}, status_code=201)
|
||||
|
||||
|
||||
@@ -1053,6 +1093,12 @@ async def api_update_task(
|
||||
actor=user["email"], project_id=existing["project_id"], task_id=task_id,
|
||||
ntype="completed", title=f"업무 완료: {task['title']}", body=project_name,
|
||||
)
|
||||
if "description" in payload:
|
||||
_record_mentions(
|
||||
st, task=task,
|
||||
emails=store.extract_mentions_from_html(payload["description"]),
|
||||
actor=user["email"], project_name=project_name,
|
||||
)
|
||||
return JSONResponse({"task": task})
|
||||
|
||||
|
||||
@@ -1185,6 +1231,13 @@ async def api_add_comment(
|
||||
ntype="comment", title=f"새 댓글: {task['title']}",
|
||||
body=comment["body"][:120],
|
||||
)
|
||||
# 댓글은 평문이라 본문에서 이메일을 꺼낼 수 없다 — 화면이 고른 멤버
|
||||
# 목록을 그대로 받아 기록한다(설명란은 본문 HTML 에서 직접 뽑는다).
|
||||
_record_mentions(
|
||||
st, task=task, emails=store.normalize_emails(payload.get("mentions")),
|
||||
actor=user["email"], comment_id=comment["id"], source="comment",
|
||||
project_name=project.get("name", ""),
|
||||
)
|
||||
return JSONResponse({"comment": comment}, status_code=201)
|
||||
|
||||
|
||||
@@ -1433,6 +1486,62 @@ async def api_notif_read_all(request: Request) -> JSONResponse:
|
||||
return JSONResponse({"ok": True, "marked": n})
|
||||
|
||||
|
||||
# ────────────────────────────────────────────────────────────
|
||||
# 수신함 — 나를 @태그한 업무 (아사나 Inbox)
|
||||
# ────────────────────────────────────────────────────────────
|
||||
def _safe_mentions(st: Any, email: str, *, limit: int = 100) -> list[dict[str, Any]]:
|
||||
"""task_mentions 조회. 006 마이그레이션 미적용 환경에서도 화면이 죽지 않게."""
|
||||
try:
|
||||
return st.list_mentioned_tasks(mentioned_email=email, limit=limit)
|
||||
except Exception: # noqa: BLE001
|
||||
logger.warning("멘션 조회 실패 — project_db_006 마이그레이션 확인 필요")
|
||||
return []
|
||||
|
||||
|
||||
def _safe_mention_unread(st: Any, email: str) -> int:
|
||||
try:
|
||||
return st.count_unread_mentions(mentioned_email=email)
|
||||
except Exception: # noqa: BLE001
|
||||
return 0
|
||||
|
||||
|
||||
@router.get("/api/mentions")
|
||||
async def api_mentions(request: Request) -> JSONResponse:
|
||||
"""나를 태그한 업무 목록 + 미확인 개수."""
|
||||
user = _require_user(request)
|
||||
st = _db_or_503(request)
|
||||
tasks = _safe_mentions(st, user["email"])
|
||||
return JSONResponse({
|
||||
"tasks": tasks,
|
||||
"unread": _safe_mention_unread(st, user["email"]),
|
||||
})
|
||||
|
||||
|
||||
@router.get("/api/mentions/unread-count")
|
||||
async def api_mentions_unread(request: Request) -> JSONResponse:
|
||||
user = _require_user(request)
|
||||
st = _db_or_503(request)
|
||||
return JSONResponse({"unread": _safe_mention_unread(st, user["email"])})
|
||||
|
||||
|
||||
@router.post("/api/mentions/read")
|
||||
async def api_mentions_read(
|
||||
request: Request, payload: dict[str, Any] = Body(default={})
|
||||
) -> JSONResponse:
|
||||
"""태그 확인 처리. task_id 를 주면 그 업무만, 없으면 전부."""
|
||||
user = _require_user(request)
|
||||
st = _db_or_503(request)
|
||||
task_id = payload.get("task_id")
|
||||
try:
|
||||
n = st.mark_mentions_read(
|
||||
mentioned_email=user["email"],
|
||||
task_id=int(task_id) if task_id else None,
|
||||
)
|
||||
except Exception: # noqa: BLE001
|
||||
n = 0
|
||||
return JSONResponse({"ok": True, "marked": n})
|
||||
|
||||
|
||||
@router.get("/inbox", response_class=HTMLResponse)
|
||||
async def inbox_page(request: Request) -> HTMLResponse:
|
||||
from app.main import build_erp_nav, render_template # noqa: WPS433
|
||||
@@ -1443,6 +1552,9 @@ async def inbox_page(request: Request) -> HTMLResponse:
|
||||
if st is None:
|
||||
return _render_config_needed(request, user)
|
||||
items = st.list_notifications(recipient_email=user["email"], limit=100)
|
||||
mentioned = _safe_mentions(st, user["email"])
|
||||
for t in mentioned:
|
||||
t["due_label"] = _fmt_date_kr(t.get("due_date"))
|
||||
return render_template(
|
||||
request,
|
||||
"project/inbox.html",
|
||||
@@ -1450,9 +1562,11 @@ async def inbox_page(request: Request) -> HTMLResponse:
|
||||
"user": user,
|
||||
"is_admin": is_admin(user),
|
||||
"nav_items": build_erp_nav(user, active="project"),
|
||||
"page_title": "알림센터",
|
||||
"page_subtitle": "내게 온 프로젝트 알림",
|
||||
"page_title": "수신함",
|
||||
"page_subtitle": "나를 태그한 업무와 프로젝트 알림",
|
||||
"force_sidebar_collapsed": True,
|
||||
"notifications": items,
|
||||
"mentioned_tasks": mentioned,
|
||||
"mention_unread": _safe_mention_unread(st, user["email"]),
|
||||
},
|
||||
)
|
||||
|
||||
@@ -262,11 +262,17 @@ _DESC_ALLOWED_TAGS: frozenset[str] = frozenset({
|
||||
"ul", "ol", "li", "blockquote", "code", "pre", "span", "div",
|
||||
})
|
||||
_DESC_VOID_TAGS: frozenset[str] = frozenset({"br", "img"})
|
||||
# a: target/rel 은 "새 탭에서 열기"용. 화면(설명란)에서 링크를 클릭하면
|
||||
# 새 탭으로 여는데, 저장했다 다시 열었을 때도 같은 동작이어야 해서 허용한다.
|
||||
# span: 멘션 칩(@이름) 전용 — class="pj-mention" + data-email 만 남긴다.
|
||||
_DESC_ALLOWED_ATTRS: dict[str, frozenset[str]] = {
|
||||
"a": frozenset({"href"}),
|
||||
"a": frozenset({"href", "target", "rel"}),
|
||||
"img": frozenset({"src", "alt", "width", "height"}),
|
||||
"span": frozenset({"class", "data-email"}),
|
||||
}
|
||||
_DESC_DANGEROUS_URL_PREFIXES: tuple[str, ...] = ("javascript:", "vbscript:", "data:text/html")
|
||||
# 멘션 칩: <span class="pj-mention" data-email="...">@이름</span>
|
||||
_MENTION_CLASS = "pj-mention"
|
||||
# script/style 은 태그 자체는 물론 그 안의 텍스트(코드)도 통째로 버린다 —
|
||||
# 허용 태그 목록에 없어 태그는 이미 안 남지만, HTMLParser는 이 둘의 내용을
|
||||
# 별도 데이터로 넘기므로 handle_data 에서 따로 걸러야 한다.
|
||||
@@ -302,6 +308,10 @@ class _DescriptionSanitizer(HTMLParser):
|
||||
if tag not in _DESC_ALLOWED_TAGS:
|
||||
return
|
||||
allowed = _DESC_ALLOWED_ATTRS.get(tag, frozenset())
|
||||
# span 은 멘션 칩일 때만 속성을 갖는다 — class 가 pj-mention 이 아니면
|
||||
# data-email 까지 통째로 버린다(평범한 span 으로만 남는다).
|
||||
if tag == "span" and (dict(attrs).get("class") or "").strip() != _MENTION_CLASS:
|
||||
allowed = frozenset()
|
||||
kept: list[str] = []
|
||||
for name, value in attrs:
|
||||
if name not in allowed:
|
||||
@@ -309,6 +319,10 @@ class _DescriptionSanitizer(HTMLParser):
|
||||
value = value or ""
|
||||
if name in ("href", "src") and not _desc_url_is_safe(value):
|
||||
continue
|
||||
# class 는 멘션 칩 하나만 허용한다(임의 클래스로 화면 스타일을
|
||||
# 흔들 여지를 남기지 않는다).
|
||||
if name == "class" and value.strip() != _MENTION_CLASS:
|
||||
continue
|
||||
kept.append(f'{name}="{_desc_escape_attr(value)}"')
|
||||
attr_text = (" " + " ".join(kept)) if kept else ""
|
||||
self.out.append(f"<{tag}{attr_text}>")
|
||||
@@ -358,3 +372,50 @@ def sanitize_description_html(html: str) -> str:
|
||||
parser.feed(html or "")
|
||||
parser.close()
|
||||
return "".join(parser.out).strip()
|
||||
|
||||
|
||||
# ════════════════════════════════════════════════════════════
|
||||
# 멘션(@태그)
|
||||
#
|
||||
# 설명란은 HTML이라 멘션 칩(<span class="pj-mention" data-email="...">)에서
|
||||
# 이메일을 그대로 꺼낼 수 있다 — 클라이언트가 따로 알려주는 목록을 믿지 않고
|
||||
# 저장될 본문에서 직접 읽는다(본문과 알림이 어긋나지 않는다).
|
||||
# 댓글은 평문이라 칩을 넣을 수 없으므로, 그쪽만 클라이언트가 보낸 이메일
|
||||
# 목록을 받아 normalize_emails 로 정리해 쓴다.
|
||||
# ════════════════════════════════════════════════════════════
|
||||
class _MentionCollector(HTMLParser):
|
||||
def __init__(self) -> None:
|
||||
super().__init__(convert_charrefs=True)
|
||||
self.emails: list[str] = []
|
||||
|
||||
def handle_starttag(self, tag: str, attrs: list[tuple[str, str | None]]) -> None:
|
||||
if tag != "span":
|
||||
return
|
||||
attr = dict(attrs)
|
||||
if (attr.get("class") or "").strip() != _MENTION_CLASS:
|
||||
return
|
||||
email = norm_str(attr.get("data-email") or "", lower=True)
|
||||
if email and email not in self.emails:
|
||||
self.emails.append(email)
|
||||
|
||||
|
||||
def extract_mentions_from_html(html: str) -> list[str]:
|
||||
"""설명 HTML 안의 멘션 칩에서 이메일을 뽑는다(중복 제거, 순서 유지)."""
|
||||
parser = _MentionCollector()
|
||||
parser.feed(html or "")
|
||||
parser.close()
|
||||
return parser.emails
|
||||
|
||||
|
||||
def normalize_emails(values: Any) -> list[str]:
|
||||
"""임의 입력(리스트/문자열)을 소문자 이메일 목록으로 정리한다."""
|
||||
if isinstance(values, str):
|
||||
values = values.split(",")
|
||||
if not isinstance(values, (list, tuple)):
|
||||
return []
|
||||
out: list[str] = []
|
||||
for v in values:
|
||||
e = norm_str(str(v or ""), lower=True)
|
||||
if e and "@" in e and e not in out:
|
||||
out.append(e)
|
||||
return out
|
||||
|
||||
@@ -1,49 +1,88 @@
|
||||
{% extends "erp_base.html" %}
|
||||
|
||||
{% block head_extra %}
|
||||
<link rel="stylesheet" href="/static/project.css?v=20260918d" />
|
||||
<link rel="stylesheet" href="/static/project.css?v=20260922a" />
|
||||
<link rel="stylesheet" href="/static/vendor/material-symbols/material-symbols.css" />
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="pj-wrap">
|
||||
<div class="pj-section-head">
|
||||
<h2>알림센터</h2>
|
||||
<h2>수신함</h2>
|
||||
<div style="display:flex; gap:8px;">
|
||||
<a class="pj-btn" href="/project/">← 프로젝트</a>
|
||||
<button type="button" class="pj-btn pj-btn-primary" id="pj-readall">모두 읽음</button>
|
||||
<button type="button" class="pj-btn" id="pj-mentions-readall">태그 모두 확인</button>
|
||||
<button type="button" class="pj-btn pj-btn-primary" id="pj-readall">알림 모두 읽음</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% if not notifications %}
|
||||
<div class="pj-empty">알림이 없습니다.</div>
|
||||
{% else %}
|
||||
<ul class="pj-inbox" id="pj-inbox">
|
||||
{% for n in notifications %}
|
||||
<li class="pj-inbox-item {% if not n.is_read %}is-unread{% endif %}"
|
||||
data-id="{{ n.id }}"
|
||||
{% if n.task_id %}data-project="{{ n.project_id }}"{% endif %}>
|
||||
<span class="material-symbols-outlined pj-inbox-icon">
|
||||
{% if n.type == 'assigned' %}assignment_ind
|
||||
{% elif n.type == 'completed' %}task_alt
|
||||
{% elif n.type == 'comment' %}chat_bubble
|
||||
{% else %}notifications{% endif %}
|
||||
</span>
|
||||
<div class="pj-inbox-body">
|
||||
<div class="pj-inbox-title">{{ n.title }}</div>
|
||||
{% if n.body %}<div class="pj-inbox-sub">{{ n.body }}</div>{% endif %}
|
||||
<div class="pj-inbox-meta">
|
||||
{% if n.actor_email %}{{ n.actor_email.split('@')[0] }} · {% endif %}{{ n.created_at[:16].replace('T',' ') }}
|
||||
<!-- 아사나 Inbox 처럼 "나를 태그(@)한 업무"를 맨 위에 리스트로 보여준다.
|
||||
업무를 누르면 그 프로젝트 화면이 열리면서 업무 편집 팝업이 뜬다
|
||||
(?task= 파라미터 — project.js 가 처리). -->
|
||||
<div class="pj-inbox-section">
|
||||
<h3 class="pj-inbox-h3">
|
||||
나를 태그한 업무
|
||||
<span class="pj-inbox-count" id="pj-mention-unread"
|
||||
{% if not mention_unread %}hidden{% endif %}>{{ mention_unread }}</span>
|
||||
</h3>
|
||||
{% if not mentioned_tasks %}
|
||||
<div class="pj-empty">태그된 업무가 없습니다.</div>
|
||||
{% else %}
|
||||
<ul class="pj-inbox pj-mention-list" id="pj-mention-tasks">
|
||||
{% for t in mentioned_tasks %}
|
||||
<li class="pj-inbox-item pj-mention-item {% if t.unread_mentions %}is-unread{% endif %}"
|
||||
data-task-id="{{ t.id }}" data-project="{{ t.project_id }}">
|
||||
<span class="material-symbols-outlined pj-inbox-icon">alternate_email</span>
|
||||
<div class="pj-inbox-body">
|
||||
<div class="pj-inbox-title {% if t.completed_at %}is-done{% endif %}">{{ t.title }}</div>
|
||||
<div class="pj-inbox-meta">
|
||||
<span class="pj-inbox-proj" style="color: {{ t.project_color or '#4573d2' }}">● {{ t.project_name }}</span>
|
||||
{% if t.stage_name %} · {{ t.stage_name }}{% endif %}
|
||||
{% if t.due_label %} · 마감 {{ t.due_label }}{% endif %}
|
||||
{% if t.mention_actor %} · {{ t.mention_actor.split('@')[0] }}님이 태그{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% if n.project_id %}
|
||||
<a class="pj-btn pj-inbox-go" href="/project/p/{{ n.project_id }}">이동</a>
|
||||
{% endif %}
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% endif %}
|
||||
<a class="pj-btn pj-inbox-go" href="/project/p/{{ t.project_id }}?task={{ t.id }}">열기</a>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<div class="pj-inbox-section">
|
||||
<h3 class="pj-inbox-h3">알림</h3>
|
||||
{% if not notifications %}
|
||||
<div class="pj-empty">알림이 없습니다.</div>
|
||||
{% else %}
|
||||
<ul class="pj-inbox" id="pj-inbox">
|
||||
{% for n in notifications %}
|
||||
<li class="pj-inbox-item {% if not n.is_read %}is-unread{% endif %}"
|
||||
data-id="{{ n.id }}"
|
||||
{% if n.task_id %}data-project="{{ n.project_id }}"{% endif %}>
|
||||
<span class="material-symbols-outlined pj-inbox-icon">
|
||||
{% if n.type == 'assigned' %}assignment_ind
|
||||
{% elif n.type == 'completed' %}task_alt
|
||||
{% elif n.type == 'comment' %}chat_bubble
|
||||
{% elif n.type == 'mention' %}alternate_email
|
||||
{% else %}notifications{% endif %}
|
||||
</span>
|
||||
<div class="pj-inbox-body">
|
||||
<div class="pj-inbox-title">{{ n.title }}</div>
|
||||
{% if n.body %}<div class="pj-inbox-sub">{{ n.body }}</div>{% endif %}
|
||||
<div class="pj-inbox-meta">
|
||||
{% if n.actor_email %}{{ n.actor_email.split('@')[0] }} · {% endif %}{{ n.created_at[:16].replace('T',' ') }}
|
||||
</div>
|
||||
</div>
|
||||
{% if n.project_id %}
|
||||
<a class="pj-btn pj-inbox-go"
|
||||
href="/project/p/{{ n.project_id }}{% if n.task_id %}?task={{ n.task_id }}{% endif %}">이동</a>
|
||||
{% endif %}
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="/static/project.js?v=20260918d" defer></script>
|
||||
<script src="/static/project.js?v=20260922a" defer></script>
|
||||
{% endblock %}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{% extends "erp_base.html" %}
|
||||
|
||||
{% block head_extra %}
|
||||
<link rel="stylesheet" href="/static/project.css?v=20260918d" />
|
||||
<link rel="stylesheet" href="/static/project.css?v=20260922a" />
|
||||
<link rel="stylesheet" href="/static/vendor/material-symbols/material-symbols.css" />
|
||||
{% endblock %}
|
||||
|
||||
@@ -428,5 +428,5 @@
|
||||
window.PJ_COLORS = {{ ["#4573d2","#37a3a3","#62a420","#e8a33d","#e8384f","#aa62e3","#f06a6a","#5a6772"] | tojson }};
|
||||
window.PJ_STAGE_COLORS = {{ ["#4573d2","#37a3a3","#62a420","#e8a33d","#e8384f","#aa62e3","#f06a6a","#5a6772","#e8398a","#a15c43"] | tojson }};
|
||||
</script>
|
||||
<script src="/static/project.js?v=20260918d" defer></script>
|
||||
<script src="/static/project.js?v=20260922a" defer></script>
|
||||
{% endblock %}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{% extends "erp_base.html" %}
|
||||
|
||||
{% block head_extra %}
|
||||
<link rel="stylesheet" href="/static/project.css?v=20260918d" />
|
||||
<link rel="stylesheet" href="/static/project.css?v=20260922a" />
|
||||
<!-- 구글 머티리얼 심볼(담당자 아이콘 등) — self-host -->
|
||||
<link rel="stylesheet" href="/static/vendor/material-symbols/material-symbols.css" />
|
||||
<!-- 타임라인 vis-timeline — self-host -->
|
||||
@@ -29,6 +29,76 @@
|
||||
<div class="pj-layout">
|
||||
<!-- ── 좌측: 프로젝트 트리 + 멤버 ── -->
|
||||
<aside class="pj-side">
|
||||
<!-- 아사나처럼 맨 위에 개인 메뉴(수신함 / 내 업무). 둘 다 기본 접힘이고
|
||||
누르면 펼쳐진다 — 예전 화면 오른쪽에 항상 떠 있던 "내 업무" 패널을
|
||||
이 메뉴가 대신한다. -->
|
||||
<nav class="pj-side-nav">
|
||||
<a class="pj-side-navlink" href="/project/inbox">
|
||||
<span class="material-symbols-outlined pj-side-navic">inbox</span>
|
||||
<span class="pj-side-navtext">수신함</span>
|
||||
<span class="pj-side-navbadge" id="pj-mention-badge"
|
||||
{% if not mention_unread %}hidden{% endif %}>{{ mention_unread }}</span>
|
||||
</a>
|
||||
<button type="button" class="pj-side-navlink pj-mytasks-toggle" id="pj-mytasks-toggle"
|
||||
aria-expanded="false" aria-controls="pj-mytasks-panel">
|
||||
<span class="material-symbols-outlined pj-side-navic">checklist</span>
|
||||
<span class="pj-side-navtext">내 업무</span>
|
||||
<span class="pj-side-navbadge pj-side-navbadge-open"
|
||||
{% if not my_open_total %}hidden{% endif %}>{{ my_open_total }}</span>
|
||||
<span class="material-symbols-outlined pj-side-navcaret">expand_more</span>
|
||||
</button>
|
||||
</nav>
|
||||
<!-- 내 업무 목록 — 접힌 상태가 기본. 업무를 고르면 팝업이 열리면서 다시 접힌다. -->
|
||||
<div class="pj-mytasks-panel" id="pj-mytasks-panel" hidden>
|
||||
{% if not my_projects %}
|
||||
<div class="pj-empty-sm">배정된 업무가 없습니다.</div>
|
||||
{% else %}
|
||||
<div class="pj-mytree">
|
||||
{% for p in my_projects %}
|
||||
<div class="pj-mytree-group" data-group-id="{{ p.id }}">
|
||||
<div class="pj-mytree-head">
|
||||
<button type="button" class="pj-mytree-toggle" title="펼치기/접기">
|
||||
<span class="material-symbols-outlined" style="color: {{ p.color }}; font-size:18px;">folder_open</span>
|
||||
</button>
|
||||
<a class="pj-mytree-proj" href="/project/p/{{ p.id }}">
|
||||
<span class="pj-mytree-proj-name">{{ p.name }}</span>
|
||||
</a>
|
||||
<span class="pj-mytree-counts">
|
||||
<span class="pj-mtc-num pj-mtc-open" data-tip="진행">{{ p.open }}</span>
|
||||
<span class="pj-mtc-num pj-mtc-done" data-tip="완료">{{ p.done }}</span>
|
||||
</span>
|
||||
</div>
|
||||
<ul class="pj-mytree-tasks">
|
||||
{% for t in p.tasks %}
|
||||
<li class="pj-mytree-task {% if t.completed_at %}is-done{% endif %}">
|
||||
<a href="/project/p/{{ t.project_id }}?task={{ t.id }}" data-task-id="{{ t.id }}" class="pj-task-popup-link">
|
||||
<span class="pj-mytree-lead">
|
||||
{% if t.comment_count %}
|
||||
<span class="pj-cmt-badge" data-task-id="{{ t.id }}" data-count="{{ t.comment_count }}" title="댓글 {{ t.comment_count }}개">
|
||||
<span class="pj-cmt-ic">💬</span><span class="pj-cmt-n">{{ t.comment_count }}</span>
|
||||
</span>
|
||||
{% endif %}
|
||||
</span>
|
||||
<span class="pj-mytree-body">
|
||||
<span class="pj-mytree-title">{{ t.title }}</span>
|
||||
{% if t.start_date or t.due_date %}
|
||||
<span class="pj-mytree-dates">
|
||||
{% if t.start_date and t.due_date %}{{ t.start_label }} ~ {{ t.due_label }}
|
||||
{% elif t.due_date %}~ {{ t.due_label }}
|
||||
{% else %}{{ t.start_label }} ~{% endif %}
|
||||
</span>
|
||||
{% endif %}
|
||||
</span>
|
||||
</a>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<div class="pj-side-block">
|
||||
<div class="pj-side-head">
|
||||
<span>프로젝트</span>
|
||||
@@ -183,6 +253,10 @@
|
||||
<div class="pj-board" id="pj-board">
|
||||
<div class="pj-board-canvas" id="pj-board-canvas"></div>
|
||||
</div>
|
||||
<!-- 가로 스크롤 막대 — 네이티브 막대는 CSS 로 숨겨두므로(자동숨김
|
||||
환경 대응) 보드 바깥에 직접 그린다. JS(attachHScrollIndicator)가
|
||||
pj-board 의 scrollLeft 와 동기화한다. -->
|
||||
<div class="pj-hbar" id="pj-board-hbar" hidden><div class="pj-hbar-thumb"></div></div>
|
||||
</div>
|
||||
<!-- 리스트 -->
|
||||
<div class="pj-view" data-view="list" hidden>
|
||||
@@ -200,59 +274,6 @@
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- ── 우측: 내 업무 (홈 화면과 동일) ── -->
|
||||
<aside class="pj-home-side pj-project-mytasks">
|
||||
<div class="pj-section-head"><h2>내 업무</h2></div>
|
||||
{% if not my_projects %}
|
||||
<div class="pj-empty pj-empty-sm">배정된 업무가 없습니다.</div>
|
||||
{% else %}
|
||||
<div class="pj-mytree">
|
||||
{% for p in my_projects %}
|
||||
<div class="pj-mytree-group" data-group-id="{{ p.id }}">
|
||||
<div class="pj-mytree-head">
|
||||
<button type="button" class="pj-mytree-toggle" title="펼치기/접기">
|
||||
<span class="material-symbols-outlined" style="color: {{ p.color }}; font-size:18px;">folder_open</span>
|
||||
</button>
|
||||
<a class="pj-mytree-proj" href="/project/p/{{ p.id }}">
|
||||
<span class="pj-mytree-proj-name">{{ p.name }}</span>
|
||||
</a>
|
||||
<!-- .pj-mytree-head 자체는 접어도(is-collapsed 는 .pj-mytree-tasks 만
|
||||
숨김) 계속 보인다. -->
|
||||
<span class="pj-mytree-counts">
|
||||
<span class="pj-mtc-num pj-mtc-open" data-tip="진행">{{ p.open }}</span>
|
||||
<span class="pj-mtc-num pj-mtc-done" data-tip="완료">{{ p.done }}</span>
|
||||
</span>
|
||||
</div>
|
||||
<ul class="pj-mytree-tasks">
|
||||
{% for t in p.tasks %}
|
||||
<li class="pj-mytree-task {% if t.completed_at %}is-done{% endif %}">
|
||||
<a href="/project/p/{{ t.project_id }}?task={{ t.id }}" data-task-id="{{ t.id }}" class="pj-task-popup-link">
|
||||
<span class="pj-mytree-lead">
|
||||
{% if t.comment_count %}
|
||||
<span class="pj-cmt-badge" data-task-id="{{ t.id }}" data-count="{{ t.comment_count }}" title="댓글 {{ t.comment_count }}개">
|
||||
<span class="pj-cmt-ic">💬</span><span class="pj-cmt-n">{{ t.comment_count }}</span>
|
||||
</span>
|
||||
{% endif %}
|
||||
</span>
|
||||
<span class="pj-mytree-body">
|
||||
<span class="pj-mytree-title">{{ t.title }}</span>
|
||||
{% if t.start_date or t.due_date %}
|
||||
<span class="pj-mytree-dates">
|
||||
{% if t.start_date and t.due_date %}{{ t.start_label }} ~ {{ t.due_label }}
|
||||
{% elif t.due_date %}~ {{ t.due_label }}
|
||||
{% else %}{{ t.start_label }} ~{% endif %}
|
||||
</span>
|
||||
{% endif %}
|
||||
</span>
|
||||
</a>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endif %}
|
||||
</aside>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -553,5 +574,5 @@
|
||||
</script>
|
||||
|
||||
<script src="/static/vendor/vis-timeline/vis-timeline-graph2d.min.js"></script>
|
||||
<script src="/static/project.js?v=20260918d" defer></script>
|
||||
<script src="/static/project.js?v=20260922a" defer></script>
|
||||
{% endblock %}
|
||||
|
||||
+115
-24
@@ -177,13 +177,14 @@
|
||||
(퍼센트 높이는 트랙이 auto면 무시되고 다시 내용 크기로 되돌아간다) —
|
||||
그래서 내 업무/좌측 목록이 제 안에서 스크롤 못 하고 카드 내용만큼
|
||||
늘어나 버렸다. 1fr 로 행 자체를 컨테이너 높이만큼 확정 지어야 한다. */
|
||||
/* 우측에 항상 떠 있던 "내 업무" 칸은 없앴다 — 좌측 사이드바의 접이식
|
||||
"내 업무" 메뉴(.pj-mytasks-panel)가 그 역할을 대신한다. 그래서 2열. */
|
||||
.pj-layout {
|
||||
display: grid; grid-template-columns: 230px 1fr 300px; grid-template-rows: minmax(0, 1fr);
|
||||
display: grid; grid-template-columns: 250px 1fr; grid-template-rows: minmax(0, 1fr);
|
||||
gap: 22px; height: 100%; min-height: 0; align-items: stretch;
|
||||
}
|
||||
.pj-side { min-width: 0; min-height: 0; height: 100%; overflow-y: auto; padding-right: 14px; }
|
||||
.pj-main { min-width: 0; min-height: 0; height: 100%; display: flex; flex-direction: column; }
|
||||
.pj-project-mytasks { min-width: 0; min-height: 0; width: 300px; height: 100%; overflow-y: auto; padding-right: 14px; }
|
||||
|
||||
/* ── 자체 스크롤 패널(내 업무/좌측 목록/홈 프로젝트 목록/보드)의 스크롤 막대 ──
|
||||
윈도우/엣지가 오버레이(자동숨김) 스크롤바를 쓰는 환경에선 네이티브 막대가
|
||||
@@ -204,8 +205,7 @@
|
||||
.pj-vbar-thumb:hover, .pj-vbar-thumb.is-dragging { background: #8f949e; }
|
||||
.pj-vbar-thumb.is-dragging { cursor: grabbing; }
|
||||
@media (max-width: 1280px) {
|
||||
.pj-layout { grid-template-columns: 230px 1fr; }
|
||||
.pj-project-mytasks { display: none; }
|
||||
.pj-layout { grid-template-columns: 220px 1fr; }
|
||||
}
|
||||
@media (max-width: 900px) {
|
||||
.erp-page:has(> .pj-wrap) { max-width: 1550px; }
|
||||
@@ -307,31 +307,36 @@
|
||||
transform-origin: top center;
|
||||
}
|
||||
|
||||
/* ── 보드(칸반) — 최대 4열 매이슨리(masonry). CSS Grid로 4열을 만들면 같은
|
||||
행의 한 칸만 카드가 많아도 그 행 전체 높이가 맞춰져 빈 칸이 생긴다 —
|
||||
그래서 각 세션을 JS(layoutMasonry)로 절대배치해 열은 고정(왼쪽부터
|
||||
순서대로 배정)하되 높이는 열마다 독립적으로 쌓이게 한다(같은 열의 다음
|
||||
세션이 바로 위 세션 아래에 붙는다). 세션이 많아지면 이 영역 안에서만
|
||||
세로 스크롤되고, "+ 세션 추가" 버튼은 이 영역 밖(pj-board-toolbar)에
|
||||
있어 스크롤과 무관하게 항상 보인다. ── */
|
||||
/* ── 보드(칸반) — 아사나식. 세션은 가로로 한 줄에 나란히 놓이고, 화면을
|
||||
넘치면 아래로 접히지 않고 보드가 가로로 스크롤된다. "+ 세션 추가" 버튼은
|
||||
스크롤 영역 밖(pj-board-toolbar)에 있어 항상 보인다. ── */
|
||||
.pj-board-toolbar { display: flex; justify-content: flex-end; margin-bottom: 10px; flex: none; }
|
||||
.pj-board-toolbar .pj-add-stage { width: auto; padding: 8px 18px; }
|
||||
/* pj-board = 스크롤 뷰포트(남은 세로 공간을 그대로 씀, 부모가 이미 flex로
|
||||
높이를 정해준다). pj-board-canvas = 매이슨리 절대배치 캔버스 — 스크롤
|
||||
컨테이너 자체 높이와 콘텐츠(캔버스) 높이 계산을 분리해야 스크롤이
|
||||
올바르게 생긴다(캔버스만 커지고 뷰포트는 flex 크기를 유지). */
|
||||
/* 네이티브 스크롤바는 숨기고 JS 가 그리는 막대를 쓴다(위 .pj-vbar-* 참고).
|
||||
막대 자리는 padding-right 14px — 매이슨리 열 너비는 canvas(=padding 안쪽)
|
||||
기준으로 계산되므로 열이 막대에 가려지지 않는다. */
|
||||
/* pj-board = 가로 스크롤 뷰포트(남은 세로 공간을 그대로 씀, 부모가 이미
|
||||
flex 로 높이를 정해준다). pj-board-canvas = 세션을 가로로 늘어놓는 flex
|
||||
컨테이너 — width:max-content 라서 세션이 늘어나는 만큼 캔버스가 넓어지고
|
||||
뷰포트(pj-board)만 스크롤한다.
|
||||
네이티브 스크롤바는 숨기고(위 .pj-vbar-* 와 같은 이유) JS 가 그리는
|
||||
가로 막대(.pj-hbar / attachHScrollIndicator)를 보드 아래에 둔다. */
|
||||
.pj-board {
|
||||
flex: 1 1 auto; min-height: 0; overflow-y: auto; overflow-x: hidden;
|
||||
padding-right: 14px; padding-bottom: 8px;
|
||||
flex: 1 1 auto; min-height: 0; min-width: 0;
|
||||
overflow-x: auto; overflow-y: hidden;
|
||||
padding-right: 14px; padding-bottom: 4px;
|
||||
}
|
||||
.pj-board-canvas {
|
||||
display: flex; align-items: flex-start; gap: 16px;
|
||||
height: 100%; min-height: 0; width: max-content; min-width: 100%;
|
||||
}
|
||||
.pj-board-canvas { position: relative; }
|
||||
/* 세션(보드 컬럼) — 배경이 페이지와 거의 같으면 구분이 안 되므로(#f6f5fb ≈
|
||||
흰 배경) 뚜렷한 회색 톤 + 테두리로 아사나처럼 컬럼 경계를 분명히 준다.
|
||||
position/width/left/top 은 layoutMasonry 가 매번 인라인으로 계산해 준다. */
|
||||
.pj-col { position: absolute; background: #eef0f4; border: 1px solid #e2e4ea; border-radius: 14px; padding: 12px; box-sizing: border-box; }
|
||||
너비는 고정(300px), 높이는 내용만큼 — 보드 높이를 넘으면 그 컬럼 안에서
|
||||
세로 스크롤(.pj-col-body). */
|
||||
.pj-col {
|
||||
flex: 0 0 300px; width: 300px; max-height: 100%;
|
||||
display: flex; flex-direction: column; min-height: 0;
|
||||
background: #eef0f4; border: 1px solid #e2e4ea; border-radius: 14px;
|
||||
padding: 12px; box-sizing: border-box;
|
||||
}
|
||||
.pj-empty { position: static; }
|
||||
/* 완료로 지정된 세션 — 반투명 + 보드 끝으로(정렬은 JS 쪽 comparator 담당) */
|
||||
.pj-col.pj-col-done { opacity: .55; }
|
||||
@@ -357,7 +362,14 @@
|
||||
background: #fff; border: 1px solid #e2e4ea; border-radius: 999px; min-width: 20px; height: 20px; padding: 0 6px;
|
||||
display: inline-flex; align-items: center; justify-content: center;
|
||||
}
|
||||
.pj-col-body { display: flex; flex-direction: column; gap: 8px; min-height: 40px; border-radius: 8px; padding-top: 8px; }
|
||||
/* 컬럼 안의 카드가 많아지면 보드 전체가 아니라 이 컬럼만 세로로 스크롤한다
|
||||
— 그래야 가로로 늘어난 다른 세션들이 화면 밖으로 밀려나지 않는다. */
|
||||
.pj-col-body {
|
||||
display: flex; flex-direction: column; gap: 8px; min-height: 40px;
|
||||
border-radius: 8px; padding-top: 8px;
|
||||
flex: 1 1 auto; overflow-y: auto; overflow-x: hidden; scrollbar-width: thin;
|
||||
}
|
||||
.pj-col-head { flex: none; }
|
||||
.pj-col-body.is-over { background: var(--pj-accent-tint); outline: 2px dashed var(--pj-accent); }
|
||||
.pj-card {
|
||||
background: #fff; border: 1px solid var(--pj-border); border-radius: var(--pj-card-radius);
|
||||
@@ -1004,3 +1016,82 @@ label.pj-desc-fmtbtn { line-height: 26px; }
|
||||
.pj-dash-charts .pj-dash-card:nth-child(3) { animation-delay: .12s; }
|
||||
@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); } }
|
||||
|
||||
/* ════════════════════════════════════════════════════════════
|
||||
좌측 사이드바 개인 메뉴 — 수신함 / 내 업무(접이식)
|
||||
예전에 화면 오른쪽에 항상 떠 있던 "내 업무" 패널을 이 메뉴가 대신한다.
|
||||
════════════════════════════════════════════════════════════ */
|
||||
.pj-side-nav { display: flex; flex-direction: column; gap: 2px; margin-bottom: 14px; }
|
||||
.pj-side-navlink {
|
||||
display: flex; align-items: center; gap: 9px; width: 100%;
|
||||
padding: 7px 8px; border: none; background: transparent; border-radius: 8px;
|
||||
color: var(--pj-ink); font-size: 13.5px; font-weight: 700; text-decoration: none;
|
||||
cursor: pointer; text-align: left;
|
||||
}
|
||||
.pj-side-navlink:hover { background: #f1f2f4; }
|
||||
.pj-side-navic { font-size: 20px; color: #5f6368; flex: 0 0 auto; }
|
||||
.pj-side-navtext { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
||||
.pj-side-navbadge {
|
||||
flex: 0 0 auto; min-width: 18px; padding: 1px 6px; border-radius: 999px;
|
||||
background: #fbe3df; color: #c22b10; font-size: 11px; font-weight: 700; text-align: center;
|
||||
}
|
||||
.pj-side-navbadge-open { background: #dcf1fc; color: #0284c7; }
|
||||
.pj-side-navbadge[hidden] { display: none; }
|
||||
.pj-side-navcaret { font-size: 18px; color: #9aa1a9; flex: 0 0 auto; transition: transform .15s; }
|
||||
.pj-mytasks-toggle[aria-expanded="true"] .pj-side-navcaret { transform: rotate(180deg); }
|
||||
.pj-mytasks-panel { margin: 0 0 18px 6px; padding-left: 4px; border-left: 2px solid #eef0f2; }
|
||||
.pj-mytasks-panel[hidden] { display: none; }
|
||||
|
||||
/* ── 보드 가로 스크롤 막대 (세로 막대 .pj-vbar-* 와 같은 이유로 직접 그린다) ── */
|
||||
.pj-hbar { position: relative; height: 8px; margin: 6px 14px 0 0; border-radius: 999px; background: #e6e8ec; flex: none; }
|
||||
.pj-hbar[hidden] { display: none; }
|
||||
.pj-hbar-thumb { position: absolute; top: 0; left: 0; height: 100%; border-radius: 999px; background: #b3b7bf; cursor: grab; }
|
||||
.pj-hbar-thumb:hover, .pj-hbar-thumb.is-dragging { background: #8f949e; }
|
||||
.pj-hbar-thumb.is-dragging { cursor: grabbing; }
|
||||
|
||||
/* ── 보드 카드에서 바로 고치는 담당자/마감일 ──
|
||||
값이 없을 때도 자리는 남겨 두되(카드에 마우스를 올려야 보인다) 눌러서
|
||||
바로 지정할 수 있게 한다. */
|
||||
.pj-card-edit-hit { cursor: pointer; border-radius: 6px; padding: 1px 4px; margin: -1px -4px; }
|
||||
.pj-card-edit-hit:hover { background: #eef1f6; }
|
||||
.pj-card-meta .is-empty { opacity: 0; transition: opacity .12s; color: #9aa1a9; }
|
||||
.pj-card:hover .pj-card-meta .is-empty { opacity: .8; }
|
||||
.pj-card-due.is-overdue { color: #c22b10; }
|
||||
.pj-inline-date {
|
||||
position: absolute; z-index: 1200; background: #fff; border: 1px solid #d8dce2;
|
||||
border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.14); padding: 8px;
|
||||
display: flex; align-items: center; gap: 6px;
|
||||
}
|
||||
.pj-inline-date input[type="date"] { border: 1px solid #d8dce2; border-radius: 7px; padding: 5px 7px; font-size: 13px; }
|
||||
|
||||
/* ── 멘션(@태그) ── */
|
||||
.pj-mention {
|
||||
display: inline-block; padding: 0 5px; border-radius: 5px;
|
||||
background: var(--pj-accent-tint, #e8eefb); color: var(--pj-accent-dark, #2f5bb7);
|
||||
font-weight: 600; white-space: nowrap;
|
||||
}
|
||||
.pj-mention-menu {
|
||||
position: absolute; z-index: 1300; min-width: 200px; max-height: 260px; overflow-y: auto;
|
||||
background: #fff; border: 1px solid #d8dce2; border-radius: 10px;
|
||||
box-shadow: 0 8px 24px rgba(0,0,0,.16); padding: 4px;
|
||||
}
|
||||
.pj-mention-menu[hidden] { display: none; }
|
||||
.pj-mention-opt {
|
||||
display: flex; align-items: center; gap: 8px; width: 100%;
|
||||
padding: 7px 8px; border: none; background: transparent; border-radius: 7px;
|
||||
font-size: 13px; color: var(--pj-ink); cursor: pointer; text-align: left;
|
||||
}
|
||||
.pj-mention-opt:hover, .pj-mention-opt.is-active { background: var(--pj-accent-tint, #e8eefb); }
|
||||
.pj-mention-opt .pj-avatar, .pj-mention-opt .pj-gicon { flex: 0 0 auto; }
|
||||
.pj-mention-empty { padding: 8px; font-size: 12.5px; color: #9aa1a9; }
|
||||
|
||||
/* 설명란 링크 — 클릭하면 새 탭으로 열린다(JS 가 처리). */
|
||||
.pj-desc-editor a { color: var(--pj-accent-dark, #2f5bb7); text-decoration: underline; cursor: pointer; }
|
||||
|
||||
/* ── 수신함 섹션 (알림 / 나를 태그한 업무) ── */
|
||||
.pj-inbox-section { margin-bottom: 26px; }
|
||||
.pj-inbox-h3 { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 800; color: #6b7280; margin: 0 0 10px; }
|
||||
.pj-inbox-count { padding: 1px 7px; border-radius: 999px; background: #fbe3df; color: #c22b10; font-size: 11px; font-weight: 700; }
|
||||
.pj-inbox-count[hidden] { display: none; }
|
||||
.pj-inbox-title.is-done { text-decoration: line-through; color: #9aa1a9; }
|
||||
.pj-inbox-proj { font-weight: 600; }
|
||||
|
||||
+542
-43
@@ -293,6 +293,7 @@
|
||||
renderPending();
|
||||
});
|
||||
const cmInput = el("pj-cm-input");
|
||||
attachMentionInput(cmInput);
|
||||
if (cmInput) cmInput.addEventListener("paste", function (e) {
|
||||
const items = (e.clipboardData || window.clipboardData || {}).items || [];
|
||||
let handled = false;
|
||||
@@ -438,7 +439,7 @@
|
||||
const filesToSend = pendingFiles.slice();
|
||||
try {
|
||||
const res = await api("POST", "/project/api/tasks/" + taskId + "/comments",
|
||||
{ body: bodyText, has_attachment: filesToSend.length > 0 });
|
||||
{ body: bodyText, has_attachment: filesToSend.length > 0, mentions: takeMentions(inp) });
|
||||
const commentId = res.comment.id;
|
||||
for (let i = 0; i < filesToSend.length; i++) {
|
||||
const fd = new FormData();
|
||||
@@ -456,6 +457,7 @@
|
||||
pendingFiles = [];
|
||||
renderPending();
|
||||
inp.value = "";
|
||||
clearMentions(inp);
|
||||
const n = await renderChat(taskId);
|
||||
if (n !== null) { markSeen(taskId, n); syncBadge(taskId, n); }
|
||||
} catch (e) { alert("등록 실패: " + e.message); }
|
||||
@@ -468,6 +470,311 @@
|
||||
return cmtChat;
|
||||
}
|
||||
|
||||
// ════════════════════════════════════════════════════════════
|
||||
// 멘션(@태그) — 설명란(contenteditable)과 댓글 입력(평문 input) 공용
|
||||
//
|
||||
// @를 누르면 등록된 전체 프로젝트 멤버가 뜨고, 고르면
|
||||
// · 설명란: <span class="pj-mention" data-email="...">@아이디</span> 칩
|
||||
// · 댓글 : "@아이디 " 평문 + 이메일을 따로 기억(전송 시 함께 보냄)
|
||||
// 으로 들어간다. 태그된 사람은 수신함(/project/inbox)에서 그 업무를 본다.
|
||||
// ════════════════════════════════════════════════════════════
|
||||
let mentionUsersCache = null;
|
||||
async function mentionUsers() {
|
||||
if (mentionUsersCache) return mentionUsersCache;
|
||||
try {
|
||||
const res = await api("GET", "/project/api/all-users");
|
||||
mentionUsersCache = res.users || [];
|
||||
} catch (_) { mentionUsersCache = []; }
|
||||
return mentionUsersCache;
|
||||
}
|
||||
|
||||
// 메뉴는 화면에 하나만 띄운다(설명란/댓글/채팅이 번갈아 쓴다).
|
||||
let mentionMenuEl = null;
|
||||
let mentionMenuState = null;
|
||||
function closeMentionMenu() {
|
||||
if (mentionMenuEl) mentionMenuEl.hidden = true;
|
||||
mentionMenuState = null;
|
||||
}
|
||||
function mentionMenuOpen() { return !!mentionMenuState; }
|
||||
function ensureMentionMenu() {
|
||||
if (mentionMenuEl) return mentionMenuEl;
|
||||
mentionMenuEl = document.createElement("div");
|
||||
mentionMenuEl.className = "pj-mention-menu";
|
||||
mentionMenuEl.hidden = true;
|
||||
document.body.appendChild(mentionMenuEl);
|
||||
// mousedown 은 막는다 — 안 그러면 목록을 누르는 순간 입력칸이 포커스를
|
||||
// 잃어 커서 위치(=치환할 자리)가 사라진다.
|
||||
mentionMenuEl.addEventListener("mousedown", function (e) { e.preventDefault(); });
|
||||
document.addEventListener("mousedown", function (e) {
|
||||
if (mentionMenuEl && !mentionMenuEl.contains(e.target)) closeMentionMenu();
|
||||
}, true);
|
||||
window.addEventListener("resize", closeMentionMenu);
|
||||
return mentionMenuEl;
|
||||
}
|
||||
function renderMentionMenu(users, rect, onPick) {
|
||||
const menu = ensureMentionMenu();
|
||||
menu.innerHTML = "";
|
||||
if (!users.length) {
|
||||
menu.innerHTML = '<div class="pj-mention-empty">일치하는 멤버 없음</div>';
|
||||
} else {
|
||||
users.forEach(function (u, i) {
|
||||
const b = document.createElement("button");
|
||||
b.type = "button";
|
||||
b.className = "pj-mention-opt" + (i === 0 ? " is-active" : "");
|
||||
b.innerHTML =
|
||||
(u.avatar
|
||||
? '<img class="pj-avatar pj-gicon-sm" src="' + escapeHtml(u.avatar) + '" alt="" referrerpolicy="no-referrer">'
|
||||
: '<span class="material-symbols-outlined pj-gicon pj-gicon-sm">account_circle</span>') +
|
||||
"<span>" + escapeHtml(u.id || u.name || u.email) + "</span>";
|
||||
b.addEventListener("click", function () { onPick(u); });
|
||||
menu.appendChild(b);
|
||||
});
|
||||
}
|
||||
menu.hidden = false;
|
||||
// 커서/입력칸 바로 아래. 화면 밖으로 나가면 위쪽으로 뒤집는다.
|
||||
let top = window.scrollY + rect.bottom + 4;
|
||||
let left = window.scrollX + rect.left;
|
||||
left = Math.min(left, window.scrollX + document.documentElement.clientWidth - menu.offsetWidth - 8);
|
||||
if (rect.bottom + menu.offsetHeight + 8 > document.documentElement.clientHeight) {
|
||||
top = window.scrollY + rect.top - menu.offsetHeight - 4;
|
||||
}
|
||||
menu.style.left = Math.max(8, left) + "px";
|
||||
menu.style.top = Math.max(8, top) + "px";
|
||||
mentionMenuState = { users: users, index: 0, onPick: onPick };
|
||||
}
|
||||
function moveMentionActive(delta) {
|
||||
if (!mentionMenuState) return;
|
||||
const opts = mentionMenuEl.querySelectorAll(".pj-mention-opt");
|
||||
if (!opts.length) return;
|
||||
opts[mentionMenuState.index].classList.remove("is-active");
|
||||
mentionMenuState.index = (mentionMenuState.index + delta + opts.length) % opts.length;
|
||||
const act = opts[mentionMenuState.index];
|
||||
act.classList.add("is-active");
|
||||
act.scrollIntoView({ block: "nearest" });
|
||||
}
|
||||
function chooseMentionActive() {
|
||||
if (!mentionMenuState) return false;
|
||||
const u = mentionMenuState.users[mentionMenuState.index];
|
||||
if (!u) { closeMentionMenu(); return false; }
|
||||
mentionMenuState.onPick(u);
|
||||
return true;
|
||||
}
|
||||
function filterMentionUsers(users, query) {
|
||||
const q = (query || "").toLowerCase();
|
||||
if (!q) return users.slice(0, 12);
|
||||
return users.filter(function (u) {
|
||||
return (u.id || "").toLowerCase().indexOf(q) >= 0 ||
|
||||
(u.name || "").toLowerCase().indexOf(q) >= 0 ||
|
||||
(u.email || "").toLowerCase().indexOf(q) >= 0;
|
||||
}).slice(0, 12);
|
||||
}
|
||||
// 메뉴가 떠 있을 때 위/아래/엔터/탭/ESC 를 가로챈다(입력칸 공용).
|
||||
function mentionKeydown(e) {
|
||||
if (!mentionMenuOpen()) return false;
|
||||
if (e.key === "ArrowDown") { e.preventDefault(); moveMentionActive(1); return true; }
|
||||
if (e.key === "ArrowUp") { e.preventDefault(); moveMentionActive(-1); return true; }
|
||||
// stopImmediatePropagation 이어야 한다 — 같은 입력칸에 걸린 "Enter=전송"
|
||||
// 핸들러는 stopPropagation 으로는 안 막힌다(같은 노드의 다른 리스너).
|
||||
// 그래서 이 멘션 리스너를 항상 먼저 등록한다(attachMentionInput 호출 위치).
|
||||
if (e.key === "Enter" || e.key === "Tab") {
|
||||
e.preventDefault(); e.stopImmediatePropagation();
|
||||
chooseMentionActive();
|
||||
return true;
|
||||
}
|
||||
if (e.key === "Escape") { e.preventDefault(); closeMentionMenu(); return true; }
|
||||
return false;
|
||||
}
|
||||
|
||||
// ── 평문 input 용 (#pj-comment-input, #pj-cm-input) ──
|
||||
// 고른 사람을 input 에 기억해두고(_pjMentions), 전송 직전에 "@아이디" 가
|
||||
// 아직 본문에 남아 있는 사람만 서버로 보낸다.
|
||||
function attachMentionInput(input) {
|
||||
if (!input || input.dataset.pjMention) return;
|
||||
input.dataset.pjMention = "1";
|
||||
input._pjMentions = {}; // "@아이디" → 이메일
|
||||
|
||||
function caretQuery() {
|
||||
const pos = input.selectionStart == null ? input.value.length : input.selectionStart;
|
||||
const before = input.value.slice(0, pos);
|
||||
const m = before.match(/(?:^|\s)@([^\s@]*)$/);
|
||||
return m === null ? null : { query: m[1], start: pos - m[1].length - 1, end: pos };
|
||||
}
|
||||
async function maybeOpen() {
|
||||
const ctx = caretQuery();
|
||||
if (!ctx) { closeMentionMenu(); return; }
|
||||
const users = filterMentionUsers(await mentionUsers(), ctx.query);
|
||||
renderMentionMenu(users, input.getBoundingClientRect(), function (u) {
|
||||
const token = "@" + (u.id || u.email.split("@")[0]);
|
||||
input.value = input.value.slice(0, ctx.start) + token + " " + input.value.slice(ctx.end);
|
||||
input._pjMentions[token] = u.email;
|
||||
const caret = ctx.start + token.length + 1;
|
||||
input.focus();
|
||||
input.setSelectionRange(caret, caret);
|
||||
closeMentionMenu();
|
||||
});
|
||||
}
|
||||
input.addEventListener("input", maybeOpen);
|
||||
input.addEventListener("blur", function () { setTimeout(closeMentionMenu, 120); });
|
||||
// keydown 은 capture 로 먼저 받는다 — 이 입력칸들은 Enter 에 "전송"이
|
||||
// 걸려 있어서, 메뉴가 떠 있을 때 Enter 가 전송으로 새 나가면 안 된다.
|
||||
input.addEventListener("keydown", function (e) { mentionKeydown(e); }, true);
|
||||
}
|
||||
// 전송 시 실제로 본문에 남아 있는 태그만 추린다.
|
||||
function takeMentions(input) {
|
||||
if (!input || !input._pjMentions) return [];
|
||||
const text = input.value || "";
|
||||
const out = [];
|
||||
Object.keys(input._pjMentions).forEach(function (token) {
|
||||
if (text.indexOf(token) >= 0) {
|
||||
const email = input._pjMentions[token];
|
||||
if (out.indexOf(email) < 0) out.push(email);
|
||||
}
|
||||
});
|
||||
return out;
|
||||
}
|
||||
function clearMentions(input) { if (input) input._pjMentions = {}; }
|
||||
|
||||
// ── contenteditable 용 (설명란) — 멘션 칩을 끼워 넣는다 ──
|
||||
function attachMentionEditor(box) {
|
||||
if (!box || box.dataset.pjMention) return;
|
||||
box.dataset.pjMention = "1";
|
||||
|
||||
function caretContext() {
|
||||
const sel = window.getSelection();
|
||||
if (!sel || !sel.rangeCount) return null;
|
||||
const r = sel.getRangeAt(0);
|
||||
if (!r.collapsed || !box.contains(r.startContainer)) return null;
|
||||
const node = r.startContainer;
|
||||
if (node.nodeType !== 3) return null; // 텍스트 노드 안에서만
|
||||
const before = node.textContent.slice(0, r.startOffset);
|
||||
const m = before.match(/(?:^|[\s\u00a0])@([^\s@\u00a0]*)$/);
|
||||
if (m === null) return null;
|
||||
return { node: node, query: m[1], start: r.startOffset - m[1].length - 1, end: r.startOffset };
|
||||
}
|
||||
async function maybeOpen() {
|
||||
const ctx = caretContext();
|
||||
if (!ctx) { closeMentionMenu(); return; }
|
||||
const sel = window.getSelection();
|
||||
let rect = sel.rangeCount ? sel.getRangeAt(0).getBoundingClientRect() : null;
|
||||
if (!rect || (!rect.width && !rect.height)) rect = box.getBoundingClientRect();
|
||||
const users = filterMentionUsers(await mentionUsers(), ctx.query);
|
||||
renderMentionMenu(users, rect, function (u) {
|
||||
const range = document.createRange();
|
||||
range.setStart(ctx.node, ctx.start);
|
||||
range.setEnd(ctx.node, ctx.end);
|
||||
range.deleteContents();
|
||||
const chip = document.createElement("span");
|
||||
chip.className = "pj-mention";
|
||||
chip.setAttribute("data-email", u.email);
|
||||
chip.setAttribute("contenteditable", "false");
|
||||
chip.textContent = "@" + (u.id || u.email.split("@")[0]);
|
||||
const space = document.createTextNode("\u00a0");
|
||||
range.insertNode(space);
|
||||
range.insertNode(chip);
|
||||
// 커서를 칩 뒤 공백 다음으로
|
||||
const after = document.createRange();
|
||||
after.setStartAfter(space);
|
||||
after.collapse(true);
|
||||
const s2 = window.getSelection();
|
||||
s2.removeAllRanges();
|
||||
s2.addRange(after);
|
||||
box.focus();
|
||||
closeMentionMenu();
|
||||
});
|
||||
}
|
||||
box.addEventListener("input", maybeOpen);
|
||||
box.addEventListener("keydown", function (e) { mentionKeydown(e); }, true);
|
||||
box.addEventListener("blur", function () { setTimeout(closeMentionMenu, 120); });
|
||||
}
|
||||
|
||||
// ════════════════════════════════════════════════════════════
|
||||
// 설명란 링크 — 주소를 붙여넣으면 <a> 로 바꾸고, 클릭하면 새 탭으로 연다
|
||||
// ════════════════════════════════════════════════════════════
|
||||
const PJ_URL_RE = /(https?:\/\/[^\s<>"']+|www\.[^\s<>"']+)/g;
|
||||
function linkifyToHtml(text) {
|
||||
const src = String(text == null ? "" : text);
|
||||
let out = "";
|
||||
let last = 0;
|
||||
let m;
|
||||
PJ_URL_RE.lastIndex = 0;
|
||||
while ((m = PJ_URL_RE.exec(src)) !== null) {
|
||||
out += escapeHtml(src.slice(last, m.index));
|
||||
// 주소 끝에 붙은 문장부호는 링크에서 뺀다(".", ",", ")" 등).
|
||||
let url = m[0];
|
||||
let tail = "";
|
||||
const trailing = url.match(/[).,!?;:'"]+$/);
|
||||
if (trailing) { tail = trailing[0]; url = url.slice(0, url.length - tail.length); }
|
||||
const href = /^https?:\/\//i.test(url) ? url : "http://" + url;
|
||||
out += '<a href="' + escapeHtml(href) + '" target="_blank" rel="noopener noreferrer">' +
|
||||
escapeHtml(url) + "</a>" + escapeHtml(tail);
|
||||
last = m.index + m[0].length;
|
||||
}
|
||||
out += escapeHtml(src.slice(last));
|
||||
return out.replace(/\n/g, "<br>");
|
||||
}
|
||||
// 에디터 안의 모든 <a> 가 새 탭으로 열리게 맞춘다(서식바 링크 버튼 포함).
|
||||
function normalizeEditorLinks(box) {
|
||||
if (!box) return;
|
||||
box.querySelectorAll("a").forEach(function (a) {
|
||||
a.setAttribute("target", "_blank");
|
||||
a.setAttribute("rel", "noopener noreferrer");
|
||||
});
|
||||
}
|
||||
|
||||
// ════════════════════════════════════════════════════════════
|
||||
// 가로 스크롤 막대 — 보드(세션이 오른쪽으로 계속 늘어난다)용.
|
||||
// 세로 막대(attachScrollIndicator)와 같은 이유로 직접 그린다.
|
||||
// ════════════════════════════════════════════════════════════
|
||||
function attachHScrollIndicator(scroller, bar) {
|
||||
if (!scroller || !bar) return null;
|
||||
const thumb = bar.querySelector(".pj-hbar-thumb");
|
||||
if (!thumb) return null;
|
||||
let thumbW = 0;
|
||||
|
||||
function update() {
|
||||
const sw = scroller.scrollWidth, cw = scroller.clientWidth;
|
||||
if (cw <= 0 || sw <= cw + 1) { bar.hidden = true; return; }
|
||||
bar.hidden = false;
|
||||
const trackW = bar.clientWidth;
|
||||
thumbW = Math.max(32, Math.round(trackW * cw / sw));
|
||||
const left = Math.round((trackW - thumbW) * scroller.scrollLeft / (sw - cw));
|
||||
thumb.style.width = thumbW + "px";
|
||||
thumb.style.transform = "translateX(" + left + "px)";
|
||||
}
|
||||
if (bar.dataset.pjHbar) return update;
|
||||
bar.dataset.pjHbar = "1";
|
||||
|
||||
scroller.addEventListener("scroll", update, { passive: true });
|
||||
window.addEventListener("resize", update);
|
||||
if (window.ResizeObserver) new ResizeObserver(update).observe(scroller);
|
||||
|
||||
let dragging = false, startX = 0, startLeft = 0;
|
||||
thumb.addEventListener("mousedown", function (e) {
|
||||
e.preventDefault();
|
||||
dragging = true; startX = e.clientX; startLeft = scroller.scrollLeft;
|
||||
thumb.classList.add("is-dragging");
|
||||
});
|
||||
document.addEventListener("mousemove", function (e) {
|
||||
if (!dragging) return;
|
||||
const sw = scroller.scrollWidth, cw = scroller.clientWidth;
|
||||
const room = bar.clientWidth - thumbW;
|
||||
if (room <= 0) return;
|
||||
scroller.scrollLeft = startLeft + (e.clientX - startX) * (sw - cw) / room;
|
||||
});
|
||||
document.addEventListener("mouseup", function () {
|
||||
if (dragging) { dragging = false; thumb.classList.remove("is-dragging"); }
|
||||
});
|
||||
bar.addEventListener("mousedown", function (e) {
|
||||
if (e.target !== bar) return;
|
||||
e.preventDefault();
|
||||
const x = e.clientX - bar.getBoundingClientRect().left;
|
||||
const thumbLeft = thumb.getBoundingClientRect().left - bar.getBoundingClientRect().left;
|
||||
scroller.scrollLeft += (x < thumbLeft ? -1 : 1) * scroller.clientWidth * 0.9;
|
||||
});
|
||||
update();
|
||||
return update;
|
||||
}
|
||||
|
||||
// ════════════════════════════════════════════════════════════
|
||||
// 홈 페이지 — 새 프로젝트
|
||||
// ════════════════════════════════════════════════════════════
|
||||
@@ -888,6 +1195,7 @@
|
||||
if (cmt) cmt.wireBadge(newLi.querySelector(".pj-cmt-badge"));
|
||||
if (existingLi) existingLi.replaceWith(newLi); else group.appendChild(newLi);
|
||||
updateMyTreeCounts(groupEl);
|
||||
refreshMyTasksBadge();
|
||||
}
|
||||
|
||||
|
||||
@@ -1155,14 +1463,17 @@
|
||||
});
|
||||
} catch (e) { ul.innerHTML = "<li class='pj-empty-sm'>불러오기 실패</li>"; }
|
||||
}
|
||||
attachMentionInput(el("pj-comment-input"));
|
||||
el("pj-comment-send").addEventListener("click", async function () {
|
||||
const taskId = el("pj-t-id").value;
|
||||
const inp = el("pj-comment-input");
|
||||
const body = inp.value.trim();
|
||||
if (!taskId || !body) return;
|
||||
try {
|
||||
await api("POST", "/project/api/tasks/" + taskId + "/comments", { body: body });
|
||||
await api("POST", "/project/api/tasks/" + taskId + "/comments",
|
||||
{ body: body, mentions: takeMentions(inp) });
|
||||
inp.value = "";
|
||||
clearMentions(inp);
|
||||
loadHomeComments(taskId);
|
||||
} catch (e) { alert("등록 실패: " + e.message); }
|
||||
});
|
||||
@@ -1459,7 +1770,7 @@
|
||||
"</a></li>";
|
||||
}
|
||||
function syncProjectMyTaskPanel(t, removed) {
|
||||
const groupEl = document.querySelector('.pj-project-mytasks .pj-mytree-group[data-group-id="' + t.project_id + '"]');
|
||||
const groupEl = document.querySelector('.pj-mytasks-panel .pj-mytree-group[data-group-id="' + t.project_id + '"]');
|
||||
const group = groupEl ? groupEl.querySelector(".pj-mytree-tasks") : null;
|
||||
if (!group) return; // 이 프로젝트에 내 업무가 하나도 없었으면 다음 새로고침까지 생략.
|
||||
const existingLink = group.querySelector('.pj-task-popup-link[data-task-id="' + t.id + '"]');
|
||||
@@ -1467,6 +1778,7 @@
|
||||
if (removed) {
|
||||
if (existingLi) existingLi.remove();
|
||||
updateMyTreeCounts(groupEl);
|
||||
refreshMyTasksBadge();
|
||||
return;
|
||||
}
|
||||
const wrap = document.createElement("div");
|
||||
@@ -1521,9 +1833,36 @@
|
||||
},
|
||||
];
|
||||
}
|
||||
// ── 좌측 사이드바의 접이식 "내 업무" 메뉴 ──
|
||||
// 기본은 접힘. 누르면 펼쳐지고, 업무를 하나 고르면 팝업이 열리면서 다시
|
||||
// 접힌다(예전 화면 오른쪽에 항상 떠 있던 패널을 대체).
|
||||
const myTasksToggle = el("pj-mytasks-toggle");
|
||||
const myTasksPanel = el("pj-mytasks-panel");
|
||||
function setMyTasksOpen(open) {
|
||||
if (!myTasksToggle || !myTasksPanel) return;
|
||||
myTasksPanel.hidden = !open;
|
||||
myTasksToggle.setAttribute("aria-expanded", open ? "true" : "false");
|
||||
}
|
||||
if (myTasksToggle) myTasksToggle.addEventListener("click", function () {
|
||||
setMyTasksOpen(myTasksPanel.hidden);
|
||||
});
|
||||
// 진행 중 업무 총합 배지 — 완료/삭제/재배정으로 목록이 바뀔 때마다 갱신.
|
||||
function refreshMyTasksBadge() {
|
||||
if (!myTasksToggle) return;
|
||||
const badge = myTasksToggle.querySelector(".pj-side-navbadge-open");
|
||||
if (!badge) return;
|
||||
let n = 0;
|
||||
document.querySelectorAll(".pj-mytasks-panel .pj-mtc-open").forEach(function (e2) {
|
||||
n += parseInt(e2.textContent, 10) || 0;
|
||||
});
|
||||
badge.textContent = n;
|
||||
badge.hidden = n === 0;
|
||||
}
|
||||
|
||||
function wireMyTaskPopupLink(a) {
|
||||
a.addEventListener("click", function (e) {
|
||||
e.preventDefault();
|
||||
setMyTasksOpen(false);
|
||||
const t = myTasksById[a.dataset.taskId];
|
||||
if (t) openTaskModal(t);
|
||||
});
|
||||
@@ -1535,7 +1874,7 @@
|
||||
showContextMenu(e.clientX, e.clientY, myTaskContextItems(t));
|
||||
});
|
||||
}
|
||||
document.querySelectorAll(".pj-project-mytasks .pj-task-popup-link").forEach(function (a) { wireMyTaskPopupLink(a); });
|
||||
document.querySelectorAll(".pj-mytasks-panel .pj-task-popup-link").forEach(function (a) { wireMyTaskPopupLink(a); });
|
||||
// 담당자/작성자 아이콘 = 구글 프로필 이미지(원형). 없으면 기본 아이콘.
|
||||
function avatarHtml(email, cls) {
|
||||
const url = email ? avatars[String(email).toLowerCase()] : "";
|
||||
@@ -2126,45 +2465,33 @@
|
||||
}
|
||||
|
||||
function renderBoard() {
|
||||
// pj-board(바깥)는 overflow-y:auto 스크롤 뷰포트, pj-board-canvas(안쪽)가
|
||||
// 실제 매이슨리 절대배치 캔버스 — 스크롤 컨테이너와 콘텐츠 높이 계산을
|
||||
// 분리해야 pj-board 의 높이가 부모(flex) 크기를 그대로 따라간다.
|
||||
// pj-board(바깥)는 가로 스크롤 뷰포트, pj-board-canvas(안쪽)는 세션을
|
||||
// 가로로 늘어놓는 flex 컨테이너(width:max-content) — 세션이 아무리
|
||||
// 늘어나도 아래로 접히지 않고 오른쪽으로 계속 이어진다.
|
||||
const canvas = el("pj-board-canvas");
|
||||
canvas.innerHTML = "";
|
||||
const vis = visibleTasks();
|
||||
if (boardAddStageBtn) boardAddStageBtn.hidden = !(viewScope === "project" && canManage);
|
||||
if (viewScope === "project") renderBoardByStage(canvas, vis);
|
||||
else renderBoardByName(canvas, vis);
|
||||
layoutMasonry(canvas);
|
||||
syncBoardHBar();
|
||||
}
|
||||
|
||||
// 세션(보드 컬럼) 매이슨리 배치 — 열은 왼쪽부터 순서대로 고정 배정하고,
|
||||
// 각 열은 자기 안에 쌓인 카드 높이만큼만 다음 세션을 그 밑에 이어붙인다
|
||||
// (CSS Grid처럼 행 전체를 가장 큰 세션에 맞춰 늘리지 않는다).
|
||||
function layoutMasonry(board) {
|
||||
const items = Array.prototype.slice.call(board.children).filter(function (node) {
|
||||
return node.classList.contains("pj-col");
|
||||
});
|
||||
if (!items.length) { board.style.height = "auto"; return; }
|
||||
const gap = 16, minColWidth = 220, maxCols = 4;
|
||||
const boardWidth = board.clientWidth || 1;
|
||||
const cols = Math.max(1, Math.min(maxCols, Math.floor((boardWidth + gap) / (minColWidth + gap))));
|
||||
const colWidth = (boardWidth - gap * (cols - 1)) / cols;
|
||||
const colHeights = new Array(cols).fill(0);
|
||||
items.forEach(function (node, i) {
|
||||
const c = i % cols;
|
||||
node.style.width = colWidth + "px";
|
||||
node.style.left = (c * (colWidth + gap)) + "px";
|
||||
node.style.top = colHeights[c] + "px";
|
||||
colHeights[c] += node.offsetHeight + gap;
|
||||
});
|
||||
board.style.height = Math.max.apply(null, colHeights) + "px";
|
||||
// 아사나식 가로 보드 — 세션은 CSS flex 로 왼쪽부터 나란히 놓이고, 세션이
|
||||
// 늘어나면 아래로 접히지 않고 계속 오른쪽으로 이어지며 보드가 가로로
|
||||
// 스크롤된다(예전 매이슨리 절대배치를 대체). 배치는 전부 CSS 가 하므로
|
||||
// JS 는 직접 그리는 가로 스크롤 막대만 갱신한다.
|
||||
let boardHBarUpdate = null;
|
||||
function syncBoardHBar() {
|
||||
const board = el("pj-board");
|
||||
const bar = el("pj-board-hbar");
|
||||
if (!board || !bar) return;
|
||||
if (!boardHBarUpdate) boardHBarUpdate = attachHScrollIndicator(board, bar);
|
||||
if (boardHBarUpdate) boardHBarUpdate();
|
||||
}
|
||||
let boardResizeTimer = null;
|
||||
window.addEventListener("resize", function () {
|
||||
if (currentView !== "board") return;
|
||||
clearTimeout(boardResizeTimer);
|
||||
boardResizeTimer = setTimeout(function () { layoutMasonry(el("pj-board-canvas")); }, 120);
|
||||
syncBoardHBar();
|
||||
});
|
||||
|
||||
function renderBoardByName(board, vis) {
|
||||
@@ -2233,7 +2560,6 @@
|
||||
if (!list.length && !vis.length) {
|
||||
const empty = document.createElement("div");
|
||||
empty.className = "pj-empty";
|
||||
empty.style.gridColumn = "1 / -1";
|
||||
empty.textContent = "세션이 없습니다. 위 \"+ 세션 추가\"로 만들어 보세요.";
|
||||
board.appendChild(empty);
|
||||
}
|
||||
@@ -2446,6 +2772,93 @@
|
||||
});
|
||||
}
|
||||
|
||||
// ── 보드 카드에서 바로 고치는 담당자/마감일 ──
|
||||
// 업무 팝업을 열지 않고 카드 위에서 끝낸다(아사나와 같은 조작감).
|
||||
// 후보는 "그 업무가 속한 프로젝트"의 멤버다 — 전체 프로젝트 보기에서는
|
||||
// 카드마다 프로젝트가 달라서 필요할 때 받아와 캐시한다.
|
||||
const memberCacheByProject = {};
|
||||
async function membersOfProject(pid) {
|
||||
if (pid === projectId) return members;
|
||||
if (memberCacheByProject[pid]) return memberCacheByProject[pid];
|
||||
const res = await api("GET", "/project/api/projects/" + pid + "/members");
|
||||
memberCacheByProject[pid] = res.members || [];
|
||||
return memberCacheByProject[pid];
|
||||
}
|
||||
|
||||
async function applyTaskPatch(t, patch, failMsg) {
|
||||
try {
|
||||
const res = await api("PUT", "/project/api/tasks/" + t.id, patch);
|
||||
mergeTask(res.task);
|
||||
if (myTasksById[t.id]) {
|
||||
myTasksById[t.id] = Object.assign({}, myTasksById[t.id], res.task);
|
||||
syncProjectMyTaskPanel(myTasksById[t.id]);
|
||||
}
|
||||
refreshActiveView();
|
||||
} catch (e) { showToast(failMsg + ": " + e.message, "error"); }
|
||||
}
|
||||
|
||||
async function openAssigneePicker(t, x, y) {
|
||||
let list;
|
||||
try { list = await membersOfProject(t.project_id); }
|
||||
catch (e) { showToast("멤버 조회 실패: " + e.message, "error"); return; }
|
||||
const cur = (t.assignee_email || "").toLowerCase();
|
||||
const items = [{
|
||||
label: (cur ? "" : "✓ ") + "(미지정)",
|
||||
onClick: function () { applyTaskPatch(t, { assignee_email: "", assignee_name: "" }, "담당자 변경 실패"); },
|
||||
}];
|
||||
list.forEach(function (m) {
|
||||
const email = m.user_email;
|
||||
items.push({
|
||||
label: (email.toLowerCase() === cur ? "✓ " : "") + idOf(email),
|
||||
onClick: function () {
|
||||
applyTaskPatch(t, { assignee_email: email, assignee_name: idOf(email) }, "담당자 변경 실패");
|
||||
},
|
||||
});
|
||||
});
|
||||
showContextMenu(x, y, items);
|
||||
}
|
||||
|
||||
// 마감일 — 카드 위에 작은 날짜 입력칸을 띄운다. 값이 바뀌면 바로 저장하고,
|
||||
// "지우기"로 마감일을 없앨 수 있다. 바깥을 누르면 닫힌다.
|
||||
let inlineDateEl = null;
|
||||
function closeInlineDate() {
|
||||
if (inlineDateEl) { inlineDateEl.remove(); inlineDateEl = null; }
|
||||
document.removeEventListener("mousedown", onInlineDateDown, true);
|
||||
}
|
||||
function onInlineDateDown(e) {
|
||||
if (inlineDateEl && !inlineDateEl.contains(e.target)) closeInlineDate();
|
||||
}
|
||||
function openDuePicker(t, anchorEl) {
|
||||
closeInlineDate();
|
||||
const box = document.createElement("div");
|
||||
box.className = "pj-inline-date";
|
||||
box.innerHTML = '<input type="date" value="' + (t.due_date || "") + '" />' +
|
||||
'<button type="button" class="pj-btn">지우기</button>';
|
||||
document.body.appendChild(box);
|
||||
const r = anchorEl.getBoundingClientRect();
|
||||
let left = window.scrollX + r.left;
|
||||
left = Math.min(left, window.scrollX + document.documentElement.clientWidth - box.offsetWidth - 8);
|
||||
box.style.left = Math.max(8, left) + "px";
|
||||
box.style.top = (window.scrollY + r.bottom + 4) + "px";
|
||||
inlineDateEl = box;
|
||||
const input = box.querySelector("input");
|
||||
input.addEventListener("change", function () {
|
||||
const v = input.value || null;
|
||||
closeInlineDate();
|
||||
if (v === (t.due_date || null)) return;
|
||||
applyTaskPatch(t, { due_date: v }, "마감일 변경 실패");
|
||||
});
|
||||
box.querySelector("button").addEventListener("click", function () {
|
||||
closeInlineDate();
|
||||
if (!t.due_date) return;
|
||||
applyTaskPatch(t, { due_date: null }, "마감일 변경 실패");
|
||||
});
|
||||
setTimeout(function () {
|
||||
document.addEventListener("mousedown", onInlineDateDown, true);
|
||||
try { input.focus(); if (input.showPicker) input.showPicker(); } catch (_) {}
|
||||
}, 0);
|
||||
}
|
||||
|
||||
function taskCard(t) {
|
||||
const card = document.createElement("div");
|
||||
card.className = "pj-card" + (t.completed_at ? " is-done" : "");
|
||||
@@ -2464,20 +2877,32 @@
|
||||
(t.priority && t.priority !== "normal"
|
||||
? '<span class="pj-pri pj-pri-' + t.priority + '">' + (priorityLabels[t.priority] || t.priority) + "</span>"
|
||||
: "") +
|
||||
(t.assignee_email
|
||||
? '<span class="pj-assignee">' + avatarHtml(t.assignee_email, "pj-gicon-sm") +
|
||||
escapeHtml(idOf(t.assignee_email)) + "</span>"
|
||||
: "") +
|
||||
// 담당자/마감일은 카드에서 바로 바꿀 수 있다(아래 클릭 핸들러).
|
||||
// 값이 없어도 자리는 남겨 둔다 — 카드에 마우스를 올리면 흐리게
|
||||
// 나타나서 눌러 지정할 수 있다(.is-empty).
|
||||
'<span class="pj-assignee pj-card-edit-hit pj-card-assignee' +
|
||||
(t.assignee_email ? '' : ' is-empty') + '" title="담당자 변경">' +
|
||||
avatarHtml(t.assignee_email, "pj-gicon-sm") +
|
||||
escapeHtml(t.assignee_email ? idOf(t.assignee_email) : "담당자") + "</span>" +
|
||||
(t.subtask_total
|
||||
? '<span class="pj-card-subtasks" title="하위 업무">' + (t.subtask_done || 0) + "/" + t.subtask_total + "</span>"
|
||||
: "") +
|
||||
(t.due_date ? '<span class="pj-card-due">' + t.due_date + "</span>" : "") +
|
||||
'<span class="pj-card-due pj-card-edit-hit' + (t.due_date ? '' : ' is-empty') +
|
||||
'" title="마감일 변경">' + (t.due_date ? escapeHtml(t.due_date) : "마감일") + "</span>" +
|
||||
(t.comment_count
|
||||
? '<span class="pj-card-cmt pj-cmt-badge" data-task-id="' + t.id + '" data-count="' + t.comment_count +
|
||||
'" title="댓글 ' + t.comment_count + '개">' + cmtBadge(t) + "</span>"
|
||||
: "") +
|
||||
"</div>";
|
||||
card.addEventListener("click", function () { if (canManage) openTaskModal(t); });
|
||||
card.addEventListener("click", function (e) {
|
||||
if (!canManage) return;
|
||||
// 담당자/마감일 칩을 누른 경우엔 업무 팝업 대신 그 자리 편집기를 연다.
|
||||
const hitAssignee = e.target.closest(".pj-card-assignee");
|
||||
if (hitAssignee) { e.stopPropagation(); openAssigneePicker(t, e.clientX, e.clientY); return; }
|
||||
const hitDue = e.target.closest(".pj-card-due");
|
||||
if (hitDue) { e.stopPropagation(); openDuePicker(t, hitDue); return; }
|
||||
openTaskModal(t);
|
||||
});
|
||||
// 댓글 말풍선 더블클릭 → 채팅형 댓글 팝업(내 업무 패널과 동일 구현 공용).
|
||||
if (cmt) cmt.wireBadge(card.querySelector(".pj-cmt-badge"));
|
||||
if (canManage) {
|
||||
@@ -3190,11 +3615,14 @@
|
||||
const body = inp.value.trim();
|
||||
if (!currentTaskId || !body) return;
|
||||
try {
|
||||
await api("POST", "/project/api/tasks/" + currentTaskId + "/comments", { body: body });
|
||||
await api("POST", "/project/api/tasks/" + currentTaskId + "/comments",
|
||||
{ body: body, mentions: takeMentions(inp) });
|
||||
inp.value = "";
|
||||
clearMentions(inp);
|
||||
loadComments(currentTaskId);
|
||||
} catch (e) { alert("등록 실패: " + e.message); }
|
||||
}
|
||||
attachMentionInput(el("pj-comment-input"));
|
||||
el("pj-comment-send").addEventListener("click", sendComment);
|
||||
el("pj-comment-input").addEventListener("keydown", function (e) {
|
||||
if (e.key === "Enter") { e.preventDefault(); sendComment(); }
|
||||
@@ -3821,6 +4249,8 @@
|
||||
function initDescEditor() {
|
||||
const box = el("pj-t-desc");
|
||||
if (!box) return null;
|
||||
// @ 를 누르면 멤버 목록 → 고르면 멘션 칩이 들어간다(수신함에 쌓인다).
|
||||
attachMentionEditor(box);
|
||||
const wrap = box.parentElement;
|
||||
const imgInput = el("pj-desc-img-input");
|
||||
const hint = el("pj-desc-hint");
|
||||
@@ -3844,6 +4274,7 @@
|
||||
if (!arg) return;
|
||||
}
|
||||
try { document.execCommand(cmd, false, arg); } catch (_) {}
|
||||
if (cmd === "createLink") normalizeEditorLinks(box);
|
||||
updateFmtState();
|
||||
});
|
||||
function updateFmtState() {
|
||||
@@ -3907,6 +4338,12 @@
|
||||
box.addEventListener("click", function (e) {
|
||||
if (e.target.tagName === "IMG") selectImg(e.target);
|
||||
else selectImg(null);
|
||||
// contenteditable 안의 <a> 는 브라우저가 기본으로 열지 않는다 — 직접 연다.
|
||||
const link = e.target.closest ? e.target.closest("a") : null;
|
||||
if (link && link.getAttribute("href")) {
|
||||
e.preventDefault();
|
||||
window.open(link.href, "_blank", "noopener,noreferrer");
|
||||
}
|
||||
});
|
||||
document.addEventListener("click", function (e) {
|
||||
if (selectedImg && !wrap.contains(e.target)) selectImg(null);
|
||||
@@ -4053,9 +4490,10 @@
|
||||
}
|
||||
}
|
||||
// 이미지가 아니면 서식 없는 텍스트로만 붙여넣기(외부 사이트 서식 유입 방지).
|
||||
// 단, 웹페이지 주소는 자동으로 링크(<a target="_blank">)로 바꾼다.
|
||||
e.preventDefault();
|
||||
const text = (e.clipboardData || window.clipboardData).getData("text/plain");
|
||||
insertHtmlAtCursor(escapeHtml(text).replace(/\n/g, "<br>"));
|
||||
insertHtmlAtCursor(linkifyToHtml(text));
|
||||
});
|
||||
|
||||
if (imgInput) imgInput.addEventListener("change", function () {
|
||||
@@ -4065,7 +4503,11 @@
|
||||
|
||||
return {
|
||||
setTaskId: setTaskId,
|
||||
setHtml: function (html) { selectImg(null); lastRange = null; box.innerHTML = html || ""; },
|
||||
setHtml: function (html) {
|
||||
selectImg(null); lastRange = null;
|
||||
box.innerHTML = html || "";
|
||||
normalizeEditorLinks(box);
|
||||
},
|
||||
getHtml: function () { return box.innerHTML; },
|
||||
isUploading: function () { return pendingUploads > 0; },
|
||||
setOnImageRemoved: function (fn) { onImageRemoved = fn; },
|
||||
@@ -4295,6 +4737,60 @@
|
||||
} catch (_) {}
|
||||
}
|
||||
|
||||
// ── 좌측 사이드바 "수신함" 배지 — 아직 확인하지 않은 @태그 개수 ──
|
||||
async function initMentionBadge() {
|
||||
const badge = document.getElementById("pj-mention-badge");
|
||||
if (!badge) return;
|
||||
try {
|
||||
const res = await api("GET", "/project/api/mentions/unread-count");
|
||||
const n = res.unread || 0;
|
||||
badge.textContent = n > 99 ? "99+" : n;
|
||||
badge.hidden = n === 0;
|
||||
} catch (_) {}
|
||||
}
|
||||
|
||||
// ── 수신함: "나를 태그한 업무" 목록 ──
|
||||
// 항목을 누르면 확인 처리(읽음)하고, "열기"는 그 업무의 편집 팝업까지 연다
|
||||
// (?task= — project.js 의 프로젝트 화면이 받아서 처리).
|
||||
function initMentionInbox() {
|
||||
const list = document.getElementById("pj-mention-tasks");
|
||||
const readAll = document.getElementById("pj-mentions-readall");
|
||||
const counter = document.getElementById("pj-mention-unread");
|
||||
if (!list && !readAll) return;
|
||||
function setCounter(n) {
|
||||
if (!counter) return;
|
||||
counter.textContent = n;
|
||||
counter.hidden = n <= 0;
|
||||
}
|
||||
function remaining() {
|
||||
return list ? list.querySelectorAll(".pj-mention-item.is-unread").length : 0;
|
||||
}
|
||||
async function markRead(li) {
|
||||
if (!li.classList.contains("is-unread")) return;
|
||||
try {
|
||||
await api("POST", "/project/api/mentions/read", { task_id: Number(li.dataset.taskId) });
|
||||
li.classList.remove("is-unread");
|
||||
setCounter(remaining());
|
||||
} catch (e) { showToast("처리 실패: " + e.message, "error"); }
|
||||
}
|
||||
if (readAll) readAll.addEventListener("click", async function () {
|
||||
try {
|
||||
await api("POST", "/project/api/mentions/read", {});
|
||||
if (list) list.querySelectorAll(".pj-mention-item.is-unread")
|
||||
.forEach(function (li) { li.classList.remove("is-unread"); });
|
||||
setCounter(0);
|
||||
} catch (e) { showToast("처리 실패: " + e.message, "error"); }
|
||||
});
|
||||
if (list) list.querySelectorAll(".pj-mention-item").forEach(function (li) {
|
||||
li.addEventListener("click", function (e) {
|
||||
if (e.target.closest("a")) return; // '열기' 링크는 그대로 통과
|
||||
markRead(li);
|
||||
});
|
||||
const go = li.querySelector(".pj-inbox-go");
|
||||
if (go) go.addEventListener("click", function () { markRead(li); });
|
||||
});
|
||||
}
|
||||
|
||||
// ── 알림센터 페이지 ──
|
||||
function initInbox() {
|
||||
const inbox = document.getElementById("pj-inbox");
|
||||
@@ -4352,6 +4848,7 @@
|
||||
} else if (d.ts !== baseline) {
|
||||
baseline = d.ts;
|
||||
initBell();
|
||||
initMentionBadge();
|
||||
if (softSyncProjectRef) softSyncProjectRef();
|
||||
}
|
||||
}
|
||||
@@ -4455,7 +4952,7 @@
|
||||
update();
|
||||
}
|
||||
function initScrollIndicators() {
|
||||
document.querySelectorAll(".pj-home-side, .pj-home-main, .pj-side, .pj-board")
|
||||
document.querySelectorAll(".pj-home-side, .pj-home-main, .pj-side")
|
||||
.forEach(attachScrollIndicator);
|
||||
}
|
||||
|
||||
@@ -4488,7 +4985,9 @@
|
||||
initHome();
|
||||
initProject();
|
||||
initBell();
|
||||
initMentionBadge();
|
||||
initInbox();
|
||||
initMentionInbox();
|
||||
initLiveRefresh();
|
||||
wireMyTreeToggles();
|
||||
initScrollIndicators();
|
||||
|
||||
+40
-6
@@ -63,7 +63,7 @@
|
||||
`html.parser`, 외부 라이브러리 없음). 새 업무 작성 중(저장 전, task_id 없음)
|
||||
에는 이미지 삽입이 비활성화된다 — 첨부가 업무 id 를 필요로 하기 때문.
|
||||
|
||||
## 2. 데이터 모델 (`scripts/sql/project_db_init.sql` + `..._002_*`/`..._003_*`)
|
||||
## 2. 데이터 모델 (`scripts/sql/project_db_init.sql` + `..._002_*` ~ `..._006_*`)
|
||||
|
||||
- `projects` — `parent_id`(self-FK, NULL=최상위 / NOT NULL=서브프로젝트, `ON DELETE CASCADE`), name, description, color, owner_email, start/due_date, status(active|archived).
|
||||
- `project_members` — 프로젝트↔사용자 배정. role(manager|member), `UNIQUE(project_id, user_email)`.
|
||||
@@ -78,6 +78,8 @@
|
||||
- `task_comments` — 댓글.
|
||||
- `task_attachments` — 첨부(설명란 이미지도 이걸 재사용).
|
||||
- `project_activity` — 활동 이력(created/assigned/completed/stage_changed). 메일 트리거 근거 + 타임라인.
|
||||
- `task_mentions`(006) — @태그. `(task_id, COALESCE(comment_id,0), mentioned_email)` UNIQUE,
|
||||
`source`=description|comment, `is_read`. 수신함의 "나를 태그한 업무" 목록 근거.
|
||||
|
||||
## 3. 화면 / 뷰
|
||||
|
||||
@@ -93,11 +95,19 @@
|
||||
날짜는 전부 `mm/dd(요일)` 형식(`_fmt_date_kr`)으로 표시.
|
||||
프로젝트/업무/댓글/멤버/단계가 추가·수정되면 `GET /project/api/live-version`(최근 변경 시각) 폴링으로 감지해
|
||||
해당 화면을 열어둔 모든 사용자의 페이지가 자동 새로고침(모달을 열어 입력 중이면 닫힐 때까지 대기).
|
||||
- **프로젝트** (`/project/p/{id}`): 좌측 서브프로젝트/멤버, 우측 뷰 토글.
|
||||
- **프로젝트** (`/project/p/{id}`): 좌측 사이드바(수신함 · 내 업무 · 프로젝트 트리 · 멤버) + 우측 뷰 토글.
|
||||
좌측 트리의 업무 클릭도 페이지 이동 없이 바로 팝업(이미 로드된 전체 업무 데이터 사용).
|
||||
좌측 맨 위 **수신함**(미확인 @태그 배지)과 **내 업무**(접이식, 기본 접힘 — 업무를 고르면
|
||||
팝업이 열리며 다시 접힌다)가 있다. 예전 화면 오른쪽에 항상 떠 있던 "내 업무" 패널은 없앴고
|
||||
이 메뉴가 그 역할을 대신한다(레이아웃도 3열 → 2열).
|
||||
- **달력** — FullCalendar. 업무를 시작~마감 기간으로 표시. 클릭 편집.
|
||||
- **타임라인** — vis-timeline(간트형). 기간 있는 업무만.
|
||||
- **보드** — 세션별 칸반. 카드 드래그로 세션 이동(`PUT /api/tasks/{id}` `stage_id`,
|
||||
- **보드** — 세션별 칸반. 세션은 아사나처럼 **가로로 계속 늘어난다** — 화면을 넘치면
|
||||
아래로 접히지 않고 보드가 가로로 스크롤된다(`.pj-board-canvas` = flex + `width:max-content`,
|
||||
막대는 `attachHScrollIndicator` 가 직접 그린다. 예전 매이슨리 절대배치는 제거).
|
||||
카드 안의 **담당자/마감일을 클릭하면 그 자리에서 바로 바꾼다**(담당자=멤버 목록 메뉴,
|
||||
마감일=날짜 입력칸 + 지우기). 값이 없는 칩은 카드에 마우스를 올리면 흐리게 나타난다.
|
||||
카드 드래그로 세션 이동(`PUT /api/tasks/{id}` `stage_id`,
|
||||
멀티호밍된 업무는 `POST /api/tasks/{id}/links`). 같은 세션 안에서 드래그하면
|
||||
이동이 아니라 카드 순서만 바꾼다(`PUT /api/projects/{id}/stages/{stage_id}/tasks/order`,
|
||||
세션 재정렬과 같은 패턴 — `tasks.sort_order`를 그 세션 소속만 0부터 재배정).
|
||||
@@ -124,8 +134,8 @@ docker exec -i postgres-db psql -U postgres -v app_password="$APP_PWD" \
|
||||
# PROJECT_DB_URL=postgresql://project_app:<APP_PWD>@postgres-db:5432/project_db
|
||||
# (메일 쓰려면 SMTP_* 추가)
|
||||
|
||||
# 3) 마이그레이션 002~004 적용 (첨부/알림, 세션 생성자·하위업무·멀티호밍,
|
||||
# 업무 시간, 세션 색상)
|
||||
# 3) 마이그레이션 002~006 적용 (첨부/알림, 세션 생성자·하위업무·멀티호밍,
|
||||
# 업무 시간, 세션 색상, 댓글 첨부, @태그)
|
||||
docker exec -i postgres-db psql -U postgres -d project_db \
|
||||
< scripts/sql/project_db_002_attachments_notifications.sql
|
||||
docker exec -i postgres-db psql -U postgres -d project_db \
|
||||
@@ -134,6 +144,10 @@ docker exec -i postgres-db psql -U postgres -d project_db \
|
||||
< scripts/sql/project_db_003_task_times.sql
|
||||
docker exec -i postgres-db psql -U postgres -d project_db \
|
||||
< scripts/sql/project_db_004_stage_color.sql
|
||||
docker exec -i postgres-db psql -U postgres -d project_db \
|
||||
< scripts/sql/project_db_005_comment_attachments.sql
|
||||
docker exec -i postgres-db psql -U postgres -d project_db \
|
||||
< scripts/sql/project_db_006_mentions.sql
|
||||
|
||||
# 4) 재배포 (git pull 후 반드시 --build)
|
||||
cd /opt/www/main && docker compose up -d --build web
|
||||
@@ -144,6 +158,26 @@ cd /opt/www/main && docker compose up -d --build web
|
||||
description 을 항상 HTML로 취급하기 때문). 두 번 실행하면 이중 이스케이프되니
|
||||
꼭 한 번만 돌릴 것.
|
||||
|
||||
## 5-1. 설명란 링크 · @태그(멘션)
|
||||
|
||||
- **설명란 링크** — 업무 편집 팝업의 설명란(contenteditable)에 웹주소를 붙여넣으면
|
||||
자동으로 `<a target="_blank" rel="noopener noreferrer">` 가 된다(`linkifyToHtml`).
|
||||
contenteditable 안에서는 브라우저가 링크를 기본으로 열지 않으므로 클릭을 직접 받아
|
||||
새 탭으로 연다. 서식바의 링크 버튼으로 만든 링크도 같은 속성으로 맞춘다
|
||||
(`normalizeEditorLinks`). 저장 시 sanitizer 가 `a` 의 `href/target/rel` 만 통과시킨다.
|
||||
- **@태그(멘션)** — 설명란·댓글 입력칸에서 `@` 를 누르면 등록된 프로젝트 멤버 목록이 뜨고
|
||||
(`GET /project/api/all-users`), 고르면
|
||||
· 설명란: `<span class="pj-mention" data-email="...">@아이디</span>` 칩
|
||||
· 댓글: `@아이디` 평문 + 이메일을 화면이 따로 기억해 전송 시 `mentions` 로 함께 보냄.
|
||||
서버는 설명란은 **저장될 HTML 에서 직접** 이메일을 뽑고(`store.extract_mentions_from_html`,
|
||||
화면이 보낸 목록을 믿지 않는다), 댓글은 받은 목록을 정규화해 쓴다.
|
||||
새로 태그된 사람에게만 알림(`type=mention`)이 생긴다 — 같은 자리에서 중복 저장 안 됨.
|
||||
- **수신함** (`/project/inbox`) — 위쪽 "나를 태그한 업무"(업무 1건당 1행, 최근 태그순.
|
||||
누르면 확인 처리, "열기"는 `?task=` 로 그 업무 편집 팝업까지 연다) + 아래쪽 "알림".
|
||||
API: `GET /api/mentions`, `GET /api/mentions/unread-count`, `POST /api/mentions/read`
|
||||
(`task_id` 주면 그 업무만, 없으면 전부).
|
||||
006 마이그레이션이 아직 안 돌아간 환경에서도 화면이 죽지 않게 조회/기록은 모두 감싸져 있다.
|
||||
|
||||
## 6. 댓글 · 첨부 · 알림센터 · 세션 편집 (구현됨)
|
||||
|
||||
- **댓글** `task_comments` — 업무 모달 하단. 등록/삭제(본인·관리자). 새 댓글 시 관련자 인앱 알림.
|
||||
@@ -154,5 +188,5 @@ description 을 항상 HTML로 취급하기 때문). 두 번 실행하면 이중
|
||||
|
||||
## 7. 추후 단계
|
||||
|
||||
태그 · 검색/필터 · 업무 정렬 영속화 · 멘션 · 하위 업무의 하위 업무(다단계 중첩,
|
||||
검색/필터 · 업무 라벨(태그 분류) · 하위 업무의 하위 업무(다단계 중첩,
|
||||
아사나도 UI상 1단계만 허용해 현재 의도적으로 안 함).
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
-- =====================================================================
|
||||
-- project_db 마이그레이션 006 — 멘션(@태그)
|
||||
-- =====================================================================
|
||||
-- 멱등(idempotent). DROP/TRUNCATE 없음.
|
||||
--
|
||||
-- 실행:
|
||||
-- docker exec -i postgres-db psql -U postgres -d project_db \
|
||||
-- < scripts/sql/project_db_006_mentions.sql
|
||||
--
|
||||
-- 설명란(HTML) 또는 댓글(평문)에서 @로 멤버를 지정하면 여기에 1행이 쌓인다.
|
||||
-- 수신함(/project/inbox)의 "나를 태그한 업무" 목록이 이 테이블을 읽는다.
|
||||
-- =====================================================================
|
||||
|
||||
\set ON_ERROR_STOP on
|
||||
\connect project_db
|
||||
|
||||
CREATE TABLE IF NOT EXISTS task_mentions (
|
||||
id BIGSERIAL PRIMARY KEY,
|
||||
task_id BIGINT NOT NULL REFERENCES tasks(id) ON DELETE CASCADE,
|
||||
comment_id BIGINT REFERENCES task_comments(id) ON DELETE CASCADE,
|
||||
mentioned_email TEXT NOT NULL,
|
||||
actor_email TEXT NOT NULL DEFAULT '',
|
||||
source TEXT NOT NULL DEFAULT 'description', -- description | comment
|
||||
is_read BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT now()
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_task_mentions_email
|
||||
ON task_mentions (mentioned_email, is_read, created_at DESC);
|
||||
CREATE INDEX IF NOT EXISTS idx_task_mentions_task
|
||||
ON task_mentions (task_id);
|
||||
|
||||
-- 같은 곳(설명란 = comment_id NULL, 또는 같은 댓글)에서 같은 사람을 여러 번
|
||||
-- 저장하지 않는다. comment_id 가 NULL 이면 UNIQUE 제약이 안 걸리므로
|
||||
-- COALESCE 표현식 인덱스를 쓴다(NULL = 설명란 멘션).
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS uq_task_mentions_once
|
||||
ON task_mentions (task_id, COALESCE(comment_id, 0), mentioned_email);
|
||||
|
||||
GRANT SELECT, INSERT, UPDATE, DELETE ON task_mentions TO project_app;
|
||||
GRANT USAGE, SELECT ON ALL SEQUENCES IN SCHEMA public TO project_app;
|
||||
|
||||
SELECT 'project_db 006 mentions ready' AS status;
|
||||
Reference in New Issue
Block a user