From 5d79d14475de2a0fa1c2e22c580a37fa38ebaabf Mon Sep 17 00:00:00 2001 From: jacobherrington Date: Mon, 28 Jan 2019 09:59:56 -0600 Subject: [PATCH] Add countries to state selection for zones When editing a state based zone it is impossible to determine the country each state is in. For example, Maryland, Liberia and Maryland, USA are identical options. This is very confusing for the user and can lead to mishaps. --- backend/app/views/spree/admin/zones/_state_members.html.erb | 2 +- core/app/models/spree/state.rb | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/backend/app/views/spree/admin/zones/_state_members.html.erb b/backend/app/views/spree/admin/zones/_state_members.html.erb index 4059a8b7707..eefa9399292 100644 --- a/backend/app/views/spree/admin/zones/_state_members.html.erb +++ b/backend/app/views/spree/admin/zones/_state_members.html.erb @@ -4,7 +4,7 @@ <%= zone_form.field_container :state_ids do %> <%= zone_form.label :state_ids, plural_resource_name(Spree::State) %>
- <%= zone_form.collection_select :state_ids, @states, :id, :name, {}, { multiple: true, class: "select2 fullwidth" } %> + <%= zone_form.collection_select :state_ids, @states, :id, :state_with_country, {}, { multiple: true, class: "select2 fullwidth" } %> <% end %> diff --git a/core/app/models/spree/state.rb b/core/app/models/spree/state.rb index c749eb27482..a3f8e0d9a2d 100644 --- a/core/app/models/spree/state.rb +++ b/core/app/models/spree/state.rb @@ -36,5 +36,9 @@ def <=>(other) def to_s name end + + def state_with_country + "#{name} (#{country})" + end end end