diff --git a/app/controllers/contexts_controller.rb b/app/controllers/contexts_controller.rb index d09883a4..348151aa 100644 --- a/app/controllers/contexts_controller.rb +++ b/app/controllers/contexts_controller.rb @@ -201,6 +201,9 @@ class ContextsController < ApplicationController :conditions => ['todos.state = ? AND (todos.project_id IS ? OR projects.state = ?)', 'active', nil, 'active'], :order => "todos.due IS NULL, todos.due ASC, todos.created_at ASC", :include => [:project, :tags]) + + @projects = current_user.projects + @count = @not_done_todos.size @default_project_context_name_map = build_default_project_context_name_map(@projects).to_json end diff --git a/app/controllers/todos_controller.rb b/app/controllers/todos_controller.rb index 99824886..8ccf710a 100644 --- a/app/controllers/todos_controller.rb +++ b/app/controllers/todos_controller.rb @@ -399,8 +399,9 @@ class TodosController < ApplicationController :limit => max_completed, :conditions => ['taggings.user_id = ? and state = ?', current_user.id, 'completed'], :order => 'todos.completed_at DESC') - - @contexts = current_user.contexts.find(:all) + + @projects = current_user.projects + @contexts = current_user.contexts @contexts_to_show = @contexts.reject {|x| x.hide? } # Set count badge to number of items with this tag diff --git a/app/helpers/todos_helper.rb b/app/helpers/todos_helper.rb index 46c30663..06671b26 100644 --- a/app/helpers/todos_helper.rb +++ b/app/helpers/todos_helper.rb @@ -242,13 +242,13 @@ module TodosHelper end def project_names_for_autocomplete - array_or_string_for_javascript( ['None'] + @projects.select{ |p| p.active? }.collect{|p| escape_javascript(p.name) } ) + array_or_string_for_javascript( ['None'] + current_user.projects.active.collect{|p| escape_javascript(p.name) } ) end def context_names_for_autocomplete # #return array_or_string_for_javascript(['Create a new context']) if # @contexts.empty? - array_or_string_for_javascript( @contexts.collect{|c| escape_javascript(c.name) } ) + array_or_string_for_javascript( current_user.contexts.collect{|c| escape_javascript(c.name) } ) end def format_ical_notes(notes) diff --git a/app/views/shared/_add_new_item_form.rhtml b/app/views/shared/_add_new_item_form.rhtml index 65316245..c84e0580 100644 --- a/app/views/shared/_add_new_item_form.rhtml +++ b/app/views/shared/_add_new_item_form.rhtml @@ -2,7 +2,7 @@ @todo = nil @initial_context_name = @context.name unless @context.nil? @initial_context_name ||= @project.default_context.name unless @project.nil? || @project.default_context.nil? - @initial_context_name ||= @contexts[0].name unless @contexts[0].nil? + @initial_context_name ||= current_user.contexts.first.name unless current_user.contexts.first.nil? @initial_project_name = @project.name unless @project.nil? %>