@@ -11,6 +11,7 @@ import (
1111
1212 "code.gitea.io/gitea/models/db"
1313 issues_model "code.gitea.io/gitea/models/issues"
14+ org_model "code.gitea.io/gitea/models/organization"
1415 project_model "code.gitea.io/gitea/models/project"
1516 attachment_model "code.gitea.io/gitea/models/repo"
1617 "code.gitea.io/gitea/models/unit"
@@ -333,7 +334,29 @@ func ViewProject(ctx *context.Context) {
333334 return
334335 }
335336
336- issuesMap , err := issues_model .LoadIssuesFromColumnList (ctx , columns )
337+ var labelIDs []int64
338+ // 1,-2 means including label 1 and excluding label 2
339+ // 0 means issues with no label
340+ // blank means labels will not be filtered for issues
341+ selectLabels := ctx .FormString ("labels" )
342+ if selectLabels == "" {
343+ ctx .Data ["AllLabels" ] = true
344+ } else if selectLabels == "0" {
345+ ctx .Data ["NoLabel" ] = true
346+ }
347+ if len (selectLabels ) > 0 {
348+ labelIDs , err = base .StringsToInt64s (strings .Split (selectLabels , "," ))
349+ if err != nil {
350+ ctx .Flash .Error (ctx .Tr ("invalid_data" , selectLabels ), true )
351+ }
352+ }
353+
354+ assigneeID := ctx .FormInt64 ("assignee" )
355+
356+ issuesMap , err := issues_model .LoadIssuesFromColumnList (ctx , columns , & issues_model.IssuesOptions {
357+ LabelIDs : labelIDs ,
358+ AssigneeID : assigneeID ,
359+ })
337360 if err != nil {
338361 ctx .ServerError ("LoadIssuesOfColumns" , err )
339362 return
@@ -372,6 +395,46 @@ func ViewProject(ctx *context.Context) {
372395 }
373396 }
374397
398+ // TODO: Add option to filter also by repository specific labels
399+ labels , err := issues_model .GetLabelsByOrgID (ctx , project .OwnerID , "" , db.ListOptions {})
400+ if err != nil {
401+ ctx .ServerError ("GetLabelsByOrgID" , err )
402+ return
403+ }
404+
405+ // Get the exclusive scope for every label ID
406+ labelExclusiveScopes := make ([]string , 0 , len (labelIDs ))
407+ for _ , labelID := range labelIDs {
408+ foundExclusiveScope := false
409+ for _ , label := range labels {
410+ if label .ID == labelID || label .ID == - labelID {
411+ labelExclusiveScopes = append (labelExclusiveScopes , label .ExclusiveScope ())
412+ foundExclusiveScope = true
413+ break
414+ }
415+ }
416+ if ! foundExclusiveScope {
417+ labelExclusiveScopes = append (labelExclusiveScopes , "" )
418+ }
419+ }
420+
421+ for _ , l := range labels {
422+ l .LoadSelectedLabelsAfterClick (labelIDs , labelExclusiveScopes )
423+ }
424+ ctx .Data ["Labels" ] = labels
425+ ctx .Data ["NumLabels" ] = len (labels )
426+
427+ // Get assignees.
428+ assigneeUsers , err := org_model .GetOrgAssignees (ctx , project .OwnerID )
429+ if err != nil {
430+ ctx .ServerError ("GetRepoAssignees" , err )
431+ return
432+ }
433+ ctx .Data ["Assignees" ] = shared_user .MakeSelfOnTop (ctx .Doer , assigneeUsers )
434+
435+ ctx .Data ["SelectLabels" ] = selectLabels
436+ ctx .Data ["AssigneeID" ] = assigneeID
437+
375438 project .RenderedContent = templates .RenderMarkdownToHtml (ctx , project .Description )
376439 ctx .Data ["LinkedPRs" ] = linkedPrsMap
377440 ctx .Data ["PageIsViewProjects" ] = true
0 commit comments