diff --git a/app/views/admin/shared/_tooltip_button.html.haml b/app/views/admin/shared/_tooltip_button.html.haml new file mode 100644 index 0000000000..06b37688cd --- /dev/null +++ b/app/views/admin/shared/_tooltip_button.html.haml @@ -0,0 +1,7 @@ +%div{ "data-controller": "tooltip" } + %button{class: button_class, "data-reflex": button_reflex, "data-id": reflex_data_id, "data-tooltip-target": "element" } + .tooltip-container + .tooltip{"data-tooltip-target": "tooltip"} + = sanitize tooltip_text + .arrow{"data-tooltip-target": "arrow"} + diff --git a/app/views/spree/admin/orders/_table_row.html.haml b/app/views/spree/admin/orders/_table_row.html.haml index aa72f0823a..9c0ffb5e17 100644 --- a/app/views/spree/admin/orders/_table_row.html.haml +++ b/app/views/spree/admin/orders/_table_row.html.haml @@ -14,6 +14,10 @@ %div{ "data-controller": "tooltip", "data-tooltip-tip-value": order.special_instructions.to_s } %span.icon-warning-sign{ "data-tooltip-target": "element" } = t('spree.admin.orders.index.note') + .tooltip-container + .tooltip{"data-tooltip-target": "tooltip"} + = sanitize order.special_instructions.to_s + .arrow{"data-tooltip-target": "arrow"} %td.align-left %span.state{ class: order.state.to_s } = t('js.admin.orders.order_state.' + order.state.to_s) @@ -41,13 +45,8 @@ %div.row-loading-icons - if local_assigns[:success] %i.success.icon-ok-sign{"data-controller": "ephemeral"} - %a.icon_link.with-tip.icon-edit.no-text{href: edit_admin_order_path(order), "data-controller": "tooltip", "data-tooltip-tip-value": t('spree.admin.orders.index.edit'), "data-tooltip-target": "element"} + = render partial: 'admin/shared/tooltip', locals: {link_class: "icon_link with-tip icon-edit no-text" ,link: edit_admin_order_path(order), link_text: "", tooltip_text: t('spree.admin.orders.index.edit')} - if order.ready_to_ship? - %div{ "data-controller": "tooltip", "data-tooltip-tip-value": t('spree.admin.orders.index.ship') } - %button.icon-road.icon_link.with-tip.no-text{"data-reflex": "click->Admin::OrdersReflex#ship", "data-id": order.id.to_s, - "data-tooltip-target": "element" } - + = render partial: 'admin/shared/tooltip_button', locals: {button_class: "icon-road icon_link with-tip no-text", button_reflex: "click->Admin::OrdersReflex#ship", reflex_data_id: order.id.to_s, tooltip_text: t('spree.admin.orders.index.ship')} - if order.payment_required? && order.pending_payments.reject(&:requires_authorization?).any? - %div{ "data-controller": "tooltip", "data-tooltip-tip-value": t('spree.admin.orders.index.capture') } - %button.icon-capture.icon_link.no-text{"data-reflex": "click->Admin::OrdersReflex#capture", "data-id": order.id.to_s, - "data-tooltip-target": "element" } + = render partial: 'admin/shared/tooltip_button', locals: {button_class: "icon-capture icon_link no-text", button_reflex: "click->Admin::OrdersReflex#capture", reflex_data_id: order.id.to_s, tooltip_text: t('spree.admin.orders.index.capture')} diff --git a/spec/system/admin/orders_spec.rb b/spec/system/admin/orders_spec.rb index 342cdda0a0..8c8b388d63 100644 --- a/spec/system/admin/orders_spec.rb +++ b/spec/system/admin/orders_spec.rb @@ -443,8 +443,9 @@ describe ' it "displays a note with order instructions" do within "tr#order_#{order3.id}" do - expect(page).to have_content I18n.t('spree.admin.orders.index.note') - expect(page).to have_css "[data-tooltip-tip-value='#{order3.special_instructions}']" + expect(page).to have_content "Note" + find(".icon-warning-sign").hover + expect(page).to have_content /#{order3.special_instructions}/i end end end @@ -762,6 +763,11 @@ describe ' # checks shipment state expect(page).to have_content "READY" + + # move away from the Ship button so we can trigger the mouseenter event by moving back. + # We are already on the "Ship" button when it gets rendered because of + # the previous click + find(".icon-edit").hover # mouse-hovers and finds Ship tooltip find(".icon-road").hover expect(page).to have_content "Ship"