Skip to content

Commit e6dbb0e

Browse files
committed
Fix template bug
1 parent 8fe5478 commit e6dbb0e

File tree

3 files changed

+21
-18
lines changed

3 files changed

+21
-18
lines changed

models/issue_project.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,16 +94,16 @@ func LoadIssuesFromBoard(b *project_model.Board) (IssueList, error) {
9494
}
9595

9696
// LoadIssuesFromBoardList load issues assigned to the boards
97-
func LoadIssuesFromBoardList(bs project_model.BoardList) (IssueList, error) {
98-
issues := make(IssueList, 0, len(bs)*10)
97+
func LoadIssuesFromBoardList(bs project_model.BoardList) (map[int64]IssueList, error) {
98+
issuesMap := make(map[int64]IssueList, len(bs))
9999
for i := range bs {
100100
il, err := LoadIssuesFromBoard(bs[i])
101101
if err != nil {
102102
return nil, err
103103
}
104-
issues = append(issues, il...)
104+
issuesMap[bs[i].ID] = il
105105
}
106-
return issues, nil
106+
return issuesMap, nil
107107
}
108108

109109
// ChangeProjectAssign changes the project associated with an issue

routers/web/repo/projects.go

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -296,27 +296,29 @@ func ViewProject(ctx *context.Context) {
296296
boards[0].Title = ctx.Tr("repo.projects.type.uncategorized")
297297
}
298298

299-
issueList, err := models.LoadIssuesFromBoardList(boards)
299+
issuesMap, err := models.LoadIssuesFromBoardList(boards)
300300
if err != nil {
301301
ctx.ServerError("LoadIssuesOfBoards", err)
302302
return
303303
}
304304

305305
linkedPrsMap := make(map[int64][]*models.Issue)
306-
for _, issue := range issueList {
307-
var referencedIds []int64
308-
for _, comment := range issue.Comments {
309-
if comment.RefIssueID != 0 && comment.RefIsPull {
310-
referencedIds = append(referencedIds, comment.RefIssueID)
306+
for _, issuesList := range issuesMap {
307+
for _, issue := range issuesList {
308+
var referencedIds []int64
309+
for _, comment := range issue.Comments {
310+
if comment.RefIssueID != 0 && comment.RefIsPull {
311+
referencedIds = append(referencedIds, comment.RefIssueID)
312+
}
311313
}
312-
}
313314

314-
if len(referencedIds) > 0 {
315-
if linkedPrs, err := models.Issues(&models.IssuesOptions{
316-
IssueIDs: referencedIds,
317-
IsPull: util.OptionalBoolTrue,
318-
}); err == nil {
319-
linkedPrsMap[issue.ID] = linkedPrs
315+
if len(referencedIds) > 0 {
316+
if linkedPrs, err := models.Issues(&models.IssuesOptions{
317+
IssueIDs: referencedIds,
318+
IsPull: util.OptionalBoolTrue,
319+
}); err == nil {
320+
linkedPrsMap[issue.ID] = linkedPrs
321+
}
320322
}
321323
}
322324
}
@@ -336,6 +338,7 @@ func ViewProject(ctx *context.Context) {
336338
ctx.Data["IsProjectsPage"] = true
337339
ctx.Data["CanWriteProjects"] = ctx.Repo.Permission.CanWrite(unit.TypeProjects)
338340
ctx.Data["Project"] = project
341+
ctx.Data["IssuesMap"] = issuesMap
339342
ctx.Data["Boards"] = boards
340343

341344
ctx.HTML(http.StatusOK, tplProjectsView)

templates/repo/projects/view.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@
175175

176176
<div class="ui cards board" data-url="{{$.RepoLink}}/projects/{{$.Project.ID}}/{{.ID}}" data-project="{{$.Project.ID}}" data-board="{{.ID}}" id="board_{{.ID}}">
177177

178-
{{ range .Issues }}
178+
{{ range (index $.IssuesMap .ID) }}
179179

180180
<!-- start issue card -->
181181
<div class="card board-card" data-issue="{{.ID}}">

0 commit comments

Comments
 (0)