mirror of
https://github.com/TracksApp/tracks.git
synced 2026-02-03 22:41:48 +01:00
Added Luke's patch for moving an action between contexts when you edit the context. If you change the context of a next action by editing it, the action moves immediately between contexts when you hit update (by the magic of Ajax), rather than requiring you to refresh as happened previously.
Fixes #245. git-svn-id: http://www.rousette.org.uk/svn/tracks-repos/trunk@219 a4c988fc-2ded-0310-b66e-134b36920a42
This commit is contained in:
parent
51a490f2c7
commit
95e0fd3590
3 changed files with 23 additions and 14 deletions
|
|
@ -23,6 +23,7 @@ class TodoController < ApplicationController
|
|||
self.init
|
||||
@on_page = "home"
|
||||
@page_title = "TRACKS::List tasks"
|
||||
|
||||
@done = @done[0..(@user.preferences["no_completed"].to_i-1)]
|
||||
|
||||
@contexts_to_show = @contexts.clone
|
||||
|
|
@ -116,21 +117,17 @@ class TodoController < ApplicationController
|
|||
if @params["on_project_page"] == true
|
||||
@on_page = "project"
|
||||
end
|
||||
item = check_user_return_item
|
||||
item.attributes = @params["item"]
|
||||
@item = check_user_return_item
|
||||
@original_item_context_id = @item.context_id
|
||||
@item.attributes = @params["item"]
|
||||
|
||||
if item.due?
|
||||
item.due = Date.strptime(@params["item"]["due"], @user.preferences["date_format"])
|
||||
if @item.due?
|
||||
@item.due = Date.strptime(@params["item"]["due"], @user.preferences["date_format"])
|
||||
else
|
||||
item.due = ""
|
||||
@item.due = ""
|
||||
end
|
||||
|
||||
if item.save
|
||||
render :partial => 'item', :object => item
|
||||
else
|
||||
flash["warning"] = "Couldn't update the action"
|
||||
render_text ""
|
||||
end
|
||||
@saved = @item.save
|
||||
end
|
||||
|
||||
# Delete a next action
|
||||
|
|
|
|||
|
|
@ -9,9 +9,7 @@ module TodoHelper
|
|||
|
||||
def form_remote_tag_edit_todo( item )
|
||||
form_remote_tag( :url => { :controller => 'todo', :action => 'update_action', :id => item.id },
|
||||
:html => { :id => "form-action-#{item.id}", :class => "inline-form" },
|
||||
:update => "item-#{item.id}-container",
|
||||
:complete => visual_effect(:appear, "item-#{item.id}-container")
|
||||
:html => { :id => "form-action-#{item.id}", :class => "inline-form" }
|
||||
)
|
||||
end
|
||||
|
||||
|
|
|
|||
14
tracks/app/views/todo/update_action.rjs
Normal file
14
tracks/app/views/todo/update_action.rjs
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
if @saved
|
||||
if @item.context_id == @original_item_context_id
|
||||
page.replace_html "item-#{@item.id}-container", :partial => 'todo/item'
|
||||
page.visual_effect :highlight, "item-#{@item.id}-container", :duration => 3
|
||||
else
|
||||
page["item-#{@item.id}-container"].remove
|
||||
page.insert_html :bottom, "c#{@item.context_id}items", :partial => 'todo/item'
|
||||
page.visual_effect :highlight, "item-#{@item.id}-container", :duration => 3
|
||||
end
|
||||
else
|
||||
page.hide "info"
|
||||
page.replace_html "info", content_tag("div", content_tag("div", "#{pluralize(@item.errors.count, "error")} prohibited this record from being saved", "id" => "warning", "class" => "warning") + content_tag("p", "There were problems with the following fields:") + content_tag("ul", @item.errors.each_full { |msg| content_tag("li", msg) }))
|
||||
page.visual_effect :appear, 'info', :duration => 0.5
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue