From b55036e16556bbc643fca4bcddf662f1982819a9 Mon Sep 17 00:00:00 2001 From: Rob Harrington Date: Wed, 12 Apr 2017 15:50:01 +1000 Subject: [PATCH] Adding alert to shopfront to alert user to presence of orders open for editing --- app/helpers/spree/orders_helper.rb | 13 +++++++++++++ app/views/enterprises/shop.html.haml | 5 +++++ app/views/spree/orders/_bought.html.haml | 3 +-- config/locales/en.yml | 4 ++++ 4 files changed, 23 insertions(+), 2 deletions(-) diff --git a/app/helpers/spree/orders_helper.rb b/app/helpers/spree/orders_helper.rb index a3183d8273..eb10adecef 100644 --- a/app/helpers/spree/orders_helper.rb +++ b/app/helpers/spree/orders_helper.rb @@ -24,5 +24,18 @@ module Spree distributor_id: current_distributor.id, order_cycle_id: current_order_cycle.id) end + + def changeable_orders_link_path + changeable_orders.one? ? spree.order_path(changeable_orders.first) : spree.account_path + end + + def shop_changeable_orders_alert_html + t(:shop_changeable_orders_alert_html, + count: changeable_orders.count, + path: changeable_orders_link_path, + order: changeable_orders.first.number, + shop: current_distributor.name, + oc_close: l(current_order_cycle.orders_close_at, format: :long)) + end end end diff --git a/app/views/enterprises/shop.html.haml b/app/views/enterprises/shop.html.haml index 569009db09..23c31e69aa 100644 --- a/app/views/enterprises/shop.html.haml +++ b/app/views/enterprises/shop.html.haml @@ -8,6 +8,11 @@ = inject_shop_enterprises %shop.darkswarm + - if changeable_orders.any? + .alert-box.info{ "ofn-inline-alert" => true, ng: { show: "visible" } } + = shop_changeable_orders_alert_html + %a.close{ ng: { click: "close()" } } × + - content_for :order_cycle_form do %div{"ng-controller" => "OrderCycleChangeCtrl", "ng-cloak" => true} diff --git a/app/views/spree/orders/_bought.html.haml b/app/views/spree/orders/_bought.html.haml index 6c31acd25c..2de33307e9 100644 --- a/app/views/spree/orders/_bought.html.haml +++ b/app/views/spree/orders/_bought.html.haml @@ -5,8 +5,7 @@ %i{ ng: { class: "{ 'ofn-i_007-caret-right': !showBought, 'ofn-i_005-caret-down': showBought}"} } = t(:orders_bought_items_notice, count: @order.finalised_line_items.count) %td.text-right{ colspan: 3 } - - edit_path = changeable_orders.count > 1 ? spree.user_path : spree.order_path(changeable_orders.first) - %a.edit-finalised.button.radius.expand.small{ href: edit_path, ng: { class: "{secondary: !showBought, primary: showBought}" } } + %a.edit-finalised.button.radius.expand.small{ href: changeable_orders_link_path, ng: { class: "{secondary: !showBought, primary: showBought}" } } = t(:orders_bought_edit_button) %i.ofn-i_007-caret-right diff --git a/config/locales/en.yml b/config/locales/en.yml index 712ab9706f..48b4916fd4 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -892,6 +892,10 @@ See the %{link} to find out more about %{sitename}'s features and to start using hubs_distance: Closest to hubs_distance_filter: "Show me shops near %{location}" + shop_changeable_orders_alert_html: + one: Your order with %{shop} / %{order} is open for review. You can make changes until %{oc_close}. + other: You have %{count} orders with %{shop} currently open for review. + products_clear_all: Clear all products_showing: "Showing:" products_with: with