Skip to content

Commit 5d79d14

Browse files
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.
1 parent 12b4c88 commit 5d79d14

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

backend/app/views/spree/admin/zones/_state_members.html.erb

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
<%= zone_form.field_container :state_ids do %>
66
<%= zone_form.label :state_ids, plural_resource_name(Spree::State) %><br>
7-
<%= zone_form.collection_select :state_ids, @states, :id, :name, {}, { multiple: true, class: "select2 fullwidth" } %>
7+
<%= zone_form.collection_select :state_ids, @states, :id, :state_with_country, {}, { multiple: true, class: "select2 fullwidth" } %>
88
<% end %>
99
</fieldset>
1010
</div>

core/app/models/spree/state.rb

+4
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,9 @@ def <=>(other)
3636
def to_s
3737
name
3838
end
39+
40+
def state_with_country
41+
"#{name} (#{country})"
42+
end
3943
end
4044
end

0 commit comments

Comments
 (0)