{{ define "title" }}New motion{{ end }}

{{ define "main" }}
    <form action="/newmotion/" method="post">
        <input type="hidden" name="csrf_token" value="{{ .CSRFToken }}">
        <div class="ui form segment{{ if .Form.FieldErrors }} error{{ end }}">
            <div class="three fields">
                <div class="field">
                    <label>ID:</label>
                    (generated on submit)
                </div>
                <div class="field">
                    <label>Proponent:</label>
                    {{ .User.Name }}
                </div>
                <div class="field">
                    <label>Proposed date/time:</label>
                    (auto filled to current date/time)
                </div>
            </div>
            <div class="required field{{ if .Form.FieldErrors.title }} error{{ end }}">
                <label for="title">Title:</label>
                <input id="title" name="title" type="text" value="{{ .Form.Title }}">
                {{ if .Form.FieldErrors.title }}
                    <span class="ui small error text">{{ .Form.FieldErrors.title }}</span>
                {{ end }}
            </div>
            <div class="required field{{ if .Form.FieldErrors.content }} error{{ end }}">
                <label for="content">Text:</label>
                <textarea id="content" name="content">{{ .Form.Content }}</textarea>
                {{ if .Form.FieldErrors.content }}
                    <span class="ui small error text">{{ .Form.FieldErrors.content }}</span>
                {{ end }}
            </div>
            <div class="two fields">
                <div class="required field{{ if .Form.FieldErrors.type }} error{{ end }}">
                    <label for="type">Vote type:</label>
                    {{ $voteType := toString .Form.Type }}
                    <select id="type" name="type">
                        <option value="motion"
                                {{ if eq "motion" $voteType }}selected{{ end }}>
                            Motion
                        </option>
                        <option value="veto"
                                {{ if eq "veto" $voteType }}selected{{ end }}>
                            Veto
                        </option>
                    </select>
                    {{ if .Form.FieldErrors.type }}
                        <span class="ui small error text">{{ .Form.FieldErrors.type}}</span>
                    {{ end}}
                </div>
                <div class="required field{{ if .Form.FieldErrors.due }} error{{ end }}">
                    <label for="due">Due: (autofilled from chosen
                        option)</label>
                    <select id="due" name="due">
                        <option value="3"{{ if eq 3 .Form.Due }} selected{{ end }}>In 3 Days</option>
                        <option value="7"{{ if eq 7 .Form.Due }} selected{{ end }}>In 1 Week</option>
                        <option value="14"{{ if eq 14 .Form.Due }} selected{{ end }}>In 2 Weeks</option>
                        <option value="28"{{ if eq 28 .Form.Due }} selected{{ end }}>In 4 Weeks</option>
                    </select>
                    {{ if .Form.FieldErrors.due }}
                        <span class="ui small error text">{{ .Form.FieldErrors.due }}</span>
                    {{ end }}
                </div>
            </div>
            <button class="ui button" type="submit">Propose</button>
        </div>
    </form>
{{ end }}