Files
grecia/app/views/budgets/investments/_header.html.erb
decabeza d70c46e578 Extract BudgetHeadingsHelper#heading_link & use it
Why:

The logic to construct the link to a heading (if it exists) is in three
different places, this is a clear candidate for a helper method.

How:

Just checking at the helper method if `assigned_heading` and `budget`
has values and composing the link if so.
2018-03-08 11:50:23 +01:00

74 lines
2.7 KiB
Plaintext

<% if @heading.present? %>
<section class="no-margin-top margin-bottom">
<div class="expanded jumbo-budget budget-heading padding">
<div class="row">
<div class="small-12 column">
<%= back_link_to budgets_path %>
<% if can? :show, @ballot %>
<%= link_to t("budgets.investments.header.check_ballot"),
budget_ballot_path(@budget),
class: "button float-right" %>
<% end %>
</div>
</div>
<div class="row progress-votes">
<div class="small-12 column">
<% if can? :show, @ballot %>
<div id="check-ballot" style="display: none;">
<%= link_to t("budgets.investments.header.check_ballot"),
budget_ballot_path(@budget) %>
</div>
<% if @ballot.valid_heading?(@heading) %>
<div class="progress-bar-nav" data-fixed-bar>
<h2>
<%= t("budgets.investments.index.by_heading", heading: @heading.name) %>
</h2>
<div id="progress_bar" class="no-margin-top">
<%= render 'budgets/ballot/progress_bar' %>
</div>
</div>
<% else %>
<h2>
<%= t("budgets.investments.index.by_heading", heading: @heading.name) %>
</h2>
<div class="small-12 medium-9">
<div class="callout warning margin-top">
<%= t("budgets.investments.header.different_heading_assigned_html",
heading_link: heading_link(@assigned_heading, @budget)) %>
<br>
<small>
<%= t("budgets.investments.header.change_ballot",
check_ballot: link_to(t("budgets.investments.header.check_ballot_link"),
budget_ballot_path(@budget))).html_safe %>
</small>
</div>
</div>
<% end %>
<% else %>
<h2 class="margin-top">
<%= t("budgets.investments.index.by_heading", heading: @heading.name) %>
</h2>
<h3>
<span class="tagline"><%= t("budgets.investments.header.price") %></span>
<%= @budget.formatted_heading_price(@heading) %>
</h3>
<% end %>
</div>
</div>
</div>
</section>
<% else %>
<div class="expanded jumbo-budget padding no-margin-top margin-bottom">
<div class="row">
<div class="small-12 column">
<%= back_link_to budget_path(@budget) %>
<h1><%= t('budgets.investments.index.title') %></h1>
</div>
</div>
</div>
<% end %>