mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-16 23:30:12 +01:00
parent
05cbea50aa
commit
67df223488
5 changed files with 45 additions and 5 deletions
|
|
@ -122,7 +122,7 @@ module TodosHelper
|
||||||
:title => 'Drag onto another action to make it depend on that action',
|
:title => 'Drag onto another action to make it depend on that action',
|
||||||
:class => 'grip') +
|
:class => 'grip') +
|
||||||
image_tag('blank.png', :width => 16, :height => 16, :border => 0,
|
image_tag('blank.png', :width => 16, :height => 16, :border => 0,
|
||||||
:title => "Drop an action to make it depend on this action", :class => 'successor_target')
|
:title => "Drop an action to make it depend on this action", :class => 'successor_target drop_target')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,4 +16,5 @@
|
||||||
</div>
|
</div>
|
||||||
<%= render :partial => "todos/todo", :collection => @not_done, :locals => { :parent_container_type => "context" } %>
|
<%= render :partial => "todos/todo", :collection => @not_done, :locals => { :parent_container_type => "context" } %>
|
||||||
</div><!-- [end:items] -->
|
</div><!-- [end:items] -->
|
||||||
|
<div id="c_<%=context.id%>_target" class="context_target drop_target"></div>
|
||||||
</div><!-- [end:c<%= context.id %>] -->
|
</div><!-- [end:c<%= context.id %>] -->
|
||||||
|
|
|
||||||
|
|
@ -153,3 +153,5 @@ else
|
||||||
page.show 'error_status'
|
page.show 'error_status'
|
||||||
page.replace_html 'error_status', "#{error_messages_for('todo')}"
|
page.replace_html 'error_status', "#{error_messages_for('todo')}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
page << "enable_rich_interaction();"
|
||||||
|
|
|
||||||
|
|
@ -232,21 +232,46 @@ function enable_rich_interaction(){
|
||||||
function drop_todo(evt, ui) {
|
function drop_todo(evt, ui) {
|
||||||
dragged_todo = ui.draggable[0].id.split('_')[2];
|
dragged_todo = ui.draggable[0].id.split('_')[2];
|
||||||
dropped_todo = $(this).parents('.item-show').get(0).id.split('_')[2];
|
dropped_todo = $(this).parents('.item-show').get(0).id.split('_')[2];
|
||||||
ui.draggable.hide();
|
ui.draggable.remove();
|
||||||
$(this).block({message: null});
|
$(this).block({message: null});
|
||||||
$.post(relative_to_root('todos/add_predecessor'),
|
$.post(relative_to_root('todos/add_predecessor'),
|
||||||
{successor: dragged_todo, predecessor: dropped_todo},
|
{successor: dragged_todo, predecessor: dropped_todo},
|
||||||
null, 'script');
|
null, 'script');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function drag_todo(){
|
||||||
|
$('.drop_target').show();
|
||||||
|
$(this).parents(".container").find(".context_target").hide();
|
||||||
|
}
|
||||||
|
|
||||||
$('.item-show').draggable({handle: '.grip',
|
$('.item-show').draggable({handle: '.grip',
|
||||||
revert: 'invalid',
|
revert: 'invalid',
|
||||||
start: function() {$('.successor_target').show();},
|
start: drag_todo,
|
||||||
stop: function() {$('.successor_target').hide();}});
|
stop: function() {$('.drop_target').hide();}});
|
||||||
|
|
||||||
$('.successor_target').droppable({drop: drop_todo,
|
$('.successor_target').droppable({drop: drop_todo,
|
||||||
tolerance: 'pointer',
|
tolerance: 'pointer',
|
||||||
hoverClass: 'hover'});
|
hoverClass: 'hover'});
|
||||||
|
|
||||||
|
/* Drag & drop for changing contexts */
|
||||||
|
function drop_todo_on_context(evt, ui) {
|
||||||
|
target = $(this);
|
||||||
|
dragged_todo = ui.draggable[0].id.split('_')[2];
|
||||||
|
context_id = this.id.split('_')[1];
|
||||||
|
ui.draggable.remove();
|
||||||
|
target.block({message: null});
|
||||||
|
setTimeout(function() {target.show()}, 0);
|
||||||
|
$.post(relative_to_root('todos/update'),
|
||||||
|
{id: dragged_todo,
|
||||||
|
"todo[id]": dragged_todo,
|
||||||
|
"todo[context_id]": context_id},
|
||||||
|
function(){target.unblock(); target.hide();}, 'script');
|
||||||
|
}
|
||||||
|
|
||||||
|
$('.context_target').droppable({
|
||||||
|
drop: drop_todo_on_context,
|
||||||
|
tolerance: 'pointer',
|
||||||
|
hoverClass: 'hover'});
|
||||||
|
|
||||||
/* Reset auto updater */
|
/* Reset auto updater */
|
||||||
field_touched = false;
|
field_touched = false;
|
||||||
|
|
|
||||||
|
|
@ -939,11 +939,14 @@ div.message {
|
||||||
cursor: move;
|
cursor: move;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.drop_target {
|
||||||
|
display:none;
|
||||||
|
}
|
||||||
|
|
||||||
.successor_target {
|
.successor_target {
|
||||||
background-image:url("../images/add_successor_off.png");
|
background-image:url("../images/add_successor_off.png");
|
||||||
background-repeat: no-repeat;
|
background-repeat: no-repeat;
|
||||||
background-position: center right;
|
background-position: center right;
|
||||||
display: none;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.successor_target.hover {
|
.successor_target.hover {
|
||||||
|
|
@ -952,6 +955,15 @@ div.message {
|
||||||
background-position: center right;
|
background-position: center right;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.context_target {
|
||||||
|
height: 15px;
|
||||||
|
margin: 4px;
|
||||||
|
border: thick dotted #CCC;
|
||||||
|
}
|
||||||
|
|
||||||
|
.context_target.hover {
|
||||||
|
}
|
||||||
|
|
||||||
/* Error message styles */
|
/* Error message styles */
|
||||||
.fieldWithErrors {
|
.fieldWithErrors {
|
||||||
padding: 2px;
|
padding: 2px;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue