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.
This commit is contained in:
@@ -28,6 +28,6 @@
|
|||||||
</table>
|
</table>
|
||||||
<% else %>
|
<% else %>
|
||||||
<div class="callout primary clear">
|
<div class="callout primary clear">
|
||||||
<%= t("admin.budget_headings.no_headings") %>
|
<%= sanitize(t("admin.budget_headings.no_headings", group: group.name)) %>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|||||||
@@ -8,10 +8,10 @@ class Admin::BudgetHeadings::HeadingsComponent < ApplicationComponent
|
|||||||
private
|
private
|
||||||
|
|
||||||
def group
|
def group
|
||||||
@group ||= headings.first.group
|
@group ||= headings.proxy_association.owner
|
||||||
end
|
end
|
||||||
|
|
||||||
def budget
|
def budget
|
||||||
@budget ||= headings.first.budget
|
@budget ||= group.budget
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
<div class="budget-group-switcher">
|
<div class="budget-group-switcher">
|
||||||
<% if other_groups.one? %>
|
<% if other_groups.one? %>
|
||||||
<p>
|
<p>
|
||||||
<%= 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),
|
<%= link_to t("admin.budget_headings.group_switcher.the_other_group", group: other_groups.first.name),
|
||||||
headings_path(other_groups.first) %>
|
headings_path(other_groups.first) %>
|
||||||
</p>
|
</p>
|
||||||
<% else %>
|
<% else %>
|
||||||
<p><%= t("admin.budget_headings.group_switcher.currently_showing", group: group.name) %></p>
|
<p><%= currently_showing_text %></p>
|
||||||
<ul class="dropdown menu" data-dropdown-menu data-disable-hover="true" data-click-open="true">
|
<ul class="dropdown menu" data-dropdown-menu data-disable-hover="true" data-click-open="true">
|
||||||
<li class="has-submenu">
|
<li class="has-submenu">
|
||||||
<button type="button"><%= t("admin.budget_headings.group_switcher.different_group") %></button>
|
<button type="button"><%= t("admin.budget_headings.group_switcher.different_group") %></button>
|
||||||
|
|||||||
@@ -22,4 +22,8 @@ class Admin::BudgetsWizard::Headings::GroupSwitcherComponent < ApplicationCompon
|
|||||||
def headings_path(group)
|
def headings_path(group)
|
||||||
admin_budgets_wizard_budget_group_headings_path(budget, group)
|
admin_budgets_wizard_budget_group_headings_path(budget, group)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def currently_showing_text
|
||||||
|
sanitize(t("admin.budget_headings.group_switcher.currently_showing", group: group.name))
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -185,7 +185,7 @@ en:
|
|||||||
index:
|
index:
|
||||||
new_button: "Add new group"
|
new_button: "Add new group"
|
||||||
budget_headings:
|
budget_headings:
|
||||||
no_headings: "There are no headings."
|
no_headings: "There are no headings in the <strong>%{group}</strong> group."
|
||||||
create:
|
create:
|
||||||
notice: "Heading created successfully!"
|
notice: "Heading created successfully!"
|
||||||
update:
|
update:
|
||||||
@@ -202,7 +202,7 @@ en:
|
|||||||
edit: "Edit heading"
|
edit: "Edit heading"
|
||||||
submit: "Save heading"
|
submit: "Save heading"
|
||||||
group_switcher:
|
group_switcher:
|
||||||
currently_showing: "Showing headings from the %{group} group."
|
currently_showing: "Showing headings from the <strong>%{group}</strong> group."
|
||||||
different_group: "Manage headings from a different group"
|
different_group: "Manage headings from a different group"
|
||||||
the_other_group: "Manage headings from the %{group} group."
|
the_other_group: "Manage headings from the %{group} group."
|
||||||
index:
|
index:
|
||||||
|
|||||||
@@ -185,7 +185,7 @@ es:
|
|||||||
index:
|
index:
|
||||||
new_button: "Añadir un grupo nuevo"
|
new_button: "Añadir un grupo nuevo"
|
||||||
budget_headings:
|
budget_headings:
|
||||||
no_headings: "No hay partidas."
|
no_headings: "El grupo <strong>%{group}</strong> no tiene ninguna partida."
|
||||||
create:
|
create:
|
||||||
notice: "¡Partida presupuestaria creada con éxito!"
|
notice: "¡Partida presupuestaria creada con éxito!"
|
||||||
update:
|
update:
|
||||||
@@ -202,7 +202,7 @@ es:
|
|||||||
edit: "Editar partida"
|
edit: "Editar partida"
|
||||||
submit: "Guardar partida"
|
submit: "Guardar partida"
|
||||||
group_switcher:
|
group_switcher:
|
||||||
currently_showing: "Mostrando las partidas del grupo: %{group}."
|
currently_showing: "Mostrando las partidas del grupo <strong>%{group}</strong>."
|
||||||
different_group: "Ir a partidas de otro grupo"
|
different_group: "Ir a partidas de otro grupo"
|
||||||
the_other_group: "Ir a partidas del grupo %{group}."
|
the_other_group: "Ir a partidas del grupo %{group}."
|
||||||
index:
|
index:
|
||||||
|
|||||||
@@ -0,0 +1,12 @@
|
|||||||
|
require "rails_helper"
|
||||||
|
|
||||||
|
describe Admin::BudgetHeadings::HeadingsComponent do
|
||||||
|
it "includes group name in the message when there are no headings" do
|
||||||
|
group = create(:budget_group, name: "Whole planet")
|
||||||
|
|
||||||
|
render_inline Admin::BudgetHeadings::HeadingsComponent.new(group.headings)
|
||||||
|
|
||||||
|
expect(page.text.strip).to eq "There are no headings in the Whole planet group."
|
||||||
|
expect(page).to have_css "strong", exact_text: "Whole planet"
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -19,10 +19,12 @@ describe "Admin budget headings", :admin do
|
|||||||
|
|
||||||
context "List of headings in the budget page" do
|
context "List of headings in the budget page" do
|
||||||
scenario "Displaying no headings for group" do
|
scenario "Displaying no headings for group" do
|
||||||
|
group.update!(name: "Universities")
|
||||||
|
|
||||||
visit admin_budget_path(budget)
|
visit admin_budget_path(budget)
|
||||||
|
|
||||||
within "section", text: "Groups and headings" do
|
within "section", text: "Groups and headings" do
|
||||||
expect(page).to have_content "There are no headings."
|
expect(page).to have_content "There are no headings in the Universities group."
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ describe "Budgets creation wizard", :admin do
|
|||||||
click_link "Continue to headings"
|
click_link "Continue to headings"
|
||||||
|
|
||||||
expect(page).to have_content "Showing headings from the All city group"
|
expect(page).to have_content "Showing headings from the All city group"
|
||||||
expect(page).to have_content "There are no headings."
|
expect(page).to have_content "There are no headings in the All city group."
|
||||||
|
|
||||||
click_button "Add new heading"
|
click_button "Add new heading"
|
||||||
fill_in "Heading name", with: "All city"
|
fill_in "Heading name", with: "All city"
|
||||||
@@ -71,10 +71,10 @@ describe "Budgets creation wizard", :admin do
|
|||||||
|
|
||||||
expect(page).to have_content "Heading created successfully!"
|
expect(page).to have_content "Heading created successfully!"
|
||||||
within_table("Headings in All city") { expect(page).to have_content "All city" }
|
within_table("Headings in All city") { expect(page).to have_content "All city" }
|
||||||
expect(page).not_to have_content "There are no headings."
|
expect(page).not_to have_content "There are no headings"
|
||||||
|
|
||||||
click_link "Manage headings from the Districts group."
|
click_link "Manage headings from the Districts group."
|
||||||
expect(page).to have_content "There are no headings."
|
expect(page).to have_content "There are no headings in the Districts group."
|
||||||
|
|
||||||
click_button "Add new heading"
|
click_button "Add new heading"
|
||||||
fill_in "Heading name", with: "North"
|
fill_in "Heading name", with: "North"
|
||||||
@@ -83,7 +83,7 @@ describe "Budgets creation wizard", :admin do
|
|||||||
|
|
||||||
expect(page).to have_content "Heading created successfully!"
|
expect(page).to have_content "Heading created successfully!"
|
||||||
within_table("Headings in Districts") { expect(page).to have_content "North" }
|
within_table("Headings in Districts") { expect(page).to have_content "North" }
|
||||||
expect(page).not_to have_content "There are no headings."
|
expect(page).not_to have_content "There are no headings"
|
||||||
|
|
||||||
click_button "Add new heading"
|
click_button "Add new heading"
|
||||||
fill_in "Heading name", with: "South"
|
fill_in "Heading name", with: "South"
|
||||||
|
|||||||
Reference in New Issue
Block a user