improve: fix 8 UI/UX issues across the app
Browse files1. Toast: mobile bottom-center above bottom nav (was top-right, hard to see)
2. Form loading: global data-loading attribute spins submit buttons
3. Schedule header: shows current period dates as subtitle
4. Customers header: shows current period dates as subtitle
5. Schedule: scroll position saved to sessionStorage before reload,
restored on return; auto-scrolls to today column if no saved scroll
6. Schedule: assign error uses in-page toast instead of browser alert()
7. Employees: archive confirm() replaced with dark Bootstrap modal
8. Shifts input: unsaved-changes confirm() replaced with dark Bootstrap modal
+ save button has loading spinner
+ empty state shows contextual message with CTA button
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- templates/base.html +26 -1
- templates/customers/index.html +10 -2
- templates/employees/index.html +47 -9
- templates/schedule/index.html +44 -2
- templates/shifts/input.html +28 -3
|
@@ -93,7 +93,20 @@
|
|
| 93 |
.btn-primary:hover { background: #0284c7; border-color: #0284c7; }
|
| 94 |
.badge-hall { background: #dbeafe; color: #1d4ed8; }
|
| 95 |
.badge-kitchen { background: #dcfce7; color: #15803d; }
|
| 96 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 97 |
|
| 98 |
/* ── デスクトップサイドバー ────────────────────────── */
|
| 99 |
.sidebar { display: none; }
|
|
@@ -260,6 +273,18 @@
|
|
| 260 |
setTimeout(() => { bootstrap.Toast.getOrCreateInstance(t).hide(); }, delay);
|
| 261 |
});
|
| 262 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 263 |
// ── PWA service worker ────────────────────────────────
|
| 264 |
if ('serviceWorker' in navigator) {
|
| 265 |
navigator.serviceWorker.register('/static/sw.js').catch(() => {});
|
|
|
|
| 93 |
.btn-primary:hover { background: #0284c7; border-color: #0284c7; }
|
| 94 |
.badge-hall { background: #dbeafe; color: #1d4ed8; }
|
| 95 |
.badge-kitchen { background: #dcfce7; color: #15803d; }
|
| 96 |
+
/* トースト:PC は右上、モバイルはボトムナビの上中央 */
|
| 97 |
+
.toast-container {
|
| 98 |
+
position: fixed; top: 1rem; right: 1rem; z-index: 9999;
|
| 99 |
+
}
|
| 100 |
+
@media (max-width: 767px) {
|
| 101 |
+
.toast-container {
|
| 102 |
+
top: auto; right: auto; left: 50%;
|
| 103 |
+
bottom: calc(var(--nav-h) + var(--safe-bottom) + .75rem);
|
| 104 |
+
transform: translateX(-50%);
|
| 105 |
+
min-width: min(320px, 90vw);
|
| 106 |
+
}
|
| 107 |
+
}
|
| 108 |
+
/* ローディングボタン */
|
| 109 |
+
.btn-loading { pointer-events: none; opacity: .75; }
|
| 110 |
|
| 111 |
/* ── デスクトップサイドバー ────────────────────────── */
|
| 112 |
.sidebar { display: none; }
|
|
|
|
| 273 |
setTimeout(() => { bootstrap.Toast.getOrCreateInstance(t).hide(); }, delay);
|
| 274 |
});
|
| 275 |
|
| 276 |
+
// ── フォーム送信ボタンのローディング状態 ─────────────
|
| 277 |
+
document.querySelectorAll('[data-loading]').forEach(btn => {
|
| 278 |
+
const form = btn.form || btn.closest('form');
|
| 279 |
+
if (form) form.addEventListener('submit', () => {
|
| 280 |
+
btn.disabled = true;
|
| 281 |
+
btn.classList.add('btn-loading');
|
| 282 |
+
const orig = btn.innerHTML;
|
| 283 |
+
btn.innerHTML = '<span class="spinner-border spinner-border-sm me-1"></span>'
|
| 284 |
+
+ (btn.dataset.loading || '処理中…');
|
| 285 |
+
});
|
| 286 |
+
});
|
| 287 |
+
|
| 288 |
// ── PWA service worker ────────────────────────────────
|
| 289 |
if ('serviceWorker' in navigator) {
|
| 290 |
navigator.serviceWorker.register('/static/sw.js').catch(() => {});
|
|
@@ -2,8 +2,16 @@
|
|
| 2 |
{% block title %}客数管理 - SDU-Shift{% endblock %}
|
| 3 |
{% block content %}
|
| 4 |
<div class="page-header">
|
| 5 |
-
<
|
| 6 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
<i class="bi bi-floppy-fill"></i> 保存
|
| 8 |
</button>
|
| 9 |
</div>
|
|
|
|
| 2 |
{% block title %}客数管理 - SDU-Shift{% endblock %}
|
| 3 |
{% block content %}
|
| 4 |
<div class="page-header">
|
| 5 |
+
<div>
|
| 6 |
+
<div class="fw-semibold"><i class="bi bi-cup-hot-fill me-2"></i>客数管理</div>
|
| 7 |
+
{% if period %}
|
| 8 |
+
<div style="font-size:.72rem;color:#94a3b8;line-height:1.2">
|
| 9 |
+
{{ period.start_date }} 〜 {{ period.end_date }}
|
| 10 |
+
</div>
|
| 11 |
+
{% endif %}
|
| 12 |
+
</div>
|
| 13 |
+
<button form="cust-form" type="submit" class="btn btn-primary btn-sm ms-auto"
|
| 14 |
+
data-loading="保存中…">
|
| 15 |
<i class="bi bi-floppy-fill"></i> 保存
|
| 16 |
</button>
|
| 17 |
</div>
|
|
@@ -50,12 +50,10 @@
|
|
| 50 |
<div class="d-flex gap-1">
|
| 51 |
<a href="{{ url_for('employees.edit', emp_id=emp.id) }}" class="btn btn-outline-primary btn-sm">編集</a>
|
| 52 |
{% if emp.is_active %}
|
| 53 |
-
<
|
| 54 |
-
|
| 55 |
-
<
|
| 56 |
-
|
| 57 |
-
</button>
|
| 58 |
-
</form>
|
| 59 |
{% else %}
|
| 60 |
<form method="post" action="{{ url_for('employees.restore', emp_id=emp.id) }}">
|
| 61 |
<button class="btn btn-outline-success btn-sm">復元</button>
|
|
@@ -66,9 +64,18 @@
|
|
| 66 |
</div>
|
| 67 |
</div>
|
| 68 |
{% else %}
|
| 69 |
-
<div class="text-center
|
| 70 |
-
<i class="bi bi-people fs-1 d-block mb-2"></i>
|
| 71 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 72 |
</div>
|
| 73 |
{% endfor %}
|
| 74 |
</div>
|
|
@@ -80,6 +87,30 @@
|
|
| 80 |
</div>
|
| 81 |
{% endblock %}
|
| 82 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 83 |
{% block scripts %}
|
| 84 |
{% if not show_archive and not q %}
|
| 85 |
<script src="https://cdn.jsdelivr.net/npm/sortablejs@1.15.2/Sortable.min.js"></script>
|
|
@@ -112,4 +143,11 @@ function saveOrder() {
|
|
| 112 |
}
|
| 113 |
</script>
|
| 114 |
{% endif %}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 115 |
{% endblock %}
|
|
|
|
| 50 |
<div class="d-flex gap-1">
|
| 51 |
<a href="{{ url_for('employees.edit', emp_id=emp.id) }}" class="btn btn-outline-primary btn-sm">編集</a>
|
| 52 |
{% if emp.is_active %}
|
| 53 |
+
<button class="btn btn-outline-secondary btn-sm"
|
| 54 |
+
onclick="openArchiveModal('{{ url_for('employees.archive', emp_id=emp.id) }}', '{{ emp.name }}')">
|
| 55 |
+
<i class="bi bi-archive me-1"></i>アーカイブ
|
| 56 |
+
</button>
|
|
|
|
|
|
|
| 57 |
{% else %}
|
| 58 |
<form method="post" action="{{ url_for('employees.restore', emp_id=emp.id) }}">
|
| 59 |
<button class="btn btn-outline-success btn-sm">復元</button>
|
|
|
|
| 64 |
</div>
|
| 65 |
</div>
|
| 66 |
{% else %}
|
| 67 |
+
<div class="text-center py-5">
|
| 68 |
+
<i class="bi bi-people fs-1 d-block mb-2 text-muted"></i>
|
| 69 |
+
<div class="fw-semibold text-muted mb-2">
|
| 70 |
+
{% if q %}「{{ q }}」に一致するスタッフが見つかりません
|
| 71 |
+
{% elif show_archive %}アーカイブされたスタッフはいません
|
| 72 |
+
{% else %}スタッフが登録されていません{% endif %}
|
| 73 |
+
</div>
|
| 74 |
+
{% if not q and not show_archive %}
|
| 75 |
+
<a href="{{ url_for('employees.new') }}" class="btn btn-primary btn-sm">
|
| 76 |
+
<i class="bi bi-plus-lg me-1"></i>最初のスタッフを登録する
|
| 77 |
+
</a>
|
| 78 |
+
{% endif %}
|
| 79 |
</div>
|
| 80 |
{% endfor %}
|
| 81 |
</div>
|
|
|
|
| 87 |
</div>
|
| 88 |
{% endblock %}
|
| 89 |
|
| 90 |
+
<!-- アーカイブ確認モーダル -->
|
| 91 |
+
<div class="modal fade" id="archiveModal" tabindex="-1">
|
| 92 |
+
<div class="modal-dialog modal-dialog-centered modal-sm">
|
| 93 |
+
<div class="modal-content" style="background:#1e293b;color:white;border:none;border-radius:14px">
|
| 94 |
+
<div class="modal-body p-4 text-center">
|
| 95 |
+
<i class="bi bi-archive-fill text-warning d-block mb-2" style="font-size:2.2rem"></i>
|
| 96 |
+
<div class="fw-semibold mb-1" id="archive-emp-name" style="font-size:1rem"></div>
|
| 97 |
+
<div style="color:#94a3b8;font-size:.85rem;margin-bottom:1.25rem">
|
| 98 |
+
をアーカイブしますか?<br>後から復元できます。
|
| 99 |
+
</div>
|
| 100 |
+
<div class="d-flex gap-2">
|
| 101 |
+
<button class="btn btn-secondary flex-grow-1" data-bs-dismiss="modal">キャンセル</button>
|
| 102 |
+
<form id="archive-form" method="post" style="flex-grow:1">
|
| 103 |
+
<button type="submit" class="btn btn-warning w-100"
|
| 104 |
+
data-loading="アーカイブ中…">
|
| 105 |
+
<i class="bi bi-archive me-1"></i>アーカイブ
|
| 106 |
+
</button>
|
| 107 |
+
</form>
|
| 108 |
+
</div>
|
| 109 |
+
</div>
|
| 110 |
+
</div>
|
| 111 |
+
</div>
|
| 112 |
+
</div>
|
| 113 |
+
|
| 114 |
{% block scripts %}
|
| 115 |
{% if not show_archive and not q %}
|
| 116 |
<script src="https://cdn.jsdelivr.net/npm/sortablejs@1.15.2/Sortable.min.js"></script>
|
|
|
|
| 143 |
}
|
| 144 |
</script>
|
| 145 |
{% endif %}
|
| 146 |
+
<script>
|
| 147 |
+
function openArchiveModal(action, name) {
|
| 148 |
+
document.getElementById('archive-emp-name').textContent = name;
|
| 149 |
+
document.getElementById('archive-form').action = action;
|
| 150 |
+
new bootstrap.Modal(document.getElementById('archiveModal')).show();
|
| 151 |
+
}
|
| 152 |
+
</script>
|
| 153 |
{% endblock %}
|
|
@@ -123,7 +123,14 @@
|
|
| 123 |
{% endblock %}
|
| 124 |
{% block content %}
|
| 125 |
<div class="page-header">
|
| 126 |
-
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 127 |
<div class="ms-auto d-flex gap-1">
|
| 128 |
{% if period %}
|
| 129 |
<a href="{{ url_for('export.excel', period_id=period.id) }}" class="btn btn-outline-light btn-sm">
|
|
@@ -424,6 +431,26 @@ const TL_ASGN = {
|
|
| 424 |
{% endfor %}
|
| 425 |
};
|
| 426 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 427 |
function toggleShortage(header) {
|
| 428 |
const body = document.getElementById('shortage-body');
|
| 429 |
const chevron = header.querySelector('.shortage-chevron');
|
|
@@ -570,15 +597,30 @@ function doRemove() {
|
|
| 570 |
|
| 571 |
function callAssign(payload) {
|
| 572 |
const periodId = {{ period.id if period else 0 }};
|
|
|
|
|
|
|
|
|
|
|
|
|
| 573 |
fetch(`/schedule/${periodId}/assign`, {
|
| 574 |
method: 'POST', headers: {'Content-Type': 'application/json'},
|
| 575 |
body: JSON.stringify(payload)
|
| 576 |
}).then(r => r.json()).then(res => {
|
| 577 |
if (res.ok) { _modal.hide(); location.reload(); }
|
| 578 |
-
else
|
| 579 |
});
|
| 580 |
}
|
| 581 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 582 |
function editNote(el) {
|
| 583 |
const date = el.dataset.date;
|
| 584 |
const periodId = el.dataset.period;
|
|
|
|
| 123 |
{% endblock %}
|
| 124 |
{% block content %}
|
| 125 |
<div class="page-header">
|
| 126 |
+
<div>
|
| 127 |
+
<div class="fs-6 fw-semibold"><i class="bi bi-calendar3 me-1"></i>シフト表</div>
|
| 128 |
+
{% if period %}
|
| 129 |
+
<div style="font-size:.72rem;color:#94a3b8;line-height:1.2">
|
| 130 |
+
{{ period.start_date }} 〜 {{ period.end_date }}
|
| 131 |
+
</div>
|
| 132 |
+
{% endif %}
|
| 133 |
+
</div>
|
| 134 |
<div class="ms-auto d-flex gap-1">
|
| 135 |
{% if period %}
|
| 136 |
<a href="{{ url_for('export.excel', period_id=period.id) }}" class="btn btn-outline-light btn-sm">
|
|
|
|
| 431 |
{% endfor %}
|
| 432 |
};
|
| 433 |
|
| 434 |
+
// スクロール復元 or 今日の列へ自動スクロール
|
| 435 |
+
(function() {
|
| 436 |
+
const grid = document.querySelector('.sched-grid');
|
| 437 |
+
if (!grid) return;
|
| 438 |
+
const saved = sessionStorage.getItem('schedScroll');
|
| 439 |
+
if (saved) {
|
| 440 |
+
const { top, left } = JSON.parse(saved);
|
| 441 |
+
grid.scrollTop = top;
|
| 442 |
+
grid.scrollLeft = left;
|
| 443 |
+
sessionStorage.removeItem('schedScroll');
|
| 444 |
+
} else {
|
| 445 |
+
const todayTh = grid.querySelector('thead th.today-col');
|
| 446 |
+
if (todayTh) {
|
| 447 |
+
// 名前列(sticky)の幅分だけ余白を引く
|
| 448 |
+
const empColW = grid.querySelector('thead th.emp-col')?.offsetWidth || 90;
|
| 449 |
+
grid.scrollLeft = Math.max(0, todayTh.offsetLeft - empColW - 8);
|
| 450 |
+
}
|
| 451 |
+
}
|
| 452 |
+
})();
|
| 453 |
+
|
| 454 |
function toggleShortage(header) {
|
| 455 |
const body = document.getElementById('shortage-body');
|
| 456 |
const chevron = header.querySelector('.shortage-chevron');
|
|
|
|
| 597 |
|
| 598 |
function callAssign(payload) {
|
| 599 |
const periodId = {{ period.id if period else 0 }};
|
| 600 |
+
// スクロール位置を保存してリロード後に復元
|
| 601 |
+
const grid = document.querySelector('.sched-grid');
|
| 602 |
+
if (grid) sessionStorage.setItem('schedScroll',
|
| 603 |
+
JSON.stringify({ top: grid.scrollTop, left: grid.scrollLeft }));
|
| 604 |
fetch(`/schedule/${periodId}/assign`, {
|
| 605 |
method: 'POST', headers: {'Content-Type': 'application/json'},
|
| 606 |
body: JSON.stringify(payload)
|
| 607 |
}).then(r => r.json()).then(res => {
|
| 608 |
if (res.ok) { _modal.hide(); location.reload(); }
|
| 609 |
+
else showToast('エラー: ' + (res.error || '不明'), 'danger');
|
| 610 |
});
|
| 611 |
}
|
| 612 |
|
| 613 |
+
function showToast(msg, type) {
|
| 614 |
+
const tc = document.querySelector('.toast-container');
|
| 615 |
+
if (!tc) return;
|
| 616 |
+
const el = document.createElement('div');
|
| 617 |
+
el.className = `toast show align-items-center text-bg-${type} border-0`;
|
| 618 |
+
el.innerHTML = `<div class="d-flex"><div class="toast-body">${msg}</div>
|
| 619 |
+
<button type="button" class="btn-close btn-close-white me-2 m-auto" data-bs-dismiss="toast"></button></div>`;
|
| 620 |
+
tc.appendChild(el);
|
| 621 |
+
setTimeout(() => bootstrap.Toast.getOrCreateInstance(el).hide(), 4000);
|
| 622 |
+
}
|
| 623 |
+
|
| 624 |
function editNote(el) {
|
| 625 |
const date = el.dataset.date;
|
| 626 |
const periodId = el.dataset.period;
|
|
@@ -43,7 +43,8 @@
|
|
| 43 |
class="btn btn-outline-light btn-sm">
|
| 44 |
<i class="bi bi-person-fill me-1"></i>1人ずつ
|
| 45 |
</a>
|
| 46 |
-
<button form="shift-form" type="submit" class="btn btn-primary btn-sm"
|
|
|
|
| 47 |
<i class="bi bi-floppy-fill"></i> 保存
|
| 48 |
</button>
|
| 49 |
{% else %}
|
|
@@ -291,8 +292,29 @@
|
|
| 291 |
{% endif %}
|
| 292 |
{% endblock %}
|
| 293 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 294 |
{% block scripts %}
|
| 295 |
<script>
|
|
|
|
|
|
|
| 296 |
function toggleCustom(sel, key) {
|
| 297 |
const div = document.getElementById('custom_' + key);
|
| 298 |
if (div) div.style.display = sel.value === 'custom' ? 'flex' : 'none';
|
|
@@ -305,12 +327,15 @@ document.querySelectorAll('select.pattern-sel, input[type=time]').forEach(el =>
|
|
| 305 |
});
|
| 306 |
document.getElementById('shift-form')?.addEventListener('submit', () => { _changed = false; });
|
| 307 |
|
| 308 |
-
// 前後ナビゲーション時に未保存なら確認
|
|
|
|
| 309 |
document.querySelectorAll('a[href*="emp_idx"]').forEach(a => {
|
| 310 |
if (!a.href.includes('grid=')) {
|
| 311 |
a.addEventListener('click', e => {
|
| 312 |
-
if (_changed
|
| 313 |
e.preventDefault();
|
|
|
|
|
|
|
| 314 |
}
|
| 315 |
});
|
| 316 |
}
|
|
|
|
| 43 |
class="btn btn-outline-light btn-sm">
|
| 44 |
<i class="bi bi-person-fill me-1"></i>1人ずつ
|
| 45 |
</a>
|
| 46 |
+
<button form="shift-form" type="submit" class="btn btn-primary btn-sm"
|
| 47 |
+
data-loading="保存中…">
|
| 48 |
<i class="bi bi-floppy-fill"></i> 保存
|
| 49 |
</button>
|
| 50 |
{% else %}
|
|
|
|
| 292 |
{% endif %}
|
| 293 |
{% endblock %}
|
| 294 |
|
| 295 |
+
<!-- 未保存変更の確認モーダル -->
|
| 296 |
+
<div class="modal fade" id="unsavedModal" tabindex="-1">
|
| 297 |
+
<div class="modal-dialog modal-dialog-centered modal-sm">
|
| 298 |
+
<div class="modal-content" style="background:#1e293b;color:white;border:none;border-radius:14px">
|
| 299 |
+
<div class="modal-body p-4 text-center">
|
| 300 |
+
<i class="bi bi-exclamation-triangle-fill text-warning d-block mb-2" style="font-size:2.2rem"></i>
|
| 301 |
+
<div class="fw-semibold mb-1" style="font-size:1rem">未保存の変更があります</div>
|
| 302 |
+
<div style="color:#94a3b8;font-size:.85rem;margin-bottom:1.25rem">
|
| 303 |
+
保存せずに移動しますか?
|
| 304 |
+
</div>
|
| 305 |
+
<div class="d-flex gap-2">
|
| 306 |
+
<button class="btn btn-secondary flex-grow-1" data-bs-dismiss="modal">戻る</button>
|
| 307 |
+
<button class="btn btn-danger flex-grow-1" onclick="proceedNav()">移動する</button>
|
| 308 |
+
</div>
|
| 309 |
+
</div>
|
| 310 |
+
</div>
|
| 311 |
+
</div>
|
| 312 |
+
</div>
|
| 313 |
+
|
| 314 |
{% block scripts %}
|
| 315 |
<script>
|
| 316 |
+
function proceedNav() { if (_pendingNav) location.href = _pendingNav; }
|
| 317 |
+
|
| 318 |
function toggleCustom(sel, key) {
|
| 319 |
const div = document.getElementById('custom_' + key);
|
| 320 |
if (div) div.style.display = sel.value === 'custom' ? 'flex' : 'none';
|
|
|
|
| 327 |
});
|
| 328 |
document.getElementById('shift-form')?.addEventListener('submit', () => { _changed = false; });
|
| 329 |
|
| 330 |
+
// 前後ナビゲーション時に未保存なら確認モーダル
|
| 331 |
+
let _pendingNav = null;
|
| 332 |
document.querySelectorAll('a[href*="emp_idx"]').forEach(a => {
|
| 333 |
if (!a.href.includes('grid=')) {
|
| 334 |
a.addEventListener('click', e => {
|
| 335 |
+
if (_changed) {
|
| 336 |
e.preventDefault();
|
| 337 |
+
_pendingNav = a.href;
|
| 338 |
+
new bootstrap.Modal(document.getElementById('unsavedModal')).show();
|
| 339 |
}
|
| 340 |
});
|
| 341 |
}
|