Update hatmill and date versions

This commit is contained in:
2020-05-25 19:43:10 -06:00
parent c4aaa1bca5
commit 8661fd3abf
3 changed files with 31 additions and 22 deletions

View File

@ -68,22 +68,6 @@ var timeLabels = []string{
"12 PM", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11",
}
func disableIf(cond bool, input hm.Term) hm.Term {
if !cond {
return input
}
switch e := input.(type) {
case hm.ParentElement:
e.Attribs = append(e.Attribs, a.Disabled())
return e
case hm.VoidElement:
e.Attribs = append(e.Attribs, a.Disabled())
return e
default:
return e
}
}
type voteState struct {
name string
earliest, latest date.Date
@ -107,14 +91,14 @@ func voteForm(disabled bool, st voteState) hm.Term {
e.Td()(hm.Text(timeLabels[hour])),
}
for day := 0; day < len(dates); day++ {
row = append(row, e.Td()(disableIf(disabled, e.Input(a.Type("checkbox")))))
row = append(row, e.Td()(e.Input(a.Type("checkbox"), a.Disabled(disabled))))
}
rows = append(rows, e.Tr()(row))
}
return e.Form(a.Method(http.MethodPost), a.Action(pathDoVote))(
e.Label()(hm.Text("What's your name?")),
e.Br(),
disableIf(disabled, e.Input(a.Size(40), a.Value(st.name))),
e.Input(a.Size(40), a.Value(st.name), a.Disabled(disabled)),
e.Fieldset()(
e.Legend()(hm.Text("When are you available?")),
e.Table()(rows),