From be18244abcec6efbdf83f5c7c74a51123e6f23d2 Mon Sep 17 00:00:00 2001 From: luisramos0 Date: Mon, 15 Jul 2019 15:37:24 +0100 Subject: [PATCH 01/10] Bring views/spree/admin/orders/_shipment and views/spree/admin/orders/_shipment_manifest from spree backend --- .../spree/admin/orders/_shipment.html.erb | 120 ++++++++++++++++++ .../admin/orders/_shipment_manifest.html.erb | 33 +++++ 2 files changed, 153 insertions(+) create mode 100644 app/views/spree/admin/orders/_shipment.html.erb create mode 100644 app/views/spree/admin/orders/_shipment_manifest.html.erb diff --git a/app/views/spree/admin/orders/_shipment.html.erb b/app/views/spree/admin/orders/_shipment.html.erb new file mode 100644 index 0000000000..109f6e00fb --- /dev/null +++ b/app/views/spree/admin/orders/_shipment.html.erb @@ -0,0 +1,120 @@ +
"> + <%= render :partial => "spree/admin/variants/split", :formats => :js %> +
+ + <%= shipment.number %> + - + <%= Spree.t("shipment_states.#{shipment.state}") %> + <%= Spree.t(:package_from) %> + '<%= shipment.stock_location.name %>' + <% if shipment.ready? and can? :update, shipment %> + - + <%= link_to 'ship', '#', :class => 'ship button icon-arrow-right', :data => {'shipment-number' => shipment.number} %> + <% end %> + +
+ + + + + + + + + + + + + + + + + + + + + <%= render 'spree/admin/orders/shipment_manifest', order: order, shipment: shipment %> + + <% unless shipment.shipped? %> + + + + + <% end %> + + + + + <% if shipment.adjustment.present? && !shipment.shipped? %> + + <% end %> + + + + + + + + + + + + +
<%= Spree.t(:item_description) %><%= Spree.t(:price) %><%= Spree.t(:quantity) %><%= Spree.t(:total) %>
+ <% if shipment.adjustment.present? %> + <%= shipment.adjustment.label %>: <%= shipment.shipping_method.name %> + <% else %> + <%= Spree.t(:cannot_set_shipping_method_without_address) %> + <% end %> + + <% if shipment.adjustment.present? %> + <%= shipment.adjustment.display_amount %> + <% end %> + + <% if can? :update, shipment %> + <%= link_to '', '#', :class => 'edit-method icon_link icon-edit no-text with-tip', :data => {:action => 'edit'}, :title => Spree.t('edit') %> + <% end %> +
+ <% if shipment.tracking.present? %> + <%= Spree.t(:tracking) %>: <%= shipment.tracking %> + <% else %> + <%= Spree.t(:no_tracking_present) %> + <% end %> + + <% if can? :update, shipment %> + <%= link_to '', '#', :class => 'edit-tracking icon_link icon-edit no-text with-tip', :data => {:action => 'edit'}, :title => Spree.t('edit') %> + <% end %> +
+
diff --git a/app/views/spree/admin/orders/_shipment_manifest.html.erb b/app/views/spree/admin/orders/_shipment_manifest.html.erb new file mode 100644 index 0000000000..2568e9e791 --- /dev/null +++ b/app/views/spree/admin/orders/_shipment_manifest.html.erb @@ -0,0 +1,33 @@ +<% shipment.manifest.each do |item| %> + <% line_item = order.find_line_item_by_variant(item.variant) %> + + + <%= mini_image(item.variant) %> + + <%= item.variant.product.name %>
<%= "(" + variant_options(item.variant) + ")" unless item.variant.option_values.empty? %> + + <%= line_item.single_money.to_html %> + + <% item.states.each do |state,count| %> + <%= count %> x <%= state.humanize.downcase %> + <% end %> + + <% unless shipment.shipped? %> + + <%= number_field_tag :quantity, item.quantity, :min => 0, :class => "line_item_quantity", :size => 5 %> + + <% end %> + <%= line_item_shipment_price(line_item, item.quantity) %> + <% unless shipment.shipped? %> + + <% if can? :update, item %> + <%= link_to '', '#', :class => 'save-item icon_link icon-ok no-text with-tip', :data => {'shipment-number' => shipment.number, 'variant-id' => item.variant.id, :action => 'save'}, :title => Spree.t('actions.save'), :style => 'display: none' %> + <%= link_to '', '#', :class => 'cancel-item icon_link icon-cancel no-text with-tip', :data => {:action => 'cancel'}, :title => Spree.t('actions.cancel'), :style => 'display: none' %> + <%= link_to '', '#', :class => 'edit-item icon_link icon-edit no-text with-tip', :data => {:action => 'edit'}, :title => Spree.t('edit') %> + <%= link_to '', '#', :class => 'split-item icon_link icon-resize-horizontal no-text with-tip', :data => {:action => 'split', 'variant-id' => item.variant.id}, :title => Spree.t('split') %> + <%= link_to '', '#', :class => 'delete-item icon-trash no-text with-tip', :data => {'shipment-number' => shipment.number, 'variant-id' => item.variant.id, :action => 'remove', :confirm => Spree.t(:are_you_sure)}, :title => Spree.t('delete') %> + <% end %> + + <% end %> + +<% end %> From ee20d354875095aa692f2c76a7ea6f858f9718cf Mon Sep 17 00:00:00 2001 From: luisramos0 Date: Mon, 15 Jul 2019 15:38:46 +0100 Subject: [PATCH 02/10] Fix authorization issue in shipment actions, authorization was being done on a struct (shipment manifest), now it's done on the shipment itself This is similar to https://github.com/spree/spree/pull/5624 --- .../admin/orders/_shipment_manifest.html.erb | 20 +++++++++---------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/app/views/spree/admin/orders/_shipment_manifest.html.erb b/app/views/spree/admin/orders/_shipment_manifest.html.erb index 2568e9e791..9ae19c7981 100644 --- a/app/views/spree/admin/orders/_shipment_manifest.html.erb +++ b/app/views/spree/admin/orders/_shipment_manifest.html.erb @@ -18,16 +18,14 @@ <% end %> <%= line_item_shipment_price(line_item, item.quantity) %> - <% unless shipment.shipped? %> - - <% if can? :update, item %> - <%= link_to '', '#', :class => 'save-item icon_link icon-ok no-text with-tip', :data => {'shipment-number' => shipment.number, 'variant-id' => item.variant.id, :action => 'save'}, :title => Spree.t('actions.save'), :style => 'display: none' %> - <%= link_to '', '#', :class => 'cancel-item icon_link icon-cancel no-text with-tip', :data => {:action => 'cancel'}, :title => Spree.t('actions.cancel'), :style => 'display: none' %> - <%= link_to '', '#', :class => 'edit-item icon_link icon-edit no-text with-tip', :data => {:action => 'edit'}, :title => Spree.t('edit') %> - <%= link_to '', '#', :class => 'split-item icon_link icon-resize-horizontal no-text with-tip', :data => {:action => 'split', 'variant-id' => item.variant.id}, :title => Spree.t('split') %> - <%= link_to '', '#', :class => 'delete-item icon-trash no-text with-tip', :data => {'shipment-number' => shipment.number, 'variant-id' => item.variant.id, :action => 'remove', :confirm => Spree.t(:are_you_sure)}, :title => Spree.t('delete') %> - <% end %> - - <% end %> + + <% if !shipment.shipped? && can?(:update, shipment) %> + <%= link_to '', '#', :class => 'save-item icon_link icon-ok no-text with-tip', :data => {'shipment-number' => shipment.number, 'variant-id' => item.variant.id, :action => 'save'}, :title => Spree.t('actions.save'), :style => 'display: none' %> + <%= link_to '', '#', :class => 'cancel-item icon_link icon-cancel no-text with-tip', :data => {:action => 'cancel'}, :title => Spree.t('actions.cancel'), :style => 'display: none' %> + <%= link_to '', '#', :class => 'edit-item icon_link icon-edit no-text with-tip', :data => {:action => 'edit'}, :title => Spree.t('edit') %> + <%= link_to '', '#', :class => 'split-item icon_link icon-resize-horizontal no-text with-tip', :data => {:action => 'split', 'variant-id' => item.variant.id}, :title => Spree.t('split') %> + <%= link_to '', '#', :class => 'delete-item icon-trash no-text with-tip', :data => {'shipment-number' => shipment.number, 'variant-id' => item.variant.id, :action => 'remove', :confirm => Spree.t(:are_you_sure)}, :title => Spree.t('delete') %> + <% end %> + <% end %> From 54156dfd32e4f974fd0099bb11ca80b5d1cab9cb Mon Sep 17 00:00:00 2001 From: luisramos0 Date: Mon, 15 Jul 2019 15:51:54 +0100 Subject: [PATCH 03/10] Convert spree/admin/orders/_shipment_manifest partial from erb to haml --- .../admin/orders/_shipment_manifest.html.erb | 31 ------------------- .../admin/orders/_shipment_manifest.html.haml | 29 +++++++++++++++++ 2 files changed, 29 insertions(+), 31 deletions(-) delete mode 100644 app/views/spree/admin/orders/_shipment_manifest.html.erb create mode 100644 app/views/spree/admin/orders/_shipment_manifest.html.haml diff --git a/app/views/spree/admin/orders/_shipment_manifest.html.erb b/app/views/spree/admin/orders/_shipment_manifest.html.erb deleted file mode 100644 index 9ae19c7981..0000000000 --- a/app/views/spree/admin/orders/_shipment_manifest.html.erb +++ /dev/null @@ -1,31 +0,0 @@ -<% shipment.manifest.each do |item| %> - <% line_item = order.find_line_item_by_variant(item.variant) %> - - - <%= mini_image(item.variant) %> - - <%= item.variant.product.name %>
<%= "(" + variant_options(item.variant) + ")" unless item.variant.option_values.empty? %> - - <%= line_item.single_money.to_html %> - - <% item.states.each do |state,count| %> - <%= count %> x <%= state.humanize.downcase %> - <% end %> - - <% unless shipment.shipped? %> - - <%= number_field_tag :quantity, item.quantity, :min => 0, :class => "line_item_quantity", :size => 5 %> - - <% end %> - <%= line_item_shipment_price(line_item, item.quantity) %> - - <% if !shipment.shipped? && can?(:update, shipment) %> - <%= link_to '', '#', :class => 'save-item icon_link icon-ok no-text with-tip', :data => {'shipment-number' => shipment.number, 'variant-id' => item.variant.id, :action => 'save'}, :title => Spree.t('actions.save'), :style => 'display: none' %> - <%= link_to '', '#', :class => 'cancel-item icon_link icon-cancel no-text with-tip', :data => {:action => 'cancel'}, :title => Spree.t('actions.cancel'), :style => 'display: none' %> - <%= link_to '', '#', :class => 'edit-item icon_link icon-edit no-text with-tip', :data => {:action => 'edit'}, :title => Spree.t('edit') %> - <%= link_to '', '#', :class => 'split-item icon_link icon-resize-horizontal no-text with-tip', :data => {:action => 'split', 'variant-id' => item.variant.id}, :title => Spree.t('split') %> - <%= link_to '', '#', :class => 'delete-item icon-trash no-text with-tip', :data => {'shipment-number' => shipment.number, 'variant-id' => item.variant.id, :action => 'remove', :confirm => Spree.t(:are_you_sure)}, :title => Spree.t('delete') %> - <% end %> - - -<% end %> diff --git a/app/views/spree/admin/orders/_shipment_manifest.html.haml b/app/views/spree/admin/orders/_shipment_manifest.html.haml new file mode 100644 index 0000000000..04efe2c0ce --- /dev/null +++ b/app/views/spree/admin/orders/_shipment_manifest.html.haml @@ -0,0 +1,29 @@ +- shipment.manifest.each do |item| + - line_item = order.find_line_item_by_variant(item.variant) + + %tr{ :class => "stock-item", "data-item-quantity" => "#{item.quantity}" } + %td{ :class => "item-image" } + = mini_image(item.variant) + %td{ :class => "item-name" } + = item.variant.product.name + %br + - unless item.variant.option_values.empty? + = "(" + variant_options(item.variant) + ")" + %td{ :class => "item-price align-center" } + = line_item.single_money.to_html + %td{ :class => "item-qty-show align-center" } + - item.states.each do |state,count| + = "#{count} x #{state.humanize.downcase}" + - unless shipment.shipped? + %td{ :class => "item-qty-edit hidden" } + = number_field_tag :quantity, item.quantity, :min => 0, :class => "line_item_quantity", :size => 5 + %td{ :class => "item-total align-center" } + = line_item_shipment_price(line_item, item.quantity) + + %td{ :class => "cart-item-delete actions", "data-hook" => "cart_item_delete" } + - if !shipment.shipped? && can?(:update, shipment) + = link_to '', '#', :class => 'save-item icon_link icon-ok no-text with-tip', :data => {'shipment-number' => shipment.number, 'variant-id' => item.variant.id, :action => 'save'}, :title => Spree.t('actions.save'), :style => 'display: none' + = link_to '', '#', :class => 'cancel-item icon_link icon-cancel no-text with-tip', :data => {:action => 'cancel'}, :title => Spree.t('actions.cancel'), :style => 'display: none' + = link_to '', '#', :class => 'edit-item icon_link icon-edit no-text with-tip', :data => {:action => 'edit'}, :title => Spree.t('edit') + = link_to '', '#', :class => 'split-item icon_link icon-resize-horizontal no-text with-tip', :data => {:action => 'split', 'variant-id' => item.variant.id}, :title => Spree.t('split') + = link_to '', '#', :class => 'delete-item icon-trash no-text with-tip', :data => {'shipment-number' => shipment.number, 'variant-id' => item.variant.id, :action => 'remove', :confirm => Spree.t(:are_you_sure)}, :title => Spree.t('delete') From 4a07d670377aae2587457d885323ad9db7dd0abc Mon Sep 17 00:00:00 2001 From: luisramos0 Date: Mon, 15 Jul 2019 16:38:57 +0100 Subject: [PATCH 04/10] Convert spree/admin/orders/_shipment partial from erb to haml --- .../spree/admin/orders/_shipment.html.erb | 120 ------------------ .../spree/admin/orders/_shipment.html.haml | 104 +++++++++++++++ 2 files changed, 104 insertions(+), 120 deletions(-) delete mode 100644 app/views/spree/admin/orders/_shipment.html.erb create mode 100644 app/views/spree/admin/orders/_shipment.html.haml diff --git a/app/views/spree/admin/orders/_shipment.html.erb b/app/views/spree/admin/orders/_shipment.html.erb deleted file mode 100644 index 109f6e00fb..0000000000 --- a/app/views/spree/admin/orders/_shipment.html.erb +++ /dev/null @@ -1,120 +0,0 @@ -
"> - <%= render :partial => "spree/admin/variants/split", :formats => :js %> -
- - <%= shipment.number %> - - - <%= Spree.t("shipment_states.#{shipment.state}") %> - <%= Spree.t(:package_from) %> - '<%= shipment.stock_location.name %>' - <% if shipment.ready? and can? :update, shipment %> - - - <%= link_to 'ship', '#', :class => 'ship button icon-arrow-right', :data => {'shipment-number' => shipment.number} %> - <% end %> - -
- - - - - - - - - - - - - - - - - - - - - <%= render 'spree/admin/orders/shipment_manifest', order: order, shipment: shipment %> - - <% unless shipment.shipped? %> - - - - - <% end %> - - - - - <% if shipment.adjustment.present? && !shipment.shipped? %> - - <% end %> - - - - - - - - - - - - -
<%= Spree.t(:item_description) %><%= Spree.t(:price) %><%= Spree.t(:quantity) %><%= Spree.t(:total) %>
- <% if shipment.adjustment.present? %> - <%= shipment.adjustment.label %>: <%= shipment.shipping_method.name %> - <% else %> - <%= Spree.t(:cannot_set_shipping_method_without_address) %> - <% end %> - - <% if shipment.adjustment.present? %> - <%= shipment.adjustment.display_amount %> - <% end %> - - <% if can? :update, shipment %> - <%= link_to '', '#', :class => 'edit-method icon_link icon-edit no-text with-tip', :data => {:action => 'edit'}, :title => Spree.t('edit') %> - <% end %> -
- <% if shipment.tracking.present? %> - <%= Spree.t(:tracking) %>: <%= shipment.tracking %> - <% else %> - <%= Spree.t(:no_tracking_present) %> - <% end %> - - <% if can? :update, shipment %> - <%= link_to '', '#', :class => 'edit-tracking icon_link icon-edit no-text with-tip', :data => {:action => 'edit'}, :title => Spree.t('edit') %> - <% end %> -
-
diff --git a/app/views/spree/admin/orders/_shipment.html.haml b/app/views/spree/admin/orders/_shipment.html.haml new file mode 100644 index 0000000000..b011268739 --- /dev/null +++ b/app/views/spree/admin/orders/_shipment.html.haml @@ -0,0 +1,104 @@ +%div{ :id => "shipment_#{shipment.id}" } + = render :partial => "spree/admin/variants/split", :formats => :js + %fieldset{ :class => "no-border-bottom" } + %legend{ :align => "center", :class => "stock-location", "data-hook" => "stock-location" } + %span{ :class => "shipment-number" } + = shipment.number + = "-" + %span{ :class => "shipment-state" } + = Spree.t("shipment_states.#{shipment.state}") + = Spree.t(:package_from) + %strong{ :class => "stock-location-name", "data-hook" => "stock-location-name" } + = "'#{shipment.stock_location.name}'" + - if shipment.ready? and can? :update, shipment + = "-" + = link_to 'ship', '#', :class => 'ship button icon-arrow-right', :data => { 'shipment-number' => shipment.number } + + %table{ :class => "stock-contents index", "data-hook" => "stock-contents" } + %colgroup + %col{ :style => "width: 10%;" } + %col{ :style => "width: 30%;" } + %col{ :style => "width: 15%;" } + %col{ :style => "width: 15%;" } + %col{ :style => "width: 15%;" } + %col{ :style => "width: 15%;" } + + %thead + %th{ :colspan => "2" } + = Spree.t(:item_description) + %th + = Spree.t(:price) + %th + = Spree.t(:quantity) + %th + = Spree.t(:total) + %th{ :class => "orders-actions actions", "data-hook" => "admin_order_form_line_items_header_actions" } + + %tbody{ "data-shipment-number" => "#{shipment.number}", "data-order-number" => "#{order.number}" } + = render 'spree/admin/orders/shipment_manifest', order: order, shipment: shipment + + - unless shipment.shipped? + %tr{ :class => "edit-method hidden total" } + %td{ :colspan => "5" } + %div{ :class => "field alpha five columns" } + = label_tag 'selected_shipping_rate_id', Spree.t(:shipping_method) + = select_tag :selected_shipping_rate_id, options_for_select(shipment.shipping_rates.backend.map { |sr| ["#{sr.name} #{sr.display_price}", sr.id] }, shipment.selected_shipping_rate_id), { :class => 'select2 fullwidth', :data => { 'shipment-number' => shipment.number } } + + - if shipment.adjustment && shipment.adjustment.closed? + %div{ :class => "field omega four columns" } + %label + = Spree.t(:associated_adjustment_closed) + %ul + %li + = radio_button_tag :open_adjustment, 'yes', false, :data => { 'shipment-number' => shipment.number } + = "Yes" + %li + = radio_button_tag :open_adjustment, 'no', true, :data => {'shipment-number' => shipment.number } + = "No" + + %td{ :class => "actions" } + - if can? :update, shipment + = link_to '', '#', :class => 'save-method icon_link icon-ok no-text with-tip', :data => { 'shipment-number' => shipment.number, :action => 'save' }, title: Spree.t('actions.save') + = link_to '', '#', :class => 'cancel-method icon_link icon-cancel no-text with-tip', :data => { :action => 'cancel' }, :title => Spree.t('actions.cancel') + + %tr{ :class => "show-method total" } + %td{ :colspan => "4" } + - if shipment.adjustment.present? + %strong + = "#{shipment.adjustment.label}: #{shipment.shipping_method.name}" + - else + = Spree.t(:cannot_set_shipping_method_without_address) + + %td{ :class => "total", :align => "center" } + - if shipment.adjustment.present? + %span + = shipment.adjustment.display_amount + + - if shipment.adjustment.present? && !shipment.shipped? + %td{ :class => "actions" } + - if can? :update, shipment + = link_to '', '#', :class => 'edit-method icon_link icon-edit no-text with-tip', :data => { :action => 'edit' }, :title => Spree.t('edit') + + %tr{ :class => "edit-tracking hidden total" } + %td{ :colspan => "5" } + %label + = "#{Spree.t(:tracking_number)}:" + = text_field_tag :tracking, shipment.tracking + + %td{ :class => "actions" } + - if can? :update, shipment + = link_to '', '#', :class => 'save-tracking icon_link icon-ok no-text with-tip', :data => { 'shipment-number' => shipment.number, :action => 'save' }, :title => Spree.t('actions.save') + = link_to '', '#', :class => 'cancel-tracking icon_link icon-cancel no-text with-tip', :data => { :action => 'cancel' }, :title => Spree.t('actions.cancel') + + %tr{ :class => "show-tracking total" } + %td{ :colspan => "5" } + - if shipment.tracking.present? + %strong + = "#{Spree.t(:tracking)}:" + = shipment.tracking + - else + = Spree.t(:no_tracking_present) + + %td{ :class => "actions" } + - if can? :update, shipment + = link_to '', '#', :class => 'edit-tracking icon_link icon-edit no-text with-tip', :data => { :action => 'edit' }, :title => Spree.t('edit') From 112017a1585c0bc2f69f7bd4f4681183a1042c57 Mon Sep 17 00:00:00 2001 From: luisramos0 Date: Mon, 15 Jul 2019 17:07:33 +0100 Subject: [PATCH 05/10] Remove variants/split partial from orders/shipments partial In OFN we have one shipment per order so it doesnt make sense to split items between shipments --- app/views/spree/admin/orders/_shipment.html.haml | 1 - 1 file changed, 1 deletion(-) diff --git a/app/views/spree/admin/orders/_shipment.html.haml b/app/views/spree/admin/orders/_shipment.html.haml index b011268739..59684842a8 100644 --- a/app/views/spree/admin/orders/_shipment.html.haml +++ b/app/views/spree/admin/orders/_shipment.html.haml @@ -1,5 +1,4 @@ %div{ :id => "shipment_#{shipment.id}" } - = render :partial => "spree/admin/variants/split", :formats => :js %fieldset{ :class => "no-border-bottom" } %legend{ :align => "center", :class => "stock-location", "data-hook" => "stock-location" } %span{ :class => "shipment-number" } From 02c573f146788e57a40a2e13853106a48b811f05 Mon Sep 17 00:00:00 2001 From: luisramos0 Date: Mon, 15 Jul 2019 17:11:41 +0100 Subject: [PATCH 06/10] Remove logic that hides item split, because the partial is now in the ofn codebase, we can now simply remove the split-item button --- .../admin/orders/controllers/order_controller.js.coffee | 5 ----- app/views/spree/admin/orders/_shipment_manifest.html.haml | 1 - 2 files changed, 6 deletions(-) diff --git a/app/assets/javascripts/admin/orders/controllers/order_controller.js.coffee b/app/assets/javascripts/admin/orders/controllers/order_controller.js.coffee index 39faaaa205..822e81eb49 100644 --- a/app/assets/javascripts/admin/orders/controllers/order_controller.js.coffee +++ b/app/assets/javascripts/admin/orders/controllers/order_controller.js.coffee @@ -24,8 +24,3 @@ angular.module("admin.orders").controller "orderCtrl", ($scope, shops, orderCycl for shop in $scope.shops shop.disabled = !$scope.distributorHasOrderCycles(shop) - - # Removes the split button introduced by spree in the order form - # We only have one stock location in OFN so it's meaningless to split the order between stock locations - # We delete it instead of hiding or changing CSS so that, when spree code toggles the element, nothing hapens - $('.split-item').remove() diff --git a/app/views/spree/admin/orders/_shipment_manifest.html.haml b/app/views/spree/admin/orders/_shipment_manifest.html.haml index 04efe2c0ce..35654d7fd6 100644 --- a/app/views/spree/admin/orders/_shipment_manifest.html.haml +++ b/app/views/spree/admin/orders/_shipment_manifest.html.haml @@ -25,5 +25,4 @@ = link_to '', '#', :class => 'save-item icon_link icon-ok no-text with-tip', :data => {'shipment-number' => shipment.number, 'variant-id' => item.variant.id, :action => 'save'}, :title => Spree.t('actions.save'), :style => 'display: none' = link_to '', '#', :class => 'cancel-item icon_link icon-cancel no-text with-tip', :data => {:action => 'cancel'}, :title => Spree.t('actions.cancel'), :style => 'display: none' = link_to '', '#', :class => 'edit-item icon_link icon-edit no-text with-tip', :data => {:action => 'edit'}, :title => Spree.t('edit') - = link_to '', '#', :class => 'split-item icon_link icon-resize-horizontal no-text with-tip', :data => {:action => 'split', 'variant-id' => item.variant.id}, :title => Spree.t('split') = link_to '', '#', :class => 'delete-item icon-trash no-text with-tip', :data => {'shipment-number' => shipment.number, 'variant-id' => item.variant.id, :action => 'remove', :confirm => Spree.t(:are_you_sure)}, :title => Spree.t('delete') From cd7906a57b9c629d28fbff4bac1936f2a217685f Mon Sep 17 00:00:00 2001 From: luisramos0 Date: Mon, 15 Jul 2019 17:48:10 +0100 Subject: [PATCH 07/10] Move translations from Spree.t to root and add them to en.yml --- app/views/spree/admin/orders/_shipment_manifest.html.haml | 8 ++++---- config/locales/en.yml | 4 ++++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/app/views/spree/admin/orders/_shipment_manifest.html.haml b/app/views/spree/admin/orders/_shipment_manifest.html.haml index 35654d7fd6..cf15c48b4f 100644 --- a/app/views/spree/admin/orders/_shipment_manifest.html.haml +++ b/app/views/spree/admin/orders/_shipment_manifest.html.haml @@ -22,7 +22,7 @@ %td{ :class => "cart-item-delete actions", "data-hook" => "cart_item_delete" } - if !shipment.shipped? && can?(:update, shipment) - = link_to '', '#', :class => 'save-item icon_link icon-ok no-text with-tip', :data => {'shipment-number' => shipment.number, 'variant-id' => item.variant.id, :action => 'save'}, :title => Spree.t('actions.save'), :style => 'display: none' - = link_to '', '#', :class => 'cancel-item icon_link icon-cancel no-text with-tip', :data => {:action => 'cancel'}, :title => Spree.t('actions.cancel'), :style => 'display: none' - = link_to '', '#', :class => 'edit-item icon_link icon-edit no-text with-tip', :data => {:action => 'edit'}, :title => Spree.t('edit') - = link_to '', '#', :class => 'delete-item icon-trash no-text with-tip', :data => {'shipment-number' => shipment.number, 'variant-id' => item.variant.id, :action => 'remove', :confirm => Spree.t(:are_you_sure)}, :title => Spree.t('delete') + = link_to '', '#', :class => 'save-item icon_link icon-ok no-text with-tip', :data => {'shipment-number' => shipment.number, 'variant-id' => item.variant.id, :action => 'save'}, :title => t('actions.save'), :style => 'display: none' + = link_to '', '#', :class => 'cancel-item icon_link icon-cancel no-text with-tip', :data => {:action => 'cancel'}, :title => t('actions.cancel'), :style => 'display: none' + = link_to '', '#', :class => 'edit-item icon_link icon-edit no-text with-tip', :data => {:action => 'edit'}, :title => t('actions.edit') + = link_to '', '#', :class => 'delete-item icon-trash no-text with-tip', :data => {'shipment-number' => shipment.number, 'variant-id' => item.variant.id, :action => 'remove', :confirm => t(:are_you_sure)}, :title => t('actions.delete') diff --git a/config/locales/en.yml b/config/locales/en.yml index 015624df34..1d18cce5bc 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -278,6 +278,10 @@ en: create_and_add_another: "Create and Add Another" create: "Create" cancel: "Cancel" + save: "Save" + edit: "Edit" + delete: "Delete" + admin: # Common properties / models begins_at: Begins At From e8127d81dc5004927c3753edc0a595797e533932 Mon Sep 17 00:00:00 2001 From: luisramos0 Date: Mon, 15 Jul 2019 18:37:19 +0100 Subject: [PATCH 08/10] Change how we display variant name in order edit page, use VariantAndLineItemNaming helper method --- app/views/spree/admin/orders/_shipment_manifest.html.haml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/app/views/spree/admin/orders/_shipment_manifest.html.haml b/app/views/spree/admin/orders/_shipment_manifest.html.haml index cf15c48b4f..1732939478 100644 --- a/app/views/spree/admin/orders/_shipment_manifest.html.haml +++ b/app/views/spree/admin/orders/_shipment_manifest.html.haml @@ -5,10 +5,7 @@ %td{ :class => "item-image" } = mini_image(item.variant) %td{ :class => "item-name" } - = item.variant.product.name - %br - - unless item.variant.option_values.empty? - = "(" + variant_options(item.variant) + ")" + = item.variant.product_and_full_name %td{ :class => "item-price align-center" } = line_item.single_money.to_html %td{ :class => "item-qty-show align-center" } From 83a306c31b19eb0c0aa3f3203c697dbbb3a83357 Mon Sep 17 00:00:00 2001 From: luisramos0 Date: Tue, 16 Jul 2019 14:09:48 +0100 Subject: [PATCH 09/10] Convert class attributes to . notation in haml --- .../spree/admin/orders/_shipment.html.haml | 36 +++++++++---------- .../admin/orders/_shipment_manifest.html.haml | 16 ++++----- 2 files changed, 26 insertions(+), 26 deletions(-) diff --git a/app/views/spree/admin/orders/_shipment.html.haml b/app/views/spree/admin/orders/_shipment.html.haml index 59684842a8..855685c640 100644 --- a/app/views/spree/admin/orders/_shipment.html.haml +++ b/app/views/spree/admin/orders/_shipment.html.haml @@ -1,19 +1,19 @@ %div{ :id => "shipment_#{shipment.id}" } - %fieldset{ :class => "no-border-bottom" } - %legend{ :align => "center", :class => "stock-location", "data-hook" => "stock-location" } - %span{ :class => "shipment-number" } + %fieldset.no-border-bottom + %legend.stock-location{ :align => "center", "data-hook" => "stock-location" } + %span.shipment-number = shipment.number = "-" - %span{ :class => "shipment-state" } + %span.shipment-state = Spree.t("shipment_states.#{shipment.state}") = Spree.t(:package_from) - %strong{ :class => "stock-location-name", "data-hook" => "stock-location-name" } + %strong.stock-location-name{ "data-hook" => "stock-location-name" } = "'#{shipment.stock_location.name}'" - if shipment.ready? and can? :update, shipment = "-" = link_to 'ship', '#', :class => 'ship button icon-arrow-right', :data => { 'shipment-number' => shipment.number } - %table{ :class => "stock-contents index", "data-hook" => "stock-contents" } + %table.stock-contents.index{ "data-hook" => "stock-contents" } %colgroup %col{ :style => "width: 10%;" } %col{ :style => "width: 30%;" } @@ -31,20 +31,20 @@ = Spree.t(:quantity) %th = Spree.t(:total) - %th{ :class => "orders-actions actions", "data-hook" => "admin_order_form_line_items_header_actions" } + %th.orders-actions.actions{ "data-hook" => "admin_order_form_line_items_header_actions" } %tbody{ "data-shipment-number" => "#{shipment.number}", "data-order-number" => "#{order.number}" } = render 'spree/admin/orders/shipment_manifest', order: order, shipment: shipment - unless shipment.shipped? - %tr{ :class => "edit-method hidden total" } + %tr.edit-method.hidden.total %td{ :colspan => "5" } - %div{ :class => "field alpha five columns" } + %div.field.alpha.five.columns = label_tag 'selected_shipping_rate_id', Spree.t(:shipping_method) = select_tag :selected_shipping_rate_id, options_for_select(shipment.shipping_rates.backend.map { |sr| ["#{sr.name} #{sr.display_price}", sr.id] }, shipment.selected_shipping_rate_id), { :class => 'select2 fullwidth', :data => { 'shipment-number' => shipment.number } } - if shipment.adjustment && shipment.adjustment.closed? - %div{ :class => "field omega four columns" } + %div.field.omega.four.columns %label = Spree.t(:associated_adjustment_closed) %ul @@ -55,12 +55,12 @@ = radio_button_tag :open_adjustment, 'no', true, :data => {'shipment-number' => shipment.number } = "No" - %td{ :class => "actions" } + %td.actions - if can? :update, shipment = link_to '', '#', :class => 'save-method icon_link icon-ok no-text with-tip', :data => { 'shipment-number' => shipment.number, :action => 'save' }, title: Spree.t('actions.save') = link_to '', '#', :class => 'cancel-method icon_link icon-cancel no-text with-tip', :data => { :action => 'cancel' }, :title => Spree.t('actions.cancel') - %tr{ :class => "show-method total" } + %tr.show-method.total %td{ :colspan => "4" } - if shipment.adjustment.present? %strong @@ -68,28 +68,28 @@ - else = Spree.t(:cannot_set_shipping_method_without_address) - %td{ :class => "total", :align => "center" } + %td.total{ :align => "center" } - if shipment.adjustment.present? %span = shipment.adjustment.display_amount - if shipment.adjustment.present? && !shipment.shipped? - %td{ :class => "actions" } + %td.actions - if can? :update, shipment = link_to '', '#', :class => 'edit-method icon_link icon-edit no-text with-tip', :data => { :action => 'edit' }, :title => Spree.t('edit') - %tr{ :class => "edit-tracking hidden total" } + %tr.edit-tracking.hidden.total %td{ :colspan => "5" } %label = "#{Spree.t(:tracking_number)}:" = text_field_tag :tracking, shipment.tracking - %td{ :class => "actions" } + %td.actions - if can? :update, shipment = link_to '', '#', :class => 'save-tracking icon_link icon-ok no-text with-tip', :data => { 'shipment-number' => shipment.number, :action => 'save' }, :title => Spree.t('actions.save') = link_to '', '#', :class => 'cancel-tracking icon_link icon-cancel no-text with-tip', :data => { :action => 'cancel' }, :title => Spree.t('actions.cancel') - %tr{ :class => "show-tracking total" } + %tr.show-tracking.total %td{ :colspan => "5" } - if shipment.tracking.present? %strong @@ -98,6 +98,6 @@ - else = Spree.t(:no_tracking_present) - %td{ :class => "actions" } + %td.actions - if can? :update, shipment = link_to '', '#', :class => 'edit-tracking icon_link icon-edit no-text with-tip', :data => { :action => 'edit' }, :title => Spree.t('edit') diff --git a/app/views/spree/admin/orders/_shipment_manifest.html.haml b/app/views/spree/admin/orders/_shipment_manifest.html.haml index 1732939478..75eaa2f4ad 100644 --- a/app/views/spree/admin/orders/_shipment_manifest.html.haml +++ b/app/views/spree/admin/orders/_shipment_manifest.html.haml @@ -1,23 +1,23 @@ - shipment.manifest.each do |item| - line_item = order.find_line_item_by_variant(item.variant) - %tr{ :class => "stock-item", "data-item-quantity" => "#{item.quantity}" } - %td{ :class => "item-image" } + %tr.stock-item{ "data-item-quantity" => "#{item.quantity}" } + %td.item-image = mini_image(item.variant) - %td{ :class => "item-name" } + %td.item-name = item.variant.product_and_full_name - %td{ :class => "item-price align-center" } + %td.item-price.align-center = line_item.single_money.to_html - %td{ :class => "item-qty-show align-center" } + %td.item-qty-show.align-center - item.states.each do |state,count| = "#{count} x #{state.humanize.downcase}" - unless shipment.shipped? - %td{ :class => "item-qty-edit hidden" } + %td.item-qty-edit.hidden = number_field_tag :quantity, item.quantity, :min => 0, :class => "line_item_quantity", :size => 5 - %td{ :class => "item-total align-center" } + %td.item-total.align-center = line_item_shipment_price(line_item, item.quantity) - %td{ :class => "cart-item-delete actions", "data-hook" => "cart_item_delete" } + %td.cart-item-delete.actions{ "data-hook" => "cart_item_delete" } - if !shipment.shipped? && can?(:update, shipment) = link_to '', '#', :class => 'save-item icon_link icon-ok no-text with-tip', :data => {'shipment-number' => shipment.number, 'variant-id' => item.variant.id, :action => 'save'}, :title => t('actions.save'), :style => 'display: none' = link_to '', '#', :class => 'cancel-item icon_link icon-cancel no-text with-tip', :data => {:action => 'cancel'}, :title => t('actions.cancel'), :style => 'display: none' From b9b8bc70dd4df9559f22b01a693a0e5a3603e099 Mon Sep 17 00:00:00 2001 From: luisramos0 Date: Wed, 24 Jul 2019 11:50:17 +0100 Subject: [PATCH 10/10] Remove stock location name from shipment header in the order edit page --- app/views/spree/admin/orders/_shipment.html.haml | 3 --- 1 file changed, 3 deletions(-) diff --git a/app/views/spree/admin/orders/_shipment.html.haml b/app/views/spree/admin/orders/_shipment.html.haml index 855685c640..2b5338806d 100644 --- a/app/views/spree/admin/orders/_shipment.html.haml +++ b/app/views/spree/admin/orders/_shipment.html.haml @@ -6,9 +6,6 @@ = "-" %span.shipment-state = Spree.t("shipment_states.#{shipment.state}") - = Spree.t(:package_from) - %strong.stock-location-name{ "data-hook" => "stock-location-name" } - = "'#{shipment.stock_location.name}'" - if shipment.ready? and can? :update, shipment = "-" = link_to 'ship', '#', :class => 'ship button icon-arrow-right', :data => { 'shipment-number' => shipment.number }