add ability to change assingee

This commit is contained in:
Robin Olsen
2026-02-25 13:20:30 +01:00
parent 6264f9dfc9
commit 44e894f025
12 changed files with 219 additions and 57 deletions

View File

@@ -186,6 +186,30 @@ func UpdateIssue(w http.ResponseWriter, r *http.Request) {
hx.WriteJSON(issue)
}
func UpdateAssignee(w http.ResponseWriter, r *http.Request) {
issue := r.Context().Value(issueKey).(*models.Issue)
assignee := r.FormValue("assignee")
if err := App(r).Issues.UpdateIssue(r.Context(), issue.ID, map[string]any{"assignee": assignee}, ""); err != nil {
http.Error(w, "Failed to update assignee", http.StatusInternalServerError)
return
}
issue, err := App(r).Issues.GetIssue(r.Context(), issue.ID)
if err != nil {
http.Error(w, "Failed to retrieve updated issue", http.StatusInternalServerError)
return
}
if HTMX(r).IsHxRequest() {
w.Header().Set("HX-Refresh", "true")
return
}
w.Header().Set("Content-Type", "application/json")
HTMX(r).WriteJSON(issue)
}
func DeleteIssue(w http.ResponseWriter, r *http.Request) {
issue := r.Context().Value(issueKey).(*models.Issue)
@@ -195,7 +219,7 @@ func DeleteIssue(w http.ResponseWriter, r *http.Request) {
}
if HTMX(r).IsHxRequest() {
w.Header().Set("HX-Redirect", "/")
w.Header().Set("HX-Refresh", "true")
return
}

View File

@@ -50,3 +50,25 @@ func EditIssueFormModal(w http.ResponseWriter, r *http.Request) {
})
modal.Render(r.Context(), w)
}
func AssigneeFormModal(w http.ResponseWriter, r *http.Request) {
issue := r.Context().Value(issueKey).(*models.Issue)
if issue == nil {
http.Error(w, "Issue not found in context", http.StatusInternalServerError)
return
}
modalContent := components.AssigneeForm(components.AssigneeFormProps{
PatchAction: "/issues/" + issue.ID + "/assignee",
Assignee: issue.Assignee,
})
modal := components.Modal(components.ModalProps{
ID: "assignee-modal",
Title: "Change Assignee",
Content: modalContent,
Open: true,
})
modal.Render(r.Context(), w)
}