Merge branch 'WEB---ADD-COMMENTS-ON-ISSUES' of https://github.com/LazyBachelor/LazyPM into WEB---ADD-COMMENTS-ON-ISSUES

This commit is contained in:
Ine Maria Nilssen Aanonsen
2026-02-20 17:04:20 +01:00
2 changed files with 24 additions and 3 deletions

View File

@@ -53,7 +53,9 @@ func (s *BeadsService) DeleteIssues() error {
} }
func (s *BeadsService) GetComments(ctx context.Context, issueID string) ([]models.Comment, error) { func (s *BeadsService) GetComments(ctx context.Context, issueID string) ([]models.Comment, error) {
commentsPtr, err := s.Storage.GetIssueComments(ctx, issueID) query := `SELECT id, issue_id, author, text, created_at FROM comments WHERE issue_id = ? ORDER BY created_at ASC LIMIT 100`
rows, err := s.UnderlyingDB().QueryContext(ctx, query, issueID)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@@ -73,5 +75,24 @@ func (s *BeadsService) GetComments(ctx context.Context, issueID string) ([]model
} }
func (s *BeadsService) AddComment(ctx context.Context, issueID, author, text string) (*models.Comment, error) { func (s *BeadsService) AddComment(ctx context.Context, issueID, author, text string) (*models.Comment, error) {
return s.Storage.AddIssueComment(ctx, issueID, author, text) query := `INSERT INTO comments (issue_id, author, text, created_at) VALUES (?, ?, ?, ?)`
createdAt := time.Now().UTC()
result, err := s.UnderlyingDB().ExecContext(ctx, query, issueID, author, text, createdAt)
if err != nil {
return nil, err
}
id, err := result.LastInsertId()
if err != nil {
return nil, err
}
return &models.Comment{
ID: id,
IssueID: issueID,
Author: author,
Text: text,
CreatedAt: createdAt,
}, nil
} }

View File

@@ -75,7 +75,7 @@ templ CommentForm(props CommentFormProps) {
hx-post={ "/issues/" + props.IssueID + "/comments" } hx-post={ "/issues/" + props.IssueID + "/comments" }
hx-target="#comments-list" hx-target="#comments-list"
hx-swap="beforeend" hx-swap="beforeend"
hx-on::after-request="this.reset()" hx-on::after-success="this.reset()"
> >
@base.Input(base.InputProps{ @base.Input(base.InputProps{
Name: "author", Name: "author",