diff --git a/app/modules/project/db.py b/app/modules/project/db.py index a44d159..0929fb3 100644 --- a/app/modules/project/db.py +++ b/app/modules/project/db.py @@ -2392,9 +2392,9 @@ class ProjectStore: "SELECT row_id, month, body FROM goal_cells WHERE row_id = ANY(%s) AND month = ANY(%s)", (rows_in, cols_in), ).fetchall()} - text = store.validate_goal_text("\n".join( + text = store.merge_goal_texts([ bodies[(r, m)] for r in rows_in for m in cols_in if bodies.get((r, m)) - )) + ]) conn.execute( "DELETE FROM goal_cell_merges WHERE row_id = ANY(%s) AND start_month = ANY(%s)", (rows_in, cols_in), diff --git a/app/modules/project/router.py b/app/modules/project/router.py index 76eb1e4..2b5137b 100644 --- a/app/modules/project/router.py +++ b/app/modules/project/router.py @@ -2567,7 +2567,8 @@ def _goal_area_layout(rows: list[dict[str, Any]], this_month: int) -> None: kind = "year" if m == store.GOAL_YEAR else "quarter" if m in store.GOAL_COL_QUARTER else "month" h = 0 if kind == "year" else store.GOAL_COL_QUARTER[m] if kind == "quarter" else store.goal_quarter_of(m) out.append({"m": m, "kind": kind, "h": h, "span": span, "rspan": rspan, - "now": kind == "month" and m <= this_month <= m + span - 1}) + "now": kind == "month" and m <= this_month <= m + span - 1, + "html": store.goal_text_html(row.get("cells", {}).get(m, ""))}) row["layout"] = out @@ -3062,7 +3063,7 @@ def _month_plan(st: Any, year: int, month: int) -> list[dict[str, Any]] | None: if not row.get("label_cont"): label = row.get("label") or "" cell = next((c for c in row["layout"] if c["kind"] == "month" and c["m"] <= month <= c["m"] + c["span"] - 1), None) - text = (row["cells"].get(cell["m"], "") if cell else "").strip() + text = store.goal_text_plain(row["cells"].get(cell["m"], "") if cell else "").strip() if not text: continue rng = f"{cell['m']}~{cell['m'] + cell['span'] - 1}월" if cell["span"] > 1 else "" diff --git a/app/modules/project/store.py b/app/modules/project/store.py index c2ba2d8..fd7263f 100644 --- a/app/modules/project/store.py +++ b/app/modules/project/store.py @@ -6,8 +6,10 @@ DB 없이 단위 테스트 가능한 순수 함수만 둔다(malaysia.store 패 from __future__ import annotations +import json import re from datetime import date, timedelta +from html import escape from html.parser import HTMLParser from typing import Any @@ -475,11 +477,83 @@ def validate_goal_color(color: Any) -> str: def validate_goal_text(body: Any) -> str: v = str(body or "").replace("\r\n", "\n").strip() + if v.startswith(GOAL_RICH_PREFIX): + runs = goal_text_runs(v, strict=True) + if not "".join(r["text"] for r in runs).strip(): + return "" + return GOAL_RICH_PREFIX + json.dumps(runs, ensure_ascii=False, separators=(",", ":")) if len(v) > GOAL_TEXT_MAX: raise ValueError(f"칸 하나에 {GOAL_TEXT_MAX}자까지 쓸 수 있습니다.") return v +# 기존 TEXT 칸에 버전이 있는 텍스트 조각을 저장한다. 예전 평문은 그대로 유지한다. +GOAL_RICH_PREFIX = "pj-rich:v1:" + + +def goal_text_runs(body: Any, *, strict: bool = False) -> list[dict[str, Any]]: + value = str(body or "") + if not value.startswith(GOAL_RICH_PREFIX): + return [{"text": value}] + try: + raw = json.loads(value[len(GOAL_RICH_PREFIX):]) + if not isinstance(raw, list) or len(raw) > GOAL_TEXT_MAX: + raise ValueError("서식 데이터가 올바르지 않습니다.") + runs = [] + for item in raw: + if not isinstance(item, dict) or not isinstance(item.get("text"), str): + raise ValueError("서식 데이터가 올바르지 않습니다.") + run: dict[str, Any] = {"text": item["text"]} + if isinstance(item.get("bold"), bool): + run["bold"] = item["bold"] + if re.fullmatch(r"#[0-9a-fA-F]{6}", str(item.get("color", ""))): + run["color"] = item["color"].lower() + size = item.get("size") + if isinstance(size, int) and not isinstance(size, bool) and 10 <= size <= 32: + run["size"] = size + if run["text"]: + runs.append(run) + if sum(len(r["text"]) for r in runs) > GOAL_TEXT_MAX: + raise ValueError(f"칸 하나에 {GOAL_TEXT_MAX}자까지 쓸 수 있습니다.") + return runs + except (ValueError, TypeError) as err: + if strict: + raise ValueError("칸의 서식 데이터가 올바르지 않습니다.") from err + return [{"text": value}] + + +def goal_text_plain(body: Any) -> str: + return "".join(r["text"] for r in goal_text_runs(body)) + + +def goal_text_html(body: Any) -> str: + """허용한 글자 서식만 HTML로 만든다. 사용자 텍스트는 항상 escape한다.""" + out = [] + for run in goal_text_runs(body): + style = [] + if "bold" in run: + style.append("font-weight:" + ("700" if run["bold"] else "400")) + if "color" in run: + style.append("color:" + run["color"]) + if "size" in run: + style.append(f'font-size:{run["size"]}px') + text = escape(run["text"]) + out.append(f'{text}' if style else text) + return "".join(out) + + +def merge_goal_texts(bodies: list[str]) -> str: + values = [v for v in bodies if goal_text_plain(v).strip()] + if not any(v.startswith(GOAL_RICH_PREFIX) for v in values): + return validate_goal_text("\n".join(values)) + runs = [] + for value in values: + if runs: + runs.append({"text": "\n"}) + runs.extend(goal_text_runs(value)) + return validate_goal_text(GOAL_RICH_PREFIX + json.dumps(runs, ensure_ascii=False)) + + # ── 엑셀식 사각형 병합(마이그레이션 015) ────────────────────────────── class GoalMigration015Needed(RuntimeError): """세로 병합·주간 회의록은 마이그레이션 015 뒤에만 된다.""" diff --git a/app/modules/project/templates/project/_help_btn.html b/app/modules/project/templates/project/_help_btn.html index 07a859e..14aed98 100644 --- a/app/modules/project/templates/project/_help_btn.html +++ b/app/modules/project/templates/project/_help_btn.html @@ -34,3 +34,4 @@ title="프로젝트 관리 도움말" aria-label="프로젝트 관리 도움말"> help +{% include "project/_options.html" %} diff --git a/app/modules/project/templates/project/_options.html b/app/modules/project/templates/project/_options.html new file mode 100644 index 0000000..f66f29b --- /dev/null +++ b/app/modules/project/templates/project/_options.html @@ -0,0 +1,31 @@ + + +
+

Project 옵션

+ + +
프로젝트와 목표를 한눈에
Project · 업무 이름 · 가나다 123
+

이 브라우저의 모든 Project 화면에 적용됩니다.

+ +
+ + +
+
+
+ + diff --git a/app/modules/project/templates/project/goal_meeting.html b/app/modules/project/templates/project/goal_meeting.html index 8dbd7a0..866abec 100644 --- a/app/modules/project/templates/project/goal_meeting.html +++ b/app/modules/project/templates/project/goal_meeting.html @@ -1,7 +1,7 @@ {% extends "erp_base.html" %} {% block head_extra %} - + {% endblock %} @@ -296,5 +296,5 @@ {% include "project/_side_modals.html" %} {% include "project/_member_tasks_modal.html" %} - + {% endblock %} diff --git a/app/modules/project/templates/project/goals.html b/app/modules/project/templates/project/goals.html index 39f69c1..f77cac8 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 %} @@ -37,6 +37,15 @@ {% endif %} + {% if is_admin and goals_enabled and board %} + + {% endif %}
{% if not goals_enabled %}
연간 목표가 아직 준비되지 않았습니다(DB 마이그레이션 013 필요).
@@ -166,10 +175,11 @@ {% if c.kind in ('month', 'quarter') %}data-h="{{ c.h }}" {% endif %}data-month="{{ c.m }}" data-span="{{ c.span }}" data-rspan="{{ c.rspan }}" {%- if c.span > 1 %} colspan="{{ c.span }}" style="--span: {{ c.span }}"{% endif %}{% if c.rspan > 1 %} rowspan="{{ c.rspan }}"{% endif %}> {%- if editable -%} - +
{{ c.html|safe }}
{%- else -%} -
{{ row.cells.get(c.m, '') }}
+
{{ c.html|safe }}
{%- endif -%} {% endfor %} @@ -181,7 +191,7 @@ {% if is_admin %}
- 칸을 고치면 바로 저장됩니다. 숫자 칸을 비우면 지워집니다. 구역·항목 칸을 우클릭하거나 칸의 ⋮ 버튼(키보드 Tab·Enter, 터치)을 누르면 색·순서·줄 추가·삭제 메뉴가 나옵니다. + 칸을 고치면 바로 저장됩니다. 글자를 드래그해 선택하면 표 위에서 색상·굵기·크기를 바꾸거나 서식을 초기화할 수 있습니다. 숫자 칸을 비우면 지워집니다. 구역·항목 칸을 우클릭하거나 칸의 ⋮ 버튼(키보드 Tab·Enter, 터치)을 누르면 색·순서·줄 추가·삭제 메뉴가 나옵니다. {%- if board.halves %} 칸을 마우스로 끌어 여러 칸을 고른 뒤 우클릭 → 셀 병합, 병합된 칸은 우클릭 → 병합 해제(글은 왼쪽 위 칸에 남음).{% endif %} 월 이름을 누르면 그 달 주간 회의록이 열립니다.
@@ -196,5 +206,6 @@ {% include "project/_side_modals.html" %} {% 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 2e8435c..84c7eae 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 %} @@ -78,7 +78,7 @@

