open same details page from board view; make assignee button more obvious
This commit is contained in:
@@ -20,6 +20,27 @@ func DashboardHandler(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
// Check if board view is requested
|
||||
isBoardView := r.URL.Query().Get("board") == "true"
|
||||
|
||||
if isBoardView {
|
||||
boardProps := routes.BoardViewProps{
|
||||
BaseURL: "/?board=true",
|
||||
QueryParam: query,
|
||||
Issues: issues,
|
||||
EmptyText: "No issues found",
|
||||
}
|
||||
|
||||
if hx.IsHxRequest() {
|
||||
routes.BoardViewContent(boardProps).Render(r.Context(), w)
|
||||
return
|
||||
}
|
||||
|
||||
routes.BoardView(boardProps).Render(r.Context(), w)
|
||||
return
|
||||
}
|
||||
|
||||
// Regular dashboard view
|
||||
var selectedIssue *models.Issue
|
||||
if len(issues) > 0 {
|
||||
selectedIssue = issues[0]
|
||||
|
||||
@@ -56,7 +56,16 @@ func CreateIssue(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
if hx.IsHxRequest() {
|
||||
w.Header().Set("HX-Refresh", "true")
|
||||
// Check if 'from' parameter says board view
|
||||
from := r.URL.Query().Get("from")
|
||||
referer := r.Header.Get("Referer")
|
||||
boardView := from == "board" || strings.Contains(referer, "board=true")
|
||||
|
||||
if boardView {
|
||||
w.Header().Set("HX-Redirect", "/?board=true")
|
||||
} else {
|
||||
w.Header().Set("HX-Redirect", "/?selected-issue="+issue.ID)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@@ -111,19 +120,20 @@ func GetIssue(w http.ResponseWriter, r *http.Request) {
|
||||
comments := r.Context().Value(commentsKey).([]*models.Comment)
|
||||
hx := HTMX(r)
|
||||
|
||||
from := r.URL.Query().Get("from")
|
||||
detailProps := routes.IssueDetailProps{
|
||||
Issue: issue,
|
||||
Comments: comments,
|
||||
From: from,
|
||||
}
|
||||
|
||||
if !hx.IsHxRequest() && strings.Contains(r.Header.Get("Accept"), "text/html") {
|
||||
routes.IssueDetail(routes.IssueDetailProps{
|
||||
Issue: issue,
|
||||
Comments: comments,
|
||||
}).Render(r.Context(), w)
|
||||
routes.IssueDetail(detailProps).Render(r.Context(), w)
|
||||
return
|
||||
}
|
||||
|
||||
if hx.IsHxRequest() {
|
||||
routes.IssueDetailContent(routes.IssueDetailProps{
|
||||
Issue: issue,
|
||||
Comments: comments,
|
||||
}).Render(r.Context(), w)
|
||||
routes.IssueDetailContent(detailProps).Render(r.Context(), w)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -165,7 +175,16 @@ func UpdateIssue(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
if hx.IsHxRequest() {
|
||||
w.Header().Set("HX-Refresh", "true")
|
||||
// Check if 'from' parameter says board view
|
||||
from := r.URL.Query().Get("from")
|
||||
referer := r.Header.Get("Referer")
|
||||
boardView := from == "board" || strings.Contains(referer, "board=true")
|
||||
|
||||
if boardView {
|
||||
w.Header().Set("HX-Redirect", "/?board=true")
|
||||
} else {
|
||||
w.Header().Set("HX-Redirect", "/?selected-issue="+issue.ID)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@@ -189,7 +208,15 @@ func UpdateAssignee(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
if HTMX(r).IsHxRequest() {
|
||||
w.Header().Set("HX-Refresh", "true")
|
||||
// Check if we're in board view
|
||||
referer := r.Header.Get("Referer")
|
||||
boardView := strings.Contains(referer, "board=true")
|
||||
|
||||
if boardView {
|
||||
w.Header().Set("HX-Redirect", "/?board=true&selected-issue="+issue.ID)
|
||||
} else {
|
||||
w.Header().Set("HX-Redirect", "/?selected-issue="+issue.ID)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@@ -206,7 +233,16 @@ func DeleteIssue(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
if HTMX(r).IsHxRequest() {
|
||||
w.Header().Set("HX-Redirect", "/")
|
||||
// Check if 'from' parameter indicates board view
|
||||
from := r.URL.Query().Get("from")
|
||||
referer := r.Header.Get("Referer")
|
||||
boardView := from == "board" || strings.Contains(referer, "board=true")
|
||||
|
||||
if boardView {
|
||||
w.Header().Set("HX-Redirect", "/?board=true")
|
||||
} else {
|
||||
w.Header().Set("HX-Redirect", "/")
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -8,8 +8,15 @@ import (
|
||||
)
|
||||
|
||||
func CreateIssueFormModal(w http.ResponseWriter, r *http.Request) {
|
||||
// Get the 'from' parameter to track where the user came from
|
||||
from := r.URL.Query().Get("from")
|
||||
postAction := "/issues"
|
||||
if from != "" {
|
||||
postAction += "?from=" + from
|
||||
}
|
||||
|
||||
modalContent := components.IssueForm(components.IssueFormProps{
|
||||
PostAction: "/issues",
|
||||
PostAction: postAction,
|
||||
Status: "open",
|
||||
IssueType: "task",
|
||||
Priority: 0,
|
||||
@@ -33,13 +40,23 @@ func EditIssueFormModal(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
// Get the 'from' parameter to track where the user came from
|
||||
from := r.URL.Query().Get("from")
|
||||
patchAction := "/issues/" + issue.ID
|
||||
deleteAction := "/issues/" + issue.ID + "/delete"
|
||||
if from != "" {
|
||||
patchAction += "?from=" + from
|
||||
deleteAction += "?from=" + from
|
||||
}
|
||||
|
||||
modalContent := components.IssueForm(components.IssueFormProps{
|
||||
PatchAction: "/issues/" + issue.ID,
|
||||
Title: issue.Title,
|
||||
Description: issue.Description,
|
||||
Status: string(issue.Status),
|
||||
IssueType: string(issue.IssueType),
|
||||
Priority: issue.Priority,
|
||||
PatchAction: patchAction,
|
||||
DeleteAction: deleteAction,
|
||||
Title: issue.Title,
|
||||
Description: issue.Description,
|
||||
Status: string(issue.Status),
|
||||
IssueType: string(issue.IssueType),
|
||||
Priority: issue.Priority,
|
||||
})
|
||||
|
||||
modal := components.Modal(components.ModalProps{
|
||||
@@ -72,3 +89,31 @@ func AssigneeFormModal(w http.ResponseWriter, r *http.Request) {
|
||||
})
|
||||
modal.Render(r.Context(), w)
|
||||
}
|
||||
|
||||
func DeleteIssueConfirmModal(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
|
||||
}
|
||||
|
||||
// Get the 'from' parameter to track where the user came from
|
||||
from := r.URL.Query().Get("from")
|
||||
deleteAction := "/issues/" + issue.ID
|
||||
if from != "" {
|
||||
deleteAction += "?from=" + from
|
||||
}
|
||||
|
||||
confirmModal := components.ConfirmModal(components.ConfirmModalProps{
|
||||
Title: "Delete Issue",
|
||||
Message: "Are you sure you want to delete this issue? This action cannot be undone.",
|
||||
ConfirmText: "Delete Issue",
|
||||
CancelText: "Cancel",
|
||||
ConfirmAction: deleteAction,
|
||||
ConfirmClass: "btn-error",
|
||||
IssueID: issue.ID,
|
||||
})
|
||||
|
||||
confirmModal.Render(r.Context(), w)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user