<!--
 SPDX-FileCopyrightText: 2023 jordi fita mas <jordi@tandem.blog>
 SPDX-License-Identifier: AGPL-3.0-only
-->
{{ define "title" -}}
    {{( pgettext "Campsite Type Features" "title" )}}
{{- end }}

{{ define "content" -}}
    {{- /*gotype: dev.tandem.ws/tandem/camper/pkg/campsite/types.featureIndex*/ -}}
    <a href="/admin/campsites/types/{{ .TypeSlug }}/features/new">{{( pgettext "Add Feature" "action" )}}</a>
    <h2>{{( pgettext "Campsite Type Features" "title" )}}</h2>
    {{ if .Features -}}
        <form id="feature-index"
              class="sortable"
              data-hx-post="/admin/campsites/types/{{ .TypeSlug }}/features/order"
              data-hx-trigger="end"
              data-hx-select="#feature-index"
              data-hx-swap="outerHTML"
        >
            {{ CSRFInput }}
            <table class="services">
                <thead>
                <tr>
                    <th scope="col" style="width: 1.5em"></th>
                    <th scope="col">{{( pgettext "Name" "header" )}}</th>
                </tr>
                </thead>
                <tbody>
                {{ range .Features -}}
                    <tr>
                        <td>
                            <span class="handle"></span>
                            <input type="hidden" name="feature_id" value="{{ .ID }}">
                        </td>
                        <td class="icon_{{ .Icon }}"><a href="{{ .URL }}">{{ .Name }}</a></td>
                    </tr>
                {{- end }}
                </tbody>
            </table>
        </form>
    {{ else -}}
        <p>{{( gettext "No campsite type features added yet." )}}</p>
    {{- end }}
{{- end }}