From f6f397dcb06b9fa7edf24a69533ba7ecbd907d77 Mon Sep 17 00:00:00 2001 From: Kevin Kaland Date: Fri, 12 Apr 2013 23:20:30 +0200 Subject: [PATCH] Use user's current day for completed/uncompleted. References #587. --- src/app/helpers.coffee | 12 ++++++++++-- views/app/tasks.html | 14 +++++++------- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/src/app/helpers.coffee b/src/app/helpers.coffee index 9852545b48..24b3050e4c 100644 --- a/src/app/helpers.coffee +++ b/src/app/helpers.coffee @@ -112,15 +112,23 @@ viewHelpers = (view) -> ### Tasks ### - view.fn 'taskClasses', (task) -> + view.fn 'taskClasses', (task, dayStart, lastCron) -> return unless task {type, completed, value, repeat} = task classes = type + now = moment().day() + + # calculate the current contextual day (e.g. if it's 12 AM Fri and the user's custom day start is 4 AM, then we should still act like it's Thursday) + dayStart = 0 unless (dayStart? and (dayStart = parseInt(dayStart)) and dayStart >= 0 and dayStart <= 24) + hourDiff = Math.abs moment(lastCron).startOf('day').add('h', dayStart).diff(moment(now), 'hours') + dayStamp = moment(now).add('h', hourDiff) + day = dayStamp.day() + # show as completed if completed (naturally) or not required for today if type in ['todo', 'daily'] - if completed or (repeat and repeat[dayMapping[moment().day()]]==false) + if completed or (repeat and (repeat[dayMapping[day]] == false)) classes += " completed" else classes += " uncompleted" diff --git a/views/app/tasks.html b/views/app/tasks.html index b0358e0051..86a6225bd9 100644 --- a/views/app/tasks.html +++ b/views/app/tasks.html @@ -69,7 +69,7 @@ The Checklist Manifesto: How to Get Things Right - + @@ -94,8 +94,8 @@ -
  • - +
  • +
    @@ -119,14 +119,14 @@ {#if equal(:task.type, 'habit')} {#if :task.up}{/} {#if :task.down}{/} - + {else if equal(:task.type, 'reward')} {:task.value} - + {else} @@ -190,7 +190,7 @@
    - + {else if equal(:task.type, 'todo')} @@ -199,7 +199,7 @@ {/} - + {#unless equal(:task.type, 'reward')}

    Advanced Options