From 955592a3b83e83fd84d012543fe25dddcd10dc73 Mon Sep 17 00:00:00 2001 From: Tyler Renelle Date: Wed, 2 May 2012 20:32:29 -0400 Subject: [PATCH] Add habits, dailies, & rewards in --- src/app/index.coffee | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/src/app/index.coffee b/src/app/index.coffee index 366397d5fd..eb637b1bed 100644 --- a/src/app/index.coffee +++ b/src/app/index.coffee @@ -17,20 +17,37 @@ get '/', (page, model) -> money: 0 exp: 0 lvl: 1 + + habits: + 0: {id: 0, text: 'Take the stairs'} + habitIds: [0] + + dailies: + 0: {id: 0, completed: false, text: 'Go to the gym'} + dailyIds: [0] + todos: - 0: {id: 0, completed: false, text: 'Example 1'} + 0: {id: 0, text: 'Make a doctor appointment'} todoIds: [0] + + rewards: + 0: {id: 0, text: '1 TV episode'} + rewardIds: [0] + getRoom page, model, userId getRoom = (page, model, userId) -> model.subscribe "users.#{userId}", (err, user) -> model.ref '_user', user + habitIds = user.at 'habitIds' + dailyIds = user.at 'dailyIds' todoIds = user.at 'todoIds' + rewardIds = user.at 'rewardIds' - # The refList supports array methods, but it stores the todo values - # on an object by id. The todos are stored on the object 'todos', - # and their order is stored in an array of ids at '_group.todoIds' + model.refList '_habitList', '_user.habits', '_user.habitIds' + model.refList '_dailyList', '_user.dailies', '_user.dailyIds' model.refList '_todoList', '_user.todos', '_user.todoIds' + model.refList '_rewardList', '_user.rewards', '_user.rewardIds' # Create a reactive function that automatically keeps '_remaining' # updated with the number of remaining todos