Improved search. added filters

4-2-stable
Dmitriy Zaporozhets 2013-01-25 10:07:21 +02:00
parent f6c482c06f
commit ac8247b46d
7 changed files with 117 additions and 106 deletions

View File

@ -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 {

View File

@ -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]

View File

@ -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

View File

@ -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(){

View File

@ -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]

View File

@ -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])}");

View File

@ -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'