Remove duplication in timeline component

This way adding new steps will be easier.
This commit is contained in:
Javi Martín
2021-06-02 01:46:50 +02:00
parent eff370b279
commit b99ce2af45
2 changed files with 10 additions and 11 deletions

View File

@@ -1,8 +1,7 @@
<ol class="creation-timeline"> <ol class="creation-timeline">
<li <%= "aria-current='step'" unless step_groups? %>> <% steps.each do |step| %>
<%= t("admin.budgets_wizard.creation_timeline.budget") %> <li <%= "aria-current='step'" if step == current_step %>>
</li> <%= t("admin.budgets_wizard.creation_timeline.#{step}") %>
<li <%= "aria-current='step'" if step_groups? %>> </li>
<%= t("admin.budgets_wizard.creation_timeline.groups") %> <% end %>
</li>
</ol> </ol>

View File

@@ -1,13 +1,13 @@
class Admin::BudgetsWizard::CreationTimelineComponent < ApplicationComponent class Admin::BudgetsWizard::CreationTimelineComponent < ApplicationComponent
attr_reader :step attr_reader :current_step
def initialize(step) def initialize(current_step)
@step = step @current_step = current_step
end end
private private
def step_groups? def steps
step == "groups" %w[budget groups]
end end
end end