Skip to content

Commit 6267713

Browse files
committed
Allow filtering issues by any assignee
This is the opposite of the "No assignee" filter. It will match all issues that have at least one assignee.
1 parent 2e42e96 commit 6267713

File tree

5 files changed

+13
-0
lines changed

5 files changed

+13
-0
lines changed

models/db/search.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ const (
3030
// eg: "milestone_id=-1" means "find the items without any milestone.
3131
const NoConditionID int64 = -1
3232

33+
// AnyConditionID means a condition to filter the records which match any id.
34+
// The inverse of the above NoConditionID
35+
// eg: "assignee_id=-2" means "find the issues with an assignee"
36+
const AnyConditionID int64 = -2
37+
3338
// NonExistingID means a condition to match no result (eg: a non-existing user)
3439
// It doesn't use -1 or -2 because they are used as builtin users.
3540
const NonExistingID int64 = -1000000

models/issues/issue_search.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,8 @@ func applyAssigneeCondition(sess *xorm.Session, assigneeID optional.Option[int64
359359
}
360360
if assigneeID.Value() == db.NoConditionID {
361361
sess.Where("issue.id NOT IN (SELECT issue_id FROM issue_assignees)")
362+
} else if assigneeID.Value() == db.AnyConditionID {
363+
sess.Where("issue.id IN (SELECT issue_id FROM issue_assignees)")
362364
} else {
363365
sess.Join("INNER", "issue_assignees", "issue.id = issue_assignees.issue_id").
364366
And("issue_assignees.assignee_id = ?", assigneeID.Value())

options/locale/locale_en-US.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1531,6 +1531,7 @@ issues.filter_project_none = No project
15311531
issues.filter_assignee = Assignee
15321532
issues.filter_assginee_no_select = All assignees
15331533
issues.filter_assginee_no_assignee = No assignee
1534+
issues.filter_assignee_any_assignee = Any assignee
15341535
issues.filter_poster = Author
15351536
issues.filter_user_placeholder = Search users
15361537
issues.filter_user_no_select = All users

templates/repo/issue/filter_item_user_assign.tmpl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
* TextFilterTitle
77
* TextZeroValue: the text for "all issues"
88
* TextNegativeOne: the text for "issues with no assignee"
9+
* TextNegativeTwo: the text for "issues with any assignee"
910
*/}}
1011
{{$queryLink := .QueryLink}}
1112
<div class="item ui dropdown jump {{if not .UserSearchList}}disabled{{end}}">
@@ -21,6 +22,9 @@
2122
{{if $.TextNegativeOne}}
2223
<a class="item {{if eq .SelectedUserId -1}}selected{{end}}" href="{{QueryBuild $queryLink $.QueryParamKey -1}}">{{$.TextNegativeOne}}</a>
2324
{{end}}
25+
{{if $.TextNegativeTwo}}
26+
<a class="item {{if eq .SelectedUserId -2}}selected{{end}}" href="{{QueryBuild $queryLink $.QueryParamKey -2}}">{{$.TextNegativeTwo}}</a>
27+
{{end}}
2428
<div class="divider"></div>
2529
{{range .UserSearchList}}
2630
<a class="item {{if eq $.SelectedUserId .ID}}selected{{end}}" href="{{QueryBuild $queryLink $.QueryParamKey .ID}}">

templates/repo/issue/filter_list.tmpl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@
9696
"TextFilterTitle" (ctx.Locale.Tr "repo.issues.filter_assignee")
9797
"TextZeroValue" (ctx.Locale.Tr "repo.issues.filter_assginee_no_select")
9898
"TextNegativeOne" (ctx.Locale.Tr "repo.issues.filter_assginee_no_assignee")
99+
"TextNegativeTwo" (ctx.Locale.Tr "repo.issues.filter_assignee_any_assignee")
99100
}}
100101

101102
{{if .IsSigned}}

0 commit comments

Comments
 (0)