Skip to content

Commit 7fb6ad5

Browse files
committed
Merge remote-tracking branch 'origin/MC-33494' into 2.4.1-develop-pr25
2 parents 72a6010 + 3e5d59d commit 7fb6ad5

File tree

2 files changed

+41
-7
lines changed
  • app/code/Magento

2 files changed

+41
-7
lines changed

app/code/Magento/Braintree/view/adminhtml/web/js/vault.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ define([
131131
this.createPublicHashSelector();
132132

133133
this.$selector.find('[name="payment[public_hash]"]').val(this.publicHash);
134-
this.$container.find('#' + this.getNonceSelectorName()).val(nonce);
134+
$('#' + this.getNonceSelectorName()).val(nonce);
135135
},
136136

137137
/**
@@ -140,7 +140,7 @@ define([
140140
createPublicHashSelector: function () {
141141
var $input;
142142

143-
if (this.$container.find('#' + this.getNonceSelectorName()).size() === 0) {
143+
if ($('#' + this.getNonceSelectorName()).length === 0) {
144144
$input = $('<input>').attr(
145145
{
146146
type: 'hidden',
@@ -149,7 +149,7 @@ define([
149149
}
150150
);
151151

152-
$input.appendTo(this.$container);
152+
$input.appendTo($('#edit_form'));
153153
$input.prop('disabled', false);
154154
}
155155
},

app/code/Magento/Vault/view/adminhtml/web/js/vault.js

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,26 @@ define([
2727
* @returns {exports.initObservable}
2828
*/
2929
initObservable: function () {
30-
var self = this;
30+
var self = this,
31+
paymentSelector = '[name="payment[method]"][value="' + this.getCode() + '"]:checked';
3132

3233
self.$selector = $('#' + self.selector);
3334
this._super()
3435
.observe(['active']);
3536

37+
if (self.$selector.find(paymentSelector).length !== 0) {
38+
this.active(true);
39+
}
40+
41+
$('#' + self.fieldset).find('[name="payment[token_switcher]"]')
42+
.on('click', this.rememberTokenSwitcher.bind(this));
43+
3644
// re-init payment method events
3745
self.$selector.off('changePaymentMethod.' + this.getCode())
3846
.on('changePaymentMethod.' + this.getCode(), this.changePaymentMethod.bind(this));
3947

4048
if (this.active()) {
41-
$('#' + this.fieldset + ' input:radio:first').trigger('click');
49+
this.chooseTokenSwitcher();
4250
}
4351

4452
return this;
@@ -56,6 +64,33 @@ define([
5664
return this;
5765
},
5866

67+
/**
68+
* Save last chosen token switcher
69+
* @param {Object} event
70+
* @returns {exports.rememberTokenSwitcher}
71+
*/
72+
rememberTokenSwitcher: function (event) {
73+
$('#' + this.selector).data('lastTokenSwitcherId', event.target.id);
74+
75+
return this;
76+
},
77+
78+
/**
79+
* Select token switcher
80+
* @returns {exports.chooseTokenSwitcher}
81+
*/
82+
chooseTokenSwitcher: function () {
83+
var lastTokenSwitcherId = $('#' + this.selector).data('lastTokenSwitcherId');
84+
85+
if (lastTokenSwitcherId) {
86+
$('#' + lastTokenSwitcherId).trigger('click');
87+
} else {
88+
$('#' + this.fieldset + ' input:radio:first').trigger('click');
89+
}
90+
91+
return this;
92+
},
93+
5994
/**
6095
* Triggered when payment changed
6196
* @param {Boolean} isActive
@@ -66,8 +101,7 @@ define([
66101

67102
return;
68103
}
69-
70-
$('#' + this.fieldset + ' input:radio:first').trigger('click');
104+
this.chooseTokenSwitcher();
71105
window.order.addExcludedPaymentMethod(this.getCode());
72106
},
73107

0 commit comments

Comments
 (0)