{{template "layout.html" .}}

{{define "title"}}Entities{{end}}

{{define "content"}}
<h3>Entities</h3>

<nav>
    <div class="nav nav-tabs" id="nav-tab" role="tablist">
        {{- range $t, $v := .}}
        <button class="nav-link{{ ifFirst $ $t " active" }}" data-bs-toggle="tab" data-bs-target="#nav-{{kebab $t}}" type="button"
            role="tab">{{$t}} ({{ len $v }})</button>
        {{- end}}
    </div>
</nav>
<div class="tab-content" id="nav-tabContent">
    {{- range $t, $v := . }}
    <div class="tab-pane{{ ifFirst $ $t " active" }}" id="nav-{{kebab $t}}" role="tabpanel" aria-labelledby="nav-home-tab">
        <table class="table table-hover table-sm table-borderless object-table">
            <tr>
                <th>Name</th>
                <th>
                    {{- if eq $t "guild" }}
                    Profession
                    {{- else if eq $t "religion" }}
                    Worshpipping
                    {{- else }}
                    Race
                    {{- end }}
                </th>
                {{- if eq $t "militaryunit" }}
                <th width="50%">Worshpipping</th>
                <th width="50%">Weapons</th>
                {{- end }}
            </tr>
            {{- range $v }}{{- if not (eq .Name "") }}
            <tr>
                <td>{{ entity .Id }}</td>
                <td>
                    {{- if eq $t "guild" }}
                    {{ .Profession }}s
                    {{- else if eq $t "religion" }}
                    {{ hfList .WorshipId }}
                    {{- else }}
                    {{ .Race }}
                    {{- end }}
                </td>
                {{- if eq $t "militaryunit" }}
                <td style="white-space: normal;">{{ hfList .WorshipId }}</td>
                <td style="white-space: normal;">{{ andList .Weapons }}</td>
                {{- end }}
            </tr>
            {{- end}}{{- end}}
        </table>
    </div>
    {{- end}}
</div>

{{- end }}