Don't allow defer past due date and popup with warning. Fixes #848.

This commit is contained in:
Eric Allen 2009-04-15 23:09:55 -04:00
parent 42bea2490b
commit 5b694bdf65

View file

@ -60,11 +60,21 @@ module TodosHelper
url = {:controller => 'todos', :action => 'defer', :id => todo.id, :days => days, url = {:controller => 'todos', :action => 'defer', :id => todo.id, :days => days,
:_source_view => (@source_view.underscore.gsub(/\s+/,'_') rescue "")} :_source_view => (@source_view.underscore.gsub(/\s+/,'_') rescue "")}
url[:_tag_name] = @tag_name if @source_view == 'tag' url[:_tag_name] = @tag_name if @source_view == 'tag'
return link_to_remote(
image_tag("defer_#{days}_off.png", :mouseover => "defer_#{days}.png", :alt => "", :align => "absmiddle")+" Defer #{pluralize(days, "day")}", futuredate = (@todo.show_from || @todo.user.date) + days.days
:url => url, puts "DUE: #{@todo.due}, futuredate: #{futuredate}"
:before => todo_start_waiting_js(todo), if @todo.due && futuredate > @todo.due
:complete => todo_stop_waiting_js) return link_to_function(
image_tag("defer_#{days}_off.png", :mouseover => "defer_#{days}.png", :alt => "", :align => "absmiddle")+" Defer #{pluralize(days, "day")}",
"alert('Defer date is after due date. Please edit and adjust due date before deferring.')"
)
else
return link_to_remote(
image_tag("defer_#{days}_off.png", :mouseover => "defer_#{days}.png", :alt => "", :align => "absmiddle")+" Defer #{pluralize(days, "day")}",
:url => url,
:before => todo_start_waiting_js(todo),
:complete => todo_stop_waiting_js)
end
end end
def todo_start_waiting_js(todo) def todo_start_waiting_js(todo)
@ -276,13 +286,5 @@ module TodosHelper
def image_tag_for_star(todo) def image_tag_for_star(todo)
class_str = todo.starred? ? "starred_todo" : "unstarred_todo" class_str = todo.starred? ? "starred_todo" : "unstarred_todo"
image_tag("blank.png", :title =>"Star action", :class => class_str) image_tag("blank.png", :title =>"Star action", :class => class_str)
end
def defer_link(days)
url = {:controller => 'todos', :action => 'defer', :id => @todo.id, :days => days,
:_source_view => (@source_view.underscore.gsub(/\s+/,'_') rescue "")}
url[:_tag_name] = @tag_name if @source_view == 'tag'
link_to_remote image_tag("defer_#{days}.png", :alt => "Defer #{pluralize(days, 'day')}"), :url => url
end end
end end