summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorValery Sizov <vsv2711@gmail.com>2015-08-13 17:48:21 +0300
committerValery Sizov <vsv2711@gmail.com>2015-08-24 13:59:01 +0300
commit56527b63e8a09e0fe4967eabf08638d853e6b2b5 (patch)
tree0ee484fe1bb0dbdae4333e30ad7c3c36251c1bcf /app
parent24b282aeeaf5ba41c6b73100051eb48428787770 (diff)
downloadgitlab-ce-56527b63e8a09e0fe4967eabf08638d853e6b2b5.tar.gz
Ability to search milestonesmilestone_search
Diffstat (limited to 'app')
-rw-r--r--app/controllers/search_controller.rb4
-rw-r--r--app/models/milestone.rb9
-rw-r--r--app/views/search/_category.html.haml14
-rw-r--r--app/views/search/results/_milestone.html.haml9
4 files changed, 33 insertions, 3 deletions
diff --git a/app/controllers/search_controller.rb b/app/controllers/search_controller.rb
index 4e2ea6c5710..eb0408a95e5 100644
--- a/app/controllers/search_controller.rb
+++ b/app/controllers/search_controller.rb
@@ -23,7 +23,7 @@ class SearchController < ApplicationController
@search_results =
if @project
- unless %w(blobs notes issues merge_requests wiki_blobs).
+ unless %w(blobs notes issues merge_requests milestones wiki_blobs).
include?(@scope)
@scope = 'blobs'
end
@@ -36,7 +36,7 @@ class SearchController < ApplicationController
Search::SnippetService.new(current_user, params).execute
else
- unless %w(projects issues merge_requests).include?(@scope)
+ unless %w(projects issues merge_requests milestones).include?(@scope)
@scope = 'projects'
end
Search::GlobalService.new(current_user, params).execute
diff --git a/app/models/milestone.rb b/app/models/milestone.rb
index d28f3c8d3f9..c6aff6f709f 100644
--- a/app/models/milestone.rb
+++ b/app/models/milestone.rb
@@ -47,6 +47,13 @@ class Milestone < ActiveRecord::Base
state :active
end
+ class << self
+ def search(query)
+ query = "%#{query}%"
+ where("title like ? or description like ?", query, query)
+ end
+ end
+
def expired?
if due_date
due_date.past?
@@ -54,7 +61,7 @@ class Milestone < ActiveRecord::Base
false
end
end
-
+
def open_items_count
self.issues.opened.count + self.merge_requests.opened.count
end
diff --git a/app/views/search/_category.html.haml b/app/views/search/_category.html.haml
index 154332cb9a9..a75cd7bd809 100644
--- a/app/views/search/_category.html.haml
+++ b/app/views/search/_category.html.haml
@@ -21,6 +21,13 @@
Merge requests
%span.badge
= @search_results.merge_requests_count
+ %li{class: ("active" if @scope == 'milestones')}
+ = link_to search_filter_path(scope: 'milestones') do
+ = icon('clock-o fw')
+ %span
+ Milestones
+ %span.badge
+ = @search_results.milestones_count
%li{class: ("active" if @scope == 'notes')}
= link_to search_filter_path(scope: 'notes') do
= icon('comments fw')
@@ -74,4 +81,11 @@
Merge requests
%span.badge
= @search_results.merge_requests_count
+ %li{class: ("active" if @scope == 'milestones')}
+ = link_to search_filter_path(scope: 'milestones') do
+ = icon('clock-o fw')
+ %span
+ Milestones
+ %span.badge
+ = @search_results.milestones_count
diff --git a/app/views/search/results/_milestone.html.haml b/app/views/search/results/_milestone.html.haml
new file mode 100644
index 00000000000..e0b18733d74
--- /dev/null
+++ b/app/views/search/results/_milestone.html.haml
@@ -0,0 +1,9 @@
+.search-result-row
+ %h4
+ = link_to [milestone.project.namespace.becomes(Namespace), milestone.project, milestone] do
+ %span.term.str-truncated= milestone.title
+
+ - if milestone.description.present?
+ .description.term
+ = preserve do
+ = search_md_sanitize(markdown(milestone.description)) \ No newline at end of file