challneges: semi-functional challenge creation for parties

This commit is contained in:
Tyler Renelle 2013-05-12 16:47:18 +01:00
parent 5ea6e55e11
commit b8ef0789df
2 changed files with 26 additions and 4 deletions

View file

@ -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

View file

@ -32,7 +32,17 @@
</div>
<div class="tab-pane" id="challengesViewParty">
Party
{#each _party.challenges as :challenge}
<h3 onClick="$(this).next().toggle();">{:challenge.name} (by {:challenge.user})</h3>
<div class="grid">
<app:tasks:task-lists
habits={:challenge.habits}
dailys={:challenge.dailys}
todos={:challenge.todos}
rewards={:challenge.rewards} />
</div>
<hr/>
{/}
</div>
<div class="tab-pane" id="challengesViewGuild">
@ -93,7 +103,7 @@
</div>
</fieldset>
<input type='submit' x-bind="click:submit:challengeSave" class='btn btn-large btn-success' value='Save' />
<input type='submit' x-bind="click:challengeSave" class='btn btn-large btn-success' value='Save' />
<input type='button' x-bind='click:challengeDiscard' class='btn btn-large btn-danger' value=Discard />
{/}