mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-20 17:20:12 +01:00
Various improvements to context drag&drop
-Don't botch other fields on context change -Better status message -Flash context title on drop -Drop target close to context name -Bolder drop target border Closes #1033
This commit is contained in:
parent
b50a1ce26f
commit
d9d08fac35
5 changed files with 29 additions and 6 deletions
|
|
@ -230,6 +230,23 @@ class TodosController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
def change_context
|
||||
@todo = Todo.find(params[:todo][:id])
|
||||
@original_item_context_id = @todo.context_id
|
||||
@context = Context.find(params[:todo][:context_id])
|
||||
@todo.context = @context
|
||||
@saved = @todo.save
|
||||
|
||||
@context_changed = true
|
||||
@message = "Context changed to #{@context.name}"
|
||||
determine_remaining_in_context_count(@original_item_context_id)
|
||||
|
||||
respond_to do |format|
|
||||
format.js {render :action => :update }
|
||||
format.xml { render :xml => @todo.to_xml( :except => :user_id ) }
|
||||
end
|
||||
end
|
||||
|
||||
def update
|
||||
@source_view = params['_source_view'] || 'todo'
|
||||
init_data_for_sidebar unless mobile?
|
||||
|
|
|
|||
|
|
@ -10,11 +10,11 @@
|
|||
<%= link_to_context( context ) %>
|
||||
<% end %>
|
||||
</h2>
|
||||
<div id="c_<%=context.id%>_target" class="context_target drop_target"></div>
|
||||
<div id="c<%= context.id %>items" class="items toggle_target">
|
||||
<div id="c<%= context.id %>empty-nd" style="display:<%= @not_done.empty? ? 'block' : 'none'%>;">
|
||||
<div class="message"><p>Currently there are no incomplete actions in this context</p></div>
|
||||
</div>
|
||||
<%= render :partial => "todos/todo", :collection => @not_done, :locals => { :parent_container_type => "context" } %>
|
||||
</div><!-- [end:items] -->
|
||||
<div id="c_<%=context.id%>_target" class="context_target drop_target"></div>
|
||||
</div><!-- [end:c<%= context.id %>] -->
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ if @saved
|
|||
status_message += ' to tickler' if @todo.deferred?
|
||||
status_message = 'Added new project / ' + status_message if @new_project_created
|
||||
status_message = 'Added new context / ' + status_message if @new_context_created
|
||||
status_message = @message || status_message
|
||||
page.notify :notice, status_message, 5.0
|
||||
|
||||
if source_view_is_one_of(:todo, :context, :tag)
|
||||
|
|
@ -46,12 +47,18 @@ if @saved
|
|||
page.replace_html("badge_count", @down_count) if source_view_is :todo
|
||||
|
||||
# show todo in context
|
||||
page.delay(0.5) do
|
||||
page.delay(0.3) do
|
||||
page.call "todoItems.ensureContainerHeight", "c#{@original_item_context_id}items"
|
||||
if source_view_is_one_of(:todo, :tag) && @todo.active?
|
||||
page.call "todoItems.ensureContainerHeight", "c#{@todo.context_id}items"
|
||||
page.visual_effect :highlight, dom_id(@todo), :duration => 3
|
||||
end
|
||||
if @context_changed
|
||||
source_view do |from|
|
||||
from.todo {page << "$('#c#{@todo.context_id} h2').effect('highlight', {}, 3000)" }
|
||||
from.tag {page << "$('#c#{@todo.context_id} h2').effect('highlight')" }
|
||||
end
|
||||
end
|
||||
end
|
||||
else
|
||||
if @original_item_was_deferred && source_view_is(:tag)
|
||||
|
|
|
|||
|
|
@ -259,9 +259,8 @@ function enable_rich_interaction(){
|
|||
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,
|
||||
$.post(relative_to_root('todos/change_context'),
|
||||
{"todo[id]": dragged_todo,
|
||||
"todo[context_id]": context_id},
|
||||
function(){target.unblock(); target.hide();}, 'script');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -951,7 +951,7 @@ div.message {
|
|||
.context_target {
|
||||
height: 15px;
|
||||
margin: 4px;
|
||||
border: thick dotted #CCC;
|
||||
border: 4px dotted #999;
|
||||
}
|
||||
|
||||
.context_target.hover {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue