pass in whole task object to taskClasses

This commit is contained in:
Tyler Renelle 2013-03-17 21:50:02 -04:00
parent 10e9d3eb40
commit 903745f7c9
2 changed files with 9 additions and 7 deletions

View file

@ -5,15 +5,17 @@ moment = require 'moment'
character = require './character'
module.exports.view = (view) ->
view.fn 'taskClasses', (type, completed, value, repeat) ->
#TODO figure out how to just pass in the task model, so i can access all these properties from one object
view.fn 'taskClasses', (task) ->
{type, completed, value, repeat} = task
classes = type
# show as completed if completed (naturally) or not required for today
if completed or (repeat and repeat[helpers.dayMapping[moment().day()]]==false)
classes += " completed"
else
classes += " uncompleted"
if type in ['todo', 'daily']
if completed or (repeat and repeat[helpers.dayMapping[moment().day()]]==false)
classes += " completed"
else
classes += " uncompleted"
if value < -20
classes += ' color-worst'

View file

@ -146,7 +146,7 @@
<!-- all the parts of a single task -->
<task:>
<li data-id={{:task.id}} class="task {taskClasses(:task.type, :task.completed, :task.value, :task.repeat)}">
<li data-id={{:task.id}} class="task {taskClasses(:task)}">
<!-- right-hand side control buttons -->
<div class="task-meta-controls">