]> source.dussan.org Git - gitea.git/commitdiff
Fix repository issues pagination bug when there are more than one label filter (...
authorLunny Xiao <xiaolunwen@gmail.com>
Sat, 28 Dec 2019 14:43:46 +0000 (22:43 +0800)
committerzeripath <art27@cantab.net>
Sat, 28 Dec 2019 14:43:46 +0000 (14:43 +0000)
modules/templates/helper.go
routers/repo/issue.go
templates/repo/issue/list.tmpl
templates/repo/issue/milestone_issues.tmpl

index deaa9526be8baaa40ed6d7ecd14526b489a687eb..c3c92f856bace80db4ed4e3b3eacb053ed99a7db 100644 (file)
@@ -269,6 +269,14 @@ func NewFuncMap() []template.FuncMap {
                                return ""
                        }
                },
+               "contain": func(s []int64, id int64) bool {
+                       for i := 0; i < len(s); i++ {
+                               if s[i] == id {
+                                       return true
+                               }
+                       }
+                       return false
+               },
        }}
 }
 
index 4810eecdc6fb229c702f1ae18e2858a717201eec..67c4ee3788194f200ae3f1f48ace39e1c120e2c6 100644 (file)
@@ -264,7 +264,8 @@ func issues(ctx *context.Context, milestoneID int64, isPullOption util.OptionalB
        }
 
        ctx.Data["IssueStats"] = issueStats
-       ctx.Data["SelectLabels"] = com.StrTo(selectLabels).MustInt64()
+       ctx.Data["SelLabelIDs"] = labelIDs
+       ctx.Data["SelectLabels"] = selectLabels
        ctx.Data["ViewType"] = viewType
        ctx.Data["SortType"] = sortType
        ctx.Data["MilestoneID"] = milestoneID
index 41f90b1c134cfd0fee8b6a669c85117e95849ea9..d280878f2ec20a191fef7513080c2398596c24e5 100644 (file)
                                                <div class="menu">
                                                        {{range .Labels}}
                                                                <div class="item issue-action has-emoji" data-action="toggle" data-element-id="{{.ID}}" data-url="{{$.RepoLink}}/issues/labels">
-                                                                       <span class="octicon {{if eq $.SelectLabels .ID}}octicon-check{{end}}"></span><span class="label color" style="background-color: {{.Color}}"></span> {{.Name}}
+                                                                       <span class="octicon {{if contain $.SelLabelIDs .ID}}octicon-check{{end}}"></span><span class="label color" style="background-color: {{.Color}}"></span> {{.Name}}
                                                                </div>
                                                        {{end}}
                                                </div>
index ad3f0b5c8625b5943380972df294146db0d496b3..fb0609601ca4f412326f489876a920fa447f5a34 100644 (file)
@@ -61,7 +61,7 @@
                                                        <span class="info">{{.i18n.Tr "repo.issues.filter_label_exclude" | Safe}}</span>
                                                        <a class="item" href="{{$.Link}}?q={{$.Keyword}}&type={{$.ViewType}}&sort={{$.SortType}}&state={{$.State}}&assignee={{$.AssigneeID}}">{{.i18n.Tr "repo.issues.filter_label_no_select"}}</a>
                                                        {{range .Labels}}
-                                                               <a class="item has-emoji label-filter-item" href="{{$.Link}}?q={{$.Keyword}}&type={{$.ViewType}}&sort={{$.SortType}}&state={{$.State}}&labels={{.ID}}&assignee={{$.AssigneeID}}" data-label-id="{{.ID}}"><span class="octicon {{if .IsExcluded}}octicon-circle-slash{{else if eq $.SelectLabels .ID}}octicon-check{{end}}"></span><span class="label color" style="background-color: {{.Color}}"></span> {{.Name}}</a>
+                                                               <a class="item has-emoji label-filter-item" href="{{$.Link}}?q={{$.Keyword}}&type={{$.ViewType}}&sort={{$.SortType}}&state={{$.State}}&labels={{.ID}}&assignee={{$.AssigneeID}}" data-label-id="{{.ID}}"><span class="octicon {{if .IsExcluded}}octicon-circle-slash{{else if contain $.SelLabelIDs .ID}}octicon-check{{end}}"></span><span class="label color" style="background-color: {{.Color}}"></span> {{.Name}}</a>
                                                        {{end}}
                                                </div>
                                        </div>
                                                <div class="menu">
                                                        {{range .Labels}}
                                                                <div class="item issue-action has-emoji" data-action="toggle" data-element-id="{{.ID}}" data-url="{{$.RepoLink}}/issues/labels">
-                                                                       <span class="octicon {{if eq $.SelectLabels .ID}}octicon-check{{end}}"></span><span class="label color" style="background-color: {{.Color}}"></span> {{.Name}}
+                                                                       <span class="octicon {{if contain $.SelLabelIDs .ID}}octicon-check{{end}}"></span><span class="label color" style="background-color: {{.Color}}"></span> {{.Name}}
                                                                </div>
                                                        {{end}}
                                                </div>