{{ define "title"}}User Management{{ end }}

{{ define "main"}}
    {{ if .Users }}
        <table class="ui selectable basic table">
            <thead>
            <tr>
                <th class="six wide">Name</th>
                <th class="four wide">Roles</th>
                <th class="six wide">Actions</th>
            </tr>
            </thead>
            <tbody>
            {{ $user := .User }}
            {{ range .Users }}
                <tr {{ if eq $user.ID .ID }}class="disabled"{{ end }}>
                    <td>{{ .Name }}</td>
                    <td>{{ .Roles | join ", " }}</td>
                    <td>
                        {{ if not (eq $user.ID .ID) }}
                            <a href="/users/{{ .ID }}/" class="ui labeled primary icon button"><i class="edit icon"></i> Edit</a>
                            {{ if .CanDelete }}
                                <a href="/users/{{ .ID }}/delete" class="ui labeled negative icon button" title="{{ .Name }} never participated in a motion and may be deleted">
                                    <i class="delete icon"></i> Delete</a>
                            {{ end }}
                        {{ else }}
                            Cannot modify your own user. Ask another administrator or secretary.
                        {{ end }}
                    </td>
                </tr>
            {{ end }}
            </tbody>
        </table>
    {{ else }}
        <div class="ui basic segment">
            <div class="ui icon message">
                <i class="users icon"></i>
                <div class="content">
                    <div class="header">No users found.</div>
                </div>
            </div>
        </div>
    {{ end }}
{{ end }}