add edit issue button and modal

This commit is contained in:
Robin Olsen
2026-02-25 11:53:56 +01:00
parent f28ab4be78
commit 87d4cdae3f
14 changed files with 233 additions and 135 deletions

View File

@@ -6,6 +6,7 @@ import (
"strings"
"github.com/LazyBachelor/LazyPM/internal/models"
"github.com/LazyBachelor/LazyPM/pkg/web/components"
"github.com/LazyBachelor/LazyPM/pkg/web/routes"
"github.com/go-chi/chi/v5"
)
@@ -49,7 +50,7 @@ func CreateIssue(w http.ResponseWriter, r *http.Request) {
}
issue := form.toIssue()
if err := app.Issues.CreateIssue(r.Context(), &issue, ""); err != nil {
if err := app.Issues.CreateIssue(r.Context(), &issue, "Me"); err != nil {
http.Error(w, "Failed to create issue: "+err.Error(), http.StatusInternalServerError)
return
}
@@ -170,6 +171,17 @@ func UpdateIssue(w http.ResponseWriter, r *http.Request) {
return
}
if hx.IsHxRequest() {
w.Header().Set("HX-Trigger", `{"closeModal": "edit-issue-modal", "issueUpdated": "`+issue.ID+`"}`)
w.Header().Set("HX-Retarget", "#issue-detail-container")
w.Header().Set("HX-Reswap", "innerHTML")
components.IssueDetail(components.IssueDetailProps{
Issue: issue,
}).Render(r.Context(), w)
return
}
w.Header().Set("Content-Type", "application/json")
hx.WriteJSON(issue)
}