Commit ·
cc047dd
1
Parent(s): 11b9b70
アーカイブ後にアーカイブ一覧へ遷移・アーカイブ画面から完全削除できる機能を追加
Browse filesCo-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- db/repositories.py +8 -0
- routes/employees.py +10 -1
- templates/employees/index.html +32 -0
db/repositories.py
CHANGED
|
@@ -96,6 +96,14 @@ def delete_employee(employee_id: int):
|
|
| 96 |
cache.delete_memoized(get_all_employees)
|
| 97 |
|
| 98 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 99 |
def restore_employee(employee_id: int):
|
| 100 |
conn = get_connection()
|
| 101 |
conn.execute("UPDATE employees SET is_active=1 WHERE id=?", (employee_id,))
|
|
|
|
| 96 |
cache.delete_memoized(get_all_employees)
|
| 97 |
|
| 98 |
|
| 99 |
+
def purge_employee(employee_id: int):
|
| 100 |
+
conn = get_connection()
|
| 101 |
+
conn.execute("DELETE FROM employees WHERE id=?", (employee_id,))
|
| 102 |
+
conn.commit()
|
| 103 |
+
conn.close()
|
| 104 |
+
cache.delete_memoized(get_all_employees)
|
| 105 |
+
|
| 106 |
+
|
| 107 |
def restore_employee(employee_id: int):
|
| 108 |
conn = get_connection()
|
| 109 |
conn.execute("UPDATE employees SET is_active=1 WHERE id=?", (employee_id,))
|
routes/employees.py
CHANGED
|
@@ -80,7 +80,16 @@ def reorder():
|
|
| 80 |
def archive(emp_id):
|
| 81 |
repo.delete_employee(emp_id)
|
| 82 |
flash("アーカイブしました", "success")
|
| 83 |
-
return redirect(url_for("employees.index"))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 84 |
|
| 85 |
|
| 86 |
@bp.post("/<int:emp_id>/restore")
|
|
|
|
| 80 |
def archive(emp_id):
|
| 81 |
repo.delete_employee(emp_id)
|
| 82 |
flash("アーカイブしました", "success")
|
| 83 |
+
return redirect(url_for("employees.index") + "?archive=1")
|
| 84 |
+
|
| 85 |
+
|
| 86 |
+
@bp.post("/<int:emp_id>/purge")
|
| 87 |
+
def purge(emp_id):
|
| 88 |
+
emp = repo.get_employee(emp_id)
|
| 89 |
+
name = emp.name if emp else "スタッフ"
|
| 90 |
+
repo.purge_employee(emp_id)
|
| 91 |
+
flash(f"{name} を完全に削除しました", "success")
|
| 92 |
+
return redirect(url_for("employees.index") + "?archive=1")
|
| 93 |
|
| 94 |
|
| 95 |
@bp.post("/<int:emp_id>/restore")
|
templates/employees/index.html
CHANGED
|
@@ -62,6 +62,10 @@
|
|
| 62 |
<i class="bi bi-arrow-counterclockwise"></i><span class="d-none d-md-inline ms-1">復元</span>
|
| 63 |
</button>
|
| 64 |
</form>
|
|
|
|
|
|
|
|
|
|
|
|
|
| 65 |
{% endif %}
|
| 66 |
</div>
|
| 67 |
</div>
|
|
@@ -90,6 +94,29 @@
|
|
| 90 |
</div>
|
| 91 |
</div>
|
| 92 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 93 |
<!-- アーカイブ確認モーダル -->
|
| 94 |
<div class="modal fade" id="archiveModal" tabindex="-1">
|
| 95 |
<div class="modal-dialog modal-dialog-centered modal-sm">
|
|
@@ -151,6 +178,11 @@ function saveOrder() {
|
|
| 151 |
</script>
|
| 152 |
{% endif %}
|
| 153 |
<script>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 154 |
function openArchiveModal(action, name) {
|
| 155 |
document.getElementById('archive-emp-name').textContent = name;
|
| 156 |
document.getElementById('archive-form').action = action;
|
|
|
|
| 62 |
<i class="bi bi-arrow-counterclockwise"></i><span class="d-none d-md-inline ms-1">復元</span>
|
| 63 |
</button>
|
| 64 |
</form>
|
| 65 |
+
<button class="btn btn-outline-danger btn-sm px-2 px-md-3" title="完全削除"
|
| 66 |
+
onclick="openPurgeModal('{{ url_for('employees.purge', emp_id=emp.id) }}', '{{ emp.name }}')">
|
| 67 |
+
<i class="bi bi-trash-fill"></i><span class="d-none d-md-inline ms-1">完全削除</span>
|
| 68 |
+
</button>
|
| 69 |
{% endif %}
|
| 70 |
</div>
|
| 71 |
</div>
|
|
|
|
| 94 |
</div>
|
| 95 |
</div>
|
| 96 |
|
| 97 |
+
<!-- 完全削除確認モーダル -->
|
| 98 |
+
<div class="modal fade" id="purgeModal" tabindex="-1">
|
| 99 |
+
<div class="modal-dialog modal-dialog-centered modal-sm">
|
| 100 |
+
<div class="modal-content" style="background:#1e293b;color:white;border:none;border-radius:14px">
|
| 101 |
+
<div class="modal-body p-4 text-center">
|
| 102 |
+
<i class="bi bi-trash-fill text-danger d-block mb-2" style="font-size:2.2rem"></i>
|
| 103 |
+
<div class="fw-semibold mb-1" id="purge-emp-name" style="font-size:1rem"></div>
|
| 104 |
+
<div style="color:#94a3b8;font-size:.85rem;margin-bottom:1.25rem">
|
| 105 |
+
を完全に削除しますか?<br><span class="text-danger fw-semibold">この操作は取り消せません。</span>
|
| 106 |
+
</div>
|
| 107 |
+
<div class="d-flex gap-2">
|
| 108 |
+
<button class="btn btn-secondary flex-grow-1" data-bs-dismiss="modal">キャンセル</button>
|
| 109 |
+
<form id="purge-form" method="post" style="flex-grow:1">
|
| 110 |
+
<button type="submit" class="btn btn-danger w-100" data-loading="削除中…">
|
| 111 |
+
<i class="bi bi-trash me-1"></i>完全削除
|
| 112 |
+
</button>
|
| 113 |
+
</form>
|
| 114 |
+
</div>
|
| 115 |
+
</div>
|
| 116 |
+
</div>
|
| 117 |
+
</div>
|
| 118 |
+
</div>
|
| 119 |
+
|
| 120 |
<!-- アーカイブ確認モーダル -->
|
| 121 |
<div class="modal fade" id="archiveModal" tabindex="-1">
|
| 122 |
<div class="modal-dialog modal-dialog-centered modal-sm">
|
|
|
|
| 178 |
</script>
|
| 179 |
{% endif %}
|
| 180 |
<script>
|
| 181 |
+
function openPurgeModal(action, name) {
|
| 182 |
+
document.getElementById('purge-emp-name').textContent = name;
|
| 183 |
+
document.getElementById('purge-form').action = action;
|
| 184 |
+
new bootstrap.Modal(document.getElementById('purgeModal')).show();
|
| 185 |
+
}
|
| 186 |
function openArchiveModal(action, name) {
|
| 187 |
document.getElementById('archive-emp-name').textContent = name;
|
| 188 |
document.getElementById('archive-form').action = action;
|