mirror of
https://github.com/TracksApp/tracks.git
synced 2026-01-28 03:36:11 +01:00
Eliminated double UPDATE when marking actions done or not done. Eliminated query for count of complete Todos in cases where it is not used.
git-svn-id: http://www.rousette.org.uk/svn/tracks-repos/trunk@658 a4c988fc-2ded-0310-b66e-134b36920a42
This commit is contained in:
parent
bfb51dd472
commit
b16ff933cb
2 changed files with 6 additions and 5 deletions
|
|
@ -106,14 +106,13 @@ class TodosController < ApplicationController
|
|||
# Toggles the 'done' status of the action
|
||||
#
|
||||
def toggle_check
|
||||
@todo.toggle_completion!
|
||||
@saved = @todo.save
|
||||
@saved = @todo.toggle_completion!
|
||||
respond_to do |format|
|
||||
format.js do
|
||||
if @saved
|
||||
determine_remaining_in_context_count(@todo.context_id)
|
||||
determine_down_count
|
||||
determine_completed_count
|
||||
determine_completed_count if @todo.completed?
|
||||
end
|
||||
render
|
||||
end
|
||||
|
|
|
|||
|
|
@ -51,11 +51,13 @@ class Todo < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def toggle_completion!
|
||||
saved = false
|
||||
if completed?
|
||||
activate!
|
||||
saved = activate!
|
||||
else
|
||||
complete!
|
||||
saved = complete!
|
||||
end
|
||||
return saved
|
||||
end
|
||||
|
||||
def activate_and_save!
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue