Commit ac8247b4 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Improved search. added filters

parent f6c482c0
html { html {
overflow-y: scroll; overflow-y: scroll;
} }
/** LAYOUT **/ /** LAYOUT **/
...@@ -277,8 +277,20 @@ p.time { ...@@ -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 { .highlight_word {
background: #EEDC94; border-bottom: 2px solid #F90;
} }
.status_info { .status_info {
......
class SearchController < ApplicationController class SearchController < ApplicationController
def show 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] @projects = result[:projects]
@merge_requests = result[:merge_requests] @merge_requests = result[:merge_requests]
......
...@@ -72,8 +72,8 @@ module ApplicationHelper ...@@ -72,8 +72,8 @@ module ApplicationHelper
end end
def search_autocomplete_source def search_autocomplete_source
projects = current_user.authorized_projects.map { |p| { label: p.name_with_namespace, url: project_path(p) } } 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) } } groups = current_user.authorized_groups.map { |group| { label: "group: #{group.name}", url: group_path(group) } }
default_nav = [ default_nav = [
{ label: "My Profile", url: profile_path }, { label: "My Profile", url: profile_path },
...@@ -83,29 +83,29 @@ module ApplicationHelper ...@@ -83,29 +83,29 @@ module ApplicationHelper
] ]
help_nav = [ help_nav = [
{ label: "API Help", url: help_api_path }, { label: "help: API Help", url: help_api_path },
{ label: "Markdown Help", url: help_markdown_path }, { label: "help: Markdown Help", url: help_markdown_path },
{ label: "Permissions Help", url: help_permissions_path }, { label: "help: Permissions Help", url: help_permissions_path },
{ label: "Public Access Help", url: help_public_access_path }, { label: "help: Public Access Help", url: help_public_access_path },
{ label: "Rake Tasks Help", url: help_raketasks_path }, { label: "help: Rake Tasks Help", url: help_raketasks_path },
{ label: "SSH Keys Help", url: help_ssh_path }, { label: "help: SSH Keys Help", url: help_ssh_path },
{ label: "System Hooks Help", url: help_system_hooks_path }, { label: "help: System Hooks Help", url: help_system_hooks_path },
{ label: "Web Hooks Help", url: help_web_hooks_path }, { label: "help: Web Hooks Help", url: help_web_hooks_path },
{ label: "Workflow Help", url: help_workflow_path }, { label: "help: Workflow Help", url: help_workflow_path },
] ]
project_nav = [] project_nav = []
if @project && @project.repository && @project.repository.root_ref if @project && @project.repository && @project.repository.root_ref
project_nav = [ project_nav = [
{ label: "#{@project.name} Issues", url: project_issues_path(@project) }, { label: "#{@project.name_with_namespace} - Issues", url: project_issues_path(@project) },
{ label: "#{@project.name} Commits", url: project_commits_path(@project, @ref || @project.repository.root_ref) }, { label: "#{@project.name_with_namespace} - 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_with_namespace} - Merge Requests", url: project_merge_requests_path(@project) },
{ label: "#{@project.name} Milestones", url: project_milestones_path(@project) }, { label: "#{@project.name_with_namespace} - Milestones", url: project_milestones_path(@project) },
{ label: "#{@project.name} Snippets", url: project_snippets_path(@project) }, { label: "#{@project.name_with_namespace} - Snippets", url: project_snippets_path(@project) },
{ label: "#{@project.name} Team", url: project_team_index_path(@project) }, { label: "#{@project.name_with_namespace} - Team", url: project_team_index_path(@project) },
{ label: "#{@project.name} Tree", url: project_tree_path(@project, @ref || @project.repository.root_ref) }, { label: "#{@project.name_with_namespace} - Tree", url: project_tree_path(@project, @ref || @project.repository.root_ref) },
{ label: "#{@project.name} Wall", url: wall_project_path(@project) }, { label: "#{@project.name_with_namespace} - Wall", url: wall_project_path(@project) },
{ label: "#{@project.name} Wiki", url: project_wikis_path(@project) }, { label: "#{@project.name_with_namespace} - Wiki", url: project_wikis_path(@project) },
] ]
end end
......
.search .search
= form_tag search_path, method: :get, class: 'navbar-form pull-left' do |f| = form_tag search_path, method: :get, class: 'navbar-form pull-left' do |f|
= text_field_tag "search", nil, placeholder: "Search", class: "search-input" = 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 :javascript
$(function(){ $(function(){
......
%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]
%br %fieldset
%h3.page_title %legend
Search results Search results
%span.cgray (#{@projects.count + @merge_requests.count + @issues.count + @wiki_pages.count}) %span.cgray (#{@projects.count + @merge_requests.count + @issues.count + @wiki_pages.count})
%hr
.search_results .search_results
.row %ul.well-list
.span6 - @projects.each do |project|
%table %li
%thead project:
%tr = link_to project do
%th Projects %strong.term= project.name_with_namespace
%tbody - @merge_requests.each do |merge_request|
- @projects.each do |project| %li
%tr merge request:
%td = link_to [merge_request.project, merge_request] do
= link_to project do %span ##{merge_request.id}
%strong.term= project.name_with_namespace %strong.term
%small.cgray = truncate merge_request.title, length: 50
last activity at %span.light (#{merge_request.project.name_with_namespace})
= project.last_activity_date.stamp("Aug 25, 2011") - @issues.each do |issue|
- if @projects.blank? %li
%tr issue:
%td = link_to [issue.project, issue] do
%h4.nothing_here_message No Projects %span ##{issue.id}
%br %strong.term
%table = truncate issue.title, length: 50
%thead %span.light (#{issue.project.name_with_namespace})
%tr - @wiki_pages.each do |wiki_page|
%th Merge Requests %li
%tbody wiki:
- @merge_requests.each do |merge_request| = link_to project_wiki_path(wiki_page.project, wiki_page) do
%tr %strong.term
%td = truncate wiki_page.title, length: 50
= link_to [merge_request.project, merge_request] do %span.light (#{wiki_page.project.name_with_namespace})
%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
:javascript :javascript
$(function() { $(function() {
$(".search_results .term").highlight("#{escape_javascript(params[:search])}"); $(".search_results .term").highlight("#{escape_javascript(params[:search])}");
......
= form_tag search_path, method: :get, class: 'form-inline' do |f| = form_tag search_path, method: :get, class: 'form-inline' do |f|
.padded .search-holder
= label_tag :search do = label_tag :search do
%strong Looking for %span Looking for
.input .input
= search_field_tag :search, params[:search], placeholder: "issue 143", class: "input-xxlarge search-text-input", id: "dashboard_search" = 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" = submit_tag 'Search', class: "btn primary wide"
- if params[:search].present? .clearfix
= render 'search/result' .row
.span3
= render 'filter', f: f
.span9
.results
- if params[:search].present?
= render 'search/result'
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment