mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-17 07:40:12 +01:00
Fix rendering of successors, drag and drop
This commit is contained in:
parent
34aeb83891
commit
d0a5f6b731
7 changed files with 24 additions and 20 deletions
|
|
@ -69,6 +69,10 @@ module TodosHelper
|
||||||
return "$('#ul#{dom_id(todo)}').css('visibility', 'hidden'); $('##{dom_id(todo)}').block({message: null})"
|
return "$('#ul#{dom_id(todo)}').css('visibility', 'hidden'); $('##{dom_id(todo)}').block({message: null})"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def successor_start_waiting_js(successor)
|
||||||
|
return "$('##{dom_id(successor, "successor")}').block({message: null})"
|
||||||
|
end
|
||||||
|
|
||||||
def todo_stop_waiting_js(todo)
|
def todo_stop_waiting_js(todo)
|
||||||
return "$('##{dom_id(todo)}').unblock();enable_rich_interaction();"
|
return "$('##{dom_id(todo)}').unblock();enable_rich_interaction();"
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -16,8 +16,7 @@ parameters += "&_tag_name=#{@tag_name}" if @source_view == 'tag'
|
||||||
{:url => {:controller => 'todos', :action => 'remove_predecessor', :id => successor.id},
|
{:url => {:controller => 'todos', :action => 'remove_predecessor', :id => successor.id},
|
||||||
:method => 'delete',
|
:method => 'delete',
|
||||||
:with => "'#{parameters}&predecessor=#{predecessor.id}'",
|
:with => "'#{parameters}&predecessor=#{predecessor.id}'",
|
||||||
:before => todo_start_waiting_js(dom_id(successor, 'successor')),
|
:before => successor_start_waiting_js(successor)},
|
||||||
:complete => todo_stop_waiting_js},
|
|
||||||
{:style => "background: transparent;"}) %>
|
{:style => "background: transparent;"}) %>
|
||||||
|
|
||||||
<%= render(:partial => "todos/toggle_successors", :locals => { :item => successor, :suppress_button => true }) unless successor.pending_successors.empty? %>
|
<%= render(:partial => "todos/toggle_successors", :locals => { :item => successor, :suppress_button => true }) unless successor.pending_successors.empty? %>
|
||||||
|
|
|
||||||
|
|
@ -45,14 +45,3 @@ parameters += "&_tag_name=#{@tag_name}" if @source_view == 'tag'
|
||||||
<% end -%>
|
<% end -%>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<%=
|
|
||||||
draggable_element(dom_id(todo), :revert => "'true'", :handle => "'grip'", :onDrop => "''")
|
|
||||||
%>
|
|
||||||
<%=
|
|
||||||
drop_receiving_element(dom_id(todo),
|
|
||||||
:url => {:controller => "todos", :action => "add_predecessor"},
|
|
||||||
:with => "'#{parameters}&successor=' + encodeURIComponent(element.id.split('_').last()) + '&predecessor=' + encodeURIComponent(#{todo.id})",
|
|
||||||
:hoverclass => 'hover'
|
|
||||||
)
|
|
||||||
%>
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,8 +19,6 @@ if @saved
|
||||||
:pending => @todo.project.pending_todos }
|
:pending => @todo.project.pending_todos }
|
||||||
end
|
end
|
||||||
|
|
||||||
page << "TodoBehavior.enableToggleNotes();"
|
|
||||||
page << "TodoBehavior.enableToggleSuccessors();"
|
|
||||||
page.notify :notice, status_message, 5.0
|
page.notify :notice, status_message, 5.0
|
||||||
else
|
else
|
||||||
page.replace_html "status", content_tag("div", content_tag("h2", "Unable to add dependency"), "id" => "errorExplanation", "class" => "errorExplanation")
|
page.replace_html "status", content_tag("div", content_tag("h2", "Unable to add dependency"), "id" => "errorExplanation", "class" => "errorExplanation")
|
||||||
|
|
|
||||||
|
|
@ -34,8 +34,7 @@ if @saved
|
||||||
page << "}"
|
page << "}"
|
||||||
end
|
end
|
||||||
# make sure the behavior of the new/updated todo is enabled
|
# make sure the behavior of the new/updated todo is enabled
|
||||||
page << "TodoBehavior.enableToggleNotes()"
|
page << "enable_rich_interaction();"
|
||||||
page << "TodoBehavior.enableToggleSuccessors()"
|
|
||||||
else
|
else
|
||||||
page.show 'status'
|
page.show 'status'
|
||||||
page.replace_html 'status', "#{error_messages_for('todo', :object_name => 'action')}"
|
page.replace_html 'status', "#{error_messages_for('todo', :object_name => 'action')}"
|
||||||
|
|
|
||||||
|
|
@ -19,9 +19,7 @@ if @removed
|
||||||
page.replace dom_id(@successor), :partial => 'todos/todo', :locals => {
|
page.replace dom_id(@successor), :partial => 'todos/todo', :locals => {
|
||||||
:todo => @successor, :parent_container_type => parent_container_type }
|
:todo => @successor, :parent_container_type => parent_container_type }
|
||||||
end
|
end
|
||||||
|
page << "enable_rich_interaction();"
|
||||||
page << "TodoBehavior.enableToggleNotes()"
|
|
||||||
page << "TodoBehavior.enableToggleSuccessors()"
|
|
||||||
else
|
else
|
||||||
page.notify :error, "There was an error removing the dependency", 8.0
|
page.notify :error, "There was an error removing the dependency", 8.0
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -203,6 +203,23 @@ function enable_rich_interaction(){
|
||||||
$('input[name=tag_list]').live('keypress', function(){
|
$('input[name=tag_list]').live('keypress', function(){
|
||||||
$(this).attr('edited', 'true');
|
$(this).attr('edited', 'true');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/* Drag & Drop for successor/predecessor */
|
||||||
|
function drop_todo(evt, ui) {
|
||||||
|
dragged_todo = ui.draggable[0].id.split('_')[2];
|
||||||
|
dropped_todo = this.id.split('_')[2];
|
||||||
|
ui.draggable.hide();
|
||||||
|
$(this).block({message: null});
|
||||||
|
$.post('/todos/add_predecessor',
|
||||||
|
{successor: dragged_todo, predecessor: dropped_todo},
|
||||||
|
null, 'script');
|
||||||
|
}
|
||||||
|
|
||||||
|
$('.item-show').draggable({handle: '.grip', revert: 'invalid'});
|
||||||
|
$('.item-show').droppable({
|
||||||
|
drop: drop_todo,
|
||||||
|
hoverClass: 'hover'
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue