Extract methods in milestones progress bars component
This way they're easier to reuse and customize.
This commit is contained in:
@@ -2,12 +2,12 @@
|
||||
<h5><%= t("milestones.index.progress") %></h5>
|
||||
|
||||
<div class="margin">
|
||||
<%= progress_tag_for(milestoneable.primary_progress_bar) %>
|
||||
<%= progress_tag_for(primary_progress_bar) %>
|
||||
</div>
|
||||
|
||||
<% if milestoneable.secondary_progress_bars.any? %>
|
||||
<% if secondary_progress_bars.any? %>
|
||||
<div class="milestone-progress">
|
||||
<% milestoneable.secondary_progress_bars.each do |progress_bar| %>
|
||||
<% secondary_progress_bars.each do |progress_bar| %>
|
||||
<div class="row margin-bottom">
|
||||
<div class="small-12 medium-6 large-4 column">
|
||||
<%= progress_bar.title %>
|
||||
|
||||
@@ -6,11 +6,19 @@ class Milestones::ProgressBarsComponent < ApplicationComponent
|
||||
end
|
||||
|
||||
def render?
|
||||
milestoneable.primary_progress_bar
|
||||
primary_progress_bar
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def primary_progress_bar
|
||||
milestoneable.primary_progress_bar
|
||||
end
|
||||
|
||||
def secondary_progress_bars
|
||||
milestoneable.secondary_progress_bars
|
||||
end
|
||||
|
||||
def progress_tag_for(progress_bar)
|
||||
text = number_to_percentage(progress_bar.percentage, precision: 0)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user