mirror of
https://github.com/sudoxnym/habitica.git
synced 2026-08-04 01:29:21 +00:00
challenges: graph rendering now dynamic
This commit is contained in:
parent
c47291fe7c
commit
c6df323b07
2 changed files with 4 additions and 3 deletions
|
|
@ -5,13 +5,13 @@ module.exports.app = (appExports, model) ->
|
|||
browser = require './browser'
|
||||
user = model.at '_user'
|
||||
|
||||
appExports.renderChallengeGraphs = ->
|
||||
$('#profile-challenges-tab-link').on 'show', (e) ->
|
||||
_.each model.get('groups'), (g) ->
|
||||
_.each g.challenges, (chal) ->
|
||||
_.each ['habit','daily','todo'], (type) ->
|
||||
_.each chal["#{type}s"], (task) ->
|
||||
_.each chal.users, (member) ->
|
||||
if (history = member["#{type}s"][task.id].history) and !!history
|
||||
if (history = member?["#{type}s"]?[task.id]?.history) and !!history
|
||||
data = google.visualization.arrayToDataTable _.map(history, (h)-> [h.date,h.value])
|
||||
options =
|
||||
backgroundColor: { fill:'transparent' }
|
||||
|
|
@ -25,6 +25,7 @@ module.exports.app = (appExports, model) ->
|
|||
chart = new google.visualization.LineChart $(".challenge-#{chal.id}-member-#{member.id}-history-#{task.id}")[0]
|
||||
chart.draw(data, options)
|
||||
|
||||
|
||||
appExports.challengeCreate = (e,el) ->
|
||||
[type, gid] = [$(el).attr('data-type'), $(el).attr('data-gid')]
|
||||
model.set '_challenge.new',
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
{/if}
|
||||
<li><a data-toggle='tab' data-target="#profile-tavern"><i class='icon-eye-close'></i> Tavern</a></li>
|
||||
<li><a data-toggle='tab' data-target="#profile-achievements"><i class='icon-certificate'></i> Achievements</a></li>
|
||||
<li><a data-toggle='tab' data-target="#profile-challenges" x-bind=click:renderChallengeGraphs ><i class='icon-bullhorn'></i> Challenges</a></li>
|
||||
<li><a data-toggle='tab' data-target="#profile-challenges" id='profile-challenges-tab-link' ><i class='icon-bullhorn'></i> Challenges</a></li>
|
||||
<li><a data-toggle='tab' data-target="#profile-settings"><i class='icon-wrench'></i> Settings</a></li>
|
||||
</ul>
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue