From c233ea38cfc9ad769fe8184baf97a4174ec6043a Mon Sep 17 00:00:00 2001 From: Hugo Daniel Date: Tue, 30 Oct 2018 11:27:39 +0100 Subject: [PATCH 1/6] Import Spree views for orders#edit in our codebase and integrate deface modifications --- .../add_distribution_fields.html.haml.deface | 3 - .../_form/hide_form_until_distribution.deface | 2 - .../relabel_update_button.html.haml.deface | 3 - .../replace_variant_label.html.haml.deface | 3 - .../replace_variant_price.html.haml.deface | 3 - .../edit/add_action_dropdown.html.haml.deface | 6 -- .../edit/suppress_errors.html.haml.deface | 6 -- .../spree/admin/orders/_add_product.html.haml | 17 +++++ app/views/spree/admin/orders/_form.html.haml | 68 +++++++++++++++++++ .../spree/admin/orders/_line_item.html.haml | 12 ++++ app/views/spree/admin/orders/edit.html.haml | 8 ++- .../spree/admin/shared/_order_tabs.html.haml | 65 ++++++++++++++++++ 12 files changed, 169 insertions(+), 27 deletions(-) delete mode 100644 app/overrides/spree/admin/orders/_form/add_distribution_fields.html.haml.deface delete mode 100644 app/overrides/spree/admin/orders/_form/hide_form_until_distribution.deface delete mode 100644 app/overrides/spree/admin/orders/_form/relabel_update_button.html.haml.deface delete mode 100644 app/overrides/spree/admin/orders/_line_item/replace_variant_label.html.haml.deface delete mode 100644 app/overrides/spree/admin/orders/_line_item/replace_variant_price.html.haml.deface delete mode 100644 app/overrides/spree/admin/orders/edit/add_action_dropdown.html.haml.deface delete mode 100644 app/overrides/spree/admin/orders/edit/suppress_errors.html.haml.deface create mode 100644 app/views/spree/admin/orders/_add_product.html.haml create mode 100644 app/views/spree/admin/orders/_form.html.haml create mode 100644 app/views/spree/admin/orders/_line_item.html.haml create mode 100644 app/views/spree/admin/shared/_order_tabs.html.haml 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..ab807961f7 --- /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{"data-hook" => ""} + %fieldset + %legend{align: "center"} + = t(:add_product) + .field.eight.columns.alpha{"data-hook" => "add_product_name"} + = label_tag :add_product_name, t(:name_or_sku) + = hidden_field_tag :add_variant_id, "", class: "variant_autocomplete fullwidth" + .field.two.columns{"data-hook" => "add_quantity"} + = label_tag :add_quantity, t(:qty) + = number_field_tag :add_quantity, 1, min: 0 + .actions.two.columns.omega{"data-hook" => "add_button"} + = 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..07a41cb7e4 --- /dev/null +++ b/app/views/spree/admin/orders/_form.html.haml @@ -0,0 +1,68 @@ +%div{"data-hook" => "admin_order_form_fields"} + - 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{"data-hook" => "admin_order_form_line_items_headers"} + %th + = t(:item_description) + %th.price + = t(:price) + %th.qty + = t(:qty) + %th.total + %span + = t(:total) + %th.orders-actions.actions{"data-hook" => "admin_order_form_line_items_header_actions"} + %tbody{"data-hook" => "admin_order_form_line_items"} + = f.fields_for :line_items do |li_form| + = render partial: 'spree/admin/orders/line_item', locals: { f: li_form } + %tbody#subtotal.no-border-top{"data-hook" => "admin_order_form_subtotal"} + %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{"data-hook" => "admin_order_form_adjustments"} + - @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{"data-hook" => "admin_order_form_total"} + %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{"data-hook" => "admin_order_form_buttons", "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..4bcc30fae0 --- /dev/null +++ b/app/views/spree/admin/orders/_line_item.html.haml @@ -0,0 +1,12 @@ +%tr{"data-hook" => "admin_order_form_line_item_row", 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{"data-hook" => "admin_order_form_line_item_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..82d5507ec1 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') @@ -11,7 +13,8 @@ = render 'spree/admin/shared/order_tabs', current: 'Order Details' %div{"data-hook" => "admin_order_edit_header"} - = render 'spree/shared/error_messages', target: @order + - 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' @@ -22,3 +25,6 @@ - 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..a2f346bf27 --- /dev/null +++ b/app/views/spree/admin/shared/_order_tabs.html.haml @@ -0,0 +1,65 @@ +- 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 + %span{:class => "state #{@order.state}"} + = 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 + %span.state + = @order.shipment_state + = t(@order.shipment_state, scope: :shipment_states, default: [:missing, none]) + %dt + = t(:payment) + \: + %dd#payment_status + %span.state + = @order.payment_state + = 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{"data-hook" => "admin_order_tabs"} + %li{ class: "#{'active' if true}" } + = link_to_with_icon 'icon-edit', t(:order_details), edit_admin_order_url(@order) + %li{"#{'class=active' if current == 'Customer Details'}"} + = link_to_with_icon 'icon-user', t(:customer_details), admin_order_customer_url(@order) + %li{"#{'class=active' if current == 'Adjustments Details'}"} + = link_to_with_icon 'icon-cogs', t(:adjustments), admin_order_adjustments_url(@order) + + %li{"#{'class=active' if current == 'Payments'}"} + = link_to_with_icon 'icon-credit-card', t(:payments), admin_order_payments_url(@order) + + %li{"#{'class=active' if current == 'Shipments'}"} + = link_to_with_icon 'icon-road', t(:shipments), admin_order_shipments_url(@order) + - if @order.completed? + %li{"#{'class=active' if current == 'Return Authorizations'}"} + = link_to_with_icon 'icon-share-alt', t(:return_authorizations), admin_order_return_authorizations_url(@order) From 652191a4c52e5d4b941a951e0b0478c3db4ec8c9 Mon Sep 17 00:00:00 2001 From: Hugo Daniel Date: Tue, 30 Oct 2018 12:11:35 +0100 Subject: [PATCH 2/6] Fixing missing variable none --- app/views/spree/admin/shared/_order_tabs.html.haml | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/app/views/spree/admin/shared/_order_tabs.html.haml b/app/views/spree/admin/shared/_order_tabs.html.haml index a2f346bf27..17ebf435bb 100644 --- a/app/views/spree/admin/shared/_order_tabs.html.haml +++ b/app/views/spree/admin/shared/_order_tabs.html.haml @@ -30,16 +30,14 @@ = t(:shipment) \: %dd#shipment_status - %span.state - = @order.shipment_state - = t(@order.shipment_state, scope: :shipment_states, default: [:missing, none]) + %span{class: "state #{@order.shipment_state}"} + = t(@order.shipment_state, scope: :shipment_states, default: [:missing, "none"]) %dt = t(:payment) \: %dd#payment_status - %span.state - = @order.payment_state - = t(@order.payment_state, scope: :payment_states, default: [:missing, none]) + %span{class: "state #{@order.payment_state}"} + = t(@order.payment_state, scope: :payment_states, default: [:missing, "none"]) %dt = t(:date_completed) \: From 422a68630f1f47ba7a680237b29b80c2b7b361e9 Mon Sep 17 00:00:00 2001 From: Hugo Daniel Date: Tue, 30 Oct 2018 14:03:51 +0100 Subject: [PATCH 3/6] Remove data-hook tags --- .../spree/admin/orders/_add_product.html.haml | 8 ++++---- app/views/spree/admin/orders/_form.html.haml | 16 ++++++++-------- .../spree/admin/orders/_line_item.html.haml | 4 ++-- app/views/spree/admin/orders/edit.html.haml | 6 +++--- .../spree/admin/shared/_order_tabs.html.haml | 2 +- 5 files changed, 18 insertions(+), 18 deletions(-) diff --git a/app/views/spree/admin/orders/_add_product.html.haml b/app/views/spree/admin/orders/_add_product.html.haml index ab807961f7..eecc678521 100644 --- a/app/views/spree/admin/orders/_add_product.html.haml +++ b/app/views/spree/admin/orders/_add_product.html.haml @@ -1,15 +1,15 @@ = render partial: "spree/admin/variants/autocomplete", formats: :js -#add-line-item{"data-hook" => ""} +#add-line-item %fieldset %legend{align: "center"} = t(:add_product) - .field.eight.columns.alpha{"data-hook" => "add_product_name"} + .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{"data-hook" => "add_quantity"} + .field.two.columns = label_tag :add_quantity, t(:qty) = number_field_tag :add_quantity, 1, min: 0 - .actions.two.columns.omega{"data-hook" => "add_button"} + .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', diff --git a/app/views/spree/admin/orders/_form.html.haml b/app/views/spree/admin/orders/_form.html.haml index 07a41cb7e4..8564ae04f5 100644 --- a/app/views/spree/admin/orders/_form.html.haml +++ b/app/views/spree/admin/orders/_form.html.haml @@ -1,4 +1,4 @@ -%div{"data-hook" => "admin_order_form_fields"} +%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| @@ -12,7 +12,7 @@ %col{style: "width: 14%;"}/ %col{style: "width: 8%;"}/ %thead#line-items - %tr{"data-hook" => "admin_order_form_line_items_headers"} + %tr %th = t(:item_description) %th.price @@ -22,11 +22,11 @@ %th.total %span = t(:total) - %th.orders-actions.actions{"data-hook" => "admin_order_form_line_items_header_actions"} - %tbody{"data-hook" => "admin_order_form_line_items"} + %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{"data-hook" => "admin_order_form_subtotal"} + %tbody#subtotal.no-border-top %tr#subtotal-row %td{colspan: "3"} %b @@ -36,7 +36,7 @@ %span = @order.display_item_total.to_html %td.actions - %tbody#order-charges.no-border-top{"data-hook" => "admin_order_form_adjustments"} + %tbody#order-charges.no-border-top - @order.adjustments.eligible.each do |adjustment| %tr %td{colspan: "3"} @@ -46,7 +46,7 @@ %td.total.align-center %span= adjustment.display_amount.to_html %td.actions - %tbody#order-total.grand-total.no-border-top{"data-hook" => "admin_order_form_total"} + %tbody#order-total.grand-total.no-border-top %tr %td{colspan: "3"} %b @@ -59,7 +59,7 @@ = render partial: 'spree/admin/orders/_form/distribution_fields' - .filter-actions.actions{"data-hook" => "admin_order_form_buttons", "ng-show" => "distributionChosen()"} + .filter-actions.actions{"ng-show" => "distributionChosen()"} = button t(:update_and_recalculate_fees), 'icon-refresh' %span.or = t(:or) diff --git a/app/views/spree/admin/orders/_line_item.html.haml b/app/views/spree/admin/orders/_line_item.html.haml index 4bcc30fae0..9afed0e2ec 100644 --- a/app/views/spree/admin/orders/_line_item.html.haml +++ b/app/views/spree/admin/orders/_line_item.html.haml @@ -1,4 +1,4 @@ -%tr{"data-hook" => "admin_order_form_line_item_row", id: "#{spree_dom_id(f.object)}", class: "#{cycle('odd', 'even')}"} +%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? @@ -8,5 +8,5 @@ = f.number_field :quantity, min: 0, class: "qty" %td.total.align-center = f.object.single_money - %td.actions{"data-hook" => "admin_order_form_line_item_actions"} + %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 82d5507ec1..015e9234e8 100644 --- a/app/views/spree/admin/orders/edit.html.haml +++ b/app/views/spree/admin/orders/edit.html.haml @@ -12,19 +12,19 @@ = render 'spree/admin/shared/order_tabs', current: 'Order Details' -%div{"data-hook" => "admin_order_edit_header"} +%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 index 17ebf435bb..af04fe676e 100644 --- a/app/views/spree/admin/shared/_order_tabs.html.haml +++ b/app/views/spree/admin/shared/_order_tabs.html.haml @@ -45,7 +45,7 @@ = pretty_time(@order.completed_at) %nav.menu - %ul{"data-hook" => "admin_order_tabs"} + %ul %li{ class: "#{'active' if true}" } = link_to_with_icon 'icon-edit', t(:order_details), edit_admin_order_url(@order) %li{"#{'class=active' if current == 'Customer Details'}"} From 60214b9a90bc0d0c03f81c8f4c9278e153223e39 Mon Sep 17 00:00:00 2001 From: Hugo Daniel Date: Wed, 31 Oct 2018 10:54:25 +0100 Subject: [PATCH 4/6] Fix failing specs --- app/views/spree/admin/orders/_form.html.haml | 2 +- spec/features/admin/variant_overrides_spec.rb | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/views/spree/admin/orders/_form.html.haml b/app/views/spree/admin/orders/_form.html.haml index 8564ae04f5..449a86ecf8 100644 --- a/app/views/spree/admin/orders/_form.html.haml +++ b/app/views/spree/admin/orders/_form.html.haml @@ -1,4 +1,4 @@ -%div +%div.admin_order_form_fields - 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| 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 From 65dd3eb5b9eb4ad7d7553c55fbe8520bbb01755f Mon Sep 17 00:00:00 2001 From: Hugo Daniel Date: Mon, 5 Nov 2018 18:35:07 +0100 Subject: [PATCH 5/6] Change line items controller HTML response spec to look for form order_edit class --- app/views/spree/admin/orders/_form.html.haml | 2 +- spec/controllers/spree/admin/line_items_controller_spec.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/spree/admin/orders/_form.html.haml b/app/views/spree/admin/orders/_form.html.haml index 449a86ecf8..8564ae04f5 100644 --- a/app/views/spree/admin/orders/_form.html.haml +++ b/app/views/spree/admin/orders/_form.html.haml @@ -1,4 +1,4 @@ -%div.admin_order_form_fields +%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| 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 From 69e186f482ebe0ccc13a2d3ba1c94cfd67b7c180 Mon Sep 17 00:00:00 2001 From: Hugo Daniel Date: Tue, 20 Nov 2018 10:13:18 +0100 Subject: [PATCH 6/6] Define dynamic classes in variables as a turnaround to HAML bug --- .../spree/admin/shared/_order_tabs.html.haml | 32 +++++++++++++------ 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/app/views/spree/admin/shared/_order_tabs.html.haml b/app/views/spree/admin/shared/_order_tabs.html.haml index af04fe676e..d250507193 100644 --- a/app/views/spree/admin/shared/_order_tabs.html.haml +++ b/app/views/spree/admin/shared/_order_tabs.html.haml @@ -17,8 +17,9 @@ %dt#order_status = t(:status) %dd - %span{:class => "state #{@order.state}"} - = t(@order.state, scope: :order_state) + - order_state_classes = "state #{@order.state}" + %span{ class: order_state_classes } + = t(@order.state, scope: :order_state) %dt = t(:total) \: @@ -30,13 +31,15 @@ = t(:shipment) \: %dd#shipment_status - %span{class: "state #{@order.shipment_state}"} + - 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 - %span{class: "state #{@order.payment_state}"} + - 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) @@ -46,18 +49,27 @@ %nav.menu %ul - %li{ class: "#{'active' if true}" } + - 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) - %li{"#{'class=active' if current == 'Customer Details'}"} + + - 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) - %li{"#{'class=active' if current == 'Adjustments Details'}"} + + - adjustments_classes = "active" if current == "Adjustments" + %li{ class: adjustments_classes } = link_to_with_icon 'icon-cogs', t(:adjustments), admin_order_adjustments_url(@order) - %li{"#{'class=active' if current == 'Payments'}"} + - payments_classes = "active" if current == "Payments" + %li{ class: payments_classes } = link_to_with_icon 'icon-credit-card', t(:payments), admin_order_payments_url(@order) - %li{"#{'class=active' if current == 'Shipments'}"} + - 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? - %li{"#{'class=active' if current == 'Return Authorizations'}"} + - 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)