add recurring todos to tracks

This commit is contained in:
Reinier Balt 2008-07-19 20:27:45 +02:00
parent c46f0a8e04
commit 8bc41e2cb0
41 changed files with 2576 additions and 632 deletions

View file

@ -0,0 +1,73 @@
module RecurringTodosHelper
def recurrence_time_span(rt)
case rt.ends_on
when "no_end_date"
return ""
when "ends_on_number_of_times"
return "for "+rt.number_of_occurences.to_s + " times"
when "ends_on_end_date"
starts = rt.start_from.nil? ? "" : "from " + format_date(rt.start_from)
ends = rt.end_date.nil? ? "" : " until " + format_date(rt.end_date)
return starts+ends
else
raise Exception.new, "unknown recurrence time span selection (#{self.ends_on})"
end
end
def recurrence_target(rt)
case rt.target
when 'due_date'
return "due"
when 'show_from_date'
return "show"
else
return "ERROR"
end
end
def recurring_todo_tag_list
tags_except_starred = @recurring_todo.tags.reject{|t| t.name == Todo::STARRED_TAG_NAME}
tag_list = tags_except_starred.collect{|t| "<span class=\"tag #{t.name.gsub(' ','-')}\">" +
# link_to(t.name, :controller => "todos", :action => "tag", :id =>
# t.name) + TODO: tag view for recurring_todos (yet?)
t.name +
"</span>"}.join('')
"<span class='tags'>#{tag_list}</span>"
end
def recurring_todo_remote_delete_icon
str = link_to( image_tag_for_delete,
recurring_todo_path(@recurring_todo), :id => "delete_icon_"+@recurring_todo.id.to_s,
:class => "icon delete_icon", :title => "delete the recurring action '#{@recurring_todo.description}'")
set_behavior_for_delete_icon
str
end
def recurring_todo_remote_star_icon
str = link_to( image_tag_for_star(@recurring_todo),
toggle_star_recurring_todo_path(@recurring_todo),
:class => "icon star_item", :title => "star the action '#{@recurring_todo.description}'")
set_behavior_for_star_icon
str
end
def recurring_todo_remote_edit_icon
if !@recurring_todo.completed?
str = link_to( image_tag_for_edit(@recurring_todo),
edit_recurring_todo_path(@recurring_todo),
:class => "icon edit_icon")
set_behavior_for_edit_icon
else
str = '<a class="icon">' + image_tag("blank.png") + "</a> "
end
str
end
def recurring_todo_remote_toggle_checkbox
str = check_box_tag('item_id', toggle_check_recurring_todo_path(@recurring_todo), @recurring_todo.completed?, :class => 'item-checkbox')
set_behavior_for_toggle_checkbox
str
end
end

View file

@ -47,7 +47,7 @@ module TodosHelper
:prevent_default => true
end
def remote_star_icon
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}'")
@ -66,7 +66,7 @@ module TodosHelper
def remote_edit_icon
if !@todo.completed?
str = link_to( image_tag_for_edit,
str = link_to( image_tag_for_edit(@todo),
edit_todo_path(@todo),
:class => "icon edit_icon")
set_behavior_for_edit_icon
@ -205,12 +205,12 @@ module TodosHelper
javascript_tag str
end
def item_container_id
def item_container_id (todo)
if source_view_is :project
return "p#{@todo.project_id}" if @todo.active?
return "tickler" if @todo.deferred?
return "p#{todo.project_id}" if todo.active?
return "tickler" if todo.deferred?
end
return "c#{@todo.context_id}"
return "c#{todo.context_id}"
end
def should_show_new_item
@ -272,8 +272,8 @@ module TodosHelper
image_tag("blank.png", :title =>"Delete action", :class=>"delete_item")
end
def image_tag_for_edit
image_tag("blank.png", :title =>"Edit action", :class=>"edit_item", :id=> dom_id(@todo, 'edit_icon'))
def image_tag_for_edit(todo)
image_tag("blank.png", :title =>"Edit action", :class=>"edit_item", :id=> dom_id(todo, 'edit_icon'))
end
def image_tag_for_star(todo)
@ -281,4 +281,4 @@ module TodosHelper
image_tag("blank.png", :title =>"Star action", :class => class_str)
end
end
end