CSSの最適化や内部挙動の改良

This commit is contained in:
2026-04-23 00:03:55 +09:00
parent 2f061f8bcd
commit 5ef801aae1
22 changed files with 1092 additions and 1019 deletions

View File

@@ -1,55 +1,68 @@
{{template "base" .}}
{{define "content"}}
<h1 class="mb-4"><i class="bi bi-people me-2"></i>ユーザー管理</h1>
<h1 class="mb-4"><i class="bi bi-people me-2" aria-hidden="true"></i>ユーザー管理</h1>
{{if .error}}<div class="alert alert-danger">{{.error}}</div>{{end}}
{{if .error}}<div class="alert alert-danger" role="alert">{{.error}}</div>{{end}}
{{if .users}}
<div class="table-responsive">
<table class="table table-hover">
<table class="table table-hover" aria-label="ユーザー一覧">
<thead class="table-light">
<tr>
<th>ID</th>
<th>名前</th>
<th>メールアドレス</th>
<th>ロール</th>
<th>登録日</th>
<th style="width: 200px">操作</th>
<th scope="col">ID</th>
<th scope="col">名前</th>
<th scope="col">メールアドレス</th>
<th scope="col">ロール</th>
<th scope="col">登録日</th>
<th scope="col" style="width: 200px">操作</th>
</tr>
</thead>
<tbody>
{{range .users}}
<tr {{if eq .ID $.currentUserID}}class="table-primary" {{end}}>
<tr {{if eq .ID $.currentUserID}}class="table-primary"{{end}}>
<td>{{.ID}}</td>
<td>{{.Name}}{{if eq .ID $.currentUserID}}<span class="badge bg-info ms-2">自分</span>{{end}}</td>
<td>{{.Email}}</td>
<td>{{if eq .Role "admin"}}<span class="badge bg-danger">管理者</span>{{else}}<span
class="badge bg-secondary">ユーザー</span>{{end}}</td>
<td>
{{if eq .Role "admin"}}
<span class="badge bg-danger">管理者</span>
{{else}}
<span class="badge bg-secondary">ユーザー</span>
{{end}}
</td>
<td>{{formatDate .CreatedAt}}</td>
<td>
{{if ne .ID $.currentUserID}}
<form action="/admin/users/{{.ID}}/role" method="POST" class="d-inline" {{if eq .Role "admin"
}}onsubmit="return confirm('このユーザーを一般ユーザーに降格しますか?')"
{{else}}onsubmit="return confirm('このユーザーを管理者に昇格しますか?')" {{end}}>
{{if eq .Role "admin"}}
<form action="/admin/users/{{.ID}}/role" method="POST" class="d-inline"
data-confirm="このユーザーを一般ユーザーに降格しますか?">
<input type="hidden" name="_csrf" value="{{$.csrfToken}}">
{{if eq .Role "admin"}}
<input type="hidden" name="role" value="user">
<button type="submit" class="btn btn-sm btn-outline-secondary" title="ユーザーに降格"><i
class="bi bi-arrow-down"></i></button>
{{else}}
<input type="hidden" name="role" value="admin">
<button type="submit" class="btn btn-sm btn-outline-warning" title="管理者に昇格"><i
class="bi bi-arrow-up"></i></button>
{{end}}
<button type="submit" class="btn btn-sm btn-outline-secondary" aria-label="{{.Name}}をユーザーに降格">
<i class="bi bi-arrow-down" aria-hidden="true"></i>
</button>
</form>
<form action="/admin/users/{{.ID}}/delete" method="POST" class="d-inline"
onsubmit="return confirm('このユーザーを削除しますか?')">
{{else}}
<form action="/admin/users/{{.ID}}/role" method="POST" class="d-inline"
data-confirm="このユーザーを管理者に昇格しますか?">
<input type="hidden" name="_csrf" value="{{$.csrfToken}}">
<button type="submit" class="btn btn-sm btn-outline-danger" title="削除"><i
class="bi bi-trash"></i></button>
<input type="hidden" name="role" value="admin">
<button type="submit" class="btn btn-sm btn-outline-warning" aria-label="{{.Name}}を管理者に昇格">
<i class="bi bi-arrow-up" aria-hidden="true"></i>
</button>
</form>
{{else}}<span class="text-muted">-</span>{{end}}
{{end}}
<form action="/admin/users/{{.ID}}/delete" method="POST" class="d-inline"
data-confirm="このユーザーを削除しますか?">
<input type="hidden" name="_csrf" value="{{$.csrfToken}}">
<button type="submit" class="btn btn-sm btn-outline-danger" aria-label="{{.Name}}を削除">
<i class="bi bi-trash" aria-hidden="true"></i>
</button>
</form>
{{else}}
<span class="text-muted">-</span>
{{end}}
</td>
</tr>
{{end}}
@@ -58,8 +71,8 @@
</div>
{{else}}
<div class="text-center py-5">
<i class="bi bi-people display-1 text-muted"></i>
<i class="bi bi-people display-1 text-muted" aria-hidden="true"></i>
<h3 class="mt-3">ユーザーがいません</h3>
</div>
{{end}}
{{end}}
{{end}}