mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-05-31 11:52:10 +00:00
Add 'Alt + click' feature to exclude labels (#8199)
Add 'Alt + click' and 'Alt +enter' feature to exclude particular labels on searching for issues.
This commit is contained in:
parent
637e3219ab
commit
dbd9d8dd54
7 changed files with 67 additions and 7 deletions
|
@ -1248,8 +1248,12 @@ func (opts *IssuesOptions) setupSession(sess *xorm.Session) {
|
|||
|
||||
if opts.LabelIDs != nil {
|
||||
for i, labelID := range opts.LabelIDs {
|
||||
sess.Join("INNER", fmt.Sprintf("issue_label il%d", i),
|
||||
fmt.Sprintf("issue.id = il%[1]d.issue_id AND il%[1]d.label_id = %[2]d", i, labelID))
|
||||
if labelID > 0 {
|
||||
sess.Join("INNER", fmt.Sprintf("issue_label il%d", i),
|
||||
fmt.Sprintf("issue.id = il%[1]d.issue_id AND il%[1]d.label_id = %[2]d", i, labelID))
|
||||
} else {
|
||||
sess.Where("issue.id not in (select issue_id from issue_label where label_id = ?)", -labelID)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -72,6 +72,7 @@ type Label struct {
|
|||
IsChecked bool `xorm:"-"`
|
||||
QueryString string `xorm:"-"`
|
||||
IsSelected bool `xorm:"-"`
|
||||
IsExcluded bool `xorm:"-"`
|
||||
}
|
||||
|
||||
// APIFormat converts a Label to the api.Label format
|
||||
|
@ -97,7 +98,10 @@ func (label *Label) LoadSelectedLabelsAfterClick(currentSelectedLabels []int64)
|
|||
for _, s := range currentSelectedLabels {
|
||||
if s == label.ID {
|
||||
labelSelected = true
|
||||
} else if s > 0 {
|
||||
} else if -s == label.ID {
|
||||
labelSelected = true
|
||||
label.IsExcluded = true
|
||||
} else if s != 0 {
|
||||
labelQuerySlice = append(labelQuerySlice, strconv.FormatInt(s, 10))
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue