Mock up voting pages
This commit is contained in:
parent
3c9d5ce883
commit
1b823fe4f0
@ -19,6 +19,8 @@ const (
|
||||
pathCreate = "/create"
|
||||
pathDoCreate = "/create/do"
|
||||
pathAdmin = "/admin"
|
||||
pathVote = "/vote"
|
||||
pathDoVote = "/vote/do"
|
||||
)
|
||||
|
||||
type handler struct {
|
||||
@ -45,6 +47,8 @@ func NewHandler(params HandlerParams) http.Handler {
|
||||
h.mux.HandleFunc(pathCreate, h.handleCreate)
|
||||
h.mux.HandleFunc(pathDoCreate, h.handleDoCreate)
|
||||
h.mux.HandleFunc(pathAdmin, h.handleAdmin)
|
||||
h.mux.HandleFunc(pathVote, h.handleVote)
|
||||
h.mux.HandleFunc(pathDoVote, h.handleDoVote)
|
||||
return h
|
||||
}
|
||||
|
||||
@ -58,6 +62,89 @@ func (h *handler) handleRoot(w http.ResponseWriter, r *http.Request) {
|
||||
_ = h.writePage(w, body)
|
||||
}
|
||||
|
||||
var timeLabels = []string{
|
||||
"12 AM", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11",
|
||||
"12 PM", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11",
|
||||
}
|
||||
|
||||
func (h *handler) handleVote(w http.ResponseWriter, r *http.Request) {
|
||||
// TODO use actual data
|
||||
var rows = hm.Terms{
|
||||
e.Thead()(
|
||||
e.Th()(),
|
||||
e.Th()(hm.Text("May 3")),
|
||||
e.Th()(hm.Text("May 4")),
|
||||
e.Th()(hm.Text("May 5")),
|
||||
),
|
||||
}
|
||||
for slot := 0; slot < 24; slot++ {
|
||||
var row = hm.Terms{
|
||||
e.Td()(hm.Text(timeLabels[slot])),
|
||||
}
|
||||
for day := 0; day < 3; day++ {
|
||||
row = append(row, e.Td()(e.Input(a.Type("checkbox"))))
|
||||
}
|
||||
rows = append(rows, e.Tr()(row))
|
||||
}
|
||||
body := hm.Terms{
|
||||
e.H2()(hm.Text("Billy's birthday party")),
|
||||
e.P()(hm.Text("At Billy's house. Bring presents. Eat cake.")),
|
||||
e.Form(a.Method(http.MethodPost), a.Action(pathDoVote))(
|
||||
e.Label()(hm.Text("What's your name?")),
|
||||
e.Br(),
|
||||
e.Input(a.Size(40)),
|
||||
e.Fieldset()(
|
||||
e.Legend()(hm.Text("When are you available?")),
|
||||
e.Table()(rows),
|
||||
),
|
||||
e.Input(a.Type("submit"), a.Value("Submit")),
|
||||
),
|
||||
}
|
||||
_ = h.writePage(w, body)
|
||||
}
|
||||
|
||||
func (h *handler) handleDoVote(w http.ResponseWriter, r *http.Request) {
|
||||
// TODO use actual data
|
||||
var rows = hm.Terms{
|
||||
e.Thead()(
|
||||
e.Th()(),
|
||||
e.Th()(hm.Text("May 3")),
|
||||
e.Th()(hm.Text("May 4")),
|
||||
e.Th()(hm.Text("May 5")),
|
||||
),
|
||||
}
|
||||
for slot := 0; slot < 24; slot++ {
|
||||
var row = hm.Terms{
|
||||
e.Td()(hm.Text(timeLabels[slot])),
|
||||
}
|
||||
for day := 0; day < 3; day++ {
|
||||
row = append(row, e.Td()(e.Input(a.Type("checkbox"), a.Disabled())))
|
||||
}
|
||||
rows = append(rows, e.Tr()(row))
|
||||
}
|
||||
body := hm.Terms{
|
||||
e.H2()(hm.Text("Billy's birthday party")),
|
||||
e.P()(hm.Text("At Billy's house. Bring presents. Eat cake.")),
|
||||
e.H3()(hm.Text("Thanks for voting!")),
|
||||
e.P()(
|
||||
hm.Text("You can edit your response anytime at "),
|
||||
e.A(a.Href("#"))(hm.Text("this link")),
|
||||
hm.Text("."),
|
||||
),
|
||||
e.Form(a.Method(http.MethodPost), a.Action(pathDoVote))(
|
||||
e.Label()(hm.Text("What's your name?")),
|
||||
e.Br(),
|
||||
e.Input(a.Size(40), a.Disabled(), a.Value("Suzie Q")),
|
||||
e.Fieldset()(
|
||||
e.Legend()(hm.Text("When are you available?")),
|
||||
e.Table()(rows),
|
||||
),
|
||||
e.Input(a.Type("submit"), a.Value("Submit")),
|
||||
),
|
||||
}
|
||||
_ = h.writePage(w, body)
|
||||
}
|
||||
|
||||
func (h *handler) handleCreate(w http.ResponseWriter, r *http.Request) {
|
||||
body := hm.Terms{
|
||||
e.H2()(hm.Text("Create an event")),
|
||||
|
Loading…
Reference in New Issue
Block a user