feat(실적): 일자별 표 열 접기 — 사람마다 저장
매출 실적·광고비 일자별 표 머리글 위 버튼으로 열 하나씩 접기/펴기(날짜 열 제외). 접은 열은 26px 띠, 로그인한 사람 본인에게만 적용 — PUT /api/my-col-fold → perf_settings col_fold:<이메일 sha1> (마이그레이션 없음, 011 테이블 재사용). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -257,6 +257,7 @@
|
||||
// 바꾼 너비는 이 브라우저 localStorage(perf_colw_sales / perf_colw_ads, 열 = th data-col)에 계속 유지, 경계를 두 번 누르면 그 열만 자동 너비로.
|
||||
// 그룹 접기·펴기 애니메이션은 apply(접는 열)/animate/settle 로 열 너비를 0 ↔ 원래 너비로 함께 움직인다.
|
||||
const COLW_MIN = 36;
|
||||
const CFOLD_W = 26; // 접은 열 너비 — performance.css .is-cfold 와 같게
|
||||
function initColWidths(root) {
|
||||
const table = root.querySelector("table.perf-colw-manual");
|
||||
const row = table && table.tHead && table.tHead.rows[0];
|
||||
@@ -271,7 +272,11 @@
|
||||
}
|
||||
// 날짜 열(label)은 조절 안 함(2026-10-27) — 늘 자동 너비(글자 길이), 손잡이 없음
|
||||
function fixedCol(th) { return th.dataset.col === "label"; }
|
||||
function widthOf(th) { const c = th.dataset.col; return (!fixedCol(th) && saved[c]) || auto[c] || 80; }
|
||||
function widthOf(th) {
|
||||
if (th.classList.contains("is-cfold")) return CFOLD_W; // 접은 열(initColFold) — 좁은 띠
|
||||
const c = th.dataset.col;
|
||||
return (!fixedCol(th) && saved[c]) || auto[c] || 80;
|
||||
}
|
||||
function apply(zero) { // zero = 너비 0 으로 둘 열(접는 중·펴기 직전)
|
||||
let sum = 0;
|
||||
heads.forEach(function (th) {
|
||||
@@ -288,7 +293,7 @@
|
||||
table.style.width = "";
|
||||
heads.forEach(function (th) {
|
||||
const w = th.getBoundingClientRect().width;
|
||||
if (w > 0) auto[th.dataset.col] = Math.ceil(w);
|
||||
if (w > 0 && !th.classList.contains("is-cfold")) auto[th.dataset.col] = Math.ceil(w);
|
||||
});
|
||||
apply();
|
||||
}
|
||||
@@ -342,6 +347,50 @@
|
||||
};
|
||||
}
|
||||
|
||||
// 열 접기(2026-11-06) — 매출 실적·광고비 일자별 표 머리글 위 버튼으로 열 하나씩 접기/펴기(날짜 열 빼고).
|
||||
// 접은 열 = 좁은 띠(버튼만, 칸 클릭·메모 안 됨). 보는 사람(로그인 계정)마다 서버에 저장(PUT /api/my-col-fold) — 다른 사람 화면은 그대로.
|
||||
function initColFold(root, colw) {
|
||||
const table = root.querySelector("table[data-cfold-kind]");
|
||||
const row = table && table.tHead && table.tHead.rows[0];
|
||||
if (!row) return;
|
||||
let folded = [];
|
||||
try { folded = JSON.parse(table.dataset.colFold || "[]") || []; } catch (_) { folded = []; }
|
||||
const ICON = '<svg viewBox="0 0 12 12" width="12" height="12" aria-hidden="true"><path d="M7.5 3 4.5 6l3 3" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/></svg>';
|
||||
function setFold(th, fold) {
|
||||
const i = th.cellIndex;
|
||||
Array.prototype.forEach.call(table.rows, function (r) { if (r.cells[i]) r.cells[i].classList.toggle("is-cfold", fold); });
|
||||
const b = th.querySelector(".perf-cfold");
|
||||
b.setAttribute("aria-expanded", fold ? "false" : "true");
|
||||
b.setAttribute("aria-label", b.dataset.name + (fold ? " 열 펴기" : " 열 접기"));
|
||||
b.title = fold ? b.dataset.name + " 열 펴기" : "열 접기";
|
||||
}
|
||||
Array.prototype.forEach.call(row.cells, function (th) {
|
||||
const col = th.dataset.col;
|
||||
if (!col || col === "label") return;
|
||||
const b = document.createElement("button");
|
||||
b.type = "button";
|
||||
b.className = "perf-cfold";
|
||||
b.dataset.name = th.textContent.replace(/[✎\s]+/g, " ").trim();
|
||||
b.innerHTML = ICON;
|
||||
th.insertBefore(b, th.firstChild);
|
||||
setFold(th, folded.indexOf(col) >= 0);
|
||||
});
|
||||
if (colw && folded.length) colw.apply();
|
||||
row.addEventListener("click", function (e) {
|
||||
const b = e.target.closest(".perf-cfold");
|
||||
if (!b) return;
|
||||
e.stopPropagation();
|
||||
const th = b.parentElement, col = th.dataset.col;
|
||||
const fold = !th.classList.contains("is-cfold");
|
||||
setFold(th, fold);
|
||||
if (colw) colw.apply();
|
||||
folded = folded.filter(function (c) { return c !== col; });
|
||||
if (fold) folded.push(col);
|
||||
api("PUT", "/performance/api/my-col-fold", { kind: table.dataset.cfoldKind, cols: folded })
|
||||
.catch(function (err) { alertMsg("접은 열을 저장하지 못했습니다: " + err.message); });
|
||||
});
|
||||
}
|
||||
|
||||
function initDashboard(root) {
|
||||
const data = JSON.parse((document.getElementById("perf-data") || {}).textContent || "{}");
|
||||
const METRIC_NAMES = { gross: "총매출", commission: "수수료", net: "수수료 차감 매출" };
|
||||
@@ -423,6 +472,7 @@
|
||||
if (fold) collapsed.push(code);
|
||||
try { localStorage.setItem(GROUP_KEY, JSON.stringify(collapsed)); } catch (_) { /* 기억만 못 함 */ }
|
||||
});
|
||||
initColFold(root, colw);
|
||||
|
||||
// 수동 입력 엑셀 업로드 — 1열 날짜, 2열부터 쇼핑몰 이름 머리글. 값이 있는 칸만 반영(빈 칸은 기존 값 그대로).
|
||||
// 잘못된 칸이 있으면 서버가 아무것도 저장하지 않고 칸 위치 목록을 돌려준다.
|
||||
|
||||
Reference in New Issue
Block a user