diff --git a/app/controllers/todos_controller.rb b/app/controllers/todos_controller.rb
index 20afba9b..4ab166fc 100644
--- a/app/controllers/todos_controller.rb
+++ b/app/controllers/todos_controller.rb
@@ -142,9 +142,13 @@ class TodosController < ApplicationController
end
def add_predecessor
- logger.debug "add_predecessor"
@predecessor = Todo.find(params['predecessor'])
- @successor = Todo.find(params['successor'])
+ @todo = Todo.find(params['successor'])
+ @original_state = @todo.state
+ # Add predecessor
+ @todo.predecessors << @predecessor
+ @todo.state = 'pending'
+ @saved = @todo.save
respond_to do |format|
format.js
end
diff --git a/app/helpers/todos_helper.rb b/app/helpers/todos_helper.rb
index 111d0adf..6a2762d7 100644
--- a/app/helpers/todos_helper.rb
+++ b/app/helpers/todos_helper.rb
@@ -90,7 +90,7 @@ module TodosHelper
if @todo.completed?
"#{format_date( @todo.completed_at )}"
elsif @todo.pending?
- "Pending "
+ "Pending "
elsif @todo.deferred?
show_date( @todo.show_from )
else
@@ -109,7 +109,7 @@ module TodosHelper
def grip_span
unless @todo.completed?
image_tag('grip.png', :width => '7', :height => '16', :border => '0',
- :title => 'Drag onto another action to make it depend on this action',
+ :title => 'Drag onto another action to make it depend on that action',
:class => 'grip')
end
end
diff --git a/app/views/todos/_todo.html.erb b/app/views/todos/_todo.html.erb
index 59134ad9..ee2eab24 100644
--- a/app/views/todos/_todo.html.erb
+++ b/app/views/todos/_todo.html.erb
@@ -41,7 +41,7 @@ parameters += "&_tag_name=#{@tag_name}" if @source_view == 'tag'
<%=
-draggable_element(dom_id(todo), :revert => "'failure'", :handle => "'grip'", :onDrop => "''")
+draggable_element(dom_id(todo), :revert => "'true'", :handle => "'grip'", :onDrop => "''")
%>
<%=
drop_receiving_element(dom_id(todo),
diff --git a/app/views/todos/add_predecessor.js.rjs b/app/views/todos/add_predecessor.js.rjs
new file mode 100644
index 00000000..4b4d46ee
--- /dev/null
+++ b/app/views/todos/add_predecessor.js.rjs
@@ -0,0 +1,14 @@
+if @saved
+ # show update message
+ status_message = "Added #{@predecessor.description} as dependency."
+ unless @original_state == 'pending'
+ status_message += " #{@todo.description} set to pending"
+ page[@todo].remove
+ page['tickler-empty-nd'].hide
+ page.insert_html :bottom, item_container_id(@todo), :partial => 'todos/todo', :locals => { :todo => @todo, :parent_container_type => parent_container_type }
+ end
+ page.notify :notice, status_message, 5.0
+else
+ page.replace_html "status", content_tag("div", content_tag("h2", "Unable to add dependency"), "id" => "errorExplanation", "class" => "errorExplanation")
+end
+
diff --git a/public/images/grip.png b/public/images/grip.png
new file mode 100644
index 00000000..40e3d9e4
Binary files /dev/null and b/public/images/grip.png differ