cleanup debug messages

This commit is contained in:
Reinier Balt 2011-01-06 10:51:58 +01:00
parent f923a40a40
commit 7a893980c2
4 changed files with 41 additions and 57 deletions

View file

@ -161,9 +161,7 @@ class TodosController < ApplicationController
:description => line) :description => line)
@todo.project_id = @project_id @todo.project_id = @project_id
@todo.context_id = @context_id @todo.context_id = @context_id
puts "TODO: #{@todo.description}, #{@todo.project_id}, #{@todo.context_id}"
@saved = @todo.save @saved = @todo.save
puts "NOT SAVED" unless @saved
unless (@saved == false) || tag_list.blank? unless (@saved == false) || tag_list.blank?
@todo.tag_with(tag_list) @todo.tag_with(tag_list)
@todo.tags.reload @todo.tags.reload
@ -837,8 +835,8 @@ class TodosController < ApplicationController
source_view do |from| source_view do |from|
from.deferred { from.deferred {
# force reload to todos to get correct count and not a cached one # force reload to todos to get correct count and not a cached one
@remaining_in_context = current_user.contexts.find(context_id).todos(true).deferred_or_blocked.count @remaining_in_context = current_user.contexts.find(context_id).todos.deferred_or_blocked.count
@target_context_count = current_user.contexts.find(@todo.context_id).todos(true).deferred_or_blocked.count @target_context_count = current_user.contexts.find(@todo.context_id).todos.deferred_or_blocked.count
} }
from.tag { from.tag {
tag = Tag.find_by_name(params['_tag_name']) tag = Tag.find_by_name(params['_tag_name'])
@ -860,12 +858,8 @@ class TodosController < ApplicationController
@target_context_count = count_old_due_empty(@new_due_id) @target_context_count = count_old_due_empty(@new_due_id)
} }
end end
@remaining_in_context = current_user.contexts.find(context_id).not_done_todo_count if !@remaining_in_context @remaining_in_context = current_user.contexts.find(context_id).todos(true).not_hidden.count if !@remaining_in_context
@target_context_count = current_user.contexts.find(@todo.context_id).not_done_todo_count if !@target_context_count @target_context_count = current_user.contexts.find(@todo.context_id).todos(true).not_hidden.count if !@target_context_count
puts "@remaining_in_context = #{@remaining_in_context}"
puts "@target_context_count = #{@target_context_count}"
puts "@remaining_hidden_count = #{@remaining_hidden_count}"
puts "@remaining_deferred_or_pending_count = #{@remaining_deferred_or_pending_count}"
end end
def determine_completed_count def determine_completed_count
@ -1156,7 +1150,6 @@ class TodosController < ApplicationController
@original_item_due = @todo.due @original_item_due = @todo.due
@original_item_due_id = get_due_id_for_calendar(@todo.due) @original_item_due_id = get_due_id_for_calendar(@todo.due)
@original_item_predecessor_list = @todo.predecessors.map{|t| t.specification}.join(', ') @original_item_predecessor_list = @todo.predecessors.map{|t| t.specification}.join(', ')
puts "wh = #{@original_item_was_hidden}"
end end
def update_project def update_project
@ -1198,7 +1191,6 @@ class TodosController < ApplicationController
params["todo"]["context_id"] = context.id params["todo"]["context_id"] = context.id
end end
@context_changed = @original_item_context_id != params["todo"]["context_id"] = context.id @context_changed = @original_item_context_id != params["todo"]["context_id"] = context.id
puts "context changed into '#{context.name}'"
end end
def update_tags def update_tags
@ -1259,13 +1251,6 @@ class TodosController < ApplicationController
@due_date_changed = @original_item_due != @todo.due @due_date_changed = @original_item_due != @todo.due
@todo_hidden_state_changed = @original_item_was_hidden != @todo.hidden? @todo_hidden_state_changed = @original_item_was_hidden != @todo.hidden?
puts "@context_changed = #{@context_changed}"
puts "@project_changed = #{@project_changed}"
puts "@todo_was_activated_from_deferred_state #{@todo_was_activated_from_deferred_state}"
puts "@todo_was_deferred_from_active_state = #{@todo_was_deferred_from_active_state}"
puts "@due_date_changed = #{@due_date_changed}"
puts "@todo_hidden_state_changed = #{@todo_hidden_state_changed} @todo.hidden?=#{@todo.hidden?}"
source_view do |page| source_view do |page|
page.calendar do page.calendar do
@old_due_empty = is_old_due_empty(@original_item_due_id) @old_due_empty = is_old_due_empty(@original_item_due_id)
@ -1274,7 +1259,6 @@ class TodosController < ApplicationController
page.tag do page.tag do
@tag_name = params['_tag_name'] @tag_name = params['_tag_name']
@tag_was_removed = !@todo.has_tag?(@tag_name) @tag_was_removed = !@todo.has_tag?(@tag_name)
puts "@tag_was_removed = #{@tag_was_removed}"
end end
end end
end end

