From 768240a5ba45e3967dfbd5e3bf980a4ee50fd461 Mon Sep 17 00:00:00 2001 From: Rob Harrington Date: Thu, 30 Mar 2017 15:23:09 +1100 Subject: [PATCH] Reorganising darkswarm order views into partials --- app/views/spree/orders/_form.html.haml | 13 +--- app/views/spree/orders/_summary.html.haml | 65 ++++++++++++++++++ app/views/spree/orders/edit.html.haml | 13 +--- .../orders/form/_cart_actions_row.html.haml | 10 +++ .../spree/orders/form/_cart_links.html.haml | 9 +++ .../orders/form/_update_buttons.html.haml | 5 ++ app/views/spree/orders/show.html.haml | 7 -- .../spree/shared/_order_details.html.haml | 67 +------------------ 8 files changed, 93 insertions(+), 96 deletions(-) create mode 100644 app/views/spree/orders/_summary.html.haml create mode 100644 app/views/spree/orders/form/_cart_actions_row.html.haml create mode 100644 app/views/spree/orders/form/_cart_links.html.haml create mode 100644 app/views/spree/orders/form/_update_buttons.html.haml diff --git a/app/views/spree/orders/_form.html.haml b/app/views/spree/orders/_form.html.haml index 68ba409aa0..a4feef8f84 100644 --- a/app/views/spree/orders/_form.html.haml +++ b/app/views/spree/orders/_form.html.haml @@ -21,18 +21,7 @@ = render :partial => 'line_item', :locals => { :variant => item_form.object.variant, :line_item => item_form.object, :item_form => item_form } %tfoot#edit-cart - %tr - %td{colspan:"2"} - %td - = button_tag :class => 'secondary radius expand small', :id => 'update-button' do - %i.ofn-i_023-refresh - = t(:update) - %td - %td#empty-cart.text-center - %span#clear_cart_link{"data-hook" => ""} - = link_to t(:orders_form_empty_cart), empty_cart_path, method: :put, :class => 'not-bold small' - -#= form_tag empty_cart_path, :method => :put do - -#= submit_tag t(:empty_cart), :class => 'button alert expand small' + = render 'spree/orders/form/cart_actions_row' / This is the fees row which we want to replace with the pop-over -# - unless @order.adjustments.eligible.blank? diff --git a/app/views/spree/orders/_summary.html.haml b/app/views/spree/orders/_summary.html.haml new file mode 100644 index 0000000000..8c904716c1 --- /dev/null +++ b/app/views/spree/orders/_summary.html.haml @@ -0,0 +1,65 @@ +%table#line-items{"data-hook" => "order_details"} + %col{valign: "middle"}/ + %col{halign: "center", valign: "middle", width: "5%"}/ + %col{halign: "center", valign: "middle", width: "5%"}/ + %col{halign: "center", valign: "middle", width: "5%"}/ + %thead{"data-hook" => ""} + %tr{"data-hook" => "order_details_line_items_headers"} + %th= t(:item) + %th.price= t(:price) + %th.text-center.qty= t(:qty) + %th.text-right.total + %span= t(:total) + %tbody{"data-hook" => ""} + - order.line_items.each do |item| + %tr{"data-hook" => "order_details_line_item_row"} + %td(data-hook = "order_item_description") + + %div.item-thumb-image{"data-hook" => "order_item_image"} + - if item.variant.images.length == 0 + = link_to mini_image(item.variant.product), item.variant.product + - else + = link_to image_tag(item.variant.images.first.attachment.url(:mini)), item.variant.product + + + = render 'spree/shared/line_item_name', line_item: item + + %td.text-right.price{"data-hook" => "order_item_price"} + %span= item.single_display_amount_with_adjustments.to_html + %td.text-center{"data-hook" => "order_item_qty"}= item.quantity + %td.text-right.total{"data-hook" => "order_item_total"} + %span= item.display_amount_with_adjustments.to_html + + %tfoot + #subtotal{"data-hook" => "order_details_subtotal"} + %tr#subtotal-row.total + %td.text-right{colspan: "3"} + %strong + = t :order_produce + %td.text-right.total + %span= display_checkout_subtotal(order) + + #order-charges{"data-hook" => "order_details_adjustments"} + - checkout_adjustments_for(order, exclude: [:line_item]).reject{ |a| a.amount == 0 }.reverse_each do |adjustment| + %tr.total + %td.text-right{:colspan => "3"} + %strong + = adjustment.label + %td.text-right.total + %span= adjustment.display_amount.to_html + + #order-total{"data-hook" => "order_details_total"} + %tr.total + %td.text-right{colspan: "3"} + %h5 + = t :order_total_price + %td.text-right.total + %h5#order_total= order.display_total.to_html + + - if order.total_tax > 0 + #tax{"data-hook" => "order_details_tax"} + %tr#tax-row.total + %td.text-right{colspan: "3"} + = t :order_includes_tax + %td.text-right.total + %span= display_checkout_tax_total(order) diff --git a/app/views/spree/orders/edit.html.haml b/app/views/spree/orders/edit.html.haml index 58124ffa71..8be16c9cec 100644 --- a/app/views/spree/orders/edit.html.haml +++ b/app/views/spree/orders/edit.html.haml @@ -31,18 +31,7 @@ .row = render :partial => 'form', :locals => { :order_form => order_form } - - .links{'data-hook' => "cart_buttons"} - .row - .columns.large-8{"data-hook" => ""} - - %a.button.large.secondary{href: main_app.shop_path} - %i.ofn-i_008-caret-left - = t :orders_edit_continue - .columns.large-4.text-right - %a#checkout-link.button.large.primary{href: main_app.checkout_path} - = t :orders_edit_checkout - %i.ofn-i_007-caret-right + = render "spree/orders/form/cart_links" = render 'bought' if show_bought_items? diff --git a/app/views/spree/orders/form/_cart_actions_row.html.haml b/app/views/spree/orders/form/_cart_actions_row.html.haml new file mode 100644 index 0000000000..5790f7f9e1 --- /dev/null +++ b/app/views/spree/orders/form/_cart_actions_row.html.haml @@ -0,0 +1,10 @@ +%tr + %td{colspan:"2"} + %td + = button_tag :class => 'secondary radius expand small', :id => 'update-button' do + %i.ofn-i_023-refresh + = t(:update) + %td + %td#empty-cart.text-center + %span#clear_cart_link{"data-hook" => ""} + = link_to t(:orders_form_empty_cart), empty_cart_path, method: :put, :class => 'not-bold small' diff --git a/app/views/spree/orders/form/_cart_links.html.haml b/app/views/spree/orders/form/_cart_links.html.haml new file mode 100644 index 0000000000..cec97a8a4d --- /dev/null +++ b/app/views/spree/orders/form/_cart_links.html.haml @@ -0,0 +1,9 @@ +.row.links{'data-hook' => "cart_buttons"} + .columns.large-8{"data-hook" => ""} + %a.button.large.secondary{href: main_app.shop_path} + %i.ofn-i_008-caret-left + = t :orders_edit_continue + .columns.large-4.text-right + %a#checkout-link.button.large.primary{href: main_app.checkout_path} + = t :orders_edit_checkout + %i.ofn-i_007-caret-right diff --git a/app/views/spree/orders/form/_update_buttons.html.haml b/app/views/spree/orders/form/_update_buttons.html.haml new file mode 100644 index 0000000000..5c8f4fa972 --- /dev/null +++ b/app/views/spree/orders/form/_update_buttons.html.haml @@ -0,0 +1,5 @@ +.row + .columns.small-12.medium-3 + = link_to main_app.shop_path, :class => "button expand" do + %i.ofn-i_008-caret-left + = t(:back_to_store) diff --git a/app/views/spree/orders/show.html.haml b/app/views/spree/orders/show.html.haml index e4cb3b1980..41b3682383 100644 --- a/app/views/spree/orders/show.html.haml +++ b/app/views/spree/orders/show.html.haml @@ -19,12 +19,5 @@ = render 'spree/shared/order_details', order: @order - .row - .columns.large-12 - = link_to t(:back_to_store), main_app.shop_path, :class => "button" - - unless params.has_key? :checkout_complete - - if try_spree_current_user && respond_to?(:spree_account_path) - = link_to t(:my_account), spree_account_path, :class => "button" - = render partial: "shared/footer" diff --git a/app/views/spree/shared/_order_details.html.haml b/app/views/spree/shared/_order_details.html.haml index d0a7e99ddf..6845c0905a 100644 --- a/app/views/spree/shared/_order_details.html.haml +++ b/app/views/spree/shared/_order_details.html.haml @@ -86,68 +86,5 @@ %br .row .columns.large-12 - %table#line-items{"data-hook" => "order_details"} - %col{valign: "middle"}/ - %col{halign: "center", valign: "middle", width: "5%"}/ - %col{halign: "center", valign: "middle", width: "5%"}/ - %col{halign: "center", valign: "middle", width: "5%"}/ - %thead{"data-hook" => ""} - %tr{"data-hook" => "order_details_line_items_headers"} - %th= t(:item) - %th.price= t(:price) - %th.text-center.qty= t(:qty) - %th.text-right.total - %span= t(:total) - %tbody{"data-hook" => ""} - - order.line_items.each do |item| - %tr{"data-hook" => "order_details_line_item_row"} - %td(data-hook = "order_item_description") - - %div.item-thumb-image{"data-hook" => "order_item_image"} - - if item.variant.images.length == 0 - = link_to mini_image(item.variant.product), item.variant.product - - else - = link_to image_tag(item.variant.images.first.attachment.url(:mini)), item.variant.product - - - = render 'spree/shared/line_item_name', line_item: item - - %td.text-right.price{"data-hook" => "order_item_price"} - %span= item.single_display_amount_with_adjustments.to_html - %td.text-center{"data-hook" => "order_item_qty"}= item.quantity - %td.text-right.total{"data-hook" => "order_item_total"} - %span= item.display_amount_with_adjustments.to_html - - %tfoot - #subtotal{"data-hook" => "order_details_subtotal"} - %tr#subtotal-row.total - %td.text-right{colspan: "3"} - %strong - = t :order_produce - %td.text-right.total - %span= display_checkout_subtotal(order) - - #order-charges{"data-hook" => "order_details_adjustments"} - - checkout_adjustments_for(order, exclude: [:line_item]).reject{ |a| a.amount == 0 }.reverse_each do |adjustment| - %tr.total - %td.text-right{:colspan => "3"} - %strong - = adjustment.label - %td.text-right.total - %span= adjustment.display_amount.to_html - - #order-total{"data-hook" => "order_details_total"} - %tr.total - %td.text-right{colspan: "3"} - %h5 - = t :order_total_price - %td.text-right.total - %h5#order_total= order.display_total.to_html - - - if order.total_tax > 0 - #tax{"data-hook" => "order_details_tax"} - %tr#tax-row.total - %td.text-right{colspan: "3"} - = t :order_includes_tax - %td.text-right.total - %span= display_checkout_tax_total(order) + = render partial: 'spree/orders/summary' + = render 'spree/orders/form/update_buttons'