-
Notifications
You must be signed in to change notification settings - Fork 26
/
ticket_list_page.go
66 lines (58 loc) · 1.46 KB
/
ticket_list_page.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package main
import (
"fmt"
ui "github.com/gizak/termui"
"strings"
)
type TicketListPage struct {
BaseListPage
}
func (p *TicketListPage) GetSelectedTicketId() string {
return strings.Split(p.cachedResults[p.selectedLine], " ")[0]
}
func (p *TicketListPage) SelectItem() {
previousPage = currentPage
currentPage = &ticketShowPage
changePage()
}
func (p *TicketListPage) GoBack() {
previousPage = currentPage
currentPage = &ticketQueryPage
changePage()
}
func (p *TicketListPage) EditTicket() {
runJiraCmdEdit(p.GetSelectedTicketId())
}
func (p *TicketListPage) CommentTicket() {
runJiraCmdComment(p.GetSelectedTicketId())
}
func (p *TicketListPage) Create(opts ...interface{}) {
ui.Clear()
var label string
var queryJQL string
var queryName string
if len(opts) > 0 {
if d, ok := opts[0].(map[string]string); ok {
label = d["label"]
}
}
ls := ui.NewList()
p.uiList = ls
p.selectedLine = 0
p.firstDisplayLine = 0
if label != "" {
queryName = ticketQueryPage.SelectedQuery().Name + "+" + label
queryJQL = ticketQueryPage.SelectedQuery().JQL + " AND labels = " + label
} else {
queryName = ticketQueryPage.SelectedQuery().Name
queryJQL = ticketQueryPage.SelectedQuery().JQL
}
p.cachedResults = JiraQueryAsStrings(queryJQL)
p.displayLines = make([]string, len(p.cachedResults))
ls.ItemFgColor = ui.ColorYellow
ls.BorderLabel = fmt.Sprintf("%s: %s", queryName, queryJQL)
ls.Height = ui.TermHeight()
ls.Width = ui.TermWidth()
ls.Y = 0
p.Update()
}