fix(project): 목표 표 병합·줄 추가/삭제 때 새로고침 대신 제자리 다시 그리기 + 애니메이션, 3열 줄 메뉴

- 병합 때 표가 줄었다 늘어나고 줄 추가/삭제 때 깜박이던 것: 새로고침(열 너비가 늦게 적용) 대신 페이지를 다시 받아
  업무 영역 tbody 만 교체(refreshTable) — 열 너비·반기 접기 다시 적용, 새 글 칸 연결
- 애니메이션: 지운 줄 흐려지며 사라짐, 남은 줄 미끄러져 이동(FLIP), 새 줄 위에서 등장 + 강조, 병합/해제 칸 테두리 강조
- 3열(연간 칸) 우클릭에도 위/아래에 줄 추가·줄 삭제(병합 메뉴가 있으면 그 아래에)
- 영역 추가·삭제·이동, 줄 이동도 같은 방식, 캐시 버전 20261001j, 문서 갱신

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-01 13:30:37 +09:00
parent 24dd3acd09
commit ac0672bc11
10 changed files with 159 additions and 46 deletions
@@ -1,7 +1,7 @@
{% extends "erp_base.html" %}
{% block head_extra %}
<link rel="stylesheet" href="/static/project.css?v=20261001i" />
<link rel="stylesheet" href="/static/project.css?v=20261001j" />
<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=20261001i" defer></script>
<script src="/static/project.js?v=20261001j" defer></script>
{% endblock %}
@@ -1,7 +1,7 @@
{% extends "erp_base.html" %}
{% block head_extra %}
<link rel="stylesheet" href="/static/project.css?v=20261001i" />
<link rel="stylesheet" href="/static/project.css?v=20261001j" />
<link rel="stylesheet" href="/static/vendor/material-symbols/material-symbols.css" />
{% endblock %}
@@ -207,5 +207,5 @@
{% include "project/_side_modals.html" %}
{% include "project/_member_tasks_modal.html" %}
<script src="/static/project.js?v=20261001i" defer></script>
<script src="/static/project.js?v=20261001j" defer></script>
{% endblock %}
@@ -1,7 +1,7 @@
{% extends "erp_base.html" %}
{% block head_extra %}
<link rel="stylesheet" href="/static/project.css?v=20261001i" />
<link rel="stylesheet" href="/static/project.css?v=20261001j" />
<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=20261001i" />
<link rel="stylesheet" href="/static/project.css?v=20261001j" />
<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=20261001i" defer></script>
<script src="/static/project.js?v=20261001j" defer></script>
{% endblock %}
@@ -1,7 +1,7 @@
{% extends "erp_base.html" %}
{% block head_extra %}
<link rel="stylesheet" href="/static/project.css?v=20261001i" />
<link rel="stylesheet" href="/static/project.css?v=20261001j" />
<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=20261001i" defer></script>
<script src="/static/project.js?v=20261001j" defer></script>
{% endblock %}
@@ -1,7 +1,7 @@
{% extends "erp_base.html" %}
{% block head_extra %}
<link rel="stylesheet" href="/static/project.css?v=20261001i" />
<link rel="stylesheet" href="/static/project.css?v=20261001j" />
<!-- 구글 머티리얼 심볼(담당자 아이콘 등) — 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=20261001i" defer></script>
<script src="/static/project.js?v=20261001j" defer></script>
{% endblock %}
@@ -1,7 +1,7 @@
{% extends "erp_base.html" %}
{% block head_extra %}
<link rel="stylesheet" href="/static/project.css?v=20261001i" />
<link rel="stylesheet" href="/static/project.css?v=20261001j" />
<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=20261001i" defer></script>
<script src="/static/project.js?v=20261001j" defer></script>
{% endblock %}
+7
View File
@@ -2155,6 +2155,13 @@ textarea.pj-goal-text::placeholder { color: rgba(0, 0, 0, .3); }
.pj-goal-foot { display: flex; align-items: center; gap: 12px; margin: 12px 0 4px; }
/* 표를 그 자리에서 다시 그린 뒤(refreshTable) — 새 줄 잠깐 강조, 병합한 칸 테두리 강조 */
.pj-goal-table tr.is-new-row > * { animation: pj-goal-row-new 1.4s ease-out; }
@keyframes pj-goal-row-new { from { box-shadow: inset 0 0 0 999px rgba(123, 104, 238, .16); } to { box-shadow: inset 0 0 0 999px rgba(123, 104, 238, 0); } }
.pj-goal-table td.is-merge-flash { animation: pj-goal-merge-flash 1.2s ease-out; }
@keyframes pj-goal-merge-flash { from { box-shadow: inset 0 0 0 2px var(--pj-accent), inset 0 0 0 999px rgba(123, 104, 238, .14); }
to { box-shadow: inset 0 0 0 2px transparent, inset 0 0 0 999px rgba(123, 104, 238, 0); } }
@media (prefers-reduced-motion: reduce) { .pj-goal-table tr.is-new-row > *, .pj-goal-table td.is-merge-flash { animation: none; } }
/* 칸 병합 — 끌어서 고르는 동안 글 선택 막기 */
html.pj-goal-selecting, html.pj-goal-selecting * { user-select: none !important; cursor: cell !important; }
/* 월 머리 → 그 달 주간 회의록 */
+132 -33
View File
@@ -8233,16 +8233,22 @@
flashSaved(ta.parentElement);
} catch (e) { showToast("저장 실패: " + e.message, "error"); }
}
table.querySelectorAll("textarea.pj-goal-text").forEach(function (ta) {
ta.dataset.saved = ta.value;
fit(ta);
ta.addEventListener("input", function () {
// 글 칸 연결 — 처음 한 번 + 표를 그 자리에서 다시 그린 뒤 새 칸에(refreshTable)
function bindTexts(root) {
root.querySelectorAll("textarea.pj-goal-text").forEach(function (ta) {
if (ta.dataset.bound) return;
ta.dataset.bound = "1";
ta.dataset.saved = ta.value;
fit(ta);
clearTimeout(pending.get(ta));
pending.set(ta, setTimeout(function () { saveText(ta); }, 800));
ta.addEventListener("input", function () {
fit(ta);
clearTimeout(pending.get(ta));
pending.set(ta, setTimeout(function () { saveText(ta); }, 800));
});
ta.addEventListener("blur", function () { saveText(ta); });
});
ta.addEventListener("blur", function () { saveText(ta); });
});
}
bindTexts(table);
// 한 줄 안 칸들 높이는 표가 맞춘다 — 창 폭이 바뀌면 글 줄바꿈이 달라지니 다시 잰다.
window.addEventListener("resize", fitAll);
window.addEventListener("beforeunload", function () {
@@ -8293,7 +8299,7 @@
try {
await api("POST", "/project/api/goals/" + year + "/areas",
{ name: String(name).trim(), color: colors.length ? colors[n % colors.length] : "" });
reloadKeepScroll();
await refreshTable();
} catch (e) { showToast("추가 실패: " + e.message, "error"); }
});
@@ -8343,6 +8349,67 @@
}
// 저장 안 된 글이 있으면 먼저 저장(구조 변경·병합 전에 — 병합은 서버가 DB 의 글을 모은다)
function flushTexts() { return Promise.all(Array.from(pending.keys()).map(saveText)); }
// ── 구조가 바뀐 뒤(줄·영역 추가/삭제/이동, 병합/해제) 페이지를 새로고침하지 않고 업무 영역 부분만 서버에서 다시 받아
// 그 자리에서 바꿔 끼운다 — 새로고침 때 저장된 열 너비가 늦게 적용돼 표가 줄었다 늘어나거나 깜박이던 것을 없앤다.
// 애니메이션: 지운 줄은 흐려지며 사라지고(opts.removed), 남은 줄은 예전 자리에서 새 자리로 미끄러지고(FLIP),
// 새 줄은 위에서 내려오며 잠깐 강조, 병합한 칸은 테두리 강조(opts.flash = {row, month}). 동작 줄이기 설정이면 애니메이션 없이.
// 받아 오기에 실패하면 예전처럼 새로고침.
const GOAL_ANIM_MS = 280;
async function refreshTable(opts) {
opts = opts || {};
await flushTexts();
const reduce = !Element.prototype.animate ||
(window.matchMedia && window.matchMedia("(prefers-reduced-motion: reduce)").matches);
if (opts.removed && opts.removed.length && !reduce) {
await Promise.all(opts.removed.map(function (tr) {
return tr.animate([{ opacity: 1 }, { opacity: 0 }], { duration: 180, easing: "ease-in", fill: "forwards" })
.finished.catch(function () {});
}));
}
const before = new Map();
table.querySelectorAll("tbody.pj-goal-area > tr[data-row-id]").forEach(function (tr) {
before.set(tr.dataset.rowId, tr.getBoundingClientRect().top);
});
let fresh = null;
try {
const res = await fetch(location.href, { credentials: "same-origin", cache: "no-store" });
if (res.ok) fresh = new DOMParser().parseFromString(await res.text(), "text/html").getElementById("pj-goal-table");
} catch (_) { fresh = null; }
if (!fresh) { reloadKeepScroll(); return; }
clearMergeSel();
table.querySelectorAll("tbody.pj-goal-area").forEach(function (t) { t.remove(); });
fresh.querySelectorAll("tbody.pj-goal-area").forEach(function (t) { table.appendChild(document.importNode(t, true)); });
applyColW();
applyFold(1, false);
applyFold(2, false);
bindTexts(table);
if (!reduce) {
table.querySelectorAll("tbody.pj-goal-area > tr[data-row-id]").forEach(function (tr) {
const top = tr.getBoundingClientRect().top;
if (before.has(tr.dataset.rowId)) {
const dy = before.get(tr.dataset.rowId) - top;
if (Math.abs(dy) > 1) {
tr.animate([{ transform: "translateY(" + dy + "px)" }, { transform: "translateY(0)" }],
{ duration: GOAL_ANIM_MS, easing: "cubic-bezier(.2,.8,.2,1)" });
}
} else {
tr.animate([{ opacity: 0, transform: "translateY(-10px)" }, { opacity: 1, transform: "translateY(0)" }],
{ duration: GOAL_ANIM_MS + 40, easing: "cubic-bezier(.2,.8,.2,1)" });
tr.classList.add("is-new-row");
setTimeout(function () { tr.classList.remove("is-new-row"); }, 1400);
}
});
}
if (opts.flash) {
const td = table.querySelector('tr[data-row-id="' + opts.flash.row + '"] > td.pj-goal-texttd[data-month="' + opts.flash.month + '"]');
if (td) {
td.classList.remove("is-merge-flash");
void td.offsetWidth;
td.classList.add("is-merge-flash");
}
}
}
table.addEventListener("click", async function (e) {
const b = e.target.closest("[data-goal-act]");
if (!b) return;
@@ -8363,6 +8430,8 @@
{ okText: "삭제", cancelText: "취소" });
if (!ok) return;
await api("DELETE", "/project/api/goals/areas/" + areaId);
await refreshTable({ removed: Array.from(tbody.rows) });
return;
} else if (act === "row-add") {
const v = await prompt("새 줄 이름 (예: 쿠팡 — 비워 둬도 됩니다)", "");
if (v == null) return;
@@ -8373,9 +8442,10 @@
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 flushTexts();
reloadKeepScroll();
await refreshTable();
} catch (err) { showToast("처리 실패: " + err.message, "error"); }
});
@@ -8395,30 +8465,51 @@
await api("DELETE", "/project/api/goals/rows/" + tr.dataset.rowId);
return true;
}
// 줄 메뉴 항목 — 항목 칸(2열)·연간 칸(3열) 우클릭이 같이 쓴다. top = 위에 추가할 기준 줄, bottom = 아래에 추가할 기준 줄
// (세로 병합된 연간 칸이면 맨 아래 줄), canDelete = 그 줄 하나를 지울 수 있을 때.
function rowMenuItems(top, bottom, canDelete) {
const run = function (fn) {
return async function () {
try {
const r = await fn();
if (r) await refreshTable(r === true ? {} : r);
} catch (err) { showToast("처리 실패: " + err.message, "error"); }
};
};
const items = [
{ label: "위에 줄 추가", onClick: run(function () { return insertRow(top, "above"); }) },
{ label: "아래에 줄 추가", onClick: run(function () { return insertRow(bottom, "below"); }) },
];
// 영역의 마지막 한 줄은 못 지운다(영역을 지운다) — 서버도 400
if (canDelete && top.closest(".pj-goal-area").rows.length > 1) {
items.push(null, { label: "줄 삭제", danger: true, onClick: run(async function () {
return (await deleteRow(top)) ? { removed: [top] } : false;
}) });
}
return items;
}
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);
showContextMenu(e.clientX, e.clientY, rowMenuItems(tr, tr, true));
});
// 3열(연간 칸) 우클릭에도 줄 추가·삭제 — 병합 메뉴가 있으면(014) 그 메뉴에 붙이고, 없으면 여기서
function yearCellRows(td) {
const tr = td.closest("tr"), rows = Array.from(td.closest("tbody").rows);
const rspan = parseInt(td.dataset.rspan || "1", 10);
return { top: tr, bottom: rows[Math.min(rows.length - 1, rows.indexOf(tr) + rspan - 1)], single: rspan === 1 };
}
if (table.dataset.halves !== "true") {
table.addEventListener("contextmenu", function (e) {
const td = e.target.closest("tbody.pj-goal-area td.pj-goal-texttd[data-month='0']");
if (!td || !table.contains(td)) return;
e.preventDefault();
const r = yearCellRows(td);
showContextMenu(e.clientX, e.clientY, rowMenuItems(r.top, r.bottom, r.single));
});
}
// ── 영역·줄 이름 — 눌러서 그 자리에서 수정(Enter·칸 떠남 = 저장, Esc = 취소). 서식 없이 글자만. ──
function startNameEdit(span) {
@@ -8552,19 +8643,22 @@
const rows = s.tbody.rows;
try {
await flushTexts();
await api("POST", "/project/api/goals/areas/" + s.tbody.dataset.areaId + "/merge", {
const res = await api("POST", "/project/api/goals/areas/" + s.tbody.dataset.areaId + "/merge", {
row_from: rows[s.r0].dataset.rowId, row_to: rows[s.r1].dataset.rowId, col_from: cols[0], col_to: cols[cols.length - 1],
});
reloadKeepScroll();
await refreshTable({ flash: { row: res.row_id, month: res.start } });
} catch (err) { showToast("병합 실패: " + err.message, "error"); }
};
const unmerge = async function (cellsToSplit) {
try {
await flushTexts();
let first = null;
for (const c of cellsToSplit) {
await api("DELETE", "/project/api/goals/rows/" + c.td.closest("tr").dataset.rowId + "/merge/" + c.td.dataset.month);
const row = c.td.closest("tr").dataset.rowId, month = c.td.dataset.month;
await api("DELETE", "/project/api/goals/rows/" + row + "/merge/" + month);
first = first || { row: row, month: month };
}
reloadKeepScroll();
await refreshTable({ flash: first });
} catch (err) { showToast("병합 해제 실패: " + err.message, "error"); }
};
@@ -8628,6 +8722,11 @@
items.push({ label: "병합 해제" + (mergedIn.length > 1 ? " (" + mergedIn.length + "곳)" : ""),
onClick: function () { clearMergeSel(); unmerge(mergedIn); } });
}
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); });
}
if (!items.length) { clearMergeSel(); return; }
e.preventDefault();
showContextMenu(e.clientX, e.clientY, items);
+7
View File
@@ -556,6 +556,13 @@ description 을 항상 HTML로 취급하기 때문). 두 번 실행하면 이중
- 줄 작업과 세로 병합(엑셀처럼): 병합 **안쪽에 줄 끼우기** → `row_span + 1` · **가려진 줄 지우기** → `row_span − 1`(1칸이 되면 병합 삭제) ·
맨 위(시작) 줄 지우기 → 병합도 지워짐(CASCADE) · 세로 병합에 걸린 줄(자신이나 바꿀 이웃)의 **↑↓ 이동은 400**(해제 뒤 이동).
- 새 연도 만들기(구조 복사)는 병합을 복사하지 않는다(줄 이름만).
- **구조 변경 뒤 제자리 다시 그리기**(`refreshTable`, 2026-10-01) — 줄·영역 추가/삭제/이동, 병합/해제 뒤 페이지를 새로고침하지
않고 이 페이지를 다시 받아 **업무 영역 tbody 만** 바꿔 끼운다(열 너비·반기 접기 다시 적용, 새 글 칸 연결 `bindTexts`). 새로고침 때
저장된 열 너비가 늦게 적용돼 표가 줄었다 늘어나고 깜박이던 것을 없앴다. 애니메이션: 지운 줄은 흐려지며 사라지고, 남은 줄은 예전
자리에서 미끄러져 오고(FLIP, 0.28초), 새 줄은 위에서 내려오며 보라색으로 잠깐 강조(`is-new-row`), 병합·해제한 칸은 테두리 강조
(`is-merge-flash`). 동작 줄이기 설정이면 애니메이션 없이. 받아 오기 실패하면 예전처럼 새로고침.
- **3열(연간 칸) 우클릭 → 줄 메뉴**: 위에 줄 추가 · 아래에 줄 추가 · 줄 삭제(항목 칸 우클릭과 같은 `rowMenuItems`). 세로로 병합된
연간 칸이면 아래 추가는 병합의 맨 아래 줄 기준, 삭제는 없음. 병합 메뉴(셀 병합·해제)가 있으면 그 아래에 붙는다.
- **월 머리 → 주간 회의록** — 목표 표 머리의 월 칸을 누르면 `/project/goals/{연도}/meetings/{월}`(6-9-2). 링크(`a.pj-goal-mlink`)는
글자만이 아니라 **칸 전체**(absolute inset 0), 오른쪽 끝 너비 조절 손잡이(z-index 5)는 링크 위라 그대로 끌 수 있다.
- **로아스 단위 %** — 로아스 목표·실적 칸은 `499%` 처럼 보인다(`router._goal_label`, 저장 응답 `label` 도 같음). 입력은 `499`·`499%`