{{define "table_view"}} {{$table := .Table}} {{$meta := .Meta}} {{$sort := .Sort}} {{$dir := .SortDir}} {{$page := .Page}} {{$total := .TotalPages}} {{template "base_start" (dict "Tables" .Tables "ActiveTable" $table)}}

{{$table}} {{$meta.RowCount}} rows

CSV JSON {{if $meta.HasID}} Add Record {{end}}
{{template "alert" .}} {{if not $meta.HasID}}
This table has no id column — records are read-only. Use the SQL Editor to modify data.
{{end}}
{{range $col := .Cols}} {{end}} {{if $meta.HasID}}{{end}} {{range $row := .Rows}} {{range $cell := $row}} {{end}} {{if $meta.HasID}} {{end}} {{else}} {{end}}
{{$newDir := "asc"}} {{if and (eq $sort $col.Name) (eq $dir "asc")}}{{$newDir = "desc"}}{{end}} {{$col.Name}} {{if eq $sort $col.Name}} {{if eq $dir "asc"}} {{else}}{{end}} {{end}} {{$col.TypeName}} Actions
{{if eq $cell ""}}null{{else}}{{$cell}}{{end}} {{$id := index $row 0}}

No records yet.

{{if $meta.HasID}} Add First Record {{end}}
{{if gt $total 1}} {{end}}
{{template "base_end" .}} {{end}}