Support task.score in css classes

This commit is contained in:
Tyler Renelle 2012-06-26 08:02:16 -04:00
parent 30cc513f54
commit 6d62baeafe
2 changed files with 11 additions and 3 deletions

View file

@ -51,9 +51,17 @@ get '/', (page, model) ->
page.render()
## VIEW HELPERS ##
view.fn 'taskClasses', (type, completed) ->
view.fn 'taskClasses', (type, completed, score) ->
classes = type
classes += " completed" if completed
classes += " completed" if completed #TODO .done instead
switch
when score<-8 then classes += ' color-worst'
when score>=-8 and score<-5 then classes += ' color-worse'
when score>=-5 and score<-1 then classes += ' color-bad'
when score>=-1 and score<1 then classes += ' color-neutral'
when score>=1 and score<5 then classes += ' color-good'
when score>=5 and score<10 then classes += ' color-better'
when score>=10 then output += ' color-best'
return classes
view.fn "percent", (x, y) ->

View file

@ -16,7 +16,7 @@
</div>
<task:>
<li data-id={{:task.id}} class="task {taskClasses(:task.type, :task.completed)}">
<li data-id={{:task.id}} class="task {taskClasses(:task.type, :task.completed, :task.score)}">
<div class="task-meta">
<!-- TODO make this a popover -->
<a x-bind=click:toggleEdit data-selector="{{:task.id}}-edit" class="edit-link">Edit</a>