Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2013-01-25 12:07:21 +0400
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2013-01-25 12:07:21 +0400
commitac8247b46df8eb8c475436fc276a3648379ae7a0 (patch)
treef4142ffae01dc8016f8efe9a133decd49102fe2a /app
parentf6c482c06f48449e7dcff34455b5bbdfbd8f6c7b (diff)
Improved search. added filters
Diffstat (limited to 'app')
-rw-r--r--app/assets/stylesheets/common.scss16
-rw-r--r--app/controllers/search_controller.rb14
-rw-r--r--app/helpers/application_helper.rb40
-rw-r--r--app/views/layouts/_search.html.haml2
-rw-r--r--app/views/search/_filter.html.haml24
-rw-r--r--app/views/search/_result.html.haml113
-rw-r--r--app/views/search/show.html.haml14
7 files changed, 117 insertions, 106 deletions
diff --git a/app/assets/stylesheets/common.scss b/app/assets/stylesheets/common.scss
index db077048b6c..0d25b104bb5 100644
--- a/app/assets/stylesheets/common.scss
+++ b/app/assets/stylesheets/common.scss
@@ -1,5 +1,5 @@
html {
- overflow-y: scroll;
+ overflow-y: scroll;
}
/** LAYOUT **/
@@ -277,8 +277,20 @@ p.time {
}
}
+.search-holder {
+ label, input {
+ height: 30px;
+ padding: 0;
+ font-size: 14px;
+ }
+ label {
+ line-height: 30px;
+ color: #666;
+ }
+}
+
.highlight_word {
- background: #EEDC94;
+ border-bottom: 2px solid #F90;
}
.status_info {
diff --git a/app/controllers/search_controller.rb b/app/controllers/search_controller.rb
index a23292396a0..bbd67df6c70 100644
--- a/app/controllers/search_controller.rb
+++ b/app/controllers/search_controller.rb
@@ -1,6 +1,18 @@
class SearchController < ApplicationController
def show
- result = SearchContext.new(current_user.authorized_projects.map(&:id), params).execute
+ project_id = params[:project_id]
+ group_id = params[:group_id]
+
+ project_ids = current_user.authorized_projects.map(&:id)
+
+ if group_id.present?
+ group_project_ids = Group.find(group_id).projects.map(&:id)
+ project_ids.select! { |id| group_project_ids.include?(id)}
+ elsif project_id.present?
+ project_ids.select! { |id| id == project_id.to_i}
+ end
+
+ result = SearchContext.new(project_ids, params).execute
@projects = result[:projects]
@merge_requests = result[:merge_requests]
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index 6478982cdad..9aafce57e60 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -72,8 +72,8 @@ module ApplicationHelper
end
def search_autocomplete_source
- projects = current_user.authorized_projects.map { |p| { label: p.name_with_namespace, url: project_path(p) } }
- groups = current_user.authorized_groups.map { |group| { label: "<group> #{group.name}", url: group_path(group) } }
+ projects = current_user.authorized_projects.map { |p| { label: "project: #{p.name_with_namespace}", url: project_path(p) } }
+ groups = current_user.authorized_groups.map { |group| { label: "group: #{group.name}", url: group_path(group) } }
default_nav = [
{ label: "My Profile", url: profile_path },
@@ -83,29 +83,29 @@ module ApplicationHelper
]
help_nav = [
- { label: "API Help", url: help_api_path },
- { label: "Markdown Help", url: help_markdown_path },
- { label: "Permissions Help", url: help_permissions_path },
- { label: "Public Access Help", url: help_public_access_path },
- { label: "Rake Tasks Help", url: help_raketasks_path },
- { label: "SSH Keys Help", url: help_ssh_path },
- { label: "System Hooks Help", url: help_system_hooks_path },
- { label: "Web Hooks Help", url: help_web_hooks_path },
- { label: "Workflow Help", url: help_workflow_path },
+ { label: "help: API Help", url: help_api_path },
+ { label: "help: Markdown Help", url: help_markdown_path },
+ { label: "help: Permissions Help", url: help_permissions_path },
+ { label: "help: Public Access Help", url: help_public_access_path },
+ { label: "help: Rake Tasks Help", url: help_raketasks_path },
+ { label: "help: SSH Keys Help", url: help_ssh_path },
+ { label: "help: System Hooks Help", url: help_system_hooks_path },
+ { label: "help: Web Hooks Help", url: help_web_hooks_path },
+ { label: "help: Workflow Help", url: help_workflow_path },
]
project_nav = []
if @project && @project.repository && @project.repository.root_ref
project_nav = [
- { label: "#{@project.name} Issues", url: project_issues_path(@project) },
- { label: "#{@project.name} Commits", url: project_commits_path(@project, @ref || @project.repository.root_ref) },
- { label: "#{@project.name} Merge Requests", url: project_merge_requests_path(@project) },
- { label: "#{@project.name} Milestones", url: project_milestones_path(@project) },
- { label: "#{@project.name} Snippets", url: project_snippets_path(@project) },
- { label: "#{@project.name} Team", url: project_team_index_path(@project) },
- { label: "#{@project.name} Tree", url: project_tree_path(@project, @ref || @project.repository.root_ref) },
- { label: "#{@project.name} Wall", url: wall_project_path(@project) },
- { label: "#{@project.name} Wiki", url: project_wikis_path(@project) },
+ { label: "#{@project.name_with_namespace} - Issues", url: project_issues_path(@project) },
+ { label: "#{@project.name_with_namespace} - Commits", url: project_commits_path(@project, @ref || @project.repository.root_ref) },
+ { label: "#{@project.name_with_namespace} - Merge Requests", url: project_merge_requests_path(@project) },
+ { label: "#{@project.name_with_namespace} - Milestones", url: project_milestones_path(@project) },
+ { label: "#{@project.name_with_namespace} - Snippets", url: project_snippets_path(@project) },
+ { label: "#{@project.name_with_namespace} - Team", url: project_team_index_path(@project) },
+ { label: "#{@project.name_with_namespace} - Tree", url: project_tree_path(@project, @ref || @project.repository.root_ref) },
+ { label: "#{@project.name_with_namespace} - Wall", url: wall_project_path(@project) },
+ { label: "#{@project.name_with_namespace} - Wiki", url: project_wikis_path(@project) },
]
end
diff --git a/app/views/layouts/_search.html.haml b/app/views/layouts/_search.html.haml
index 7ea9079849a..c484af04704 100644
--- a/app/views/layouts/_search.html.haml
+++ b/app/views/layouts/_search.html.haml
@@ -1,6 +1,8 @@
.search
= form_tag search_path, method: :get, class: 'navbar-form pull-left' do |f|
= text_field_tag "search", nil, placeholder: "Search", class: "search-input"
+ = hidden_field_tag :group_id, @group.try(:id)
+ = hidden_field_tag :project_id, @project.try(:id)
:javascript
$(function(){
diff --git a/app/views/search/_filter.html.haml b/app/views/search/_filter.html.haml
new file mode 100644
index 00000000000..3fe17dce857
--- /dev/null
+++ b/app/views/search/_filter.html.haml
@@ -0,0 +1,24 @@
+%fieldset
+ %legend Groups:
+ %ul.nav.nav-pills.nav-stacked
+ %li{class: ("active" if params[:group_id].blank?)}
+ = link_to search_path(group_id: nil, search: params[:search]) do
+ Any
+ - current_user.authorized_groups.each do |group|
+ %li{class: ("active" if params[:group_id] == group.id.to_s)}
+ = link_to search_path(group_id: group.id, search: params[:search]) do
+ = group.name
+
+%fieldset
+ %legend Projects:
+ %ul.nav.nav-pills.nav-stacked
+ %li{class: ("active" if params[:project_id].blank?)}
+ = link_to search_path(project_id: nil, search: params[:search]) do
+ Any
+ - current_user.authorized_projects.each do |project|
+ %li{class: ("active" if params[:project_id] == project.id.to_s)}
+ = link_to search_path(project_id: project.id, search: params[:search]) do
+ = project.name_with_namespace
+
+= hidden_field_tag :group_id, params[:group_id]
+= hidden_field_tag :project_id, params[:project_id]
diff --git a/app/views/search/_result.html.haml b/app/views/search/_result.html.haml
index 79bed4f737c..bfa46075baa 100644
--- a/app/views/search/_result.html.haml
+++ b/app/views/search/_result.html.haml
@@ -1,83 +1,38 @@
-%br
-%h3.page_title
- Search results
- %span.cgray (#{@projects.count + @merge_requests.count + @issues.count + @wiki_pages.count})
-%hr
+%fieldset
+ %legend
+ Search results
+ %span.cgray (#{@projects.count + @merge_requests.count + @issues.count + @wiki_pages.count})
.search_results
- .row
- .span6
- %table
- %thead
- %tr
- %th Projects
- %tbody
- - @projects.each do |project|
- %tr
- %td
- = link_to project do
- %strong.term= project.name_with_namespace
- %small.cgray
- last activity at
- = project.last_activity_date.stamp("Aug 25, 2011")
- - if @projects.blank?
- %tr
- %td
- %h4.nothing_here_message No Projects
- %br
- %table
- %thead
- %tr
- %th Merge Requests
- %tbody
- - @merge_requests.each do |merge_request|
- %tr
- %td
- = link_to [merge_request.project, merge_request] do
- %span.badge.badge-info ##{merge_request.id}
- &ndash;
- %strong.term= truncate merge_request.title, length: 50
- %strong.right
- %span.label= merge_request.project.name
- - if @merge_requests.blank?
- %tr
- %td
- %h4.nothing_here_message No Merge Requests
- .span6
- %table
- %thead
- %tr
- %th Issues
- %tbody
- - @issues.each do |issue|
- %tr
- %td
- = link_to [issue.project, issue] do
- %span.badge.badge-info ##{issue.id}
- &ndash;
- %strong.term= truncate issue.title, length: 40
- %strong.right
- %span.label= issue.project.name
- - if @issues.blank?
- %tr
- %td
- %h4.nothing_here_message No Issues
- .span6
- %table
- %thead
- %tr
- %th Wiki
- %tbody
- - @wiki_pages.each do |wiki_page|
- %tr
- %td
- = link_to project_wiki_path(wiki_page.project, wiki_page) do
- %strong.term= truncate wiki_page.title, length: 40
- %strong.right
- %span.label= wiki_page.project.name
- - if @wiki_pages.blank?
- %tr
- %td
- %h4.nothing_here_message No wiki pages
+ %ul.well-list
+ - @projects.each do |project|
+ %li
+ project:
+ = link_to project do
+ %strong.term= project.name_with_namespace
+ - @merge_requests.each do |merge_request|
+ %li
+ merge request:
+ = link_to [merge_request.project, merge_request] do
+ %span ##{merge_request.id}
+ %strong.term
+ = truncate merge_request.title, length: 50
+ %span.light (#{merge_request.project.name_with_namespace})
+ - @issues.each do |issue|
+ %li
+ issue:
+ = link_to [issue.project, issue] do
+ %span ##{issue.id}
+ %strong.term
+ = truncate issue.title, length: 50
+ %span.light (#{issue.project.name_with_namespace})
+ - @wiki_pages.each do |wiki_page|
+ %li
+ wiki:
+ = link_to project_wiki_path(wiki_page.project, wiki_page) do
+ %strong.term
+ = truncate wiki_page.title, length: 50
+ %span.light (#{wiki_page.project.name_with_namespace})
+
:javascript
$(function() {
$(".search_results .term").highlight("#{escape_javascript(params[:search])}");
diff --git a/app/views/search/show.html.haml b/app/views/search/show.html.haml
index aa0d6d700d9..22e1ae50df1 100644
--- a/app/views/search/show.html.haml
+++ b/app/views/search/show.html.haml
@@ -1,9 +1,15 @@
= form_tag search_path, method: :get, class: 'form-inline' do |f|
- .padded
+ .search-holder
= label_tag :search do
- %strong Looking for
+ %span Looking for
.input
= search_field_tag :search, params[:search], placeholder: "issue 143", class: "input-xxlarge search-text-input", id: "dashboard_search"
= submit_tag 'Search', class: "btn primary wide"
-- if params[:search].present?
- = render 'search/result'
+ .clearfix
+ .row
+ .span3
+ = render 'filter', f: f
+ .span9
+ .results
+ - if params[:search].present?
+ = render 'search/result'