* added a "show always" radio to the recurring todo forms
* added a show_always flag to recurring todos
* created a migration to convert existing recurring todos where show_from_delta==0
* recurring todos where show_from_delta is 0 are now shown the same day they're due

Signed-off-by: Reinier Balt <lrbalt@gmail.com>
This commit is contained in:
piglop 2009-05-31 20:15:01 +08:00 committed by Reinier Balt
parent 8002eef8ab
commit 4e1e18da0f
6 changed files with 101 additions and 12 deletions

View file

@ -311,6 +311,10 @@ class RecurringTodo < ActiveRecord::Base
self.show_from_delta=days
end
def recurring_show_always=(value)
self.show_always=value
end
def recurrence_pattern
case recurring_period
when 'daily'
@ -380,9 +384,12 @@ class RecurringTodo < ActiveRecord::Base
def get_show_from_date(previous)
case self.target
when 'due_date'
# so set show from date relative to due date unless show_from_delta is
# zero / nil
return (self.show_from_delta == 0 || self.show_from_delta.nil?) ? nil : get_due_date(previous) - self.show_from_delta.days
# so set show from date relative to due date unless show_always is true or show_from_delta is nil
if self.show_always? or self.show_from_delta.nil?
nil
else
get_due_date(previous) - self.show_from_delta.days
end
when 'show_from_date'
# Leave due date empty
return get_next_date(previous)

View file

@ -134,10 +134,12 @@
</div>
<div id="recurring_target">
<label>Set recurrence on</label><br/>
<%= radio_button_tag('recurring_todo[recurring_target]', 'due_date', @recurring_todo.target == 'due_date')%> the date that the todo is due.
Show the todo <%=
text_field_tag( 'recurring_todo[recurring_show_days_before]', @recurring_todo.show_from_delta, {"size" => 3, "tabindex" => 12}) %>
days before the todo is due (0=show always)<br/>
<%= radio_button_tag('recurring_todo[recurring_target]', 'due_date', @recurring_todo.target == 'due_date')%> the date that the todo is due. Show the todo:
<%= radio_button_tag('recurring_todo[recurring_show_always]', '1', @recurring_todo.show_always?)%> always
<%= radio_button_tag('recurring_todo[recurring_show_always]', '0', !@recurring_todo.show_always?)%>
<%= text_field_tag( 'recurring_todo[recurring_show_days_before]', @recurring_todo.show_from_delta, {"size" => 3, "tabindex" => 12}) %>
days before the todo is due
<br/>
<%= radio_button_tag('recurring_todo[recurring_target]', 'show_from_date', @recurring_todo.target == 'show_from_date')%> the date todo comes from tickler (no due date set)<br/>
<br/>
</div>

View file

@ -132,10 +132,12 @@
</div>
<div id="recurring_target">
<label>Set recurrence on</label><br/>
<%= radio_button_tag('recurring_todo[recurring_target]', 'due_date', true)%> the date that the todo is due.
Show the todo <%=
text_field_tag( 'recurring_todo[recurring_show_days_before]', "0", {"size" => 3, "tabindex" => 12}) %>
days before the todo is due (0=show always)<br/>
<%= radio_button_tag('recurring_todo[recurring_target]', 'due_date', true)%> the date that the todo is due. Show the todo:
<%= radio_button_tag('recurring_todo[recurring_show_always]', '1', true)%> always
<%= radio_button_tag('recurring_todo[recurring_show_always]', '0', false)%>
<%= text_field_tag( 'recurring_todo[recurring_show_days_before]', "0", {"size" => 3, "tabindex" => 12}) %>
days before the todo is due
<br/>
<%= radio_button_tag('recurring_todo[recurring_target]', 'show_from_date', false)%> the date todo comes from tickler (no due date set)<br/>
<br/>
</div>