Files
habitica/app/views/habits/_habit.html.erb
T
Tyler Renelle 229be57c31 Adding sortable
2012-02-01 16:55:33 -05:00

33 lines
1.2 KiB
Plaintext

<li id="habit_<%= habit.id %>" class="ui-state-default">
<span class="ui-icon ui-icon-arrowthick-2-n-s"></span>
<%
s = habit.score
case
when s<-5 then score = 'bad'
when s>=-5 && s<0 then score = 'iffy'
when s>=0 && s<5 then score = 'ok'
when s>=5 && s<15 then score = 'good'
when s>=15 then score = 'done'
end
name = "<span class='#{score}'>#{h(habit.name)}</span>"
%>
<% if habit.habit_type==Habit::ALWAYS %>
<%= link_to("√", { :action => "vote", :id => habit.id, :vote => 'up' }, :remote=>true) if habit.up %>
<%= link_to("X", { :action => "vote", :id => habit.id, :vote => 'down' }, :remote=>true) if habit.down %>
<%= raw name %> (<%= habit.score %>)
<% elsif habit.habit_type==Habit::DAILY %>
<% if habit.done %>
<%= link_to("[X]", { :action => "vote", :id => habit.id, :vote => 'down' }, :remote=>true) %>
<strike><%= raw name %></strike> (<%= habit.score %>)
<% else %>
<%= link_to("[ ]", { :action => "vote", :id => habit.id, :vote => 'up' }, :remote=>true) %>
<%= raw name %> (<%= habit.score %>)
<% end %>
<% end %>
<%= link_to 'Edit', edit_habit_path(habit) %>
</li>