From 32e3fc0175440b02ea2e475c77d69d59ba4cab46 Mon Sep 17 00:00:00 2001 From: Cillian O'Ruanaidh Date: Fri, 22 Aug 2025 14:20:14 +0100 Subject: [PATCH] Replace disable-dynamically angular directive --- .../directives/disable_dynamically.js.coffee | 14 -------------- app/views/spree/orders/form/_cart_links.html.haml | 4 ++-- 2 files changed, 2 insertions(+), 16 deletions(-) delete mode 100644 app/assets/javascripts/darkswarm/directives/disable_dynamically.js.coffee diff --git a/app/assets/javascripts/darkswarm/directives/disable_dynamically.js.coffee b/app/assets/javascripts/darkswarm/directives/disable_dynamically.js.coffee deleted file mode 100644 index 33df890ead..0000000000 --- a/app/assets/javascripts/darkswarm/directives/disable_dynamically.js.coffee +++ /dev/null @@ -1,14 +0,0 @@ -# Allows disabling of link buttons via disabled attribute. -# This is normally ignored, ie the link appears disabled but is still clickable. - -angular.module('Darkswarm').directive "disableDynamically", -> - restrict: 'A' - - link: (scope, element, attrs) -> - element.on 'click', (e) -> - if attrs.disabled - e.preventDefault() - return - - scope.$on "$destroy", -> - element.off("click") diff --git a/app/views/spree/orders/form/_cart_links.html.haml b/app/views/spree/orders/form/_cart_links.html.haml index 5eaac48a55..a3114cb670 100644 --- a/app/views/spree/orders/form/_cart_links.html.haml +++ b/app/views/spree/orders/form/_cart_links.html.haml @@ -1,5 +1,5 @@ .row.links - %a.continue-shopping.button.secondary{href: current_shop_products_path, "ng-disabled" => "#{@insufficient_stock_lines.any?}", "disable-dynamically" => true} + %a.continue-shopping.button.secondary{ @insufficient_stock_lines.any? ? { disabled: "disabled" } : { href: current_shop_products_path } } = t :orders_edit_continue - %a#checkout-link.button.primary.right{href: main_app.checkout_path, "ng-disabled" => "#{@insufficient_stock_lines.any?}", "disable-dynamically" => true} + %a#checkout-link.button.primary.right{ @insufficient_stock_lines.any? ? { disabled: "disabled" } : { href: main_app.checkout_path } } = t :orders_edit_checkout