mirror of
https://github.com/sudoxnym/habitica-self-host.git
synced 2026-08-03 12:40:00 +00:00
challenges: basics for challenge subscription
This commit is contained in:
parent
b8ef0789df
commit
57f51048a1
3 changed files with 38 additions and 15 deletions
|
|
@ -7,25 +7,36 @@ module.exports.app = (appExports, model) ->
|
|||
user = model.at '_user'
|
||||
|
||||
appExports.challengeCreate = ->
|
||||
id = model.id()
|
||||
model.set '_challenge.new',
|
||||
name: ''
|
||||
habits: []
|
||||
daily: []
|
||||
dailys: []
|
||||
todos: []
|
||||
rewards: []
|
||||
assignTo: 'Party'
|
||||
model.set '_challenge.creating', true
|
||||
|
||||
appExports.challengeSave = ->
|
||||
challenge = _.defaults model.get('_challenge.new'),
|
||||
id: model.id()
|
||||
id: 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()
|
||||
|
||||
model.set '_challenge.creating', true
|
||||
|
||||
appExports.challengeSave = ->
|
||||
model.unshift '_party.challenges', model.get('_challenge.new'), -> challengeDiscard()
|
||||
browser.growlNotification('Challenge Created','success')
|
||||
|
||||
appExports.challengeDiscard = challengeDiscard = ->
|
||||
model.set '_challenge.new', {}
|
||||
model.set '_challenge.creating', false
|
||||
model.set '_challenge.creating', false
|
||||
|
||||
appExports.challengeSubscribe = (e) ->
|
||||
userChallenges = user.get('challenges')
|
||||
chal = e.get()
|
||||
user.unshift('challenges', chal.id) unless userChallenges and (userChallenges.indexOf(chal.id) != -1)
|
||||
_.each ['habit', 'daily', 'todo', 'reward'], (type) ->
|
||||
_.each chal["#{type}s"], (task) -> model.push("_#{type}List", task)
|
||||
|
||||
appExports.challengeUnsubscribe = (e) ->
|
||||
i = user.get('challenges')?.indexOf e.get('id')
|
||||
user.remove("challenges.#{i}") if i? and i != -1
|
||||
|
|
|
|||
|
|
@ -214,7 +214,6 @@ viewHelpers = (view) ->
|
|||
view.fn 'itemText', (type, item=0) -> items[type][parseInt(item)].text
|
||||
view.fn 'itemStat', (type, item=0) -> if type is 'weapon' then items[type][parseInt(item)].strength else items[type][parseInt(item)].defense
|
||||
|
||||
|
||||
# view.fn 'activeFilters', (filters) ->
|
||||
# debugger
|
||||
# (_.find filters, (f) -> f)?
|
||||
|
|
|
|||
|
|
@ -33,7 +33,16 @@
|
|||
|
||||
<div class="tab-pane" id="challengesViewParty">
|
||||
{#each _party.challenges as :challenge}
|
||||
<div class='pull-right'>
|
||||
{#if indexOf(_user.challenges,:challenge.id)}
|
||||
<a x-bind="click:challengeUnsubscribe" class='btn btn-large btn-danger'><i class='icon-ban-circle'></i> Unsubscribe</a>
|
||||
{else}
|
||||
<a x-bind="click:challengeSubscribe" class='btn btn-large btn-success'><i class='icon-ok'></i> Subscribe</a>
|
||||
{/}
|
||||
</div>
|
||||
<h3 onClick="$(this).next().toggle();">{:challenge.name} (by {:challenge.user})</h3>
|
||||
|
||||
|
||||
<div class="grid">
|
||||
<app:tasks:task-lists
|
||||
habits={:challenge.habits}
|
||||
|
|
@ -88,11 +97,15 @@
|
|||
<small>No individual privacy on the challenge, all party members can see progress even if they decline the challenge. Any new party members can subscribe to this challenge.</small>
|
||||
</div>
|
||||
<div class='span8 well'>
|
||||
<input type='radio' name='challenge-party-selection' checked={not(_challenge.new.partyAssignees)} >Individual Members</input>
|
||||
{{#each _partyMembers as :member}}
|
||||
<div><input type=checkbox checked=true /> {{username(:member.auth,:member.profile.name)}}</div>
|
||||
{{/}}
|
||||
<small>Only the invited party members can subscribe to this challenge. New party joins won't see this challenge.</small>
|
||||
<div><input type='radio' name='challenge-party-selection' checked={not(_challenge.new.partyAssignees)} >Individual Members</input></div>
|
||||
<div>
|
||||
<select multiple="multiple">
|
||||
{{#each _partyMembers as :member}}
|
||||
<option>{{username(:member.auth,:member.profile.name)}}</option>
|
||||
{{/}}
|
||||
</select>
|
||||
</div>
|
||||
<div><small>Only the invited party members can subscribe to this challenge. New party joins won't see this challenge.</small></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue