diff --git a/app/assets/javascripts/darkswarm/controllers/credit_cards_controller.js.coffee b/app/assets/javascripts/darkswarm/controllers/credit_cards_controller.js.coffee index 1b1ee5fd97..8e14d96627 100644 --- a/app/assets/javascripts/darkswarm/controllers/credit_cards_controller.js.coffee +++ b/app/assets/javascripts/darkswarm/controllers/credit_cards_controller.js.coffee @@ -20,3 +20,7 @@ angular.module('Darkswarm').controller "CreditCardsCtrl", ($scope, $http, Credit ).finally -> window.location.reload() + + $scope.hasOneDefaultSavedCards = () -> + $scope.savedCreditCards.length > 0 && $scope.savedCreditCards.some((card) -> card.is_default) + diff --git a/app/views/spree/users/_authorised_shops.html.haml b/app/views/spree/users/_authorised_shops.html.haml index 1d033da72f..05aefc9119 100644 --- a/app/views/spree/users/_authorised_shops.html.haml +++ b/app/views/spree/users/_authorised_shops.html.haml @@ -12,5 +12,6 @@ name: 'allow_charges', ng: { model: 'customer.allow_charges', change: 'customer.update()', + disabled: "!hasOneDefaultSavedCards()", "true-value" => "true", "false-value" => "false" } }