diff --git a/src/app/challenges.coffee b/src/app/challenges.coffee index 3f7562baf8..e6461d3d84 100644 --- a/src/app/challenges.coffee +++ b/src/app/challenges.coffee @@ -1,4 +1,9 @@ +_ = require 'underscore' + module.exports.app = (appExports, model) -> + browser = require './browser' + helpers = require './helpers' + user = model.at '_user' appExports.challengeCreate = -> @@ -12,8 +17,15 @@ module.exports.app = (appExports, model) -> model.set '_challenge.creating', true appExports.challengeSave = -> - #TODO + challenge = _.defaults model.get('_challenge.new'), + id: model.id() + uuid: user.get('id') + user: helpers.username(model.get('_user.auth'), model.get('_user.profile.name')) + timestamp: +new Date + model.unshift '_party.challenges', challenge + challengeDiscard() + browser.growlNotification('Challenge Created','success') - appExports.challengeDiscard = -> + appExports.challengeDiscard = challengeDiscard = -> model.set '_challenge.new', {} model.set '_challenge.creating', false \ No newline at end of file diff --git a/views/app/challenges.html b/views/app/challenges.html index a71cd30f12..ff71e04a5f 100644 --- a/views/app/challenges.html +++ b/views/app/challenges.html @@ -32,7 +32,17 @@
- Party + {#each _party.challenges as :challenge} +

{:challenge.name} (by {:challenge.user})

+
+ +
+
+ {/}
@@ -93,7 +103,7 @@
- + {/}