Skip to content

Commit

Permalink
SelectAll should also uncheck when individual items are unchecked (th…
Browse files Browse the repository at this point in the history
…e things you remember while trying to sleep).
  • Loading branch information
absoludity committed Aug 14, 2012
1 parent 60a6b4e commit 6373796
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions labs/architecture-examples/derbyjs/src/todos/index.coffee
Expand Up @@ -55,6 +55,10 @@ ready (model) ->
group = model.at '_group'

group.on 'set', 'select_all', (select_all, previous_value, isLocal, e) ->
# We only want to react to select_all being set if it's in response
# to a UI event (as opposed to our checkAllCompleted below checking
# individual items).
return unless e
# Is there a way to do this with one call rather than iterating?
todos = model.at('_group.todos')
for item in list.get()
Expand Down Expand Up @@ -87,8 +91,7 @@ ready (model) ->
exports.checkAllCompleted = ->
allCompleted = true
allCompleted &&= item.completed for item in list.get()
if allCompleted
group.set('select_all', true)
group.set('select_all', allCompleted)

exports.endEdit = (e) ->
target = e.target
Expand Down

0 comments on commit 6373796

Please sign in to comment.