forgejo-tickets/web/templates/pages/admin/tickets/list.html

111 lines
6.2 KiB
HTML

{{define "title"}}All Tickets{{end}}
{{define "content"}}
<h1 class="text-2xl font-bold text-gray-900 mb-6">All Tickets</h1>
{{with .Data}}
{{$filters := dict "status" .StatusFilter "priority" .PriorityFilter "product" .ProductFilter "reporter" .ReporterFilter}}
{{$productFilter := .ProductFilter}}
{{$reporterFilter := .ReporterFilter}}
<div class="flex items-center gap-4 mb-4">
<div class="flex items-center gap-1.5">
<label class="text-xs font-medium text-gray-500 uppercase">Status</label>
<select data-filter-nav class="rounded-md border-gray-300 text-sm py-1.5 pr-8">
<option value="{{filterURL "/admin/tickets" $filters "status" ""}}" {{if not .StatusFilter}}selected{{end}}>All</option>
<option value="{{filterURL "/admin/tickets" $filters "status" "open"}}" {{if eq .StatusFilter "open"}}selected{{end}}>Open</option>
<option value="{{filterURL "/admin/tickets" $filters "status" "in_progress"}}" {{if eq .StatusFilter "in_progress"}}selected{{end}}>In Progress</option>
<option value="{{filterURL "/admin/tickets" $filters "status" "closed"}}" {{if eq .StatusFilter "closed"}}selected{{end}}>Closed</option>
</select>
</div>
<div class="flex items-center gap-1.5">
<label class="text-xs font-medium text-gray-500 uppercase">Priority</label>
<select data-filter-nav class="rounded-md border-gray-300 text-sm py-1.5 pr-8">
<option value="{{filterURL "/admin/tickets" $filters "priority" ""}}" {{if not .PriorityFilter}}selected{{end}}>All</option>
<option value="{{filterURL "/admin/tickets" $filters "priority" "high"}}" {{if eq .PriorityFilter "high"}}selected{{end}}>High</option>
<option value="{{filterURL "/admin/tickets" $filters "priority" "medium"}}" {{if eq .PriorityFilter "medium"}}selected{{end}}>Medium</option>
<option value="{{filterURL "/admin/tickets" $filters "priority" "low"}}" {{if eq .PriorityFilter "low"}}selected{{end}}>Low</option>
</select>
</div>
{{if .Products}}
<div class="flex items-center gap-1.5">
<label class="text-xs font-medium text-gray-500 uppercase">Product</label>
<select data-filter-nav class="rounded-md border-gray-300 text-sm py-1.5 pr-8">
<option value="{{filterURL "/admin/tickets" $filters "product" ""}}" {{if not .ProductFilter}}selected{{end}}>All</option>
{{range .Products}}
<option value="{{filterURL "/admin/tickets" $filters "product" .}}" {{if eq $productFilter .}}selected{{end}}>{{.}}</option>
{{end}}
</select>
</div>
{{end}}
{{if .Reporters}}
<div class="flex items-center gap-1.5">
<label class="text-xs font-medium text-gray-500 uppercase">Reporter</label>
<select data-filter-nav class="rounded-md border-gray-300 text-sm py-1.5 pr-8">
<option value="{{filterURL "/admin/tickets" $filters "reporter" ""}}" {{if not .ReporterFilter}}selected{{end}}>All</option>
{{range .Reporters}}
<option value="{{filterURL "/admin/tickets" $filters "reporter" .}}" {{if eq $reporterFilter .}}selected{{end}}>{{.}}</option>
{{end}}
</select>
</div>
{{end}}
</div>
{{if .Tickets}}
<div class="overflow-hidden bg-white shadow ring-1 ring-gray-200 rounded-lg">
<table class="min-w-full divide-y divide-gray-200">
<thead class="bg-gray-50">
<tr>
<th class="px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase">Title</th>
<th class="px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase">User</th>
<th class="px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase">Product</th>
<th class="px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase">Priority</th>
<th class="px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase">Status</th>
<th class="px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase">Due</th>
<th class="px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase">Created</th>
</tr>
</thead>
<tbody class="divide-y divide-gray-200">
{{range .Tickets}}
<tr class="hover:bg-gray-50">
<td class="px-4 py-3">
<div class="flex items-center gap-1">
{{if .Pinned}}<span class="text-gray-400 text-xs" title="Pinned">&#128204;</span>{{end}}
<a href="/admin/tickets/{{.ID}}" class="text-sm font-medium text-blue-600 hover:text-blue-500">{{.Title}}</a>
</div>
</td>
<td class="px-4 py-3 text-sm text-gray-500">{{.UserName}}</td>
<td class="px-4 py-3 text-sm text-gray-500">{{.RepoName}}</td>
<td class="px-4 py-3">{{if .Priority}}{{priorityBadge .Priority}}{{end}}</td>
<td class="px-4 py-3">{{statusBadge (print .Status)}}</td>
<td class="px-4 py-3 text-sm {{if isOverdue .DueDate}}text-red-600 font-medium{{else}}text-gray-500{{end}}">{{if .DueDate}}{{formatDatePtr .DueDate}}{{end}}</td>
<td class="px-4 py-3 text-sm text-gray-500">{{formatDate .CreatedAt}}</td>
</tr>
{{end}}
</tbody>
</table>
</div>
{{if gt .TotalPages 1}}
<nav class="flex items-center justify-between mt-4 px-1">
<div>
{{if gt .Page 1}}
<a href="{{pageURL "/admin/tickets" $filters (sub .Page 1)}}" class="rounded-md px-3 py-1.5 text-sm font-medium bg-white text-gray-700 ring-1 ring-gray-300 hover:bg-gray-50">Previous</a>
{{end}}
</div>
<span class="text-sm text-gray-500">Page {{.Page}} of {{.TotalPages}}</span>
<div>
{{if lt .Page .TotalPages}}
<a href="{{pageURL "/admin/tickets" $filters (add .Page 1)}}" class="rounded-md px-3 py-1.5 text-sm font-medium bg-white text-gray-700 ring-1 ring-gray-300 hover:bg-gray-50">Next</a>
{{end}}
</div>
</nav>
{{end}}
{{else}}
{{if or .StatusFilter .PriorityFilter .ProductFilter .ReporterFilter}}
<p class="text-sm text-gray-500">No tickets match the current filters.</p>
{{else}}
<p class="text-sm text-gray-500">No tickets found.</p>
{{end}}
{{end}}
{{end}}
{{end}}