Skip to content

Commit

Permalink
#413 Fixed "arePaymentMethodsDeactivated" function.
Browse files Browse the repository at this point in the history
Also:
- disabled payment method toggle input while removing.
- after removal, if there are no payment methods, #noRealPaymentMethods panel
is shown.
  • Loading branch information
criske committed Mar 27, 2021
1 parent 5c46c5b commit c80d213
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/main/resources/public/js/wallets.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,17 +172,27 @@ function renderPaymentMethodRow(method) {
function () {
var thisBtn = $(this);
thisBtn.prop('disabled', true);
//prevent activating toggle input while payment method is removed;
thisBtn.siblings().children().first().prop('disabled', true);
confirmDialog
.create("Are you sure you want to remove this payment method?", "Warning", "Yes")
.then(() => removePaymentMethod(owner, name, method))
.then(() => thisBtn.closest("tr").remove())
.then(() => {
thisBtn.closest("tr").remove();
if($('#realPaymentMethodsTable > tbody > tr').length === 0){
$("#realPaymentMethods").hide();
$("#noRealPaymentMethods").show();
}
})
.catch((jqXHR) => {
if (jqXHR) {
confirmDialog
.create("Something went wrong while removing the payment method. Please try again.", "Error", "Yes")
.then(() => { });
}
thisBtn.prop('disabled', false);
//re-enable toggle input
thisBtn.siblings().children().first().prop('disabled', false);
});
}
);
Expand All @@ -195,8 +205,9 @@ function renderPaymentMethodRow(method) {
*/
function arePaymentMethodsDeactivated(toggleButtons) {
var allDeactivated = true;
toggleButtons.each(function () {
allDeactivated = allDeactivated & !$(this).prop('checked');
toggleButtons.each(function (idx, button) {
var checked = $(button).prop('checked');
allDeactivated = allDeactivated && !checked;
});
return allDeactivated;
}
Expand Down

0 comments on commit c80d213

Please sign in to comment.