fix(project): retain monthly plan text styles

This commit is contained in:
2026-10-04 13:30:36 +09:00
parent ed7da57066
commit 86622cc4dd
7 changed files with 50 additions and 10 deletions
+3 -2
View File
@@ -3092,11 +3092,12 @@ 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 = store.goal_text_plain(row["cells"].get(cell["m"], "") if cell else "").strip()
body = row["cells"].get(cell["m"], "") if cell else ""
text = store.goal_text_plain(body).strip()
if not text:
continue
rng = f"{cell['m']}~{cell['m'] + cell['span'] - 1}월" if cell["span"] > 1 else ""
items.append({"label": label, "text": text, "range": rng})
items.append({"label": label, "text": text, "text_html": store.goal_text_html(body, include_size=False), "range": rng})
if items:
out.append({"name": area["name"], "color": area["color"], "lines": items}) # 키 lines — 템플릿의 a.items 는 dict.items 메서드
return out
+4 -3
View File
@@ -535,8 +535,9 @@ 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한다."""
def goal_text_html(body: Any, *, include_size: bool = True) -> str:
"""허용한 글자 서식만 HTML로 만든다. 사용자 텍스트는 항상 escape한다.
월간 계획 요약에서는 include_size=False로 글자 크기만 화면 기본값을 사용한다."""
out = []
for run in goal_text_runs(body):
style = []
@@ -548,7 +549,7 @@ def goal_text_html(body: Any) -> str:
style.append("text-decoration:" + ("underline" if run["underline"] else "none"))
if "color" in run:
style.append("color:" + run["color"])
if "size" in run:
if include_size and "size" in run:
style.append(f'font-size:{run["size"]}px')
text = escape(run["text"])
out.append(f'<span style="{";".join(style)}">{text}</span>' if style else text)
@@ -1,7 +1,7 @@
{% extends "erp_base.html" %}
{% block head_extra %}
<link rel="stylesheet" href="/static/project.css?v=20261003o" />
<link rel="stylesheet" href="/static/project.css?v=20261004b" />
<link rel="stylesheet" href="/static/vendor/material-symbols/material-symbols.css" />
{% endblock %}
@@ -63,7 +63,7 @@
<div class="pj-meet-plan-area" style="--goal-bg: {{ a.color or '#f4f5f7' }}">
<b class="pj-meet-plan-name">{{ a.name }}</b>
{% for it in a.lines %}
<div class="pj-meet-plan-item">{% if it.label %}<span class="pj-meet-plan-label">{{ it.label }}</span>{% endif %}<span class="pj-meet-plan-text">{{ it.text }}</span>{% if it.range %}<em>{{ it.range }}</em>{% endif %}</div>
<div class="pj-meet-plan-item">{% if it.label %}<span class="pj-meet-plan-label">{{ it.label }}</span>{% endif %}<span class="pj-meet-plan-text">{{ it.text_html | safe }}</span>{% if it.range %}<em>{{ it.range }}</em>{% endif %}</div>
{% endfor %}
</div>
{% endfor %}
@@ -587,7 +587,7 @@
</ul>
<h3 id="meetings-month-plan">이 달 계획 확인</h3>
<p>제목 아래 <span class="pjh-ui">해당 월 계획</span>은 연간 목표 표에 적은 월 계획을 업무 영역별로 보여 줍니다. 빈 계획은 생략하고, 병합 칸은 해당 월을 포함하는 계획을 한 번 표시합니다. 여기서는 읽기만 하므로 수정하려면 연간 목표 표로 돌아갑니다.</p>
<p>제목 아래 <span class="pjh-ui">해당 월 계획</span>은 연간 목표 표에 적은 월 계획을 업무 영역별로 보여 줍니다. 굵게·기울임·밑줄·글자 색상과 줄바꿈·들여쓰기를 유지하고, 글자 크기는 월 계획의 기본 크기로 표시합니다. 빈 계획은 생략하고, 병합 칸은 해당 월을 포함하는 계획을 한 번 표시합니다. 여기서는 읽기만 하므로 수정하려면 연간 목표 표로 돌아갑니다.</p>
<h3 id="meetings-kpis">월 목표·누적·주당 필요 매출 읽기</h3>
<table class="pjh-table">
+1 -1
View File
@@ -2538,7 +2538,7 @@ html.pj-goal-selecting, html.pj-goal-selecting * { user-select: none !important;
.pj-meet-plan-item + .pj-meet-plan-item { margin-top: 2px; }
.pj-meet-plan-label { flex: none; font-weight: 700; color: #3b4048; }
.pj-meet-plan-label::after { content: ":"; }
.pj-meet-plan-text { white-space: pre-line; overflow-wrap: anywhere; }
.pj-meet-plan-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.pj-meet-plan-item em { flex: none; margin-left: auto; font-style: normal; font-size: 10.5px; color: var(--pj-ink-soft); }
.pj-meet-plan-empty { margin: 0; font-size: 12px; color: var(--pj-ink-soft); }
+3 -1
View File
@@ -757,7 +757,9 @@ description 을 항상 HTML로 취급하기 때문). 두 번 실행하면 이중
"지난주 회의록에 없는 줄"). 예전엔 몇 주 전 회의록 줄이 지난주 날짜 아래 보였다(점검 버그 5).
- 첫 회의록 기본 줄 마케팅 "메타"(예전 "메타(숫자)" — 017 이 그 이름 줄만 "메타"로 바꿈).
- **{월}월 계획**(`router._month_plan`, `.pj-meet-plan`, 머리 왼쪽 `.pj-meet-headleft` 안 — 제목 줄 아래·달력 왼쪽): 연간 목표 표의 그 달 열 글을 업무 영역별 작은 카드로
(영역 색, `항목: 글`, 빈 칸·글 없는 영역은 뺌). 가로 병합 칸(예: 9~10월)에 적은 글도 그 달 계획으로 보이고 범위를 오른쪽에 작게,
표시(영역 색, `항목: 글`, 빈 칸·글 없는 영역은 뺌). 굵게·기울임·밑줄·글자 색상·줄바꿈·들여쓰기를 유지하고
글자 크기만 카드 기본값을 사용(`goal_text_html(include_size=False)`), 원본 셀 서식은 변경하지 않는다.
가로 병합 칸(예: 9~10월)에 적은 글도 그 달 계획으로 보이고 범위를 오른쪽에 작게,
세로 병합은 한 번만, 묶인 줄(016 `label_cont`)은 묶음 항목 이름. 목표 표가 없으면(013 미적용) 칸 자체를 숨김, 읽기만.
- **줄**(구역 = 목표 표 업무 영역, 표의 구역 칸 rowspan): 항목 | **이번주 할 일·행사** | **정량 목표**(원, 예전 이름 "목표 금액") ‖ 지난주 리뷰: 지난주 할 일 |
지난주 목표 | **결과** | 달성률 | **평가**(— · 완료 · 일부 · 미달). 지난주 칸 = **7일 전 주 회의록에서 같은 연결키(`line_key`, 018)의 줄**
+36
View File
@@ -1,6 +1,8 @@
import json
import unittest
from types import SimpleNamespace
from app.modules.project import store
from app.modules.project.router import _month_plan
def rich(runs):
@@ -8,6 +10,40 @@ def rich(runs):
class GoalRichTextTests(unittest.TestCase):
def test_summary_keeps_all_styles_except_font_size(self):
body = rich([{"text": "<계획>\n 다음 줄", "bold": True, "italic": True,
"underline": True, "color": "#DC2626", "size": 32},
{"text": " 해제", "bold": False, "italic": False,
"underline": False, "size": 10}])
html = store.goal_text_html(body, include_size=False)
for style in ("font-weight:700", "font-style:italic", "text-decoration:underline",
"color:#dc2626", "font-weight:400", "font-style:normal", "text-decoration:none"):
self.assertIn(style, html)
self.assertIn("&lt;계획&gt;\n 다음 줄", html)
self.assertNotIn("font-size", html)
self.assertIn("font-size:32px", store.goal_text_html(body))
self.assertIn("font-size:10px", store.goal_text_html(body))
def test_month_plan_preserves_formatted_merged_cells_and_literal_legacy_text(self):
body = rich([{"text": "<img src=x onerror=alert(1)>\n 계획", "bold": True,
"italic": True, "underline": True, "color": "#2563EB", "size": 24}])
rows = [{"label": "인플", "cells": {7: body}, "merges": {7: (3, 2)}},
{"label": "숨긴 줄", "cells": {}, "merges": {}},
{"label": "쿠팡", "cells": {9: "<b>평문</b>"}, "merges": {}},
{"label": "빈 칸", "cells": {9: rich([{"text": " ", "bold": True}])}, "merges": {}}]
fake = SimpleNamespace(goals_enabled=lambda: True,
get_goal_board=lambda **kw: {"areas": [{"name": "유통", "color": "#cdebf8", "rows": rows}]})
plans = _month_plan(fake, 2026, 9)
lines = plans[0]["lines"]
self.assertEqual(len(lines), 2)
self.assertEqual(lines[0]["range"], "7~9월")
self.assertEqual(lines[0]["text"], store.goal_text_plain(body))
self.assertEqual(lines[0]["text_html"], store.goal_text_html(body, include_size=False))
self.assertNotIn("<img", lines[0]["text_html"])
self.assertNotIn("font-size", lines[0]["text_html"])
self.assertEqual(lines[1]["text_html"], "&lt;b&gt;평문&lt;/b&gt;")
self.assertEqual(rows[0]["cells"][7], body)
def test_selected_styles_are_safe_and_legacy_text_stays_literal(self):
body = rich([{"text": "<img src=x onerror=alert(1)>", "bold": True,
"color": "#FF0000", "size": 20, "onclick": "alert(1)"},