View file

@ -270,12 +270,13 @@ module TodosHelper
def update_needs_to_remove_todo_from_container def update_needs_to_remove_todo_from_container
source_view do |page| source_view do |page|
page.context { return @context_changed || @todo.deferred? || @todo.pending?} page.context { return @context_changed || @todo.deferred? || @todo.pending? }
page.project { return @todo_deferred_state_changed } page.project { return @todo_deferred_state_changed }
page.deferred { return @context_changed || !(@todo.deferred? || @todo.pending?) } page.deferred { return @context_changed || !(@todo.deferred? || @todo.pending?) }
page.calendar { return @due_date_changed || !@todo.due } page.calendar { return @due_date_changed || !@todo.due }
page.stats { return @todo.completed? } page.stats { return @todo.completed? }
page.tag { return (@context_changed && !@todo.hidden?) || @tag_was_removed || @todo_hidden_state_changed || @todo_deferred_state_changed } page.tag { return (@context_changed && !@todo.hidden?) || @tag_was_removed || @todo_hidden_state_changed || @todo_deferred_state_changed }
page.todo { return @context_changed || @todo.hidden? || @todo.deferred? || @todo.pending?}
end end
return false return false
end end
@ -288,6 +289,7 @@ module TodosHelper
page.calendar { return !@due_date_changed && @todo.due } page.calendar { return !@due_date_changed && @todo.due }
page.stats { return !@todo.completed? } page.stats { return !@todo.completed? }
page.tag { return !update_needs_to_remove_todo_from_container && !@tag_was_removed } page.tag { return !update_needs_to_remove_todo_from_container && !@tag_was_removed }
page.todo { return !update_needs_to_remove_todo_from_container }
end end
return false return false
end end
@ -300,21 +302,20 @@ module TodosHelper
page.calendar { return @due_date_changed && @todo.due } page.calendar { return @due_date_changed && @todo.due }
page.stats { return false } page.stats { return false }
page.tag { return update_needs_to_remove_todo_from_container && !@tag_was_removed} page.tag { return update_needs_to_remove_todo_from_container && !@tag_was_removed}
page.todo { return @context_changed && !(@todo.deferred? || @todo.pending? || @todo.hidden?) }
end end
return false return false
end end
def item_container_id (todo) def item_container_id (todo)
puts "todo.hidden?=#{todo.hidden?} en source_view=#{@source_view}"
return "hiddenitems" if source_view_is(:tag) && todo.hidden? return "hiddenitems" if source_view_is(:tag) && todo.hidden?
return "c#{todo.context_id}items" if source_view_is :deferred return "c#{todo.context_id}items" if source_view_is :deferred
return @new_due_id if source_view_is :calendar return @new_due_id if source_view_is :calendar
return "tickleritems" if todo.deferred? || todo.pending? return "tickleritems" if !source_view_is(:todo) && (todo.deferred? || todo.pending?)
return "p#{todo.project_id}items" if source_view_is :project return "p#{todo.project_id}items" if source_view_is :project
return "c#{todo.context_id}items" return "c#{todo.context_id}items"
end end
def empty_container_msg_div_id(todo = @todo || @successor) def empty_container_msg_div_id(todo = @todo || @successor)
raise Exception.new, "no @todo or @successor set" if !todo raise Exception.new, "no @todo or @successor set" if !todo
@ -336,6 +337,25 @@ module TodosHelper
return "c#{todo.context_id}empty-nd" return "c#{todo.context_id}empty-nd"
end end
def show_empty_message_in_source_container
container_id = ""
source_view do |page|
page.project {
container_id = "p#{@original_item_project_id}empty-nd" if @remaining_in_context == 0
container_id = "tickler-empty-nd" if @todo_was_activated_from_deferred_state && @remaining_deferred_or_pending_count == 0
}
page.deferred { container_id = "c#{@original_item_context_id}empty-nd" if @remaining_in_context == 0 }
page.calendar { container_id = "empty_#{@original_item_due_id}" if @old_due_empty }
page.tag {
container_id = "hidden-empty-nd" if !@todo.hidden? && @todo_hidden_state_changed && @remaining_hidden_count == 0
container_id = "tickler-empty-nd" if @todo_was_activated_from_deferred_state && @remaining_deferred_or_pending_count == 0
}
page.context { container_id = "c#{@original_item_context_id}empty-nd" if @remaining_in_context == 0 }
page.todo { container_id = "c#{@original_item_context_id}empty-nd" if @remaining_in_context == 0 }
end
return container_id.blank? ? "" : "$(\"##{container_id}\").slideDown(100);"
end
def render_animation(animation) def render_animation(animation)
html = "" html = ""
animation.each do |step| animation.each do |step|

