diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 99c3b7f6..260aef71 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -128,9 +128,13 @@ class ApplicationController < ActionController::Base end def for_autocomplete(coll, substr) - filtered = coll.find_all{|item| item.name.downcase.include? substr.downcase} - json_elems = "[{" + filtered.map {|item| "\"value\" : \"#{item.name}\", \"id\" : \"#{item.id}\""}.join("},{") + "}]" - return json_elems == "[{}]" ? "" : json_elems + if substr # protect agains empty request + filtered = coll.find_all{|item| item.name.downcase.include? substr.downcase} + json_elems = "[{" + filtered.map {|item| "\"value\" : \"#{item.name}\", \"id\" : \"#{item.id}\""}.join("},{") + "}]" + return json_elems == "[{}]" ? "" : json_elems + else + return "" + end end # Uses RedCloth to transform text using either Textile or Markdown Need to diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 77b6dc7c..fadf2db3 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -9,7 +9,6 @@ class ProjectsController < ApplicationController def index @source_view = params['_source_view'] || 'project_list' - @projects = current_user.projects.all @new_project = current_user.projects.build if params[:projects_and_actions] projects_and_actions @@ -18,6 +17,8 @@ class ProjectsController < ApplicationController init_not_done_counts(['project']) if params[:only_active_with_no_next_actions] @projects = current_user.projects.active.select { |p| count_undone_todos(p) == 0 } + else + @projects = current_user.projects.all end init_project_hidden_todo_counts(['project']) respond_to do |format| @@ -27,9 +28,7 @@ class ProjectsController < ApplicationController format.rss &render_rss_feed format.atom &render_atom_feed format.text &render_text_feed - format.autocomplete { - uncompleted_projects = current_user.projects.uncompleted(true) - render :text => for_autocomplete(uncompleted_projects, params[:term]) } + format.autocomplete { render :text => for_autocomplete(current_user.projects.uncompleted, params[:term]) } end end end @@ -139,7 +138,7 @@ class ProjectsController < ApplicationController render :template => 'projects/update.js.erb' return - # TODO: are these params ever set? or is this dead code? + # TODO: are these params ever set? or is this dead code? elsif boolean_param('update_status') render :template => 'projects/update_status.js.rjs' diff --git a/features/edit_a_todo.feature b/features/edit_a_todo.feature index 43693ded..7c13fe4d 100644 --- a/features/edit_a_todo.feature +++ b/features/edit_a_todo.feature @@ -15,10 +15,10 @@ Feature: Edit a next action from every page Scenario: I can delete a todo Given this is a pending scenario - Scenario: Deleting the last todo in context will hide context + Scenario: Removing the last todo in context will hide context # delete, edit Given this is a pending scenario - Scenario: Deleting the last todo in container will show empty message + Scenario: Deleting the last todo in container will show empty message # only project, context, tag, not todo Given this is a pending scenario Scenario: I can mark a todo complete