forked from tildetown/town
basic email validation
the code for the panes is getting messy. since we have one window we constantly reuse, and especially now that we have weird state-dependent validation. probably good to rework?trunk
parent
a124b27021
commit
0472c24199
|
@ -136,7 +136,7 @@ func _main() error {
|
||||||
appView.SetDynamicColors(true)
|
appView.SetDynamicColors(true)
|
||||||
|
|
||||||
legend := tview.NewTextView()
|
legend := tview.NewTextView()
|
||||||
legend.SetText("s: skip r: random A: approve R: reject N: notate Q: quit")
|
legend.SetText("s/S: next/prev r: random A: approve R: reject N: notate Q: quit")
|
||||||
legend.SetTextColor(tcell.ColorPurple)
|
legend.SetTextColor(tcell.ColorPurple)
|
||||||
legend.SetTextAlign(tview.AlignCenter)
|
legend.SetTextAlign(tview.AlignCenter)
|
||||||
legend.SetBackgroundColor(tcell.ColorBlack)
|
legend.SetBackgroundColor(tcell.ColorBlack)
|
||||||
|
@ -238,14 +238,11 @@ func _main() error {
|
||||||
reviewForm.AddFormItem(cleanEmailInput)
|
reviewForm.AddFormItem(cleanEmailInput)
|
||||||
reviewForm.AddButton("submit", func() {
|
reviewForm.AddButton("submit", func() {
|
||||||
currSignup := signups[signupIx]
|
currSignup := signups[signupIx]
|
||||||
cleanEmail := reviewForm.GetFormItemByLabel("clean email").(*tview.InputField).GetText()
|
cleanEmail := cleanEmailInput.GetText()
|
||||||
defer func() {
|
|
||||||
cleanEmailInput.SetText("")
|
|
||||||
}()
|
|
||||||
currSignup.CleanEmail = cleanEmail
|
currSignup.CleanEmail = cleanEmail
|
||||||
|
|
||||||
decision := models.SignupRejected
|
decision := models.SignupRejected
|
||||||
_, d := reviewForm.GetFormItemByLabel("decision").(*tview.DropDown).GetCurrentOption()
|
_, d := decisionFI.GetCurrentOption()
|
||||||
if d == "accepted" {
|
if d == "accepted" {
|
||||||
decision = models.SignupAccepted
|
decision = models.SignupAccepted
|
||||||
}
|
}
|
||||||
|
@ -332,12 +329,16 @@ func _main() error {
|
||||||
updateCount()
|
updateCount()
|
||||||
render()
|
render()
|
||||||
}
|
}
|
||||||
|
// TODO: there's a bunch of messy state management.
|
||||||
|
// should we generate this pane functionally?
|
||||||
case 'A':
|
case 'A':
|
||||||
if len(signups) == 0 {
|
if len(signups) == 0 {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
emailVal := signups[signupIx].Email
|
emailVal := signups[signupIx].Email
|
||||||
providedEmailView.SetText(emailVal)
|
providedEmailView.SetText(emailVal)
|
||||||
|
cleanEmailInput.SetLabel("clean email ")
|
||||||
|
cleanEmailInput.SetText("")
|
||||||
/*
|
/*
|
||||||
TODO the placeholder doesn't appear to become the default text which is
|
TODO the placeholder doesn't appear to become the default text which is
|
||||||
what I wanted it to do. Just taking this out so the blank box beckons
|
what I wanted it to do. Just taking this out so the blank box beckons
|
||||||
|
@ -346,6 +347,13 @@ func _main() error {
|
||||||
cleanEmailInput.SetPlaceholder(
|
cleanEmailInput.SetPlaceholder(
|
||||||
strings.TrimSpace(strings.ReplaceAll(emailVal, "\n", " ")))
|
strings.TrimSpace(strings.ReplaceAll(emailVal, "\n", " ")))
|
||||||
*/
|
*/
|
||||||
|
cleanEmailInput.SetChangedFunc(func(text string) {
|
||||||
|
if strings.Contains(emailVal, text) {
|
||||||
|
cleanEmailInput.SetLabel("clean email ")
|
||||||
|
} else {
|
||||||
|
cleanEmailInput.SetLabel("[red]clean email :(")
|
||||||
|
}
|
||||||
|
})
|
||||||
decisionFI.SetCurrentOption(0)
|
decisionFI.SetCurrentOption(0)
|
||||||
pages.SwitchToPage("review")
|
pages.SwitchToPage("review")
|
||||||
app.SetFocus(cleanEmailInput)
|
app.SetFocus(cleanEmailInput)
|
||||||
|
@ -356,6 +364,8 @@ func _main() error {
|
||||||
}
|
}
|
||||||
emailVal := signups[signupIx].Email
|
emailVal := signups[signupIx].Email
|
||||||
providedEmailView.SetText(emailVal)
|
providedEmailView.SetText(emailVal)
|
||||||
|
cleanEmailInput.SetLabel("clean email ")
|
||||||
|
cleanEmailInput.SetText("")
|
||||||
/*
|
/*
|
||||||
TODO the placeholder doesn't appear to become the default text which is
|
TODO the placeholder doesn't appear to become the default text which is
|
||||||
what I wanted it to do. Just taking this out so the blank box beckons
|
what I wanted it to do. Just taking this out so the blank box beckons
|
||||||
|
@ -364,6 +374,13 @@ func _main() error {
|
||||||
cleanEmailInput.SetPlaceholder(
|
cleanEmailInput.SetPlaceholder(
|
||||||
strings.TrimSpace(strings.ReplaceAll(emailVal, "\n", " ")))
|
strings.TrimSpace(strings.ReplaceAll(emailVal, "\n", " ")))
|
||||||
*/
|
*/
|
||||||
|
cleanEmailInput.SetChangedFunc(func(text string) {
|
||||||
|
if strings.Contains(emailVal, text) {
|
||||||
|
cleanEmailInput.SetLabel("clean email ")
|
||||||
|
} else {
|
||||||
|
cleanEmailInput.SetLabel("[red]clean email :(")
|
||||||
|
}
|
||||||
|
})
|
||||||
decisionFI.SetCurrentOption(1)
|
decisionFI.SetCurrentOption(1)
|
||||||
pages.SwitchToPage("review")
|
pages.SwitchToPage("review")
|
||||||
app.SetFocus(cleanEmailInput)
|
app.SetFocus(cleanEmailInput)
|
||||||
|
|
Loading…
Reference in New Issue