#300: Implemented basic drag and drop dependency support.

Dragging an action onto another action creates a dependency to that action.
This commit is contained in:
Henrik Bohre 2009-06-12 22:09:46 +02:00 committed by Eric Allen
parent fe066e3bcb
commit 00e063a0a2
5 changed files with 23 additions and 5 deletions

View file

@ -142,9 +142,13 @@ class TodosController < ApplicationController
end end
def add_predecessor def add_predecessor
logger.debug "add_predecessor"
@predecessor = Todo.find(params['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| respond_to do |format|
format.js format.js
end end

View file

@ -90,7 +90,7 @@ module TodosHelper
if @todo.completed? if @todo.completed?
"<span class=\"grey\">#{format_date( @todo.completed_at )}</span>" "<span class=\"grey\">#{format_date( @todo.completed_at )}</span>"
elsif @todo.pending? elsif @todo.pending?
"<a title='Depends on: #{@todo.predecessors.map(&:description).join(', ')}'><span class=\"orange\">Pending</span></a> " "<a title='Depends on: #{@todo.uncompleted_predecessors.map(&:description).join(', ')}'><span class=\"orange\">Pending</span></a> "
elsif @todo.deferred? elsif @todo.deferred?
show_date( @todo.show_from ) show_date( @todo.show_from )
else else
@ -109,7 +109,7 @@ module TodosHelper
def grip_span def grip_span
unless @todo.completed? unless @todo.completed?
image_tag('grip.png', :width => '7', :height => '16', :border => '0', 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') :class => 'grip')
end end
end end

View file

@ -41,7 +41,7 @@ parameters += "&_tag_name=#{@tag_name}" if @source_view == 'tag'
</div> </div>
</div> </div>
<%= <%=
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), drop_receiving_element(dom_id(todo),

View file

@ -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

BIN
public/images/grip.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 192 B