Rename @budget to @current budget at budget index
Clear instance variable names help understand what's going around when you're deep 2 or 3 partials. In this case @budget is only used to carry around the current_budget so @current_budget is more descriptive. Using `current_budget` directly around would be an alternative, but maybe not as maintainable in case we want to change which budget is being shown (for example the drafting one if you're admin).
This commit is contained in:
@@ -15,7 +15,7 @@ class BudgetsController < ApplicationController
|
|||||||
|
|
||||||
def index
|
def index
|
||||||
@finished_budgets = @budgets.finished.order(created_at: :desc)
|
@finished_budgets = @budgets.finished.order(created_at: :desc)
|
||||||
@budget = current_budget
|
@current_budget = current_budget
|
||||||
@budgets_coordinates = current_budget_map_locations
|
@budgets_coordinates = current_budget_map_locations
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<ul class="no-bullet budget-timeline">
|
<ul class="no-bullet budget-timeline">
|
||||||
<% @budget.published_phases.each do |phase| %>
|
<% @current_budget.published_phases.each do |phase| %>
|
||||||
<li class="phase <%= 'active' if phase == @budget.current_phase %>">
|
<li class="phase <%= 'active' if phase == @current_budget.current_phase %>">
|
||||||
<h3><%= t("budgets.phase.#{phase.kind}") %></h3>
|
<h3><%= t("budgets.phase.#{phase.kind}") %></h3>
|
||||||
<span>
|
<span>
|
||||||
<%= l(phase.starts_at.to_date, format: :long) if phase.starts_at.present? %>
|
<%= l(phase.starts_at.to_date, format: :long) if phase.starts_at.present? %>
|
||||||
|
|||||||
@@ -7,9 +7,9 @@
|
|||||||
<div class="row" data-equalizer data-equalizer-on="medium">
|
<div class="row" data-equalizer data-equalizer-on="medium">
|
||||||
<div class="small-12 medium-9 column padding" data-equalizer-watch>
|
<div class="small-12 medium-9 column padding" data-equalizer-watch>
|
||||||
|
|
||||||
<h1><%= @budget.name %></h1>
|
<h1><%= @current_budget.name %></h1>
|
||||||
<div class="description">
|
<div class="description">
|
||||||
<%= safe_html_with_links(@budget.description) %>
|
<%= safe_html_with_links(@current_budget.description) %>
|
||||||
</div>
|
</div>
|
||||||
<p>
|
<p>
|
||||||
<%= link_to t("budgets.index.section_header.help"), "#section_help" %>
|
<%= link_to t("budgets.index.section_header.help"), "#section_help" %>
|
||||||
@@ -19,11 +19,11 @@
|
|||||||
<p>
|
<p>
|
||||||
<strong><%= t('budgets.show.phase') %></strong>
|
<strong><%= t('budgets.show.phase') %></strong>
|
||||||
</p>
|
</p>
|
||||||
<h2><%= t("budgets.phase.#{@budget.phase}") %></h2>
|
<h2><%= t("budgets.phase.#{@current_budget.phase}") %></h2>
|
||||||
|
|
||||||
<%= link_to t("budgets.index.section_header.all_phases"), "#all_phases" %>
|
<%= link_to t("budgets.index.section_header.all_phases"), "#all_phases" %>
|
||||||
|
|
||||||
<% if @budget.accepting? %>
|
<% if @current_budget.accepting? %>
|
||||||
<% if current_user %>
|
<% if current_user %>
|
||||||
<% if current_user.level_two_or_three_verified? %>
|
<% if current_user.level_two_or_three_verified? %>
|
||||||
<%= link_to t("budgets.investments.index.sidebar.create"),
|
<%= link_to t("budgets.investments.index.sidebar.create"),
|
||||||
@@ -48,9 +48,9 @@
|
|||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
|
|
||||||
<% if @budget.finished? || (@budget.balloting? && can?(:read_results, @budget)) %>
|
<% if @current_budget.finished? || (@current_budget.balloting? && can?(:read_results, @current_budget)) %>
|
||||||
<%= link_to t("budgets.show.see_results"),
|
<%= link_to t("budgets.show.see_results"),
|
||||||
budget_results_path(@budget, heading_id: @budget.headings.first),
|
budget_results_path(@current_budget, heading_id: @current_budget.headings.first),
|
||||||
class: "button margin-top expanded" %>
|
class: "button margin-top expanded" %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
@@ -62,18 +62,18 @@
|
|||||||
<div class="small-12 column">
|
<div class="small-12 column">
|
||||||
|
|
||||||
<div id="groups_and_headings" class="groups-and-headings">
|
<div id="groups_and_headings" class="groups-and-headings">
|
||||||
<% @budget.groups.each do |group| %>
|
<% @current_budget.groups.each do |group| %>
|
||||||
<h2><%= group.name %></h2>
|
<h2><%= group.name %></h2>
|
||||||
<ul class="no-bullet">
|
<ul class="no-bullet">
|
||||||
<% group.headings.order_by_group_name.each do |heading| %>
|
<% group.headings.order_by_group_name.each do |heading| %>
|
||||||
<li class="heading small-12 medium-4 large-2">
|
<li class="heading small-12 medium-4 large-2">
|
||||||
<% unless @budget.informing? %>
|
<% unless @budget.informing? %>
|
||||||
<%= link_to budget_investments_path(@budget.id, heading_id: heading.id) do %>
|
<%= link_to budget_investments_path(@current_budget.id, heading_id: heading.id) do %>
|
||||||
<%= heading_name_and_price_html(heading, @budget) %>
|
<%= heading_name_and_price_html(heading, @current_budget) %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% else %>
|
<% else %>
|
||||||
<div>
|
<div>
|
||||||
<%= heading_name_and_price_html(heading, @budget) %>
|
<%= heading_name_and_price_html(heading, @current_budget) %>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
</li>
|
</li>
|
||||||
@@ -89,13 +89,13 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
<%= link_to budget_investments_path(@budget.id) do %>
|
<%= link_to budget_investments_path(@current_budget.id) do %>
|
||||||
<small><%= t("budgets.index.investment_proyects") %></small>
|
<small><%= t("budgets.index.investment_proyects") %></small>
|
||||||
<% end %><br>
|
<% end %><br>
|
||||||
<%= link_to budget_investments_path(budget_id: @budget.id, filter: 'unfeasible') do %>
|
<%= link_to budget_investments_path(budget_id: @current_budget.id, filter: 'unfeasible') do %>
|
||||||
<small><%= t("budgets.index.unfeasible_investment_proyects") %></small>
|
<small><%= t("budgets.index.unfeasible_investment_proyects") %></small>
|
||||||
<% end %><br>
|
<% end %><br>
|
||||||
<%= link_to budget_investments_path(budget_id: @budget.id, filter: 'unselected') do %>
|
<%= link_to budget_investments_path(budget_id: @current_budget.id, filter: 'unselected') do %>
|
||||||
<small><%= t("budgets.index.not_selected_investment_proyects") %></small>
|
<small><%= t("budgets.index.not_selected_investment_proyects") %></small>
|
||||||
<% end %>
|
<% end %>
|
||||||
</p>
|
</p>
|
||||||
@@ -103,7 +103,7 @@
|
|||||||
|
|
||||||
<div id="all_phases">
|
<div id="all_phases">
|
||||||
<h2><%= t("budgets.index.all_phases") %></h2>
|
<h2><%= t("budgets.index.all_phases") %></h2>
|
||||||
<%= render "phases" %>
|
<%= render "phases", budget: @current_budget %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user