mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-19 15:48:04 +01:00
total todos tally chart
This commit is contained in:
@@ -133,11 +133,12 @@ endOfDayTally = (model) ->
|
|||||||
if user.get('hp') < 0
|
if user.get('hp') < 0
|
||||||
#TODO this is implemented in exports.vote also, make it a user.on or something
|
#TODO this is implemented in exports.vote also, make it a user.on or something
|
||||||
user.set('hp',50);user.set('lvl',1);user.set('exp',0)
|
user.set('hp',50);user.set('lvl',1);user.set('exp',0)
|
||||||
task.set('completed', false) if type == 'daily'
|
|
||||||
if type == 'daily'
|
if type == 'daily'
|
||||||
task.push "history", { date: new Date(), value: task.get('value') }
|
task.push "history", { date: new Date(), value: value }
|
||||||
else
|
else
|
||||||
todoTally += task.get('value')
|
absVal = if (completed) then Math.abs(value) else value
|
||||||
|
todoTally += absVal
|
||||||
|
task.set('completed', false) if type == 'daily'
|
||||||
model.push '_user.history.todos', { date: new Date(), value: todoTally }
|
model.push '_user.history.todos', { date: new Date(), value: todoTally }
|
||||||
|
|
||||||
## VIEW HELPERS ##
|
## VIEW HELPERS ##
|
||||||
@@ -244,12 +245,12 @@ ready (model) ->
|
|||||||
# Derby extends model.at to support creation from DOM nodes
|
# Derby extends model.at to support creation from DOM nodes
|
||||||
model.at(e.target).remove()
|
model.at(e.target).remove()
|
||||||
|
|
||||||
exports.toggleEdit = (e, el) ->
|
exports.toggleTaskEdit = (e, el) ->
|
||||||
task = model.at $(el).parents('li')[0]
|
task = model.at $(el).parents('li')[0]
|
||||||
$('#\\' + task.get('id') + '-chart').hide()
|
$('#\\' + task.get('id') + '-chart').hide()
|
||||||
$('#\\' + task.get('id') + '-edit').toggle()
|
$('#\\' + task.get('id') + '-edit').toggle()
|
||||||
|
|
||||||
exports.toggleChart = (e, el) ->
|
exports.toggleTaskChart = (e, el) ->
|
||||||
task = model.at $(el).parents('li')[0]
|
task = model.at $(el).parents('li')[0]
|
||||||
$('#\\' + task.get('id') + '-edit').hide()
|
$('#\\' + task.get('id') + '-edit').hide()
|
||||||
$('#\\' + task.get('id') + '-chart').toggle()
|
$('#\\' + task.get('id') + '-chart').toggle()
|
||||||
@@ -270,6 +271,24 @@ ready (model) ->
|
|||||||
chart = new google.visualization.LineChart(document.getElementById( task.get('id') + '-chart' ))
|
chart = new google.visualization.LineChart(document.getElementById( task.get('id') + '-chart' ))
|
||||||
chart.draw(data, options)
|
chart.draw(data, options)
|
||||||
|
|
||||||
|
exports.toggleTodosChart = (e, el) ->
|
||||||
|
$('#todos-chart').toggle()
|
||||||
|
|
||||||
|
matrix = [['Date', 'Score']]
|
||||||
|
for obj in model.get('_user.history.todos')
|
||||||
|
date = new Date(obj.date)
|
||||||
|
readableDate = "#{date.getMonth()}/#{date.getDate()}/#{date.getFullYear()}"
|
||||||
|
matrix.push [ readableDate, obj.value ]
|
||||||
|
data = google.visualization.arrayToDataTable matrix
|
||||||
|
|
||||||
|
options = {
|
||||||
|
title: 'History'
|
||||||
|
backgroundColor: 'whiteSmoke'
|
||||||
|
}
|
||||||
|
|
||||||
|
chart = new google.visualization.LineChart(document.getElementById( 'todos-chart' ))
|
||||||
|
chart.draw(data, options)
|
||||||
|
|
||||||
exports.vote = (e, el, next) ->
|
exports.vote = (e, el, next) ->
|
||||||
direction = $(el).attr('data-direction')
|
direction = $(el).attr('data-direction')
|
||||||
direction = 'up' if direction == 'true/'
|
direction = 'up' if direction == 'true/'
|
||||||
|
|||||||
@@ -76,6 +76,8 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<a x-bind=click:toggleTodosChart><i class=icon-signal></i></a>
|
||||||
|
<div id="todos-chart" style="display:none;"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="span3 well">
|
<div class="span3 well">
|
||||||
@@ -107,9 +109,9 @@
|
|||||||
<!-- TODO make this a popover -->
|
<!-- TODO make this a popover -->
|
||||||
|
|
||||||
<div class="hover-show">
|
<div class="hover-show">
|
||||||
<a x-bind=click:toggleEdit><i class="icon-pencil"></i></a>
|
<a x-bind=click:toggleTaskEdit><i class="icon-pencil"></i></a>
|
||||||
{#if :task.history}
|
{#if :task.history}
|
||||||
<a x-bind=click:toggleChart><i class="icon-signal"></i></a>
|
<a x-bind=click:toggleTaskChart><i class="icon-signal"></i></a>
|
||||||
{/}
|
{/}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user