Use user's current day for completed/uncompleted.

References #587.
This commit is contained in:
Kevin Kaland 2013-04-12 23:20:30 +02:00
parent 4c08fa4e15
commit f6f397dcb0
2 changed files with 17 additions and 9 deletions

View file

@ -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"

View file

@ -69,7 +69,7 @@
<app:tasks:ads>
<a href="http://www.amazon.com/gp/product/0312430000/ref=as_li_tf_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=0312430000&linkCode=as2&tag=ha0d2-20">The Checklist Manifesto: How to Get Things Right</a><img src="//www.assoc-amazon.com/e/ir?t=ha0d2-20&l=as2&o=1&a=0312430000" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" />
</app:tasks:ads>
<button class='task-action-btn tile spacious bright display-context-dependant show-for-completed' x-bind=click:clearCompleted>Clear Completed</button>
<!-- remaining/completed tabs -->
@ -94,8 +94,8 @@
<!-- all the parts of a single task -->
<task:>
<li data-id={{:task.id}} class="task {taskClasses(:task)} {#if :task.down}{#if :task.up}habit-wide{/}{/}">
<li data-id={{:task.id}} class="task {taskClasses(:task, _user.preferences.dayStart, _user.lastCron)} {#if :task.down}{#if :task.up}habit-wide{/}{/}">
<!-- right-hand side control buttons -->
<div class="task-meta-controls">
<!-- edit -->
@ -119,14 +119,14 @@
{#if equal(:task.type, 'habit')}
{#if :task.up}<a class="task-action-btn" data-direction=up x-bind=click:score></a>{/}
{#if :task.down}<a class="task-action-btn" data-direction=down x-bind=click:score></a>{/}
<!-- Rewards -->
{else if equal(:task.type, 'reward')}
<a class="money btn-buy" x-bind=click:score data-direction=down>
<span class="reward-cost">{:task.value}</span>
<span class='shop_gold'></span>
</a>
<!-- Daily & Todos -->
{else}
<span class="task-checker action-yesno">
@ -190,7 +190,7 @@
<input class="option-content" size="16" type="number" min="0" value={:task.value}>
<div class="money input-suffix"><span class='shop_gold'></span></div>
</fieldset>
<!-- if Todo, the due date -->
{else if equal(:task.type, 'todo')}
@ -199,7 +199,7 @@
<input class="option-content datepicker" type="text" value="{:task.date}" data-date-format="mm/dd/yyyy">
</fieldset>
{/}
<!-- Advanced Options -->
{#unless equal(:task.type, 'reward')}
<p x-bind="click:tasksToggleAdvanced" class="option-title mega">Advanced Options</p>