Skip to content

Commit 0963b8e

Browse files
committed
Add email, vat_id, and reverse_charge_status to admin address forms
Update the admin address handling logic to include email, vat_id, and reverse_charge_status fields. Changes include updating form partials and views to handle these new fields, and modifying the JavaScript to process them.
1 parent 5e1bff9 commit 0963b8e

File tree

5 files changed

+37
-2
lines changed

5 files changed

+37
-2
lines changed

admin/app/components/solidus_admin/ui/forms/address/component.html.erb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,5 +50,15 @@
5050
<% end %>
5151

5252
<%= render component("ui/forms/field").text_field(@form_field_name, :phone, object: @addressable) %>
53+
<%= render component("ui/forms/field").text_field(@form_field_name, :email, object: @addressable) %>
54+
<% if Spree::Backend::Config.show_reverse_charge_fields %>
55+
<%= render component("ui/forms/field").text_field(@form_field_name, :vat_id, object: @addressable) %>
56+
<%= render component("ui/forms/field").select(
57+
@form_field_name,
58+
:reverse_charge_status,
59+
Spree::Address.reverse_charge_statuses.keys.map { |key| [I18n.t("spree.reverse_charge_statuses.#{key}"), key] },
60+
object: @addressable
61+
) %>
62+
<% end %>
5363
</div>
5464
</fieldset>

backend/app/assets/javascripts/spree/backend/views/order/address.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Spree.Views.Order.Address = Backbone.View.extend({
2424
eachField: function(callback){
2525
var view = this;
2626
var fields = ["name", "company", "address1", "address2",
27-
"city", "zipcode", "phone", "country_id", "state_name"];
27+
"city", "zipcode", "phone", "country_id", "state_name", "vat_id", "email", "reverse_charge_status"];
2828
_.each(fields, function(field) {
2929
var el = view.$('[name$="[' + field + ']"]');
3030
if (el.length) callback(field, el);

backend/app/views/spree/admin/search/users.json.jbuilder

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@ json.array!(@users) do |user|
1414
:state_name,
1515
:state_id,
1616
:country_id,
17-
:company
17+
:company,
18+
:email,
19+
:vat_id,
20+
:reverse_charge_status
1821
]
1922
json.ship_address do
2023
if user.ship_address

backend/app/views/spree/admin/shared/_address.html.erb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
<div data-hook="address">
22
<%= address.name %> <%= address.company unless address.company.blank? %><br>
33
<%= address.phone %><%= address.alternative_phone unless address.alternative_phone.blank? %><br>
4+
<%= address.email unless address.email.blank? %><br>
5+
<%= address.vat_id unless address.vat_id.blank? %><br>
46
<%= address.address1 %><br>
57
<% if address.address2.present? %><%= address.address2 %><br><% end %>
68
<%= "#{address.city}, #{address.state_text}, #{address.zipcode}" %><br>

backend/app/views/spree/admin/shared/_address_form.html.erb

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,24 @@
6363
<%= f.label :phone %>
6464
<%= f.phone_field :phone, class: 'fullwidth' %>
6565
</div>
66+
67+
<div class="field <%= "#{type}-row" %>">
68+
<%= f.label :email %>
69+
<%= f.email_field :email, class: 'fullwidth' %>
70+
</div>
71+
72+
<% if Spree::Backend::Config.show_reverse_charge_fields %>
73+
<div class="field <%= "#{type}-row" %>">
74+
<%= f.label :vat_id %>
75+
<%= f.text_field :vat_id, class: 'fullwidth' %>
76+
</div>
77+
78+
<div class="field <%= "#{type}-row" %>">
79+
<%= f.label :reverse_charge_status %>
80+
<%= f.select :reverse_charge_status,
81+
Spree::Address.reverse_charge_statuses.keys.map { |key| [I18n.t("spree.reverse_charge_statuses.#{key}"), key] },
82+
{ include_blank: false },
83+
{ class: 'custom-select fullwidth' } %>
84+
</div>
85+
<% end %>
6686
</div>

0 commit comments

Comments
 (0)