mirror of
https://github.com/TracksApp/tracks.git
synced 2026-02-07 16:24:21 +01:00
Applied Luke Melia's patch to update the todo toggling to use RJS templates (#190).
I also added the following: * Expanded Luke's patch so that toggling also works on Context and Project pages. * The 'empty' messages for the uncompleted and completed actions divs now appear and disappear automatically on the context and project pages as you toggle, untoggle, add and delete actions * At some point, hiding of contexts on the front page broke. It seems that recent updates to Rails changed the way that it interprets tinyint fields: these can now only be tested with true or false, not 0 and 1, and that was why it broke. Also the code for selecting only unhidden contexts on the front page used .hidden? for some reason and not .hide. Fixed now. A remaining issue is that on the home page, if you add an action to (or uncheck an action to) a context that is not currently shown (because it is hidden, or it has been empty), the record will be changed, but nothing will appear to happen until you refresh. I'd like to test for this situation and put a message up assuring the user that things worked and that they need to refresh. git-svn-id: http://www.rousette.org.uk/svn/tracks-repos/trunk@175 a4c988fc-2ded-0310-b66e-134b36920a42
This commit is contained in:
parent
7bc8783d03
commit
825bad76a7
14 changed files with 163 additions and 117 deletions
|
|
@ -59,7 +59,9 @@ class ContextController < ApplicationController
|
|||
|
||||
@saved = @item.save
|
||||
@on_page = "context"
|
||||
@up_count = Todo.find(:all, :conditions => ["todos.user_id = ? and todos.done = 0 and todos.context_id IN (?)", @user.id, @item.context_id]).size.to_s
|
||||
if @saved
|
||||
@up_count = Todo.find(:all, :conditions => ["todos.user_id = ? and todos.done = 0 and todos.context_id IN (?)", @user.id, @item.context_id]).size.to_s
|
||||
end
|
||||
|
||||
return if request.xhr?
|
||||
|
||||
|
|
@ -88,7 +90,9 @@ class ContextController < ApplicationController
|
|||
@item = check_user_return_item
|
||||
|
||||
@saved = @item.destroy
|
||||
@down_count = Todo.find(:all, :conditions => ["todos.user_id = ? and todos.done = 0 and todos.context_id IN (?)", @user.id, @item.context_id]).size.to_s
|
||||
if @saved
|
||||
@down_count = Todo.find(:all, :conditions => ["todos.user_id = ? and todos.done = 0 and todos.context_id IN (?)", @user.id, @item.context_id]).size.to_s
|
||||
end
|
||||
|
||||
return if request.xhr?
|
||||
|
||||
|
|
@ -108,6 +112,29 @@ class ContextController < ApplicationController
|
|||
render :controller => 'todo', :action => 'list'
|
||||
end
|
||||
end
|
||||
|
||||
# Toggles the 'done' status of the action
|
||||
#
|
||||
def toggle_check
|
||||
self.init
|
||||
|
||||
@item = check_user_return_item
|
||||
@item.toggle!('done')
|
||||
@item.completed = Time.now() # For some reason, the before_save in todo.rb stopped working
|
||||
@saved = @item.save
|
||||
if @saved
|
||||
@down_count = Todo.find(:all, :conditions => ["todos.user_id = ? and todos.done = 0 and todos.context_id IN (?)", @user.id, @item.context_id]).size.to_s
|
||||
@done_count = Todo.find(:all, :conditions => ["todos.user_id = ? and todos.done = 1 and todos.context_id IN (?)", @user.id, @item.context_id]).size.to_s
|
||||
end
|
||||
return if request.xhr?
|
||||
|
||||
if @saved
|
||||
flash['notice'] = "The action <strong>'#{@item.description}'</strong> was marked as <strong>#{@item.done? ? 'complete' : 'incomplete' }</strong>"
|
||||
else
|
||||
flash['notice'] = "The action <strong>'#{@item.description}'</strong> was NOT marked as <strong>#{@item.done? ? 'complete' : 'incomplete' } due to an error on the server.</strong>"
|
||||
end
|
||||
redirect_to :action => "list"
|
||||
end
|
||||
|
||||
# Edit the details of the context
|
||||
#
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue