fix(project): keep sidebar on week navigation
This commit is contained in:
@@ -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 %}
|
||||
|
||||
@@ -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; }
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
})();
|
||||
|
||||
@@ -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
@@ -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;
|
||||
|
||||
@@ -728,6 +728,10 @@ description 을 항상 HTML로 취급하기 때문). 두 번 실행하면 이중
|
||||
`GET /project/api/goals/meeting-nav`, 프로젝트 권한자 조회). 월요일이 속한 월로 묶고 월·주차는 날짜순이다.
|
||||
월 폴더는 아이콘과 함께 접기·펼치기를 지원하며 `pj_goal_month_open:{연도}:{월}`에 선택을 기억한다.
|
||||
현재 회의록의 월은 저장된 선택이 없으면 펼치고, 주간 링크는 그 주의 회의록으로 바로 이동한다. 조회로 회의록을 만들지 않는다.
|
||||
주간 링크·회의록 안 주차/달 이동은 왼쪽 DOM과 스크롤을 유지하고 오른쪽 문서만 교체한다.
|
||||
`?content=1`은 `_meeting_content_base.html`로 공통 메뉴 없는 회의록을 반환하며 `project-meeting-panel.js`가 부모 화면에 이동을 전달한다.
|
||||
주소·뒤로/앞으로 이동·선택한 주 표시를 동기화한다. 교체 전 `PJFlushForNavigation`이 글·금액 저장을 완료하고,
|
||||
실패하면 기존 회의록을 유지한다. 새 문서가 성공적으로 로드된 후 기존 문서를 제거해 편집 이벤트·타이머 중복을 방지한다.
|
||||
|
||||
지난주 목표·결과를 리뷰하고 월 목표를 달성하기 위한 이번주 목표·할 일을 정하는 회의(WBR — Weekly Business Review)용.
|
||||
참고한 도구 방식: **WBR 지표 자동 집계**(목표 대비 누적·주당 필요 매출 = 페이싱), **Fellow·Notion 회의 템플릿의 이월**(지난 회의
|
||||
|
||||
@@ -24,6 +24,7 @@ node tests/js/box_calc_ui.test.js
|
||||
python tests/js/render_goals.py # → tests/js/.out/goals_*.html · meeting_*.html
|
||||
node tests/js/goals_meeting_ui.test.js # jsdom 필요(npm install jsdom 또는 NODE_PATH)
|
||||
node tests/js/goal_nav_ui.test.js # 월별 회의록 폴더·주간 링크·접기 상태 기억·조회 재시도
|
||||
node tests/js/goal_nav.browser.test.js # Playwright: 메뉴 유지·오른쪽 전환·저장 대기/실패·뒤로/앞으로
|
||||
```
|
||||
|
||||
실제 브라우저 레이아웃·입력기·터치 기기는 아니다(그건 헤드리스 크롬으로 따로 확인).
|
||||
|
||||
@@ -0,0 +1,140 @@
|
||||
// 실제 브라우저에서 주차를 바꿔도 왼쪽 DOM·스크롤·폴더가 유지되고, 저장 실패 시 이동을 멈추는지 확인한다.
|
||||
// python tests/js/render_goals.py; NODE_PATH=<playwright 경로> PJ_TEST_BROWSER=<Chrome 경로> node tests/js/goal_nav.browser.test.js
|
||||
const assert = require("node:assert/strict");
|
||||
const fs = require("node:fs"), path = require("node:path"), http = require("node:http");
|
||||
const { chromium } = require("playwright");
|
||||
const ROOT = path.resolve(__dirname, "../.."), OUT = path.join(__dirname, ".out"), STATIC = path.join(ROOT, "app/static");
|
||||
const firstMonday = month => {
|
||||
const d = new Date(Date.UTC(2026, month - 1, 1));
|
||||
d.setUTCDate(d.getUTCDate() + (8 - d.getUTCDay()) % 7);
|
||||
return d.toISOString().slice(0, 10);
|
||||
};
|
||||
const tree = { years: [{ year: 2026, months: Array.from({ length: 12 }, (_, i) => {
|
||||
const month = i + 1, starts = month === 9 ? ["2026-09-21", "2026-09-28"] : [firstMonday(month)];
|
||||
return { month, weeks: starts.map(start => ({ start, label: start, href: `/project/goals/2026/meetings/${month}?week=${start}` })) };
|
||||
}) }] };
|
||||
let navReads = 0, topReads = 0, releaseSave = null, saving = false, failSave = false, holdSave = false;
|
||||
let failContent = false, delayWeek = "", liveVersion = "1";
|
||||
const contentReads = [], writes = [];
|
||||
const server = http.createServer(async (req, res) => {
|
||||
const url = new URL(req.url, "http://localhost");
|
||||
if (url.pathname === "/project/api/goals/meeting-nav") { navReads++; res.setHeader("Content-Type", "application/json"); res.end(JSON.stringify(tree)); return; }
|
||||
if (url.pathname.startsWith("/project/api/")) {
|
||||
res.setHeader("Content-Type", "application/json");
|
||||
if (url.pathname.endsWith("/live-version")) { res.end(JSON.stringify({ ts: liveVersion })); return; }
|
||||
if (req.method === "PUT") {
|
||||
let raw = ""; for await (const chunk of req) raw += chunk;
|
||||
writes.push({ path: url.pathname, body: JSON.parse(raw) });
|
||||
if (holdSave) { saving = true; await new Promise(r => { releaseSave = r; }); saving = false; }
|
||||
if (failSave) { res.statusCode = 503; res.end(JSON.stringify({ detail: "test save failure" })); return; }
|
||||
}
|
||||
res.end("{}"); return;
|
||||
}
|
||||
if (url.pathname.startsWith("/project/goals/")) {
|
||||
const month = Number(url.pathname.split("/").pop());
|
||||
const week = url.searchParams.get("week") || firstMonday(month);
|
||||
const content = url.searchParams.get("content") === "1";
|
||||
if (content) contentReads.push(week); else topReads++;
|
||||
if (content && week === delayWeek) await new Promise(r => setTimeout(r, 150));
|
||||
if (content && failContent) { res.statusCode = 503; res.setHeader("Content-Type", "text/html"); res.end("unavailable"); return; }
|
||||
const fixture = /\/meetings\//.test(url.pathname) ? (content ? "meeting_content_admin.html" : "meeting_shell_admin.html") : "goals_shell_admin.html";
|
||||
let html = fs.readFileSync(path.join(OUT, fixture), "utf8")
|
||||
.replaceAll("2026-09-28", week).replaceAll("2026년 9월", `2026년 ${month}월`).replaceAll('data-month="9"', `data-month="${month}"`);
|
||||
res.setHeader("Content-Type", "text/html; charset=utf-8"); res.end(html); return;
|
||||
}
|
||||
const file = path.resolve(STATIC, "." + decodeURIComponent(url.pathname.slice(7)));
|
||||
if (!url.pathname.startsWith("/static/") || !file.startsWith(STATIC + path.sep) || !fs.existsSync(file)) { res.statusCode = 404; res.end(); return; }
|
||||
res.setHeader("Content-Type", ({ ".css": "text/css", ".js": "text/javascript", ".woff2": "font/woff2", ".woff": "font/woff" })[path.extname(file)] || "application/octet-stream");
|
||||
res.end(fs.readFileSync(file));
|
||||
});
|
||||
(async () => {
|
||||
let browser;
|
||||
try {
|
||||
await new Promise(r => server.listen(0, "127.0.0.1", r));
|
||||
browser = await chromium.launch({ headless: true, executablePath: process.env.PJ_TEST_BROWSER || undefined });
|
||||
const page = await browser.newPage({ viewport: { width: 1600, height: 1000 } });
|
||||
const errors = []; page.on("pageerror", e => errors.push(e.message));
|
||||
const origin = "http://127.0.0.1:" + server.address().port;
|
||||
await page.goto(origin + "/project/goals/2026/meetings/9?week=2026-09-28");
|
||||
const currentFrame = () => page.frames().find(f => /content=1/.test(f.url()) && f.url() !== "about:blank");
|
||||
const ready = async week => {
|
||||
await page.waitForFunction(w => {
|
||||
const f = document.querySelector(".pj-meeting-panel-frame:not(.is-loading)");
|
||||
return f && f.contentDocument.getElementById("pj-meet-pane")?.dataset.week === w;
|
||||
}, week);
|
||||
};
|
||||
await ready("2026-09-28");
|
||||
assert.ok((await page.locator(".pj-meeting-panel-host").boundingBox()).height > 500, "실제 ERP 셸에서 오른쪽은 화면 높이를 사용");
|
||||
await page.locator(".pj-side-meeting-month").first().waitFor();
|
||||
await page.evaluate(() => {
|
||||
window.sidebarIdentity = document.querySelector(".pj-side");
|
||||
window.monthIdentity = document.querySelectorAll(".pj-side-meeting-month")[8];
|
||||
sidebarIdentity.style.height = "300px";
|
||||
sidebarIdentity.scrollTop = 200;
|
||||
window.savedSideScroll = sidebarIdentity.scrollTop;
|
||||
});
|
||||
const clickWeek = async week => page.locator(`.pj-side-meeting-week[href$="week=${week}"]`).evaluate(e => e.click());
|
||||
await clickWeek("2026-09-21"); await ready("2026-09-21");
|
||||
assert.ok(page.url().endsWith("week=2026-09-21"));
|
||||
assert.ok(await page.evaluate(() => document.querySelector(".pj-side") === sidebarIdentity && document.querySelectorAll(".pj-side-meeting-month")[8] === monthIdentity && sidebarIdentity.scrollTop === savedSideScroll && monthIdentity.open));
|
||||
assert.equal(navReads, 1); assert.equal(topReads, 1);
|
||||
assert.equal(await currentFrame().locator(".pj-side").count(), 0);
|
||||
await page.goBack(); await ready("2026-09-28");
|
||||
await page.goForward(); await ready("2026-09-21");
|
||||
// 저장 응답이 늦으면 현재 회의록을 유지하고 완료 후에만 다음 주를 연다.
|
||||
holdSave = true;
|
||||
await currentFrame().locator("#pj-meet-notes").fill("saved before changing weeks");
|
||||
const readsBeforeSave = contentReads.length;
|
||||
await clickWeek("2026-09-28");
|
||||
await page.waitForFunction(() => document.querySelector(".pj-meeting-panel-frame:not(.is-loading)").contentWindow.document.getElementById("pj-meet-notes").value === "saved before changing weeks");
|
||||
await new Promise(r => setTimeout(r, 80));
|
||||
assert.ok(saving); assert.equal(contentReads.length, readsBeforeSave);
|
||||
holdSave = false; releaseSave(); await ready("2026-09-28");
|
||||
assert.ok(writes.some(w => w.path.endsWith("2026-09-21") && w.body.notes === "saved before changing weeks"));
|
||||
failSave = true;
|
||||
await currentFrame().locator("#pj-meet-notes").fill("keep failed draft");
|
||||
await clickWeek("2026-09-21");
|
||||
await page.locator(".pj-meeting-panel-status.is-error").waitFor();
|
||||
assert.ok(page.url().endsWith("week=2026-09-28"));
|
||||
assert.equal(await currentFrame().locator("#pj-meet-notes").inputValue(), "keep failed draft");
|
||||
failSave = false; await clickWeek("2026-09-21"); await ready("2026-09-21");
|
||||
await page.evaluate(() => { window.currentPanelIdentity = document.querySelector(".pj-meeting-panel-frame:not(.is-loading)"); });
|
||||
const reloadingFrame = currentFrame();
|
||||
await Promise.all([reloadingFrame.waitForNavigation(), reloadingFrame.evaluate(() => location.reload())]); await ready("2026-09-21");
|
||||
assert.ok(await page.evaluate(() => document.querySelector(".pj-meeting-panel-frame:not(.is-loading)") === currentPanelIdentity && currentPanelIdentity.isConnected));
|
||||
// 오른쪽 안의 달 링크도 부모 주소만 갱신하고, 왼쪽 목록은 다시 읽지 않는다.
|
||||
await currentFrame().locator('a[href="/project/goals/2026/meetings/10"]').click();
|
||||
await ready("2026-10-05"); assert.ok(page.url().includes("/meetings/10?week=2026-10-05"));
|
||||
failContent = true; await clickWeek("2026-09-21");
|
||||
await page.locator(".pj-meeting-panel-status.is-error").waitFor();
|
||||
assert.ok(page.url().includes("/meetings/10?week=2026-10-05"));
|
||||
assert.equal(await currentFrame().locator("#pj-meet-pane").getAttribute("data-week"), "2026-10-05");
|
||||
failContent = false; delayWeek = "2026-09-21";
|
||||
await clickWeek("2026-09-21"); await new Promise(r => setTimeout(r, 30)); await clickWeek("2026-10-05");
|
||||
await ready("2026-10-05"); await new Promise(r => setTimeout(r, 200));
|
||||
assert.ok(page.url().includes("/meetings/10?week=2026-10-05")); delayWeek = "";
|
||||
assert.equal(navReads, 1); assert.equal(topReads, 1);
|
||||
assert.ok(await page.evaluate(() => document.querySelector(".pj-side") === sidebarIdentity && sidebarIdentity.scrollTop === savedSideScroll));
|
||||
await page.locator(".pj-meeting-panel-host").screenshot({ path: path.join(OUT, "meeting-stable-navigation.png") });
|
||||
assert.deepEqual(errors, []);
|
||||
// 연간 목표에서 회의록으로 갔다가 뒤로 가면 원래 표와 메뉴를 다시 쓰며 새로고침하지 않는다.
|
||||
const annual = await browser.newPage({ viewport: { width: 1600, height: 1000 } });
|
||||
await annual.addInitScript(() => { window.__PJ_TEST__ = true; });
|
||||
await annual.goto(origin + "/project/goals/2026");
|
||||
await annual.locator(".pj-side-meeting-month").first().waitFor();
|
||||
assert.equal(await annual.locator(".pj-side-goal-year.is-active").count(), 1);
|
||||
await annual.evaluate(() => { window.originalTable = document.getElementById("pj-goal-table"); });
|
||||
await annual.locator('.pj-side-meeting-week[href$="week=2026-09-28"]').evaluate(e => e.click());
|
||||
await annual.waitForFunction(() => !!document.querySelector(".pj-meeting-panel-frame:not(.is-loading)"));
|
||||
liveVersion = "2";
|
||||
await annual.evaluate(() => window.__pjLivePoll());
|
||||
assert.equal(await annual.evaluate(() => window.pjLiveRefreshState().applied), "1", "회의록을 보는 동안 이전 화면 자동 갱신은 보류");
|
||||
await annual.goBack();
|
||||
await annual.waitForFunction(() => document.getElementById("pj-goal-table") === window.originalTable);
|
||||
await annual.evaluate(() => window.__pjLivePoll());
|
||||
assert.equal(await annual.evaluate(() => window.pjLiveRefreshState().applied), "2", "원래 화면으로 돌아오면 자동 갱신 재개");
|
||||
assert.equal(await annual.locator(".pj-side-goal-year.is-active").count(), 1);
|
||||
await annual.close();
|
||||
console.log("ALL PASS: stable left DOM/scroll/folders, right-only navigation, back/forward, delayed saves, failed-save draft, inner month links and single sidebar read");
|
||||
} finally { if (releaseSave) releaseSave(); if (browser) await browser.close(); await new Promise(r => server.close(r)); }
|
||||
})().catch(e => { console.error(e); process.exitCode = 1; });
|
||||
@@ -145,6 +145,8 @@ def main() -> None:
|
||||
"meeting_layout_admin.html": ("project/goal_meeting.html", meeting_layout_ctx(True)),
|
||||
"meeting_layout_ro.html": ("project/goal_meeting.html", meeting_layout_ctx(False)),
|
||||
"meeting_merged.html": ("project/goal_meeting.html", meeting_merged_ctx()),
|
||||
"meeting_content_admin.html": ("project/goal_meeting.html", meeting_ctx(True, False, can_sync=False) | {"meeting_embedded": True}),
|
||||
"meeting_content_ro.html": ("project/goal_meeting.html", meeting_ctx(False, False, can_sync=False) | {"meeting_embedded": True}),
|
||||
}
|
||||
for name, (tpl, ctx) in pages.items():
|
||||
html = env.get_template(tpl).render(**ctx)
|
||||
@@ -152,6 +154,21 @@ def main() -> None:
|
||||
io.open(path, "w", encoding="utf-8", newline="\n").write(html)
|
||||
print("rendered:", path)
|
||||
|
||||
# 왼쪽을 유지하는 브라우저 검증은 실제 ERP 기본 레이아웃도 사용한다.
|
||||
shell_env = jinja2.Environment(loader=jinja2.ChoiceLoader([
|
||||
jinja2.FileSystemLoader(os.path.join(ROOT, "app", "modules", "project", "templates")),
|
||||
jinja2.FileSystemLoader(os.path.join(ROOT, "app", "templates")),
|
||||
]), autoescape=True)
|
||||
shell_env.globals["pj_kr_holidays"] = {}
|
||||
for name, ctx in [("meeting_shell_admin.html", meeting_ctx(True, False, can_sync=False)),
|
||||
("goals_shell_admin.html", goals_ctx(True))]:
|
||||
ctx.update(nav_items=[], force_sidebar_collapsed=True, page_title="목표·회의록 검증")
|
||||
ctx["user"]["name"] = "Tester"
|
||||
html = shell_env.get_template("project/goals.html" if name.startswith("goals") else "project/goal_meeting.html").render(**ctx)
|
||||
path = os.path.join(OUT_DIR, name)
|
||||
io.open(path, "w", encoding="utf-8", newline="\n").write(html)
|
||||
print("rendered:", path)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
"""회의록 메뉴의 권한·저장된 주만 조회·월 경계를 DB 연결 없이 확인한다."""
|
||||
import importlib
|
||||
import sys
|
||||
import unittest
|
||||
from datetime import date
|
||||
from types import SimpleNamespace
|
||||
@@ -47,3 +48,13 @@ class MeetingNavTests(unittest.TestCase):
|
||||
patch.object(api, "_store") as query:
|
||||
self.assertEqual(self.client.get("/project/api/goals/meeting-nav").status_code, status)
|
||||
query.assert_not_called()
|
||||
|
||||
def test_other_month_redirect_keeps_content_only_mode(self):
|
||||
# 다른 달의 월요일 링크가 들어와도 오른쪽 전용 화면을 유지한다.
|
||||
main_stub = SimpleNamespace(build_erp_nav=Mock(), render_template=Mock())
|
||||
with patch.dict(sys.modules, {"app.main": main_stub}), patch.object(api, "_require_user", return_value={}), \
|
||||
patch.object(api, "_store", return_value=SimpleNamespace()):
|
||||
response = self.client.get("/project/goals/2026/meetings/10?week=2026-09-28&content=1", follow_redirects=False)
|
||||
self.assertEqual(response.status_code, 303)
|
||||
self.assertEqual(response.headers["location"], "/project/goals/2026/meetings/9?week=2026-09-28&content=1")
|
||||
main_stub.render_template.assert_not_called()
|
||||
|
||||
Reference in New Issue
Block a user