mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-28 12:58:48 +01:00
#300: Added infrastructure for drag and drop dependency creation
This commit is contained in:
parent
c8b442cc41
commit
fe066e3bcb
4 changed files with 33 additions and 5 deletions
|
|
@ -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
|
||||
#
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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})"
|
||||
)
|
||||
%>
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue