#300: Added infrastructure for drag and drop dependency creation

This commit is contained in:
Henrik Bohre 2009-06-10 00:07:23 +02:00 committed by Eric Allen
parent c8b442cc41
commit fe066e3bcb
4 changed files with 33 additions and 5 deletions

View file

@ -140,6 +140,15 @@ class TodosController < ApplicationController
format.xml { render :xml => @todo.to_xml( :root => 'todo', :except => :user_id ) }
end
end
def add_predecessor
logger.debug "add_predecessor"
@predecessor = Todo.find(params['predecessor'])
@successor = Todo.find(params['successor'])
respond_to do |format|
format.js
end
end
# Toggles the 'done' status of the action
#

View file

@ -106,6 +106,14 @@ module TodosHelper
end
end
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',
:class => 'grip')
end
end
def tag_list_text
@todo.tags.collect{|t| t.name}.join(', ')
end

View file

@ -22,6 +22,7 @@ parameters += "&_tag_name=#{@tag_name}" if @source_view == 'tag'
<% end %>
</ul></ul>
<div class="description<%= staleness_class( todo ) %>">
<%= grip_span %>
<%= date_span -%>
<span class="todo.descr"><%= h sanitize(todo.description) %></span>
<%= successors_span %>
@ -39,3 +40,13 @@ parameters += "&_tag_name=#{@tag_name}" if @source_view == 'tag'
<% end -%>
</div>
</div>
<%=
draggable_element(dom_id(todo), :revert => "'failure'", :handle => "'grip'", :onDrop => "''")
%>
<%=
drop_receiving_element(dom_id(todo),
:url => {:controller => "todos", :action => "add_predecessor"},
:with => "'successor=' + encodeURIComponent(element.id.split('_').last()) + '&predecessor=' + encodeURIComponent(#{todo.id})"
)
%>

View file

@ -381,11 +381,7 @@ input.item-checkbox {
.description, .stale_l1, .stale_l2, .stale_l3 {
margin-left: 60px;
position:relative;
}
.stale_l1, .stale_l2, .stale_l3 {
padding-left: 3px;
position:relative;
}
.stale_l1 {
@ -939,6 +935,10 @@ div.message {
color: #666;
}
.grip {
cursor: move;
}
/* Error message styles */
.fieldWithErrors {
padding: 2px;