fix(project): fit goal rows to text height

This commit is contained in:
2026-10-03 07:59:22 +09:00
parent b32f2ac3a3
commit 2c8542339d
12 changed files with 104 additions and 21 deletions
@@ -1,7 +1,7 @@
{% extends "erp_base.html" %}
{% block head_extra %}
<link rel="stylesheet" href="/static/project.css?v=20261003d" />
<link rel="stylesheet" href="/static/project.css?v=20261003e" />
<link rel="stylesheet" href="/static/vendor/material-symbols/material-symbols.css" />
{% endblock %}
@@ -296,5 +296,5 @@
{% include "project/_side_modals.html" %}
{% include "project/_member_tasks_modal.html" %}
<script src="/static/project.js?v=20261003f" defer></script>
<script src="/static/project.js?v=20261003g" defer></script>
{% endblock %}
@@ -1,7 +1,7 @@
{% extends "erp_base.html" %}
{% block head_extra %}
<link rel="stylesheet" href="/static/project.css?v=20261003d" />
<link rel="stylesheet" href="/static/project.css?v=20261003e" />
<link rel="stylesheet" href="/static/vendor/material-symbols/material-symbols.css" />
{% endblock %}
@@ -223,5 +223,5 @@
{% include "project/_member_tasks_modal.html" %}
<script src="/static/project-goal-text.js?v=20261003c" defer></script>
<script src="/static/project.js?v=20261003f" defer></script>
<script src="/static/project.js?v=20261003g" defer></script>
{% endblock %}
@@ -1,7 +1,7 @@
{% extends "erp_base.html" %}
{% block head_extra %}
<link rel="stylesheet" href="/static/project.css?v=20261003d" />
<link rel="stylesheet" href="/static/project.css?v=20261003e" />
<link rel="stylesheet" href="/static/project-help.css?v=20261002d" />
<link rel="stylesheet" href="/static/vendor/material-symbols/material-symbols.css" />
{% endblock %}
@@ -100,6 +100,7 @@
<span class="pjh-ui">서식 초기화</span>는 선택한 글자를 기본 서식으로 되돌리며 내용은 유지합니다. 서식도 자동으로 저장됩니다. 색상은 12색의 네모 견본에서 고릅니다.
<b>모든 행의 셀 오른쪽 경계</b>를 끌어 열 너비를 조절하고, 더블클릭하면 <b>그 열의 가장 긴 문단에 맞춰</b> 자동으로 조절합니다.
직접 넣은 줄바꿈은 유지하며 글자 크기·굵기·여백도 반영합니다. 병합 칸에서는 다른 열 너비를 유지하고 오른쪽 끝 열만 맞춥니다. 너비는 내 브라우저에 기억됩니다.
<b>행 높이는 가장 높은 글 칸에 맞춰</b> 자동으로 늘어나거나 줄어들며, 위·아래 여백은 각각 6px입니다. 짧은 글도 같은 위치에서 상단 정렬됩니다.
영역·줄 이름은 <b>눌러서 그 자리에서 고치고</b>(Enter 저장, Esc 취소),
구역·항목 칸을 <b>우클릭</b>하거나 칸 오른쪽 위의 작은 <span class="pjh-ui">⋮</span> 버튼(마우스를 올리면 보임)을 눌러 색·순서·줄 추가·삭제를 합니다.
키보드로는 <kbd>Tab</kbd>으로 이름 칸·<span class="pjh-ui">⋮</span>로 가서 <kbd>Enter</kbd>(이름 칸 = 이름 고치기, ⋮ = 메뉴), 메뉴 안에서 <kbd>↑</kbd><kbd>↓</kbd>·<kbd>Enter</kbd>,
@@ -1,7 +1,7 @@
{% extends "erp_base.html" %}
{% block head_extra %}
<link rel="stylesheet" href="/static/project.css?v=20261003d" />
<link rel="stylesheet" href="/static/project.css?v=20261003e" />
<link rel="stylesheet" href="/static/vendor/material-symbols/material-symbols.css" />
{% endblock %}
@@ -104,5 +104,5 @@
{% include "project/_side_modals.html" %}
{% include "project/_member_tasks_modal.html" %}
<script src="/static/project.js?v=20261003f" defer></script>
<script src="/static/project.js?v=20261003g" defer></script>
{% endblock %}
@@ -1,7 +1,7 @@
{% extends "erp_base.html" %}
{% block head_extra %}
<link rel="stylesheet" href="/static/project.css?v=20261003d" />
<link rel="stylesheet" href="/static/project.css?v=20261003e" />
<link rel="stylesheet" href="/static/vendor/material-symbols/material-symbols.css" />
{% endblock %}
@@ -100,5 +100,5 @@
"today": {{ today | tojson }}
}
</script>
<script src="/static/project.js?v=20261003f" defer></script>
<script src="/static/project.js?v=20261003g" defer></script>
{% endblock %}
@@ -1,7 +1,7 @@
{% extends "erp_base.html" %}
{% block head_extra %}
<link rel="stylesheet" href="/static/project.css?v=20261003d" />
<link rel="stylesheet" href="/static/project.css?v=20261003e" />
<!-- 구글 머티리얼 심볼(담당자 아이콘 등) — self-host -->
<link rel="stylesheet" href="/static/vendor/material-symbols/material-symbols.css" />
<!-- 타임라인 vis-timeline — self-host -->
@@ -496,5 +496,5 @@
</script>
<script src="/static/vendor/vis-timeline/vis-timeline-graph2d.min.js"></script>
<script src="/static/project.js?v=20261003f" defer></script>
<script src="/static/project.js?v=20261003g" defer></script>
{% endblock %}
@@ -1,7 +1,7 @@
{% extends "erp_base.html" %}
{% block head_extra %}
<link rel="stylesheet" href="/static/project.css?v=20261003d" />
<link rel="stylesheet" href="/static/project.css?v=20261003e" />
<link rel="stylesheet" href="/static/vendor/material-symbols/material-symbols.css" />
{% endblock %}
@@ -70,5 +70,5 @@
{% include "project/_side_modals.html" %}
{% include "project/_member_tasks_modal.html" %}
<script src="/static/project.js?v=20261003f" defer></script>
<script src="/static/project.js?v=20261003g" defer></script>
{% endblock %}
+7 -3
View File
@@ -2214,6 +2214,7 @@ input.pj-goal-num:focus { outline: 2px solid var(--pj-accent); outline-offset: -
/* 업무 영역 — 영역 색(--goal-bg)이 줄 전체 배경(스프레드시트처럼) */
.pj-goal-area > tr > th, .pj-goal-area > tr > td { background: var(--goal-bg, #fff); border-color: rgba(0, 0, 0, .07); }
.pj-goal-area > tr > th { padding: 6px 8px; vertical-align: top; }
.pj-goal-area > tr:first-child > * { border-top: 1px solid rgba(0, 0, 0, .12); }
.pj-goal-area-name { font-size: var(--pj-text-size); font-weight: 500 !important; }
.pj-goal-area-text, .pj-goal-row-text { display: block; word-break: keep-all; overflow-wrap: anywhere; }
@@ -2236,7 +2237,7 @@ th.pj-goal-area-name:focus-within .pj-goal-menu-btn, th.pj-goal-row-label:focus-
html.pj-goal-selecting .pj-goal-menu-btn { pointer-events: none; }
@media print { .pj-goal-menu-btn { display: none !important; } }
.pj-goal-text {
display: block; width: 100%; box-sizing: border-box; min-height: 46px; padding: 6px; border: none;
display: block; width: 100%; box-sizing: border-box; min-height: calc(var(--pj-text-leading) + 12px); padding: 6px; border: none;
white-space: pre-wrap; overflow-wrap: anywhere;
background: transparent; font: inherit; line-height: var(--pj-text-leading); color: inherit; resize: none; overflow: hidden;
}
@@ -2246,8 +2247,11 @@ html.pj-goal-selecting .pj-goal-menu-btn { pointer-events: none; }
box-shadow: inset 0 0 0 2px var(--pj-accent);
background-image: linear-gradient(rgba(255, 255, 255, .75), rgba(255, 255, 255, .75));
}
.pj-goal-text:empty::before { content: attr(data-placeholder); pointer-events: none; color: rgba(0, 0, 0, .3); }
.pj-goal-text-ro { min-height: 46px; padding: 6px; line-height: var(--pj-text-leading); white-space: pre-wrap; overflow-wrap: anywhere; }
.pj-goal-text:empty::before {
content: attr(data-placeholder); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
pointer-events: none; color: rgba(0, 0, 0, .3);
}
.pj-goal-text-ro { box-sizing: border-box; min-height: calc(var(--pj-text-leading) + 12px); padding: 6px; line-height: var(--pj-text-leading); white-space: pre-wrap; overflow-wrap: anywhere; }
.pj-goal-text span, .pj-goal-text-ro span { line-height: normal; }
.pj-goal-area td.is-now { box-shadow: inset 2px 0 0 rgba(123, 104, 238, .35), inset -2px 0 0 rgba(123, 104, 238, .35); }
.pj-goal-texttd.pj-goal-year-col { font-weight: 600; }
+4 -1
View File
@@ -8904,8 +8904,11 @@
applyFold(h, true);
});
});
// 글 칸 높이 맞추기 — 접혀 안 보이는 칸은 건너뛴다(높이 0 으로 재져 펼쳤을 때 글이 잘림). 펼칠 때 다시 잰다.
// contenteditable 글 칸은 내용의 자연 높이를 쓴다. 표가 가장 높은 칸에 행을 맞추고
// 짧은 칸은 상단에 둔다. 글·폭·부분 서식 변경과 숨긴 분기에서도 오래된 높이가 남지 않는다.
function fit(ta) {
if (ta.tagName !== "TEXTAREA") { ta.style.removeProperty("height"); return; }
// 예전 textarea 템플릿도 지원하되 접힌 칸은 펼친 뒤 잰다.
if (!ta.offsetParent) return;
ta.style.height = "auto";
ta.style.height = ta.scrollHeight + "px";
+13 -3
View File
@@ -66,6 +66,8 @@
경계를 더블클릭하면 그 열의 가장 긴 문단에 자동으로 맞춘다. 직접 넣은 줄바꿈은 유지하고 글꼴·크기·굵기·여백을
반영하며, 병합 칸은 다른 열 너비를 유지한 채 선택한 열만 맞춘다. 긴 문단은 드래그 최대 너비(600px)를 넘어도
맞추고 브라우저에 기억한다(이름 열도 자동 맞춤 가능). 현재 편집 중인 글·숫자도 내용 변경 없이 측정한다.
목표 업무 행 높이는 가장 높은 글 칸의 자연 높이에 맞춘다. 글·이름 칸 모두 위·아래 6px 여백과 상단 정렬을
사용하며, 글이 짧아지면 행도 줄어든다. 글이 한 줄이거나 비어 있으면 한 줄 높이만 확보하고 보기 전용도 같은 규칙이다.
목표 글자를 선택하면 해당 셀 상단 중앙을 기준으로 셀 위에 서식 도구가 표시되며, 색상은 지정된 12색 견본으로만 선택한다.
기존 글의 다른 색상은 보존. 글자 선택 해제·외부 클릭·편집 셀 제거 시 도구를 닫고 기존 부분 서식·자동 저장을 재사용한다.
@@ -549,7 +551,14 @@ description 을 항상 HTML로 취급하기 때문). 두 번 실행하면 이중
(`initGoalSide`, localStorage `pj_goal_open`, 목표 화면에선 항상 펼침). 연도 목록은 `router._goal_years_nav`
(`goal_years` 최근 연도 먼저 + **올해는 항상**, 013 미적용이면 올해만) — 사이드바를 그리는 모든 화면 컨텍스트에 `goal_years`.
- 연도를 누르면 `/project/goals/{연도}`(`goals.html`) — 스프레드시트 같은 한 표. 머리 줄(연간·1~12월)과 왼쪽 두 칸은 고정,
이번 달 열 강조. **가로 스크롤 때 3열(구분·항목·연간)까지 고정** — 연간 열 `position: sticky; left: 1열+2열 너비`, 경계 그림자. 월 칸 너비 85px·연간 90px(여백 포함, `box-sizing: border-box`), 머리·왼쪽 이름 가운데 정렬(왼쪽 이름은 세로도 가운데 — 관리자 도구는 칸 아래에 떠 있는 막대라 자리를 차지하지 않음). **모든 열**(구분·항목·연간·1~12월·상/하반기)은 머리 칸 오른쪽 끝을 끌어 너비 조절(더블클릭 = 기본 너비) — 브라우저별 localStorage `pj_goal_col_w`(키 `c1`·`c2`·`y`·`m1`~`m12`·`h1`·`h2`, 기본값과 다른 칸만 저장). 이름 두 칸은 48~320px·CSS 변수 `--goal-c1-w`·`--goal-c2-w`, 나머지는 40~600px·머리 칸의 `--cw`(table-layout: fixed 라 머리 칸 너비가 열 너비). 반기 접기 애니메이션의 월 칸 안쪽 고정 폭은 `--fold-w`(병합 칸 = 걸친 월 너비 합)로 JS 가 넣는다.
이번 달 열 강조. **가로 스크롤 때 3열(구분·항목·연간)까지 고정** — 연간 열 `position: sticky; left: 1열+2열 너비`, 경계 그림자.
월 칸 기본 너비 85px·연간 90px(여백 포함, `box-sizing: border-box`). 머리·왼쪽 이름은 가로 가운데 정렬이며,
업무 영역의 이름·글은 세로 상단 정렬, 위·아래 여백 각 6px이다. 행 높이는 가장 높은 글 칸에 맞추고 글이 줄면 함께 줄어든다.
**모든 열**(구분·항목·연간·1~12월·분기)은 모든 행의 셀 오른쪽 끝에서 끌어 너비 조절(더블클릭 = 가장 긴 문단에 맞춤).
브라우저별 localStorage `pj_goal_col_w`(키 `c1`·`c2`·`y`·`m1`~`m12`·`q1`~`q4`, 기본값과 다른 칸만 저장).
드래그는 이름 두 칸 48~320px·CSS 변수 `--goal-c1-w`·`--goal-c2-w`, 나머지 40~600px·머리 칸의 `--cw`로 조절한다.
자동 맞춤은 긴 문단에 맞게 최대 너비를 넘어도 저장·복원한다. 접기 애니메이션의 월 칸 안쪽 고정 폭은
`--fold-w`(병합 칸 = 걸친 월 너비 합)로 JS가 넣는다.
- **틀 고정** — 세로 스크롤에도 머리 줄 + 숫자 지표(매출·로아스) 줄까지 위에 붙어 있다. 지표 칸 `position: sticky` + 줄마다 `--kpi-top`(머리 줄 높이 + 앞 지표 줄 높이 합, `stickKpi`, 창 크기 바뀌면 다시 잼). z-index: 영역 이름 칸 2(마우스 올림 6) < 지표 칸 7 < 지표 이름 칸 8 < 머리 줄 9 < 머리 이름 칸 10.
- **숫자 지표** `goal_metrics`(year·metric `sales|roas`·kind `target|actual`·month 1~12·value NUMERIC(18,2)) —
매출 목표/실적/달성, 로아스 목표/실적. 매출 연간 = 월 합계, 달성률 = 실적÷목표(월별, **연간·반기는 그 기간 목표 합계 전체 대비 입력된
@@ -612,8 +621,9 @@ description 을 항상 HTML로 취급하기 때문). 두 번 실행하면 이중
애니메이션(`applyFold`): 접기 = `.is-shrunk`(칸 width·padding·테두리 → 0, `.is-folding` 동안만 transition .32s) 뒤
`.is-gone`(display:none), 펴기 = 거꾸로. 줄어드는 동안 칸 안 내용은 원래 폭(`85px × --span`)으로 고정해 잘라 내서 줄 높이가
출렁이지 않는다. **표는 `width: 1px` + `table-layout: fixed`** — fixed 는 표 너비가 auto 가 아닐 때만 먹는다(auto 면 칸 너비가
내용을 따라가 펼칠 때 애니메이션 없이 한 번에 튄다). 표는 칸 너비 합만큼 늘어난다. 접힌 칸의 글 칸 높이는 잴 수 없어(`fit` 이
`offsetParent` 없으면 건너뜀) 펼친 뒤 다시 잰다. `prefers-reduced-motion` 이면 애니메이션 없이.
내용을 따라가 펼칠 때 애니메이션 없이 한 번에 튄다). 표는 칸 너비 합만큼 늘어난다. contenteditable 글 칸은 고정 높이 없이
펼쳤을 때의 내용·너비로 자연 높이가 정해진다(예전 textarea는 숨겨져 있으면 측정을 건너뛰고 펼친 뒤 다시 잼).
`prefers-reduced-motion` 이면 애니메이션 없이.
- **영역·줄 이름 바로 수정**(관리자) — 이름(`[data-goal-edit="area|row"]`)을 누르면 contenteditable(`startNameEdit`) —
Enter·칸 떠남 = 저장, Esc = 취소, 붙여넣기는 글자만. 영역 이름 빈 값은 되돌림(서버도 400), 줄 이름은 빈 값 허용(빈 줄 이름은
마우스를 올리면 "줄 이름" 자리 표시). 예전 ✎(prompt) 버튼은 없앴다. 색·순서·줄 추가·삭제는 우클릭 메뉴(아래).
+1
View File
@@ -28,6 +28,7 @@ node tests/js/goals_meeting_ui.test.js # jsdom 필요(npm install jsdom
목표 열 자동 맞춤은 실제 Chromium에서도 검증한다. 로컬 테스트 HTML·프로젝트 CSS/폰트를 사용하며 운영 서버·DB에 연결하지 않는다.
부분 서식과 셀 여백, 명시적 줄바꿈, 75% 배율, 600px를 넘는 긴 문단, 저장된 너비 복원을 확인한다.
행 높이는 3줄/2줄 셀의 상단 정렬·같은 위아래 여백, 한 줄로 줄였을 때 높이 축소, 큰 글씨, 보기 전용 화면까지 확인한다.
```powershell
python tests/js/render_goals.py
+65 -1
View File
@@ -12,7 +12,8 @@ const STATIC = path.join(ROOT, "app/static");
const server = http.createServer(function (req, res) {
const url = new URL(req.url, "http://localhost");
if (url.pathname === "/project/goals/2026") {
const html = fs.readFileSync(path.join(__dirname, ".out/goals_admin.html"), "utf8")
const fixture = url.searchParams.has("readonly") ? "goals_ro.html" : "goals_admin.html";
const html = fs.readFileSync(path.join(__dirname, ".out", fixture), "utf8")
.replace("<body>", '<body style="font-family:var(--pj-font)"><div class="erp-app">')
.replace("</body>", "</div></body>");
res.setHeader("Content-Type", "text/html; charset=utf-8"); res.end(html); return;
@@ -137,6 +138,69 @@ const server = http.createServer(function (req, res) {
assert(Math.abs(merged.actual - parseFloat(before) - merged.last) < 1, JSON.stringify(merged));
console.log("PASS merged cell mapping, one unwrapped paragraph, other column unchanged");
await mergedPage.close();
for (const readonly of [false, true]) {
const heightPage = await browser.newPage({ viewport: { width: 1600, height: 1000 } });
await heightPage.addInitScript(function () {
document.addEventListener("DOMContentLoaded", function () {
const row = document.querySelector('tr[data-row-id="10"]');
row.querySelector('td[data-month="0"] > div').textContent = "첫 번째 줄\n두 번째 줄\n세 번째 줄";
row.querySelector('td[data-month="1"] > div').textContent = "첫 줄\n둘째 줄";
});
});
await heightPage.goto("http://127.0.0.1:" + server.address().port + "/project/goals/2026" + (readonly ? "?readonly=1" : ""));
await heightPage.evaluate(function () {
// 세 줄은 열 폭에 의해 추가로 접히지 않도록 연간 열만 넓힌다.
const h = document.querySelector('thead .pj-goal-colresize[data-col="y"]');
h.dispatchEvent(new MouseEvent("dblclick", { bubbles: true, cancelable: true }));
});
async function rowMetrics() {
return heightPage.evaluate(function () {
const row = document.querySelector('tr[data-row-id="10"]');
const long = row.querySelector('td[data-month="0"] > div'), short = row.querySelector('td[data-month="1"] > div');
const cell = long.closest("td"), style = getComputedStyle(long), cellStyle = getComputedStyle(cell);
const range = document.createRange(); range.selectNodeContents(long);
return { row: row.getBoundingClientRect().height, editor: long.getBoundingClientRect().height,
paddingTop: parseFloat(style.paddingTop), paddingBottom: parseFloat(style.paddingBottom),
border: parseFloat(cellStyle.borderTopWidth) + parseFloat(cellStyle.borderBottomWidth),
topDifference: short.getBoundingClientRect().top - long.getBoundingClientRect().top,
lines: new Set(Array.from(range.getClientRects()).filter(function (r) { return r.width > 0; }).map(function (r) { return r.top; })).size,
namesAtTop: Array.from(row.querySelectorAll("th")).every(function (th) { return getComputedStyle(th).verticalAlign === "top"; }),
oneLineRow: document.querySelector('tr[data-row-id="11"]').getBoundingClientRect().height };
});
}
const initial = await rowMetrics();
assert.equal(initial.lines, 3, JSON.stringify(initial));
assert.equal(initial.paddingTop, initial.paddingBottom);
assert(Math.abs(initial.row - initial.editor - initial.border) <= 1, JSON.stringify(initial));
assert(Math.abs(initial.topDifference) <= 1, "짧은 셀도 긴 셀과 같은 위치에서 상단 정렬");
assert(initial.namesAtTop, "구역·항목 이름도 상단 정렬");
assert(initial.oneLineRow <= 36, "한 줄 셀은 불필요한 빈 줄 없이 내용에 맞는 높이: " + initial.oneLineRow);
if (!readonly) {
await heightPage.evaluate(function () {
const row = document.querySelector('tr[data-row-id="10"]');
const long = row.querySelector('td[data-month="0"] > div'), short = row.querySelector('td[data-month="1"] > div');
long.value = "한 줄"; short.value = "한 줄";
long.dispatchEvent(new Event("input", { bubbles: true })); short.dispatchEvent(new Event("input", { bubbles: true }));
});
const smaller = await rowMetrics();
assert(smaller.row < initial.row && smaller.row <= 36, JSON.stringify({ initial, smaller }));
await heightPage.evaluate(function () {
const editor = document.querySelector('tr[data-row-id="10"] td[data-month="1"] > div');
editor.value = "pj-rich:v1:" + JSON.stringify([{ text: "큰 글씨\n두 줄", size: 32, bold: true }]);
editor.dispatchEvent(new Event("input", { bubbles: true }));
});
const largeText = await heightPage.evaluate(function () {
const editor = document.querySelector('tr[data-row-id="10"] td[data-month="1"] > div');
return { row: editor.closest("tr").getBoundingClientRect().height, editor: editor.getBoundingClientRect().height,
clipped: editor.scrollHeight > editor.clientHeight, border: parseFloat(getComputedStyle(editor.closest("td")).borderBottomWidth) };
});
assert(largeText.row > smaller.row && !largeText.clipped);
assert(Math.abs(largeText.row - largeText.editor - largeText.border) <= 1, JSON.stringify(largeText));
}
console.log("PASS content row height, symmetric padding, top alignment" + (readonly ? " (read-only)" : ", shrink and large font"));
await heightPage.close();
}
console.log("ALL PASS");
} finally {
if (browser) await browser.close();