{{ define "title" }}Proxy Vote on Motion {{ .Motion.Tag }}{{ end }}

{{ define "main" }}
    {{ $form := .Form }}
    {{ $user := .User }}
    <div class="ui form segment">
        {{ template "motion_display" .Motion }}
        <form action="/proxy/{{ .Motion.Tag }}" method="post">
            <input type="hidden" name="csrf_token" value="{{ .CSRFToken }}">
            <div class="ui form{{ if .Form.FieldErrors }} error{{ end }}">
                <div class="required field{{ if .Form.FieldErrors.user }} error{{ end }}">
                    <label for="voter">Voter</label>
                    <select id="voter" name="voter">
                        {{ range .Form.Voters }}
                            {{ if ne .ID $user.ID }}
                                <option value="{{ .ID }}"
                                        {{ if $form.Voter }}{{ if eq .ID $form.Voter.ID }} selected{{ end }}{{ end }}>{{ .Name }}</option>
                            {{ end }}
                        {{ end }}
                    </select>
                    {{ if .Form.FieldErrors.user }}
                        <span class="ui small error text">{{ .Form.FieldErrors.user }}</span>
                    {{ end }}
                </div>
                <div class="inline fields required{{ if .Form.FieldErrors.choice }} error{{ end }}">
                    <label>Choice</label>
                    <div class="field">
                        <div class="ui radio checkbox">
                            <input type="radio" aria-labelledby="label-aye" name="choice" id="choice-aye"
                                   value="aye"{{ with .Form.Choice }}{{ if eq "aye" .Label }} checked{{ end }}{{ end }}>
                            <label id="label-aye" for="choice-aye">Aye</label>
                        </div>
                    </div>
                    <div class="field">
                        <div class="ui radio checkbox">
                            <input type="radio" aria-labelledby="label-naye" name="choice" id="choice-naye"
                                   value="naye"{{ with .Form.Choice }}{{ if eq "naye" .Label }} checked{{ end }}{{ end }}>
                            <label id="label-naye" for="choice-naye">Naye</label>
                        </div>
                    </div>
                    <div class="field">
                        <div class="ui radio checkbox">
                            <input type="radio" aria-labelledby="label-abstain" name="choice" id="choice-abstain"
                                   value="abstain"{{ with .Form.Choice }}{{ if eq "abstain" .Label }} checked{{ end }}{{ end }}>
                            <label id="label-abstain" for="choice-abstain">Abstain</label>
                        </div>
                    </div>
                    {{ if .Form.FieldErrors.choice }}
                        <div>
                            <span class="ui small error text">{{ .Form.FieldErrors.choice }}</span>
                        </div>
                    {{ end }}
                </div>
                <div class="required field{{ if .Form.FieldErrors.justification }} error{{ end }}">
                    <label for="justification">Justification</label>
                    <textarea id="justification" name="justification" rows="2">{{ .Form.Justification }}</textarea>
                    {{ if .Form.FieldErrors.justification }}
                        <span class="ui small error text">{{ .Form.FieldErrors.justification }}</span>
                    {{ end }}
                </div>
                <button class="ui primary labeled icon button" type="submit"><i class="users icon"></i> Proxy Vote
                </button>
            </div>
        </form>
    </div>
{{ end }}