mirror of
https://github.com/sudoxnym/habitica-self-host.git
synced 2026-04-14 19:47:03 +00:00
Display score
This commit is contained in:
parent
0edfdfc9d8
commit
e72669cc3a
3 changed files with 7 additions and 4 deletions
|
|
@ -6,7 +6,8 @@ class HabitsController < ApplicationController
|
||||||
# GET /habits.json
|
# GET /habits.json
|
||||||
def index
|
def index
|
||||||
@habits = current_user.habits.where(:habit_type => Habit::ALWAYS)
|
@habits = current_user.habits.where(:habit_type => Habit::ALWAYS)
|
||||||
@todos = current_user.habits.where(:habit_type => Habit::DAILY)
|
@daily = current_user.habits.where(:habit_type => Habit::DAILY)
|
||||||
|
@score = current_user.habits.sum('score')
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html # index.html.erb
|
format.html # index.html.erb
|
||||||
|
|
@ -80,6 +81,7 @@ class HabitsController < ApplicationController
|
||||||
def vote
|
def vote
|
||||||
@habit = current_user.habits.find(params[:id])
|
@habit = current_user.habits.find(params[:id])
|
||||||
@habit.vote(params[:vote])
|
@habit.vote(params[:vote])
|
||||||
|
@score = current_user.habits.sum('score')
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
if @habit.save
|
if @habit.save
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
|
<h1>Score: <span id="score"><%= @score %></span></h1>
|
||||||
<%= link_to 'New Habit', new_habit_path %>
|
<%= link_to 'New Habit', new_habit_path %>
|
||||||
|
|
||||||
<table>
|
<table>
|
||||||
|
|
@ -17,7 +17,7 @@
|
||||||
<div id="daily">
|
<div id="daily">
|
||||||
<h2>Daily</h2>
|
<h2>Daily</h2>
|
||||||
<ul>
|
<ul>
|
||||||
<% @todos.each do |habit| %>
|
<% @daily.each do |habit| %>
|
||||||
<li><%= render :partial => "habit", :locals => { :habit => habit } %></li>
|
<li><%= render :partial => "habit", :locals => { :habit => habit } %></li>
|
||||||
<% end %>
|
<% end %>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
|
||||||
|
|
@ -1 +1,2 @@
|
||||||
$('#<%= @habit.id %>').html("<%= escape_javascript(render :partial => "habit", :locals => { :habit => @habit }) %>")
|
$('#<%= @habit.id %>').html("<%= escape_javascript(render :partial => "habit", :locals => { :habit => @habit }) %>");
|
||||||
|
$('#score').html("<%= @score %>");
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue