Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.

Commit 9b248bf

Browse files
committed
fix: quick pay button
1 parent bd5a183 commit 9b248bf

File tree

2 files changed

+108
-0
lines changed

2 files changed

+108
-0
lines changed

css/reskin-2/paymentHistory.css

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,39 @@ body {
281281

282282
/* **************** View-All, View Pending **************** */
283283

284+
.above-tabs {
285+
width: 100%;
286+
}
287+
.above-tabs .pay-me-btn {
288+
padding-bottom: 24px;
289+
}
290+
.above-tabs .pay-me-btn input[type="button"] {
291+
text-transform: uppercase;
292+
padding: 8px 24px;
293+
border: 0;
294+
border-radius: 24px;
295+
cursor: pointer;
296+
297+
font-family: Roboto;
298+
font-weight: 700;
299+
font-size: 14px;
300+
line-height: 24px;
301+
letter-spacing: 0.008em;
302+
303+
color: var(--tc-white);
304+
background-color: var(--green);
305+
}
306+
.above-tabs .pay-me-btn input[type="button"]:disabled {
307+
color: var(--grey-1);
308+
background-color: var(--black-5);
309+
cursor: default;
310+
}
311+
@media (max-width: /* --sm-max */ 959px) {
312+
.above-tabs .pay-me-btn {
313+
padding-bottom: 16px;
314+
}
315+
}
316+
284317
#payments > br { display: none; }
285318

286319
.form-container {

js/reskin/newTCScript.js

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,19 @@ function updatePayMe() {
378378
}
379379
}
380380

381+
/**
382+
* Updates the text of Quick Pay Me button with total amount of owed payments.
383+
*/
384+
function updateQuickPayMe() {
385+
var total = totalOwedPayments;
386+
$('#quickPayMe').val('Pay Me: $' + total.toFixed(2));
387+
if (total < MINIMUM_PAYMENT_ACCRUAL_AMOUNT) {
388+
$('#quickPayMe').attr('disabled', 'disabled');
389+
} else {
390+
$('#quickPayMe').removeAttr('disabled');
391+
}
392+
}
393+
381394
/**
382395
* Calculates the total amount of payments selected by user.
383396
*
@@ -687,6 +700,66 @@ $(document).ready(function() {
687700
}
688701
});
689702

703+
$('#quickPayMe').click(function() {
704+
var total = totalOwedPayments;
705+
var confirmationMessage = PAY_ME_CONFIRMATION_TEMPLATE.replace('{0}', '$' + total.toFixed(2));
706+
707+
var isNativeDialog = $('#payment-confirm-modal-id').length === 0;
708+
709+
if (isNativeDialog) {
710+
if (confirm(confirmationMessage)) {
711+
var myForm = document.f;
712+
myForm.method = 'POST';
713+
myForm.module.value = 'PayMe';
714+
myForm.submit();
715+
}
716+
} else {
717+
var resultPromise = new Promise(function (resolve) {
718+
$('#payment-confirm-modal-id .modal-body').text(confirmationMessage);
719+
document.body.style.overflow = 'hidden';
720+
721+
function onCancel () {
722+
document.body.style.overflow = '';
723+
$('#payment-confirm-modal-id').removeClass('show');
724+
$('#payment-confirm-modal-id .close-btn').off('click');
725+
$('#payment-confirm-modal-id .button-secondary').off('click');
726+
$('#payment-confirm-modal-id .button-primary').off('click');
727+
resolve(false);
728+
}
729+
function onOk () {
730+
document.body.style.overflow = '';
731+
$('#payment-confirm-modal-id').removeClass('show');
732+
$('#payment-confirm-modal-id .close-btn').off('click');
733+
$('#payment-confirm-modal-id .button-secondary').off('click');
734+
$('#payment-confirm-modal-id .button-primary').off('click');
735+
resolve(true);
736+
}
737+
738+
$('#payment-confirm-modal-id').addClass('show');
739+
$('#payment-confirm-modal-id .close-btn').one('click', onCancel);
740+
$('#payment-confirm-modal-id .button-secondary').one('click', onCancel);
741+
$('#payment-confirm-modal-id .button-primary').one('click', onOk);
742+
});
743+
744+
resultPromise.then(function (ok) {
745+
if (ok) {
746+
var myForm = document.f;
747+
myForm.method = 'POST';
748+
myForm.module.value = 'PayMe';
749+
for (var i = 0; i < owedPayments.length; i++) {
750+
var paymentId = owedPayments[i]
751+
var input = document.createElement('input');
752+
input.type = 'hidden';
753+
input.value = paymentId;
754+
input.name = 'paymentId';
755+
myForm.appendChild(input);
756+
}
757+
myForm.submit();
758+
}
759+
})
760+
}
761+
});
762+
690763
$('.getable').click(function () {
691764
var myForm = document.f;
692765
myForm.method = 'GET';
@@ -697,6 +770,8 @@ $(document).ready(function() {
697770

698771
updatePayMe();
699772

773+
updateQuickPayMe();
774+
700775
$('.buttonArea .register').click(function(){
701776
// the 'isAnonymous' is defined in the projectDetails.jsp file
702777
if(!isAnonymous) {

0 commit comments

Comments
 (0)