2화면 구성

@@ -94,7 +94,9 @@ 달성은 실적÷목표(100% 이상 초록)로 저절로 계산됩니다. 분기 칸 머리의 ‹ 버튼을 누르면 그 분기의 월 칸 3개가 접히고, 다시 누르면 펼쳐집니다(접힌 상태는 내 브라우저에 기억). 월 이름을 누르면 그 달 주간 회의록이 열립니다. 입력은 관리자만 할 수 있고(칸을 고치면 바로 저장), 다른 직원은 보기만 합니다. 관리자는 + 연도 추가로 새해 목표를 - 만들고(이전 연도의 업무 영역 구성을 그대로 가져옴), 영역·줄 이름은 눌러서 그 자리에서 고치고(Enter 저장, Esc 취소), + 만듭니다(이전 연도의 업무 영역 구성을 그대로 가져옴). 글 칸에서 글자를 드래그해 선택하고 표 위 서식 도구로 색상·굵기·크기를 바꾸면 선택한 글자에만 적용됩니다. + 서식 초기화는 선택한 글자를 기본 서식으로 되돌리며 내용은 유지합니다. 서식도 자동으로 저장됩니다. + 영역·줄 이름은 눌러서 그 자리에서 고치고(Enter 저장, Esc 취소), 구역·항목 칸을 우클릭하거나 칸 오른쪽 위의 작은 ⋮ 버튼(마우스를 올리면 보임)을 눌러 색·순서·줄 추가·삭제를 합니다. 키보드로는 Tab으로 이름 칸·⋮로 가서 Enter(이름 칸 = 이름 고치기, ⋮ = 메뉴), 메뉴 안에서 ↑↓·Enter, Esc로 닫습니다. 터치 화면에서는 ⋮ 버튼이 늘 옅게 보여 손가락으로 누르면 됩니다. 업무 영역 칸은 엑셀처럼 병합할 수 있습니다 — 칸을 마우스로 @@ -116,6 +118,8 @@
  • notifications 종 아이콘 — 읽지 않은 알림 수가 표시되고, 누르면 수신함으로 갑니다.
  • fit_screen 화면 배율 — 누르면(파랗게 켜짐) 화면 전체를 75%로 줄입니다. 2880×1620 모니터를 Windows 배율 200%로 쓰면 화면이 꽉 차 보이는데, 이때 켜면 1920×1080 모니터와 같은 모습이 됩니다. 브라우저마다 기억합니다. 메뉴·말풍선 같은 작은 팝업은 원래 크기로 뜹니다.
  • help 물음표 — 지금 보고 있는 이 도움말을 새 탭으로 엽니다.
  • +
  • settings 도움말 오른쪽의 옵션 — 폰트를 고르고 미리 본 뒤 저장을 누르면 Project 화면에 적용되고 창이 닫힙니다. + 기본 시스템 폰트·프리텐다드·나눔 스퀘어·나눔 스퀘어 네오·나눔 스퀘어 라운드 중 선택할 수 있습니다. 설정은 이 브라우저의 모든 Project 화면에서 기억합니다. 취소는 변경을 적용하지 않고 닫습니다.
  • 프로젝트 제목

    가운데 위 프로젝트 제목에 마우스를 올리면 테두리가 생깁니다. 누르면 그 자리에서 이름을 고칩니다 — Enter나 바깥을 누르면 저장, Esc는 취소. (그 프로젝트 멤버·관리자만)

    @@ -232,7 +236,8 @@
    기본 담당자를 정해 두면, 그 섹션에 담당자 없는 작업을 새로 만들거나 옮겨 올 때 그 사람이 자동으로 담당자가 됩니다. 예) “검토” 섹션의 기본 담당자 = 팀장.

    작업 카드 다루기