mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-17 15:50:13 +01:00
Don't allow defer past due date and popup with warning. Fixes #848.
This commit is contained in:
parent
42bea2490b
commit
5b694bdf65
1 changed files with 15 additions and 13 deletions
|
|
@ -60,12 +60,22 @@ 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'
|
||||||
|
|
||||||
|
futuredate = (@todo.show_from || @todo.user.date) + days.days
|
||||||
|
puts "DUE: #{@todo.due}, futuredate: #{futuredate}"
|
||||||
|
if @todo.due && futuredate > @todo.due
|
||||||
|
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(
|
return link_to_remote(
|
||||||
image_tag("defer_#{days}_off.png", :mouseover => "defer_#{days}.png", :alt => "", :align => "absmiddle")+" Defer #{pluralize(days, "day")}",
|
image_tag("defer_#{days}_off.png", :mouseover => "defer_#{days}.png", :alt => "", :align => "absmiddle")+" Defer #{pluralize(days, "day")}",
|
||||||
:url => url,
|
:url => url,
|
||||||
:before => todo_start_waiting_js(todo),
|
:before => todo_start_waiting_js(todo),
|
||||||
:complete => todo_stop_waiting_js)
|
:complete => todo_stop_waiting_js)
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def todo_start_waiting_js(todo)
|
def todo_start_waiting_js(todo)
|
||||||
return "$('ul#{dom_id(todo)}').hide(); itemContainer = $('#{dom_id(todo)}'); itemContainer.startWaiting()"
|
return "$('ul#{dom_id(todo)}').hide(); itemContainer = $('#{dom_id(todo)}'); itemContainer.startWaiting()"
|
||||||
|
|
@ -277,12 +287,4 @@ module TodosHelper
|
||||||
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
|
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
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue