{{ define "title" }}
    Group - {{ .GroupName }}
{{ end }}
{{ define "content" }}
{{- $parentGroupName := .GroupName }}
    <div>
        <h2 class="headline">Group: {{ .GroupName }}</h2>
        <p class="description">{{ .Description }}</p>
    </div>
    <hr class="divider">
    <form action="/group/{{ .GroupName }}/add-user/" method="post">
        <fieldset class="grid first">
            <input type="text" id="username" name="username" placeholder="username" required>
            <select id="status" name="status" required>
                <option value="Member" selected>Member</option>
                <option value="Owner">Owner</option>
            </select>
            <button type="submit">Add Member</button>
        </fieldset>
    </form>
    <form action="/group/{{ .GroupName }}/add-child-group" method="post">
        <fieldset class="grid twoone">
            <select id="child-group" aria-label="Select" name="child-group" required>
                {{- range .AllGroups }}
                <option value="{{ .Name }}">{{ .Name }}</option>
                {{- end }}
            </select>
            <button type="submit">Create Child Group</button>
        </fieldset>
    </form>
    <form action="/group/{{ .GroupName }}/add-owner-group" method="post">
        <fieldset class="grid twoone">
            <select id="owner-group" aria-label="Select" name="owner-group" required>
                {{- range .AllGroups }}
                <option value="{{ .Name }}">{{ .Name }}</option>
                {{- end }}
            </select>
            <button type="submit">Add Owner Group</button>
        </fieldset>
    </form>
    <hr class="divider">
    <h3>Owners</h3>
    <div class="user-remove">
        {{- range .Owners }}
        <div>
            <fieldset role="group">
            <a class="link-button" href="/user/{{ . }}" role="button">{{ . }}</a>
            <form action="/group/{{ $parentGroupName }}/remove-owner/{{ . }}" method="post" class="remove-form" data-confirmation-message="Are you sure you want to revoke user <strong>{{ . }}</strong>'s ownership of the  <strong>{{ $parentGroupName }}</strong> group?">
                <button class="remove" type="submit" aria-label="Remove owner">
                    {{ template "svgIcon" }}
                </button>
            </form>
            </fieldset>
        </div>
        {{- end }}
    </div>
    
    <hr class="divider">

    <h3>Members</h3>
    <div class="user-remove">
        {{- range .Members }}
        <div>
            <fieldset role="group">
                <a class="link-button" href="/user/{{ . }}" role="button">{{ . }}</a>
            <form action="/group/{{ $parentGroupName }}/remove-member/{{ . }}" method="post" class="remove-form" data-confirmation-message="Are you sure you want to remove user  <strong>{{ . }}</strong> user from  <strong>{{ $parentGroupName }}</strong> group?">
                <button class="remove" type="submit">
                    {{ template "svgIcon" }}
                </button>
            </form>
            </fieldset>
        </div>
        {{- end }}
    </div>
    <hr class="divider">

    <h3>Transitive Groups</h3>
    <div class="user-remove">
        {{- range .TransitiveGroups }}
            <a class="link-button" href="/group/{{ .Name }}" role="button" 
               {{ if ne .Description "" }} data-tooltip="{{ .Description }}" data-placement="bottom" {{ end }}>
               {{ .Name }}
            </a>
        {{- end }}
    </div>
    <hr class="divider">

    <h3>Child Groups</h3>
    <div class="user-remove">
        {{- range .ChildGroups }}
        <div>
            <fieldset role="group">
                <a class="link-button" href="/group/{{ .Name }}" role="button" 
                    {{ if ne .Description "" }} data-tooltip="{{ .Description }}" data-placement="bottom" {{ end }}>
                    {{ .Name }}
                </a>
                <form action="/group/{{ $parentGroupName }}/remove-child-group/{{ .Name }}" method="post" class="remove-form" data-confirmation-message="Are you sure you want to remove group  <strong>{{ .Name }}</strong> as a child of the group  <strong>{{ $parentGroupName }}</strong>?">
                    <button class="remove" type="submit">
                        {{ template "svgIcon" }}
                    </button>
                </form>
            </fieldset>
        </div>
        {{- end }}
    </div>
    <hr class="divider">

    <h3>Owner Groups</h3>
    <div class="user-remove">
        {{- range .OwnerGroups }}
        <a class="link-button" href="/group/{{ .Name }}" role="button" 
            {{ if ne .Description "" }} data-tooltip="{{ .Description }}" data-placement="bottom" {{ end }}>
            {{ .Name }}
        </a>
        {{- end }}
    </div>

    <dialog id="confirmation" close>
        <article>
            <h3>Attention</h3>
            <p id="confirmation-message">Are you sure?</p>
            <footer>
                <button id="cancel-button" class="secondary cancel-button">Cancel</button>
                <button id="confirm-button">Confirm</button>
            </footer>
        </article>
    </dialog>
{{ end }}
