89 lines
2.0 KiB
Plaintext
89 lines
2.0 KiB
Plaintext
package routes
|
|
|
|
import (
|
|
"github.com/LazyBachelor/LazyPM/internal/models"
|
|
"github.com/LazyBachelor/LazyPM/pkg/web/components"
|
|
)
|
|
|
|
type IssueDetailProps struct {
|
|
Issue *models.Issue
|
|
Comments []*models.Comment
|
|
From string // "board" when navigating from board view
|
|
}
|
|
|
|
type IssueDetailModalProps struct {
|
|
Issue *models.Issue
|
|
Comments []*models.Comment
|
|
From string
|
|
}
|
|
|
|
templ IssueDetailContent(props IssueDetailProps) {
|
|
{{
|
|
backURL := "/"
|
|
editURL := "/issues/" + props.Issue.ID + "/edit"
|
|
if props.From == "board" {
|
|
backURL = "/?board=true"
|
|
editURL += "?from=board"
|
|
}
|
|
}}
|
|
<div class="max-w-2xl mx-auto">
|
|
<div class="mb-4">
|
|
<a
|
|
class="btn btn-ghost btn-sm"
|
|
hx-get={ backURL }
|
|
hx-target="main"
|
|
hx-swap="innerHTML"
|
|
hx-push-url="true"
|
|
>
|
|
@components.IconBack()
|
|
Back to Issues
|
|
</a>
|
|
<button
|
|
type="button"
|
|
class="btn btn-primary btn-sm"
|
|
hx-get={ editURL }
|
|
hx-target="#modal-container"
|
|
hx-swap="innerHTML"
|
|
>
|
|
Edit
|
|
</button>
|
|
if props.Issue.Status != "closed" {
|
|
<button
|
|
type="button"
|
|
class="btn btn-warning btn-sm btn-outline"
|
|
hx-get={ "/issues/" + props.Issue.ID + "/close" }
|
|
hx-target="#modal-container"
|
|
hx-swap="innerHTML"
|
|
>
|
|
Close issue
|
|
</button>
|
|
}
|
|
</div>
|
|
<div id="issue-detail-container" class="mb-6">
|
|
@components.IssueDetail(components.IssueDetailProps{Issue: props.Issue})
|
|
</div>
|
|
@components.CommentSection(components.CommentSectionProps{
|
|
IssueID: props.Issue.ID,
|
|
Comments: props.Comments,
|
|
})
|
|
</div>
|
|
}
|
|
|
|
templ IssueDetail(props IssueDetailProps) {
|
|
@BaseLayout() {
|
|
@IssueDetailContent(props)
|
|
}
|
|
}
|
|
|
|
templ IssueDetailModalContent(props IssueDetailModalProps) {
|
|
<div class="w-full">
|
|
<div id="issue-detail-container" class="mb-6">
|
|
@components.IssueDetail(components.IssueDetailProps{Issue: props.Issue})
|
|
</div>
|
|
@components.CommentSection(components.CommentSectionProps{
|
|
IssueID: props.Issue.ID,
|
|
Comments: props.Comments,
|
|
})
|
|
</div>
|
|
}
|