mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Add a directive attribute 'selected' that update AdminStripeElements when true
Filled with `PaymentCtrl.isSelected(payment_method_id)` Therefore, each time a stripe payment is selected, the one that is actually selected is linked to `AdminStripeElements.card` and `AdminStripeElements.stripe`
This commit is contained in:
@@ -8,3 +8,6 @@ angular.module("admin.payments").controller "PaymentCtrl", ($scope, Payment, Sta
|
||||
$scope.submitted = true
|
||||
StatusMessage.display 'progress', t("spree.admin.payments.source_forms.stripe.submitting_payment")
|
||||
Payment.purchase()
|
||||
|
||||
$scope.isSelected = (payment_method_id) ->
|
||||
return parseInt($scope.form_data.payment_method) == payment_method_id
|
||||
|
||||
@@ -4,7 +4,9 @@ angular.module('admin.payments').directive "stripeElements", ($injector, AdminSt
|
||||
<div id='card-element' class='card-element'></div>\
|
||||
<div class='error card-errors'></div>\
|
||||
</label>"
|
||||
|
||||
scope:
|
||||
selected: "="
|
||||
|
||||
link: (scope, elem, attr)->
|
||||
if $injector.has('stripeObject')
|
||||
stripe = $injector.get('stripeObject')
|
||||
@@ -32,5 +34,7 @@ angular.module('admin.payments').directive "stripeElements", ($injector, AdminSt
|
||||
|
||||
return
|
||||
|
||||
AdminStripeElements.stripe = stripe
|
||||
AdminStripeElements.card = card
|
||||
scope.$watch "selected", (value) ->
|
||||
if (value)
|
||||
AdminStripeElements.stripe = stripe
|
||||
AdminStripeElements.card = card
|
||||
|
||||
@@ -16,4 +16,4 @@
|
||||
.three.columns
|
||||
= label_tag :card_details, t(:card_details)
|
||||
.nine.columns
|
||||
%stripe-elements
|
||||
%stripe-elements{selected: "isSelected(#{payment_method.id})"}
|
||||
|
||||
@@ -15,4 +15,4 @@
|
||||
.three.columns
|
||||
= label_tag :card_details, t(:card_details)
|
||||
.nine.columns
|
||||
%stripe-elements
|
||||
%stripe-elements{selected: "isSelected(#{payment_method.id})"}
|
||||
|
||||
Reference in New Issue
Block a user