mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-18 16:20:12 +01:00
#300: Updated projects and todos controllers to use Todo dependencies.
This commit is contained in:
parent
ced0e8f531
commit
cb4ed7ff7f
2 changed files with 20 additions and 1 deletions
|
|
@ -47,10 +47,11 @@ class ProjectsController < ApplicationController
|
|||
|
||||
@not_done = @project.not_done_todos_including_hidden
|
||||
@deferred = @project.deferred_todos
|
||||
@pending = @project.pending_todos
|
||||
@done = @project.todos.find_in_state(:all, :completed, :order => "todos.completed_at DESC", :limit => current_user.prefs.show_number_completed, :include => [:context])
|
||||
|
||||
@count = @not_done.size
|
||||
@down_count = @count + @deferred.size
|
||||
@down_count = @count + @deferred.size + @pending.size
|
||||
@next_project = current_user.projects.next_from(@project)
|
||||
@previous_project = current_user.projects.previous_from(@project)
|
||||
@default_tags = @project.default_tags
|
||||
|
|
|
|||
|
|
@ -142,6 +142,24 @@ class TodosController < ApplicationController
|
|||
# check if this todo has a related recurring_todo. If so, create next todo
|
||||
@new_recurring_todo = check_for_next_todo(@todo) if @saved
|
||||
|
||||
if @todo.completed?
|
||||
logger.debug "completed #{@todo.description}"
|
||||
# A todo was completed - check for pending todos
|
||||
@todo.successors.each do |t|
|
||||
if t.uncompleted_predecessors.empty? # Activate pending todos
|
||||
logger.debug "activated #{t.description}"
|
||||
t.activate!
|
||||
end
|
||||
end
|
||||
else
|
||||
# Block todos for undone actions - (it does no harm if they are already pending)
|
||||
logger.debug "undid #{@todo.description}"
|
||||
@todo.successors.each do |t|
|
||||
logger.debug "blocked #{t.description}"
|
||||
t.block!
|
||||
end
|
||||
end
|
||||
|
||||
respond_to do |format|
|
||||
format.js do
|
||||
if @saved
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue