diff --git a/tracks/app/helpers/todos_helper.rb b/tracks/app/helpers/todos_helper.rb index 7b9ca745..ec6fa272 100644 --- a/tracks/app/helpers/todos_helper.rb +++ b/tracks/app/helpers/todos_helper.rb @@ -22,55 +22,71 @@ module TodosHelper :prevent_default => true end - def remote_delete_icon + def set_behavior_for_delete_icon parameters = "_source_view=#{@source_view}" parameters += "&_tag_name=#{@tag_name}" if @source_view == 'tag' - str = link_to( image_tag_for_delete, - todo_path(@todo), :id => "delete_icon_"+@todo.id.to_s, - :class => "icon delete_icon", :title => "delete the action '#{@todo.description}'") apply_behavior '.item-container a.delete_icon:click', :prevent_default => true do |page| page.confirming "'Are you sure that you want to ' + this.title + '?'" do page << "itemContainer = this.up('.item-container'); itemContainer.startWaiting();" page << remote_to_href(:method => 'delete', :with => "'#{parameters}'", :complete => "itemContainer.stopWaiting();") - end + end end + end + + def remote_delete_icon + str = link_to( image_tag_for_delete, + todo_path(@todo), :id => "delete_icon_"+@todo.id.to_s, + :class => "icon delete_icon", :title => "delete the action '#{@todo.description}'") + set_behavior_for_delete_icon str end + def set_behavior_for_star_icon + apply_behavior '.item-container a.star_item:click', + remote_to_href(:method => 'put', :with => "{ _source_view : '#{@source_view}' }"), + :prevent_default => true + end + def remote_star_icon str = link_to( image_tag_for_star(@todo), toggle_star_todo_path(@todo), :class => "icon star_item", :title => "star the action '#{@todo.description}'") - apply_behavior '.item-container a.star_item:click', - remote_to_href(:method => 'put', :with => "{ _source_view : '#{@source_view}' }"), - :prevent_default => true + set_behavior_for_star_icon str end - def remote_edit_icon + def set_behavior_for_edit_icon parameters = "_source_view=#{@source_view}" parameters += "&_tag_name=#{@tag_name}" if @source_view == 'tag' + apply_behavior '.item-container a.edit_icon:click', :prevent_default => true do |page| + page << "Effect.Pulsate(this);" + page << remote_to_href(:method => 'get', :with => "'#{parameters}'") + end + end + + def remote_edit_icon if !@todo.completed? str = link_to( image_tag_for_edit, edit_todo_path(@todo), :class => "icon edit_icon") - apply_behavior '.item-container a.edit_icon:click', :prevent_default => true do |page| - page << "Effect.Pulsate(this);" - page << remote_to_href(:method => 'get', :with => "'#{parameters}'") - end + set_behavior_for_edit_icon else str = '' + image_tag("blank.png") + " " end str end - def remote_toggle_checkbox - str = check_box_tag('item_id', toggle_check_todo_path(@todo), @todo.completed?, :class => 'item-checkbox') + def set_behavior_for_toggle_checkbox parameters = "_source_view=#{@source_view}" parameters += "&_tag_name=#{@tag_name}" if @source_view == 'tag' apply_behavior '.item-container input.item-checkbox:click', remote_function(:url => javascript_variable('this.value'), :method => 'put', - :with => "'#{parameters}'") + :with => "'#{parameters}'") + end + + def remote_toggle_checkbox + str = check_box_tag('item_id', toggle_check_todo_path(@todo), @todo.completed?, :class => 'item-checkbox') + set_behavior_for_toggle_checkbox str end diff --git a/tracks/app/views/contexts/_context.rhtml b/tracks/app/views/contexts/_context.rhtml index 59809d23..0c26b469 100644 --- a/tracks/app/views/contexts/_context.rhtml +++ b/tracks/app/views/contexts/_context.rhtml @@ -31,6 +31,14 @@

Currently there are no incomplete actions in this context

-<%= render :partial => "todos/todo", :collection => @not_done, :locals => { :parent_container_type => "context" } %> + <%= render :partial => "todos/todo", :collection => @not_done, :locals => { :parent_container_type => "context" } %> + <% if @not_done.empty? + # fix (hack) for #713 + set_behavior_for_delete_icon + set_behavior_for_star_icon + set_behavior_for_edit_icon + set_behavior_for_toggle_checkbox + end + -%> diff --git a/tracks/app/views/projects/_project.rhtml b/tracks/app/views/projects/_project.rhtml index 14f36f9b..c2cd4036 100644 --- a/tracks/app/views/projects/_project.rhtml +++ b/tracks/app/views/projects/_project.rhtml @@ -22,5 +22,13 @@

Currently there are no incomplete actions in this project

<%= render :partial => "todos/todo", :collection => @not_done, :locals => { :parent_container_type => "project" } %> + <% if @not_done.empty? + # fix (hack) for #713 + set_behavior_for_delete_icon + set_behavior_for_star_icon + set_behavior_for_edit_icon + set_behavior_for_toggle_checkbox + end + -%> \ No newline at end of file