Commit ac8247b46df8eb8c475436fc276a3648379ae7a0
1 parent
f6c482c0
Exists in
master
and in
4 other branches
Improved search. added filters
Showing
7 changed files
with
117 additions
and
106 deletions
Show diff stats
app/assets/stylesheets/common.scss
1 | html { | 1 | html { |
2 | - overflow-y: scroll; | 2 | + overflow-y: scroll; |
3 | } | 3 | } |
4 | 4 | ||
5 | /** LAYOUT **/ | 5 | /** LAYOUT **/ |
@@ -277,8 +277,20 @@ p.time { | @@ -277,8 +277,20 @@ p.time { | ||
277 | } | 277 | } |
278 | } | 278 | } |
279 | 279 | ||
280 | +.search-holder { | ||
281 | + label, input { | ||
282 | + height: 30px; | ||
283 | + padding: 0; | ||
284 | + font-size: 14px; | ||
285 | + } | ||
286 | + label { | ||
287 | + line-height: 30px; | ||
288 | + color: #666; | ||
289 | + } | ||
290 | +} | ||
291 | + | ||
280 | .highlight_word { | 292 | .highlight_word { |
281 | - background: #EEDC94; | 293 | + border-bottom: 2px solid #F90; |
282 | } | 294 | } |
283 | 295 | ||
284 | .status_info { | 296 | .status_info { |
app/controllers/search_controller.rb
1 | class SearchController < ApplicationController | 1 | class SearchController < ApplicationController |
2 | def show | 2 | def show |
3 | - result = SearchContext.new(current_user.authorized_projects.map(&:id), params).execute | 3 | + project_id = params[:project_id] |
4 | + group_id = params[:group_id] | ||
5 | + | ||
6 | + project_ids = current_user.authorized_projects.map(&:id) | ||
7 | + | ||
8 | + if group_id.present? | ||
9 | + group_project_ids = Group.find(group_id).projects.map(&:id) | ||
10 | + project_ids.select! { |id| group_project_ids.include?(id)} | ||
11 | + elsif project_id.present? | ||
12 | + project_ids.select! { |id| id == project_id.to_i} | ||
13 | + end | ||
14 | + | ||
15 | + result = SearchContext.new(project_ids, params).execute | ||
4 | 16 | ||
5 | @projects = result[:projects] | 17 | @projects = result[:projects] |
6 | @merge_requests = result[:merge_requests] | 18 | @merge_requests = result[:merge_requests] |
app/helpers/application_helper.rb
@@ -72,8 +72,8 @@ module ApplicationHelper | @@ -72,8 +72,8 @@ module ApplicationHelper | ||
72 | end | 72 | end |
73 | 73 | ||
74 | def search_autocomplete_source | 74 | def search_autocomplete_source |
75 | - projects = current_user.authorized_projects.map { |p| { label: p.name_with_namespace, url: project_path(p) } } | ||
76 | - groups = current_user.authorized_groups.map { |group| { label: "<group> #{group.name}", url: group_path(group) } } | 75 | + projects = current_user.authorized_projects.map { |p| { label: "project: #{p.name_with_namespace}", url: project_path(p) } } |
76 | + groups = current_user.authorized_groups.map { |group| { label: "group: #{group.name}", url: group_path(group) } } | ||
77 | 77 | ||
78 | default_nav = [ | 78 | default_nav = [ |
79 | { label: "My Profile", url: profile_path }, | 79 | { label: "My Profile", url: profile_path }, |
@@ -83,29 +83,29 @@ module ApplicationHelper | @@ -83,29 +83,29 @@ module ApplicationHelper | ||
83 | ] | 83 | ] |
84 | 84 | ||
85 | help_nav = [ | 85 | help_nav = [ |
86 | - { label: "API Help", url: help_api_path }, | ||
87 | - { label: "Markdown Help", url: help_markdown_path }, | ||
88 | - { label: "Permissions Help", url: help_permissions_path }, | ||
89 | - { label: "Public Access Help", url: help_public_access_path }, | ||
90 | - { label: "Rake Tasks Help", url: help_raketasks_path }, | ||
91 | - { label: "SSH Keys Help", url: help_ssh_path }, | ||
92 | - { label: "System Hooks Help", url: help_system_hooks_path }, | ||
93 | - { label: "Web Hooks Help", url: help_web_hooks_path }, | ||
94 | - { label: "Workflow Help", url: help_workflow_path }, | 86 | + { label: "help: API Help", url: help_api_path }, |
87 | + { label: "help: Markdown Help", url: help_markdown_path }, | ||
88 | + { label: "help: Permissions Help", url: help_permissions_path }, | ||
89 | + { label: "help: Public Access Help", url: help_public_access_path }, | ||
90 | + { label: "help: Rake Tasks Help", url: help_raketasks_path }, | ||
91 | + { label: "help: SSH Keys Help", url: help_ssh_path }, | ||
92 | + { label: "help: System Hooks Help", url: help_system_hooks_path }, | ||
93 | + { label: "help: Web Hooks Help", url: help_web_hooks_path }, | ||
94 | + { label: "help: Workflow Help", url: help_workflow_path }, | ||
95 | ] | 95 | ] |
96 | 96 | ||
97 | project_nav = [] | 97 | project_nav = [] |
98 | if @project && @project.repository && @project.repository.root_ref | 98 | if @project && @project.repository && @project.repository.root_ref |
99 | project_nav = [ | 99 | project_nav = [ |
100 | - { label: "#{@project.name} Issues", url: project_issues_path(@project) }, | ||
101 | - { label: "#{@project.name} Commits", url: project_commits_path(@project, @ref || @project.repository.root_ref) }, | ||
102 | - { label: "#{@project.name} Merge Requests", url: project_merge_requests_path(@project) }, | ||
103 | - { label: "#{@project.name} Milestones", url: project_milestones_path(@project) }, | ||
104 | - { label: "#{@project.name} Snippets", url: project_snippets_path(@project) }, | ||
105 | - { label: "#{@project.name} Team", url: project_team_index_path(@project) }, | ||
106 | - { label: "#{@project.name} Tree", url: project_tree_path(@project, @ref || @project.repository.root_ref) }, | ||
107 | - { label: "#{@project.name} Wall", url: wall_project_path(@project) }, | ||
108 | - { label: "#{@project.name} Wiki", url: project_wikis_path(@project) }, | 100 | + { label: "#{@project.name_with_namespace} - Issues", url: project_issues_path(@project) }, |
101 | + { label: "#{@project.name_with_namespace} - Commits", url: project_commits_path(@project, @ref || @project.repository.root_ref) }, | ||
102 | + { label: "#{@project.name_with_namespace} - Merge Requests", url: project_merge_requests_path(@project) }, | ||
103 | + { label: "#{@project.name_with_namespace} - Milestones", url: project_milestones_path(@project) }, | ||
104 | + { label: "#{@project.name_with_namespace} - Snippets", url: project_snippets_path(@project) }, | ||
105 | + { label: "#{@project.name_with_namespace} - Team", url: project_team_index_path(@project) }, | ||
106 | + { label: "#{@project.name_with_namespace} - Tree", url: project_tree_path(@project, @ref || @project.repository.root_ref) }, | ||
107 | + { label: "#{@project.name_with_namespace} - Wall", url: wall_project_path(@project) }, | ||
108 | + { label: "#{@project.name_with_namespace} - Wiki", url: project_wikis_path(@project) }, | ||
109 | ] | 109 | ] |
110 | end | 110 | end |
111 | 111 |
app/views/layouts/_search.html.haml
1 | .search | 1 | .search |
2 | = form_tag search_path, method: :get, class: 'navbar-form pull-left' do |f| | 2 | = form_tag search_path, method: :get, class: 'navbar-form pull-left' do |f| |
3 | = text_field_tag "search", nil, placeholder: "Search", class: "search-input" | 3 | = text_field_tag "search", nil, placeholder: "Search", class: "search-input" |
4 | + = hidden_field_tag :group_id, @group.try(:id) | ||
5 | + = hidden_field_tag :project_id, @project.try(:id) | ||
4 | 6 | ||
5 | :javascript | 7 | :javascript |
6 | $(function(){ | 8 | $(function(){ |
@@ -0,0 +1,24 @@ | @@ -0,0 +1,24 @@ | ||
1 | +%fieldset | ||
2 | + %legend Groups: | ||
3 | + %ul.nav.nav-pills.nav-stacked | ||
4 | + %li{class: ("active" if params[:group_id].blank?)} | ||
5 | + = link_to search_path(group_id: nil, search: params[:search]) do | ||
6 | + Any | ||
7 | + - current_user.authorized_groups.each do |group| | ||
8 | + %li{class: ("active" if params[:group_id] == group.id.to_s)} | ||
9 | + = link_to search_path(group_id: group.id, search: params[:search]) do | ||
10 | + = group.name | ||
11 | + | ||
12 | +%fieldset | ||
13 | + %legend Projects: | ||
14 | + %ul.nav.nav-pills.nav-stacked | ||
15 | + %li{class: ("active" if params[:project_id].blank?)} | ||
16 | + = link_to search_path(project_id: nil, search: params[:search]) do | ||
17 | + Any | ||
18 | + - current_user.authorized_projects.each do |project| | ||
19 | + %li{class: ("active" if params[:project_id] == project.id.to_s)} | ||
20 | + = link_to search_path(project_id: project.id, search: params[:search]) do | ||
21 | + = project.name_with_namespace | ||
22 | + | ||
23 | += hidden_field_tag :group_id, params[:group_id] | ||
24 | += hidden_field_tag :project_id, params[:project_id] |
app/views/search/_result.html.haml
1 | -%br | ||
2 | -%h3.page_title | ||
3 | - Search results | ||
4 | - %span.cgray (#{@projects.count + @merge_requests.count + @issues.count + @wiki_pages.count}) | ||
5 | -%hr | 1 | +%fieldset |
2 | + %legend | ||
3 | + Search results | ||
4 | + %span.cgray (#{@projects.count + @merge_requests.count + @issues.count + @wiki_pages.count}) | ||
6 | .search_results | 5 | .search_results |
7 | - .row | ||
8 | - .span6 | ||
9 | - %table | ||
10 | - %thead | ||
11 | - %tr | ||
12 | - %th Projects | ||
13 | - %tbody | ||
14 | - - @projects.each do |project| | ||
15 | - %tr | ||
16 | - %td | ||
17 | - = link_to project do | ||
18 | - %strong.term= project.name_with_namespace | ||
19 | - %small.cgray | ||
20 | - last activity at | ||
21 | - = project.last_activity_date.stamp("Aug 25, 2011") | ||
22 | - - if @projects.blank? | ||
23 | - %tr | ||
24 | - %td | ||
25 | - %h4.nothing_here_message No Projects | ||
26 | - %br | ||
27 | - %table | ||
28 | - %thead | ||
29 | - %tr | ||
30 | - %th Merge Requests | ||
31 | - %tbody | ||
32 | - - @merge_requests.each do |merge_request| | ||
33 | - %tr | ||
34 | - %td | ||
35 | - = link_to [merge_request.project, merge_request] do | ||
36 | - %span.badge.badge-info ##{merge_request.id} | ||
37 | - – | ||
38 | - %strong.term= truncate merge_request.title, length: 50 | ||
39 | - %strong.right | ||
40 | - %span.label= merge_request.project.name | ||
41 | - - if @merge_requests.blank? | ||
42 | - %tr | ||
43 | - %td | ||
44 | - %h4.nothing_here_message No Merge Requests | ||
45 | - .span6 | ||
46 | - %table | ||
47 | - %thead | ||
48 | - %tr | ||
49 | - %th Issues | ||
50 | - %tbody | ||
51 | - - @issues.each do |issue| | ||
52 | - %tr | ||
53 | - %td | ||
54 | - = link_to [issue.project, issue] do | ||
55 | - %span.badge.badge-info ##{issue.id} | ||
56 | - – | ||
57 | - %strong.term= truncate issue.title, length: 40 | ||
58 | - %strong.right | ||
59 | - %span.label= issue.project.name | ||
60 | - - if @issues.blank? | ||
61 | - %tr | ||
62 | - %td | ||
63 | - %h4.nothing_here_message No Issues | ||
64 | - .span6 | ||
65 | - %table | ||
66 | - %thead | ||
67 | - %tr | ||
68 | - %th Wiki | ||
69 | - %tbody | ||
70 | - - @wiki_pages.each do |wiki_page| | ||
71 | - %tr | ||
72 | - %td | ||
73 | - = link_to project_wiki_path(wiki_page.project, wiki_page) do | ||
74 | - %strong.term= truncate wiki_page.title, length: 40 | ||
75 | - %strong.right | ||
76 | - %span.label= wiki_page.project.name | ||
77 | - - if @wiki_pages.blank? | ||
78 | - %tr | ||
79 | - %td | ||
80 | - %h4.nothing_here_message No wiki pages | 6 | + %ul.well-list |
7 | + - @projects.each do |project| | ||
8 | + %li | ||
9 | + project: | ||
10 | + = link_to project do | ||
11 | + %strong.term= project.name_with_namespace | ||
12 | + - @merge_requests.each do |merge_request| | ||
13 | + %li | ||
14 | + merge request: | ||
15 | + = link_to [merge_request.project, merge_request] do | ||
16 | + %span ##{merge_request.id} | ||
17 | + %strong.term | ||
18 | + = truncate merge_request.title, length: 50 | ||
19 | + %span.light (#{merge_request.project.name_with_namespace}) | ||
20 | + - @issues.each do |issue| | ||
21 | + %li | ||
22 | + issue: | ||
23 | + = link_to [issue.project, issue] do | ||
24 | + %span ##{issue.id} | ||
25 | + %strong.term | ||
26 | + = truncate issue.title, length: 50 | ||
27 | + %span.light (#{issue.project.name_with_namespace}) | ||
28 | + - @wiki_pages.each do |wiki_page| | ||
29 | + %li | ||
30 | + wiki: | ||
31 | + = link_to project_wiki_path(wiki_page.project, wiki_page) do | ||
32 | + %strong.term | ||
33 | + = truncate wiki_page.title, length: 50 | ||
34 | + %span.light (#{wiki_page.project.name_with_namespace}) | ||
35 | + | ||
81 | :javascript | 36 | :javascript |
82 | $(function() { | 37 | $(function() { |
83 | $(".search_results .term").highlight("#{escape_javascript(params[:search])}"); | 38 | $(".search_results .term").highlight("#{escape_javascript(params[:search])}"); |
app/views/search/show.html.haml
1 | = form_tag search_path, method: :get, class: 'form-inline' do |f| | 1 | = form_tag search_path, method: :get, class: 'form-inline' do |f| |
2 | - .padded | 2 | + .search-holder |
3 | = label_tag :search do | 3 | = label_tag :search do |
4 | - %strong Looking for | 4 | + %span Looking for |
5 | .input | 5 | .input |
6 | = search_field_tag :search, params[:search], placeholder: "issue 143", class: "input-xxlarge search-text-input", id: "dashboard_search" | 6 | = search_field_tag :search, params[:search], placeholder: "issue 143", class: "input-xxlarge search-text-input", id: "dashboard_search" |
7 | = submit_tag 'Search', class: "btn primary wide" | 7 | = submit_tag 'Search', class: "btn primary wide" |
8 | -- if params[:search].present? | ||
9 | - = render 'search/result' | 8 | + .clearfix |
9 | + .row | ||
10 | + .span3 | ||
11 | + = render 'filter', f: f | ||
12 | + .span9 | ||
13 | + .results | ||
14 | + - if params[:search].present? | ||
15 | + = render 'search/result' |