FIXED COMMENTS. TASK BACKLOG REFINEMENT ISSUE

This commit is contained in:
Ine Maria Nilssen Aanonsen
2026-03-06 21:04:58 +01:00
parent 68054f7409
commit e64950879d
25 changed files with 51 additions and 37 deletions

View File

@@ -2,6 +2,7 @@ package handler
import (
"context"
"html"
"net/http"
"strings"
@@ -219,11 +220,18 @@ func CloseIssue(w http.ResponseWriter, r *http.Request) {
return
}
issue := r.Context().Value(issueKey).(*models.Issue)
issueVal := r.Context().Value(issueKey)
issue, ok := issueVal.(*models.Issue)
if !ok || issue == nil {
http.Error(w, "Issue not found in context", http.StatusInternalServerError)
return
}
closeReason := r.FormValue("close_reason")
if closeReason == "" {
if HTMX(r).IsHxRequest() {
w.WriteHeader(http.StatusBadRequest)
HTMX(r).WriteString("<div class=\"alert alert-error\">Closing reason is required</div>")
} else {
http.Error(w, "Closing reason is required", http.StatusBadRequest)
@@ -233,7 +241,8 @@ func CloseIssue(w http.ResponseWriter, r *http.Request) {
if err := App(r).Issues.CloseIssue(r.Context(), issue.ID, closeReason, "web", ""); err != nil {
if HTMX(r).IsHxRequest() {
HTMX(r).WriteString("<div class=\"alert alert-error\">Failed to close issue: " + err.Error() + "</div>")
w.WriteHeader(http.StatusInternalServerError)
HTMX(r).WriteString("<div class=\"alert alert-error\">Failed to close issue: " + html.EscapeString(err.Error()) + "</div>")
} else {
http.Error(w, "Failed to close issue: "+err.Error(), http.StatusInternalServerError)
}

View File

@@ -26,9 +26,9 @@ func CreateIssueFormModal(w http.ResponseWriter, r *http.Request) {
}
func EditIssueFormModal(w http.ResponseWriter, r *http.Request) {
issue := r.Context().Value(issueKey).(*models.Issue)
if issue == nil {
issueVal := r.Context().Value(issueKey)
issue, ok := issueVal.(*models.Issue)
if !ok || issue == nil {
http.Error(w, "Issue not found in context", http.StatusInternalServerError)
return
}
@@ -52,9 +52,9 @@ func EditIssueFormModal(w http.ResponseWriter, r *http.Request) {
}
func AssigneeFormModal(w http.ResponseWriter, r *http.Request) {
issue := r.Context().Value(issueKey).(*models.Issue)
if issue == nil {
issueVal := r.Context().Value(issueKey)
issue, ok := issueVal.(*models.Issue)
if !ok || issue == nil {
http.Error(w, "Issue not found in context", http.StatusInternalServerError)
return
}
@@ -74,9 +74,9 @@ func AssigneeFormModal(w http.ResponseWriter, r *http.Request) {
}
func CloseIssueFormModal(w http.ResponseWriter, r *http.Request) {
issue := r.Context().Value(issueKey).(*models.Issue)
if issue == nil {
issueVal := r.Context().Value(issueKey)
issue, ok := issueVal.(*models.Issue)
if !ok || issue == nil {
http.Error(w, "Issue not found in context", http.StatusInternalServerError)
return
}