m1m02530125 Claude Sonnet 4.6 commited on
Commit
68bcd4b
·
1 Parent(s): a35f028

improve: simplify employee form - position in basic info, dynamic skills

Browse files

- Move 所属ポジション to basic info section as a 3-button toggle
(ホール / キッチン / 両方) with visual card styling
- Show/hide skill dropdowns dynamically:
ホール → ホール習熟度 only
キッチン → キッチン習熟度 only
両方 → both skills shown
- Remove 所属ポジション and 兼務可チェックボックス from 勤務設定
- can_work_both_positions now auto-derived: True when position is empty (両方)
- Route: handle missing skill field gracefully (default to "novice")

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

routes/employees.py CHANGED
@@ -101,16 +101,18 @@ def _form_to_employee(emp_id):
101
 
102
  pp_val = f.get("primary_position") or None
103
  pt_val = f.get("primary_timeslot") or None
 
 
104
 
105
  return Employee(
106
  id=emp_id,
107
  name=f["name"].strip(),
108
  employment_type=EmploymentType(f["employment_type"]),
109
- hall_skill=SkillLevel(f["hall_skill"]),
110
- kitchen_skill=SkillLevel(f["kitchen_skill"]),
111
  primary_position=PrimaryPosition(pp_val) if pp_val else None,
112
  primary_timeslot=TimeSlot(pt_val) if pt_val else None,
113
- can_work_both_positions=bool(f.get("can_work_both_positions")),
114
  can_open=bool(f.get("can_open")),
115
  can_cleanup=bool(f.get("can_cleanup")),
116
  always_available_breakfast=bool(f.get("always_available_breakfast")),
 
101
 
102
  pp_val = f.get("primary_position") or None
103
  pt_val = f.get("primary_timeslot") or None
104
+ # 所属ポジションが「どちらでも」の場合は兼務可を自動でTrue
105
+ can_work_both = (pp_val is None)
106
 
107
  return Employee(
108
  id=emp_id,
109
  name=f["name"].strip(),
110
  employment_type=EmploymentType(f["employment_type"]),
111
+ hall_skill=SkillLevel(f.get("hall_skill") or "novice"),
112
+ kitchen_skill=SkillLevel(f.get("kitchen_skill") or "novice"),
113
  primary_position=PrimaryPosition(pp_val) if pp_val else None,
114
  primary_timeslot=TimeSlot(pt_val) if pt_val else None,
115
+ can_work_both_positions=can_work_both,
116
  can_open=bool(f.get("can_open")),
117
  can_cleanup=bool(f.get("can_cleanup")),
118
  always_available_breakfast=bool(f.get("always_available_breakfast")),
templates/employees/form.html CHANGED
@@ -1,5 +1,22 @@
1
  {% extends "base.html" %}
2
  {% block title %}{{ '従業員編集' if emp else '新規登録' }} - SDU-Shift{% endblock %}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  {% block content %}
4
  <div class="page-header">
5
  <a href="{{ url_for('employees.index') }}" class="text-white me-2"><i class="bi bi-arrow-left"></i></a>
@@ -8,6 +25,7 @@
8
 
9
  <div class="content">
10
  <form method="post">
 
11
  <!-- 基本情報 -->
12
  <div class="card mb-3">
13
  <div class="card-body">
@@ -15,7 +33,8 @@
15
 
16
  <div class="mb-3">
17
  <label class="form-label fw-semibold">氏名 <span class="text-danger">*</span></label>
18
- <input type="text" name="name" class="form-control" value="{{ emp.name if emp else '' }}" required>
 
19
  </div>
20
 
21
  <div class="mb-3">
@@ -29,8 +48,36 @@
29
  </select>
30
  </div>
31
 
32
- <div class="row g-3">
33
- <div class="col-6">
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
34
  <label class="form-label fw-semibold">ホール習熟度</label>
35
  <select name="hall_skill" class="form-select">
36
  {% for sl in skill_levels %}
@@ -40,7 +87,7 @@
40
  {% endfor %}
41
  </select>
42
  </div>
43
- <div class="col-6">
44
  <label class="form-label fw-semibold">キッチン習熟度</label>
45
  <select name="kitchen_skill" class="form-select">
46
  {% for sl in skill_levels %}
@@ -59,18 +106,6 @@
59
  <div class="card-body">
60
  <h6 class="card-title text-muted mb-3">勤務設定</h6>
61
 
62
- <div class="mb-3">
63
- <label class="form-label fw-semibold">所属ポジション</label>
64
- <select name="primary_position" class="form-select">
65
- <option value="">どちらでも</option>
66
- {% for pp in primary_positions %}
67
- <option value="{{ pp.value }}" {{ 'selected' if emp and emp.primary_position == pp else '' }}>
68
- {{ pp.label() }}
69
- </option>
70
- {% endfor %}
71
- </select>
72
- </div>
73
-
74
  <div class="mb-3">
75
  <label class="form-label fw-semibold">勤務時間帯</label>
76
  <select name="primary_timeslot" class="form-select">
@@ -84,11 +119,6 @@
84
  </div>
85
 
86
  <div class="d-flex flex-column gap-2">
87
- <div class="form-check">
88
- <input class="form-check-input" type="checkbox" name="can_work_both_positions" id="cwbp"
89
- {{ 'checked' if emp and emp.can_work_both_positions else '' }}>
90
- <label class="form-check-label" for="cwbp">兼務可(主所属外ポジション対応可)</label>
91
- </div>
92
  <div class="form-check">
93
  <input class="form-check-input" type="checkbox" name="can_open" id="co"
94
  {{ 'checked' if emp and emp.can_open else '' }}>
@@ -113,7 +143,7 @@
113
  </div>
114
  </div>
115
 
116
- <!-- 固定パターン(アルバイトのみ有意) -->
117
  <div class="card mb-3">
118
  <div class="card-body">
119
  <h6 class="card-title text-muted mb-3">固定シフトパターン(アルバイト)</h6>
@@ -129,19 +159,15 @@
129
  <tr>
130
  <td class="fw-semibold">朝食</td>
131
  {% for i in range(7) %}
132
- <td>
133
- <input type="checkbox" name="fp_b_{{ i }}"
134
- {{ 'checked' if emp and emp.get_pattern(i) and emp.get_pattern(i).breakfast else '' }}>
135
- </td>
136
  {% endfor %}
137
  </tr>
138
  <tr>
139
  <td class="fw-semibold">ディナー</td>
140
  {% for i in range(7) %}
141
- <td>
142
- <input type="checkbox" name="fp_d_{{ i }}"
143
- {{ 'checked' if emp and emp.get_pattern(i) and emp.get_pattern(i).dinner else '' }}>
144
- </td>
145
  {% endfor %}
146
  </tr>
147
  </tbody>
@@ -153,7 +179,7 @@
153
  <!-- 固定不可日 -->
154
  <div class="card mb-3">
155
  <div class="card-body">
156
- <h6 class="card-title text-muted mb-3">固定不可日(毎年/毎月ではなく特定の日付)</h6>
157
  <div id="unavail-list" class="d-flex flex-wrap gap-2 mb-2">
158
  {% for d in (emp.fixed_unavailable_dates if emp else []) %}
159
  <div class="badge bg-secondary d-flex align-items-center gap-1 unavail-badge" style="font-size:.85rem">
@@ -174,15 +200,34 @@
174
  </div>
175
 
176
  <div class="d-grid gap-2">
177
- <button type="submit" class="btn btn-primary btn-lg">
178
  <i class="bi bi-check-lg me-1"></i>{{ '更新する' if emp else '登録する' }}
179
  </button>
180
  <a href="{{ url_for('employees.index') }}" class="btn btn-outline-secondary">キャンセル</a>
181
  </div>
182
  </form>
183
  </div>
 
184
 
 
185
  <script>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
186
  function addUnavailDate() {
187
  const input = document.getElementById('new-unavail-date');
188
  const val = input.value;
 
1
  {% extends "base.html" %}
2
  {% block title %}{{ '従業員編集' if emp else '新規登録' }} - SDU-Shift{% endblock %}
3
+
4
+ {% block head %}
5
+ <style>
6
+ .pos-btn {
7
+ display: flex; flex-direction: column; align-items: center; justify-content: center;
8
+ padding: .7rem .5rem; border: 1.5px solid #e2e8f0;
9
+ border-radius: 10px; cursor: pointer; font-size: .85rem; font-weight: 500;
10
+ color: #64748b; transition: all .15s; user-select: none;
11
+ background: white; min-height: 70px;
12
+ }
13
+ .pos-btn:hover { border-color: #94a3b8; color: #1e293b; background: #f8fafc; }
14
+ .pos-btn.selected { border-color: #0ea5e9; background: #f0f9ff; color: #0284c7; font-weight: 600; }
15
+ .pos-btn.pos-hall.selected { border-color: #1d4ed8; background: #eff6ff; color: #1d4ed8; }
16
+ .pos-btn.pos-kitchen.selected { border-color: #15803d; background: #f0fdf4; color: #15803d; }
17
+ </style>
18
+ {% endblock %}
19
+
20
  {% block content %}
21
  <div class="page-header">
22
  <a href="{{ url_for('employees.index') }}" class="text-white me-2"><i class="bi bi-arrow-left"></i></a>
 
25
 
26
  <div class="content">
27
  <form method="post">
28
+
29
  <!-- 基本情報 -->
30
  <div class="card mb-3">
31
  <div class="card-body">
 
33
 
34
  <div class="mb-3">
35
  <label class="form-label fw-semibold">氏名 <span class="text-danger">*</span></label>
36
+ <input type="text" name="name" class="form-control"
37
+ value="{{ emp.name if emp else '' }}" required>
38
  </div>
39
 
40
  <div class="mb-3">
 
48
  </select>
49
  </div>
50
 
51
+ <!-- 所属ポジション -->
52
+ <div class="mb-3">
53
+ <label class="form-label fw-semibold">所属ポジション</label>
54
+ {% set cur_pos = emp.primary_position.value if emp and emp.primary_position else '' %}
55
+ <div class="d-flex gap-2">
56
+ <label class="pos-btn pos-hall flex-grow-1 text-center" id="pos-hall-label">
57
+ <input type="radio" name="primary_position" value="hall" class="d-none"
58
+ {{ 'checked' if cur_pos == 'hall' else '' }}
59
+ onchange="onPositionChange()">
60
+ <i class="bi bi-people-fill d-block mb-1" style="font-size:1.3rem"></i>ホール
61
+ </label>
62
+ <label class="pos-btn pos-kitchen flex-grow-1 text-center" id="pos-kitchen-label">
63
+ <input type="radio" name="primary_position" value="kitchen" class="d-none"
64
+ {{ 'checked' if cur_pos == 'kitchen' else '' }}
65
+ onchange="onPositionChange()">
66
+ <i class="bi bi-egg-fried d-block mb-1" style="font-size:1.3rem"></i>キッチン
67
+ </label>
68
+ <label class="pos-btn flex-grow-1 text-center" id="pos-both-label">
69
+ <input type="radio" name="primary_position" value="" class="d-none"
70
+ {{ 'checked' if cur_pos == '' else '' }}
71
+ onchange="onPositionChange()">
72
+ <i class="bi bi-shuffle d-block mb-1" style="font-size:1.3rem"></i>両方
73
+ </label>
74
+ </div>
75
+ <div class="form-text">「両方」を選ぶとホール・キッチンどちらにも配置できます</div>
76
+ </div>
77
+
78
+ <!-- 習熟度(ポジションに応じて表示切替) -->
79
+ <div class="row g-3" id="skill-row">
80
+ <div class="col" id="hall-skill-block">
81
  <label class="form-label fw-semibold">ホール習熟度</label>
82
  <select name="hall_skill" class="form-select">
83
  {% for sl in skill_levels %}
 
87
  {% endfor %}
88
  </select>
89
  </div>
90
+ <div class="col" id="kitchen-skill-block">
91
  <label class="form-label fw-semibold">キッチン習熟度</label>
92
  <select name="kitchen_skill" class="form-select">
93
  {% for sl in skill_levels %}
 
106
  <div class="card-body">
107
  <h6 class="card-title text-muted mb-3">勤務設定</h6>
108
 
 
 
 
 
 
 
 
 
 
 
 
 
109
  <div class="mb-3">
110
  <label class="form-label fw-semibold">勤務時間帯</label>
111
  <select name="primary_timeslot" class="form-select">
 
119
  </div>
120
 
121
  <div class="d-flex flex-column gap-2">
 
 
 
 
 
122
  <div class="form-check">
123
  <input class="form-check-input" type="checkbox" name="can_open" id="co"
124
  {{ 'checked' if emp and emp.can_open else '' }}>
 
143
  </div>
144
  </div>
145
 
146
+ <!-- 固定シフトパターン -->
147
  <div class="card mb-3">
148
  <div class="card-body">
149
  <h6 class="card-title text-muted mb-3">固定シフトパターン(アルバイト)</h6>
 
159
  <tr>
160
  <td class="fw-semibold">朝食</td>
161
  {% for i in range(7) %}
162
+ <td><input type="checkbox" name="fp_b_{{ i }}"
163
+ {{ 'checked' if emp and emp.get_pattern(i) and emp.get_pattern(i).breakfast else '' }}></td>
 
 
164
  {% endfor %}
165
  </tr>
166
  <tr>
167
  <td class="fw-semibold">ディナー</td>
168
  {% for i in range(7) %}
169
+ <td><input type="checkbox" name="fp_d_{{ i }}"
170
+ {{ 'checked' if emp and emp.get_pattern(i) and emp.get_pattern(i).dinner else '' }}></td>
 
 
171
  {% endfor %}
172
  </tr>
173
  </tbody>
 
179
  <!-- 固定不可日 -->
180
  <div class="card mb-3">
181
  <div class="card-body">
182
+ <h6 class="card-title text-muted mb-3">固定不可日</h6>
183
  <div id="unavail-list" class="d-flex flex-wrap gap-2 mb-2">
184
  {% for d in (emp.fixed_unavailable_dates if emp else []) %}
185
  <div class="badge bg-secondary d-flex align-items-center gap-1 unavail-badge" style="font-size:.85rem">
 
200
  </div>
201
 
202
  <div class="d-grid gap-2">
203
+ <button type="submit" class="btn btn-primary btn-lg" data-loading="保存中…">
204
  <i class="bi bi-check-lg me-1"></i>{{ '更新する' if emp else '登録する' }}
205
  </button>
206
  <a href="{{ url_for('employees.index') }}" class="btn btn-outline-secondary">キャンセル</a>
207
  </div>
208
  </form>
209
  </div>
210
+ {% endblock %}
211
 
212
+ {% block scripts %}
213
  <script>
214
+ function onPositionChange() {
215
+ const checked = document.querySelector('input[name="primary_position"]:checked');
216
+ const pos = checked ? checked.value : '';
217
+
218
+ document.getElementById('hall-skill-block').style.display = (pos === 'kitchen') ? 'none' : '';
219
+ document.getElementById('kitchen-skill-block').style.display = (pos === 'hall') ? 'none' : '';
220
+
221
+ ['pos-hall-label','pos-kitchen-label','pos-both-label'].forEach(id => {
222
+ document.getElementById(id).classList.remove('selected');
223
+ });
224
+ if (pos === 'hall') document.getElementById('pos-hall-label').classList.add('selected');
225
+ else if (pos === 'kitchen') document.getElementById('pos-kitchen-label').classList.add('selected');
226
+ else document.getElementById('pos-both-label').classList.add('selected');
227
+ }
228
+
229
+ onPositionChange();
230
+
231
  function addUnavailDate() {
232
  const input = document.getElementById('new-unavail-date');
233
  const val = input.value;