feat(project): auto-fit goal column widths
This commit is contained in:
@@ -296,5 +296,5 @@
|
||||
{% include "project/_side_modals.html" %}
|
||||
{% include "project/_member_tasks_modal.html" %}
|
||||
|
||||
<script src="/static/project.js?v=20261003e" defer></script>
|
||||
<script src="/static/project.js?v=20261003f" defer></script>
|
||||
{% endblock %}
|
||||
|
||||
@@ -207,7 +207,7 @@
|
||||
{% if is_admin %}
|
||||
<div class="pj-goal-foot">
|
||||
<button type="button" class="pj-btn" id="pj-goal-area-add">+ 업무 영역 추가</button>
|
||||
<span class="pj-goal-note">칸을 고치면 바로 저장됩니다. 글자를 드래그해 선택하면 선택한 셀 상단에서 12색 견본·크기 2px 증감·굵게·기울임·밑줄·서식 초기화를 사용할 수 있습니다. 모든 행의 셀 오른쪽 경계를 끌어 열 너비를 조절합니다. 숫자 칸을 비우면 지워집니다. 구역·항목 칸을 우클릭하거나 칸의 ⋮ 버튼(키보드 Tab·Enter, 터치)을 누르면 색·순서·줄 추가·삭제 메뉴가 나옵니다.
|
||||
<span class="pj-goal-note">칸을 고치면 바로 저장됩니다. 글자를 드래그해 선택하면 선택한 셀 상단에서 12색 견본·크기 2px 증감·굵게·기울임·밑줄·서식 초기화를 사용할 수 있습니다. 모든 행의 셀 오른쪽 경계를 끌어 열 너비를 조절하고, 더블클릭하면 그 열의 가장 긴 문단에 맞춥니다. 숫자 칸을 비우면 지워집니다. 구역·항목 칸을 우클릭하거나 칸의 ⋮ 버튼(키보드 Tab·Enter, 터치)을 누르면 색·순서·줄 추가·삭제 메뉴가 나옵니다.
|
||||
{%- if board.halves %} 칸을 마우스로 끌어 여러 칸을 고른 뒤 우클릭 → 셀 병합, 병합된 칸은 우클릭 → 병합 해제(글은 왼쪽 위 칸에 남음).{% endif %}
|
||||
월 이름을 누르면 그 달 주간 회의록이 열립니다.</span>
|
||||
</div>
|
||||
@@ -223,5 +223,5 @@
|
||||
{% include "project/_member_tasks_modal.html" %}
|
||||
|
||||
<script src="/static/project-goal-text.js?v=20261003c" defer></script>
|
||||
<script src="/static/project.js?v=20261003e" defer></script>
|
||||
<script src="/static/project.js?v=20261003f" defer></script>
|
||||
{% endblock %}
|
||||
|
||||
@@ -98,7 +98,8 @@
|
||||
만듭니다(이전 연도의 업무 영역 구성을 그대로 가져옴). 글 칸에서 <b>글자를 드래그해 선택</b>하면 선택한 셀 상단에 나타나는 엑셀 형태 서식 도구로 <b>색상·크기·굵게·기울임·밑줄</b>을 바꿀 수 있으며 선택한 글자에만 적용됩니다.
|
||||
위/아래 화살표가 붙은 글자 버튼은 크기를 <b>2px씩</b> 키우거나 줄입니다(10~32px). 굵게·기울임·밑줄 버튼은 다시 누르면 해당 서식을 해제합니다.
|
||||
<span class="pjh-ui">서식 초기화</span>는 선택한 글자를 기본 서식으로 되돌리며 내용은 유지합니다. 서식도 자동으로 저장됩니다. 색상은 12색의 네모 견본에서 고릅니다.
|
||||
<b>모든 행의 셀 오른쪽 경계</b>를 끌어 열 너비를 조절하고, 더블클릭하면 기본 너비로 돌아갑니다(병합 칸은 오른쪽 끝 열).
|
||||
<b>모든 행의 셀 오른쪽 경계</b>를 끌어 열 너비를 조절하고, 더블클릭하면 <b>그 열의 가장 긴 문단에 맞춰</b> 자동으로 조절합니다.
|
||||
직접 넣은 줄바꿈은 유지하며 글자 크기·굵기·여백도 반영합니다. 병합 칸에서는 다른 열 너비를 유지하고 오른쪽 끝 열만 맞춥니다. 너비는 내 브라우저에 기억됩니다.
|
||||
영역·줄 이름은 <b>눌러서 그 자리에서 고치고</b>(Enter 저장, Esc 취소),
|
||||
구역·항목 칸을 <b>우클릭</b>하거나 칸 오른쪽 위의 작은 <span class="pjh-ui">⋮</span> 버튼(마우스를 올리면 보임)을 눌러 색·순서·줄 추가·삭제를 합니다.
|
||||
키보드로는 <kbd>Tab</kbd>으로 이름 칸·<span class="pjh-ui">⋮</span>로 가서 <kbd>Enter</kbd>(이름 칸 = 이름 고치기, ⋮ = 메뉴), 메뉴 안에서 <kbd>↑</kbd><kbd>↓</kbd>·<kbd>Enter</kbd>,
|
||||
|
||||
@@ -104,5 +104,5 @@
|
||||
{% include "project/_side_modals.html" %}
|
||||
{% include "project/_member_tasks_modal.html" %}
|
||||
|
||||
<script src="/static/project.js?v=20261003e" defer></script>
|
||||
<script src="/static/project.js?v=20261003f" defer></script>
|
||||
{% endblock %}
|
||||
|
||||
@@ -100,5 +100,5 @@
|
||||
"today": {{ today | tojson }}
|
||||
}
|
||||
</script>
|
||||
<script src="/static/project.js?v=20261003e" defer></script>
|
||||
<script src="/static/project.js?v=20261003f" defer></script>
|
||||
{% endblock %}
|
||||
|
||||
@@ -496,5 +496,5 @@
|
||||
</script>
|
||||
|
||||
<script src="/static/vendor/vis-timeline/vis-timeline-graph2d.min.js"></script>
|
||||
<script src="/static/project.js?v=20261003e" defer></script>
|
||||
<script src="/static/project.js?v=20261003f" defer></script>
|
||||
{% endblock %}
|
||||
|
||||
@@ -70,5 +70,5 @@
|
||||
{% include "project/_side_modals.html" %}
|
||||
{% include "project/_member_tasks_modal.html" %}
|
||||
|
||||
<script src="/static/project.js?v=20261003e" defer></script>
|
||||
<script src="/static/project.js?v=20261003f" defer></script>
|
||||
{% endblock %}
|
||||
|
||||
+52
-8
@@ -8599,10 +8599,10 @@
|
||||
const year = table.dataset.year;
|
||||
const isAdmin = table.dataset.admin === "true";
|
||||
|
||||
// ── 열 너비 — 머리 칸 오른쪽 끝을 끌어 조절, 브라우저에 기억(localStorage pj_goal_col_w) ──
|
||||
// ── 열 너비 — 셀 오른쪽 경계에서 끌기·더블클릭 맞춤, 브라우저에 기억(localStorage pj_goal_col_w) ──
|
||||
// · c1·c2 = 왼쪽 이름 두 칸(구분·항목) → 표의 CSS 변수 --goal-c1-w·--goal-c2-w(c2 의 left 도 c1 너비로 정해진다)
|
||||
// · y = 연간, m1~m12 = 월, q1~q4 = 분기 → 그 머리 칸의 --cw(표는 table-layout: fixed 라 머리 칸 너비가 열 너비)
|
||||
// 화면 배율(uiZoom) 안이라 마우스 이동 거리는 배율로 나눈다. 더블클릭 = 기본 너비.
|
||||
// 화면 배율(uiZoom) 안이라 마우스 이동 거리는 배율로 나눈다. 더블클릭 = 가장 긴 문단에 맞춤.
|
||||
const COL_KEY = "pj_goal_col_w";
|
||||
const colDefault = { c1: 72, c2: 72, y: 90, q1: 80, q2: 80, q3: 80, q4: 80 };
|
||||
for (let m = 1; m <= 12; m++) colDefault["m" + m] = 85;
|
||||
@@ -8613,7 +8613,8 @@
|
||||
const saved = JSON.parse(localStorage.getItem(COL_KEY) || "null");
|
||||
if (saved) Object.keys(colDefault).forEach(function (k) {
|
||||
const v = parseInt(saved[k], 10);
|
||||
if (v) colW[k] = clampCol(k, v);
|
||||
// 자동 맞춤은 긴 문단을 자르지 않도록 드래그 최대 너비를 넘을 수 있다.
|
||||
if (v > 0) colW[k] = Math.max(colLimit(k)[0], v);
|
||||
});
|
||||
} catch (_) {}
|
||||
function saveColW() {
|
||||
@@ -8653,15 +8654,59 @@
|
||||
occupied[rr] = occupied[rr] || [];
|
||||
for (let cc = c; cc <= end; cc++) occupied[rr][cc] = true;
|
||||
}
|
||||
td.dataset.goalCols = keys.slice(c, end + 1).join(",");
|
||||
if (!td.querySelector(".pj-goal-colresize") && keys[end]) {
|
||||
const h = document.createElement("span"); h.className = "pj-goal-colresize";
|
||||
h.dataset.col = keys[end]; h.title = "끌어서 너비 조절"; td.appendChild(h);
|
||||
h.dataset.col = keys[end]; td.appendChild(h);
|
||||
}
|
||||
const handle = td.querySelector(".pj-goal-colresize");
|
||||
if (handle) handle.title = "끌어서 너비 조절 · 더블클릭하면 내용에 맞춤";
|
||||
c = end + 1;
|
||||
});
|
||||
});
|
||||
}
|
||||
addColHandles();
|
||||
function naturalCellWidth(td) {
|
||||
// 원본은 건드리지 않는다. 같은 셀 안의 숨은 복사본으로 폰트·부분 서식·여백을
|
||||
// 그대로 재되, 화면 폭에 따른 줄바꿈만 해제한다(직접 넣은 줄바꿈은 유지).
|
||||
const probe = document.createElement("div"), copy = td.cloneNode(true);
|
||||
probe.style.cssText = "position:fixed;left:0;top:0;visibility:hidden;pointer-events:none;width:max-content;";
|
||||
probe.setAttribute("aria-hidden", "true");
|
||||
copy.classList.add("pj-goal-autofit-measure");
|
||||
copy.querySelectorAll(".pj-goal-colresize, .pj-goal-menu-btn").forEach(function (n) { n.remove(); });
|
||||
// input의 현재 초안은 HTML 속성과 다를 수 있고, 기본 입력칸의 내재 너비도 제외한다.
|
||||
copy.querySelectorAll("input, textarea").forEach(function (n) {
|
||||
const text = document.createElement("span");
|
||||
text.className = n.className; text.style.cssText = n.style.cssText;
|
||||
text.textContent = n.value; n.replaceWith(text);
|
||||
});
|
||||
[copy].concat(Array.from(copy.querySelectorAll("*"))).forEach(function (n) {
|
||||
n.removeAttribute("id"); n.removeAttribute("contenteditable"); n.removeAttribute("data-placeholder");
|
||||
n.classList.remove("is-shrunk", "is-gone");
|
||||
const overrides = { position: "static", width: "max-content", "min-width": "0", "max-width": "none",
|
||||
height: "auto", overflow: "visible", transition: "none", "overflow-wrap": "normal", "word-break": "normal" };
|
||||
Object.keys(overrides).forEach(function (p) { n.style.setProperty(p, overrides[p], "important"); });
|
||||
if (n.matches(".pj-goal-text, .pj-goal-text-ro, .pj-goal-area-text, .pj-goal-row-text")) {
|
||||
n.style.setProperty("white-space", "pre", "important");
|
||||
}
|
||||
});
|
||||
copy.style.setProperty("display", "block", "important");
|
||||
probe.appendChild(copy); td.appendChild(probe);
|
||||
try { return Math.ceil(copy.getBoundingClientRect().width / uiZoom()) + 2; }
|
||||
finally { probe.remove(); }
|
||||
}
|
||||
function autoFitCol(key) {
|
||||
let width = colLimit(key)[0];
|
||||
table.querySelectorAll("[data-goal-cols]").forEach(function (td) {
|
||||
const keys = td.dataset.goalCols.split(",");
|
||||
if (!keys.includes(key)) return;
|
||||
// 병합 칸의 다른 열은 유지하고 선택한 열에 필요한 나머지 너비만 더한다.
|
||||
const otherWidth = keys.reduce(function (sum, k) { return sum + (k === key ? 0 : colW[k]); }, 0);
|
||||
width = Math.max(width, naturalCellWidth(td) - otherWidth);
|
||||
});
|
||||
colW[key] = width;
|
||||
applyColW(); saveColW(); fitAll(); stickKpi();
|
||||
}
|
||||
table.addEventListener("mousedown", function (e) {
|
||||
const h = e.target.closest(".pj-goal-colresize");
|
||||
if (!h) return;
|
||||
@@ -8692,11 +8737,10 @@
|
||||
table.addEventListener("dblclick", function (e) {
|
||||
const h = e.target.closest(".pj-goal-colresize");
|
||||
if (!h) return;
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
colW[h.dataset.col] = colDefault[h.dataset.col];
|
||||
applyColW();
|
||||
saveColW();
|
||||
fitAll();
|
||||
lastColResize = Date.now();
|
||||
autoFitCol(h.dataset.col);
|
||||
});
|
||||
|
||||
// ── 틀 고정 — 머리 줄 아래 숫자 지표(매출·로아스) 줄까지 세로 스크롤에도 위에 붙어 있다.
|
||||
|
||||
Reference in New Issue
Block a user