|
8bc41e2c
»
|
lrbalt |
2008-07-19 |
add recurring todos to tracks |
1 |
module RecurringTodosHelper |
| |
2 |
|
| |
3 |
def recurrence_time_span(rt) |
| |
4 |
case rt.ends_on |
| |
5 |
when "no_end_date" |
|
5659b8ad
»
|
lrbalt |
2008-11-29 |
fix #764 where unnecessary ... |
6 |
return rt.start_from.nil? ? "" : "from " + format_date(rt.start_from) |
|
8bc41e2c
»
|
lrbalt |
2008-07-19 |
add recurring todos to tracks |
7 |
when "ends_on_number_of_times" |
| |
8 |
return "for "+rt.number_of_occurences.to_s + " times" |
| |
9 |
when "ends_on_end_date" |
| |
10 |
starts = rt.start_from.nil? ? "" : "from " + format_date(rt.start_from) |
| |
11 |
ends = rt.end_date.nil? ? "" : " until " + format_date(rt.end_date) |
| |
12 |
return starts+ends |
| |
13 |
else |
|
5659b8ad
»
|
lrbalt |
2008-11-29 |
fix #764 where unnecessary ... |
14 |
raise Exception.new, "unknown recurrence time span selection (#{self.ends_on})" |
|
8bc41e2c
»
|
lrbalt |
2008-07-19 |
add recurring todos to tracks |
15 |
end |
| |
16 |
end |
| |
17 |
|
| |
18 |
def recurrence_target(rt) |
| |
19 |
case rt.target |
| |
20 |
when 'due_date' |
| |
21 |
return "due" |
| |
22 |
when 'show_from_date' |
| |
23 |
return "show" |
| |
24 |
else |
| |
25 |
return "ERROR" |
| |
26 |
end |
| |
27 |
end |
| |
28 |
|
| |
29 |
def recurring_todo_tag_list |
| |
30 |
tags_except_starred = @recurring_todo.tags.reject{|t| t.name == Todo::STARRED_TAG_NAME} |
|
5659b8ad
»
|
lrbalt |
2008-11-29 |
fix #764 where unnecessary ... |
31 |
tag_list = tags_except_starred.collect{|t| "<span class=\"tag #{t.name.gsub(' ','-')}\">" + |
|
8bc41e2c
»
|
lrbalt |
2008-07-19 |
add recurring todos to tracks |
32 |
# link_to(t.name, :controller => "todos", :action => "tag", :id => |
| |
33 |
# t.name) + TODO: tag view for recurring_todos (yet?) |
|
5659b8ad
»
|
lrbalt |
2008-11-29 |
fix #764 where unnecessary ... |
34 |
t.name + |
|
8bc41e2c
»
|
lrbalt |
2008-07-19 |
add recurring todos to tracks |
35 |
"</span>"}.join('') |
| |
36 |
"<span class='tags'>#{tag_list}</span>" |
| |
37 |
end |
| |
38 |
|
| |
39 |
def recurring_todo_remote_delete_icon |
| |
40 |
str = link_to( image_tag_for_delete, |
| |
41 |
recurring_todo_path(@recurring_todo), :id => "delete_icon_"+@recurring_todo.id.to_s, |
| |
42 |
:class => "icon delete_icon", :title => "delete the recurring action '#{@recurring_todo.description}'") |
| |
43 |
set_behavior_for_delete_icon |
| |
44 |
str |
| |
45 |
end |
| |
46 |
|
|
5659b8ad
»
|
lrbalt |
2008-11-29 |
fix #764 where unnecessary ... |
47 |
def recurring_todo_remote_star_icon |
|
8bc41e2c
»
|
lrbalt |
2008-07-19 |
add recurring todos to tracks |
48 |
str = link_to( image_tag_for_star(@recurring_todo), |
| |
49 |
toggle_star_recurring_todo_path(@recurring_todo), |
| |
50 |
:class => "icon star_item", :title => "star the action '#{@recurring_todo.description}'") |
| |
51 |
set_behavior_for_star_icon |
| |
52 |
str |
| |
53 |
end |
| |
54 |
|
| |
55 |
def recurring_todo_remote_edit_icon |
| |
56 |
if !@recurring_todo.completed? |
| |
57 |
str = link_to( image_tag_for_edit(@recurring_todo), |
| |
58 |
edit_recurring_todo_path(@recurring_todo), |
| |
59 |
:class => "icon edit_icon") |
| |
60 |
set_behavior_for_edit_icon |
| |
61 |
else |
| |
62 |
str = '<a class="icon">' + image_tag("blank.png") + "</a> " |
| |
63 |
end |
| |
64 |
str |
| |
65 |
end |
| |
66 |
|
| |
67 |
def recurring_todo_remote_toggle_checkbox |
| |
68 |
str = check_box_tag('item_id', toggle_check_recurring_todo_path(@recurring_todo), @recurring_todo.completed?, :class => 'item-checkbox') |
| |
69 |
set_behavior_for_toggle_checkbox |
| |
70 |
str |
| |
71 |
end |
| |
72 |
|
| |
73 |
end |