diff --git a/models/issue.go b/models/issue.go index d17bc2073..14191afdd 100644 --- a/models/issue.go +++ b/models/issue.go @@ -816,6 +816,7 @@ type IssuesOptions struct { IsPull bool Labels string SortType string + Keyword string } // Issues returns a list of issues by given conditions. @@ -882,6 +883,10 @@ func Issues(opts *IssuesOptions) ([]*Issue, error) { } } + if len(opts.Keyword) > 0 { + sess.And("(LOWER(name) LIKE LOWER(?) OR LOWER(content) LIKE LOWER(?))", "%"+opts.Keyword+"%", "%"+opts.Keyword+"%") + } + issues := make([]*Issue, 0, setting.UI.IssuePagingNum) if err := sess.Find(&issues); err != nil { return nil, fmt.Errorf("Find: %v", err) @@ -1102,6 +1107,7 @@ type IssueStatsOptions struct { AssigneeID int64 FilterMode FilterMode IsPull bool + Keyword string } // GetIssueStats returns issue statistic information by given conditions. @@ -1126,6 +1132,10 @@ func GetIssueStats(opts *IssueStatsOptions) *IssueStats { sess.And("assignee_id = ?", opts.AssigneeID) } + if len(opts.Keyword) > 0 { + sess.And("(LOWER(name) LIKE LOWER(?) OR LOWER(content) LIKE LOWER(?))", "%"+opts.Keyword+"%", "%"+opts.Keyword+"%") + } + return sess } diff --git a/routers/repo/issue.go b/routers/repo/issue.go index 83a6c3545..19681a063 100644 --- a/routers/repo/issue.go +++ b/routers/repo/issue.go @@ -109,6 +109,7 @@ func Issues(ctx *context.Context) { if !com.IsSliceContainsStr(types, viewType) { viewType = "all" } + keyword := ctx.Query("q") // Must sign in to see issues about you. if viewType != "all" && !ctx.IsSigned { @@ -150,6 +151,7 @@ func Issues(ctx *context.Context) { AssigneeID: assigneeID, FilterMode: filterMode, IsPull: isPullList, + Keyword: keyword, }) page := ctx.QueryInt("page") @@ -178,6 +180,7 @@ func Issues(ctx *context.Context) { IsPull: isPullList, Labels: selectLabels, SortType: sortType, + Keyword: keyword, }) if err != nil { ctx.Handle(500, "Issues", err) @@ -238,6 +241,7 @@ func Issues(ctx *context.Context) { } else { ctx.Data["State"] = "open" } + ctx.Data["Keyword"] = keyword ctx.HTML(200, ISSUES) } diff --git a/templates/repo/issue/list.tmpl b/templates/repo/issue/list.tmpl index d00c9aea2..5e47d5f23 100644 --- a/templates/repo/issue/list.tmpl +++ b/templates/repo/issue/list.tmpl @@ -14,15 +14,19 @@
- + {{.i18n.Tr "repo.issues.open_tab" .IssueStats.OpenCount}} - + {{.i18n.Tr "repo.issues.close_tab" .IssueStats.ClosedCount}}
+
+ + {{template "repo/issue/searchbar" .}} +
@@ -59,9 +63,9 @@ @@ -73,10 +77,10 @@ @@ -87,12 +91,12 @@ @@ -105,7 +109,7 @@ {{.Title}} {{range .Labels}} - {{.Name}} + {{.Name}} {{end}} {{if .NumComments}} @@ -115,7 +119,7 @@

{{$.i18n.Tr "repo.issues.opened_by" $timeStr .Poster.HomeLink .Poster.Name | Safe}} {{if .Milestone}} - + {{.Milestone.Name}} {{end}} @@ -132,17 +136,17 @@ {{if gt .TotalPages 1}}

diff --git a/templates/repo/issue/searchbar.tmpl b/templates/repo/issue/searchbar.tmpl new file mode 100644 index 000000000..2ac63be48 --- /dev/null +++ b/templates/repo/issue/searchbar.tmpl @@ -0,0 +1,14 @@ +
+ + +
+ +