Update cart page links to be disabled when changes are required and form is unsaved

See: https://stackoverflow.com/questions/23425254/enable-disable-anchor-tags-using-angularjs
This commit is contained in:
Matt-Yorkley
2020-05-15 13:36:10 +02:00
parent c2efa901c2
commit 63e4430ea4
2 changed files with 14 additions and 2 deletions

View File

@@ -0,0 +1,12 @@
# Allows disabling of link buttons via disabled attribute.
# This is normally ignored, ie the link appears disabled but is still clickable.
Darkswarm.directive "disableDynamically", ->
restrict: 'A'
link: (scope, element, attrs) ->
element.on 'click', (e) ->
if attrs.disabled
e.preventDefault()
return

View File

@@ -1,5 +1,5 @@
.row.links{'data-hook' => "cart_buttons"}
%a.button.large.secondary{href: current_shop_products_path}
%a.button.large.secondary{href: current_shop_products_path, "ng-disabled" => "#{@insufficient_stock_lines.any?}", "disable-dynamically" => true}
= t :orders_edit_continue
%a#checkout-link.button.large.primary.right{href: main_app.checkout_path}
%a#checkout-link.button.large.primary.right{href: main_app.checkout_path, "ng-disabled" => "#{@insufficient_stock_lines.any?}", "disable-dynamically" => true}
= t :orders_edit_checkout