mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-18 00:00:12 +01:00
Ticket #300: Improved ajax behavior
Conflicts: app/views/todos/create.js.rjs app/views/todos/update.js.rjs
This commit is contained in:
parent
a91547265d
commit
d14d09559e
3 changed files with 20 additions and 2 deletions
|
|
@ -246,6 +246,7 @@ module TodosHelper
|
|||
return true if source_view_is(:project) && @todo.deferred?
|
||||
return true if !source_view_is(:deferred) && @todo.active?
|
||||
return true if source_view_is(:project) && @todo.pending?
|
||||
return true if source_view_is(:tag) && @todo.pending?
|
||||
return false
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ if @saved
|
|||
page.hide 'status'
|
||||
status_message = 'Added new next action'
|
||||
status_message += ' to tickler' if @todo.deferred?
|
||||
status_message += ' in pending state' if @todo.pending?
|
||||
status_message = 'Added new project / ' + status_message if @new_project_created
|
||||
status_message = 'Added new context / ' + status_message if @new_context_created
|
||||
page.notify :notice, status_message, 5.0
|
||||
|
|
@ -21,11 +22,20 @@ if @saved
|
|||
page.visual_effect :highlight, dom_id(@todo), :duration => 3
|
||||
page[empty_container_msg_div_id].hide unless empty_container_msg_div_id.nil?
|
||||
end
|
||||
# make sure the behavior of the new/updated todo is enabled
|
||||
if (source_view_is :project and @todo.pending?) or (source_view_is :deferred)
|
||||
page['tickler-empty-nd'].hide # For some reason this does not work: page['tickler-empty-nd'].hide if (@todo.pending? or (source_view_is :deferred))
|
||||
end
|
||||
end
|
||||
# Update predecessors (if they exist and are visible)
|
||||
@todo.uncompleted_predecessors.each do |p|
|
||||
page << "if ($(\'#{item_container_id(p)}\')) {"
|
||||
page[p].replace_html :partial => 'todos/todo',
|
||||
:locals => { :todo => p, :parent_container_type => parent_container_type }
|
||||
page << "}"
|
||||
end
|
||||
# make sure the behavior of the new/updated todo is enabled
|
||||
page << "TodoBehavior.enableToggleNotes()"
|
||||
page << "TodoBehavior.enableToggleSuccessors()"
|
||||
else
|
||||
page.show 'status'
|
||||
page.replace_html 'status', "#{error_messages_for('todo', :object_name => 'action')}"
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ if @saved
|
|||
page.notify :notice, status_message, 5.0
|
||||
|
||||
if source_view_is_one_of(:todo, :context, :tag)
|
||||
if @context_changed || @todo.deferred?
|
||||
if @context_changed || @todo.deferred? || @todo.pending?
|
||||
page[@todo].remove
|
||||
|
||||
if (@remaining_in_context == 0)
|
||||
|
|
@ -142,6 +142,13 @@ if @saved
|
|||
else
|
||||
logger.error "unexpected source_view '#{params[:_source_view]}'"
|
||||
end
|
||||
# Update predecessors (if they exist and are visible)
|
||||
@todo.uncompleted_predecessors.each do |p|
|
||||
page << "if ($(\'#{item_container_id(p)}\')) {"
|
||||
page[p].replace_html :partial => 'todos/todo',
|
||||
:locals => { :todo => p, :parent_container_type => parent_container_type }
|
||||
page << "}"
|
||||
end
|
||||
else
|
||||
page.show 'error_status'
|
||||
page.replace_html 'error_status', "#{error_messages_for('todo')}"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue