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
+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();