From 9f94e9568940c124eb6177a79e2235d2ce5f7c06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Thu, 16 Sep 2021 12:24:55 +0200 Subject: [PATCH] Extract methods in ballot component Assigning variables in the view makes the code harder to read. --- .../budgets/ballot/ballot_component.html.erb | 2 -- app/components/budgets/ballot/ballot_component.rb | 10 ++++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/app/components/budgets/ballot/ballot_component.html.erb b/app/components/budgets/ballot/ballot_component.html.erb index cdd1f0641..132431c74 100644 --- a/app/components/budgets/ballot/ballot_component.html.erb +++ b/app/components/budgets/ballot/ballot_component.html.erb @@ -15,7 +15,6 @@
- <% ballot_groups = ballot.groups.sort_by_name %> <% ballot_groups.each do |group| %> <% heading = ballot.heading_for_group(group) %>
@@ -46,7 +45,6 @@
<% end %> - <% no_balloted_groups = budget.groups.sort_by_name - ballot_groups %> <% no_balloted_groups.each do |group| %>
diff --git a/app/components/budgets/ballot/ballot_component.rb b/app/components/budgets/ballot/ballot_component.rb index 7e2b77aaf..3eb6e78e4 100644 --- a/app/components/budgets/ballot/ballot_component.rb +++ b/app/components/budgets/ballot/ballot_component.rb @@ -8,4 +8,14 @@ class Budgets::Ballot::BallotComponent < ApplicationComponent def budget ballot.budget end + + private + + def ballot_groups + ballot.groups.sort_by_name + end + + def no_balloted_groups + budget.groups.sort_by_name - ballot.groups + end end