From ecc64052993f3695679d79bb8ea7a54f678a3ff8 Mon Sep 17 00:00:00 2001 From: king Date: Tue, 13 Oct 2026 13:10:57 +0900 Subject: [PATCH] =?UTF-8?q?feat(project):=20=EC=84=B8=EB=B6=80=20=EC=97=85?= =?UTF-8?q?=EB=AC=B4=20=ED=98=91=EC=97=85=EC=9E=90=20=EB=93=B1=EB=A1=9D?= =?UTF-8?q?=C2=B7=EB=8C=80=EC=8B=9C=EB=B3=B4=EB=93=9C=20=ED=94=84=EB=A1=9C?= =?UTF-8?q?=EC=A0=9D=ED=8A=B8=EB=B3=84=C2=B7=EB=A7=88=EA=B0=90=20=EC=A7=80?= =?UTF-8?q?=EB=82=9C=20=EC=97=85=EB=AC=B4=20=EC=95=8C=EB=A6=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 세부 업무를 만들 때 협업자도 같이(업무 창 추가 칸·보드 카드 새 줄) — POST tasks 의 followers, 비멤버면 400 - 보드 카드 세부 업무 줄에도 협업자 아이콘, 업무 창 줄의 빈 협업자 아이콘은 늘 보이게 - 협업자 메뉴는 고를 때마다 다시 열려 여러 명을 이어서 지정(openFollowerMenu 공용) - 대시보드 "업무 합계(프로젝트별)" 카드 — 완료 상태별 카드 왼쪽, 프로젝트별 완료/전체·완료율 - 마감 지난 내 업무 위쪽 알림(ERP 모든 화면, erp-overdue.js, GET /project/api/my-overdue) — 닫으면 1시간 뒤 다시, 새로 지난 업무는 바로 Co-Authored-By: Claude Opus 5.5 --- CLAUDE.md | 2 +- .../notice/templates/notice/admin.html | 4 +- app/modules/project/db.py | 15 ++ app/modules/project/router.py | 30 ++- .../templates/project/goal_meeting.html | 4 +- .../project/templates/project/goals.html | 4 +- .../project/templates/project/help.html | 2 +- .../project/templates/project/inbox.html | 4 +- .../project/templates/project/mytasks.html | 4 +- .../project/templates/project/notifier.html | 4 +- .../project/templates/project/project.html | 5 +- .../project/templates/project/trash.html | 4 +- app/static/erp-overdue.css | 33 +++ app/static/erp-overdue.js | 106 +++++++++ app/static/project.css | 44 +++- app/static/project.js | 213 +++++++++++++++--- app/templates/admin.html | 2 + app/templates/erp_base.html | 3 + app/templates/main.html | 2 + docs/PROJECT_MODULE.md | 21 ++ tests/js/README.md | 8 + tests/js/overdue_ui.test.js | 74 ++++++ tests/js/project_ui.test.js | 62 +++++ tests/test_project_module.py | 31 +++ 24 files changed, 628 insertions(+), 53 deletions(-) create mode 100644 app/static/erp-overdue.css create mode 100644 app/static/erp-overdue.js create mode 100644 tests/js/overdue_ui.test.js diff --git a/CLAUDE.md b/CLAUDE.md index b05b6ce..8a384e4 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -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/{no}/images` 에 base64 data URI + `image_upload_type=A` — NNEditor 업로드 경로를 PUT `detail_image` 에 넣는 방식은 적용 안 됨), 옵션(생성/이름·썸네일·표시방식 수정/삭제)·품목(자체코드·추가금액·진열·판매)을 수정. 카페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)·프로젝트 색상(32색 — 아사나 16색 + 진한 16색, 수정 창 12열)·아이콘(`projects.icon`, Material Symbols 42종, 마이그레이션 011 + [아사나 아이콘] 탭 33종 `"asana:"+이름`, 채워진 모양 전용 부분 글꼴 `material-symbols-asana.woff2`)·작업(`tasks`: 담당자·우선순위·시작/마감)·진행단계(`project_stages` 칸반, 새 프로젝트는 섹션 없이 시작 — `create_project(seed_stages=True)` 일 때만 기본 4단계, 섹션 머리는 모두 `#f3f3f3` — 섹션별 색 지정 없음, 섹션 이름 굵게, 섹션 기본 담당자 `default_assignee_email` — 담당자 빈 작업을 그 섹션에 만들거나 옮기면 자동 배정, 마이그레이션 009)·멤버 배정(`project_members`)·활동이력(`project_activity`). 첫 화면(`/project/`)은 **내 작업 목록**(프로젝트 홈 카드 화면은 폐지). 프로젝트 화면은 캘린더(FullCalendar)/타임라인(vis-timeline)/보드/목록/대시보드 뷰 토글. 좌측 사이드바는 수신함·내 작업·휴지통·프로젝트 화면 공용(`templates/project/_side.html` + 프로젝트 목록 동작 `initSideTree`, 새 프로젝트/수정 모달 `_side_modals.html`) — 프로젝트 목록(순서 변경·✎·×)은 어느 화면에서나 같다. 보드는 아사나처럼 섹션이 가로로 계속 늘어나고(넘치면 가로 스크롤) 카드의 담당자·마감일을 클릭해 그 자리에서 바꾼다. 좌측 사이드바에 수신함·전체 보기(Pro user 이상 — 예전 오른쪽 위 "전체 프로젝트" 토글, `?scope=all`)·내 작업(접이식) 메뉴. 설명란 서식 도구에 글자 색·크기(서버는 span style 의 color·font-size 만 허용, `desc_inline_style`). 설명란은 주소 붙여넣기 시 자동 링크, 설명란·댓글에서 @로 멤버를 태그하면 (`task_mentions`, 마이그레이션 006) 수신함에 그 작업이 쌓인다. 진입 권한키 `project`(관리자 페이지 토글로 직원별 부여, admin 자동). **관리자 등급 4단계(2026-10-12) — 수퍼관리자(`SUPER_ADMIN_EMAIL` 한 명 고정, 추가 불가) > Admin(`role=admin`) > Pro user(`role=pro`) > User** — 판단은 `access.is_pro`(Pro user 이상)·`access.is_project_admin`(Admin 이상), 라우터 `_require_pro`, 화면 `pj_pro`·`pj_admin`(`_role_ctx`, `is_admin` 은 ERP 상단 관리자 메뉴용 그대로). pro 는 프로젝트 모듈 밖에서는 user 와 같다. 새 프로젝트·프로젝트 이름/색/아이콘/소유자 수정·멤버 배정(자기가 멤버인 프로젝트)·사이드바 순서·남의 댓글 수정/삭제·휴지통·전체 보기·담당자별 합계·전체 멤버 = Pro user 이상, 프로젝트·섹션 삭제 = Admin 이상 또는 만든 사람, 작업 삭제·서브프로젝트 = 멤버 누구나(표는 docs/PROJECT_MODULE.md 6-14). 배정 멤버(또는 owner)만 그 프로젝트를 조회 — **관리자도 멤버가 아니면 안 보임, 예외는 슈퍼관리자뿐**(2026-10-07, `access.sees_all_projects`; 사이드바 목록·검색·휴지통·알림도 같은 기준, 화면·API 모두 비멤버 403)하고 서브프로젝트/작업/단계 CRUD — URL 의 섹션·부모 작업이 그 프로젝트 것인지 서버가 검증. 실시간 반영은 `project_live_version` 카운터(마이그레이션 007, 미적용 시 MAX 폴백). 사이드바 전체 검색(`/api/search`, 제목·설명·댓글, pg_trgm) + 프로젝트/내 작업 필터 바(찾기·상태·담당자·마감·우선순위·정렬, 클라이언트 필터). 협업자(`task_followers`, 자동 팔로우: 만든 사람·담당자·댓글·@태그) — 완료·댓글 알림은 담당자+협업자에게만. 나를 태그하거나 작업이 배정되면 프로젝트 화면 가운데 아래에 깜박이는 큰 팝업(닫기 전까지, `initTaskAlerts` + `GET /api/notifications/alerts`). 작업 삭제는 휴지통(`project_trash`, 마이그레이션 010) — 삭제 직전 스냅샷 3개월 보관, Pro user 이상만 보기·복구(`/project/trash`). 권한은 **지금 기준 공통 모듈 `access.py`**(목록·배지·알림·멘션·메일 수신자·삭제·댓글 수정까지 — 멤버에서 빠지면 기록이 있어도 안 보이고 알림도 없음), 소유자 변경은 Pro user 이상, 연결(멀티호밍)된 작업은 연결된 프로젝트 멤버에게 읽기 전용(docs/PROJECT_MODULE.md 6-10). 연간 목표(마이그레이션 013, `goal_*` 테이블) — 사이드바 "목표" → 연도 펼침 → `/project/goals/{연도}` 에 매출(목표·실적·달성)·로아스 월별 숫자 + 업무 영역(상품·마케팅·컨텐츠·유통 등)별 연간·월별 글, 조회는 전원·입력(주차별 목표·연도 추가/삭제 포함)은 Pro user 이상. 3·6·9·12월 오른쪽 1~4분기 칸(글 칸 13=1분기·15=2분기·14=3분기·16=4분기 — 예전 반기 칸 번호 재사용, 15·16 은 마이그레이션 017) + 분기 월 칸 접기 애니메이션(localStorage `pj_goal_fold_q`, 표는 `width:1px`+`table-layout:fixed`), 영역·줄 이름 클릭 바로 수정, **엑셀식 칸 병합**(마우스로 끌어 사각형 선택 → 우클릭 셀 병합/병합 해제, 같은 영역 안 세로 `row_span` + 같은 분기 월 칸 가로, 글은 왼쪽 위 칸 — `goal_cell_merges`, 마이그레이션 014·015·017), 3열 줄 추가는 같은 항목 칸(2열) 안에(`goal_rows.label_cont`, 마이그레이션 016), 구조 변경은 새로고침 없이 제자리 다시 그리기(`refreshTable`)+애니메이션, 로아스는 % 표기. 월 머리 → **주간 회의록**(`/project/goals/{연도}/meetings/{월}`, 프로젝트 권한자 **누구나 수정** — Pro user 이상 [회의 완료](`completed_at`, 마이그레이션 022)면 잠금(지난주 결과는 다음 주 회의록이 열려 있는 동안 허용), 삭제·완료·완료 해제는 Pro user 이상, 표 첫 열 머리 글자 "구분", 주차 탭 — **주차는 그 달 안**(`store.month_weeks`: 1일이 월~금이면 1일~일요일이 1주차, 토·일이면 1일~다음 주 일요일, 그 뒤 월~일, 말일이 월·화면 앞 주차에 붙음, 회의록 `week_start` = 주차 시작일, 마이그레이션 020), `goal_meetings`·`goal_meeting_items` 마이그레이션 015 — 지난주 = **바로 앞 주차**(`store.prev_week_period`) 회의록의 같은 연결키 줄(`line_key`, 마이그레이션 018 — 생성 순서·이름 변경과 무관, 이름 추정 연결 금지)로 리뷰(열: 주요 업무·정량 목표 ‖ 전주 업무·결과(글, `result_note` 020)·전주 목표·결과 — 정량 목표·결과는 숫자면 원 정수 칸, 아니면 글 칸 `target_text`·`result_text`(예: 20개, 021)), 실적 조회 장애는 0원이 아니라 "미확인", 위에 목표 표 그 달 열 글을 영역별 "N월 계획" 카드로, 참석자 옆 [회의록 보드] = 그 주차의 빈 Google 슬라이드를 독립 창으로(오른쪽 🔗 아이콘 = 그 보드 링크 복사)(공유 드라이브 `MEETING_BOARD_FOLDER_ID`, 없으면 만듦, `app/integrations/google_slides.py`, Drive appProperties 로 주차 연결 — Drive·Slides 권한 토큰 필요), 표를 스크롤해도 보이는 머리 영역 3칸 = ① 월 계획 + 머리 줄에 숫자 4개 작게 1행(월 목표 매출·월 누적 목표 매출(목표 표 **주차별 매출 목표** `goal_week_targets` 1주차~이 주차 합 — 목표 표 매출 목표 월 칸을 누르면 입력 창 — 월 전체 목표는 직접 입력(주차 합계와 별개), 맨 아래 차이 = 월 목표 − 주차 합계)·월 누적 실적(1일~오늘)·누적 목표 대비 차액·%) | ② 결정 사항·메모 | ③ "N주차 작업 등록" 표(제목·담당자·프로젝트·섹션 → [적용] = 서버가 그 프로젝트에 작업 생성, `initMeetQuickTasks` — 주차별 서버 표 `goal_meeting_tasks`(마이그레이션 025)라 모두가 같이 보고, 남의 프로젝트 이름은 가림, 완료 프로젝트·섹션은 목록에서 뺌, 작업 칸(마이그레이션 026 `parent_task_id`) = 이미 있는 작업을 고르면 그 작업의 세부 작업으로 등록, 등록된 줄 제목 = 오른쪽 작업 창(편집, 저장 대기), [크게 열기] = 같은 표를 넓은 창으로), 실적 모듈 `performance_store` 매출은 머리 카드에만 읽기 전용 — 줄(쇼핑몰)별 자동 결과·이번주 실적·연결 배지·쇼핑몰 연결 메뉴는 폐지, 지난주 결과는 늘 직접 입력). 모든 열 너비 끌어서 조절(localStorage `pj_goal_col_w`), 세로 스크롤 틀 고정은 머리 줄+매출·로아스 줄까지, 항목 칸 +·우클릭으로 줄 위/아래 추가·삭제, 회의록 "주요 업무" 칸 우클릭 위/아래 줄 추가 = 항목 칸은 그대로 그 항목 안에(마이그레이션 027 `label_cont`, 항목 칸 나누기), 회의록 줄 작업은 새로고침 없이 제자리 다시 그리기(`refreshMeeting`)+애니메이션, 구분(구역) 칸 우클릭·⋯ = 구역 통째로 위/아래(`move-section`). 마감 알림(`reminders.py` 데몬 스레드, 영업일 09시, D-1/당일/지연, `task_reminders` 로 중복 방지, `PROJECT_REMINDER_*` env) — 마이그레이션 008. 라우터 핸들러는 동기 DB 라 `def` 로 둔다(`async def` 금지). 말풍선은 전부 아사나식 공용 말풍선(`.pj-hovertip`) — 새 기능도 `title=`/`data-tip=` 만 달고 별도 툴팁 구현 금지. 멤버 배정 후보는 `project` 권한 보유 등록 사용자에서 자동 목록(`GET /project/api/assignable-users`). 작업 배정·완료 시 관리자에게 메일(`app/mail.py` stdlib smtplib, `SMTP_*`+`PROJECT_NOTIFY_EMAIL` env, 미설정 시 조용히 skip, `BackgroundTasks` 비동기). 목표 표·회의록 칸 저장은 공용 `createFieldSaver`(같은 칸 요청 직렬화·보낸 값만 저장됨·실패 시 초안 유지·localStorage 초안 백업, 저장 실패면 구조 변경 중단 — docs/PROJECT_MODULE.md 6-9-3), 구역·항목 메뉴는 우클릭 + ⋮ 버튼(키보드·터치). ERP 메뉴 이름은 "Project"(`app/main.py` 모듈 목록 title). **PC 알림 프로그램**(`desktop/notifier/`, C# .NET Framework 4.8 WinForms exe 하나·트레이 상주, 마이그레이션 023 `notifier_links`·`notifier_tokens`) — 브라우저가 뒤에 있어도 태그·배정 알림을 웹 팝업과 같은 모양으로 화면 위에. 브라우저 `/project/notifier?code=` 승인으로 PC별 토큰(서버는 SHA-256 만, PC 는 DPAPI), `GET /project/api/notifier/alerts`(Bearer)는 웹 알림과 같은 `_alerts_payload`, 토큰마다 지금 사용자·권한 재확인. 프로그램이 돌고 있으면(최근 3분 확인, `notifier_active`) 웹 큰 팝업은 쉰다(`desktop: true`). 압축·난독화 금지(백신 오탐), 빌드 `desktop/notifier/build.ps1`, 상세 docs/PROJECT_MODULE.md 6-11. 댓글·답글 입력칸은 Enter 등록·Shift+Enter 줄바꿈(textarea), 설명란 이미지 더블클릭 = 별도 창 이미지 보기(확대·축소·끌어 이동). 작업 창은 **저장 버튼 없이 실시간 저장**(칸별 PUT, `saveField`/`saveChain`, 새 작업은 제목이 생기는 순간 생성). 댓글 답글·이모티콘 반응(마이그레이션 012 `task_comments.parent_id`·`task_comment_reactions`, 미적용 시 버튼 숨김·API 503), 완료 이력 줄은 `project_activity` completed 를 댓글 사이에 표시(댓글 수 제외), 댓글 `@아이디` 는 아이콘+이름 칩. 수신함은 확인 안 한 태그·읽지 않은 알림만(2026-10-08) — [확인] 버튼 없이 줄을 누르면 읽음·확인 처리(같은 작업 줄 함께) + 페이지 이동 없이 오른쪽 iframe 패널, 다른 줄을 고르거나 패널을 닫으면 그 줄은 목록에서 빠짐. 용어는 **"업무"**(2026-10-13 "작업"에서 다시 통일 — 화면·메시지·알림 제목, 코드·DB 는 그대로)·"세부 업무"·"메인 업무 추가". 섹션 제목 오른쪽 담당자 아이콘 = 그 자리에서 기본 담당자 지정, 업무 창 세부 업무 줄 담당자 오른쪽 = 협업자 지정, 댓글 이모티콘 반응 = 댓글 쓴 사람에게 알림(`type=reaction`), 왼쪽 전체 보기 = 기본 대시보드, 대시보드 업무 목록 패널에서 연 업무 창은 패널 왼쪽에(docs/PROJECT_MODULE.md 6-16). 패널(`/project/p/{pid}?task=&embed=1`, `html.pj-embed`). 상단 바 화면 배율 토글(`html.pj-ui-scale` → `.erp-app` zoom .75, 2880×1620·200%용) — **팝업은 반드시 `document.body` 에 붙인다**(배율 안의 fixed 좌표는 어긋남). 상세는 `docs/PROJECT_MODULE.md` +- 프로젝트 관리 (`app/modules/project/`, `project_db`) — 아사나식. 프로젝트/서브프로젝트(self-FK `parent_id`, CASCADE)·프로젝트 색상(32색 — 아사나 16색 + 진한 16색, 수정 창 12열)·아이콘(`projects.icon`, Material Symbols 42종, 마이그레이션 011 + [아사나 아이콘] 탭 33종 `"asana:"+이름`, 채워진 모양 전용 부분 글꼴 `material-symbols-asana.woff2`)·작업(`tasks`: 담당자·우선순위·시작/마감)·진행단계(`project_stages` 칸반, 새 프로젝트는 섹션 없이 시작 — `create_project(seed_stages=True)` 일 때만 기본 4단계, 섹션 머리는 모두 `#f3f3f3` — 섹션별 색 지정 없음, 섹션 이름 굵게, 섹션 기본 담당자 `default_assignee_email` — 담당자 빈 작업을 그 섹션에 만들거나 옮기면 자동 배정, 마이그레이션 009)·멤버 배정(`project_members`)·활동이력(`project_activity`). 첫 화면(`/project/`)은 **내 작업 목록**(프로젝트 홈 카드 화면은 폐지). 프로젝트 화면은 캘린더(FullCalendar)/타임라인(vis-timeline)/보드/목록/대시보드 뷰 토글. 좌측 사이드바는 수신함·내 작업·휴지통·프로젝트 화면 공용(`templates/project/_side.html` + 프로젝트 목록 동작 `initSideTree`, 새 프로젝트/수정 모달 `_side_modals.html`) — 프로젝트 목록(순서 변경·✎·×)은 어느 화면에서나 같다. 보드는 아사나처럼 섹션이 가로로 계속 늘어나고(넘치면 가로 스크롤) 카드의 담당자·마감일을 클릭해 그 자리에서 바꾼다. 좌측 사이드바에 수신함·전체 보기(Pro user 이상 — 예전 오른쪽 위 "전체 프로젝트" 토글, `?scope=all`)·내 작업(접이식) 메뉴. 설명란 서식 도구에 글자 색·크기(서버는 span style 의 color·font-size 만 허용, `desc_inline_style`). 설명란은 주소 붙여넣기 시 자동 링크, 설명란·댓글에서 @로 멤버를 태그하면 (`task_mentions`, 마이그레이션 006) 수신함에 그 작업이 쌓인다. 진입 권한키 `project`(관리자 페이지 토글로 직원별 부여, admin 자동). **관리자 등급 4단계(2026-10-12) — 수퍼관리자(`SUPER_ADMIN_EMAIL` 한 명 고정, 추가 불가) > Admin(`role=admin`) > Pro user(`role=pro`) > User** — 판단은 `access.is_pro`(Pro user 이상)·`access.is_project_admin`(Admin 이상), 라우터 `_require_pro`, 화면 `pj_pro`·`pj_admin`(`_role_ctx`, `is_admin` 은 ERP 상단 관리자 메뉴용 그대로). pro 는 프로젝트 모듈 밖에서는 user 와 같다. 새 프로젝트·프로젝트 이름/색/아이콘/소유자 수정·멤버 배정(자기가 멤버인 프로젝트)·사이드바 순서·남의 댓글 수정/삭제·휴지통·전체 보기·담당자별 합계·전체 멤버 = Pro user 이상, 프로젝트·섹션 삭제 = Admin 이상 또는 만든 사람, 작업 삭제·서브프로젝트 = 멤버 누구나(표는 docs/PROJECT_MODULE.md 6-14). 배정 멤버(또는 owner)만 그 프로젝트를 조회 — **관리자도 멤버가 아니면 안 보임, 예외는 슈퍼관리자뿐**(2026-10-07, `access.sees_all_projects`; 사이드바 목록·검색·휴지통·알림도 같은 기준, 화면·API 모두 비멤버 403)하고 서브프로젝트/작업/단계 CRUD — URL 의 섹션·부모 작업이 그 프로젝트 것인지 서버가 검증. 실시간 반영은 `project_live_version` 카운터(마이그레이션 007, 미적용 시 MAX 폴백). 사이드바 전체 검색(`/api/search`, 제목·설명·댓글, pg_trgm) + 프로젝트/내 작업 필터 바(찾기·상태·담당자·마감·우선순위·정렬, 클라이언트 필터). 협업자(`task_followers`, 자동 팔로우: 만든 사람·담당자·댓글·@태그) — 완료·댓글 알림은 담당자+협업자에게만. 나를 태그하거나 작업이 배정되면 프로젝트 화면 가운데 아래에 깜박이는 큰 팝업(닫기 전까지, `initTaskAlerts` + `GET /api/notifications/alerts`). 작업 삭제는 휴지통(`project_trash`, 마이그레이션 010) — 삭제 직전 스냅샷 3개월 보관, Pro user 이상만 보기·복구(`/project/trash`). 권한은 **지금 기준 공통 모듈 `access.py`**(목록·배지·알림·멘션·메일 수신자·삭제·댓글 수정까지 — 멤버에서 빠지면 기록이 있어도 안 보이고 알림도 없음), 소유자 변경은 Pro user 이상, 연결(멀티호밍)된 작업은 연결된 프로젝트 멤버에게 읽기 전용(docs/PROJECT_MODULE.md 6-10). 연간 목표(마이그레이션 013, `goal_*` 테이블) — 사이드바 "목표" → 연도 펼침 → `/project/goals/{연도}` 에 매출(목표·실적·달성)·로아스 월별 숫자 + 업무 영역(상품·마케팅·컨텐츠·유통 등)별 연간·월별 글, 조회는 전원·입력(주차별 목표·연도 추가/삭제 포함)은 Pro user 이상. 3·6·9·12월 오른쪽 1~4분기 칸(글 칸 13=1분기·15=2분기·14=3분기·16=4분기 — 예전 반기 칸 번호 재사용, 15·16 은 마이그레이션 017) + 분기 월 칸 접기 애니메이션(localStorage `pj_goal_fold_q`, 표는 `width:1px`+`table-layout:fixed`), 영역·줄 이름 클릭 바로 수정, **엑셀식 칸 병합**(마우스로 끌어 사각형 선택 → 우클릭 셀 병합/병합 해제, 같은 영역 안 세로 `row_span` + 같은 분기 월 칸 가로, 글은 왼쪽 위 칸 — `goal_cell_merges`, 마이그레이션 014·015·017), 3열 줄 추가는 같은 항목 칸(2열) 안에(`goal_rows.label_cont`, 마이그레이션 016), 구조 변경은 새로고침 없이 제자리 다시 그리기(`refreshTable`)+애니메이션, 로아스는 % 표기. 월 머리 → **주간 회의록**(`/project/goals/{연도}/meetings/{월}`, 프로젝트 권한자 **누구나 수정** — Pro user 이상 [회의 완료](`completed_at`, 마이그레이션 022)면 잠금(지난주 결과는 다음 주 회의록이 열려 있는 동안 허용), 삭제·완료·완료 해제는 Pro user 이상, 표 첫 열 머리 글자 "구분", 주차 탭 — **주차는 그 달 안**(`store.month_weeks`: 1일이 월~금이면 1일~일요일이 1주차, 토·일이면 1일~다음 주 일요일, 그 뒤 월~일, 말일이 월·화면 앞 주차에 붙음, 회의록 `week_start` = 주차 시작일, 마이그레이션 020), `goal_meetings`·`goal_meeting_items` 마이그레이션 015 — 지난주 = **바로 앞 주차**(`store.prev_week_period`) 회의록의 같은 연결키 줄(`line_key`, 마이그레이션 018 — 생성 순서·이름 변경과 무관, 이름 추정 연결 금지)로 리뷰(열: 주요 업무·정량 목표 ‖ 전주 업무·결과(글, `result_note` 020)·전주 목표·결과 — 정량 목표·결과는 숫자면 원 정수 칸, 아니면 글 칸 `target_text`·`result_text`(예: 20개, 021)), 실적 조회 장애는 0원이 아니라 "미확인", 위에 목표 표 그 달 열 글을 영역별 "N월 계획" 카드로, 참석자 옆 [회의록 보드] = 그 주차의 빈 Google 슬라이드를 독립 창으로(오른쪽 🔗 아이콘 = 그 보드 링크 복사)(공유 드라이브 `MEETING_BOARD_FOLDER_ID`, 없으면 만듦, `app/integrations/google_slides.py`, Drive appProperties 로 주차 연결 — Drive·Slides 권한 토큰 필요), 표를 스크롤해도 보이는 머리 영역 3칸 = ① 월 계획 + 머리 줄에 숫자 4개 작게 1행(월 목표 매출·월 누적 목표 매출(목표 표 **주차별 매출 목표** `goal_week_targets` 1주차~이 주차 합 — 목표 표 매출 목표 월 칸을 누르면 입력 창 — 월 전체 목표는 직접 입력(주차 합계와 별개), 맨 아래 차이 = 월 목표 − 주차 합계)·월 누적 실적(1일~오늘)·누적 목표 대비 차액·%) | ② 결정 사항·메모 | ③ "N주차 작업 등록" 표(제목·담당자·프로젝트·섹션 → [적용] = 서버가 그 프로젝트에 작업 생성, `initMeetQuickTasks` — 주차별 서버 표 `goal_meeting_tasks`(마이그레이션 025)라 모두가 같이 보고, 남의 프로젝트 이름은 가림, 완료 프로젝트·섹션은 목록에서 뺌, 작업 칸(마이그레이션 026 `parent_task_id`) = 이미 있는 작업을 고르면 그 작업의 세부 작업으로 등록, 등록된 줄 제목 = 오른쪽 작업 창(편집, 저장 대기), [크게 열기] = 같은 표를 넓은 창으로), 실적 모듈 `performance_store` 매출은 머리 카드에만 읽기 전용 — 줄(쇼핑몰)별 자동 결과·이번주 실적·연결 배지·쇼핑몰 연결 메뉴는 폐지, 지난주 결과는 늘 직접 입력). 모든 열 너비 끌어서 조절(localStorage `pj_goal_col_w`), 세로 스크롤 틀 고정은 머리 줄+매출·로아스 줄까지, 항목 칸 +·우클릭으로 줄 위/아래 추가·삭제, 회의록 "주요 업무" 칸 우클릭 위/아래 줄 추가 = 항목 칸은 그대로 그 항목 안에(마이그레이션 027 `label_cont`, 항목 칸 나누기), 회의록 줄 작업은 새로고침 없이 제자리 다시 그리기(`refreshMeeting`)+애니메이션, 구분(구역) 칸 우클릭·⋯ = 구역 통째로 위/아래(`move-section`). 마감 알림(`reminders.py` 데몬 스레드, 영업일 09시, D-1/당일/지연, `task_reminders` 로 중복 방지, `PROJECT_REMINDER_*` env) — 마이그레이션 008. 라우터 핸들러는 동기 DB 라 `def` 로 둔다(`async def` 금지). 말풍선은 전부 아사나식 공용 말풍선(`.pj-hovertip`) — 새 기능도 `title=`/`data-tip=` 만 달고 별도 툴팁 구현 금지. 멤버 배정 후보는 `project` 권한 보유 등록 사용자에서 자동 목록(`GET /project/api/assignable-users`). 작업 배정·완료 시 관리자에게 메일(`app/mail.py` stdlib smtplib, `SMTP_*`+`PROJECT_NOTIFY_EMAIL` env, 미설정 시 조용히 skip, `BackgroundTasks` 비동기). 목표 표·회의록 칸 저장은 공용 `createFieldSaver`(같은 칸 요청 직렬화·보낸 값만 저장됨·실패 시 초안 유지·localStorage 초안 백업, 저장 실패면 구조 변경 중단 — docs/PROJECT_MODULE.md 6-9-3), 구역·항목 메뉴는 우클릭 + ⋮ 버튼(키보드·터치). ERP 메뉴 이름은 "Project"(`app/main.py` 모듈 목록 title). **PC 알림 프로그램**(`desktop/notifier/`, C# .NET Framework 4.8 WinForms exe 하나·트레이 상주, 마이그레이션 023 `notifier_links`·`notifier_tokens`) — 브라우저가 뒤에 있어도 태그·배정 알림을 웹 팝업과 같은 모양으로 화면 위에. 브라우저 `/project/notifier?code=` 승인으로 PC별 토큰(서버는 SHA-256 만, PC 는 DPAPI), `GET /project/api/notifier/alerts`(Bearer)는 웹 알림과 같은 `_alerts_payload`, 토큰마다 지금 사용자·권한 재확인. 프로그램이 돌고 있으면(최근 3분 확인, `notifier_active`) 웹 큰 팝업은 쉰다(`desktop: true`). 압축·난독화 금지(백신 오탐), 빌드 `desktop/notifier/build.ps1`, 상세 docs/PROJECT_MODULE.md 6-11. 댓글·답글 입력칸은 Enter 등록·Shift+Enter 줄바꿈(textarea), 설명란 이미지 더블클릭 = 별도 창 이미지 보기(확대·축소·끌어 이동). 작업 창은 **저장 버튼 없이 실시간 저장**(칸별 PUT, `saveField`/`saveChain`, 새 작업은 제목이 생기는 순간 생성). 댓글 답글·이모티콘 반응(마이그레이션 012 `task_comments.parent_id`·`task_comment_reactions`, 미적용 시 버튼 숨김·API 503), 완료 이력 줄은 `project_activity` completed 를 댓글 사이에 표시(댓글 수 제외), 댓글 `@아이디` 는 아이콘+이름 칩. 수신함은 확인 안 한 태그·읽지 않은 알림만(2026-10-08) — [확인] 버튼 없이 줄을 누르면 읽음·확인 처리(같은 작업 줄 함께) + 페이지 이동 없이 오른쪽 iframe 패널, 다른 줄을 고르거나 패널을 닫으면 그 줄은 목록에서 빠짐. 용어는 **"업무"**(2026-10-13 "작업"에서 다시 통일 — 화면·메시지·알림 제목, 코드·DB 는 그대로)·"세부 업무"·"메인 업무 추가". 섹션 제목 오른쪽 담당자 아이콘 = 그 자리에서 기본 담당자 지정, 업무 창 세부 업무 줄 담당자 오른쪽 = 협업자 지정, 댓글 이모티콘 반응 = 댓글 쓴 사람에게 알림(`type=reaction`), 왼쪽 전체 보기 = 기본 대시보드, 대시보드 업무 목록 패널에서 연 업무 창은 패널 왼쪽에(docs/PROJECT_MODULE.md 6-16). 세부 업무를 만들 때(업무 창 추가 칸·보드 카드 새 줄) 협업자도 같이(`POST …/tasks` 의 `followers`, 비멤버 400), 보드 카드 세부 업무 줄에도 협업자 아이콘, 대시보드 "업무 합계(프로젝트별)" 카드, **마감 지난 내 업무 위쪽 알림**(`static/erp-overdue.js`, ERP 모든 화면, `GET /project/api/my-overdue`, 닫으면 1시간 뒤 다시 — 새로 지난 업무는 바로)(6-17). 패널(`/project/p/{pid}?task=&embed=1`, `html.pj-embed`). 상단 바 화면 배율 토글(`html.pj-ui-scale` → `.erp-app` zoom .75, 2880×1620·200%용) — **팝업은 반드시 `document.body` 에 붙인다**(배율 안의 fixed 좌표는 어긋남). 상세는 `docs/PROJECT_MODULE.md` - 실적 (`app/modules/performance/`, `performance_db`) — 쇼핑몰 통합 매출. 네 영역 분리: ① 수집 `adapters/`(쇼핑몰 하나 = 어댑터 파일 하나 + `registry.py` 한 줄 + SQL seed 한 줄) + `sync.py`(공통 동기화, 같은 쇼핑몰 동시 실행 차단, 쇼핑몰별 실패 격리) ② 보안 `security/`(AES-256-GCM, 키 버전, 비밀값 가리기) + `credentials.py` ③ 계산 `calc.py`(주=월~일, 수수료 반올림은 `commission()` 한 곳, 요율 이력) + `db.py` ④ 화면 `dashboard.py`/`router.py`/템플릿. 쇼핑몰 API 인증정보는 `.env` 가 아니라 **설정 화면에서 입력 → 마스터 키 `APP_ENCRYPTION_KEY` 로 암호화해 DB 저장**, secret 원문은 화면으로 다시 보내지 않는다. 쇼핑몰 API 는 백엔드에서만 호출, 오류·로그·raw 는 `redact` 후 저장. 매출 기준일: 결제=결제일, 취소·반품=발생일(`sync.sales_date_for`). 금액은 원 단위 정수. 권한키 `performance`, 설정 화면은 모듈 권한자 누구나(일반 사용자는 수수료율만), 수수료 외 설정 API 는 `is_admin`. 매출 업데이트 진행 창에서 쇼핑몰별 [중지](그 쇼핑몰만 멈추고 다음 쇼핑몰로). **자동 업데이트**(`auto_sync.py`, 웹 프로세스 데몬 스레드) — 매일 09~19시 정각·30분마다 오늘 포함 최근 10일, 진행 창 작업으로 돌고 다른 업데이트 중이면 그 회차 건너뜀, env `PERFORMANCE_AUTO_SYNC`·`_DAYS`·`_HOURS`. 카페24 어댑터는 기존 `app/integrations/cafe24` 토큰 재사용. 1단계는 모의 데이터(`is_sample`)·구조까지, 실제 수집은 쇼핑몰별로 공식 문서 확인 후 순차 구현. 쿠팡은 판매자배송 발주서 + 로켓그로스 주문을 결제일로 합산(WING 판매분석 대조는 원본 데이터 확인으로). 설정의 쇼핑몰별 **수동 입력** 토글(마이그레이션 002 `manual_input`·`perf_manual_sales`) — 켜면 일자별 표 날짜 칸에 총매출 직접 입력, 넣은 날은 API 값 대신(`daily_amounts` 한 곳). 일자별 표 [엑셀 업로드] 팝업(`manual_upload.py`, `POST /performance/api/manual-sales/upload`) — 1열 날짜·2열부터 쇼핑몰 이름 머리글, 수동 입력 켜진 쇼핑몰 열의 값 있는 칸만 반영(덮어씀, 빈 칸 그대로), 잘못된 칸이 하나라도 있으면 전부 저장 안 함, 샘플 = 모듈 폴더 `upload_sample.xlsx`. 열 순서 카페24·네이버·쿠팡(윙)·쿠팡(로켓)·오늘의집·G마켓·카카오·GS샵·11번가·롯데ON·토스·애터미아자몰(마이그레이션 003). 쿠팡(로켓)·애터미아자몰은 **수동 입력 전용**(`adapters/manual.py`, `manual_only` — 매출 업데이트에서 빠지고 인증 설정·연결 테스트 없음, 수동 입력 늘 켜짐). 상세는 `docs/PERFORMANCE_MODULE.md` diff --git a/app/modules/notice/templates/notice/admin.html b/app/modules/notice/templates/notice/admin.html index 1224232..49f4b0a 100644 --- a/app/modules/notice/templates/notice/admin.html +++ b/app/modules/notice/templates/notice/admin.html @@ -2,7 +2,7 @@ {% block head_extra %} {# 프로젝트 화면 부품(설명 편집기·날짜 팝업·멤버 고르기)을 그대로 쓴다 — project.js 는 PJ_LIB_ONLY 로 부품만 #} - + {% endblock %} @@ -64,7 +64,7 @@ - + {% endif %} {% endblock %} diff --git a/app/modules/project/db.py b/app/modules/project/db.py index 5fe1865..f4b3ec2 100644 --- a/app/modules/project/db.py +++ b/app/modules/project/db.py @@ -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: diff --git a/app/modules/project/router.py b/app/modules/project/router.py index 96c49d4..7c3a74e 100644 --- a/app/modules/project/router.py +++ b/app/modules/project/router.py @@ -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: """새로 지정하는 담당자가 그 프로젝트를 볼 수 있는지 — 권한 없는 사람에게 배정 알림(작업 제목 등)이 가지 않게. 비우거나 그대로 두는 건 검사하지 않는다(멤버에서 빠진 예전 담당자 보존).""" diff --git a/app/modules/project/templates/project/goal_meeting.html b/app/modules/project/templates/project/goal_meeting.html index 180dfde..b18aad1 100644 --- a/app/modules/project/templates/project/goal_meeting.html +++ b/app/modules/project/templates/project/goal_meeting.html @@ -1,7 +1,7 @@ {% extends "project/_meeting_content_base.html" if meeting_embedded else "erp_base.html" %} {% block head_extra %} - + {% endblock %} @@ -298,5 +298,5 @@ - + {% endblock %} diff --git a/app/modules/project/templates/project/goals.html b/app/modules/project/templates/project/goals.html index acf9840..04267fb 100644 --- a/app/modules/project/templates/project/goals.html +++ b/app/modules/project/templates/project/goals.html @@ -1,7 +1,7 @@ {% extends "erp_base.html" %} {% block head_extra %} - + {% endblock %} @@ -207,5 +207,5 @@ {% include "project/_member_tasks_modal.html" %} - + {% endblock %} diff --git a/app/modules/project/templates/project/help.html b/app/modules/project/templates/project/help.html index 5225cec..9885d9d 100644 --- a/app/modules/project/templates/project/help.html +++ b/app/modules/project/templates/project/help.html @@ -1,7 +1,7 @@ {% extends "erp_base.html" %} {% block head_extra %} - + {% endblock %} diff --git a/app/modules/project/templates/project/inbox.html b/app/modules/project/templates/project/inbox.html index ef93586..a9e8d21 100644 --- a/app/modules/project/templates/project/inbox.html +++ b/app/modules/project/templates/project/inbox.html @@ -1,7 +1,7 @@ {% extends "erp_base.html" %} {% block head_extra %} - + {% endblock %} @@ -102,5 +102,5 @@ {% include "project/_side_modals.html" %} {% include "project/_member_tasks_modal.html" %} - + {% endblock %} diff --git a/app/modules/project/templates/project/mytasks.html b/app/modules/project/templates/project/mytasks.html index 9f5aca1..91318e3 100644 --- a/app/modules/project/templates/project/mytasks.html +++ b/app/modules/project/templates/project/mytasks.html @@ -1,7 +1,7 @@ {% extends "erp_base.html" %} {% block head_extra %} - + {% endblock %} @@ -100,5 +100,5 @@ "today": {{ today | tojson }} } - + {% endblock %} diff --git a/app/modules/project/templates/project/notifier.html b/app/modules/project/templates/project/notifier.html index e275aea..b157ee2 100644 --- a/app/modules/project/templates/project/notifier.html +++ b/app/modules/project/templates/project/notifier.html @@ -1,7 +1,7 @@ {% extends "erp_base.html" %} {% block head_extra %} - + {% endblock %} @@ -108,5 +108,5 @@ }); })(); - + {% endblock %} diff --git a/app/modules/project/templates/project/project.html b/app/modules/project/templates/project/project.html index b486b9e..3d40d9d 100644 --- a/app/modules/project/templates/project/project.html +++ b/app/modules/project/templates/project/project.html @@ -1,7 +1,7 @@ {% extends "erp_base.html" %} {% block head_extra %} - + @@ -365,6 +365,7 @@
+
@@ -468,5 +469,5 @@ - + {% endblock %} diff --git a/app/modules/project/templates/project/trash.html b/app/modules/project/templates/project/trash.html index 2e14f68..113cf9c 100644 --- a/app/modules/project/templates/project/trash.html +++ b/app/modules/project/templates/project/trash.html @@ -1,7 +1,7 @@ {% extends "erp_base.html" %} {% block head_extra %} - + {% endblock %} @@ -70,5 +70,5 @@ {% include "project/_side_modals.html" %} {% include "project/_member_tasks_modal.html" %} - + {% endblock %} diff --git a/app/static/erp-overdue.css b/app/static/erp-overdue.css new file mode 100644 index 0000000..12319ad --- /dev/null +++ b/app/static/erp-overdue.css @@ -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; } diff --git a/app/static/erp-overdue.js b/app/static/erp-overdue.js new file mode 100644 index 0000000..e175b1e --- /dev/null +++ b/app/static/erp-overdue.js @@ -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 { "&": "&", "<": "<", ">": ">", '"': """, "'": "'" }[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 '' + + '' + + '' + esc(t.title || "(제목 없음)") + "" + esc(where) + "" + + '마감 ' + esc(md(t.due_date)) + (late > 0 ? " · " + late + "일 지남" : "") + ""; + }).join(""); + const more = tasks.length > MAX_ROWS + ? '그 밖에 ' + (tasks.length - MAX_ROWS) + "건 — 내 업무에서 보기" : ""; + box.innerHTML = + '
' + + '마감이 지난 내 업무 ' + tasks.length + "건" + + '
' + + '
' + rows + more + "
"; + 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(); +})(); diff --git a/app/static/project.css b/app/static/project.css index 48db1e3..476c760 100644 --- a/app/static/project.css +++ b/app/static/project.css @@ -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); } } diff --git a/app/static/project.js b/app/static/project.js index 93661ce..4cdb3f4 100644 --- a/app/static/project.js +++ b/app/static/project.js @@ -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 ? '+' + (list.length - 1) + "" : "") + : 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(", ") : "협업자 지정"; + } // ' + '' + '' + + '' + ""; } 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 = "
데이터가 없습니다.
"; 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 = '' + + ''; + 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 = '
업무 합계(프로젝트별)
'; + 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("")) + + ''; + 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 ? '+' + (f.length - 1) + "" : "") - : 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; diff --git a/app/templates/admin.html b/app/templates/admin.html index e090181..d32d7d7 100644 --- a/app/templates/admin.html +++ b/app/templates/admin.html @@ -343,5 +343,7 @@ {# 긴급 공지 — erp_base 를 쓰지 않는 화면도 같이(app/modules/notice) #} + + diff --git a/app/templates/erp_base.html b/app/templates/erp_base.html index 192b717..0b79e70 100644 --- a/app/templates/erp_base.html +++ b/app/templates/erp_base.html @@ -9,6 +9,7 @@ + {% block head_extra %}{% endblock %} @@ -192,6 +193,8 @@ {# 긴급 공지 — 로그인한 모든 화면 가운데(받는 사람이 [확인] 전까지). app/modules/notice #} {% if user %}{% endif %} + {# 마감 지난 내 업무 — 로그인한 모든 화면 위쪽(닫으면 1시간 뒤 다시). Project 권한이 없으면 조용히 멈춘다. #} + {% if user %}{% endif %} {% block scripts %}{% endblock %} diff --git a/app/templates/main.html b/app/templates/main.html index 9e060be..41e96cf 100644 --- a/app/templates/main.html +++ b/app/templates/main.html @@ -170,5 +170,7 @@ {# 긴급 공지 — erp_base 를 쓰지 않는 화면도 같이(app/modules/notice) #} + + diff --git a/docs/PROJECT_MODULE.md b/docs/PROJECT_MODULE.md index e035aa1..a3383d2 100644 --- a/docs/PROJECT_MODULE.md +++ b/docs/PROJECT_MODULE.md @@ -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. 추후 단계 작업 라벨(태그 분류) · 반복 작업 · 템플릿 · 작업 의존성. diff --git a/tests/js/README.md b/tests/js/README.md index 024b238..ca4f290 100644 --- a/tests/js/README.md +++ b/tests/js/README.md @@ -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·초안 보호·구조 변경 중단·이번주 실적 %· diff --git a/tests/js/overdue_ui.test.js b/tests/js/overdue_ui.test.js new file mode 100644 index 0000000..ae873c5 --- /dev/null +++ b/tests/js/overdue_ui.test.js @@ -0,0 +1,74 @@ +// 마감 지난 내 업무 알림(static/erp-overdue.js) — jsdom. 위쪽 알림·닫으면 1시간 쉼·새로 지난 업무는 바로·권한 없으면 멈춤. +// NODE_PATH= 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("
화면
", { 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, "세부", "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); }); diff --git a/tests/js/project_ui.test.js b/tests/js/project_ui.test.js index 53569d2..b5eddde 100644 --- a/tests/js/project_ui.test.js +++ b/tests/js/project_ui.test.js @@ -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); } // ── 나를 태그·작업 배정 알림 팝업 — 본 것 이후 새 알림만, 깜박이는 팝업, 닫기 전까지 유지 ── { diff --git a/tests/test_project_module.py b/tests/test_project_module.py index 1d43bbf..b221972 100644 --- a/tests/test_project_module.py +++ b/tests/test_project_module.py @@ -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")