diff --git a/src/app/index.coffee b/src/app/index.coffee index b4b935bd9c..6bc7ca237c 100644 --- a/src/app/index.coffee +++ b/src/app/index.coffee @@ -240,11 +240,27 @@ ready (model) -> # Derby extends model.at to support creation from DOM nodes model.at(e.target).remove() - exports.toggleMeta = (e, el) -> - selector = $(el).attr('data-selector') - if selector.charAt(0) == '$' - selector = '\\' + selector - $('#'+selector).toggle() + exports.toggleEdit = (e, el) -> + task = model.at $(el).parents('li')[0] + $('#\\' + task.get('id') + '-chart').hide() + $('#\\' + task.get('id') + '-edit').toggle() + + exports.toggleChart = (e, el) -> + task = model.at $(el).parents('li')[0] + $('#\\' + task.get('id') + '-edit').hide() + $('#\\' + task.get('id') + '-chart').toggle() + + matrix = [['Date', 'Score']] + for obj in task.get('history') + matrix.push [obj.date, obj.value] + data = google.visualization.arrayToDataTable matrix + + options = { + title: 'History' + } + + chart = new google.visualization.LineChart(document.getElementById( task.get('id') + '-chart' )) + chart.draw(data, options) exports.vote = (e, el, next) -> direction = $(el).attr('data-direction') diff --git a/views/app/index.html b/views/app/index.html index 653fc3fa93..50fdb9742b 100644 --- a/views/app/index.html +++ b/views/app/index.html @@ -107,9 +107,9 @@
- + {#if :task.history} - + {/}
@@ -166,12 +166,7 @@ - + Fork me on GitHub @@ -186,3 +181,9 @@ + + + \ No newline at end of file