feat(project): add monthly meeting menu tree
This commit is contained in:
@@ -2684,6 +2684,32 @@ def api_create_goal_year(request: Request, payload: dict[str, Any] = Body(...))
|
||||
return JSONResponse({"ok": True, "year": y}, status_code=201)
|
||||
|
||||
|
||||
@router.get("/api/goals/meeting-nav")
|
||||
def api_goal_meeting_nav(request: Request) -> JSONResponse:
|
||||
"""왼쪽 메뉴용: 저장된 회의록만 연도·월로 묶는다. 화면 조회로 회의록을 만들지 않는다."""
|
||||
_require_user(request)
|
||||
st = _db_or_503(request)
|
||||
years = _goal_years_nav(st)
|
||||
# 연도마다 DB를 읽지 않고, 메뉴에 있는 전체 연도 범위를 한 번에 조회한다.
|
||||
weeks = _goal_call(st.meeting_weeks, start=date(min(years), 1, 1), end=date(max(years), 12, 31))
|
||||
grouped: dict[int, dict[int, list[dict[str, Any]]]] = {}
|
||||
for value in sorted(set(weeks)):
|
||||
mon = store.validate_week_start(value)
|
||||
if mon.year not in years:
|
||||
continue
|
||||
end = mon + timedelta(days=6)
|
||||
# 달이 바뀌어도 월요일이 속한 월 아래에 한 번만 표시한다.
|
||||
number = next(i + 1 for i, (w, _) in enumerate(store.month_weeks(mon.year, mon.month)) if w == mon)
|
||||
grouped.setdefault(mon.year, {}).setdefault(mon.month, []).append({
|
||||
"start": mon.isoformat(), "label": f"{number}주차 ({mon.month}/{mon.day}~{end.month}/{end.day})",
|
||||
"href": f"/project/goals/{mon.year}/meetings/{mon.month}?week={mon.isoformat()}",
|
||||
})
|
||||
return JSONResponse({"years": [
|
||||
{"year": y, "months": [{"month": m, "weeks": grouped[y][m]} for m in sorted(grouped[y])]}
|
||||
for y in years if y in grouped
|
||||
]})
|
||||
|
||||
|
||||
@router.put("/api/goals/{year}")
|
||||
def api_update_goal_year(request: Request, year: int, payload: dict[str, Any] = Body(...)) -> JSONResponse:
|
||||
_require_admin(request)
|
||||
|
||||
@@ -16,6 +16,9 @@
|
||||
{# 날짜 팝업(openDatePopover)이 공휴일을 빨강으로 칠할 때 쓰는 표 — 이 사이드바는
|
||||
프로젝트 관리의 모든 화면에 들어가므로 여기서 한 번 넘긴다(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>
|
||||
<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 }}">
|
||||
@@ -62,8 +65,11 @@
|
||||
</button>
|
||||
<div class="pj-side-goal-years" id="pj-side-goal-years"{% if not goal_open %} hidden{% endif %}>
|
||||
{% for y in (goal_years or []) %}
|
||||
<div class="pj-side-goal-branch" data-goal-year="{{ y }}">
|
||||
<a class="pj-side-goal-year{% if side_active == 'goals' and y == goal_year_active %} is-active{% endif %}"
|
||||
href="/project/goals/{{ y }}">{{ y }}년</a>
|
||||
<div class="pj-side-meeting-months" data-current-week="{{ week if goal_month is defined else '' }}"></div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% if is_admin %}
|
||||
<button type="button" class="pj-side-goal-add" id="pj-goal-year-add"
|
||||
|
||||
@@ -573,6 +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>위쪽 주차 탭 또는 오른쪽 작은 달력의 주 한 줄을 눌러 주를 고릅니다. 점은 회의록이 있는 주, <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>
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
/* 목표 연도 아래 월 폴더와 주간 회의록 — 좁은 왼쪽 메뉴에서도 글자는 한 줄로 표시한다. */
|
||||
.pj-side-goal-branch { min-width: 0; }
|
||||
.pj-side-meeting-months { padding-left: 8px; }
|
||||
.pj-side-meeting-month { min-width: 0; }
|
||||
.pj-side-meeting-month > summary {
|
||||
display: flex; align-items: center; gap: 5px; padding: 5px 4px;
|
||||
border-radius: 6px; cursor: pointer; color: var(--pj-ink-soft); list-style: none;
|
||||
font-size: 13px; line-height: 20px;
|
||||
}
|
||||
.pj-side-meeting-month > summary::-webkit-details-marker { display: none; }
|
||||
.pj-side-meeting-month > summary:hover { background: #f1f2f4; }
|
||||
.pj-side-meeting-month > summary:focus-visible,
|
||||
.pj-side-meeting-week:focus-visible { outline: 2px solid var(--pj-accent); outline-offset: -2px; }
|
||||
.pj-side-meeting-caret { flex: none; font-size: 16px; }
|
||||
.pj-side-meeting-month[open] .pj-side-meeting-caret { transform: rotate(90deg); }
|
||||
.pj-side-meeting-folder { flex: none; font-size: 18px; color: var(--pj-accent); }
|
||||
.pj-side-meeting-folder-open { display: none; }
|
||||
.pj-side-meeting-month[open] .pj-side-meeting-folder-closed { display: none; }
|
||||
.pj-side-meeting-month[open] .pj-side-meeting-folder-open { display: inline-block; }
|
||||
.pj-side-meeting-weeks { margin: 0 0 4px 12px; padding-left: 8px; border-left: 1px solid var(--pj-border); }
|
||||
.pj-side-meeting-week {
|
||||
display: block; min-width: 0; padding: 5px 4px; border-radius: 6px;
|
||||
color: var(--pj-ink); text-decoration: none; font-size: 12px; line-height: 18px;
|
||||
overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
|
||||
}
|
||||
.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; }
|
||||
@@ -0,0 +1,87 @@
|
||||
/* 생성된 회의록만 읽어서 목표 연도 아래에 월별 폴더를 만든다. */
|
||||
(function () {
|
||||
"use strict";
|
||||
function init() {
|
||||
const branches = Array.from(document.querySelectorAll(".pj-side-goal-branch"));
|
||||
if (!branches.length) return;
|
||||
let loading = false, retry = null;
|
||||
|
||||
// 문자열을 HTML로 해석하지 않고 넣어 회의록 메뉴의 글자를 그대로 표시한다.
|
||||
function icon(name, cls) {
|
||||
const span = document.createElement("span");
|
||||
span.className = "material-symbols-outlined " + cls;
|
||||
span.setAttribute("aria-hidden", "true");
|
||||
span.textContent = name;
|
||||
return span;
|
||||
}
|
||||
function render(branch, months) {
|
||||
const list = branch.querySelector(".pj-side-meeting-months");
|
||||
const current = list.dataset.currentWeek;
|
||||
list.replaceChildren();
|
||||
months.forEach(function (month) {
|
||||
const folder = document.createElement("details");
|
||||
folder.className = "pj-side-meeting-month";
|
||||
const key = "pj_goal_month_open:" + branch.dataset.goalYear + ":" + month.month;
|
||||
let saved = null;
|
||||
try { saved = localStorage.getItem(key); } catch (_) {}
|
||||
folder.open = saved == null ? month.weeks.some(function (w) { return w.start === current; }) : saved === "1";
|
||||
const summary = document.createElement("summary");
|
||||
summary.append(icon("chevron_right", "pj-side-meeting-caret"),
|
||||
icon("folder", "pj-side-meeting-folder pj-side-meeting-folder-closed"),
|
||||
icon("folder_open", "pj-side-meeting-folder pj-side-meeting-folder-open"),
|
||||
document.createTextNode(month.month + "월"));
|
||||
summary.setAttribute("aria-label", month.month + "월 주간 회의록");
|
||||
folder.append(summary);
|
||||
const weeks = document.createElement("div");
|
||||
weeks.className = "pj-side-meeting-weeks";
|
||||
month.weeks.forEach(function (week) {
|
||||
const link = document.createElement("a");
|
||||
link.className = "pj-side-meeting-week";
|
||||
link.href = week.href;
|
||||
link.textContent = week.label;
|
||||
link.title = week.label;
|
||||
if (week.start === current) {
|
||||
link.classList.add("is-active");
|
||||
link.setAttribute("aria-current", "page");
|
||||
}
|
||||
weeks.append(link);
|
||||
});
|
||||
folder.append(weeks);
|
||||
list.append(folder);
|
||||
// 접기·펼치기 선택은 같은 브라우저에서 다음 화면에도 유지한다.
|
||||
folder.addEventListener("toggle", function () {
|
||||
try { localStorage.setItem(key, folder.open ? "1" : "0"); } catch (_) {}
|
||||
});
|
||||
});
|
||||
}
|
||||
async function load() {
|
||||
if (loading) return;
|
||||
loading = true;
|
||||
if (retry) retry.disabled = true;
|
||||
try {
|
||||
const response = await fetch("/project/api/goals/meeting-nav", { credentials: "same-origin" });
|
||||
if (!response.ok) throw new Error("회의록 조회 실패");
|
||||
const data = await response.json();
|
||||
branches.forEach(function (branch) {
|
||||
const year = (data.years || []).find(function (y) { return String(y.year) === branch.dataset.goalYear; });
|
||||
render(branch, year ? year.months : []);
|
||||
});
|
||||
if (retry) { retry.remove(); retry = null; }
|
||||
} catch (_) {
|
||||
// 목록 조회가 실패해도 기존 목표·프로젝트 메뉴는 계속 사용할 수 있다.
|
||||
if (!retry) {
|
||||
retry = document.createElement("button");
|
||||
retry.type = "button";
|
||||
retry.className = "pj-side-meeting-retry";
|
||||
retry.textContent = "회의록 목록 다시 불러오기";
|
||||
retry.addEventListener("click", load);
|
||||
branches[branches.length - 1].after(retry);
|
||||
}
|
||||
retry.disabled = false;
|
||||
} finally { loading = false; }
|
||||
}
|
||||
load();
|
||||
}
|
||||
if (document.readyState === "loading") document.addEventListener("DOMContentLoaded", init);
|
||||
else init();
|
||||
})();
|
||||
Reference in New Issue
Block a user