diff --git a/app/helpers/todos_helper.rb b/app/helpers/todos_helper.rb index 45bdcb3c..6721059c 100644 --- a/app/helpers/todos_helper.rb +++ b/app/helpers/todos_helper.rb @@ -246,6 +246,7 @@ module TodosHelper return true if source_view_is(:project) && @todo.deferred? return true if !source_view_is(:deferred) && @todo.active? return true if source_view_is(:project) && @todo.pending? + return true if source_view_is(:tag) && @todo.pending? return false end diff --git a/app/views/todos/create.js.rjs b/app/views/todos/create.js.rjs index f4e750b6..61943463 100644 --- a/app/views/todos/create.js.rjs +++ b/app/views/todos/create.js.rjs @@ -2,6 +2,7 @@ if @saved page.hide 'status' status_message = 'Added new next action' status_message += ' to tickler' if @todo.deferred? + status_message += ' in pending state' if @todo.pending? status_message = 'Added new project / ' + status_message if @new_project_created status_message = 'Added new context / ' + status_message if @new_context_created page.notify :notice, status_message, 5.0 @@ -21,11 +22,20 @@ if @saved page.visual_effect :highlight, dom_id(@todo), :duration => 3 page[empty_container_msg_div_id].hide unless empty_container_msg_div_id.nil? end - # make sure the behavior of the new/updated todo is enabled if (source_view_is :project and @todo.pending?) or (source_view_is :deferred) page['tickler-empty-nd'].hide # For some reason this does not work: page['tickler-empty-nd'].hide if (@todo.pending? or (source_view_is :deferred)) end end + # Update predecessors (if they exist and are visible) + @todo.uncompleted_predecessors.each do |p| + page << "if ($(\'#{item_container_id(p)}\')) {" + page[p].replace_html :partial => 'todos/todo', + :locals => { :todo => p, :parent_container_type => parent_container_type } + page << "}" + end + # make sure the behavior of the new/updated todo is enabled + page << "TodoBehavior.enableToggleNotes()" + page << "TodoBehavior.enableToggleSuccessors()" else page.show 'status' page.replace_html 'status', "#{error_messages_for('todo', :object_name => 'action')}" diff --git a/app/views/todos/update.js.rjs b/app/views/todos/update.js.rjs index a1d0cfab..6cdf7367 100644 --- a/app/views/todos/update.js.rjs +++ b/app/views/todos/update.js.rjs @@ -7,7 +7,7 @@ if @saved page.notify :notice, status_message, 5.0 if source_view_is_one_of(:todo, :context, :tag) - if @context_changed || @todo.deferred? + if @context_changed || @todo.deferred? || @todo.pending? page[@todo].remove if (@remaining_in_context == 0) @@ -142,6 +142,13 @@ if @saved else logger.error "unexpected source_view '#{params[:_source_view]}'" end + # Update predecessors (if they exist and are visible) + @todo.uncompleted_predecessors.each do |p| + page << "if ($(\'#{item_container_id(p)}\')) {" + page[p].replace_html :partial => 'todos/todo', + :locals => { :todo => p, :parent_container_type => parent_container_type } + page << "}" + end else page.show 'error_status' page.replace_html 'error_status', "#{error_messages_for('todo')}"