From b99ce2af455144aee766450f130418a381a04374 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Wed, 2 Jun 2021 01:46:50 +0200 Subject: [PATCH] Remove duplication in timeline component This way adding new steps will be easier. --- .../creation_timeline_component.html.erb | 11 +++++------ .../budgets_wizard/creation_timeline_component.rb | 10 +++++----- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/app/components/admin/budgets_wizard/creation_timeline_component.html.erb b/app/components/admin/budgets_wizard/creation_timeline_component.html.erb index f1ab8cd5a..3d0063898 100644 --- a/app/components/admin/budgets_wizard/creation_timeline_component.html.erb +++ b/app/components/admin/budgets_wizard/creation_timeline_component.html.erb @@ -1,8 +1,7 @@
    -
  1. > - <%= t("admin.budgets_wizard.creation_timeline.budget") %> -
  2. -
  3. > - <%= t("admin.budgets_wizard.creation_timeline.groups") %> -
  4. + <% steps.each do |step| %> +
  5. > + <%= t("admin.budgets_wizard.creation_timeline.#{step}") %> +
  6. + <% end %>
diff --git a/app/components/admin/budgets_wizard/creation_timeline_component.rb b/app/components/admin/budgets_wizard/creation_timeline_component.rb index e7e0e717b..6db8d61e2 100644 --- a/app/components/admin/budgets_wizard/creation_timeline_component.rb +++ b/app/components/admin/budgets_wizard/creation_timeline_component.rb @@ -1,13 +1,13 @@ class Admin::BudgetsWizard::CreationTimelineComponent < ApplicationComponent - attr_reader :step + attr_reader :current_step - def initialize(step) - @step = step + def initialize(current_step) + @current_step = current_step end private - def step_groups? - step == "groups" + def steps + %w[budget groups] end end