fix #1268. The default context in the new todo form on the home page is now the first active context

Instead of the first context that could be hidden and thus appear random. Also fix setting the default context based on the project you select.
This commit is contained in:
Reinier Balt 2012-04-03 20:29:58 +02:00
parent 90c80c4330
commit c7637053e1
3 changed files with 7 additions and 5 deletions

View file

@ -18,8 +18,8 @@ class TodosController < ApplicationController
extend ActionView::Helpers::SanitizeHelper::ClassMethods
def index
@projects = current_user.projects.find(:all, :include => [:default_context])
@contexts = current_user.contexts.find(:all)
@projects = current_user.projects.all(:include => [:default_context])
@contexts = current_user.contexts
@contexts_to_show = current_user.contexts.active

View file

@ -1,4 +1,5 @@
module TodosHelper
def remote_star_icon(todo=@todo)
link_to( image_tag_for_star(todo),
@ -272,7 +273,7 @@ module TodosHelper
end
def default_contexts_for_autocomplete
projects = current_user.uncompleted.projects.find(:all, :include => [:context], :conditions => ['default_context_id is not null'])
projects = current_user.projects.uncompleted.find(:all, :include => [:default_context], :conditions => ['NOT(default_context_id IS NULL)'])
Hash[*projects.map{ |p| [escape_javascript(p.name), escape_javascript(p.default_context.name)] }.flatten].to_json
end

View file

@ -1,6 +1,7 @@
<%
@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 = @context.name if @context
@initial_context_name ||= @project.default_context.name unless @project.nil? || @project.default_context.nil?
@initial_context_name ||= @contexts.active.first.name unless @contexts.active.first.nil?
@initial_context_name ||= @contexts.first.name unless @contexts.first.nil?
@initial_project_name = @project.name unless @project.nil?
@initial_tags ||= @default_tags