diff --git a/app/controllers/search_controller.rb b/app/controllers/search_controller.rb index baaa25dd..93bdb23e 100644 --- a/app/controllers/search_controller.rb +++ b/app/controllers/search_controller.rb @@ -1,27 +1,30 @@ -class SearchController < ApplicationController - - helper :todos, :application, :notes, :projects - - def results - @source_view = params['_source_view'] || 'search' - @page_title = "TRACKS::Search Results for #{params[:search]}" - terms = '%' + params[:search] + '%' - @found_todos = current_user.todos.find(:all, :conditions => ["todos.description LIKE ? OR todos.notes LIKE ?", terms, terms], :include => [:tags, :project, :context]) - @found_projects = current_user.projects.find(:all, :conditions => ["name LIKE ? or description LIKE ?", terms, terms]) - @found_notes = current_user.notes.find(:all, :conditions => ["body LIKE ?", terms]) - - @count = @found_todos.size + @found_projects.size + @found_notes.size - - init_not_done_counts(['project']) - init_project_hidden_todo_counts(['project']) - end - - def index - @page_title = "TRACKS::Search" - end - - def init - @source_view = params['_source_view'] || 'search' - end - -end +class SearchController < ApplicationController + + helper :todos, :application, :notes, :projects + + def results + @source_view = params['_source_view'] || 'search' + @page_title = "TRACKS::Search Results for #{params[:search]}" + terms = '%' + params[:search] + '%' + @found_todos = current_user.todos.find(:all, :conditions => ["todos.description LIKE ? OR todos.notes LIKE ?", terms, terms], :include => [:tags, :project, :context]) + @found_projects = current_user.projects.find(:all, :conditions => ["name LIKE ? OR description LIKE ?", terms, terms]) + @found_notes = current_user.notes.find(:all, :conditions => ["body LIKE ?", terms]) + @found_contexts = current_user.contexts.find(:all, :conditions => ["name LIKE ?", terms]) + # TODO: limit search to tags on todos + @found_tags = current_user.tags.find(:all, :conditions => ["name LIKE ?", terms]) + + @count = @found_todos.size + @found_projects.size + @found_notes.size + @found_contexts.size + @found_tags.size + + init_not_done_counts + init_project_hidden_todo_counts + end + + def index + @page_title = "TRACKS::Search" + end + + def init + @source_view = params['_source_view'] || 'search' + end + +end diff --git a/app/views/contexts/_context_listing.rhtml b/app/views/contexts/_context_listing.rhtml index 03ad73f3..32335457 100644 --- a/app/views/contexts/_context_listing.rhtml +++ b/app/views/contexts/_context_listing.rhtml @@ -1,9 +1,14 @@ -<% context = context_listing %> +<% context = context_listing + suppress_drag_handle ||= false + suppress_edit_button ||= false +%>
" class="list">
-
- DRAG -
+ <% unless suppress_drag_handle -%> +
+ DRAG +
+ <% end -%>
<%= link_to_context( context ) %> <%= " (" + count_undone_todos_phrase(context,"actions") + ")" %>
@@ -32,5 +37,5 @@ -%>
- <%= render :partial => 'context_form', :object => context %> + <%= render :partial => 'contexts/context_form', :object => context %> \ No newline at end of file diff --git a/app/views/search/index.rhtml b/app/views/search/index.rhtml index 7065746b..8cfcbd76 100644 --- a/app/views/search/index.rhtml +++ b/app/views/search/index.rhtml @@ -1,6 +1,9 @@ - + + \ No newline at end of file diff --git a/app/views/search/results.rhtml b/app/views/search/results.rhtml index 679360c5..e18516ee 100644 --- a/app/views/search/results.rhtml +++ b/app/views/search/results.rhtml @@ -1,32 +1,48 @@ -
- <% if @count == 0 -%> -

Your search yielded no results.

- <% else -%> - <% source_view_is = :search %> - <% parent_container_type = 'search' %> - <% if not @found_todos.empty? -%> -
-

<%= @found_todos.size %>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 } %> -
- <% end -%> - - <% if not @found_projects.empty? -%> -
-

<%= @found_projects.size %>Projects matching query

- <%= render :partial => "projects/project_listing", :collection => @found_projects, :locals => { :suppress_drag_handle => true, :suppress_edit_button => true } %> -
- <% end -%> - - <% if not @found_notes.empty? -%> -
-

<%= @found_notes.size %>Notes matching query

- <% for notes in @found_notes -%> -
- <%= render :partial => "notes/notes_summary", :object => notes %> -
- <% end -%> -
- <% end -%> - <% end -%> -
+
+<% if @count == 0 -%> +

Your search yielded no results.

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

<%= @found_todos.size %>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 } %> +
+ <% end -%> + + <% unless @found_projects.empty? -%> +
+

<%= @found_projects.size %>Projects matching query

+ <%= 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 %>Notes matching query

+ <% for notes in @found_notes -%> +
+ <%= render :partial => "notes/notes_summary", :object => notes %> +
+ <% end -%> +
+ <% end -%> + + <% unless @found_contexts.empty? -%> +
+

<%= @found_contexts.size %>Contexts matching query

+ <%= 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 %>Tags matching query

+ <% @found_tags.each do |tag| -%> + <%= link_to tag.name, {:controller => "todos", :action => "tag", :id => tag.name} -%> + <% end %> + +
+
+ <% end %> +<% end -%> +