transmet/templates/pages/categories.html

52 lines
1.7 KiB
HTML

{{define "body"}}
<h2 class="form-categories-heading">Categories</h2>
{{template "flashes" .}}
{{range $category := .categories}}
{{template "row-category" dict "category" $category "categories" $.categories}}
{{end}}
{{end}}
{{define "row-category"}}
<div class="row">
<div class="col-xs-2">
{{stringTimes .category.Depth "- "}}
{{.category.Name}}
</div>
<div class="col-xs-1">
<a href="/categories/delete?id={{.category.Id}}">delete</a>
</div>
<div class="col-xs-3">
<form action="/categories/change-parent?cid={{.category.Id}}" method="POST">
<select class="form-control category-change-parent" name="parent" >
<option value="none" {{if not .category.Parent.Valid}} selected="true"{{end}}>-- None --</option>
{{range $category := .categories}}
{{if $.category.Parent.Valid }}
{{template "option-category" dict "category" $category "id" $.category.Parent.Value}}
{{else}}
{{template "option-category" dict "category" $category "id" -1}}
{{end}}
{{end}}
</select>
</form>
</div>
</div>
{{range $child := .category.Children}}
{{template "row-category" dict "category" $child "categories" $.categories}}
{{end}}
{{end}}
{{define "option-category"}}
<option value="{{.category.Id}}" {{if eq .id .category.Id}}selected="true"{{end}}>{{.category.ToString}}</option>
{{range $child := .category.Children}}
{{template "option-category" dict "category" $child "id" $.id}}
{{end}}
{{end}}