summaryrefslogtreecommitdiffstats
path: root/models/issue_label.go
diff options
context:
space:
mode:
authorLauris BH <lauris@nix.lv>2019-01-23 06:10:38 +0200
committertechknowlogick <matti@mdranta.net>2019-01-22 23:10:38 -0500
commit075649572d4472b588a8484ce3d7c37df7621f85 (patch)
tree5658dfda46b32c0686895615bceffbdac01ef4a3 /models/issue_label.go
parent6a949af8ca3aaa30f917c8ed792ae88bbaafdd75 (diff)
downloadgitea-075649572d4472b588a8484ce3d7c37df7621f85.tar.gz
gitea-075649572d4472b588a8484ce3d7c37df7621f85.zip
Add the ability to use multiple labels as filters(#5786)
Diffstat (limited to 'models/issue_label.go')
-rw-r--r--models/issue_label.go21
1 files changed, 21 insertions, 0 deletions
diff --git a/models/issue_label.go b/models/issue_label.go
index bf61fcaeca..6adb4eedcb 100644
--- a/models/issue_label.go
+++ b/models/issue_label.go
@@ -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 {