fix editing a todo from tag view

saving worked, but the edit form did not disappear and the updated todo did not show up in the right place
This commit is contained in:
Reinier Balt 2008-07-24 23:22:16 +02:00
parent 49aac48616
commit 186fd5694d
3 changed files with 19 additions and 9 deletions

View file

@ -542,11 +542,17 @@ class TodosController < ApplicationController
end
def determine_remaining_in_context_count(context_id = @todo.context_id)
if source_view_is :deferred
@remaining_in_context = current_user.contexts.find(context_id).deferred_todo_count
else
@remaining_in_context = current_user.contexts.find(context_id).not_done_todo_count
source_view do |from|
from.deferred { @remaining_in_context = current_user.contexts.find(context_id).deferred_todo_count }
from.tag {
tag = Tag.find_by_name(params['_tag_name'])
if tag.nil?
tag = Tag.new(:name => params['tag'])
end
@remaining_in_context = current_user.contexts.find(context_id).not_done_todo_count({:tag => tag.id})
}
end
@remaining_in_context = current_user.contexts.find(context_id).not_done_todo_count if @remaining_in_context.nil?
end
def determine_completed_count

View file

@ -9,7 +9,7 @@ if @saved
# #update auto completer arrays for context and project
page << "contextAutoCompleter.options.array = #{context_names_for_autocomplete}; contextAutoCompleter.changed = true" if @new_context_created
page << "projectAutoCompleter.options.array = #{project_names_for_autocomplete}; projectAutoCompleter.changed = true" if @new_project_created
if source_view_is_one_of(:todo, :context)
if source_view_is_one_of(:todo, :context, :tag)
if @context_changed || @todo.deferred?
page[@todo].remove
@ -17,11 +17,12 @@ if @saved
# remove context container from page if empty
source_view do |from|
from.todo { page.visual_effect :fade, "c#{@original_item_context_id}", :duration => 0.4 }
from.tag { page.visual_effect :fade, "c#{@original_item_context_id}", :duration => 0.4 }
from.context { page.show "c#{@original_item_context_id}empty-nd" }
end
end
if source_view_is(:todo) && @todo.active?
if source_view_is_one_of(:todo, :tag) && @todo.active?
page.call "todoItems.ensureVisibleWithEffectAppear", "c#{@todo.context_id}"
page.call "todoItems.expandNextActionListingByContext", "c#{@todo.context_id}items", true
page[empty_container_msg_div_id].hide unless empty_container_msg_div_id.nil?
@ -36,7 +37,7 @@ if @saved
# show todo in context
page.delay(0.5) do
page.call "todoItems.ensureContainerHeight", "c#{@original_item_context_id}items"
if source_view_is(:todo) && @todo.active?
if source_view_is_one_of(:todo, :tag) && @todo.active?
page.call "todoItems.ensureContainerHeight", "c#{@todo.context_id}items"
page.visual_effect :highlight, dom_id(@todo), :duration => 3
end

View file

@ -36,9 +36,12 @@ module Tracks
def with_not_done_scope(opts={})
conditions = ["todos.state = ?", 'active']
if opts.has_key?(:include_project_hidden_todos) && (opts[:include_project_hidden_todos] == true)
conditions = ["(todos.state = ? or todos.state = ?)", 'active', 'project_hidden']
conditions = ["(todos.state = ? OR todos.state = ?)", 'active', 'project_hidden']
end
self.todos.send :with_scope, :find => {:conditions => conditions} do
if opts.has_key?(:tag)
conditions = ["todos.state = ? AND taggings.tag_id = ?", 'active', opts[:tag]]
end
self.todos.send :with_scope, :find => {:conditions => conditions, :include => [:taggings]} do
yield
end
end