1
0
mirror of https://github.com/go-gitea/gitea.git synced 2025-02-02 15:09:33 -05:00

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.
This commit is contained in:
Andreas Svanberg 2025-01-21 14:32:49 +01:00
parent 2e42e96ce2
commit 6267713f9f
No known key found for this signature in database
GPG Key ID: 2D081222BBEB56A3
5 changed files with 13 additions and 0 deletions

View File

@ -30,6 +30,11 @@ const (
// eg: "milestone_id=-1" means "find the items without any milestone.
const NoConditionID int64 = -1
// AnyConditionID means a condition to filter the records which match any id.
// The inverse of the above NoConditionID
// eg: "assignee_id=-2" means "find the issues with an assignee"
const AnyConditionID int64 = -2
// NonExistingID means a condition to match no result (eg: a non-existing user)
// It doesn't use -1 or -2 because they are used as builtin users.
const NonExistingID int64 = -1000000

View File

@ -359,6 +359,8 @@ func applyAssigneeCondition(sess *xorm.Session, assigneeID optional.Option[int64
}
if assigneeID.Value() == db.NoConditionID {
sess.Where("issue.id NOT IN (SELECT issue_id FROM issue_assignees)")
} else if assigneeID.Value() == db.AnyConditionID {
sess.Where("issue.id IN (SELECT issue_id FROM issue_assignees)")
} else {
sess.Join("INNER", "issue_assignees", "issue.id = issue_assignees.issue_id").
And("issue_assignees.assignee_id = ?", assigneeID.Value())

View File

@ -1531,6 +1531,7 @@ issues.filter_project_none = No project
issues.filter_assignee = Assignee
issues.filter_assginee_no_select = All assignees
issues.filter_assginee_no_assignee = No assignee
issues.filter_assignee_any_assignee = Any assignee
issues.filter_poster = Author
issues.filter_user_placeholder = Search users
issues.filter_user_no_select = All users

View File

@ -6,6 +6,7 @@
* TextFilterTitle
* TextZeroValue: the text for "all issues"
* TextNegativeOne: the text for "issues with no assignee"
* TextNegativeTwo: the text for "issues with any assignee"
*/}}
{{$queryLink := .QueryLink}}
<div class="item ui dropdown jump {{if not .UserSearchList}}disabled{{end}}">
@ -21,6 +22,9 @@
{{if $.TextNegativeOne}}
<a class="item {{if eq .SelectedUserId -1}}selected{{end}}" href="{{QueryBuild $queryLink $.QueryParamKey -1}}">{{$.TextNegativeOne}}</a>
{{end}}
{{if $.TextNegativeTwo}}
<a class="item {{if eq .SelectedUserId -2}}selected{{end}}" href="{{QueryBuild $queryLink $.QueryParamKey -2}}">{{$.TextNegativeTwo}}</a>
{{end}}
<div class="divider"></div>
{{range .UserSearchList}}
<a class="item {{if eq $.SelectedUserId .ID}}selected{{end}}" href="{{QueryBuild $queryLink $.QueryParamKey .ID}}">

View File

@ -96,6 +96,7 @@
"TextFilterTitle" (ctx.Locale.Tr "repo.issues.filter_assignee")
"TextZeroValue" (ctx.Locale.Tr "repo.issues.filter_assginee_no_select")
"TextNegativeOne" (ctx.Locale.Tr "repo.issues.filter_assginee_no_assignee")
"TextNegativeTwo" (ctx.Locale.Tr "repo.issues.filter_assignee_any_assignee")
}}
{{if .IsSigned}}