{{ define "admin-edit-html" }}
<!DOCTYPE html>
<html lang="fr">

<head>
  <meta charset="utf-8">
  <title>AGECEM</title>
  {{ template "general-html" }}
  <link rel="stylesheet" href="/public/css/admin-edit.css">
  <script src="https://unpkg.com/htmx.org@2.0.3"></script>
</head>

<body>
  {{ template "header-html" }}
  {{ if .Error }}
    <b>{{ .Error }}</b>
  {{ end }}
  <article id="moduleAdminEdit">
    <h2>Modifier les documents</h2>

    {{ range .Buckets }}
    {{ $bucketID := .ID }}
    <h3>{{ .DisplayName }} ({{ .ID }})</h3>
    {{ if not .DocumentKeys }}
        <p><i>Aucun document de type {{ .DisplayName }} enregistré, voir le <a href="/admin">panneau d'administration</a> pour en ajouter.</i></p>
    {{ else }}
    <table>
        <tr><th></th><th>Renommer</th><th>Effacer</th></tr>
        {{ range .DocumentKeys }}
            <tr>
                <td>{{ . }}</td>
                <td><a
                        hx-get="/admin/documents/edit/{{$bucketID}}/{{.}}/key"
                        hx-target="#app-dialog"
                        hx-on:click="document.getElementById('app-dialog').style.display = 'block';">
                        <button>🖉</button>
                </a></td>
                <td><a
                        hx-get="/admin/documents/edit/{{$bucketID}}/{{.}}/delete"
                        hx-target="#app-dialog"
                        hx-on:click="document.getElementById('app-dialog').style.display = 'block';">
                        <button>🗑</button>
                </a></td>
            </tr>
        {{ end }}
    </table>
    {{ end }}
    {{ end }}
    <div id="app-dialog" style="display: none;"> </div>
  </article>
  {{ template "footer-html" }}
</body>

</html>
{{ end }}
