From d32e106bf0c3101df0e22d228195fadb6dc067e0 Mon Sep 17 00:00:00 2001 From: luisramos0 Date: Sun, 15 Dec 2019 16:28:59 +0000 Subject: [PATCH] Add partials needed in the orders edit page --- .../spree/admin/shared/_address_form.html.erb | 72 +++++++++++++++++++ .../spree/admin/shared/_update_order_state.js | 7 ++ 2 files changed, 79 insertions(+) create mode 100644 app/views/spree/admin/shared/_address_form.html.erb create mode 100644 app/views/spree/admin/shared/_update_order_state.js diff --git a/app/views/spree/admin/shared/_address_form.html.erb b/app/views/spree/admin/shared/_address_form.html.erb new file mode 100644 index 0000000000..012c40d9e8 --- /dev/null +++ b/app/views/spree/admin/shared/_address_form.html.erb @@ -0,0 +1,72 @@ +<% if use_billing %> +
+ + <%= check_box_tag 'order[use_billing]', '1', (!(@order.bill_address.empty? && @order.ship_address.empty?) && @order.bill_address.same_as?(@order.ship_address)) %> + <%= label_tag 'order[use_billing]', Spree.t(:use_billing_address) %> + +
+<% end %> + +<% is_shipping_address = name == Spree.t(:shipping_address) %> +<% shipping_or_billing = is_shipping_address ? 'shipping' : 'billing' %> +<% s_or_b = is_shipping_address ? 's' : 'b' %> + +
+
"> + <%= f.label :firstname, Spree.t(:first_name) + ':' %> + <%= f.text_field :firstname, :class => 'fullwidth' %> +
+
"> + <%= f.label :lastname, Spree.t(:last_name) + ':' %> + <%= f.text_field :lastname, :class => 'fullwidth' %> +
+ <% if Spree::Config[:company] %> +
"> + <%= f.label :company, Spree.t(:company) + ':' %> + <%= f.text_field :company, :class => 'fullwidth' %> +
+ <% end %> +
"> + <%= f.label :address1, Spree.t(:street_address) + ':' %> + <%= f.text_field :address1, :class => 'fullwidth' %> +
+
"> + <%= f.label :address2, Spree.t(:street_address_2) + ':' %> + <%= f.text_field :address2, :class => 'fullwidth' %> +
+
"> + <%= f.label :city, Spree.t(:city) + ':' %> + <%= f.text_field :city, :class => 'fullwidth' %> +
+
"> + <%= f.label :zipcode, Spree.t(:zip) + ':' %> + <%= f.text_field :zipcode, :class => 'fullwidth' %> +
+
"> + <%= f.label :country_id, Spree.t(:country) + ':' %> + + <%= f.collection_select :country_id, available_countries, :id, :name, {}, {:class => 'select2 fullwidth'} %> + +
+
"> + <%= f.label :state_id, Spree.t(:state) + ':' %> + + <%= f.text_field :state_name, + :style => "display: #{f.object.country.states.empty? ? 'block' : 'none' };", + :disabled => !f.object.country.states.empty?, :class => 'fullwidth state_name' %> + <%= f.collection_select :state_id, f.object.country.states.sort, :id, :name, {:include_blank => true}, {:class => 'select2 fullwidth', :style => "display: #{f.object.country.states.empty? ? 'none' : 'block' };", :disabled => f.object.country.states.empty?} %> + +
+
"> + <%= f.label :phone, Spree.t(:phone) + ':' %> + <%= f.phone_field :phone, :class => 'fullwidth' %> +
+
+ +<% content_for :head do %> + <%= javascript_tag do -%> + $(document).ready(function(){ + $('span#<%= s_or_b %>country .select2').on('change', function() { update_state('<%= s_or_b %>'); }); + }); + <% end -%> +<% end %> diff --git a/app/views/spree/admin/shared/_update_order_state.js b/app/views/spree/admin/shared/_update_order_state.js new file mode 100644 index 0000000000..32b2d4d574 --- /dev/null +++ b/app/views/spree/admin/shared/_update_order_state.js @@ -0,0 +1,7 @@ +$('#order_tab_summary h5#order_status').html('<%= j Spree.t(:status) %>: <%= j Spree.t(@order.state, :scope => :order_state) %>'); +$('#order_tab_summary h5#order_total').html('<%= j Spree.t(:total) %>: <%= j @order.display_total.to_html %>'); + +<% if @order.completed? %> + $('#order_tab_summary h5#payment_status').html('<%= j Spree.t(:payment) %>: <%= j Spree.t(@order.payment_state, :scope => :payment_states, :default => [:missing, "none"]) %>'); + $('#order_tab_summary h5#shipment_status').html('<%= j Spree.t(:shipment) %>: <%= j Spree.t(@order.shipment_state, :scope => :shipment_state, :default => [:missing, "none"]) %>'); +<% end %>