From f7145bb9517ff5f62d026e0b5036a993ca3bd68c Mon Sep 17 00:00:00 2001 From: Tyler Renelle Date: Sun, 12 May 2013 10:52:32 +0100 Subject: [PATCH] cleanup of the show-completed / show-remaining. That context-dependant / display-context-for stuff was bugging me out, and wasn't using Derby to it's potential. also some tags & habit-wide cleanup in helpers:taskClasses() --- src/app/helpers.coffee | 9 +++++++-- src/app/tasks.coffee | 24 ++---------------------- styles/app/tasks.styl | 15 --------------- views/app/tasks.html | 16 ++++++++-------- 4 files changed, 17 insertions(+), 47 deletions(-) diff --git a/src/app/helpers.coffee b/src/app/helpers.coffee index b0963580bd..184a75738e 100644 --- a/src/app/helpers.coffee +++ b/src/app/helpers.coffee @@ -125,14 +125,17 @@ viewHelpers = (view) -> ### Tasks ### - view.fn 'taskClasses', (task, filters, dayStart, lastCron) -> + view.fn 'taskClasses', (task, filters, dayStart, lastCron, showCompleted=false) -> return unless task {type, completed, value, repeat} = task + # completed / remaining toggle + return 'hidden' if (type is 'todo') and (completed != showCompleted) + for filter, enabled of filters if enabled and not task.tags?[filter] # All the other classes don't matter - return 'hide' + return 'hidden' classes = type @@ -150,6 +153,8 @@ viewHelpers = (view) -> classes += " completed" else classes += " uncompleted" + else if type is 'habit' + classes += ' habit-wide' if task.down and task.up if value < -20 classes += ' color-worst' diff --git a/src/app/tasks.coffee b/src/app/tasks.coffee index 3fb3dff8f3..d9b2811bf9 100644 --- a/src/app/tasks.coffee +++ b/src/app/tasks.coffee @@ -99,28 +99,8 @@ module.exports.app = (appExports, model) -> chart = new google.visualization.LineChart(document.getElementById( chartSelector )) chart.draw(data, options) - appExports.changeContext = (e, el) -> - # Get the data from the element - targetSelector = $(el).attr('data-target') - newContext = $(el).attr('data-context') - newActiveNav = $(el).parent('li') - - # If the clicked nav is already active, do nothing - if newActiveNav.hasClass('active') - return - - # Find the old active nav and context - oldActiveNav = $(el).closest('ul').find('> .active') - oldContext = oldActiveNav.find('a').attr('data-context') - - # Set the new active nav - oldActiveNav.removeClass('active') - newActiveNav.addClass('active') - - # Set the new context on the target - target = $(targetSelector) - target.removeClass(oldContext) - target.addClass(newContext) + appExports.todosShowRemaining = -> model.set '_showCompleted', false + appExports.todosShowCompleted = -> model.set '_showCompleted', true setUndo = (stats, task) -> previousUndo = model.get('_undo') diff --git a/styles/app/tasks.styl b/styles/app/tasks.styl index b79843411d..08db9535e9 100644 --- a/styles/app/tasks.styl +++ b/styles/app/tasks.styl @@ -383,21 +383,6 @@ form // todos ui // -------- -// context switching -.context-enabled - .display-context-dependant, - .task-list > li - display: none - - &.context-completed - .show-for-completed, .completed - display: block - - &.context-uncompleted - .show-for-uncompleted, .uncompleted - display: block - - // nav tabs .nav-tabs margin-top: 1.5em diff --git a/views/app/tasks.html b/views/app/tasks.html index 7e82907735..45f30609a9 100644 --- a/views/app/tasks.html +++ b/views/app/tasks.html @@ -54,7 +54,7 @@
-
+
{#if _user.history.todos} @@ -67,7 +67,7 @@ -
+
@@ -80,12 +80,12 @@ The Checklist Manifesto: How to Get Things Right - + -
@@ -103,7 +103,7 @@ -
  • +
  • @@ -238,4 +238,4 @@
    - \ No newline at end of file +