Extract methods in milestones progress bars component

This way they're easier to reuse and customize.
This commit is contained in:
Javi Martín
2025-02-25 18:37:16 +01:00
parent ee03712df0
commit e0fc8bc83f
2 changed files with 12 additions and 4 deletions

View File

@@ -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 %>

View File

@@ -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)