feat(project): 목표 표 3열에서 줄 추가 = 같은 항목 칸(2열) 안에 — 항목 칸 묶음

- goal_rows.label_cont(마이그레이션 016): 바로 위 줄 항목 칸에 묶임, 이름은 묶음 첫 줄, 2열 rowspan(_goal_label_spans)
- 3열 우클릭 위/아래에 줄 추가 → same_label: 같은 항목 칸 안(이름 묻지 않음), 첫 줄 위면 새 줄이 첫 줄로 이름 넘겨받음
- 2열 메뉴·+ 줄 추가는 묶음 밖(묶음 맨 위/맨 아래 기준), 묶인 2열 우클릭 → 항목 칸 나누기(split-label)
- 묶음 첫 줄 삭제 → 다음 줄이 첫 줄·이름 넘겨받음, 묶인 줄 이동 400, 새 연도 복사에 묶음 유지
- 캐시 버전 20261001k, DB 회귀 test_goal_label_groups, 문서 갱신

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-01 13:37:40 +09:00
parent ac0672bc11
commit 164153dc9c
15 changed files with 271 additions and 48 deletions
+1 -1
View File
File diff suppressed because one or more lines are too long
+102 -17
View File
@@ -1877,25 +1877,35 @@ class ProjectStore:
(src["year"],),
).fetchall()
plan = []
groups = self._column_exists(conn, "goal_rows", "label_cont")
for a in areas:
labels = conn.execute(
"SELECT label FROM goal_rows WHERE area_id = %s ORDER BY sort_order, id",
"SELECT label" + (", label_cont" if groups else "") + " FROM goal_rows "
"WHERE area_id = %s ORDER BY sort_order, id",
(a["id"],),
).fetchall()
plan.append((a["name"], a["color"], tuple(r["label"] for r in labels) or ("",)))
plan.append((a["name"], a["color"],
tuple((r["label"], bool(r.get("label_cont"))) for r in labels) or (("", False),)))
else:
plan = list(store.DEFAULT_GOAL_AREAS)
plan = [(n, c, tuple((lb, False) for lb in labels)) for n, c, labels in store.DEFAULT_GOAL_AREAS]
groups = self._column_exists(conn, "goal_rows", "label_cont")
for i, (name, color, labels) in enumerate(plan):
aid = conn.execute(
"INSERT INTO goal_areas (year, name, color, sort_order) "
"VALUES (%s, %s, %s, %s) RETURNING id",
(y, name, color, i),
).fetchone()["id"]
for j, label in enumerate(labels):
conn.execute(
"INSERT INTO goal_rows (area_id, label, sort_order) VALUES (%s, %s, %s)",
(aid, label, j),
)
for j, (label, cont) in enumerate(labels):
if groups:
conn.execute(
"INSERT INTO goal_rows (area_id, label, label_cont, sort_order) VALUES (%s, %s, %s, %s)",
(aid, label, cont and j > 0, j),
)
else:
conn.execute(
"INSERT INTO goal_rows (area_id, label, sort_order) VALUES (%s, %s, %s)",
(aid, label, j),
)
def delete_goal_year(self, *, year: int) -> None:
with self._pool.connection() as conn:
@@ -1937,8 +1947,9 @@ class ProjectStore:
"SELECT id, name, color FROM goal_areas WHERE year = %s ORDER BY sort_order, id",
(year,),
).fetchall()
groups = self._column_exists(conn, "goal_rows", "label_cont")
row_rows = conn.execute(
"SELECT r.id, r.area_id, r.label FROM goal_rows r "
"SELECT r.id, r.area_id, r.label" + (", r.label_cont" if groups else "") + " FROM goal_rows r "
"JOIN goal_areas a ON a.id = r.area_id WHERE a.year = %s "
"ORDER BY r.sort_order, r.id",
(year,),
@@ -1974,7 +1985,7 @@ class ProjectStore:
rid = int(r["id"])
rows_by_area.setdefault(int(r["area_id"]), []).append(
{"id": rid, "label": r["label"], "cells": cells.get(rid, {}),
"merges": merges.get(rid, {})}
"merges": merges.get(rid, {}), "label_cont": bool(r.get("label_cont"))}
)
areas = [
{"id": int(a["id"]), "name": a["name"], "color": a["color"],
@@ -1982,7 +1993,7 @@ class ProjectStore:
for a in area_rows
]
return {"year": int(head["year"]), "sales_unit": head["sales_unit"],
"metrics": metrics, "areas": areas, "halves": halves, "rect": rect}
"metrics": metrics, "areas": areas, "halves": halves, "rect": rect, "groups": groups}
def set_goal_metric(
self, *, year: int, metric: str, kind: str, month: int, value: float | None, updated_by: str = ""
@@ -2084,15 +2095,35 @@ class ProjectStore:
if 0 <= j < len(ids) and any(g["r1"] > g["r0"] and (g["r0"] <= i <= g["r1"] or g["r0"] <= j <= g["r1"])
for g in merges):
raise ValueError("세로로 병합된 칸에 걸린 줄은 옮길 수 없습니다. 병합을 해제한 뒤 옮기세요.")
if 0 <= j < len(ids):
conts = self._label_conts(int(me["area_id"]), ids)
in_group = lambda k: conts[k] or (k + 1 < len(ids) and conts[k + 1]) # noqa: E731
if in_group(i) or in_group(j):
raise ValueError("같은 항목 칸으로 묶인 줄은 옮길 수 없습니다. 항목 칸을 나눈 뒤 옮기세요.")
self._move_goal_item("goal_rows", "area_id", row_id, direction)
def _label_conts(self, area_id: int, ids: list[int]) -> list[bool]:
"""영역 줄 순서(ids)대로 label_cont — 016 미적용이면 모두 False."""
with self._pool.connection() as conn:
if not self._column_exists(conn, "goal_rows", "label_cont"):
return [False] * len(ids)
got = {int(r["id"]): bool(r["label_cont"]) for r in conn.execute(
"SELECT id, label_cont FROM goal_rows WHERE area_id = %s", (area_id,)).fetchall()}
return [got.get(i, False) for i in ids]
def add_goal_row(
self, *, area_id: int, label: str = "", ref_row_id: int | None = None, place: str = "below"
self, *, area_id: int, label: str = "", ref_row_id: int | None = None, place: str = "below",
same_label: bool = False,
) -> int:
"""줄 추가 — 기준 줄(ref_row_id)이 있으면 그 줄 위(place="above")/아래("below")에, 없으면 영역 맨 끝에."""
"""줄 추가 — 기준 줄(ref_row_id)이 있으면 그 줄 위(place="above")/아래("below")에, 없으면 영역 맨 끝에.
same_label(3열에서 추가, 016) = 새 줄을 기준 줄과 **같은 항목 칸(2열)** 안에 넣는다: 아래면 새 줄이 묶음에 이어 붙고
(label_cont), 위면 — 기준 줄이 묶음 첫 줄이면 새 줄이 첫 줄이 되어 이름을 넘겨받고 기준 줄이 이어 붙는다."""
lb = store.validate_goal_row_label(label)
if place not in ("above", "below"):
raise ValueError("place 는 above 또는 below 입니다.")
if same_label and ref_row_id is None:
raise ValueError("같은 항목 칸에 추가하려면 기준 줄이 필요합니다.")
with self._pool.connection() as conn:
with conn.transaction():
if not conn.execute(
@@ -2112,11 +2143,29 @@ class ProjectStore:
).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"])
if same_label:
if not self._column_exists(conn, "goal_rows", "label_cont"):
raise store.GoalMigration016Needed()
ref = conn.execute("SELECT label, label_cont FROM goal_rows WHERE id = %s", (ref_row_id,)).fetchone()
if place == "above" and not ref["label_cont"]:
# 묶음 첫 줄 위 — 새 줄이 첫 줄(이름을 넘겨받음), 기준 줄은 이어 붙는다
rid = int(conn.execute(
"INSERT INTO goal_rows (area_id, label, label_cont, sort_order) VALUES (%s, %s, false, 0) "
"RETURNING id", (area_id, ref["label"]),
).fetchone()["id"])
conn.execute("UPDATE goal_rows SET label = '', label_cont = true WHERE id = %s", (ref_row_id,))
else:
rid = int(conn.execute(
"INSERT INTO goal_rows (area_id, label, label_cont, sort_order) VALUES (%s, '', true, 0) "
"RETURNING id", (area_id,),
).fetchone()["id"])
else:
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)
# 따로 추가(2열 메뉴·+)는 화면이 묶음의 맨 위(위에)·맨 아래(아래) 줄을 기준으로 보내 묶음 밖에 들어간다
# 세로 병합 안쪽(시작 줄 아래 ~ 마지막 줄)에 끼우면 엑셀처럼 그 병합이 한 줄 늘어난다
if self._table_exists(conn, "goal_cell_merges") and self._column_exists(
conn, "goal_cell_merges", "row_span"):
@@ -2172,8 +2221,44 @@ class ProjectStore:
"DELETE FROM goal_cell_merges WHERE row_id = %s AND start_month = %s",
(g["row_id"], g["start"]),
)
if self._column_exists(conn, "goal_rows", "label_cont"):
# 묶음 첫 줄을 지우면 바로 아래 이어 붙은 줄이 첫 줄이 되고 이름을 넘겨받는다(비어 있으면)
me2 = conn.execute("SELECT label, label_cont, sort_order FROM goal_rows WHERE id = %s",
(row_id,)).fetchone()
if not me2["label_cont"]:
nxt = conn.execute(
"SELECT id, label, label_cont FROM goal_rows WHERE area_id = %s AND id <> %s "
"AND (sort_order, id) > (%s, %s) ORDER BY sort_order, id LIMIT 1",
(me["area_id"], row_id, me2["sort_order"], row_id),
).fetchone()
if nxt and nxt["label_cont"]:
conn.execute(
"UPDATE goal_rows SET label_cont = false, label = CASE WHEN label = '' THEN %s ELSE label END "
"WHERE id = %s", (me2["label"], nxt["id"]),
)
conn.execute("DELETE FROM goal_rows WHERE id = %s", (row_id,))
def split_goal_label(self, *, row_id: int) -> int:
"""항목 칸 나누기 — row_id(묶음 첫 줄) 아래 이어 붙은 줄들을 각자 항목 칸으로(이름은 빈 칸). 나눈 줄 수."""
with self._pool.connection() as conn:
with conn.transaction():
if not self._column_exists(conn, "goal_rows", "label_cont"):
raise store.GoalMigration016Needed()
me = conn.execute("SELECT area_id FROM goal_rows WHERE id = %s FOR UPDATE", (row_id,)).fetchone()
if me is None:
raise KeyError(row_id)
rows = conn.execute(
"SELECT id, label_cont FROM goal_rows WHERE area_id = %s ORDER BY sort_order, id", (me["area_id"],)
).fetchall()
ids = [int(r["id"]) for r in rows]
n = 0
for r in rows[ids.index(row_id) + 1:]:
if not r["label_cont"]:
break
conn.execute("UPDATE goal_rows SET label_cont = false WHERE id = %s", (r["id"],))
n += 1
return n
def set_goal_cell(self, *, row_id: int, month: int, body: str, updated_by: str = "") -> None:
m = store.validate_goal_month(month, allow_year=True)
text = store.validate_goal_text(body)
+29 -1
View File
@@ -2516,6 +2516,7 @@ def inbox_page(request: Request) -> HTMLResponse:
_GOALS_MIGRATION_MSG = "연간 목표 기능이 아직 준비되지 않았습니다(DB 마이그레이션 013 필요)."
_GOALS_014_MSG = "상·하반기 칸과 칸 병합은 DB 마이그레이션 014 가 필요합니다."
_GOALS_015_MSG = "세로 병합·연간/반기 칸 병합과 주간 회의록은 DB 마이그레이션 015 가 필요합니다."
_GOALS_016_MSG = "같은 항목 칸 안에 줄 추가(3열)는 DB 마이그레이션 016 이 필요합니다."
def _fmt_goal_num(v: float | None) -> str:
@@ -2568,6 +2569,20 @@ def _goal_area_layout(rows: list[dict[str, Any]], this_month: int) -> None:
row["layout"] = out
def _goal_label_spans(rows: list[dict[str, Any]]) -> None:
"""항목 칸(2열) 묶음(016) — 묶음 첫 줄 label_span = 이어 붙은 줄 수 + 1, 이어 붙은 줄은 label_span 0(2열을 그리지 않음).
영역 첫 줄은 늘 묶음 첫 줄."""
for k, row in enumerate(rows):
if k == 0 or not row.get("label_cont"):
row["label_cont"] = False
n = 1
while k + n < len(rows) and rows[k + n].get("label_cont"):
n += 1
row["label_span"] = n
else:
row["label_span"] = 0
def _goal_call(fn: Any, *args: Any, **kwargs: Any) -> Any:
"""목표 DB 호출 공통 — 013 미적용 503, 없는 대상 404, 입력 오류 400."""
try:
@@ -2576,6 +2591,8 @@ def _goal_call(fn: Any, *args: Any, **kwargs: Any) -> Any:
raise HTTPException(status_code=503, detail=_GOALS_014_MSG)
except store.GoalMigration015Needed:
raise HTTPException(status_code=503, detail=_GOALS_015_MSG)
except store.GoalMigration016Needed:
raise HTTPException(status_code=503, detail=_GOALS_016_MSG)
except UndefinedTable:
raise HTTPException(status_code=503, detail=_GOALS_MIGRATION_MSG)
except KeyError:
@@ -2617,6 +2634,7 @@ def goals_page(request: Request, year: int) -> HTMLResponse:
m[kind + "_label"] = {mo: _goal_label(metric, v) for mo, v in m[kind].items()}
for area in board["areas"]:
_goal_area_layout(area["rows"], this_month)
_goal_label_spans(area["rows"])
return render_template(
request,
"project/goals.html",
@@ -2730,7 +2748,8 @@ def api_add_goal_row(request: Request, area_id: int, payload: dict[str, Any] = B
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")
ref_row_id=ref_id, place=payload.get("place") or "below",
same_label=bool(payload.get("same_label")))
return JSONResponse({"ok": True, "id": rid}, status_code=201)
@@ -2750,6 +2769,15 @@ def api_delete_goal_row(request: Request, row_id: int) -> JSONResponse:
return JSONResponse({"ok": True})
@router.post("/api/goals/rows/{row_id}/split-label")
def api_split_goal_label(request: Request, row_id: int) -> JSONResponse:
"""항목 칸 나누기 — 묶음 첫 줄 아래 이어 붙은 줄들을 각자 항목 칸으로(016)."""
_require_admin(request)
st = _db_or_503(request)
n = _goal_call(st.split_goal_label, row_id=row_id)
return JSONResponse({"ok": True, "split": n})
@router.post("/api/goals/rows/{row_id}/move")
def api_move_goal_row(request: Request, row_id: int, payload: dict[str, Any] = Body(...)) -> JSONResponse:
_require_admin(request)
+4
View File
@@ -477,6 +477,10 @@ class GoalMigration015Needed(RuntimeError):
"""세로 병합·주간 회의록은 마이그레이션 015 뒤에만 된다."""
class GoalMigration016Needed(RuntimeError):
"""항목 칸(2열) 묶음(같은 항목 칸 안에 줄 추가)은 마이그레이션 016 뒤에만 된다."""
# 업무 영역 글 칸의 화면 순서 — 연간 · 1~6월 · 상반기 · 7~12월 · 하반기
GOAL_COL_ORDER: tuple[int, ...] = (0, 1, 2, 3, 4, 5, 6, GOAL_H1, 7, 8, 9, 10, 11, 12, GOAL_H2)
@@ -1,7 +1,7 @@
{% extends "erp_base.html" %}
{% block head_extra %}
<link rel="stylesheet" href="/static/project.css?v=20261001j" />
<link rel="stylesheet" href="/static/project.css?v=20261001k" />
<link rel="stylesheet" href="/static/vendor/material-symbols/material-symbols.css" />
{% endblock %}
@@ -246,5 +246,5 @@
{% include "project/_side_modals.html" %}
{% include "project/_member_tasks_modal.html" %}
<script src="/static/project.js?v=20261001j" defer></script>
<script src="/static/project.js?v=20261001k" defer></script>
{% endblock %}
@@ -1,7 +1,7 @@
{% extends "erp_base.html" %}
{% block head_extra %}
<link rel="stylesheet" href="/static/project.css?v=20261001j" />
<link rel="stylesheet" href="/static/project.css?v=20261001k" />
<link rel="stylesheet" href="/static/vendor/material-symbols/material-symbols.css" />
{% endblock %}
@@ -153,12 +153,14 @@
{% endif %}
</th>
{% endif %}
<th class="pj-goal-c2 pj-goal-row-label">
{# 항목 칸(2열) — 같은 항목 칸으로 묶인 줄(016 label_cont)은 묶음 첫 줄이 rowspan 으로 덮는다 #}
{% if not row.label_cont %}
<th class="pj-goal-c2 pj-goal-row-label"{% if row.label_span > 1 %} rowspan="{{ row.label_span }}"{% endif %} data-label-span="{{ row.label_span or 1 }}">
<span class="pj-goal-row-text"{% if is_admin %} data-goal-edit="row" title="눌러서 줄 이름 수정"{% endif %}>{{ row.label }}</span>
{# 줄 도구 — + = 이 줄 아래에 줄 추가, × = 줄 삭제(영역의 마지막 한 줄은 못 지움). 우클릭 메뉴로 위/아래 추가·삭제도 #}
{% if is_admin %}
<span class="pj-goal-tools">
{% if area.rows | length > 1 %}
{% if area.rows | length > 1 and row.label_span == 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 %}
@@ -169,6 +171,7 @@
</span>
{% endif %}
</th>
{% endif %}
{# 칸 배치는 router._goal_area_layout — 엑셀식 사각형 병합(colspan·rowspan), 가려진 칸은 없다 #}
{% for c in row.layout %}
{% set editable = is_admin and (c.kind != 'half' or board.halves) %}
@@ -207,5 +210,5 @@
{% include "project/_side_modals.html" %}
{% include "project/_member_tasks_modal.html" %}
<script src="/static/project.js?v=20261001j" defer></script>
<script src="/static/project.js?v=20261001k" defer></script>
{% endblock %}
@@ -1,7 +1,7 @@
{% extends "erp_base.html" %}
{% block head_extra %}
<link rel="stylesheet" href="/static/project.css?v=20261001j" />
<link rel="stylesheet" href="/static/project.css?v=20261001k" />
<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=20261001j" />
<link rel="stylesheet" href="/static/project.css?v=20261001k" />
<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=20261001j" defer></script>
<script src="/static/project.js?v=20261001k" defer></script>
{% endblock %}
@@ -1,7 +1,7 @@
{% extends "erp_base.html" %}
{% block head_extra %}
<link rel="stylesheet" href="/static/project.css?v=20261001j" />
<link rel="stylesheet" href="/static/project.css?v=20261001k" />
<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=20261001j" defer></script>
<script src="/static/project.js?v=20261001k" defer></script>
{% endblock %}
@@ -1,7 +1,7 @@
{% extends "erp_base.html" %}
{% block head_extra %}
<link rel="stylesheet" href="/static/project.css?v=20261001j" />
<link rel="stylesheet" href="/static/project.css?v=20261001k" />
<!-- 구글 머티리얼 심볼(담당자 아이콘 등) — 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=20261001j" defer></script>
<script src="/static/project.js?v=20261001k" defer></script>
{% endblock %}
@@ -1,7 +1,7 @@
{% extends "erp_base.html" %}
{% block head_extra %}
<link rel="stylesheet" href="/static/project.css?v=20261001j" />
<link rel="stylesheet" href="/static/project.css?v=20261001k" />
<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=20261001j" defer></script>
<script src="/static/project.js?v=20261001k" defer></script>
{% endblock %}
+34 -12
View File
@@ -8437,7 +8437,7 @@
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;
if (!(await insertRow(labelGroupBottom(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") {
@@ -8450,13 +8450,25 @@
});
// ── 줄(항목 칸) 추가·삭제 — 도구 막대의 +·× 와 항목 칸 우클릭 메뉴가 같이 쓴다. 한 일이 있으면 true.
async function insertRow(tr, place) {
const v = await prompt("새 줄 이름 (예: 쿠팡 — 비워 둬도 됩니다)", "");
if (v == null) return false;
// sameLabel = 3열에서 추가 — 새 줄을 기준 줄과 같은 항목 칸(2열) 안에(이름을 묻지 않음, 016)
async function insertRow(tr, place, sameLabel) {
let label = "";
if (!sameLabel) {
const v = await prompt("새 줄 이름 (예: 쿠팡 — 비워 둬도 됩니다)", "");
if (v == null) return false;
label = String(v).trim();
}
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 });
{ label: label, ref_row_id: tr.dataset.rowId, place: place, same_label: !!sameLabel });
return true;
}
// 항목 칸(2열) 묶음의 맨 아래 줄 — 항목 칸 th 의 rowspan 만큼
function labelGroupBottom(tr) {
const th = tr.querySelector("th.pj-goal-row-label");
const span = th ? th.rowSpan || 1 : 1;
const rows = Array.from(tr.closest("tbody").rows);
return rows[Math.min(rows.length - 1, rows.indexOf(tr) + span - 1)];
}
async function deleteRow(tr) {
const lb = textOf(tr, ".pj-goal-row-text");
const label = lb ? "'" + lb + "' 줄" : "이 줄";
@@ -8467,7 +8479,8 @@
}
// 줄 메뉴 항목 — 항목 칸(2열)·연간 칸(3열) 우클릭이 같이 쓴다. top = 위에 추가할 기준 줄, bottom = 아래에 추가할 기준 줄
// (세로 병합된 연간 칸이면 맨 아래 줄), canDelete = 그 줄 하나를 지울 수 있을 때.
function rowMenuItems(top, bottom, canDelete) {
function rowMenuItems(top, bottom, canDelete, opts) {
opts = opts || {};
const run = function (fn) {
return async function () {
try {
@@ -8477,9 +8490,15 @@
};
};
const items = [
{ label: "위에 줄 추가", onClick: run(function () { return insertRow(top, "above"); }) },
{ label: "아래에 줄 추가", onClick: run(function () { return insertRow(bottom, "below"); }) },
{ label: "위에 줄 추가", onClick: run(function () { return insertRow(top, "above", opts.sameLabel); }) },
{ label: "아래에 줄 추가", onClick: run(function () { return insertRow(bottom, "below", opts.sameLabel); }) },
];
if (opts.splitRow) { // 항목 칸 묶음 나누기 — 이어 붙은 줄들이 각자 항목 칸으로
items.push({ label: "항목 칸 나누기", onClick: run(async function () {
await api("POST", "/project/api/goals/rows/" + opts.splitRow.dataset.rowId + "/split-label");
return true;
}) });
}
// 영역의 마지막 한 줄은 못 지운다(영역을 지운다) — 서버도 400
if (canDelete && top.closest(".pj-goal-area").rows.length > 1) {
items.push(null, { label: "줄 삭제", danger: true, onClick: run(async function () {
@@ -8493,9 +8512,12 @@
if (!th || !table.contains(th) || e.target.closest(".is-editing")) return;
e.preventDefault();
const tr = th.closest("tr");
showContextMenu(e.clientX, e.clientY, rowMenuItems(tr, tr, true));
// 2열 = 항목 칸 밖에 따로 추가(묶음의 맨 위·맨 아래 기준), 묶인 칸이면 "항목 칸 나누기"도
showContextMenu(e.clientX, e.clientY, rowMenuItems(tr, labelGroupBottom(tr), true,
{ splitRow: (th.rowSpan || 1) > 1 ? tr : null }));
});
// 3열(연간 칸) 우클릭에도 줄 추가·삭제 — 병합 메뉴가 있으면(014) 그 메뉴에 붙이고, 없으면 여기서
// 3열(연간 칸) 우클릭에도 줄 추가·삭제 — 추가한 줄은 같은 항목 칸(2열) 안에 들어간다(sameLabel, 016).
// 병합 메뉴가 있으면(014) 그 메뉴에 붙이고, 없으면 여기서
function yearCellRows(td) {
const tr = td.closest("tr"), rows = Array.from(td.closest("tbody").rows);
const rspan = parseInt(td.dataset.rspan || "1", 10);
@@ -8507,7 +8529,7 @@
if (!td || !table.contains(td)) return;
e.preventDefault();
const r = yearCellRows(td);
showContextMenu(e.clientX, e.clientY, rowMenuItems(r.top, r.bottom, r.single));
showContextMenu(e.clientX, e.clientY, rowMenuItems(r.top, r.bottom, r.single, { sameLabel: true }));
});
}
@@ -8725,7 +8747,7 @@
if (td.dataset.month === "0" && s.n === 1) { // 3열(연간 칸) 하나 우클릭 — 줄 추가·삭제도
const r = yearCellRows(td);
if (items.length) items.push(null);
rowMenuItems(r.top, r.bottom, r.single).forEach(function (it) { items.push(it); });
rowMenuItems(r.top, r.bottom, r.single, { sameLabel: true }).forEach(function (it) { items.push(it); });
}
if (!items.length) { clearMergeSel(); return; }
e.preventDefault();
+13 -2
View File
@@ -297,6 +297,8 @@ docker exec -i postgres-db psql -U postgres -d project_db \
< scripts/sql/project_db_014_goal_halves_merges.sql
docker exec -i postgres-db psql -U postgres -d project_db \
< scripts/sql/project_db_015_goal_rect_merges_meetings.sql
docker exec -i postgres-db psql -U postgres -d project_db \
< scripts/sql/project_db_016_goal_row_label_groups.sql
# 4) 재배포 (git pull 후 반드시 --build)
cd /opt/www/main && docker compose up -d --build web
@@ -561,8 +563,17 @@ description 을 항상 HTML로 취급하기 때문). 두 번 실행하면 이중
저장된 열 너비가 늦게 적용돼 표가 줄었다 늘어나고 깜박이던 것을 없앴다. 애니메이션: 지운 줄은 흐려지며 사라지고, 남은 줄은 예전
자리에서 미끄러져 오고(FLIP, 0.28초), 새 줄은 위에서 내려오며 보라색으로 잠깐 강조(`is-new-row`), 병합·해제한 칸은 테두리 강조
(`is-merge-flash`). 동작 줄이기 설정이면 애니메이션 없이. 받아 오기 실패하면 예전처럼 새로고침.
- **3열(연간 칸) 우클릭 → 줄 메뉴**: 위에 줄 추가 · 아래에 줄 추가 · 줄 삭제(항목 칸 우클릭과 같은 `rowMenuItems`). 세로로 병합된
연간 칸이면 아래 추가는 병합의 맨 아래 줄 기준, 삭제는 없음. 병합 메뉴(셀 병합·해제)가 있으면 그 아래에 붙는다.
- **3열(연간 칸) 우클릭 → 줄 메뉴**: 위에 줄 추가 · 아래에 줄 추가 · 줄 삭제. **3열에서 추가한 줄은 같은 항목 칸(2열) 안에** 들어간다
(2열은 하나, 3열부터 줄이 늘어남 — 이름을 묻지 않음, `same_label`, 마이그레이션 016). 세로로 병합된 연간 칸이면 아래 추가는 병합의
맨 아래 줄 기준, 삭제는 없음. 병합 메뉴(셀 병합·해제)가 있으면 그 아래에 붙는다.
- **항목 칸(2열) 묶음**(016 `goal_rows.label_cont` = 바로 위 줄 항목 칸에 묶임, 이름은 묶음 첫 줄에): 화면은 `router._goal_label_spans`
가 묶음 첫 줄에 `label_span`(2열 rowspan), 이어 붙은 줄은 2열을 그리지 않는다.
- `POST /api/goals/areas/{id}/rows {ref_row_id, place, same_label: true}` → 아래 = 새 줄이 이어 붙음, 위 = 기준 줄이 묶음 첫 줄이면
새 줄이 첫 줄이 되어 이름을 넘겨받고 기준 줄이 이어 붙음(이어 붙은 줄 위면 그냥 이어 붙음). 016 미적용이면 503.
- 2열 메뉴·+ 의 줄 추가는 **묶음 밖**(위 = 묶음 첫 줄 위, 아래 = 묶음 맨 아래 줄 아래, 이름 물음). 묶인 2열 우클릭 → **항목 칸 나누기**
(`POST /api/goals/rows/{첫 줄}/split-label` — 이어 붙은 줄들이 각자 빈 이름 항목 칸으로).
- 묶음 첫 줄 삭제 → 바로 아래 이어 붙은 줄이 첫 줄이 되고 이름이 비어 있으면 넘겨받음. 묶인 줄(첫 줄·이어 붙은 줄)과 바꾸는 ↑↓ 이동은 400
(나눈 뒤 이동), 묶음 첫 줄 도구 막대엔 ↑↓ 없음. 새 연도 만들기는 묶음도 복사한다.
- **월 머리 → 주간 회의록** — 목표 표 머리의 월 칸을 누르면 `/project/goals/{연도}/meetings/{월}`(6-9-2). 링크(`a.pj-goal-mlink`)는
글자만이 아니라 **칸 전체**(absolute inset 0), 오른쪽 끝 너비 조절 손잡이(z-index 5)는 링크 위라 그대로 끌 수 있다.
- **로아스 단위 %** — 로아스 목표·실적 칸은 `499%` 처럼 보인다(`router._goal_label`, 저장 응답 `label` 도 같음). 입력은 `499`·`499%`
@@ -0,0 +1,26 @@
-- =====================================================================
-- project_db 마이그레이션 016 — 연간 목표: 항목 칸(2열) 묶음
-- =====================================================================
-- 멱등(idempotent). 칸 하나 추가뿐 — 기존 데이터는 그대로(모두 false = 지금과 같은 화면).
--
-- goal_rows.label_cont = true → 이 줄의 항목 칸(2열)은 바로 위 줄의 항목 칸에 묶인다(이름은 묶음 첫 줄에만).
-- 3열(연간 칸)에서 "아래에 줄 추가"를 하면 새 줄이 같은 항목 칸 안에 들어간다(2열은 하나, 3열부터 줄이 늘어남).
--
-- 미적용이어도 목표 화면은 동작한다 — 3열 줄 추가만 "마이그레이션 016 필요".
--
-- 적용 (1회, 여러 번 돌려도 안전):
-- docker exec -i postgres-db psql -U postgres -d project_db \
-- < scripts/sql/project_db_016_goal_row_label_groups.sql
-- =====================================================================
\set ON_ERROR_STOP on
\connect project_db
BEGIN;
ALTER TABLE goal_rows ADD COLUMN IF NOT EXISTS label_cont BOOLEAN NOT NULL DEFAULT false;
COMMENT ON COLUMN goal_rows.label_cont IS 'true = 항목 칸(2열)이 바로 위 줄 항목 칸에 묶임(이름은 묶음 첫 줄에)';
COMMIT;
SELECT 'project_db 016 goal row label groups ready' AS status;
+44
View File
@@ -604,6 +604,50 @@ def test_goal_rect_merges():
ST.delete_goal_year(year=year)
def test_goal_label_groups():
"""항목 칸(2열) 묶음(016): 3열 추가(same_label) 아래 = 이어 붙음, 묶음 첫 줄 위 = 새 줄이 첫 줄(이름 넘겨받음),
묶음 첫 줄 삭제 → 다음 줄이 첫 줄(이름 넘겨받음), 묶인 줄 이동 400, 항목 칸 나누기, 새 연도 복사에 묶음 유지."""
year = 2060 + (int(RUN, 16) + 13) % 40
for y in (year, year + 1):
ST.delete_goal_year(year=y) if y in ST.list_goal_years() else None
assert req("POST", "/project/api/goals/years", ADMIN, json={"year": year}).status_code == 201
try:
assert ST.get_goal_board(year=year)["groups"] is True, "마이그레이션 016 적용 필요"
aid = ST.get_goal_board(year=year)["areas"][0]["id"]
rows = lambda: [(r["label"], r["label_cont"]) for r in ST.get_goal_board(year=year)["areas"][0]["rows"]] # noqa: E731
ids = lambda: [r["id"] for r in ST.get_goal_board(year=year)["areas"][0]["rows"]] # noqa: E731
first = ids()[0]
assert req("PUT", f"/project/api/goals/rows/{first}", ADMIN, json={"label": "마케팅1"}).status_code == 200
add = lambda body: req("POST", f"/project/api/goals/areas/{aid}/rows", ADMIN, json=body) # noqa: E731
assert add({"ref_row_id": first, "place": "below", "same_label": True}).status_code == 201
assert rows()[:2] == [("마케팅1", False), ("", True)]
# 같은 항목 칸 위(첫 줄 위) — 새 줄이 첫 줄, 이름을 넘겨받고 예전 첫 줄은 이어 붙음
r = add({"ref_row_id": first, "place": "above", "same_label": True})
assert r.status_code == 201
assert rows()[:3] == [("마케팅1", False), ("", True), ("", True)], rows()
assert ids()[1] == first
assert add({"same_label": True}).status_code == 400 # 기준 줄 없음
# 묶인 줄 이동 거절
assert req("POST", f"/project/api/goals/rows/{first}/move", ADMIN, json={"direction": 1}).status_code == 400
# 묶음 첫 줄 삭제 → 다음 줄이 첫 줄 + 이름
head = ids()[0]
assert req("DELETE", f"/project/api/goals/rows/{head}", ADMIN).status_code == 200
assert rows()[:2] == [("마케팅1", False), ("", True)], rows()
# 새 연도 복사 — 묶음 유지
assert req("POST", "/project/api/goals/years", ADMIN, json={"year": year + 1}).status_code == 201
nxt = [(r["label"], r["label_cont"]) for r in ST.get_goal_board(year=year + 1)["areas"][0]["rows"]]
assert nxt[:2] == [("마케팅1", False), ("", True)], nxt
# 항목 칸 나누기
r = req("POST", f"/project/api/goals/rows/{ids()[0]}/split-label", ADMIN)
assert r.status_code == 200 and r.json()["split"] == 1
assert rows()[:2] == [("마케팅1", False), ("", False)]
assert req("POST", f"/project/api/goals/rows/{ids()[0]}/split-label", BOB).status_code == 403
finally:
for y in (year, year + 1):
ST.delete_goal_year(year=y) if y in ST.list_goal_years() else None
def test_goal_meetings():
"""주간 회의록: 만들기(처음 = 목표 표 영역 + 기본 양식 줄, 유통 줄 쇼핑몰 추측), 다음 주 = 지난 회의록 줄 이어받기
(carry_from → prev), 금액 표기(만·억), 평가 값 검사, 줄 추가/이동/삭제, 화면·권한."""