2011-01-06 23:01:17 +01:00
|
|
|
<% if !@saved -%>
|
|
|
|
|
TracksPages.page_notify('error', "Could not mark this todo complete", 5);
|
|
|
|
|
<% else -%>
|
|
|
|
|
<% if @wants_redirect_after_complete -%>
|
|
|
|
|
redirect_after_complete();
|
|
|
|
|
<% else
|
|
|
|
|
animation = []
|
|
|
|
|
animation << "remove_todo"
|
|
|
|
|
if @todo.completed?
|
|
|
|
|
animation << "add_to_completed_container"
|
|
|
|
|
animation << "add_new_recurring_todo"
|
|
|
|
|
animation << "activate_pending_todos"
|
|
|
|
|
animation << "remove_source_container"
|
|
|
|
|
else
|
|
|
|
|
animation << "add_todo_to_context"
|
|
|
|
|
animation << "block_predecessors"
|
|
|
|
|
end -%>
|
|
|
|
|
<%= render_animation(animation) %>
|
|
|
|
|
TracksPages.set_page_badge(<%= @down_count %>);
|
|
|
|
|
<% end -%>
|
|
|
|
|
<% end -%>
|
2008-08-05 11:00:04 +02:00
|
|
|
|
2011-01-06 23:01:17 +01:00
|
|
|
function redirect_after_complete() {
|
|
|
|
|
redirect_to("<%= project_path(@todo.project) -%>");
|
|
|
|
|
}
|
2009-04-14 21:36:57 +02:00
|
|
|
|
2011-01-06 23:01:17 +01:00
|
|
|
function remove_todo(next_steps) {
|
|
|
|
|
$('#<%= dom_id(@todo) %>').fadeOut(400, function() {
|
|
|
|
|
$('#<%= dom_id(@todo) %>').remove();
|
|
|
|
|
<%= show_empty_message_in_source_container -%>
|
|
|
|
|
next_steps.go();
|
|
|
|
|
});
|
|
|
|
|
}
|
2009-04-14 21:36:57 +02:00
|
|
|
|
2011-01-06 23:01:17 +01:00
|
|
|
function add_to_completed_container(next_steps) {
|
|
|
|
|
<% unless current_user.prefs.hide_completed_actions? -%>
|
|
|
|
|
$('#<%= item_container_id(@todo) %>').append(html_for_todo());
|
|
|
|
|
$("#empty-d").slideUp(100);
|
|
|
|
|
highlight_updated_todo(next_steps);
|
|
|
|
|
<% end -%>
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function add_todo_to_context(next_steps) {
|
|
|
|
|
$('#<%= item_container_id(@todo) %>').append(html_for_todo());
|
|
|
|
|
$('#c<%= @todo.context_id %>').fadeIn(500, function() {
|
|
|
|
|
highlight_updated_todo(next_steps);
|
|
|
|
|
<%= show_empty_message_in_source_container -%>
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function add_new_recurring_todo(next_steps) {
|
|
|
|
|
<% # show new todo if the completed todo was recurring
|
2008-08-05 11:00:04 +02:00
|
|
|
if @todo.from_recurring_todo?
|
2011-01-06 23:01:17 +01:00
|
|
|
unless @new_recurring_todo.nil? || @new_recurring_todo.deferred? -%>
|
|
|
|
|
$('#<%= item_container_id(@new_recurring_todo) %>').append(html_for_recurring_todo());
|
|
|
|
|
$('#c<%= @new_recurring_todo.context_id %>').fadeIn(500, function() {
|
|
|
|
|
highlight_updated_recurring_todo(next_steps);
|
|
|
|
|
});
|
|
|
|
|
<% else
|
|
|
|
|
if @todo.recurring_todo.todos.active.count == 0 && @new_recurring_todo.nil? -%>
|
|
|
|
|
TracksPages.page_notify('notice', "<%=t('todos.recurrence_completed')%>", 6);
|
|
|
|
|
<% end
|
2009-05-21 01:55:53 +02:00
|
|
|
end
|
2011-01-06 23:01:17 +01:00
|
|
|
end -%>
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
<% if @new_recurring_todo # hide js if @new_recurring_todo is not there-%>
|
|
|
|
|
function highlight_updated_recurring_todo(next_steps) {
|
|
|
|
|
highlight_todo('#<%= dom_id(@new_recurring_todo)%>');
|
|
|
|
|
next_steps.go();
|
|
|
|
|
}
|
|
|
|
|
<% end -%>
|
|
|
|
|
|
|
|
|
|
function highlight_updated_todo(next_steps) {
|
|
|
|
|
highlight_todo('#<%= dom_id(@todo)%>');
|
|
|
|
|
next_steps.go();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function highlight_todo(id) {
|
|
|
|
|
$(id).effect('highlight', {}, 2000, function(){ });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function activate_pending_todos(next_steps) {
|
|
|
|
|
<% # Activate pending todos that are successors of the completed
|
|
|
|
|
if @saved && @pending_to_activate
|
|
|
|
|
# do not render the js in case of an error or if no todos to activate
|
|
|
|
|
@pending_to_activate.each do |t|
|
|
|
|
|
if source_view_is(:project) or source_view_is(:tag) -%>
|
|
|
|
|
$('#<%= dom_id(t) %>').fadeOut(400, function() {
|
|
|
|
|
$('#<%= dom_id(t) %>').remove();
|
|
|
|
|
next_steps.go();
|
|
|
|
|
});
|
|
|
|
|
<% end -%>
|
2011-01-07 16:46:20 +01:00
|
|
|
$('#<%= item_container_id(t) %>').append("<%= escape_javascript(render(:partial => t, :locals => { :parent_container_type => parent_container_type }))%>");
|
2011-01-06 23:01:17 +01:00
|
|
|
highlight_todo('#<%= dom_id(t)%>');
|
|
|
|
|
<% end -%>
|
|
|
|
|
<% end -%>
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function block_predecessors(next_steps) {
|
|
|
|
|
<% # Activate pending todos that are successors of the completed
|
|
|
|
|
if @saved && @active_to_block
|
|
|
|
|
# do not render the js in case of an error or if no todos to block
|
|
|
|
|
@active_to_block.each do |t| %>
|
|
|
|
|
$('#<%= dom_id(t) %>').fadeOut(400, function() {
|
|
|
|
|
$('#<%= dom_id(t) %>').remove();
|
|
|
|
|
<% if source_view_is(:project) or source_view_is(:tag) # Insert it in deferred/pending block if existing -%>
|
2011-01-07 16:46:20 +01:00
|
|
|
$('#<%= item_container_id(t) %>').append("<%= escape_javascript(render(:partial => t, :locals => { :parent_container_type => parent_container_type }))%>");
|
2011-01-06 23:01:17 +01:00
|
|
|
highlight_todo('#<%= dom_id(t)%>');
|
|
|
|
|
<% end -%>
|
|
|
|
|
});
|
|
|
|
|
<% end -%>
|
|
|
|
|
next_steps.go();
|
|
|
|
|
<% end -%>
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function remove_source_container(next_steps) {
|
|
|
|
|
<% if (@remaining_in_context == 0 && source_view_is_one_of(:todo, :tag))
|
|
|
|
|
# remove context with deleted todo
|
|
|
|
|
-%>
|
|
|
|
|
$('#c<%=@todo.context_id%>').fadeOut(1000, function() {
|
|
|
|
|
next_steps.go();
|
|
|
|
|
});
|
|
|
|
|
<% end %>
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function html_for_todo() {
|
2011-01-07 16:46:20 +01:00
|
|
|
return "<%= @saved ? escape_javascript(render(:partial => @todo, :locals => { :parent_container_type => "completed" })) : "" %>";
|
2011-01-06 23:01:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function html_for_recurring_todo() {
|
2011-01-07 16:46:20 +01:00
|
|
|
return "<%= @saved ? escape_javascript(render(:partial => @new_recurring_todo, :locals => { :parent_container_type => parent_container_type })) : "" %>";
|
2011-01-06 23:01:17 +01:00
|
|
|
}
|