mirror of
https://github.com/sudoxnym/habitica-self-host.git
synced 2026-04-14 19:47:03 +00:00
javascript bugfix, _habit partial bug fixes
This commit is contained in:
parent
06133f9379
commit
fdab691cb9
3 changed files with 18 additions and 15 deletions
|
|
@ -11,18 +11,19 @@ module HabitsHelper
|
|||
end
|
||||
end
|
||||
|
||||
def vote_link(habit, state)
|
||||
case state
|
||||
when 'up'
|
||||
return unless habit.up
|
||||
text,dir,style = "+","up","up"
|
||||
when 'down'
|
||||
return unless habit.down
|
||||
text,dir,style = "-","down","down"
|
||||
when 'checked' then text,dir,style = "[ ]","up","check"
|
||||
when 'unchecked' then text,dir,style = "[X]","down","check"
|
||||
def vote_link(habit, direction=nil)
|
||||
if direction=='up'
|
||||
return unless habit.up
|
||||
text,dir,style = "+","up","up"
|
||||
elsif direction=='down'
|
||||
return unless habit.down
|
||||
text,dir,style = "-","down","down"
|
||||
elsif habit.done
|
||||
text,dir,style = "[X]","down","check"
|
||||
else
|
||||
text,dir,style = "[ ]","up","check"
|
||||
end
|
||||
return link_to(text, { :action => "vote", :id => habit.id, :vote => 'dir' }, :class=>style, :remote=>true)
|
||||
return link_to(text, { :action => "vote", :id => habit.id, :vote => dir }, :class=>style, :remote=>true)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -2,9 +2,12 @@
|
|||
<%= link_to 'New Habit', new_habit_path %>
|
||||
|
||||
<table id="layout">
|
||||
<tr>
|
||||
<th>Habits</th>
|
||||
<th>Daily</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="panel">
|
||||
<h2>Habits</h2>
|
||||
<ul id="habits">
|
||||
<% @habits.each do |habit| %>
|
||||
<%= render :partial => "habit", :locals => { :habit => habit } %>
|
||||
|
|
@ -13,7 +16,6 @@
|
|||
</td>
|
||||
|
||||
<td class="panel">
|
||||
<h2>Daily</h2>
|
||||
<ul id="daily">
|
||||
<% @daily.each do |habit| %>
|
||||
<%= render :partial => "habit", :locals => { :habit => habit } %>
|
||||
|
|
|
|||
|
|
@ -1,2 +1,2 @@
|
|||
$('#habit_<%= @habit.id %>').html("<%= escape_javascript(render :partial => "habit", :locals => { :habit => @habit }) %>");
|
||||
$('#score').html("<%= @score %>");
|
||||
$('#habit_<%= @habit.id %>').replaceWith("<%= escape_javascript(render :partial => "habit", :locals => { :habit => @habit }) %>");
|
||||
$('#score').replaceWith("<%= @score %>");
|
||||
|
|
|
|||
Loading…
Reference in a new issue