m1m02530125 Claude Sonnet 4.6 commited on
Commit
4e49a00
·
1 Parent(s): d8d8da2

UI/UX improvements: archive label, nav size, toast timing, empty states, note feedback, unsaved warning

Browse files

- employees: 削除→アーカイブ with icon + restore message in confirm dialog
- base: bottom nav height 60→68px, icon 22→24px, font 10→11px (Apple HIG 44px tap target)
- base: toast auto-dismiss 4s→5-7s (proportional to text length)
- schedule: empty state alert when no employees in current filter
- schedule: note save feedback (green flash on success, red on error)
- shifts: unsaved changes warning before prev/next navigation
- shifts: button text 全員表示→全員一覧 for clarity

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

templates/base.html CHANGED
@@ -13,7 +13,7 @@
13
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.css">
14
  <style>
15
  :root {
16
- --nav-h: 60px;
17
  --safe-bottom: env(safe-area-inset-bottom, 0px);
18
  }
19
  body { padding-bottom: calc(var(--nav-h) + var(--safe-bottom)); background: #f8fafc; }
@@ -27,10 +27,11 @@
27
  .bottom-nav a {
28
  flex: 1; display: flex; flex-direction: column; align-items: center;
29
  justify-content: center; color: #94a3b8; text-decoration: none;
30
- font-size: 10px; gap: 2px; transition: color .15s;
 
31
  }
32
  .bottom-nav a.active, .bottom-nav a:hover { color: #38bdf8; }
33
- .bottom-nav a i { font-size: 22px; }
34
  .page-header {
35
  background: #1e293b; color: white;
36
  padding: .75rem 1rem; position: sticky; top: 0; z-index: 100;
@@ -122,7 +123,10 @@
122
  <script>
123
  // Auto-dismiss toasts
124
  document.querySelectorAll('.toast').forEach(t => {
125
- setTimeout(() => { bootstrap.Toast.getOrCreateInstance(t).hide(); }, 4000);
 
 
 
126
  });
127
  // PWA service worker
128
  if ('serviceWorker' in navigator) {
 
13
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.css">
14
  <style>
15
  :root {
16
+ --nav-h: 68px;
17
  --safe-bottom: env(safe-area-inset-bottom, 0px);
18
  }
19
  body { padding-bottom: calc(var(--nav-h) + var(--safe-bottom)); background: #f8fafc; }
 
27
  .bottom-nav a {
28
  flex: 1; display: flex; flex-direction: column; align-items: center;
29
  justify-content: center; color: #94a3b8; text-decoration: none;
30
+ font-size: 11px; gap: 3px; transition: color .15s;
31
+ min-height: 44px; /* Apple HIG: 最小タップ領域 */
32
  }
33
  .bottom-nav a.active, .bottom-nav a:hover { color: #38bdf8; }
34
+ .bottom-nav a i { font-size: 24px; }
35
  .page-header {
36
  background: #1e293b; color: white;
37
  padding: .75rem 1rem; position: sticky; top: 0; z-index: 100;
 
123
  <script>
124
  // Auto-dismiss toasts
125
  document.querySelectorAll('.toast').forEach(t => {
126
+ // 文字数に応じて表示時間を調整(最低5秒、長いメッセージは7秒)
127
+ const len = t.querySelector('.toast-body')?.textContent.length || 0;
128
+ const delay = Math.min(7000, Math.max(5000, len * 50));
129
+ setTimeout(() => { bootstrap.Toast.getOrCreateInstance(t).hide(); }, delay);
130
  });
131
  // PWA service worker
132
  if ('serviceWorker' in navigator) {
templates/employees/index.html CHANGED
@@ -36,8 +36,11 @@
36
  <div class="d-flex gap-1">
37
  <a href="{{ url_for('employees.edit', emp_id=emp.id) }}" class="btn btn-outline-primary btn-sm">編集</a>
38
  {% if emp.is_active %}
39
- <form method="post" action="{{ url_for('employees.archive', emp_id=emp.id) }}" onsubmit="return confirm('アーカイブしますか?')">
40
- <button class="btn btn-outline-danger btn-sm">削除</button>
 
 
 
41
  </form>
42
  {% else %}
43
  <form method="post" action="{{ url_for('employees.restore', emp_id=emp.id) }}">
 
36
  <div class="d-flex gap-1">
37
  <a href="{{ url_for('employees.edit', emp_id=emp.id) }}" class="btn btn-outline-primary btn-sm">編集</a>
38
  {% if emp.is_active %}
39
+ <form method="post" action="{{ url_for('employees.archive', emp_id=emp.id) }}"
40
+ onsubmit="return confirm('{{ emp.name }} をアーカイブしますか?\n(後から復元できます)')">
41
+ <button class="btn btn-outline-secondary btn-sm">
42
+ <i class="bi bi-archive me-1"></i>アーカイブ
43
+ </button>
44
  </form>
45
  {% else %}
46
  <form method="post" action="{{ url_for('employees.restore', emp_id=emp.id) }}">
templates/schedule/index.html CHANGED
@@ -86,6 +86,14 @@
86
  {% endif %}
87
  </div>
88
 
 
 
 
 
 
 
 
 
89
  <!-- シフトグリッド -->
90
  <div class="sched-grid">
91
  <table class="table table-bordered table-sm mb-0">
@@ -168,16 +176,26 @@ function editNote(el) {
168
  el.replaceWith(input); input.focus();
169
  function save() {
170
  const note = input.value.trim();
171
- fetch(`/schedule/${periodId}/note`, {
172
- method:'POST', headers:{'Content-Type':'application/json'},
173
- body:JSON.stringify({date, note})
174
- });
175
  const span = document.createElement('span');
176
  span.className = 'note-cell d-block small text-muted';
177
  span.style.cssText = 'cursor:pointer;min-height:18px';
178
- span.dataset.date = date; span.dataset.period = periodId;
 
179
  span.onclick = function(){ editNote(this); };
180
- span.textContent = note; input.replaceWith(span);
 
 
 
 
 
 
 
 
 
 
 
 
 
181
  }
182
  input.addEventListener('blur', save);
183
  input.addEventListener('keydown', e => { if(e.key==='Enter') input.blur(); });
 
86
  {% endif %}
87
  </div>
88
 
89
+ {% if not employees %}
90
+ <div class="alert alert-info mx-0 mb-3">
91
+ <i class="bi bi-info-circle me-2"></i>
92
+ 表示するスタッフがいません。
93
+ <a href="{{ url_for('employees.index') }}" class="alert-link">スタッフ管理</a>からスタッフを登録してください。
94
+ </div>
95
+ {% endif %}
96
+
97
  <!-- シフトグリッド -->
98
  <div class="sched-grid">
99
  <table class="table table-bordered table-sm mb-0">
 
176
  el.replaceWith(input); input.focus();
177
  function save() {
178
  const note = input.value.trim();
 
 
 
 
179
  const span = document.createElement('span');
180
  span.className = 'note-cell d-block small text-muted';
181
  span.style.cssText = 'cursor:pointer;min-height:18px';
182
+ span.dataset.date = date;
183
+ span.dataset.period = periodId;
184
  span.onclick = function(){ editNote(this); };
185
+ span.textContent = note;
186
+ input.replaceWith(span);
187
+ fetch(`/schedule/${periodId}/note`, {
188
+ method: 'POST',
189
+ headers: {'Content-Type': 'application/json'},
190
+ body: JSON.stringify({date, note})
191
+ }).then(() => {
192
+ span.style.transition = 'background .15s';
193
+ span.style.background = '#bbf7d0';
194
+ setTimeout(() => { span.style.background = ''; }, 800);
195
+ }).catch(() => {
196
+ span.style.background = '#fecaca';
197
+ setTimeout(() => { span.style.background = ''; }, 1500);
198
+ });
199
  }
200
  input.addEventListener('blur', save);
201
  input.addEventListener('keydown', e => { if(e.key==='Enter') input.blur(); });
templates/shifts/input.html CHANGED
@@ -49,7 +49,7 @@
49
  {% else %}
50
  <a href="{{ url_for('shifts.input', period_id=period.id, grid=1) }}"
51
  class="btn btn-outline-light btn-sm">
52
- <i class="bi bi-table me-1"></i>全員表示
53
  </a>
54
  {% endif %}
55
  </div>
@@ -294,6 +294,24 @@ function toggleCustom(sel, key) {
294
  if (div) div.style.display = sel.value === 'custom' ? 'flex' : 'none';
295
  }
296
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
297
  function applyBulk(empId) {
298
  const pattern = document.getElementById('bulk-pattern').value;
299
  document.querySelectorAll(`select[name^="pattern_${empId}_"]`).forEach(sel => {
 
49
  {% else %}
50
  <a href="{{ url_for('shifts.input', period_id=period.id, grid=1) }}"
51
  class="btn btn-outline-light btn-sm">
52
+ <i class="bi bi-table me-1"></i>全員一覧
53
  </a>
54
  {% endif %}
55
  </div>
 
294
  if (div) div.style.display = sel.value === 'custom' ? 'flex' : 'none';
295
  }
296
 
297
+ // 未保存変更の検知
298
+ let _changed = false;
299
+ document.querySelectorAll('select.pattern-sel, input[type=time]').forEach(el => {
300
+ el.addEventListener('change', () => { _changed = true; });
301
+ });
302
+ document.getElementById('shift-form')?.addEventListener('submit', () => { _changed = false; });
303
+
304
+ // 前後ナビゲーション時に未保存なら確認
305
+ document.querySelectorAll('a[href*="emp_idx"]').forEach(a => {
306
+ if (!a.href.includes('grid=')) {
307
+ a.addEventListener('click', e => {
308
+ if (_changed && !confirm('変更が保存されていません。移動しますか?')) {
309
+ e.preventDefault();
310
+ }
311
+ });
312
+ }
313
+ });
314
+
315
  function applyBulk(empId) {
316
  const pattern = document.getElementById('bulk-pattern').value;
317
  document.querySelectorAll(`select[name^="pattern_${empId}_"]`).forEach(sel => {