diff --git a/app/assets/javascripts/darkswarm/directives/confirm_link_click.js.coffee b/app/assets/javascripts/darkswarm/directives/confirm_link_click.js.coffee new file mode 100644 index 0000000000..b5da68d4dc --- /dev/null +++ b/app/assets/javascripts/darkswarm/directives/confirm_link_click.js.coffee @@ -0,0 +1,9 @@ +Darkswarm.directive "confirmLinkClick", ($window) -> + restrict: 'A' + scope: + confirmMsg: '@confirmLinkClick' + link: (scope, elem, attr) -> + elem.bind 'click', (event) -> + unless confirm(scope.confirmMsg) + event.preventDefault() + event.stopPropagation() diff --git a/app/views/spree/orders/form/_update_buttons.html.haml b/app/views/spree/orders/form/_update_buttons.html.haml index 9d62b720d8..7a89ab25b4 100644 --- a/app/views/spree/orders/form/_update_buttons.html.haml +++ b/app/views/spree/orders/form/_update_buttons.html.haml @@ -14,7 +14,7 @@ - if order.changes_allowed? .columns.show-for-medium-up.medium-3   .columns.small-12.medium-3 - = link_to spree.cancel_order_path(@order), method: :put, :class => "button secondary expand" do + = link_to spree.cancel_order_path(@order), method: :put, :class => "button secondary expand", "confirm-link-click" => t('orders_confirm_cancel') do %i.ofn-i_009-close = t(:cancel_order) .columns.small-12.medium-3 diff --git a/app/views/spree/users/_open_orders.html.haml b/app/views/spree/users/_open_orders.html.haml index c8efbfb4f4..5f78738e34 100644 --- a/app/views/spree/users/_open_orders.html.haml +++ b/app/views/spree/users/_open_orders.html.haml @@ -20,4 +20,4 @@ %td.order6.text-right.show-for-large-up.brick %a{"ng-href" => "{{::order.path}}" }= t('.edit') %td.order7.text-right - = link_to t('.cancel'), "", method: :put, "ng-href" => "{{::order.cancel_path}}" + = link_to t('.cancel'), "", method: :put, "ng-href" => "{{::order.cancel_path}}", "confirm-link-click" => t('orders_confirm_cancel') diff --git a/config/locales/en.yml b/config/locales/en.yml index 7ffb769534..ab882e9527 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1066,6 +1066,7 @@ See the %{link} to find out more about %{sitename}'s features and to start using other: "%{count} additional items already confirmed for this order cycle" orders_bought_edit_button: Edit confirmed items orders_bought_already_confirmed: "* already confirmed" + orders_confirm_cancel: Are you sure you want to cancel this order? products_cart_distributor_choice: "Distributor for your order:" products_cart_distributor_change: "Your distributor for this order will be changed to %{name} if you add this product to your cart."