app / templates /base.html
Ryo_Shimano
Claude Sonnet 5
feat: アプリ上からバグ報告・機能要望を送信しGitHub Issueに自動起票する機能を追加
57d9b6b
Raw History Blame Contribute Delete
33.8 kB
<!doctype html>
<html lang="ja">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
<meta name="theme-color" content="#0f172a">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
<meta name="apple-mobile-web-app-title" content="SDU-Shift">
<meta name="csrf-token" content="{{ csrf_token() }}">
<link rel="manifest" href="/static/manifest.json">
<link rel="icon" type="image/x-icon" href="/static/favicon.ico">
<link rel="icon" type="image/png" sizes="32x32" href="/static/icons/favicon-32.png">
<link rel="icon" type="image/png" sizes="16x16" href="/static/icons/favicon-16.png">
<link rel="apple-touch-icon" href="/static/icons/apple-touch-icon.png">
{% include "pwa/_splash_links.html" %}
<!-- Noto Sans JP (ノンブロッキング読み込み) -->
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link rel="preload" as="style"
href="https://fonts.googleapis.com/css2?family=Noto+Sans+JP:wght@400;500;600;700&display=swap"
onload="this.rel='stylesheet'">
<noscript>
<link href="https://fonts.googleapis.com/css2?family=Noto+Sans+JP:wght@400;500;600;700&display=swap" rel="stylesheet">
</noscript>
<title>{% block title %}SDU-Shift{% endblock %}</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.css">
<style>
/* ── デザイントークン ─────────────────────────────── */
:root {
--nav-h: 68px;
--safe-top: env(safe-area-inset-top, 0px);
--safe-bottom: env(safe-area-inset-bottom, 0px);
--primary: #0ea5e9;
--primary-dark: #0284c7;
--primary-light: #38bdf8;
--accent: #38bdf8;
--radius-xl: 20px;
--radius-lg: 14px;
--radius-md: 10px;
--radius-sm: 7px;
--transition: .25s cubic-bezier(.4, 0, .2, 1);
}
[data-theme="light"] {
--bg: linear-gradient(165deg, #e0f2fe 0%, #f0f9ff 35%, #f8fafc 75%);
--bg-card: rgba(255, 255, 255, 0.75);
--border: rgba(226, 232, 240, 0.8);
--text: #0f172a;
--text-muted: #475569;
--shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.03);
--shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
--shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -2px rgba(0, 0, 0, 0.04);
--shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
--glass-bg: rgba(255, 255, 255, 0.7);
--glass-border: rgba(255, 255, 255, 0.5);
--sidebar-bg: linear-gradient(180deg, #0f172a 0%, #1e293b 100%);
--dark-card-bg: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
--dark-card-text:#f8fafc;
--header-bg: linear-gradient(135deg, #0f172a 0%, #1e293b 60%, #0f172a 100%);
--grid-bg: #ffffff;
}
[data-theme="dark"] {
--bg: linear-gradient(165deg, #020617 0%, #0f172a 45%, #1e293b 100%);
--bg-card: rgba(30, 41, 59, 0.65);
--border: rgba(51, 65, 85, 0.5);
--text: #f8fafc;
--text-muted: #94a3b8;
--shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.2);
--shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.2), 0 2px 4px -1px rgba(0, 0, 0, 0.1);
--shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.35), 0 4px 6px -2px rgba(0, 0, 0, 0.15);
--shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.55), 0 10px 10px -5px rgba(0, 0, 0, 0.25);
--glass-bg: rgba(15, 23, 42, 0.65);
--glass-border: rgba(255, 255, 255, 0.05);
--sidebar-bg: linear-gradient(180deg, #020617 0%, #0f172a 100%);
--dark-card-bg: linear-gradient(135deg, #0f172a 0%, #020617 100%);
--dark-card-text:#e2e8f0;
--header-bg: linear-gradient(135deg, #020617 0%, #0f172a 60%, #1e293b 100%);
--grid-bg: #0f172a;
}
/* ── ベース ──────────────────────────────────────── */
body {
padding-bottom: calc(var(--nav-h) + var(--safe-bottom));
background: var(--bg);
min-height: 100vh;
font-family: 'Noto Sans JP', system-ui, -apple-system, sans-serif;
-webkit-font-smoothing: antialiased;
color: var(--text);
transition: background var(--transition), color var(--transition);
}
/* ── ページヘッダー ──────────────────────────────── */
.page-header {
background: var(--header-bg);
border-bottom: 1px solid rgba(148,163,184,.15);
box-shadow: 0 2px 20px rgba(0,0,0,.3);
color: white;
padding: calc(.7rem + var(--safe-top)) 1rem .7rem;
position: sticky; top: 0; z-index: 100;
display: flex; align-items: center; gap: .65rem;
min-height: 54px;
transition: background var(--transition);
}
.page-header h1, .page-header .fw-semibold {
font-size: 1rem; margin: 0; font-weight: 700; letter-spacing: .02em;
}
.page-header .header-brand-logo {
width: 30px; height: 30px; object-fit: contain;
border-radius: 7px; flex-shrink: 0; opacity: .9;
}
@media (min-width: 768px) { .page-header .header-brand-logo { display: none; } }
@media (min-width: 768px) {
.page-header::after {
content: 'SKY DINING UOMAN';
margin-left: auto;
font-size: .58rem; letter-spacing: .15em;
color: rgba(148,163,184,.3); font-weight: 600;
white-space: nowrap; text-transform: uppercase; pointer-events: none;
}
.page-header:has(.ms-auto)::after { display: none; }
}
/* ── コンテンツ ──────────────────────────────────── */
.content { padding: 1rem; }
/* ── モバイル共通 UI 修正 ──────────────────────────── */
@media (max-width: 767px) {
.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-responsive table th, .table-responsive table td { white-space: nowrap; }
.mobile-label { min-width: 0 !important; width: 100%; margin-bottom: .3rem; }
.mobile-stack { flex-direction: column !important; align-items: stretch !important; }
.mobile-stack > * { width: 100% !important; max-width: 100% !important; }
.mobile-btn-wrap { flex-wrap: wrap !important; }
.mobile-btn-wrap > .btn { flex: 1 1 auto; min-width: 0; }
input[type="number"].form-control-sm { width: 52px !important; }
input[type="time"].form-control-sm { max-width: 100% !important; }
.card-body { padding: .75rem; }
.page-header { flex-wrap: wrap; min-height: auto; gap: .4rem; }
.page-header .ms-auto { margin-left: auto !important; }
input, select, textarea { font-size: 16px !important; }
input.form-control-sm, select.form-select-sm { font-size: 14px !important; }
}
/* ── カード ──────────────────────────────────────── */
.card, .db-card {
border: 1px solid var(--border);
background: var(--glass-bg);
backdrop-filter: blur(16px);
-webkit-backdrop-filter: blur(16px);
box-shadow: var(--shadow-sm);
border-radius: var(--radius-lg);
transition: all var(--transition);
}
@media (hover: hover) {
.card:hover, .db-card:hover {
box-shadow: var(--shadow-md);
transform: translateY(-2px);
}
}
/* ── ボタン ──────────────────────────────────────── */
.btn { border-radius: var(--radius-md); font-weight: 500; transition: all var(--transition); }
.btn-primary {
background: linear-gradient(135deg, #0ea5e9 0%, #0284c7 100%);
border: none;
box-shadow: 0 2px 8px rgba(14,165,233,.28);
}
.btn-primary:hover {
background: linear-gradient(135deg, #38bdf8 0%, #0ea5e9 100%);
box-shadow: 0 4px 14px rgba(14,165,233,.4);
transform: translateY(-2px); border: none;
}
.btn-primary:active { transform: translateY(0); }
.btn-outline-secondary { border-color: var(--border); color: var(--text-muted); background: transparent; }
.btn-outline-secondary:hover { background: rgba(100, 116, 139, 0.08); border-color: var(--text-muted); color: var(--text); }
.btn-sm { border-radius: var(--radius-sm); }
/* ── フォーム ─────────────────────────────────────── */
.form-control, .form-select {
border-radius: var(--radius-md);
border: 1.5px solid var(--border);
padding: .5rem .85rem;
font-size: .9rem;
transition: border-color var(--transition), box-shadow var(--transition);
background: var(--bg-card);
color: var(--text);
font-family: inherit;
}
.form-control:focus, .form-select:focus {
border-color: var(--primary);
box-shadow: 0 0 0 3px rgba(14,165,233,.12);
outline: none;
background: var(--bg-card);
color: var(--text);
}
.form-control-sm, .form-select-sm { border-radius: var(--radius-sm); }
.form-label { font-size: .85rem; font-weight: 600; color: var(--text-muted); }
.input-group-text { border-color: var(--border); background: var(--bg-card); color: var(--text-muted); }
/* ── バッジ ──────────────────────────────────────── */
.badge { border-radius: var(--radius-sm); font-weight: 600; }
.badge-hall { background: rgba(59, 130, 246, 0.15); color: #3b82f6; }
.badge-kitchen { background: rgba(34, 197, 94, 0.15); color: #22c55e; }
[data-theme="dark"] .badge-hall { color: #60a5fa; }
[data-theme="dark"] .badge-kitchen { color: #4ade80; }
.bg-secondary { background: var(--text-muted) !important; color: var(--bg-card) !important; }
.bg-success { background: linear-gradient(135deg,#22c55e,#16a34a) !important; }
/* ── トースト ─────────────────────────────────────── */
.toast-container {
position: fixed; top: 1rem; right: 1rem; z-index: 9999;
}
@media (max-width: 767px) {
.toast-container {
top: auto; right: auto; left: 50%;
bottom: calc(var(--nav-h) + var(--safe-bottom) + .75rem);
transform: translateX(-50%);
min-width: min(320px, 90vw);
}
}
.toast {
border-radius: var(--radius-md) !important;
box-shadow: var(--shadow-md) !important;
border: none !important;
font-size: .88rem;
}
.btn-loading { pointer-events: none; opacity: .75; }
/* ── モーダル ─────────────────────────────────────── */
.modal-content {
background: var(--bg-card);
backdrop-filter: blur(20px);
-webkit-backdrop-filter: blur(20px);
color: var(--text);
border: 1.5px solid var(--border);
border-radius: var(--radius-lg) !important;
box-shadow: var(--shadow-lg);
}
/* ── ボトムナビ ───────────────────────────────────── */
.bottom-nav {
position: fixed; bottom: 0; left: 0; right: 0;
height: calc(var(--nav-h) + var(--safe-bottom));
padding-bottom: var(--safe-bottom);
background: rgba(15, 23, 42, 0.9);
backdrop-filter: blur(24px) saturate(180%);
-webkit-backdrop-filter: blur(24px) saturate(180%);
border-top: 1px solid rgba(255,255,255,.06);
display: flex; z-index: 1000;
}
.bottom-nav a, .bottom-nav button.nav-btn {
flex: 1; display: flex; flex-direction: column; align-items: center;
justify-content: center; color: #94a3b8; text-decoration: none;
font-size: 10px; gap: 3px; transition: color var(--transition);
min-height: 44px; background: none; border: none; padding: 0;
cursor: pointer; position: relative; font-family: inherit;
}
.bottom-nav a i, .bottom-nav button.nav-btn i { font-size: 22px; }
.bottom-nav a.active, .bottom-nav button.nav-btn.active { color: var(--accent); }
.bottom-nav a:hover, .bottom-nav button.nav-btn:hover { color: #cbd5e1; }
/* アクティブ上部インジケーター */
.bottom-nav a.active::before, .bottom-nav button.nav-btn.active::before {
content: ''; position: absolute; top: 0; left: 50%; transform: translateX(-50%);
width: 28px; height: 2.5px; border-radius: 0 0 3px 3px;
background: var(--accent);
}
/* ── ホーム画面に追加バナー ───────────────────────── */
.pwa-install-banner {
display: none;
position: fixed; left: .75rem; right: .75rem;
bottom: calc(var(--nav-h) + var(--safe-bottom) + .75rem);
z-index: 1000;
align-items: center; gap: .75rem;
background: var(--bg-card);
backdrop-filter: blur(20px);
-webkit-backdrop-filter: blur(20px);
border: 1.5px solid var(--border);
border-radius: var(--radius-lg);
box-shadow: var(--shadow-lg);
padding: .75rem;
color: var(--text);
}
.pwa-install-banner.show { display: flex; }
.pwa-install-banner img { width: 40px; height: 40px; border-radius: 10px; flex-shrink: 0; }
.pwa-install-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.pwa-install-text strong { font-size: .85rem; }
.pwa-install-text span { font-size: .75rem; color: var(--text-muted); }
.pwa-install-action {
background: var(--primary); color: #fff; border: none; border-radius: var(--radius-md);
padding: .4rem .9rem; font-size: .8rem; font-weight: 600; white-space: nowrap;
font-family: inherit;
}
.pwa-install-close {
background: none; border: none; color: var(--text-muted); font-size: 1.1rem;
padding: .25rem; line-height: 1; flex-shrink: 0; cursor: pointer;
}
@media (min-width: 768px) {
.pwa-install-banner { left: auto; right: 1.5rem; bottom: 1.5rem; max-width: 360px; }
}
/* ── ハンバーガードロワー ─────────────────────────── */
.drawer-backdrop {
display: none; position: fixed; inset: 0;
background: rgba(0,0,0,.65); z-index: 1100;
backdrop-filter: blur(4px);
}
.drawer-backdrop.open { display: block; }
.drawer {
position: fixed; bottom: 0; left: 0; right: 0;
background: #0f172a;
border: 1px solid rgba(255,255,255,.06);
border-radius: 24px 24px 0 0;
z-index: 1200; padding-bottom: var(--safe-bottom);
transform: translateY(100%);
transition: transform .3s cubic-bezier(.4,0,.2,1);
box-shadow: 0 -10px 40px rgba(0,0,0,.6);
}
.drawer.open { transform: translateY(0); }
.drawer-handle {
width: 40px; height: 4px;
background: rgba(255,255,255,.15);
border-radius: 2px; margin: 12px auto 6px;
}
.drawer-title {
color: #64748b; font-size: .7rem; font-weight: 700;
text-transform: uppercase; letter-spacing: .08em;
padding: .25rem 1.25rem .5rem;
}
.drawer a {
display: flex; align-items: center; gap: .9rem;
color: #e2e8f0; text-decoration: none;
padding: .9rem 1.25rem; font-size: .95rem; font-weight: 500;
border-bottom: 1px solid rgba(255,255,255,.04);
transition: background var(--transition);
}
.drawer a:last-child { border-bottom: none; }
.drawer a:hover, .drawer a.active { background: rgba(255,255,255,.05); color: var(--accent); }
.drawer a i { font-size: 20px; width: 26px; color: #64748b; }
.drawer a:hover i, .drawer a.active i { color: var(--accent); }
.drawer-close {
display: flex; align-items: center; justify-content: center;
margin: .75rem 1rem 1rem; padding: .7rem;
background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.08);
border-radius: var(--radius-md); color: #94a3b8;
font-size: .88rem; cursor: pointer; width: calc(100% - 2rem);
transition: all var(--transition); font-family: inherit;
}
.drawer-close:hover { background: rgba(255,255,255,.1); color: #e2e8f0; }
/* ── デスクトップサイドバー ─────────────────────── */
.sidebar { display: none; }
@media (min-width: 768px) {
body { padding-bottom: 0; padding-left: 210px; }
.bottom-nav { display: none; }
.drawer-backdrop, .drawer { display: none !important; }
.sidebar {
display: flex; position: fixed; left: 0; top: 0; bottom: 0; width: 210px;
background: var(--sidebar-bg);
border-right: 1px solid var(--border);
flex-direction: column; padding: 1rem 0; z-index: 100;
box-shadow: 2px 0 20px rgba(0,0,0,.2);
}
.sidebar .brand {
display: flex; align-items: center; gap: .6rem;
padding: .5rem 1rem 1rem;
border-bottom: 1px solid rgba(255,255,255,.06);
margin-bottom: .5rem;
text-decoration: none;
transition: opacity var(--transition);
}
.sidebar .brand:hover { opacity: .8; }
.sidebar .brand img {
width: 34px; height: 34px; border-radius: 8px; object-fit: contain;
flex-shrink: 0;
}
.sidebar .brand span {
color: white; font-weight: 700; font-size: .95rem; letter-spacing: .02em;
}
.sidebar a {
display: flex; align-items: center; gap: .7rem;
color: #94a3b8; text-decoration: none;
padding: .55rem 1rem; margin: 1px .75rem;
font-size: .88rem; font-weight: 500;
border-radius: var(--radius-md);
transition: all var(--transition);
}
.sidebar a.active {
color: var(--accent);
background: rgba(56,189,248,.1);
}
.sidebar a:hover:not(.logout-btn) { color: #94a3b8; background: rgba(255,255,255,.04); }
.sidebar a i { font-size: 17px; width: 20px; }
.sidebar .logout-btn {
margin-top: auto; margin-bottom: 0; color: #475569;
}
.sidebar .logout-btn:hover { color: #f87171 !important; background: rgba(248,113,113,.08) !important; }
}
</style>
{% block head %}{% endblock %}
</head>
<body>
<!-- Desktop Sidebar -->
<nav class="sidebar">
<a href="{{ url_for('dashboard.index') }}" class="brand" style="text-decoration:none">
<img src="/static/icons/apple-touch-icon.png" alt="SDU-Shift">
<span>SDU-Shift</span>
</a>
{% set nav_items = [
('dashboard.index', 'bi-house-fill', 'ホーム'),
('shifts.index', 'bi-pencil-square', '希望シフト'),
('generate.index', 'bi-lightning-fill', '自動生成'),
('schedule.list_periods', 'bi-calendar3', 'シフト表'),
('schedule.stats_multi', 'bi-bar-chart-fill', '勤務統計'),
('customers.list_periods','bi-cup-hot-fill', '客数管理'),
('employees.index', 'bi-people-fill', 'スタッフ管理'),
('settings.index', 'bi-gear-fill', '設定'),
('help.index', 'bi-question-circle','ヘルプ'),
('feedback.index', 'bi-chat-square-text','フィードバック'),
] %}
{% for endpoint, icon, label in nav_items %}
{% set active = (request.endpoint == endpoint) if endpoint == 'schedule.stats_multi'
else (request.endpoint and request.endpoint.startswith(endpoint.split('.')[0]) and request.endpoint != 'schedule.stats_multi') %}
<a href="{{ url_for(endpoint) }}"
class="{{ 'active' if active else '' }}">
<i class="bi {{ icon }}"></i>{{ label }}
</a>
{% endfor %}
{% if auth_enabled %}
<a href="{{ url_for('auth.logout') }}" class="logout-btn" style="margin: 1px .75rem;">
<i class="bi bi-box-arrow-right"></i>ログアウト
</a>
{% endif %}
</nav>
<!-- ホーム画面に追加バナー -->
<div class="pwa-install-banner" id="pwa-install-banner">
<img src="/static/icons/icon-192.png" alt="">
<div class="pwa-install-text">
<strong>ホーム画面に追加</strong>
<span id="pwa-install-desc">アプリのように使えます</span>
</div>
<button type="button" class="pwa-install-action d-none" id="pwa-install-action">追加</button>
<button type="button" class="pwa-install-close" id="pwa-install-close" aria-label="閉じる">
<i class="bi bi-x-lg"></i>
</button>
</div>
<!-- Mobile Bottom Nav -->
{% set _in_drawer = request.endpoint and (
request.endpoint.startswith('customers') or
request.endpoint.startswith('employees') or
request.endpoint.startswith('settings') or
request.endpoint.startswith('help') or
request.endpoint.startswith('feedback') or
request.endpoint == 'schedule.stats_multi'
) %}
<div class="bottom-nav">
{% for endpoint, icon, label in [
('dashboard.index', 'bi-house-fill', 'ホーム'),
('shifts.index', 'bi-pencil-square', 'シフト入力'),
('generate.index', 'bi-lightning-fill', '自動生成'),
('schedule.list_periods', 'bi-calendar3', 'シフト表'),
] %}
{% set active = request.endpoint and request.endpoint.startswith(endpoint.split('.')[0]) and request.endpoint != 'schedule.stats_multi' %}
<a href="{{ url_for(endpoint) }}"
class="{{ 'active' if active else '' }}">
<i class="bi {{ icon }}"></i>{{ label }}
</a>
{% endfor %}
<button class="nav-btn {{ 'active' if _in_drawer else '' }}"
onclick="openDrawer()" aria-label="メニュー">
<i class="bi bi-grid-fill"></i>
<span>メニュー</span>
</button>
</div>
<!-- ハンバーガードロワー -->
<div class="drawer-backdrop" id="drawer-backdrop" onclick="closeDrawer()"></div>
<div class="drawer" id="drawer">
<div class="drawer-handle"></div>
<div class="drawer-title">メニュー</div>
{% for endpoint, icon, label, desc in [
('customers.list_periods', 'bi-cup-hot-fill', '客数管理', '予約客数の入力'),
('schedule.stats_multi', 'bi-bar-chart-fill', '勤務統計', '複数期間の勤務時間集計'),
('employees.index', 'bi-people-fill', 'スタッフ管理','スタッフの登録・編集'),
('settings.index', 'bi-gear-fill', '設定', 'シフト制約・アプリ設定'),
('help.index', 'bi-question-circle', 'ヘルプ', '各機能の使い方'),
('feedback.index', 'bi-chat-square-text','フィードバック','不具合報告・機能要望を送る'),
] %}
{% set active = (request.endpoint == endpoint) if endpoint == 'schedule.stats_multi'
else (request.endpoint and request.endpoint.startswith(endpoint.split('.')[0])) %}
<a href="{{ url_for(endpoint) }}"
class="{{ 'active' if active else '' }}"
onclick="closeDrawer()">
<i class="bi {{ icon }}"></i>
<div>
<div>{{ label }}</div>
<div style="font-size:.73rem;color:#94a3b8;font-weight:400;margin-top:1px">{{ desc }}</div>
</div>
</a>
{% endfor %}
{% if auth_enabled %}
<a href="{{ url_for('auth.logout') }}" onclick="closeDrawer()"
style="border-top:1px solid rgba(255,255,255,.06)">
<i class="bi bi-box-arrow-right" style="color:#f87171"></i>
<div>
<div style="color:#f87171">ログアウト</div>
<div style="font-size:.73rem;color:#94a3b8;font-weight:400;margin-top:1px">アクセスを終了する</div>
</div>
</a>
{% endif %}
<button class="drawer-close" onclick="closeDrawer()">
<i class="bi bi-x-lg me-2"></i>閉じる
</button>
</div>
<!-- 未保存離脱ガードモーダル(全ページ共通) -->
<div class="modal fade" id="unsavedModal" tabindex="-1">
<div class="modal-dialog modal-dialog-centered modal-sm">
<div class="modal-content">
<div class="modal-body p-4 text-center">
<i class="bi bi-exclamation-triangle-fill text-warning d-block mb-2" style="font-size:2.2rem"></i>
<div class="fw-semibold mb-1">未保存の変更があります</div>
<div class="text-muted small mb-3">保存せずに移動しますか?</div>
<div class="d-flex gap-2">
<button class="btn btn-secondary flex-grow-1" data-bs-dismiss="modal">戻る</button>
<button class="btn btn-danger flex-grow-1" id="unsaved-proceed-btn">移動する</button>
</div>
</div>
</div>
</div>
</div>
<!-- Flash Messages -->
<div class="toast-container">
{% for cat, msg in get_flashed_messages(with_categories=true) %}
<div class="toast show align-items-center text-bg-{{ 'success' if cat == 'success' else 'danger' if cat == 'error' else 'warning' if cat == 'warning' else 'info' }} border-0" role="alert">
<div class="d-flex">
<div class="toast-body">{{ msg }}</div>
<button type="button" class="btn-close btn-close-white me-2 m-auto" data-bs-dismiss="toast"></button>
</div>
</div>
{% endfor %}
</div>
{% block content %}{% endblock %}
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
<script>
// ── CSRF対策(fetchによるPOST/PUT/PATCH/DELETEに自動でトークンを付与) ──────
(function() {
const token = document.querySelector('meta[name="csrf-token"]').content;
const origFetch = window.fetch;
window.fetch = function(input, init) {
init = init || {};
const method = (init.method || 'GET').toUpperCase();
if (!['GET', 'HEAD', 'OPTIONS', 'TRACE'].includes(method)) {
const headers = new Headers(init.headers || {});
if (!headers.has('X-CSRFToken')) headers.set('X-CSRFToken', token);
init = Object.assign({}, init, { headers });
}
return origFetch(input, init);
};
})();
// ── テーマ管理 ──────────────────────────────────────────
(function() {
const savedTheme = localStorage.getItem('theme');
const systemDark = window.matchMedia('(prefers-color-scheme: dark)').matches;
const initialTheme = savedTheme || (systemDark ? 'dark' : 'light');
document.documentElement.setAttribute('data-theme', initialTheme);
document.documentElement.setAttribute('data-bs-theme', initialTheme);
window.addEventListener('DOMContentLoaded', () => {
updateThemeUI(initialTheme);
});
window.toggleTheme = function() {
const current = document.documentElement.getAttribute('data-theme');
const next = current === 'dark' ? 'light' : 'dark';
document.documentElement.setAttribute('data-theme', next);
document.documentElement.setAttribute('data-bs-theme', next);
localStorage.setItem('theme', next);
updateThemeUI(next);
};
function updateThemeUI(theme) {
// 設定画面のトグルスイッチの同期
const switchEl = document.getElementById('theme-switch');
if (switchEl) {
switchEl.checked = (theme === 'dark');
}
}
})();
function openDrawer() {
document.getElementById('drawer').classList.add('open');
document.getElementById('drawer-backdrop').classList.add('open');
document.body.style.overflow = 'hidden';
}
function closeDrawer() {
document.getElementById('drawer').classList.remove('open');
document.getElementById('drawer-backdrop').classList.remove('open');
document.body.style.overflow = '';
}
(function() {
const drawer = document.getElementById('drawer');
let startY = 0;
drawer.addEventListener('touchstart', e => { startY = e.touches[0].clientY; }, {passive:true});
drawer.addEventListener('touchend', e => {
if (e.changedTouches[0].clientY - startY > 60) closeDrawer();
}, {passive:true});
})();
document.querySelectorAll('.toast').forEach(t => {
const len = t.querySelector('.toast-body')?.textContent.length || 0;
setTimeout(() => bootstrap.Toast.getOrCreateInstance(t).hide(),
Math.min(7000, Math.max(5000, len * 50)));
});
document.querySelectorAll('[data-loading]').forEach(btn => {
const form = btn.form || btn.closest('form');
if (form) form.addEventListener('submit', () => {
btn.disabled = true; btn.classList.add('btn-loading');
btn.innerHTML = '<span class="spinner-border spinner-border-sm me-1"></span>'
+ (btn.dataset.loading || '処理中…');
});
});
(function() {
if (window.innerWidth >= 768) return;
const hdr = document.querySelector('.page-header');
if (!hdr) return;
const a = document.createElement('a');
a.href = '/'; a.style.display = 'flex'; a.style.flexShrink = '0';
const img = document.createElement('img');
img.src = '/static/icons/apple-touch-icon.png';
img.alt = 'ホーム'; img.className = 'header-brand-logo';
a.appendChild(img);
hdr.insertBefore(a, hdr.firstChild);
})();
// ── 未保存離脱ガード(全ページ共通) ────────────────────────────
(function() {
window._formDirty = false;
let _pendingNav = null;
let _guardModal = null;
function _getModal() {
return _guardModal || (_guardModal = new bootstrap.Modal(document.getElementById('unsavedModal')));
}
// data-dirty-form を持つフォームを自動監視
document.querySelectorAll('form[data-dirty-form]').forEach(form => {
form.querySelectorAll('input, select, textarea').forEach(el => {
el.addEventListener('change', () => { window._formDirty = true; });
if (['text','number','time','search'].includes(el.type) || el.tagName === 'TEXTAREA') {
el.addEventListener('input', () => { window._formDirty = true; });
}
});
form.addEventListener('submit', () => { window._formDirty = false; });
});
// 「移動する」ボタン
document.getElementById('unsaved-proceed-btn').addEventListener('click', () => {
window._formDirty = false;
_getModal().hide();
if (_pendingNav) location.href = _pendingNav;
});
// 全リンクのクリックを監視(ページ内アンカー・javascript: は除外)
document.addEventListener('click', e => {
if (!window._formDirty) return;
const a = e.target.closest('a[href]');
if (!a) return;
const href = a.getAttribute('href');
if (!href || href.startsWith('#') || href.startsWith('javascript:')) return;
e.preventDefault();
e.stopPropagation();
_pendingNav = a.href;
_getModal().show();
}, true);
// ブラウザの戻る・リロード
window.addEventListener('beforeunload', e => {
if (!window._formDirty) return;
e.preventDefault();
e.returnValue = '';
});
})();
if ('serviceWorker' in navigator) {
navigator.serviceWorker.register('/sw.js').catch(() => {});
}
// ── ホーム画面に追加バナー ──────────────────────────
(() => {
const KEY = 'pwaInstallDismissedUntil';
const banner = document.getElementById('pwa-install-banner');
const desc = document.getElementById('pwa-install-desc');
const actionBtn = document.getElementById('pwa-install-action');
const closeBtn = document.getElementById('pwa-install-close');
if (!banner) return;
// 既にホーム画面から起動している場合は表示しない
const isStandalone = window.matchMedia('(display-mode: standalone)').matches
|| window.navigator.standalone === true;
if (isStandalone) return;
// 閉じてから14日以内は再表示しない
const dismissedUntil = Number(localStorage.getItem(KEY) || 0);
if (Date.now() < dismissedUntil) return;
const DISMISS_MS = 14 * 24 * 60 * 60 * 1000;
const show = () => banner.classList.add('show');
const hide = () => banner.classList.remove('show');
const isIOS = /iphone|ipad|ipod/i.test(navigator.userAgent);
let deferredPrompt = null;
if (isIOS) {
// iOS Safariはbeforeinstallpromptに対応していないため案内文のみ表示
desc.textContent = '共有ボタン →「ホーム画面に追加」';
show();
} else {
window.addEventListener('beforeinstallprompt', e => {
e.preventDefault();
deferredPrompt = e;
actionBtn.classList.remove('d-none');
show();
});
}
actionBtn.addEventListener('click', async () => {
if (!deferredPrompt) return;
hide();
await deferredPrompt.prompt();
deferredPrompt = null;
});
closeBtn.addEventListener('click', () => {
hide();
localStorage.setItem(KEY, String(Date.now() + DISMISS_MS));
});
window.addEventListener('appinstalled', () => {
hide();
localStorage.setItem(KEY, String(Date.now() + DISMISS_MS));
});
})();
</script>
{% block scripts %}{% endblock %}
</body>
</html>