Extract component for budget groups and headings
This commit is contained in:
committed by
Javi Martín
parent
45135bb87e
commit
16c582f282
29
app/assets/stylesheets/budgets/groups_and_headings.scss
Normal file
29
app/assets/stylesheets/budgets/groups_and_headings.scss
Normal file
@@ -0,0 +1,29 @@
|
||||
.groups-and-headings {
|
||||
|
||||
.heading {
|
||||
border: 1px solid $border;
|
||||
border-radius: rem-calc(3);
|
||||
display: inline-block;
|
||||
margin-bottom: $line-height / 2;
|
||||
|
||||
a {
|
||||
display: block;
|
||||
padding: $line-height / 2;
|
||||
|
||||
&:hover {
|
||||
background: $highlight;
|
||||
text-decoration: none;
|
||||
}
|
||||
}
|
||||
|
||||
.heading-name {
|
||||
padding: $line-height / 2;
|
||||
}
|
||||
|
||||
span {
|
||||
color: $text;
|
||||
display: block;
|
||||
font-size: $small-font-size;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1222,36 +1222,6 @@
|
||||
color: $brand;
|
||||
}
|
||||
|
||||
.groups-and-headings {
|
||||
|
||||
.heading {
|
||||
border: 1px solid $border;
|
||||
border-radius: rem-calc(3);
|
||||
display: inline-block;
|
||||
margin-bottom: $line-height / 2;
|
||||
|
||||
a {
|
||||
display: block;
|
||||
padding: $line-height / 2;
|
||||
|
||||
&:hover {
|
||||
background: $highlight;
|
||||
text-decoration: none;
|
||||
}
|
||||
}
|
||||
|
||||
.heading-name {
|
||||
padding: $line-height / 2;
|
||||
}
|
||||
|
||||
span {
|
||||
color: $text;
|
||||
display: block;
|
||||
font-size: $small-font-size;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.progress-votes {
|
||||
position: relative;
|
||||
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
<div id="groups_and_headings" class="groups-and-headings">
|
||||
<% budget.groups.each do |group| %>
|
||||
<h2 id="<%= group.name.parameterize %>"><%= group.name %></h2>
|
||||
<ul class="no-bullet" data-equalizer data-equalizer-on="medium">
|
||||
<% group.headings.sort_by_name.each do |heading| %>
|
||||
<li class="heading small-12 medium-4 large-2" data-equalizer-watch>
|
||||
<% unless budget.informing? || budget.finished? %>
|
||||
<%= link_to budget_investments_path(budget.id,
|
||||
heading_id: heading.id) do %>
|
||||
<%= heading_name_and_price_html(heading) %>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<div class="heading-name">
|
||||
<%= heading_name_and_price_html(heading) %>
|
||||
</div>
|
||||
<% end %>
|
||||
</li>
|
||||
<% end %>
|
||||
</ul>
|
||||
<% end %>
|
||||
</div>
|
||||
16
app/components/budgets/groups_and_headings_component.rb
Normal file
16
app/components/budgets/groups_and_headings_component.rb
Normal file
@@ -0,0 +1,16 @@
|
||||
class Budgets::GroupsAndHeadingsComponent < ApplicationComponent
|
||||
attr_reader :budget
|
||||
|
||||
def initialize(budget)
|
||||
@budget = budget
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def heading_name_and_price_html(heading)
|
||||
tag.div do
|
||||
concat(heading.name + " ")
|
||||
concat(tag.span(budget.formatted_heading_price(heading)))
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -5,13 +5,6 @@ module BudgetsHelper
|
||||
end
|
||||
end
|
||||
|
||||
def heading_name_and_price_html(heading, budget)
|
||||
tag.div do
|
||||
concat(heading.name + " ")
|
||||
concat(tag.span(budget.formatted_heading_price(heading)))
|
||||
end
|
||||
end
|
||||
|
||||
def csv_params
|
||||
csv_params = params.clone.merge(format: :csv)
|
||||
csv_params = csv_params.to_unsafe_h.map { |k, v| [k.to_sym, v] }.to_h
|
||||
|
||||
@@ -27,28 +27,7 @@
|
||||
<div id="budget_info" class="budget-info">
|
||||
<div class="row margin-top">
|
||||
<div class="small-12 column">
|
||||
|
||||
<div id="groups_and_headings" class="groups-and-headings">
|
||||
<% current_budget.groups.each do |group| %>
|
||||
<h2 id="<%= group.name.parameterize %>"><%= group.name %></h2>
|
||||
<ul class="no-bullet" data-equalizer data-equalizer-on="medium">
|
||||
<% group.headings.sort_by_name.each do |heading| %>
|
||||
<li class="heading small-12 medium-4 large-2" data-equalizer-watch>
|
||||
<% unless current_budget.informing? || current_budget.finished? %>
|
||||
<%= link_to budget_investments_path(current_budget.id,
|
||||
heading_id: heading.id) do %>
|
||||
<%= heading_name_and_price_html(heading, current_budget) %>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<div class="heading-name">
|
||||
<%= heading_name_and_price_html(heading, current_budget) %>
|
||||
</div>
|
||||
<% end %>
|
||||
</li>
|
||||
<% end %>
|
||||
</ul>
|
||||
<% end %>
|
||||
</div>
|
||||
<%= render Budgets::GroupsAndHeadingsComponent.new(current_budget) %>
|
||||
|
||||
<% unless current_budget.informing? %>
|
||||
<div class="map inline">
|
||||
|
||||
Reference in New Issue
Block a user