mirror of
https://github.com/go-gitea/gitea
synced 2025-07-22 18:28:37 +00:00
Add the ability to use multiple labels as filters(#5786)
This commit is contained in:
committed by
techknowlogick
parent
6a949af8ca
commit
075649572d
@@ -69,6 +69,8 @@ type Label struct {
|
||||
NumClosedIssues int
|
||||
NumOpenIssues int `xorm:"-"`
|
||||
IsChecked bool `xorm:"-"`
|
||||
QueryString string
|
||||
IsSelected bool
|
||||
}
|
||||
|
||||
// APIFormat converts a Label to the api.Label format
|
||||
@@ -85,6 +87,25 @@ func (label *Label) CalOpenIssues() {
|
||||
label.NumOpenIssues = label.NumIssues - label.NumClosedIssues
|
||||
}
|
||||
|
||||
// LoadSelectedLabelsAfterClick calculates the set of selected labels when a label is clicked
|
||||
func (label *Label) LoadSelectedLabelsAfterClick(currentSelectedLabels []int64) {
|
||||
var labelQuerySlice []string
|
||||
labelSelected := false
|
||||
labelID := strconv.FormatInt(label.ID, 10)
|
||||
for _, s := range currentSelectedLabels {
|
||||
if s == label.ID {
|
||||
labelSelected = true
|
||||
} else if s > 0 {
|
||||
labelQuerySlice = append(labelQuerySlice, strconv.FormatInt(s, 10))
|
||||
}
|
||||
}
|
||||
if !labelSelected {
|
||||
labelQuerySlice = append(labelQuerySlice, labelID)
|
||||
}
|
||||
label.IsSelected = labelSelected
|
||||
label.QueryString = strings.Join(labelQuerySlice, ",")
|
||||
}
|
||||
|
||||
// ForegroundColor calculates the text color for labels based
|
||||
// on their background color.
|
||||
func (label *Label) ForegroundColor() template.CSS {
|
||||
|
Reference in New Issue
Block a user