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