Implemented add comments for tui
This commit is contained in:
@@ -47,6 +47,9 @@ type Model struct {
|
||||
priorityIssueID string
|
||||
choosingType bool // true while choosing a type
|
||||
typeIssueID string
|
||||
addingComment bool // true while adding a comment
|
||||
commentInput textarea.Model
|
||||
commentIssueID string
|
||||
feedbackChan chan models.ValidationFeedback
|
||||
quitChan chan bool
|
||||
currentFeedback models.ValidationFeedback
|
||||
@@ -89,15 +92,39 @@ func NewDashboard(app *app.App, feedbackChan chan models.ValidationFeedback, qui
|
||||
descTa.SetHeight(8)
|
||||
m.descriptionInput = descTa
|
||||
|
||||
commentTa := textarea.New()
|
||||
commentTa.Placeholder = "Write your comment..."
|
||||
commentTa.SetWidth(56)
|
||||
commentTa.SetHeight(6)
|
||||
m.commentInput = commentTa
|
||||
|
||||
if selected := m.issueList.SelectedItem(); selected.ID != "" {
|
||||
m.issueDetail.SetIssue(selected.Issue)
|
||||
m.setDetailIssueWithComments(selected.Issue)
|
||||
} else if selected := m.closedIssueList.SelectedItem(); selected.ID != "" {
|
||||
m.issueDetail.SetIssue(selected.Issue)
|
||||
m.setDetailIssueWithComments(selected.Issue)
|
||||
}
|
||||
|
||||
return m
|
||||
}
|
||||
|
||||
// setDetailIssueWithComments sets the issue in the detail pane and loads its comments.
|
||||
func (m *Model) setDetailIssueWithComments(issue models.Issue) {
|
||||
m.issueDetail.SetIssue(issue)
|
||||
if issue.ID == "" {
|
||||
m.issueDetail.SetComments(nil)
|
||||
return
|
||||
}
|
||||
comments, _ := m.app.Issues.GetIssueComments(context.Background(), issue.ID)
|
||||
m.issueDetail.SetComments(comments)
|
||||
}
|
||||
|
||||
func (m *Model) startAddComment(selected ListIssue) {
|
||||
m.addingComment = true
|
||||
m.commentIssueID = selected.ID
|
||||
m.commentInput.SetValue("")
|
||||
m.commentInput.Reset()
|
||||
}
|
||||
|
||||
func (m *Model) startEditTitle(selected ListIssue) {
|
||||
m.editingTitle = true
|
||||
m.editingIssueID = selected.ID
|
||||
@@ -203,11 +230,11 @@ func (m *Model) ToggleFocusedWindow() {
|
||||
m.focusedWindow = 1 - m.focusedWindow
|
||||
if m.focusedWindow == 0 {
|
||||
if selected := m.issueList.SelectedItem(); selected.ID != "" {
|
||||
m.issueDetail.SetIssue(selected.Issue)
|
||||
m.setDetailIssueWithComments(selected.Issue)
|
||||
}
|
||||
} else {
|
||||
if selected := m.closedIssueList.SelectedItem(); selected.ID != "" {
|
||||
m.issueDetail.SetIssue(selected.Issue)
|
||||
m.setDetailIssueWithComments(selected.Issue)
|
||||
}
|
||||
}
|
||||
m.issueDetail.SetFocused(m.IsFocusedOnDetail())
|
||||
|
||||
Reference in New Issue
Block a user