From 4d0638d5df23dbb3864b73b39f47b46d98c922ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Fri, 10 Sep 2021 01:44:09 +0200 Subject: [PATCH] Specify group in the "No headings" message Since the message might appear several times on the same page, it's useful to give a bit more context. Besides, usability tests show that when there's a group with no headings, there's no clear indication on the page that the group is actually a group and not a heading. We're also adding some emphasis to the group name in the "Showing headings" message, to be consistent with the emphasis we've added the the group name in the "No headings" message. --- .../budget_headings/headings_component.html.erb | 2 +- .../admin/budget_headings/headings_component.rb | 4 ++-- .../headings/group_switcher_component.html.erb | 4 ++-- .../headings/group_switcher_component.rb | 4 ++++ config/locales/en/admin.yml | 4 ++-- config/locales/es/admin.yml | 4 ++-- .../admin/budget_headings/headings_component_spec.rb | 12 ++++++++++++ spec/system/admin/budget_headings_spec.rb | 4 +++- spec/system/admin/budgets_wizard/wizard_spec.rb | 8 ++++---- 9 files changed, 32 insertions(+), 14 deletions(-) create mode 100644 spec/components/admin/budget_headings/headings_component_spec.rb diff --git a/app/components/admin/budget_headings/headings_component.html.erb b/app/components/admin/budget_headings/headings_component.html.erb index 189d7166d..cde24117b 100644 --- a/app/components/admin/budget_headings/headings_component.html.erb +++ b/app/components/admin/budget_headings/headings_component.html.erb @@ -28,6 +28,6 @@ <% else %>
- <%= t("admin.budget_headings.no_headings") %> + <%= sanitize(t("admin.budget_headings.no_headings", group: group.name)) %>
<% end %> diff --git a/app/components/admin/budget_headings/headings_component.rb b/app/components/admin/budget_headings/headings_component.rb index 3b6594f23..396944392 100644 --- a/app/components/admin/budget_headings/headings_component.rb +++ b/app/components/admin/budget_headings/headings_component.rb @@ -8,10 +8,10 @@ class Admin::BudgetHeadings::HeadingsComponent < ApplicationComponent private def group - @group ||= headings.first.group + @group ||= headings.proxy_association.owner end def budget - @budget ||= headings.first.budget + @budget ||= group.budget end end diff --git a/app/components/admin/budgets_wizard/headings/group_switcher_component.html.erb b/app/components/admin/budgets_wizard/headings/group_switcher_component.html.erb index 4fe2ba830..1c04c5af5 100644 --- a/app/components/admin/budgets_wizard/headings/group_switcher_component.html.erb +++ b/app/components/admin/budgets_wizard/headings/group_switcher_component.html.erb @@ -1,12 +1,12 @@
<% if other_groups.one? %>

- <%= t("admin.budget_headings.group_switcher.currently_showing", group: group.name) %> + <%= currently_showing_text %> <%= link_to t("admin.budget_headings.group_switcher.the_other_group", group: other_groups.first.name), headings_path(other_groups.first) %>

<% else %> -

<%= t("admin.budget_headings.group_switcher.currently_showing", group: group.name) %>

+

<%= currently_showing_text %>