From 25c6e2cc9cf5d76937980e95824f3082cb150b78 Mon Sep 17 00:00:00 2001 From: Reinier Balt Date: Sun, 5 Dec 2010 12:13:29 +0100 Subject: [PATCH] refactor search results page --- app/helpers/search_helper.rb | 1 - .../search/_show_results_collection.rhtml | 11 +++++ app/views/search/results.rhtml | 46 ++++++------------- 3 files changed, 24 insertions(+), 34 deletions(-) create mode 100644 app/views/search/_show_results_collection.rhtml diff --git a/app/helpers/search_helper.rb b/app/helpers/search_helper.rb index 9c4c5a10..b3ce20ac 100644 --- a/app/helpers/search_helper.rb +++ b/app/helpers/search_helper.rb @@ -1,3 +1,2 @@ module SearchHelper - end diff --git a/app/views/search/_show_results_collection.rhtml b/app/views/search/_show_results_collection.rhtml new file mode 100644 index 00000000..0ea84351 --- /dev/null +++ b/app/views/search/_show_results_collection.rhtml @@ -0,0 +1,11 @@ +<% +collection = show_results_collection +collection_name ||= 'unknown' +collection_title ||= 'unknown object' +unless collection.empty? +-%> +
+

<%= collection.size %><%= collection_title %>

+ <%= yield %> +
+<% end -%> \ No newline at end of file diff --git a/app/views/search/results.rhtml b/app/views/search/results.rhtml index ceb1e232..cb83a8d7 100644 --- a/app/views/search/results.rhtml +++ b/app/views/search/results.rhtml @@ -1,48 +1,28 @@ -
<% if @count == 0 -%>

<%= t('search.no_results') %>

<% else -%> - <% unless @found_todos.empty? -%> -
-

<%= @found_todos.size %><%= t('search.todos_matching_query') %>

- <%= render :partial => "todos/todo", :collection => @found_todos, :locals => { :parent_container_type => 'search', :suppress_context => false, :suppress_project => false, :suppress_edit_button => true } %> -
+ + <% render :layout => 'show_results_collection', :object => @found_todos, :locals => { :collection_name => "found-todos", :collection_title => t('search.todos_matching_query')} do %> + <%= render :partial => "todos/todo", :collection => @found_todos, :locals => { :parent_container_type => 'search', :suppress_context => false, :suppress_project => false, :suppress_edit_button => true } %> <% end -%> - <% unless @found_projects.empty? -%> -
-

<%= @found_projects.size %><%= t('search.projects_matching_query') %>

- <%= render :partial => "projects/project_listing", :collection => @found_projects, :locals => { :suppress_drag_handle => true, :suppress_edit_button => true } %> -
+ <% render :layout => 'show_results_collection', :object => @found_projects, :locals => { :collection_name => "found-project", :collection_title => t('search.projects_matching_query')} do %> + <%= render :partial => "projects/project_listing", :collection => @found_projects, :locals => { :suppress_drag_handle => true, :suppress_edit_button => true } %> <% end -%> - <% unless @found_notes.empty? -%> -
-

<%= @found_notes.size %><%= t('search.notes_matching_query') %>

- <% for notes in @found_notes -%> -
- <%= render :partial => "notes/notes_summary", :object => notes %> -
- <% end -%> -
+ <% render :layout => 'show_results_collection', :object => @found_notes, :locals => { :collection_name => "found-notes", :collection_title => t('search.notes_matching_query')} do %> + <%= render :partial => "notes/notes_summary", :collection=> @found_notes %> <% end -%> - <% unless @found_contexts.empty? -%> -
-

<%= @found_contexts.size %><%= t('search.contexts_matching_query') %>

- <%= render :partial => "contexts/context_listing", :collection => @found_contexts, :locals => { :suppress_drag_handle => true, :suppress_edit_button => true } %> -
+ <% render :layout => 'show_results_collection', :object => @found_contexts, :locals => { :collection_name => "found-contexts", :collection_title => t('search.contexts_matching_query')} do %> + <%= render :partial => "contexts/context_listing", :collection => @found_contexts, :locals => { :suppress_drag_handle => true, :suppress_edit_button => true } %> <% end -%> - <% unless @found_tags.empty? -%> -
-

<%= @found_tags.size %><%= t('search.tags_matching_query') %>

+ <% render :layout => 'show_results_collection', :object => @found_tags, :locals => { :collection_name => "found-tags", :collection_title => t('search.tags_matching_query')} do %> <% @found_tags.each do |tag| -%> <%= link_to tag.name, {:controller => "todos", :action => "tag", :id => tag.name} -%> <% end %> - -
-
- <% end %> +

+ <% end -%> + <% end -%> -