change validation to be submission callback based

This commit is contained in:
Robin Olsen
2026-03-04 22:43:28 +01:00
parent 5a9a8238d9
commit 3d183d7fcd
4 changed files with 27 additions and 34 deletions

View File

@@ -13,12 +13,24 @@ import (
type ValidationFeedback = models.ValidationFeedback
var taskFeedback ValidationFeedback
var submitChan chan<- struct{}
func SetTaskFeedback(feedback ValidationFeedback) {
taskFeedback = feedback
}
func SetSubmitChan(ch chan<- struct{}) {
submitChan = ch
}
func HandleTaskStatus(w http.ResponseWriter, r *http.Request) {
if submitChan != nil {
select {
case submitChan <- struct{}{}:
default:
}
}
hx := HTMX(r)
if hx.IsHxRequest() {
hx.WriteString(`<a hx-get="/status/modal" hx-target="#modal-container" hx-swap="innerHTML">` + taskFeedback.Message + `</a>`)