View file

@ -28,11 +28,12 @@ class Todo < ActiveRecord::Base
named_scope :of_user, lambda { |user_id| {:conditions => ["todos.user_id = ? ", user_id] } } named_scope :of_user, lambda { |user_id| {:conditions => ["todos.user_id = ? ", user_id] } }
named_scope :hidden, named_scope :hidden,
:joins => :context, :joins => :context,
:conditions => ["todos.state = ? OR (contexts.hide = ? AND (todos.state = ? OR todos.state = ?))", :conditions => ["todos.state = ? OR (contexts.hide = ? AND (todos.state = ? OR todos.state = ? OR todos.state = ?))",
'project_hidden', true, 'active', 'deferred'] 'project_hidden', true, 'active', 'deferred', 'pending']
named_scope :not_hidden, named_scope :not_hidden,
:joins => [:context, :project], :joins => [:context, :project],
:conditions => ['contexts.hide = ? AND (projects.state = ? OR todos.project_id IS NULL)', false, 'active'] :conditions => ['NOT(todos.state = ? OR (contexts.hide = ? AND (todos.state = ? OR todos.state = ? OR todos.state = ?)))',
'project_hidden', true, 'active', 'deferred', 'pending']
STARRED_TAG_NAME = "starred" STARRED_TAG_NAME = "starred"
@ -210,12 +211,10 @@ class Todo < ActiveRecord::Base
end end
def hidden? def hidden?
puts "hidden => state = #{self.state} context(#{self.context.name}).hidden=#{self.context.hidden?}"
return self.state == 'project_hidden' || ( self.context.hidden? && (self.state == 'active' || self.state == 'deferred')) return self.state == 'project_hidden' || ( self.context.hidden? && (self.state == 'active' || self.state == 'deferred'))
end end
def update_state_from_project def update_state_from_project
puts "state was #{self.state}; project.hidden?=#{self.project.hidden?}"
if state == 'project_hidden' and !self.project.hidden? if state == 'project_hidden' and !self.project.hidden?
if self.uncompleted_predecessors.empty? if self.uncompleted_predecessors.empty?
self.state = 'active' self.state = 'active'

View file

@ -2,9 +2,9 @@
TracksPages.show_edit_errors(html_for_error_messages()); TracksPages.show_edit_errors(html_for_error_messages());
<% else <% else
# jquery animations are async, so first collect all animation steps, # jquery animations are async, so first collect all animation steps that need
# then execute them sequential. All steps are functions which are passed a function # to be run sequential,then execute them. All steps are functions which are
# with the next animation steps # passed a function as parameter that will execute the next animation steps
animation = [] animation = []
animation << "remove_todo" if update_needs_to_remove_todo_from_container animation << "remove_todo" if update_needs_to_remove_todo_from_container
@ -25,26 +25,7 @@
function remove_todo(next_steps) { function remove_todo(next_steps) {
$('#<%= dom_id(@todo) %>').fadeOut(400, function() { $('#<%= dom_id(@todo) %>').fadeOut(400, function() {
$('#<%= dom_id(@todo) %>').remove(); $('#<%= dom_id(@todo) %>').remove();
<%= show_empty_message_in_source_container -%>
<% # TODO: to helper function: show_empty_message_source_container
container_id = ""
source_view do |page|
page.project {
container_id = "p#{@original_item_project_id}empty-nd" if @remaining_in_context == 0
container_id = "tickler-empty-nd" if @todo_was_activated_from_deferred_state && @remaining_deferred_or_pending_count == 0
}
page.deferred { container_id = "c#{@original_item_context_id}empty-nd" if @remaining_in_context == 0 }
page.calendar { container_id = "empty_#{@original_item_due_id}" if @old_due_empty }
page.tag {
container_id = "hidden-empty-nd" if !@todo.hidden? && @todo_hidden_state_changed && @remaining_hidden_count == 0
container_id = "tickler-empty-nd" if @todo_was_activated_from_deferred_state && @remaining_deferred_or_pending_count == 0
}
page.context { container_id = "c#{@original_item_context_id}empty-nd" if @remaining_in_context == 0 }
end
unless container_id.blank?
-%>
$("#<%= container_id%>").slideDown(100);
<% end -%>
next_steps.go(); next_steps.go();
}); });
} }