feat(project): meeting rows added from the task cell stay in the same item cell (migration 027), in-place redraw with animation

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-12 20:28:24 +09:00
parent 59add598fa
commit 3882836fd5
22 changed files with 514 additions and 72 deletions
+9 -3
View File
@@ -287,19 +287,25 @@
if (merged.length) items.push({ label: "병합 해제", icon: opts.icon("call_split"), onClick: () => unmergeCells(merged) });
if (cells.some(c => editorOf(c).value)) items.push({ label: "내용 지우기 (Del)", icon: opts.icon("ink_eraser"), onClick: () => clearCells(cells) });
if (saver) {
// 주요 업무 칸에서 추가한 줄은 같은 항목 칸 안에 들어간다(항목 칸은 그대로 — 027 sameLabel)
items.push(null,
{ label: "위에 줄 추가", icon: opts.icon("add_row_above"), onClick: () => saver.addRow(cell.closest("tbody").dataset.section, cell.dataset.meetItem, "above") },
{ label: "위에 줄 추가", icon: opts.icon("add_row_above"), onClick: () => saver.addRow(cell.closest("tbody").dataset.section, cell.dataset.meetItem, "above", { sameLabel: true }) },
{ label: "아래에 줄 추가", icon: opts.icon("add_row_below"), onClick: () => {
const rows = Array.from(cell.closest("tbody").rows), bottom = rows[rows.indexOf(cell.parentElement) + cell.rowSpan - 1];
saver.addRow(cell.closest("tbody").dataset.section, bottom.dataset.item, "below");
saver.addRow(cell.closest("tbody").dataset.section, bottom.dataset.item, "below", { sameLabel: true });
} });
if (cell.rowSpan === 1 && cells.length === 1 && saver.deleteRow) {
items.push({ label: "줄 삭제", danger: true, icon: opts.icon("delete"), onClick: () => saver.deleteRow(cell.parentElement) });
}
}
}
if (items.length) items.push(null);
items.push(...widthItems(td));
if (items.length) { e.preventDefault(); opts.menu(e.clientX, e.clientY, items); }
});
return { bindSaver: s => { saver = s; }, widthItems: widthItems };
// 줄 구조를 다시 끼운 뒤(refreshMeeting) — 새 칸에 열 너비 손잡이·이동 테두리, 너비 다시 적용, 선택 풀기
function refresh() { anchor = null; clearSelection(); handles(); applyWidths(); }
return { bindSaver: s => { saver = s; }, widthItems: widthItems, refresh: refresh };
}
window.PJMeetingCells = { init: init };
})();
+3
View File
@@ -2475,6 +2475,9 @@ html.pj-goal-moving, html.pj-goal-moving * { cursor: grabbing !important; user-s
@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; } }
/* 주간 회의록 — 줄을 그 자리에서 다시 그린 뒤(refreshMeeting) 새 줄 잠깐 강조(연간 목표와 같은 색) */
.pj-meet-table tr.is-new-row > * { animation: pj-goal-row-new 1.4s ease-out; }
@media (prefers-reduced-motion: reduce) { .pj-meet-table tr.is-new-row > * { animation: none; } }
/* 칸 병합 — 끌어서 고르는 동안 글 선택 막기 */
html.pj-goal-selecting, html.pj-goal-selecting * { user-select: none !important; cursor: cell !important; }
/* 칸 아무 곳이나 눌러 입력 — 칸 전체가 글 입력 커서(관리자 화면) */
+145 -29
View File
@@ -10572,6 +10572,7 @@
btn.setAttribute("aria-pressed", prevFirst ? "true" : "false");
}
arrange();
table.addEventListener("pj-meet-rows", arrange); // 줄 구조를 다시 끼운 뒤(refreshMeeting) 새 줄도 같은 순서로
btn.addEventListener("click", function () {
prevFirst = !prevFirst;
try { localStorage.setItem(KEY, prevFirst ? "prev" : "this"); } catch (_) {}
@@ -11408,7 +11409,10 @@
return ta.dataset.field === "result_note" ? "meet:item:" + tr.dataset.prev + ":result_note"
: "meet:item:" + tr.dataset.item + ":content";
},
onSaved: function (ta) { const n = ta.closest("td") || ta; clearSaveFailed(n); flashSaved(n); },
onSaved: function (ta) {
const n = ta.closest("td") || ta; clearSaveFailed(n); flashSaved(n);
if (pendingMeetRefresh && !textSaver.anyDirty()) refreshMeeting().catch(function (err) { showToast(err.message, "error"); });
},
onClear: function (ta) { clearSaveFailed(ta.closest("td") || ta); },
onFail: function (ta, err) { markSaveFailed(ta.closest("td") || ta, err); },
});
@@ -11433,8 +11437,11 @@
if (table) table.querySelectorAll(".pj-meet-text, .pj-meet-rnote").forEach(bindText);
if (cellGrid) cellGrid.bindSaver({ flush: flushAll, save: function (ta) { return textSaver.flush(ta); },
replace: function (ta, value) { ta.value = value; textSaver.acceptSaved(ta, ta.value); },
rowMenu: rowMenu, addRow: function (section, ref, place) { run(function () { return addRow(section, ref, place); }); },
reload: reloadKeepScroll });
rowMenu: rowMenu,
// 주요 업무 칸 메뉴 — 위/아래 줄 추가는 같은 항목 칸 안에(027, 이름을 묻지 않음), 줄 삭제
addRow: function (section, ref, place, o) { run(function () { return addRow(section, ref, place, o && o.sameLabel); }); },
deleteRow: function (tr) { run(function () { return deleteRow(tr); }); },
reload: function () { refreshMeeting().catch(function (err) { showToast("처리 실패: " + err.message, "error"); }); } });
if (table && window.PJGoalText) window.PJGoalText.init(table, el("pj-goal-format"));
if (restored) showToast("저장되지 않았던 글 " + restored + "칸을 되살려 다시 저장합니다.");
else if (conflict) showToast("다른 곳에서 바뀐 칸 " + conflict + "개는 예전 초안을 되살리지 않았습니다.");
@@ -11500,41 +11507,150 @@
span.addEventListener("blur", onBlur);
});
// ── 줄 메뉴(⋯ · 항목 우클릭) — 위/아래 줄 추가 · 순서 · 삭제 ──
// 줄 작업 뒤엔 새로고침 — 그 전에 저장 안 된 칸(대기·진행 중·실패)을 저장하고, 실패하면 작업 자체를 하지 않는다(초안 유지)
async function run(fn) {
try {
await flushAll();
if (!(await fn())) return;
await flushAll();
reloadKeepScroll();
} catch (err) { showToast("처리 실패: " + err.message, "error"); }
// ── 줄 메뉴(⋯ · 항목 우클릭) — 위/아래 줄 추가 · 순서 · 항목 칸 나누기 · 삭제 ──
// 줄 작업 전에 저장 안 된 칸(대기·진행 중·실패)을 저장하고, 실패하면 작업 자체를 하지 않는다(초안 유지).
// 작업 뒤엔 새로고침 대신 표만 그 자리에서 다시 그린다(refreshMeeting — 연간 목표 표와 같은 애니메이션).
// fn 이 true 면 다시 그리기, { removed: [tr…] } 면 그 줄을 흐리게 지운 뒤 다시 그리기, false 면 아무것도 안 함.
let meetStruct = Promise.resolve();
function run(fn) {
const job = meetStruct.then(async function () { // 줄 작업은 한 번에 하나씩(앞 작업 다시 그리기가 끝난 뒤)
try {
await flushAll();
const r = await fn();
if (!r) return;
await flushAll();
await refreshMeeting(r === true ? {} : r);
} catch (err) { showToast("처리 실패: " + err.message, "error"); }
});
meetStruct = job;
return job;
}
async function addRow(section, ref, place) {
// sameLabel(주요 업무 칸에서) = 기준 줄과 같은 항목 칸 안에 — 이름을 묻지 않는다(027)
async function addRow(section, ref, place, sameLabel) {
if (sameLabel) {
await api("POST", meetingUrl + "/items", { section: section, label: "", ref_item_id: ref, place: place, same_label: true });
return true;
}
const v = await prompt("새 줄 이름 (예: 쿠팡 — 비워 둬도 됩니다)", "");
if (v == null) return false;
await api("POST", meetingUrl + "/items", { section: section, label: String(v).trim(), ref_item_id: ref, place: place });
return true;
}
// 항목 칸 묶음의 첫 줄(이어 붙은 줄이면 위로 거슬러 올라감)·맨 아래 줄
function groupHead(tr) {
let r = tr;
while (r && r.dataset.labelCont === "1" && r.previousElementSibling) r = r.previousElementSibling;
return r;
}
function groupBottom(tr) {
const head = groupHead(tr), th = head.querySelector("th.pj-meet-c-label");
const rows = Array.from(head.closest("tbody").rows);
return rows[Math.min(rows.length - 1, rows.indexOf(head) + ((th && th.rowSpan) || 1) - 1)];
}
async function deleteRow(tr) {
const head = groupHead(tr);
const label = ((head.querySelector(".pj-meet-label") || {}).textContent || "").trim();
const grouped = groupBottom(tr) !== head;
const msg = !grouped ? "'" + (label || "이 줄") + "' 줄을 삭제할까요? 주요 업무·금액도 함께 삭제됩니다."
: tr === head ? "'" + (label || "이 항목") + "' 항목의 첫 줄을 삭제할까요? 주요 업무·금액도 함께 삭제되고, 아래 줄이 항목 이름을 이어받습니다."
: "'" + (label || "이 항목") + "' 항목의 이 줄을 삭제할까요? 주요 업무·금액도 함께 삭제됩니다.";
const ok = await confirm(msg, { okText: "삭제", cancelText: "취소" });
if (!ok) return false;
await api("DELETE", itemUrl(tr.dataset.item));
return { removed: [tr] };
}
function rowMenu(x, y, tr) {
const id = tr.dataset.item, section = tr.dataset.section;
const label = (tr.querySelector(".pj-meet-label") || {}).textContent || "";
showContextMenu(x, y, [
tr = groupHead(tr);
const id = tr.dataset.item, section = tr.dataset.section, bottom = groupBottom(tr);
const grouped = bottom !== tr;
// 항목 칸에서 추가 = 항목 칸 밖에 따로(묶음 맨 위·맨 아래 기준). 묶인 칸은 순서 대신 "항목 칸 나누기"
const items = [
{ label: "위에 줄 추가", icon: menuIcon("add_row_above"), onClick: function () { run(function () { return addRow(section, id, "above"); }); } },
{ label: "아래에 줄 추가", icon: menuIcon("add_row_below"), onClick: function () { run(function () { return addRow(section, id, "below"); }); } },
{ label: "위로", icon: menuIcon("arrow_upward"), onClick: function () { run(async function () { await api("POST", itemUrl(id) + "/move", { direction: -1 }); return true; }); } },
{ label: "아래로", icon: menuIcon("arrow_downward"), onClick: function () { run(async function () { await api("POST", itemUrl(id) + "/move", { direction: 1 }); return true; }); } },
null,
{ label: "줄 삭제", danger: true, icon: menuIcon("delete"), onClick: function () {
run(async function () {
const ok = await confirm("'" + (label.trim() || "이 줄") + "' 줄을 삭제할까요? 주요 업무·금액도 함께 삭제됩니다.",
{ okText: "삭제", cancelText: "취소" });
if (!ok) return false;
await api("DELETE", itemUrl(id));
return true;
{ label: "아래에 줄 추가", icon: menuIcon("add_row_below"), onClick: function () { run(function () { return addRow(section, bottom.dataset.item, "below"); }); } },
];
if (grouped) {
items.push({ label: "항목 칸 나누기", icon: menuIcon("horizontal_split"), onClick: function () {
run(async function () { await api("POST", itemUrl(id) + "/split-label"); return true; });
} });
} else {
items.push(
{ label: "위로", icon: menuIcon("arrow_upward"), onClick: function () { run(async function () { await api("POST", itemUrl(id) + "/move", { direction: -1 }); return true; }); } },
{ label: "아래로", icon: menuIcon("arrow_downward"), onClick: function () { run(async function () { await api("POST", itemUrl(id) + "/move", { direction: 1 }); return true; }); } });
}
items.push(null, { label: grouped ? "첫 줄 삭제" : "줄 삭제", danger: true, icon: menuIcon("delete"), onClick: function () {
run(function () { return deleteRow(tr); });
} });
showContextMenu(x, y, items.concat(cellGrid ? [null].concat(cellGrid.widthItems(tr.querySelector("th.pj-meet-c-label"))) : []));
}
// ── 줄 구조가 바뀐 뒤(줄 추가·삭제·이동·항목 칸 나누기·구역 이동·셀 병합) 새로고침 없이 표의 구역 부분만 서버에서 다시 받아
// 그 자리에서 바꿔 끼운다(연간 목표 refreshTable 과 같은 방식) — 지운 줄은 흐려지며 사라지고, 남은 줄은 예전 자리에서
// 새 자리로 미끄러지고(FLIP), 새 줄은 위에서 내려오며 잠깐 강조. 동작 줄이기 설정이면 애니메이션 없이.
// 글 보호: 시작 전에 저장(실패하면 throw — 표는 그대로), 받는 사이에 새로 입력한 글이 있으면 저장 후 다시 받고,
// 계속 입력 중이면 바꿔 끼우지 않고 저장이 끝난 뒤 다시 그린다(pendingMeetRefresh). 받아 오기에 실패하면 예전처럼 새로고침.
const MEET_ANIM_MS = 280;
let pendingMeetRefresh = false;
async function refreshMeeting(opts) {
opts = opts || {};
await flushAll();
const reduce = !Element.prototype.animate ||
(window.matchMedia && window.matchMedia("(prefers-reduced-motion: reduce)").matches);
const busy = function () {
return textSaver.anyDirty() || amtSaver.anyDirty() || !!table.querySelector("[data-meet-edit].is-editing");
};
let fresh = null, anims = [];
for (let tries = 0; ; tries++) {
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-meet-table");
} catch (_) { fresh = null; }
if (!busy() && opts.removed && opts.removed.length && !reduce && !anims.length) {
anims = opts.removed.filter(function (tr) { return tr.isConnected; }).map(function (tr) {
return tr.animate([{ opacity: 1 }, { opacity: 0 }], { duration: 180, easing: "ease-in", fill: "forwards" });
});
} },
].concat(cellGrid ? [null].concat(cellGrid.widthItems(tr.querySelector("th.pj-meet-c-label"))) : []));
await Promise.all(anims.map(function (a) { return a.finished.catch(function () {}); }));
}
if (!busy()) break;
anims.forEach(function (a) { try { a.cancel(); } catch (_) {} });
anims = [];
if (tries >= 2) {
pendingMeetRefresh = true;
showToast("입력 중인 칸이 있어 표를 아직 다시 그리지 않았습니다 — 저장되면 다시 그립니다.");
return;
}
await flushAll(); // 받는 동안 새로 입력한 글 — 저장 실패면 throw(표는 그대로)
}
if (!fresh) { reloadKeepScroll(); return; }
pendingMeetRefresh = false;
const before = new Map();
table.querySelectorAll("tbody.pj-meet-sec > tr[data-item]").forEach(function (tr) {
before.set(tr.dataset.item, tr.getBoundingClientRect().top);
});
table.querySelectorAll("tbody.pj-meet-sec").forEach(function (t) { t.remove(); });
fresh.querySelectorAll("tbody.pj-meet-sec").forEach(function (t) { table.appendChild(document.importNode(t, true)); });
textSaver.prune();
amtSaver.prune();
table.querySelectorAll(".pj-meet-text, .pj-meet-rnote").forEach(bindText);
table.querySelectorAll("input.pj-meet-amount").forEach(bindAmount);
table.dispatchEvent(new CustomEvent("pj-meet-rows")); // 이번주 ↔ 지난주 칸 순서(initMeetOrder)
if (cellGrid && cellGrid.refresh) cellGrid.refresh(); // 열 너비 손잡이·이동 테두리·선택
if (reduce) return;
table.querySelectorAll("tbody.pj-meet-sec > tr[data-item]").forEach(function (tr) {
const top = tr.getBoundingClientRect().top;
if (before.has(tr.dataset.item)) {
const dy = before.get(tr.dataset.item) - top;
if (Math.abs(dy) > 1) {
tr.animate([{ transform: "translateY(" + dy + "px)" }, { transform: "translateY(0)" }],
{ duration: MEET_ANIM_MS, easing: "cubic-bezier(.2,.8,.2,1)" });
}
} else {
tr.animate([{ opacity: 0, transform: "translateY(-10px)" }, { opacity: 1, transform: "translateY(0)" }],
{ duration: MEET_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);
}
});
}
// ── 구역 메뉴(구분 칸 ⋯ · 우클릭) — 구역을 통째로 위/아래(그 안의 줄 순서·병합은 그대로), 구역 끝에 줄 추가 ──
function secMenu(x, y, tbody) {