diff --git a/app/controllers/search_controller.rb b/app/controllers/search_controller.rb index 872b4fdd..44fa0d3f 100644 --- a/app/controllers/search_controller.rb +++ b/app/controllers/search_controller.rb @@ -1,12 +1,22 @@ class SearchController < ApplicationController - helper :todos, :application, :notes, :projects - + 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_not_complete_todos = current_user.todos.find(:all, + :conditions => ["(todos.description LIKE ? OR todos.notes LIKE ?) AND todos.completed_at IS NULL", terms, terms], + :include => Todo::DEFAULT_INCLUDES, + :order => "todos.due IS NULL, todos.due ASC, todos.created_at ASC") + @found_complete_todos = current_user.todos.find(:all, + :conditions => ["(todos.description LIKE ? OR todos.notes LIKE ?) AND NOT (todos.completed_at IS NULL)", terms, terms], + :include => Todo::DEFAULT_INCLUDES, + :order => "todos.completed_at DESC") + @found_todos = @found_not_complete_todos + @found_complete_todos + @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]) @@ -18,17 +28,17 @@ class SearchController < ApplicationController "LEFT JOIN todos ON taggings.taggable_id = todos.id "+ "WHERE todos.user_id=? "+ "AND tags.name LIKE ? ", current_user.id, 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" + @page_title = "TRACKS::Search" end - + def init @source_view = params['_source_view'] || 'search' end diff --git a/app/views/projects/_project_listing.rhtml b/app/views/projects/_project_listing.rhtml index 3d452c54..8da4996d 100644 --- a/app/views/projects/_project_listing.rhtml +++ b/app/views/projects/_project_listing.rhtml @@ -2,6 +2,7 @@ project = project_listing suppress_drag_handle ||= false suppress_edit_button ||= false +suppress_delete_button ||= false -%>
" class="list">
@@ -22,7 +23,7 @@ suppress_edit_button ||= false
<%= project.aasm_current_state.to_s.upcase %> - <%= link_to_delete_project(project, image_tag( "blank.png", :title => t('projects.delete_project_title'), :class=>"delete_item")) %> + <%= suppress_delete_button ? "" : link_to_delete_project(project, image_tag( "blank.png", :title => t('projects.delete_project_title'), :class=>"delete_item")) %> <%= suppress_edit_button ? "" : link_to_edit_project(project, image_tag( "blank.png", :title => t('projects.edit_project_title'), :class=>"edit_item")) %>
diff --git a/app/views/search/results.rhtml b/app/views/search/results.rhtml index cb83a8d7..55367380 100644 --- a/app/views/search/results.rhtml +++ b/app/views/search/results.rhtml @@ -3,11 +3,11 @@ <% else -%> <% 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 } %> + <%= render :partial => "todos/todo", :collection => @found_todos, :locals => { :parent_container_type => 'search', :suppress_context => false, :suppress_project => false, :suppress_edit_button => false } %> <% end -%> <% 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 } %> + <%= render :partial => "projects/project_listing", :collection => @found_projects, :locals => { :suppress_drag_handle => true, :suppress_edit_button => true, :suppress_delete_button => true } %> <% end -%> <% render :layout => 'show_results_collection', :object => @found_notes, :locals => { :collection_name => "found-notes", :collection_title => t('search.notes_matching_query')} do %>