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

97 lines
6.9 KiB
HTML

{{define "title"}}My Tickets{{end}}
{{define "content"}}
<div class="flex items-center justify-between mb-6">
<h1 class="text-2xl font-bold text-gray-900">My Tickets</h1>
<a href="/tickets/new" class="rounded-md bg-blue-600 px-4 py-2 text-sm font-semibold text-white shadow hover:bg-blue-500">New Ticket</a>
</div>
{{with .Data}}
{{$filters := dict "status" .StatusFilter "priority" .PriorityFilter "product" .ProductFilter}}
{{$productFilter := .ProductFilter}}
<div class="mb-4 space-y-2">
<div class="flex items-center gap-2">
<span class="text-xs font-medium text-gray-500 uppercase w-16">Status</span>
<a href="{{filterURL "/tickets" $filters "status" ""}}" class="rounded-md px-3 py-1.5 text-sm font-medium {{if not .StatusFilter}}bg-gray-900 text-white{{else}}bg-white text-gray-700 ring-1 ring-gray-300 hover:bg-gray-50{{end}}">All</a>
<a href="{{filterURL "/tickets" $filters "status" "open"}}" class="rounded-md px-3 py-1.5 text-sm font-medium {{if eq .StatusFilter "open"}}bg-gray-900 text-white{{else}}bg-white text-gray-700 ring-1 ring-gray-300 hover:bg-gray-50{{end}}">Open</a>
<a href="{{filterURL "/tickets" $filters "status" "in_progress"}}" class="rounded-md px-3 py-1.5 text-sm font-medium {{if eq .StatusFilter "in_progress"}}bg-gray-900 text-white{{else}}bg-white text-gray-700 ring-1 ring-gray-300 hover:bg-gray-50{{end}}">In Progress</a>
<a href="{{filterURL "/tickets" $filters "status" "closed"}}" class="rounded-md px-3 py-1.5 text-sm font-medium {{if eq .StatusFilter "closed"}}bg-gray-900 text-white{{else}}bg-white text-gray-700 ring-1 ring-gray-300 hover:bg-gray-50{{end}}">Closed</a>
</div>
<div class="flex items-center gap-2">
<span class="text-xs font-medium text-gray-500 uppercase w-16">Priority</span>
<a href="{{filterURL "/tickets" $filters "priority" ""}}" class="rounded-md px-3 py-1.5 text-sm font-medium {{if not .PriorityFilter}}bg-gray-900 text-white{{else}}bg-white text-gray-700 ring-1 ring-gray-300 hover:bg-gray-50{{end}}">All</a>
<a href="{{filterURL "/tickets" $filters "priority" "high"}}" class="rounded-md px-3 py-1.5 text-sm font-medium {{if eq .PriorityFilter "high"}}bg-gray-900 text-white{{else}}bg-white text-gray-700 ring-1 ring-gray-300 hover:bg-gray-50{{end}}">High</a>
<a href="{{filterURL "/tickets" $filters "priority" "medium"}}" class="rounded-md px-3 py-1.5 text-sm font-medium {{if eq .PriorityFilter "medium"}}bg-gray-900 text-white{{else}}bg-white text-gray-700 ring-1 ring-gray-300 hover:bg-gray-50{{end}}">Medium</a>
<a href="{{filterURL "/tickets" $filters "priority" "low"}}" class="rounded-md px-3 py-1.5 text-sm font-medium {{if eq .PriorityFilter "low"}}bg-gray-900 text-white{{else}}bg-white text-gray-700 ring-1 ring-gray-300 hover:bg-gray-50{{end}}">Low</a>
</div>
{{if .Products}}
<div class="flex items-center gap-2">
<span class="text-xs font-medium text-gray-500 uppercase w-16">Product</span>
<a href="{{filterURL "/tickets" $filters "product" ""}}" class="rounded-md px-3 py-1.5 text-sm font-medium {{if not .ProductFilter}}bg-gray-900 text-white{{else}}bg-white text-gray-700 ring-1 ring-gray-300 hover:bg-gray-50{{end}}">All</a>
{{range .Products}}
<a href="{{filterURL "/tickets" $filters "product" .}}" class="rounded-md px-3 py-1.5 text-sm font-medium {{if eq $productFilter .}}bg-gray-900 text-white{{else}}bg-white text-gray-700 ring-1 ring-gray-300 hover:bg-gray-50{{end}}">{{.}}</a>
{{end}}
</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">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="/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">{{.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 "/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 "/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}}
<div class="text-center py-12 bg-white rounded-lg shadow ring-1 ring-gray-200">
{{if or .StatusFilter .PriorityFilter .ProductFilter}}
<p class="text-gray-500">No tickets match the current filters.</p>
{{else}}
<p class="text-gray-500">No tickets yet.</p>
<a href="/tickets/new" class="mt-4 inline-block text-sm font-medium text-blue-600 hover:text-blue-500">Create your first ticket</a>
{{end}}
</div>
{{end}}
{{end}}
{{end}}