feat(project): 목표 표 1·2열 마우스 오버 도구 막대 제거 → 우클릭 메뉴로

- 1열(구역) 우클릭: 색 바꾸기(색 창은 우클릭 자리)·위로·아래로·줄 추가(구역 맨 아래)·영역 삭제 — goalAct 로 정리
- 2열(항목) 우클릭: 기존 줄 추가·삭제·항목 칸 나누기 + 위로·아래로(묶이지 않은 칸)
- 도구 막대 템플릿·JS(placeTools)·CSS 제거, 영역 색은 tbody[data-color], 캐시 버전 20261001q, 문서 갱신

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-01 14:49:43 +09:00
parent 2a9f6f5628
commit 5460c7f676
10 changed files with 66 additions and 121 deletions
+42 -58
View File
@@ -8326,7 +8326,7 @@
document.removeEventListener("mousedown", onColorDocDown, true);
}
function onColorDocDown(e) { if (colorPop && !colorPop.contains(e.target)) closeColorPop(); }
function openColorPop(anchor, areaId, current, tbody) {
function openColorPop(pt, areaId, current, tbody) {
closeColorPop();
colorPop = document.createElement("div");
colorPop.className = "pj-goal-colorpop";
@@ -8338,10 +8338,9 @@
'" data-c="' + c + '" style="background:' + c + '"></button>';
}).join("");
document.body.appendChild(colorPop);
const r = anchor.getBoundingClientRect();
const w = colorPop.offsetWidth;
colorPop.style.left = Math.max(8, Math.min(r.left, document.documentElement.clientWidth - w - 8)) + "px";
colorPop.style.top = (r.bottom + 6) + "px";
const w = colorPop.offsetWidth, h = colorPop.offsetHeight;
colorPop.style.left = Math.max(8, Math.min(pt.x, document.documentElement.clientWidth - w - 8)) + "px";
colorPop.style.top = Math.max(8, Math.min(pt.y + 6, document.documentElement.clientHeight - h - 8)) + "px";
colorPop.addEventListener("click", async function (e) {
const sw = e.target.closest(".pj-goal-swatch, .pj-goal-swatch-none");
if (!sw) return;
@@ -8350,13 +8349,13 @@
try {
await api("PUT", "/project/api/goals/areas/" + areaId, { color: c || "none" });
tbody.style.setProperty("--goal-bg", c || "#fff");
anchor.dataset.color = c;
tbody.dataset.color = c;
} catch (err) { showToast("색 변경 실패: " + err.message, "error"); }
});
setTimeout(function () { document.addEventListener("mousedown", onColorDocDown, true); }, 0);
}
// ── 영역·줄 도구(색 ↑ ↓ + ×) — 이벤트 위임. 이름 바꾸기는 이름을 눌러 그 자리에서(아래 startNameEdit) ──
// ── 구역(1열) 작업 — 우클릭 메뉴(areaMenuItems)가 부른다. 이름 바꾸기는 이름을 눌러 그 자리에서(아래 startNameEdit) ──
function textOf(node, sel) {
const t = node && node.querySelector(sel);
return t ? t.textContent.trim() : "";
@@ -8424,17 +8423,11 @@
}
}
}
table.addEventListener("click", async function (e) {
const b = e.target.closest("[data-goal-act]");
if (!b) return;
const act = b.dataset.goalAct;
const tbody = b.closest(".pj-goal-area");
const tr = b.closest("tr");
const areaId = tbody && tbody.dataset.areaId;
const rowId = tr && tr.dataset.rowId;
async function goalAct(act, tbody, pt) {
const areaId = tbody.dataset.areaId;
try {
if (act === "area-color") {
openColorPop(b, areaId, b.dataset.color, tbody);
openColorPop(pt, areaId, tbody.dataset.color || "", tbody);
return;
} else if (act === "area-up" || act === "area-down") {
await api("POST", "/project/api/goals/areas/" + areaId + "/move", { direction: act === "area-up" ? -1 : 1 });
@@ -8450,20 +8443,31 @@
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(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") {
if (!(await deleteRow(tr))) return;
await refreshTable({ removed: [tr] });
return;
} else return;
await refreshTable();
} catch (err) { showToast("처리 실패: " + err.message, "error"); }
}
// 1열(구역 칸) 우클릭 메뉴 — 예전 마우스 오버 도구 막대(색·↑·↓·+·×)를 옮겼다
function areaMenuItems(tbody, pt) {
const areas = Array.from(table.querySelectorAll("tbody.pj-goal-area"));
const i = areas.indexOf(tbody);
const go = function (act) { return function () { goalAct(act, tbody, pt); }; };
const items = [{ label: "색 바꾸기", icon: menuIcon("palette"), onClick: go("area-color") }];
if (i > 0) items.push({ label: "위로", icon: menuIcon("arrow_upward"), onClick: go("area-up") });
if (i < areas.length - 1) items.push({ label: "아래로", icon: menuIcon("arrow_downward"), onClick: go("area-down") });
items.push({ label: "줄 추가(구역 맨 아래)", icon: menuIcon("add_row_below"), onClick: go("row-add") });
items.push(null, { label: "영역 삭제", danger: true, icon: menuIcon("delete"), onClick: go("area-del") });
return items;
}
table.addEventListener("contextmenu", function (e) {
const th = e.target.closest("th.pj-goal-area-name");
if (!th || !table.contains(th) || e.target.closest(".is-editing")) return;
e.preventDefault();
const pt = { x: e.clientX, y: e.clientY };
showContextMenu(e.clientX, e.clientY, areaMenuItems(th.closest("tbody"), pt));
});
// ── 줄(항목 칸) 추가·삭제 — 도구 막대의 +·× 와 항목 칸 우클릭 메뉴가 같이 쓴다. 한 일이 있으면 true.
// ── 줄(항목 칸) 추가·삭제 — 항목 칸·연간 칸 우클릭 메뉴가 쓴다. 한 일이 있으면 true.
// sameLabel = 3열에서 추가 — 새 줄을 기준 줄과 같은 항목 칸(2열) 안에(이름을 묻지 않음, 016)
async function insertRow(tr, place, sameLabel) {
let label = "";
@@ -8507,6 +8511,17 @@
{ label: "위에 줄 추가", icon: menuIcon("add_row_above"), onClick: run(function () { return insertRow(top, "above", opts.sameLabel); }) },
{ label: "아래에 줄 추가", icon: menuIcon("add_row_below"), onClick: run(function () { return insertRow(bottom, "below", opts.sameLabel); }) },
];
if (opts.move) { // 2열 — 줄 순서(묶인 줄은 서버가 막으므로 묶음이 아닐 때만)
const rows = Array.from(opts.move.closest("tbody").rows), k = rows.indexOf(opts.move);
const mv = function (dir) {
return run(async function () {
await api("POST", "/project/api/goals/rows/" + opts.move.dataset.rowId + "/move", { direction: dir });
return true;
});
};
if (k > 0) items.push({ label: "위로", icon: menuIcon("arrow_upward"), onClick: mv(-1) });
if (k < rows.length - 1) items.push({ label: "아래로", icon: menuIcon("arrow_downward"), onClick: mv(1) });
}
if (opts.splitRow) { // 항목 칸 묶음 나누기 — 이어 붙은 줄들이 각자 항목 칸으로
items.push({ label: "항목 칸 나누기", icon: menuIcon("horizontal_split"), onClick: run(async function () {
await api("POST", "/project/api/goals/rows/" + opts.splitRow.dataset.rowId + "/split-label");
@@ -8527,8 +8542,9 @@
e.preventDefault();
const tr = th.closest("tr");
// 2열 = 항목 칸 밖에 따로 추가(묶음의 맨 위·맨 아래 기준), 묶인 칸이면 "항목 칸 나누기"도
const grouped = (th.rowSpan || 1) > 1;
showContextMenu(e.clientX, e.clientY, rowMenuItems(tr, labelGroupBottom(tr), true,
{ splitRow: (th.rowSpan || 1) > 1 ? tr : null }));
{ splitRow: grouped ? tr : null, move: grouped ? null : tr }));
});
// 3열(연간 칸) 우클릭에도 줄 추가·삭제 — 추가한 줄은 같은 항목 칸(2열) 안에 들어간다(sameLabel, 016).
// 병합 메뉴가 있으면(014) 그 메뉴에 붙이고, 없으면 여기서
@@ -8547,38 +8563,6 @@
});
}
// ── 영역·줄 도구 막대(색 ↑ ↓ + ×) — 마우스 커서 **오른쪽 위**에.
// 커서 바로 오른쪽(같은 높이)에 두면 옆 칸으로 가로질러 갈 때 막대에 걸려 옆 칸 막대가 안 뜨고 막대가 "고정"돼 버린다
// (2026-10-01 버그). 오른쪽 위에 두면 가로로는 막대 밑으로 지나가 옆 칸으로 넘어가고, 막대를 누를 땐 오른쪽 위로 간다.
// 막대는 커서가 막대에서 멀어질 때(왼쪽·아래)만 따라오고, 막대 쪽(오른쪽·위)으로 갈 땐 그 자리에 있어 도망가지 않는다.
// 커서가 막대보다 훨씬 위로 가면 다시 커서 높이로. 막대 시작점은 이름 칸 안(오른쪽 끝 − 10px 까지).
// 막대는 이름 칸 안 요소라 막대 위에서도 칸 호버가 이어진다. 화면 배율(uiZoom) 안이라 거리는 배율로 나눈다.
const TOOL_HOSTS = "th.pj-goal-area-name, th.pj-goal-row-label";
let toolAnchor = null; // {th, x, y} — 막대 기준점(커서 자리, 뷰포트 좌표)
function placeTools(th, e) {
const tools = th.querySelector(".pj-goal-tools");
if (!tools || (e.target && e.target.closest && e.target.closest(".pj-goal-tools"))) return;
const r = th.getBoundingClientRect(), z = uiZoom(), h = tools.offsetHeight * z;
if (!toolAnchor || toolAnchor.th !== th) toolAnchor = { th: th, x: e.clientX, y: e.clientY };
else {
toolAnchor.x = Math.min(toolAnchor.x, e.clientX); // 왼쪽으로는 따라감
if (e.clientY > toolAnchor.y || e.clientY < toolAnchor.y - h - 16) toolAnchor.y = e.clientY; // 아래로·훨씬 위로는 따라감
}
tools.classList.add("is-at-cursor");
tools.style.left = Math.round(Math.min((toolAnchor.x - r.left) / z + 8, r.width / z - 10)) + "px";
tools.style.top = Math.round((toolAnchor.y - r.top) / z - tools.offsetHeight - 4) + "px";
}
table.addEventListener("mouseover", function (e) {
const th = e.target.closest(TOOL_HOSTS);
if (!th || (e.relatedTarget && th.contains(e.relatedTarget))) return; // 칸에 막 들어왔을 때 — 기준점 새로
toolAnchor = null;
placeTools(th, e);
});
table.addEventListener("mousemove", function (e) {
const th = e.target.closest(TOOL_HOSTS);
if (th) placeTools(th, e);
});
// ── 영역·줄 이름 — 눌러서 그 자리에서 수정(Enter·칸 떠남 = 저장, Esc = 취소). 서식 없이 글자만. ──
function startNameEdit(span) {
if (span.isContentEditable) return;