mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-18 07:07:35 +01:00
Refactore progressbar via score in application_helper
This commit is contained in:
@@ -8,7 +8,6 @@ class HabitsController < ApplicationController
|
||||
@habits = current_user.habits.where(:habit_type => Habit::ALWAYS)
|
||||
@daily = current_user.habits.where(:habit_type => Habit::DAILY)
|
||||
@one_time = current_user.habits.where(:habit_type => Habit::ONE_TIME).where(:done=>false)
|
||||
@score = current_user.habits.sum('score').to_i
|
||||
|
||||
respond_to do |format|
|
||||
format.html # index.html.erb
|
||||
@@ -98,7 +97,6 @@ class HabitsController < ApplicationController
|
||||
@habit.user=current_user
|
||||
|
||||
@habit.vote(params[:vote])
|
||||
@score = current_user.habits.sum('score').to_i
|
||||
|
||||
respond_to do |format|
|
||||
# format.html { render action: "edit" }
|
||||
|
||||
@@ -1,2 +1,6 @@
|
||||
module ApplicationHelper
|
||||
|
||||
def score
|
||||
current_user.habits.sum('score').to_i
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,9 +1,4 @@
|
||||
<% content_for :score do %>
|
||||
<%= render :partial => "progressbar", :locals => { :score => @score } %>
|
||||
<% end %>
|
||||
|
||||
|
||||
<%= link_to 'New Habit', new_habit_path %>
|
||||
<%= link_to 'Back', habits_url %>
|
||||
|
||||
<table id="layout">
|
||||
<tr>
|
||||
|
||||
@@ -1,8 +1,3 @@
|
||||
<% content_for :score do %>
|
||||
<%= render :partial => "progressbar", :locals => { :score => @score } %>
|
||||
<% end %>
|
||||
|
||||
|
||||
<%= link_to 'New Habit', new_habit_path %>
|
||||
|
||||
<table id="layout">
|
||||
@@ -50,6 +45,7 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<%= link_to 'View Completed', :action=>'completed' %>
|
||||
</td>
|
||||
|
||||
<td class="panel">
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<% unless @habit.habit_type==Habit::ONE_TIME %>
|
||||
$('#habit_<%= @habit.id %>').replaceWith("<%= escape_javascript(render :partial => "habit", :locals => { :habit => @habit }) %>");
|
||||
<% end %>
|
||||
$('#progressbar').replaceWith("<%= escape_javascript(render :partial => "progressbar", :locals => { :score => @score }) %>");
|
||||
$('#progressbar').replaceWith("<%= escape_javascript(render :partial => "progressbar") %>");
|
||||
$('#money').replaceWith("<%= escape_javascript(render 'money') %>");
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
<div id="container">
|
||||
<div id="header">
|
||||
<!-- <h1><a href="/">Web App</a></h1> -->
|
||||
<%= yield :score %>
|
||||
<%= render :partial => "progressbar" %>
|
||||
<div id="user-navigation">
|
||||
<ul class="wat-cf">
|
||||
<li><a href="#"><%= t("web-app-theme.profile", :default => "Profile") %></a></li>
|
||||
|
||||
Reference in New Issue
Block a user