mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-29 05:18:49 +01:00
#300: Fixes changes that broke drag and drop
This commit is contained in:
parent
cc9746371c
commit
c543eb3659
2 changed files with 15 additions and 8 deletions
|
|
@ -145,7 +145,7 @@ class TodosController < ApplicationController
|
|||
@todo = Todo.find(params['successor'])
|
||||
@original_state = @todo.state
|
||||
# Add predecessor
|
||||
@todo.predecessors << @predecessor
|
||||
@todo.add_predecessor(@predecessor)
|
||||
@todo.state = 'pending'
|
||||
@saved = @todo.save
|
||||
respond_to do |format|
|
||||
|
|
|
|||
|
|
@ -80,13 +80,15 @@ class Todo < ActiveRecord::Base
|
|||
if !show_from.blank? && show_from < user.date
|
||||
errors.add("show_from", "must be a date in the future")
|
||||
end
|
||||
# Validate predecessors array
|
||||
@predecessor_array.each do |description|
|
||||
t = Todo.find_by_description(description)
|
||||
if t.nil?
|
||||
errors.add("Depends on:", "Could not find action '#{description}'")
|
||||
else
|
||||
errors.add("Depends on:", "Adding '#{description}' would create a circular dependency") if is_successor?(t)
|
||||
unless @predecessor_array.nil?
|
||||
# Validate predecessors array
|
||||
@predecessor_array.each do |description|
|
||||
t = Todo.find_by_description(description)
|
||||
if t.nil?
|
||||
errors.add("Depends on:", "Could not find action '#{description}'")
|
||||
else
|
||||
errors.add("Depends on:", "Adding '#{description}' would create a circular dependency") if is_successor?(t)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -225,6 +227,11 @@ class Todo < ActiveRecord::Base
|
|||
end
|
||||
end
|
||||
|
||||
def add_predecessor(t)
|
||||
@predecessor_array = predecessors.map(&:description)
|
||||
@predecessor_array << t.description
|
||||
end
|
||||
|
||||
# Rich Todo API
|
||||
|
||||
def self.from_rich_message(user, default_context_id, description, notes)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue