fix(project): keep sidebar on week navigation

This commit is contained in:
2026-10-04 14:14:25 +09:00
parent 5bf8c9c160
commit 2a1a3e7bd9
19 changed files with 415 additions and 29 deletions
+3 -2
View File
@@ -3159,7 +3159,7 @@ def _parse_attendees(text: str, members: list[dict[str, str]]) -> list[dict[str,
@router.get("/goals/{year}/meetings/{month}", response_class=HTMLResponse)
def goal_meeting_page(request: Request, year: int, month: int, week: str | None = None) -> HTMLResponse:
def goal_meeting_page(request: Request, year: int, month: int, week: str | None = None, content: bool = False) -> HTMLResponse:
"""주간 회의록 — 그 달과 겹치는 주(월~일) 탭, 주마다 회의록 하나. 입력은 관리자만(목표 표와 같음)."""
from app.main import build_erp_nav, render_template # noqa: WPS433
from app.store import has_module, is_admin # noqa: WPS433
@@ -3180,7 +3180,7 @@ def goal_meeting_page(request: Request, year: int, month: int, week: str | None
sel = None
if sel is not None and (sel.year, sel.month) != (year, month):
# 다른 달의 주(주는 월요일이 속한 달의 것) — 그 달 회의록 주소로
return RedirectResponse(url=f"/project/goals/{sel.year}/meetings/{sel.month}?week={sel.isoformat()}",
return RedirectResponse(url=f"/project/goals/{sel.year}/meetings/{sel.month}?week={sel.isoformat()}" + ("&content=1" if content else ""),
status_code=303)
if sel is None or sel not in [w for w, _ in weeks]:
sel = next((w for w, e in weeks if w <= today <= e), weeks[0][0])
@@ -3209,6 +3209,7 @@ def goal_meeting_page(request: Request, year: int, month: int, week: str | None
"project_icons": list(store.PROJECT_ICONS),
"goal_year": year,
"goal_month": month,
"meeting_embedded": content,
"meetings_enabled": enabled,
"weeks": [{"start": w.isoformat(), "end": e.isoformat(), "n": i + 1, "label": f"{w.month}/{w.day}~{e.month}/{e.day}",
"has": w.isoformat() in existing, "now": w <= today <= e,
@@ -0,0 +1,22 @@
{# 오른쪽 회의록 전용 문서. 공통 메뉴를 다시 만들지 않고 회의록의 기존 편집 기능을 그대로 사용한다. #}
<!doctype html>
<html lang="ko" class="pj-meeting-content">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>{{ page_title or '주간 회의록' }}</title>
<link rel="stylesheet" href="/static/erp.css?v=20260615b" />
<link rel="stylesheet" href="/static/erp-dialog.css?v=20260930a" />
{% block head_extra %}{% endblock %}
<link rel="stylesheet" href="/static/project-goal-nav.css?v=20261004b" />
<script>
try { document.documentElement.dataset.pjFont = localStorage.getItem('pj_font') || 'system'; } catch (_) {}
window.PJ_HOLIDAYS = {{ (pj_kr_holidays or {}) | tojson }};
</script>
<script src="/static/project-meeting-panel.js?v=20261004a" defer></script>
</head>
<body class="erp-body">
<main class="erp-page">{% block content %}{% endblock %}</main>
<script src="/static/erp-dialog.js?v=20260930a"></script>
</body>
</html>
@@ -17,8 +17,8 @@
프로젝트 관리의 모든 화면에 들어가므로 여기서 한 번 넘긴다(main.py 의 Jinja 전역). #}
<script>window.PJ_HOLIDAYS = {{ (pj_kr_holidays or {}) | tojson }};</script>
{# 모든 프로젝트 화면에서 같은 회의록 트리를 사용한다. #}
<link rel="stylesheet" href="/static/project-goal-nav.css?v=20261004a" />
<script src="/static/project-goal-nav.js?v=20261004a" defer></script>
<link rel="stylesheet" href="/static/project-goal-nav.css?v=20261004b" />
<script src="/static/project-goal-nav.js?v=20261004b" defer></script>
<aside class="pj-side" data-is-admin="{{ 'true' if is_admin else 'false' }}"
data-is-super="{{ 'true' if user.is_super_admin else 'false' }}"
data-me="{{ user.email }}">
@@ -1,4 +1,4 @@
{% extends "erp_base.html" %}
{% extends "project/_meeting_content_base.html" if meeting_embedded else "erp_base.html" %}
{% block head_extra %}
<link rel="stylesheet" href="/static/project.css?v=20261004b" />
@@ -18,7 +18,7 @@
입력은 관리자만(칸별 즉시 저장, project.js initGoalMeeting). DB: project_db 015 (goal_meetings·goal_meeting_items). #}
<div class="pj-wrap pj-inbox-view pj-goal-view pj-meet-view" data-me="{{ (user.email if user else '') | lower }}">
<div class="pj-layout">
{% with current_pid = 0, side_active = "goals" %}{% include "project/_side.html" %}{% endwith %}
{% if not meeting_embedded %}{% with current_pid = 0, side_active = "goals" %}{% include "project/_side.html" %}{% endwith %}{% endif %}
<section class="pj-main">
{# 머리 — 왼쪽: 제목·이전/다음 달·인쇄·회의록 삭제·주차 탭(한 줄) + 이 달 계획(달력 앞까지) / 오른쪽 위: 작은 달력 #}
@@ -308,5 +308,5 @@
<script src="/static/project-goal-text.js?v=20261003d" defer></script>
<script src="/static/project-meeting-cells.js?v=20261003b" defer></script>
<script src="/static/project.js?v=20261003k" defer></script>
<script src="/static/project.js?v=20261004c" defer></script>
{% endblock %}
@@ -202,5 +202,5 @@
{% include "project/_member_tasks_modal.html" %}
<script src="/static/project-goal-text.js?v=20261003d" defer></script>
<script src="/static/project.js?v=20261003n" defer></script>
<script src="/static/project.js?v=20261004c" defer></script>
{% endblock %}
@@ -573,7 +573,7 @@
<h3 id="meetings-week">회의록 열기와 주차 기준</h3>
<ol class="pjh-steps">
<li>왼쪽 <span class="pjh-ui">목표</span>에서 연도를 선택하고 표 머리의 <b>월 이름</b>을 누릅니다.</li>
<li>이미 만든 회의록은 왼쪽 목표 연도 아래의 <b>월 폴더</b>에서도 열 수 있습니다. 폴더 아이콘과 월 이름을 눌러 접거나 펼치고, 주차·날짜 항목을 누르면 그 주 회의록으로 바로 이동합니다. 접기·펼치기는 이 브라우저에 기억됩니다.</li>
<li>이미 만든 회의록은 왼쪽 목표 연도 아래의 <b>월 폴더</b>에서도 열 수 있습니다. 폴더 아이콘과 월 이름을 눌러 접거나 펼치고, 주차·날짜 항목을 누르면 오른쪽 회의록만 바뀝니다. 왼쪽 메뉴와 스크롤 위치는 유지됩니다. 입력한 칸은 이동 전에 저장하며, 저장에 실패하면 현재 회의록을 유지합니다. 접기·펼치기는 이 브라우저에 기억됩니다.</li>
<li>위쪽 주차 탭 또는 오른쪽 작은 달력의 주 한 줄을 눌러 주를 고릅니다. 점은 회의록이 있는 주, <span class="pjh-ui">이번 주</span>는 현재 주입니다. 이전·다음 달 버튼으로 달을 바꿉니다.</li>
<li>한 주는 <b>월요일~일요일</b>이고, 월요일이 속한 달의 회의록입니다. 1주차는 그 달 첫 월요일이 있는 주입니다. 예: 2026년 10월 1주차는 10/5~10/11이며, 9/28~10/4는 9월 회의록입니다.</li>
<li>작은 달력의 흐린 앞 달 주를 누르면 그 달 회의록으로 갑니다. <span class="pjh-ui">해당 연도 목표</span> 버튼은 연간 목표 표로 돌아갑니다.</li>
@@ -104,5 +104,5 @@
{% include "project/_side_modals.html" %}
{% include "project/_member_tasks_modal.html" %}
<script src="/static/project.js?v=20261003h" defer></script>
<script src="/static/project.js?v=20261004c" defer></script>
{% endblock %}
@@ -100,5 +100,5 @@
"today": {{ today | tojson }}
}
</script>
<script src="/static/project.js?v=20261003h" defer></script>
<script src="/static/project.js?v=20261004c" defer></script>
{% endblock %}
@@ -492,5 +492,5 @@
</script>
<script src="/static/vendor/vis-timeline/vis-timeline-graph2d.min.js"></script>
<script src="/static/project.js?v=20261004a" defer></script>
<script src="/static/project.js?v=20261004c" defer></script>
{% endblock %}
@@ -70,5 +70,5 @@
{% include "project/_side_modals.html" %}
{% include "project/_member_tasks_modal.html" %}
<script src="/static/project.js?v=20261003h" defer></script>
<script src="/static/project.js?v=20261004c" defer></script>
{% endblock %}
+14
View File
@@ -26,3 +26,17 @@
.pj-side-meeting-week:hover { background: #f1f2f4; }
.pj-side-meeting-week.is-active { background: var(--pj-accent-tint); color: var(--pj-accent-dark); }
.pj-side-meeting-retry { font: inherit; font-size: 12px; color: var(--pj-ink-soft); border: 0; background: transparent; cursor: pointer; padding: 5px 8px; }
/* 왼쪽 메뉴와 별개로 오른쪽 회의록 문서만 바뀌는 영역. */
.pj-meeting-panel-host { position: relative; max-width: none !important; overflow: hidden; }
.pj-meeting-panel-frame { display: block; width: 100%; height: 100%; min-height: 0; flex: 1; border: 0; background: #fff; }
.pj-meeting-panel-frame.is-loading { position: absolute; inset: 0; visibility: hidden; }
.pj-meeting-panel-status { position: absolute; top: 4px; right: 8px; z-index: 2; padding: 6px 10px; border-radius: 6px; background: #f4f5f7; color: var(--pj-ink-soft); font-size: 12px; }
.pj-meeting-panel-status.is-error { color: #b42318; background: #fff1f0; }
html.pj-meeting-content, html.pj-meeting-content body { height: 100%; overflow: hidden; }
html.pj-meeting-content .erp-page { height: 100%; margin: 0; padding: 0; display: flex; box-sizing: border-box; }
html.pj-meeting-content .pj-wrap { width: 100%; min-height: 0; display: flex; flex-direction: column; padding: 0; }
html.pj-meeting-content .pj-layout { display: flex; flex-direction: column; height: 100%; min-height: 0; }
@media (max-width: 800px) {
.pj-meeting-panel-host { height: 80vh; min-height: 400px; }
}
+142
View File
@@ -5,6 +5,7 @@
const branches = Array.from(document.querySelectorAll(".pj-side-goal-branch"));
if (!branches.length) return;
let loading = false, retry = null;
const navigation = initMeetingNavigation();
// 문자열을 HTML로 해석하지 않고 넣어 회의록 메뉴의 글자를 그대로 표시한다.
function icon(name, cls) {
@@ -40,6 +41,13 @@
link.href = week.href;
link.textContent = week.label;
link.title = week.label;
link.addEventListener("click", function (event) {
// Ctrl/⌘ 클릭과 새 탭 열기는 일반 링크의 동작을 유지한다.
if (event.defaultPrevented || event.button || event.ctrlKey || event.metaKey || event.shiftKey || event.altKey) return;
if (!navigation) return;
event.preventDefault();
navigation.open(link.href);
});
if (week.start === current) {
link.classList.add("is-active");
link.setAttribute("aria-current", "page");
@@ -66,6 +74,7 @@
const year = (data.years || []).find(function (y) { return String(y.year) === branch.dataset.goalYear; });
render(branch, year ? year.months : []);
});
if (navigation) navigation.markCurrent();
if (retry) { retry.remove(); retry = null; }
} catch (_) {
// 목록 조회가 실패해도 기존 목표·프로젝트 메뉴는 계속 사용할 수 있다.
@@ -82,6 +91,139 @@
}
load();
}
// 왼쪽 메뉴는 그대로 두고 오른쪽 문서만 교체한다. 회의록 편집 이벤트·타이머는 문서와 함께 정리된다.
function initMeetingNavigation() {
const layout = document.querySelector(".pj-layout");
const original = layout && layout.querySelector(".pj-main");
if (!original) return null;
const root = layout.closest(".pj-wrap"), originalClasses = root.className;
const originalUrl = location.pathname + location.search;
const originalTitle = document.title;
const originalYears = new Set(Array.from(document.querySelectorAll(".pj-side-goal-year.is-active")));
let host = null, frame = null, pending = null, sequence = 0, current = originalUrl;
function meetingUrl(value) {
const url = new URL(value, location.href);
if (url.origin !== location.origin || !/^\/project\/goals\/\d{4}\/meetings\/\d{1,2}$/.test(url.pathname)) return null;
url.searchParams.delete("content");
return url;
}
function markCurrent() {
const url = meetingUrl(current), week = url && url.searchParams.get("week");
document.querySelectorAll(".pj-side-meeting-week").forEach(function (link) {
const selected = url && link.pathname === url.pathname && new URL(link.href).searchParams.get("week") === week;
link.classList.toggle("is-active", !!selected);
if (selected) link.setAttribute("aria-current", "page"); else link.removeAttribute("aria-current");
});
document.querySelectorAll(".pj-side-goal-year").forEach(function (link) {
link.classList.toggle("is-active", url ? url.pathname.startsWith(link.pathname + "/") : originalYears.has(link));
});
}
function ensureHost() {
if (host) return;
host = document.createElement("section");
host.className = "pj-main pj-meeting-panel-host";
original.replaceWith(host);
root.classList.add("pj-goal-view", "pj-inbox-view", "pj-meet-view");
}
function status(message, failed) {
if (!host) return;
let box = host.querySelector(".pj-meeting-panel-status");
if (!box) { box = document.createElement("div"); box.className = "pj-meeting-panel-status"; box.setAttribute("role", "status"); host.append(box); }
box.textContent = message;
box.classList.toggle("is-error", !!failed);
}
function clearStatus() { const box = host && host.querySelector(".pj-meeting-panel-status"); if (box) box.remove(); }
function syncFont() {
if (!frame) return;
const font = document.documentElement.dataset.pjFont || "system";
if (frame.contentDocument.documentElement.dataset.pjFont !== font) {
frame.contentDocument.documentElement.dataset.pjFont = font;
frame.contentWindow.dispatchEvent(new frame.contentWindow.Event("resize"));
}
}
async function saveCurrent() {
const view = frame ? frame.contentWindow : window;
if (view.PJFlushForNavigation) await view.PJFlushForNavigation();
}
async function open(value, options) {
options = options || {};
const url = meetingUrl(value);
if (!url) return;
const target = url.pathname + url.search;
if (frame && target === current && !pending) return;
const turn = ++sequence;
try {
if (!options.initial) await saveCurrent();
if (turn !== sequence) return;
ensureHost();
if (pending) { pending.remove(); pending = null; }
status("회의록을 불러오는 중…", false);
const next = document.createElement("iframe");
next.className = "pj-meeting-panel-frame is-loading";
next.title = "주간 회의록";
pending = next;
next.addEventListener("load", function () {
if (next !== frame && turn !== sequence) { next.remove(); return; }
try {
if (!next.contentDocument.documentElement.classList.contains("pj-meeting-content")) throw new Error("회의록을 불러오지 못했습니다. 주차를 다시 눌러 주세요.");
const actual = meetingUrl(next.contentWindow.location.href);
const pane = next.contentDocument.getElementById("pj-meet-pane");
if (pane && pane.dataset.week) actual.searchParams.set("week", pane.dataset.week);
// 줄 추가·삭제 등으로 현재 회의록 자체가 새로고침되어도 패널을 제거하지 않는다.
if (next === frame) {
if (!pending) {
current = actual.pathname + actual.search;
clearStatus(); markCurrent(); history.replaceState({ pjMeeting: true }, "", current);
}
syncFont(); return;
}
current = actual.pathname + actual.search;
if (frame) frame.remove();
frame = next; pending = null;
next.classList.remove("is-loading");
syncFont(); clearStatus(); markCurrent();
document.title = next.contentDocument.title;
if (options.history !== false) history[options.initial ? "replaceState" : "pushState"]({ pjMeeting: true }, "", current);
} catch (error) {
if (next !== frame) { next.remove(); if (pending === next) pending = null; }
status(error.message, true);
if (options.history === false) history.replaceState(null, "", current);
}
});
url.searchParams.set("content", "1");
next.src = url.href;
host.append(next);
} catch (error) {
if (turn !== sequence) return;
if (host) status("이동하지 못했습니다. " + error.message, true);
else if (window.erpAlert) window.erpAlert(error.message);
if (options.history === false) history.replaceState(null, "", current);
}
}
window.addEventListener("message", function (event) {
if (!frame || event.origin !== location.origin || event.source !== frame.contentWindow) return;
if (event.data && event.data.type === "pj-meeting-navigate") open(event.data.href);
});
window.addEventListener("resize", syncFont);
window.addEventListener("popstate", async function () {
const url = location.pathname + location.search;
if (meetingUrl(url)) { open(url, { history: false }); return; }
if (url === originalUrl && host) {
try {
await saveCurrent(); sequence++;
if (pending) pending.remove();
if (frame) frame.remove();
host.replaceWith(original); host = frame = pending = null;
root.className = originalClasses; current = originalUrl; document.title = originalTitle; markCurrent();
} catch (error) { status(error.message, true); history.replaceState(null, "", current); }
}
});
// 첫 회의록도 편집 코드가 붙기 전에 오른쪽 전용 문서로 분리해 중복 초기화를 막는다.
if (meetingUrl(originalUrl)) open(originalUrl, { initial: true });
return { open: open, markCurrent: markCurrent };
}
if (document.readyState === "loading") document.addEventListener("DOMContentLoaded", init);
else init();
})();
+19
View File
@@ -0,0 +1,19 @@
/* 오른쪽 회의록 안의 주차·달 이동도 왼쪽 메뉴를 유지하도록 부모 화면에 전달한다. */
(function () {
"use strict";
if (window.parent === window) return;
document.addEventListener("click", function (event) {
const link = event.target.closest("a[href]");
if (!link || event.defaultPrevented || event.button || event.ctrlKey || event.metaKey || event.shiftKey || event.altKey) return;
const url = new URL(link.href, location.href);
if (url.origin !== location.origin) return;
if (/^\/project\/goals\/\d{4}\/meetings\/\d{1,2}$/.test(url.pathname)) {
event.preventDefault();
url.searchParams.delete("content");
window.parent.postMessage({ type: "pj-meeting-navigate", href: url.href }, location.origin);
} else if (/^\/project\/goals\/\d{4}$/.test(url.pathname)) {
// 연간 목표로 돌아갈 때는 중첩 메뉴가 생기지 않도록 바깥 화면에서 연다.
link.target = "_top";
}
});
})();
+31 -16
View File
@@ -8,24 +8,36 @@
"use strict";
// ── 공용 fetch ─────────────────────────────────────────────
const navigationSavers = [];
let navigationWrites = 0;
// 오른쪽 회의록을 바꾸기 전에 입력 칸 저장을 끝낸다. 실패하면 기존 화면을 유지한다.
window.PJFlushForNavigation = async function () {
if (document.activeElement && document.activeElement.blur) document.activeElement.blur();
await Promise.all(navigationSavers.map(function (flush) { return flush(); }));
if (navigationWrites) throw new Error("저장 중입니다. 저장이 끝난 뒤 다시 이동해 주세요.");
};
// extra.keepalive — 페이지를 떠나는 중에도 요청을 보내 달라고 브라우저에 부탁(보장은 아님, createFieldSaver 참고)
async function api(method, url, body, extra) {
const opts = { method, headers: { "Content-Type": "application/json" } };
if (body !== undefined) opts.body = JSON.stringify(body);
if (extra && extra.keepalive) opts.keepalive = true;
const res = await fetch(url, opts);
if (!res.ok) {
let msg = res.statusText, detail = null;
try { detail = (await res.json()).detail; } catch (_) {}
if (typeof detail === "string") msg = detail;
else if (detail && detail.message) msg = detail.message;
const err = new Error(msg);
err.status = res.status; // 403(권한 없음)·404 를 일시 오류와 구분하려고
err.detail = detail;
throw err;
}
if (res.status === 204) return null;
return res.json();
const writing = method !== "GET";
if (writing) navigationWrites++;
try {
const opts = { method, headers: { "Content-Type": "application/json" } };
if (body !== undefined) opts.body = JSON.stringify(body);
if (extra && extra.keepalive) opts.keepalive = true;
const res = await fetch(url, opts);
if (!res.ok) {
let msg = res.statusText, detail = null;
try { detail = (await res.json()).detail; } catch (_) {}
if (typeof detail === "string") msg = detail;
else if (detail && detail.message) msg = detail.message;
const err = new Error(msg);
err.status = res.status; // 403(권한 없음)·404 를 일시 오류와 구분하려고
err.detail = detail;
throw err;
}
if (res.status === 204) return null;
return await res.json();
} finally { if (writing) navigationWrites--; }
}
function el(id) { return document.getElementById(id); }
@@ -347,6 +359,7 @@
if (warn && e) { e.preventDefault(); e.returnValue = ""; }
return warn;
}
navigationSavers.push(flushAll);
return {
track: track, queue: queue, flush: flush, flushAll: flushAll, isDirty: isDirty, anyDirty: anyDirty,
prune: prune, onBeforeUnload: onBeforeUnload,
@@ -8338,6 +8351,8 @@
let failures = 0;
let timer = null;
async function syncOnce() {
// 회의록 패널을 보는 동안은 이전 프로젝트 화면의 자동 갱신이 왼쪽 메뉴를 다시 만들지 않게 한다.
if (document.querySelector(".pj-meeting-panel-host")) return;
if (syncing || observed === null || observed === applied) return;
syncing = true;
const target = observed;