Clear completed & add todo at bottom of list
This commit is contained in:
@@ -9,7 +9,9 @@ class HabitTracker.Models.Habit extends Backbone.Model
|
||||
up: true
|
||||
down: true
|
||||
done: false
|
||||
position: 0
|
||||
# TODO this is being calculated instead on habit creation in index_view
|
||||
# because HabitsCollection instance isn't available here. Fix that
|
||||
position: 0
|
||||
|
||||
isHabit: =>
|
||||
@get("habit_type")==1
|
||||
@@ -50,10 +52,21 @@ class HabitTracker.Models.Habit extends Backbone.Model
|
||||
done = false if direction=="down"
|
||||
@set({ score: score, done: done })
|
||||
window.userStats.updateStats(this, delta)
|
||||
|
||||
|
||||
#send all the update information, as well as tack on userStats which will save to Users
|
||||
@save({ user_stats: window.userStats })
|
||||
|
||||
class HabitTracker.Collections.HabitsCollection extends Backbone.Collection
|
||||
model: HabitTracker.Models.Habit
|
||||
url: '/habits'
|
||||
comparator: (habit) ->
|
||||
habit.get("position")
|
||||
|
||||
# Filter down the list of all todo items that are finished.
|
||||
doneTodos: ->
|
||||
@filter (todo) ->
|
||||
todo.get('done') and todo.isTodo()
|
||||
|
||||
nextPosition: ->
|
||||
if (!@length) then return 1
|
||||
return @max() + 1
|
||||
Reference in New Issue
Block a user