diff --git a/app/overrides/spree/admin/orders/_form/add_distribution_fields.html.haml.deface b/app/overrides/spree/admin/orders/_form/add_distribution_fields.html.haml.deface deleted file mode 100644 index af07be1d23..0000000000 --- a/app/overrides/spree/admin/orders/_form/add_distribution_fields.html.haml.deface +++ /dev/null @@ -1,3 +0,0 @@ -/ insert_before "[data-hook='admin_order_form_buttons']" - -= render partial: 'spree/admin/orders/_form/distribution_fields' diff --git a/app/overrides/spree/admin/orders/_form/hide_form_until_distribution.deface b/app/overrides/spree/admin/orders/_form/hide_form_until_distribution.deface deleted file mode 100644 index 7fe5652aae..0000000000 --- a/app/overrides/spree/admin/orders/_form/hide_form_until_distribution.deface +++ /dev/null @@ -1,2 +0,0 @@ -add_to_attributes "table.index, [data-hook='admin_order_form_buttons']" -attributes "ng-show" => "distributionChosen()" diff --git a/app/overrides/spree/admin/orders/_form/relabel_update_button.html.haml.deface b/app/overrides/spree/admin/orders/_form/relabel_update_button.html.haml.deface deleted file mode 100644 index d4d3aefc8d..0000000000 --- a/app/overrides/spree/admin/orders/_form/relabel_update_button.html.haml.deface +++ /dev/null @@ -1,3 +0,0 @@ -/ replace "code[erb-loud]:contains('button t(:update)')" - -= button t(:update_and_recalculate_fees), 'icon-refresh' diff --git a/app/overrides/spree/admin/orders/_line_item/replace_variant_label.html.haml.deface b/app/overrides/spree/admin/orders/_line_item/replace_variant_label.html.haml.deface deleted file mode 100644 index 6481791112..0000000000 --- a/app/overrides/spree/admin/orders/_line_item/replace_variant_label.html.haml.deface +++ /dev/null @@ -1,3 +0,0 @@ -/ replace 'code[erb-loud]:contains(\'"(#{f.object.variant.options_text})"\')' - -= "(#{f.object.full_name})" diff --git a/app/overrides/spree/admin/orders/_line_item/replace_variant_price.html.haml.deface b/app/overrides/spree/admin/orders/_line_item/replace_variant_price.html.haml.deface deleted file mode 100644 index 605f645996..0000000000 --- a/app/overrides/spree/admin/orders/_line_item/replace_variant_price.html.haml.deface +++ /dev/null @@ -1,3 +0,0 @@ -/ replace 'code[erb-loud]:contains(\'f.object.variant.display_amount\')' - -= f.object.single_money diff --git a/app/overrides/spree/admin/orders/edit/add_action_dropdown.html.haml.deface b/app/overrides/spree/admin/orders/edit/add_action_dropdown.html.haml.deface deleted file mode 100644 index 58b13a3b32..0000000000 --- a/app/overrides/spree/admin/orders/edit/add_action_dropdown.html.haml.deface +++ /dev/null @@ -1,6 +0,0 @@ -/ insert_after "code[erb-loud]:contains('button_link_to t(:resend)')" - -%li.links-dropdown#links-dropdown{ links: order_links(@order).to_json } - -:coffee - angular.bootstrap(document.getElementById("links-dropdown"),['admin.dropdown']) diff --git a/app/overrides/spree/admin/orders/edit/suppress_errors.html.haml.deface b/app/overrides/spree/admin/orders/edit/suppress_errors.html.haml.deface deleted file mode 100644 index 31a8c961e8..0000000000 --- a/app/overrides/spree/admin/orders/edit/suppress_errors.html.haml.deface +++ /dev/null @@ -1,6 +0,0 @@ -/ replace "code[erb-loud]:contains(\'error_messages\')" - --# Suppress errors when manually creating a new order - needs to proceed to edit page --# without having line items (which otherwise gives a validation error) -- unless params["suppress_error_msg"] - = render partial: "spree/shared/error_messages", :locals => { :target => @order } diff --git a/app/views/spree/admin/orders/_add_product.html.haml b/app/views/spree/admin/orders/_add_product.html.haml new file mode 100644 index 0000000000..eecc678521 --- /dev/null +++ b/app/views/spree/admin/orders/_add_product.html.haml @@ -0,0 +1,17 @@ += render partial: "spree/admin/variants/autocomplete", formats: :js +#add-line-item + %fieldset + %legend{align: "center"} + = t(:add_product) + .field.eight.columns.alpha + = label_tag :add_product_name, t(:name_or_sku) + = hidden_field_tag :add_variant_id, "", class: "variant_autocomplete fullwidth" + .field.two.columns + = label_tag :add_quantity, t(:qty) + = number_field_tag :add_quantity, 1, min: 0 + .actions.two.columns.omega + = link_to_with_icon 'icon-plus', t(:add), admin_order_line_items_url(@order), + method: :post, + id: 'add_line_item_to_order', + class: 'button fullwidth', + 'data-update' => 'order-form-wrapper' diff --git a/app/views/spree/admin/orders/_form.html.haml b/app/views/spree/admin/orders/_form.html.haml new file mode 100644 index 0000000000..8564ae04f5 --- /dev/null +++ b/app/views/spree/admin/orders/_form.html.haml @@ -0,0 +1,68 @@ +%div + - if @line_item.try(:errors).present? + = render partial: 'spree/shared/error_messages', locals: { target: @line_item } + = form_for @order, url: admin_order_url(@order), method: :put do |f| + %fieldset.no-border-top + = f.hidden_field :number + %table.index{"ng-show" => "distributionChosen()"} + %colgroup + %col{style: "width: 49%;"}/ + %col{style: "width: 14%;"}/ + %col{style: "width: 10%;"}/ + %col{style: "width: 14%;"}/ + %col{style: "width: 8%;"}/ + %thead#line-items + %tr + %th + = t(:item_description) + %th.price + = t(:price) + %th.qty + = t(:qty) + %th.total + %span + = t(:total) + %th.orders-actions.actions + %tbody + = f.fields_for :line_items do |li_form| + = render partial: 'spree/admin/orders/line_item', locals: { f: li_form } + %tbody#subtotal.no-border-top + %tr#subtotal-row + %td{colspan: "3"} + %b + = t(:subtotal) + \: + %td.total.align-center + %span + = @order.display_item_total.to_html + %td.actions + %tbody#order-charges.no-border-top + - @order.adjustments.eligible.each do |adjustment| + %tr + %td{colspan: "3"} + %strong + = adjustment.label + \: + %td.total.align-center + %span= adjustment.display_amount.to_html + %td.actions + %tbody#order-total.grand-total.no-border-top + %tr + %td{colspan: "3"} + %b + = t(:order_total) + \: + %td.total.align-center + %span#order_total + = @order.display_total.to_html + %td.actions + + = render partial: 'spree/admin/orders/_form/distribution_fields' + + .filter-actions.actions{"ng-show" => "distributionChosen()"} + = button t(:update_and_recalculate_fees), 'icon-refresh' + %span.or + = t(:or) + = link_to_with_icon 'button icon-arrow-left', t(:back), admin_orders_url + = javascript_tag do + = render partial: 'spree/admin/shared/update_order_state', handlers: [:js] diff --git a/app/views/spree/admin/orders/_line_item.html.haml b/app/views/spree/admin/orders/_line_item.html.haml new file mode 100644 index 0000000000..9afed0e2ec --- /dev/null +++ b/app/views/spree/admin/orders/_line_item.html.haml @@ -0,0 +1,12 @@ +%tr{id: "#{spree_dom_id(f.object)}", class: "#{cycle('odd', 'even')}"} + %td + = f.object.variant.product.name + = "(#{f.object.full_name})" unless f.object.variant.option_values.empty? + %td.price.align-center + = f.object.variant.display_amount + %td.qty + = f.number_field :quantity, min: 0, class: "qty" + %td.total.align-center + = f.object.single_money + %td.actions + = link_to_delete f.object, {url: admin_order_line_item_url(@order.number, f.object), no_text: true} diff --git a/app/views/spree/admin/orders/edit.html.haml b/app/views/spree/admin/orders/edit.html.haml index f897065224..015e9234e8 100644 --- a/app/views/spree/admin/orders/edit.html.haml +++ b/app/views/spree/admin/orders/edit.html.haml @@ -3,6 +3,8 @@ - content_for :page_actions do %li= event_links %li= button_link_to t(:resend), resend_admin_order_url(@order), method: :post, icon: 'icon-email' + %li.links-dropdown#links-dropdown{ links: order_links(@order).to_json } + %li= button_link_to t(:back_to_orders_list), admin_orders_path, icon: 'icon-arrow-left' = admin_inject_shops(module: 'admin.orders') @@ -10,15 +12,19 @@ = render 'spree/admin/shared/order_tabs', current: 'Order Details' -%div{"data-hook" => "admin_order_edit_header"} - = render 'spree/shared/error_messages', target: @order +%div + - unless params["suppress_error_msg"] + = render partial: "spree/shared/error_messages", :locals => { :target => @order } %div{"ng-app" => "admin.orders", "ng-controller" => "orderCtrl", "ofn-distributor-id" => @order.distributor_id, "ofn-order-cycle-id" => @order.order_cycle_id} = render 'add_product' - %div{"data-hook" => "admin_order_edit_form"} + %div #order-form-wrapper = render 'form', order: @order - content_for :head do = javascript_tag 'var expand_variants = true;' + +:coffee + angular.bootstrap(document.getElementById("links-dropdown"),['admin.dropdown']) diff --git a/app/views/spree/admin/shared/_order_tabs.html.haml b/app/views/spree/admin/shared/_order_tabs.html.haml new file mode 100644 index 0000000000..d250507193 --- /dev/null +++ b/app/views/spree/admin/shared/_order_tabs.html.haml @@ -0,0 +1,75 @@ +- content_for :page_title do + = t(:order) + \# + = @order.number + +- if @order.bill_address.present? + = @order.bill_address.firstname + = @order.bill_address.lastname + \- + +- content_for :sidebar_title do + = t(:order_information) + +- content_for :sidebar do + %header#order_tab_summary + %dl.additional-info + %dt#order_status + = t(:status) + %dd + - order_state_classes = "state #{@order.state}" + %span{ class: order_state_classes } + = t(@order.state, scope: :order_state) + %dt + = t(:total) + \: + %dd#order_total + = @order.display_total.to_html + + - if @order.completed? + %dt + = t(:shipment) + \: + %dd#shipment_status + - shipment_state_classes = "state #{@order.shipment_state}" + %span{ class: shipment_state_classes } + = t(@order.shipment_state, scope: :shipment_states, default: [:missing, "none"]) + %dt + = t(:payment) + \: + %dd#payment_status + - payment_state_classes = "state #{@order.payment_state}" + %span{ class: payment_state_classes } + = t(@order.payment_state, scope: :payment_states, default: [:missing, "none"]) + %dt + = t(:date_completed) + \: + %dd#date_complete + = pretty_time(@order.completed_at) + + %nav.menu + %ul + - order_details_classes = "active" if current == "Order Details" + %li{ class: order_details_classes } + = link_to_with_icon 'icon-edit', t(:order_details), edit_admin_order_url(@order) + + - customer_details_classes = "active" if current == "Customer Details" + %li{ class: customer_details_classes } + = link_to_with_icon 'icon-user', t(:customer_details), admin_order_customer_url(@order) + + - adjustments_classes = "active" if current == "Adjustments" + %li{ class: adjustments_classes } + = link_to_with_icon 'icon-cogs', t(:adjustments), admin_order_adjustments_url(@order) + + - payments_classes = "active" if current == "Payments" + %li{ class: payments_classes } + = link_to_with_icon 'icon-credit-card', t(:payments), admin_order_payments_url(@order) + + - shipments_classes = "active" if current == "Shipments" + %li{ class: shipments_classes } + = link_to_with_icon 'icon-road', t(:shipments), admin_order_shipments_url(@order) + + - if @order.completed? + - authorizations_classes = "active" if current == "Return Authorizations" + %li{ class: authorizations_classes } + = link_to_with_icon 'icon-share-alt', t(:return_authorizations), admin_order_return_authorizations_url(@order) diff --git a/spec/controllers/spree/admin/line_items_controller_spec.rb b/spec/controllers/spree/admin/line_items_controller_spec.rb index 5b7575e7e5..874600c321 100644 --- a/spec/controllers/spree/admin/line_items_controller_spec.rb +++ b/spec/controllers/spree/admin/line_items_controller_spec.rb @@ -90,7 +90,7 @@ describe Spree::Admin::LineItemsController, type: :controller do it 'returns an HTML response with the order form' do spree_put :update, params - expect(response.body).to match(/admin_order_form_fields/) + expect(response.body).to match(/edit_order/) end end end diff --git a/spec/features/admin/variant_overrides_spec.rb b/spec/features/admin/variant_overrides_spec.rb index 853104711c..60130ddc6d 100644 --- a/spec/features/admin/variant_overrides_spec.rb +++ b/spec/features/admin/variant_overrides_spec.rb @@ -16,10 +16,10 @@ feature %q{ let!(:producer_related) { create(:supplier_enterprise) } let!(:producer_unrelated) { create(:supplier_enterprise) } let!(:er1) { create(:enterprise_relationship, parent: producer, child: hub, - permissions_list: [:create_variant_overrides]) + permissions_list: [:create_variant_overrides]) } let!(:er2) { create(:enterprise_relationship, parent: producer_related, child: hub, - permissions_list: [:create_variant_overrides]) + permissions_list: [:create_variant_overrides]) } context "as an enterprise user" do @@ -28,7 +28,7 @@ feature %q{ describe "selecting a hub" do let!(:er1) { create(:enterprise_relationship, parent: hub2, child: producer_managed, - permissions_list: [:add_to_order_cycle]) + permissions_list: [:add_to_order_cycle]) } # This er should not confer ability to create VOs for hub2 it "displays a list of hub choices (ie. only those managed by the user)" do @@ -338,7 +338,7 @@ feature %q{ it "shows the overridden price" do targetted_select2_search product.name, from: '#add_variant_id', dropdown_css: '.select2-drop' click_link 'Add' - expect(page).to have_selector("table.index tbody[data-hook='admin_order_form_line_items'] tr") # Wait for JS + expect(page).to have_selector("table.index tbody tr") # Wait for JS expect(page).to have_content(product.variants.first.variant_overrides.first.price) end end