package routes import ( "fmt" "github.com/LazyBachelor/LazyPM/internal/models" "github.com/LazyBachelor/LazyPM/pkg/web/components" ) templ IssueDetailPage(issue *models.Issue, comments []*models.Comment) { {{ issueJSON, _ := templ.JSONString(issue) xData := fmt.Sprintf(`{ issue: %s, editing: null, newComment: '', get statusClass() { const classes = { 'open': 'badge-info', 'in_progress': 'badge-warning', 'blocked': 'badge-error', 'closed': 'badge-success' } return classes[this.issue.status] || 'badge-ghost' }, get priorityLabel() { const labels = ['Irrelevant', 'Low', 'Normal', 'High', 'Critical'] return labels[this.issue.priority] || 'P' + this.issue.priority }, async saveField(field, value) { const formData = new URLSearchParams() formData.append(field, value || '') const response = await fetch('/issues/' + this.issue.id, { method: 'PATCH', body: formData, headers: { 'HX-Request': 'true' } }) this.editing = null // Check if server wants to redirect back to list const redirectUrl = response.headers.get('HX-Redirect') if (redirectUrl) { window.location.href = redirectUrl } }, async addComment() { if (!this.newComment.trim()) return const author = this.issue.created_by || 'Anonymous' const formData = new URLSearchParams() formData.append('text', this.newComment) formData.append('author', author) await fetch('/issues/' + this.issue.id + '/comments', { method: 'POST', body: formData, headers: { 'HX-Request': 'true' } }) this.newComment = '' window.location.reload() } }`, issueJSON) }} @BaseLayout() {
Click to add description...
{ comment.Text }