feat(project): 연간 목표 모든 열 너비 조절·지표 줄 틀 고정·항목 줄 위/아래 추가·삭제

- 연간·1~12월·상/하반기 열도 머리 칸 오른쪽 끝을 끌어 너비 조절(더블클릭 = 기본), localStorage pj_goal_col_w
  에 기본값과 다른 칸만 저장. 반기 접기 애니메이션의 안쪽 고정 폭은 --fold-w(병합 칸 = 걸친 월 너비 합)
- 세로 스크롤 틀 고정: 머리 줄 + 매출·로아스 지표 줄까지 sticky(줄마다 --kpi-top, stickKpi)
- 항목 칸 도구 막대에 + (아래에 줄 추가) 항상 표시, 우클릭 메뉴로 위/아래 줄 추가·줄 삭제
- POST /api/goals/areas/{id}/rows 에 ref_row_id·place(above|below) — 기준 줄 위/아래에 넣고 순서 다시 매김
- project.css/js 캐시 버전 20261001b, 문서·회귀 테스트 갱신

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-01 09:11:55 +09:00
parent 5d07770ce2
commit d3761183c3
13 changed files with 200 additions and 60 deletions
+1 -1
View File
File diff suppressed because one or more lines are too long
+33 -10
View File
@@ -2071,18 +2071,41 @@ class ProjectStore:
def move_goal_row(self, *, row_id: int, direction: int) -> None:
self._move_goal_item("goal_rows", "area_id", row_id, direction)
def add_goal_row(self, *, area_id: int, label: str = "") -> int:
def add_goal_row(
self, *, area_id: int, label: str = "", ref_row_id: int | None = None, place: str = "below"
) -> int:
"""줄 추가 — 기준 줄(ref_row_id)이 있으면 그 줄 위(place="above")/아래("below")에, 없으면 영역 맨 끝에."""
lb = store.validate_goal_row_label(label)
if place not in ("above", "below"):
raise ValueError("place 는 above 또는 below 입니다.")
with self._pool.connection() as conn:
if not conn.execute("SELECT 1 FROM goal_areas WHERE id = %s", (area_id,)).fetchone():
raise KeyError(area_id)
rid = conn.execute(
"INSERT INTO goal_rows (area_id, label, sort_order) VALUES (%s, %s, "
"(SELECT COALESCE(MAX(sort_order), -1) + 1 FROM goal_rows WHERE area_id = %s)) "
"RETURNING id",
(area_id, lb, area_id),
).fetchone()["id"]
return int(rid)
with conn.transaction():
if not conn.execute(
"SELECT 1 FROM goal_areas WHERE id = %s FOR UPDATE", (area_id,)
).fetchone():
raise KeyError(area_id)
if ref_row_id is None:
rid = conn.execute(
"INSERT INTO goal_rows (area_id, label, sort_order) VALUES (%s, %s, "
"(SELECT COALESCE(MAX(sort_order), -1) + 1 FROM goal_rows WHERE area_id = %s)) "
"RETURNING id",
(area_id, lb, area_id),
).fetchone()["id"]
return int(rid)
ids = [int(r["id"]) for r in conn.execute(
"SELECT id FROM goal_rows WHERE area_id = %s ORDER BY sort_order, id", (area_id,)
).fetchall()]
if ref_row_id not in ids:
raise KeyError(ref_row_id)
rid = int(conn.execute(
"INSERT INTO goal_rows (area_id, label, sort_order) VALUES (%s, %s, 0) RETURNING id",
(area_id, lb),
).fetchone()["id"])
i = ids.index(ref_row_id) + (1 if place == "below" else 0)
ids.insert(i, rid)
for n, x in enumerate(ids):
conn.execute("UPDATE goal_rows SET sort_order = %s WHERE id = %s", (n, x))
return rid
def update_goal_row(self, *, row_id: int, label: str) -> None:
lb = store.validate_goal_row_label(label)
+8 -1
View File
@@ -2705,7 +2705,14 @@ def api_move_goal_area(request: Request, area_id: int, payload: dict[str, Any] =
def api_add_goal_row(request: Request, area_id: int, payload: dict[str, Any] = Body(...)) -> JSONResponse:
_require_admin(request)
st = _db_or_503(request)
rid = _goal_call(st.add_goal_row, area_id=area_id, label=payload.get("label", ""))
# ref_row_id + place(above|below) 가 있으면 그 줄 위/아래에, 없으면 영역 맨 끝에
ref = payload.get("ref_row_id")
try:
ref_id = int(ref) if ref not in (None, "") else None
except (TypeError, ValueError):
raise HTTPException(status_code=400, detail="ref_row_id 가 올바르지 않습니다.")
rid = _goal_call(st.add_goal_row, area_id=area_id, label=payload.get("label", ""),
ref_row_id=ref_id, place=payload.get("place") or "below")
return JSONResponse({"ok": True, "id": rid}, status_code=201)
@@ -1,7 +1,7 @@
{% extends "erp_base.html" %}
{% block head_extra %}
<link rel="stylesheet" href="/static/project.css?v=20261001a" />
<link rel="stylesheet" href="/static/project.css?v=20261001b" />
<link rel="stylesheet" href="/static/vendor/material-symbols/material-symbols.css" />
{% endblock %}
@@ -71,14 +71,16 @@
{# 오른쪽 끝을 끌어 이름 칸 너비 조절 — 브라우저에 기억(localStorage pj_goal_col_w) #}
<th class="pj-goal-c1"><span class="pj-goal-colresize" data-col="c1" title="끌어서 너비 조절"></span></th>
<th class="pj-goal-c2"><span class="pj-goal-colresize" data-col="c2" title="끌어서 너비 조절"></span></th>
<th class="pj-goal-year-col">연간</th>
{# 연간·월·반기 칸도 머리 칸 오른쪽 끝을 끌어 너비 조절(data-col: y · m1~m12 · h1 · h2) #}
<th class="pj-goal-year-col" data-col="y">연간<span class="pj-goal-colresize" data-col="y" title="끌어서 너비 조절"></span></th>
{% for h, hmonths, hm, hname in halves %}
{% for mo in hmonths %}<th class="pj-goal-m{% if mo == this_month %} is-now{% endif %}" data-h="{{ h }}"><span class="pj-goal-mlabel">{{ mo }}월</span></th>{% endfor %}
{% for mo in hmonths %}<th class="pj-goal-m{% if mo == this_month %} is-now{% endif %}" data-h="{{ h }}" data-col="m{{ mo }}"><span class="pj-goal-mlabel">{{ mo }}월</span><span class="pj-goal-colresize" data-col="m{{ mo }}" title="끌어서 너비 조절"></span></th>{% endfor %}
{# 반기 칸 — 버튼으로 그 반기의 월 칸을 접었다 편다(localStorage pj_goal_fold) #}
<th class="pj-goal-half-col" data-h="{{ h }}">
<th class="pj-goal-half-col" data-h="{{ h }}" data-col="h{{ h }}">
<button type="button" class="pj-goal-fold" data-h="{{ h }}" aria-expanded="true"
data-label="{{ hmonths[0] }}~{{ hmonths[-1] }}월"
title="{{ hmonths[0] }}~{{ hmonths[-1] }}월 접기"><span class="material-symbols-outlined">chevron_left</span></button>{{ hname }}
<span class="pj-goal-colresize" data-col="h{{ h }}" title="끌어서 너비 조절"></span>
</th>
{% endfor %}
</tr>
@@ -151,11 +153,17 @@
{% endif %}
<th class="pj-goal-c2 pj-goal-row-label">
<span class="pj-goal-row-text"{% if is_admin %} data-goal-edit="row" title="눌러서 줄 이름 수정"{% endif %}>{{ row.label }}</span>
{% if is_admin and area.rows | length > 1 %}
{# 줄 도구 — + = 이 줄 아래에 줄 추가, × = 줄 삭제(영역의 마지막 한 줄은 못 지움). 우클릭 메뉴로 위/아래 추가·삭제도 #}
{% if is_admin %}
<span class="pj-goal-tools">
{% if area.rows | length > 1 %}
<button type="button" class="pj-icon-btn" data-goal-act="row-up" title="위로">↑</button>
<button type="button" class="pj-icon-btn" data-goal-act="row-down" title="아래로">↓</button>
{% endif %}
<button type="button" class="pj-icon-btn" data-goal-act="row-insert" title="아래에 줄 추가">+</button>
{% if area.rows | length > 1 %}
<button type="button" class="pj-icon-btn" data-goal-act="row-del" title="줄 삭제">×</button>
{% endif %}
</span>
{% endif %}
</th>
@@ -183,7 +191,7 @@
{% if is_admin %}
<div class="pj-goal-foot">
<button type="button" class="pj-btn" id="pj-goal-area-add">+ 업무 영역 추가</button>
<span class="pj-goal-note">칸을 고치면 바로 저장됩니다. 숫자 칸을 비우면 지워집니다.
<span class="pj-goal-note">칸을 고치면 바로 저장됩니다. 숫자 칸을 비우면 지워집니다. 항목 칸을 우클릭하면 줄을 추가·삭제합니다.
{%- if board.halves %} 월 칸은 Shift+클릭으로 여러 칸을 고른 뒤 병합하거나, 우클릭 메뉴로 병합·해제합니다.{% endif %}</span>
</div>
{% endif %}
@@ -197,5 +205,5 @@
{% include "project/_side_modals.html" %}
{% include "project/_member_tasks_modal.html" %}
<script src="/static/project.js?v=20261001a" defer></script>
<script src="/static/project.js?v=20261001b" defer></script>
{% endblock %}
@@ -1,7 +1,7 @@
{% extends "erp_base.html" %}
{% block head_extra %}
<link rel="stylesheet" href="/static/project.css?v=20261001a" />
<link rel="stylesheet" href="/static/project.css?v=20261001b" />
<link rel="stylesheet" href="/static/project-help.css?v=20260926v" />
<link rel="stylesheet" href="/static/vendor/material-symbols/material-symbols.css" />
{% endblock %}
@@ -1,7 +1,7 @@
{% extends "erp_base.html" %}
{% block head_extra %}
<link rel="stylesheet" href="/static/project.css?v=20261001a" />
<link rel="stylesheet" href="/static/project.css?v=20261001b" />
<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=20261001a" defer></script>
<script src="/static/project.js?v=20261001b" defer></script>
{% endblock %}
@@ -1,7 +1,7 @@
{% extends "erp_base.html" %}
{% block head_extra %}
<link rel="stylesheet" href="/static/project.css?v=20261001a" />
<link rel="stylesheet" href="/static/project.css?v=20261001b" />
<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=20261001a" defer></script>
<script src="/static/project.js?v=20261001b" defer></script>
{% endblock %}
@@ -1,7 +1,7 @@
{% extends "erp_base.html" %}
{% block head_extra %}
<link rel="stylesheet" href="/static/project.css?v=20261001a" />
<link rel="stylesheet" href="/static/project.css?v=20261001b" />
<!-- 구글 머티리얼 심볼(담당자 아이콘 등) — 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=20261001a" defer></script>
<script src="/static/project.js?v=20261001b" defer></script>
{% endblock %}
@@ -1,7 +1,7 @@
{% extends "erp_base.html" %}
{% block head_extra %}
<link rel="stylesheet" href="/static/project.css?v=20261001a" />
<link rel="stylesheet" href="/static/project.css?v=20261001b" />
<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=20261001a" defer></script>
<script src="/static/project.js?v=20261001b" defer></script>
{% endblock %}
+18 -9
View File
@@ -2019,11 +2019,12 @@ html.pj-ui-scale .pj-modal-chat { max-height: calc(92vh / var(--pj-z)); }
}
.pj-goal-table tr > :last-child { border-right: none; }
.pj-goal-table thead th {
position: sticky; top: 0; z-index: 3; background: #f7f8f9; height: 32px; padding: 0 10px;
position: sticky; top: 0; z-index: 9; background: #f7f8f9; height: 32px; padding: 0 10px;
font-weight: 700; text-align: center; vertical-align: middle; white-space: nowrap;
}
.pj-goal-table thead th { width: 85px; min-width: 85px; max-width: 85px; } /* 1~12월 */
.pj-goal-table thead th.pj-goal-year-col { width: 90px; min-width: 90px; max-width: 90px; }
/* 열 너비 = 머리 칸 너비(table-layout: fixed). --cw 는 initGoals 가 머리 칸마다 넣는다(끌어서 조절, localStorage pj_goal_col_w) */
.pj-goal-table thead th { width: var(--cw, 85px); min-width: var(--cw, 85px); max-width: var(--cw, 85px); } /* 1~12월 */
.pj-goal-table thead th.pj-goal-year-col { width: var(--cw, 90px); min-width: var(--cw, 90px); max-width: var(--cw, 90px); }
.pj-goal-table thead th.is-now { color: var(--pj-accent-dark); box-shadow: inset 0 -2px 0 var(--pj-accent); }
/* 왼쪽 고정 두 칸(구분·항목) — 너비는 머리 칸 오른쪽 끝을 끌어 조절(initGoals, localStorage
pj_goal_col_w). --goal-c1-w 가 c2 의 left 도 같이 정한다. */
@@ -2036,8 +2037,8 @@ html.pj-ui-scale .pj-modal-chat { max-height: calc(92vh / var(--pj-z)); }
left: var(--goal-c1-w); width: var(--goal-c2-w); min-width: var(--goal-c2-w); max-width: var(--goal-c2-w);
font-weight: 600; color: #3b4048;
}
.pj-goal-table thead th.pj-goal-c1 { z-index: 4; width: var(--goal-c1-w); min-width: var(--goal-c1-w); max-width: var(--goal-c1-w); }
.pj-goal-table thead th.pj-goal-c2 { z-index: 4; width: var(--goal-c2-w); min-width: var(--goal-c2-w); max-width: var(--goal-c2-w); }
.pj-goal-table thead th.pj-goal-c1 { z-index: 10; width: var(--goal-c1-w); min-width: var(--goal-c1-w); max-width: var(--goal-c1-w); }
.pj-goal-table thead th.pj-goal-c2 { z-index: 10; width: var(--goal-c2-w); min-width: var(--goal-c2-w); max-width: var(--goal-c2-w); }
.pj-goal-colresize {
position: absolute; top: 0; right: -4px; bottom: 0; width: 8px; z-index: 5; cursor: col-resize;
}
@@ -2045,10 +2046,18 @@ html.pj-ui-scale .pj-modal-chat { max-height: calc(92vh / var(--pj-z)); }
content: ""; position: absolute; top: 6px; bottom: 6px; left: 3px; width: 2px; border-radius: 2px; background: transparent;
}
.pj-goal-colresize:hover::after, .pj-goal-colresize.is-dragging::after { background: var(--pj-accent); }
/* 월 칸은 overflow: hidden(접기 애니메이션)이라 칸 밖으로 나간 손잡이가 잘린다 — 칸 안쪽 오른쪽 끝에 둔다 */
.pj-goal-table thead th.pj-goal-m .pj-goal-colresize { right: 0; width: 7px; }
.pj-goal-table thead th.pj-goal-m .pj-goal-colresize::after { left: auto; right: 1px; }
html.pj-goal-resizing, html.pj-goal-resizing * { cursor: col-resize !important; user-select: none !important; }
.pj-goal-table tbody th { padding: 7px 8px; vertical-align: middle; } /* 왼쪽 이름은 세로 가운데 */
/* 숫자 지표 */
/* 숫자 지표 — 틀 고정: 머리 줄 아래에 로아스 줄까지 붙어 있다(줄마다 top = --kpi-top, initGoals stickKpi).
z-index: 업무 영역 이름 칸 2(마우스 올림 6) < 지표 칸 7 < 지표 이름 칸 8 < 머리 줄 9 < 머리 이름 칸 10.
스크롤에 아래 줄이 비치지 않게 배경을 채운다(:where = 아래 .pj-goal-sum 등 배경이 이긴다). */
.pj-goal-kpi > tr > * { position: sticky; top: var(--kpi-top, 0); z-index: 7; }
.pj-goal-kpi > tr > .pj-goal-c1, .pj-goal-kpi > tr > .pj-goal-c2 { z-index: 8; }
:where(.pj-goal-kpi) td { background: #fff; }
.pj-goal-kpi td { height: 32px; vertical-align: middle; }
.pj-goal-kpi td.is-now { background: #faf9ff; }
input.pj-goal-num, span.pj-goal-num {
@@ -2099,7 +2108,7 @@ textarea.pj-goal-text::placeholder { color: rgba(0, 0, 0, .3); }
/* 상반기·하반기 칸 — 6월·12월 오른쪽. 앞 칸 오른쪽 테두리와 겹쳐 두 줄로 구분된다. */
.pj-goal-table thead th.pj-goal-half-col {
width: 90px; min-width: 90px; max-width: 90px; padding: 0 6px; background: #eef0f3;
width: var(--cw, 90px); min-width: var(--cw, 90px); max-width: var(--cw, 90px); padding: 0 6px; background: #eef0f3;
}
.pj-goal-table .pj-goal-half-col { border-left: 1px solid #cfd3d8; }
.pj-goal-kpi td.pj-goal-half-col { background: #f4f5f7; }
@@ -2116,13 +2125,13 @@ textarea.pj-goal-text::placeholder { color: rgba(0, 0, 0, .3); }
.pj-goal-fold.is-folded { background: var(--pj-accent-tint); color: var(--pj-accent-dark); }
.pj-goal-fold.is-folded .material-symbols-outlined { transform: rotate(180deg); }
/* 접기 애니메이션 — 월 칸 너비를 0 으로(.is-shrunk) 줄인 뒤 숨김(.is-gone), 펼 땐 거꾸로(initGoals applyFold).
줄어드는 동안 칸 안 글이 다시 줄바꿈돼 줄 높이가 출렁이지 않게 안쪽 내용은 원래 폭(85px × 칸 수)으로 고정해 잘라 낸다. */
줄어드는 동안 칸 안 글이 다시 줄바꿈돼 줄 높이가 출렁이지 않게 안쪽 내용은 원래 폭(--fold-w = 걸친 월 너비 합)으로 고정해 잘라 낸다. */
.pj-goal-table .pj-goal-m { overflow: hidden; }
.pj-goal-table.is-folding .pj-goal-m {
transition: width .32s ease, min-width .32s ease, max-width .32s ease,
padding .32s ease, border-right-width .32s ease;
}
.pj-goal-table.is-folding td.pj-goal-m > * { width: calc(85px * var(--span, 1) - 1px); }
.pj-goal-table.is-folding td.pj-goal-m > * { width: var(--fold-w, calc(85px * var(--span, 1) - 1px)); }
.pj-goal-table thead th.pj-goal-m.is-shrunk,
.pj-goal-table td.pj-goal-m.is-shrunk {
width: 0; min-width: 0; max-width: 0; padding-left: 0 !important; padding-right: 0 !important; border-right-width: 0;
+97 -21
View File
@@ -7952,21 +7952,42 @@
const year = table.dataset.year;
const isAdmin = table.dataset.admin === "true";
// ── 왼쪽 이름 두 칸(구분·항목) 너비 — 머리 칸 오른쪽 끝을 끌어 조절, 브라우저에 기억 ──
// 화면 배율(uiZoom) 안이라 마우스 이동 거리는 배율로 나눈다.
// ── 열 너비 — 머리 칸 오른쪽 끝을 끌어 조절, 브라우저에 기억(localStorage pj_goal_col_w) ──
// · c1·c2 = 왼쪽 이름 두 칸(구분·항목) → 표의 CSS 변수 --goal-c1-w·--goal-c2-w(c2 의 left 도 c1 너비로 정해진다)
// · y = 연간, m1~m12 = 월, h1·h2 = 상·하반기 → 그 머리 칸의 --cw(표는 table-layout: fixed 라 머리 칸 너비가 열 너비)
// 화면 배율(uiZoom) 안이라 마우스 이동 거리는 배율로 나눈다. 더블클릭 = 기본 너비.
const COL_KEY = "pj_goal_col_w";
const COL_MIN = 48, COL_MAX = 320;
const colW = { c1: 72, c2: 72 };
const colDefault = { c1: 72, c2: 72, y: 90, h1: 90, h2: 90 };
for (let m = 1; m <= 12; m++) colDefault["m" + m] = 85;
function colLimit(key) { return key === "c1" || key === "c2" ? [48, 320] : [40, 600]; }
function clampCol(key, w) { const lim = colLimit(key); return Math.min(lim[1], Math.max(lim[0], w)); }
const colW = Object.assign({}, colDefault);
try {
const saved = JSON.parse(localStorage.getItem(COL_KEY) || "null");
if (saved) ["c1", "c2"].forEach(function (k) {
if (saved) Object.keys(colDefault).forEach(function (k) {
const v = parseInt(saved[k], 10);
if (v) colW[k] = Math.min(COL_MAX, Math.max(COL_MIN, v));
if (v) colW[k] = clampCol(k, v);
});
} catch (_) {}
function saveColW() {
// 기본값과 같은 칸은 저장하지 않는다(나중에 기본 너비를 바꾸면 따라가게)
const out = {};
Object.keys(colW).forEach(function (k) { if (colW[k] !== colDefault[k]) out[k] = colW[k]; });
try { localStorage.setItem(COL_KEY, JSON.stringify(out)); } catch (_) {}
}
function applyColW() {
table.style.setProperty("--goal-c1-w", colW.c1 + "px");
table.style.setProperty("--goal-c2-w", colW.c2 + "px");
table.querySelectorAll("thead th[data-col]").forEach(function (th) {
th.style.setProperty("--cw", colW[th.dataset.col] + "px");
});
// 반기 접기 애니메이션 동안 월 칸 안 내용을 고정할 폭(병합 칸 = 걸친 월 너비 합, 오른쪽 테두리 1px 빼고)
table.querySelectorAll("td.pj-goal-m[data-month]").forEach(function (td) {
const m = parseInt(td.dataset.month, 10), span = parseInt(td.dataset.span || "1", 10);
let w = 0;
for (let i = m; i < m + span; i++) w += colW["m" + i] || 85;
td.style.setProperty("--fold-w", (w - 1) + "px");
});
}
applyColW();
table.querySelectorAll(".pj-goal-colresize").forEach(function (h) {
@@ -7979,8 +8000,7 @@
h.classList.add("is-dragging");
document.documentElement.classList.add("pj-goal-resizing");
function onMove(ev) {
const w = Math.round(startW + (ev.clientX - startX) / uiZoom());
colW[key] = Math.min(COL_MAX, Math.max(COL_MIN, w));
colW[key] = clampCol(key, Math.round(startW + (ev.clientX - startX) / uiZoom()));
applyColW();
}
function onUp() {
@@ -7988,19 +8008,37 @@
document.removeEventListener("mouseup", onUp);
h.classList.remove("is-dragging");
document.documentElement.classList.remove("pj-goal-resizing");
try { localStorage.setItem(COL_KEY, JSON.stringify(colW)); } catch (_) {}
saveColW();
fitAll(); // 폭이 바뀌면 글 줄바꿈이 달라진다
}
document.addEventListener("mousemove", onMove);
document.addEventListener("mouseup", onUp);
});
// 두 번 누르면 기본 너비(72px)로
h.addEventListener("dblclick", function () {
colW[h.dataset.col] = 72;
h.addEventListener("click", function (e) { e.stopPropagation(); });
h.addEventListener("dblclick", function (e) {
e.stopPropagation();
colW[h.dataset.col] = colDefault[h.dataset.col];
applyColW();
try { localStorage.setItem(COL_KEY, JSON.stringify(colW)); } catch (_) {}
saveColW();
fitAll();
});
});
// ── 틀 고정 — 머리 줄 아래 숫자 지표(매출·로아스) 줄까지 세로 스크롤에도 위에 붙어 있다.
// 줄마다 sticky top(--kpi-top) = 머리 줄 높이 + 앞 지표 줄 높이 합. 배율 안이라 offsetHeight(배율 전 값)로 잰다.
function stickKpi() {
const head = table.tHead && table.tHead.rows[0];
if (!head) return;
let top = head.offsetHeight;
table.querySelectorAll("tbody.pj-goal-kpi > tr").forEach(function (tr) {
tr.style.setProperty("--kpi-top", top + "px");
top += tr.offsetHeight;
});
}
stickKpi();
if (document.fonts && document.fonts.ready) document.fonts.ready.then(stickKpi);
window.addEventListener("resize", stickKpi);
// ── 합계·달성률 ──
function numOf(node) {
const raw = (node.tagName === "INPUT" ? node.value : node.textContent) || "";
@@ -8118,6 +8156,7 @@
ta.style.height = "auto";
ta.style.height = ta.scrollHeight + "px";
}
function fitAll() { table.querySelectorAll("textarea.pj-goal-text").forEach(fit); }
applyFold(1, false);
applyFold(2, false);
@@ -8181,9 +8220,7 @@
ta.addEventListener("blur", function () { saveText(ta); });
});
// 한 줄 안 칸들 높이는 표가 맞춘다 — 창 폭이 바뀌면 글 줄바꿈이 달라지니 다시 잰다.
window.addEventListener("resize", function () {
table.querySelectorAll("textarea.pj-goal-text").forEach(fit);
});
window.addEventListener("resize", fitAll);
window.addEventListener("beforeunload", function () {
pending.forEach(function (timer, ta) {
clearTimeout(timer);
@@ -8306,20 +8343,59 @@
const v = await prompt("새 줄 이름 (예: 쿠팡 — 비워 둬도 됩니다)", "");
if (v == null) return;
await api("POST", "/project/api/goals/areas/" + areaId + "/rows", { label: String(v).trim() });
} else if (act === "row-insert") {
if (!(await insertRow(tr, "below"))) return;
} else if (act === "row-up" || act === "row-down") {
await api("POST", "/project/api/goals/rows/" + rowId + "/move", { direction: act === "row-up" ? -1 : 1 });
} else if (act === "row-del") {
const lb = textOf(tr, ".pj-goal-row-text");
const label = lb ? "'" + lb + "' 줄" : "이 줄";
const ok = await confirm(label + "을 삭제할까요? 그 줄의 글도 모두 삭제됩니다.", { okText: "삭제", cancelText: "취소" });
if (!ok) return;
await api("DELETE", "/project/api/goals/rows/" + rowId);
if (!(await deleteRow(tr))) return;
} else return;
await flushTexts();
reloadKeepScroll();
} catch (err) { showToast("처리 실패: " + err.message, "error"); }
});
// ── 줄(항목 칸) 추가·삭제 — 도구 막대의 +·× 와 항목 칸 우클릭 메뉴가 같이 쓴다. 한 일이 있으면 true.
async function insertRow(tr, place) {
const v = await prompt("새 줄 이름 (예: 쿠팡 — 비워 둬도 됩니다)", "");
if (v == null) return false;
await api("POST", "/project/api/goals/areas/" + tr.closest(".pj-goal-area").dataset.areaId + "/rows",
{ label: String(v).trim(), ref_row_id: tr.dataset.rowId, place: place });
return true;
}
async function deleteRow(tr) {
const lb = textOf(tr, ".pj-goal-row-text");
const label = lb ? "'" + lb + "' 줄" : "이 줄";
const ok = await confirm(label + "을 삭제할까요? 그 줄의 글도 모두 삭제됩니다.", { okText: "삭제", cancelText: "취소" });
if (!ok) return false;
await api("DELETE", "/project/api/goals/rows/" + tr.dataset.rowId);
return true;
}
table.addEventListener("contextmenu", function (e) {
const th = e.target.closest("th.pj-goal-row-label");
if (!th || !table.contains(th) || e.target.closest(".is-editing")) return;
e.preventDefault();
const tr = th.closest("tr");
const run = function (fn) {
return async function () {
try {
if (!(await fn())) return;
await flushTexts();
reloadKeepScroll();
} catch (err) { showToast("처리 실패: " + err.message, "error"); }
};
};
const items = [
{ label: "위에 줄 추가", onClick: run(function () { return insertRow(tr, "above"); }) },
{ label: "아래에 줄 추가", onClick: run(function () { return insertRow(tr, "below"); }) },
];
// 영역의 마지막 한 줄은 못 지운다(영역을 지운다) — 서버도 400
if (tr.closest(".pj-goal-area").rows.length > 1) {
items.push(null, { label: "줄 삭제", danger: true, onClick: run(function () { return deleteRow(tr); }) });
}
showContextMenu(e.clientX, e.clientY, items);
});
// ── 영역·줄 이름 — 눌러서 그 자리에서 수정(Enter·칸 떠남 = 저장, Esc = 취소). 서식 없이 글자만. ──
function startNameEdit(span) {
if (span.isContentEditable) return;
+4 -2
View File
@@ -491,7 +491,8 @@ description 을 항상 HTML로 취급하기 때문). 두 번 실행하면 이중
(`initGoalSide`, localStorage `pj_goal_open`, 목표 화면에선 항상 펼침). 연도 목록은 `router._goal_years_nav`
(`goal_years` 최근 연도 먼저 + **올해는 항상**, 013 미적용이면 올해만) — 사이드바를 그리는 모든 화면 컨텍스트에 `goal_years`.
- 연도를 누르면 `/project/goals/{연도}`(`goals.html`) — 스프레드시트 같은 한 표. 머리 줄(연간·1~12월)과 왼쪽 두 칸은 고정,
이번 달 열 강조. 월 칸 너비 85px·연간 90px(여백 포함, `box-sizing: border-box`), 머리·왼쪽 이름 가운데 정렬(왼쪽 이름은 세로도 가운데 — 관리자 도구는 칸 아래에 떠 있는 막대라 자리를 차지하지 않음). 왼쪽 이름 두 칸(구분·항목)은 머리 칸 오른쪽 끝을 끌어 너비 조절(48~320px, 더블클릭 = 72px) — 브라우저별 localStorage `pj_goal_col_w`, CSS 변수 `--goal-c1-w`·`--goal-c2-w`.
이번 달 열 강조. 월 칸 너비 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 가 넣는다.
- **틀 고정** — 세로 스크롤에도 머리 줄 + 숫자 지표(매출·로아스) 줄까지 위에 붙어 있다. 지표 칸 `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)) —
매출 목표/실적/달성, 로아스 목표/실적. 매출 연간 = 월 합계, 달성률 = 실적÷목표(월별, 연간은 실적이 있는 달의 목표 합계 대비)는
화면에서 계산(저장 안 함). 매출 단위 글자는 `goal_years.sales_unit`.
@@ -503,7 +504,7 @@ description 을 항상 HTML로 취급하기 때문). 두 번 실행하면 이중
관리자에게 "목표 만들기" 버튼(GET 에서 자동 생성하지 않는다). 연도 삭제는 연도를 직접 입력해야 진행(CASCADE 전부 삭제).
- API(전부 관리자): `PUT /api/goals/{y}` `{sales_unit}` · `DELETE /api/goals/{y}` · `PUT /api/goals/{y}/metrics`
`{metric,kind,month,value}`(빈값 = 지움, 응답 `label` 은 쉼표 표기) · `POST /api/goals/{y}/areas` `{name,color}` ·
`PUT|DELETE /api/goals/areas/{id}` · `POST /api/goals/areas/{id}/move` `{direction:-1|1}` · `POST /api/goals/areas/{id}/rows` ·
`PUT|DELETE /api/goals/areas/{id}` · `POST /api/goals/areas/{id}/move` `{direction:-1|1}` · `POST /api/goals/areas/{id}/rows` `{label, ref_row_id?, place?: above|below}`(기준 줄 위/아래, 없으면 맨 끝) ·
`PUT|DELETE /api/goals/rows/{id}` · `POST /api/goals/rows/{id}/move` · `PUT /api/goals/rows/{id}/cells/{month}` `{body}`.
013 미적용 503, 없는 대상 404, 입력 오류 400(`_goal_call`).
- 화면 동작(`initGoals`): 숫자 칸은 Enter/칸 떠남에 저장(Esc 취소), 글 칸은 0.8초 멈춤·칸 떠남·페이지 떠남(keepalive)에 저장,
@@ -529,6 +530,7 @@ description 을 항상 HTML로 취급하기 때문). 두 번 실행하면 이중
- **영역·줄 이름 바로 수정**(관리자) — 이름(`[data-goal-edit="area|row"]`)을 누르면 contenteditable(`startNameEdit`) —
Enter·칸 떠남 = 저장, Esc = 취소, 붙여넣기는 글자만. 영역 이름 빈 값은 되돌림(서버도 400), 줄 이름은 빈 값 허용(빈 줄 이름은
마우스를 올리면 "줄 이름" 자리 표시). 예전 ✎(prompt) 버튼은 없앴고 도구 막대는 색·↑·↓·+·× 만.
- **줄 추가·삭제(항목 칸)**(관리자) — 줄 이름 칸 도구 막대: ↑·↓(줄 2개 이상)·**+ = 이 줄 아래에 줄 추가**·×(줄 2개 이상). 항목 칸 **우클릭 메뉴**: 위에 줄 추가 / 아래에 줄 추가 / 줄 삭제(영역의 마지막 한 줄이면 없음). 추가는 이름을 묻고(비워도 됨) `db.add_goal_row(ref_row_id, place)` 가 영역 줄 순서를 다시 매긴다(영역 FOR UPDATE). 영역 이름 칸의 + 는 예전처럼 맨 끝에 추가.
- **월 칸 병합**(관리자, 014) — `goal_cell_merges(row_id, start_month, span)` — 한 줄 안에서 가로로만, **같은 반기 안에서만**
(DB CHECK + `store.validate_goal_merge`), 2칸 이상. 화면은 `router._goal_row_layout` 이 줄마다 칸 배치(병합이면 `colspan`)를 만든다.
- 고르기: 월 칸을 누른 뒤 **Shift+클릭**(같은 줄·같은 반기) → 칸 테두리 강조 + 떠 있는 "N~M월 병합" 버튼(`.pj-goal-mergebar`,
+15
View File
@@ -521,6 +521,21 @@ def test_goal_halves_and_merges():
assert req("PUT", f"/project/api/goals/areas/{aid}", ADMIN, json={"name": ""}).status_code == 400
assert req("PUT", f"/project/api/goals/areas/{aid}", ADMIN, json={"name": "상품2"}).status_code == 200
assert req("PUT", f"/project/api/goals/rows/{rid}", ADMIN, json={"label": ""}).status_code == 200
# 줄 추가 — 기준 줄 위/아래(ref_row_id + place), 없으면 맨 끝. 다른 영역 줄 기준은 404, place 오류는 400
add = lambda body, who=ADMIN: req( # noqa: E731
"POST", f"/project/api/goals/areas/{aid}/rows", who, json=body)
labels = lambda: [r["label"] for r in ST.get_goal_board(year=year)["areas"][0]["rows"]] # noqa: E731
before = labels()
assert add({"label": "끝"}).status_code == 201
assert add({"label": "아래", "ref_row_id": rid, "place": "below"}).status_code == 201
assert add({"label": "위", "ref_row_id": rid, "place": "above"}).status_code == 201
assert labels() == ["위", before[0], "아래"] + before[1:] + ["끝"], labels()
areas = ST.get_goal_board(year=year)["areas"]
if len(areas) > 1:
assert add({"label": "x", "ref_row_id": areas[1]["rows"][0]["id"]}).status_code == 404
assert add({"label": "x", "ref_row_id": rid, "place": "left"}).status_code == 400
assert add({"label": "x", "ref_row_id": "abc"}).status_code == 400
assert add({"label": "x"}, BOB).status_code == 403
finally:
ST.delete_goal_year(year=year)