From c797ea59998cbbbf11244771e81e2138d61bc76c Mon Sep 17 00:00:00 2001 From: Tyler Renelle Date: Sat, 15 Jun 2013 12:35:55 -0400 Subject: [PATCH] charts: fix exp & todos charts --- src/app/tasks.coffee | 34 ++++++++++++++++------------------ views/app/header.html | 2 +- views/app/index.html | 2 +- views/app/tasks.html | 4 ++-- 4 files changed, 20 insertions(+), 22 deletions(-) diff --git a/src/app/tasks.coffee b/src/app/tasks.coffee index bc2a5e1331..4403bb027b 100644 --- a/src/app/tasks.coffee +++ b/src/app/tasks.coffee @@ -56,30 +56,28 @@ module.exports.app = (appExports, model) -> appExports.toggleTaskEdit = (e, el) -> id = e.get('id') - path = "_tasks.editing.#{id}" - model.set path, !model.get(path) - $(".#{id}-chart").hide() + [editPath, chartPath] = ["_tasks.editing.#{id}", "_page.charts.#{id}"] + model.set editPath, !(model.get editPath) + model.set chartPath, false appExports.toggleChart = (e, el) -> id = $(el).attr('data-id') - history = [] + [historyPath, togglePath] = ['',''] - if id is 'todos' - model.set "_tasks.charts.todos", !model.get("_tasks.charts.todos") - history = model.get("_user.history.todos") - $(".#{id}-chart").toggle() - else - [id, path] = [$(el).attr('data-id'), "_tasks.charts.#{id}"] - model.set path, !model.get(path) - model.set "_tasks.editing.#{id}", false - $(".#{id}-chart").toggle() - history = model.get("_user.tasks.#{id}.history") + switch id + when 'exp' + [togglePath, historyPath] = ['_page.charts.exp', '_user.history.exp'] + when 'todos' + [togglePath, historyPath] = ['_page.charts.todos', '_user.history.todos'] + else + [togglePath, historyPath] = ["_page.charts.#{id}", "_user.tasks.#{id}.history"] + model.set "_tasks.editing.#{id}", false + + history = model.get(historyPath) + model.set togglePath, !(model.get togglePath) matrix = [['Date', 'Score']] - for obj in history - date = +new Date(obj.date) - readableDate = moment(date).format('MM/DD') - matrix.push [ readableDate, obj.value ] + _.each history, (obj) -> matrix.push([ moment(obj.date).format('MM/DD/YY'), obj.value ]) data = google.visualization.arrayToDataTable matrix options = title: 'History' diff --git a/views/app/header.html b/views/app/header.html index c271a475be..f2c5e045e9 100644 --- a/views/app/header.html +++ b/views/app/header.html @@ -16,7 +16,7 @@
{#if _user.history.exp} -   +   {/} {floor(_user.stats.exp)} / {tnl(_user.stats.lvl)} diff --git a/views/app/index.html b/views/app/index.html index 4cfd3048e3..dd60c0896d 100644 --- a/views/app/index.html +++ b/views/app/index.html @@ -40,7 +40,7 @@
{#if _user.preferences.hideHeader}{/} - +
diff --git a/views/app/tasks.html b/views/app/tasks.html index 08e2229c41..8468064a61 100644 --- a/views/app/tasks.html +++ b/views/app/tasks.html @@ -132,7 +132,7 @@

{{t(@header)}}

- {{#if equal(@type,'todo')}}{{/}} + {{#if equal(@type,'todo')}}
{{/}} {#if @editable} @@ -354,4 +354,4 @@
- +