From a04c4de06839b63615b8cf2dee770bf55aa821f5 Mon Sep 17 00:00:00 2001 From: Pinga <121483313+getpinga@users.noreply.github.com> Date: Wed, 27 Dec 2023 17:27:22 +0200 Subject: [PATCH] Improvements to the transfers page --- cp/resources/views/partials/js-transfers.twig | 52 ++++++++++++++++--- 1 file changed, 45 insertions(+), 7 deletions(-) diff --git a/cp/resources/views/partials/js-transfers.twig b/cp/resources/views/partials/js-transfers.twig index 4b3ee5a..39530e2 100644 --- a/cp/resources/views/partials/js-transfers.twig +++ b/cp/resources/views/partials/js-transfers.twig @@ -21,14 +21,14 @@ var clidValue = document.getElementById('clid').value; if (hasPendingStatus && clidValue === '0') { - actionButtons += ` `; - actionButtons += ` `; - actionButtons += ``; + actionButtons += ` `; + actionButtons += ` `; + actionButtons += ``; } else if (clidValue === rowData.reid) { - actionButtons += ` `; + actionButtons += ` `; } else if (clidValue === rowData.acid) { - actionButtons += ` `; - actionButtons += ``; + actionButtons += ` `; + actionButtons += ``; } else { actionButtons += ` Completed`; } @@ -82,7 +82,45 @@ {title:"Initiated Date", field:"redate", width:250, minWidth:150, headerSort:true, responsive:2}, {title:"Expiry Date", field:"acdate", width:250, minWidth:150, headerSort:true, responsive:2}, {title:"Status", field:"trstatus", width:200, minWidth:150, headerSort:false, download:false, formatter: statusFormatter, responsive:0}, - {title: "Actions", formatter: actionsFormatter, headerSort: false, download:false, hozAlign: "center", responsive:0, cellClick:function(e, cell){ e.stopPropagation(); }}, + {title: "Actions", formatter: actionsFormatter, headerSort: false, download:false, hozAlign: "center", responsive:0, cellClick: function(e, cell){ + if (e.target.closest('.approve-btn')) { + e.preventDefault(); // Prevent the default link behavior + Swal.fire({ + title: "Are you sure you want to approve this transfer?", + showCancelButton: true, + confirmButtonText: "Confirm" + }).then((result) => { + if (result.isConfirmed) { + let approveUrl = e.target.closest('.approve-btn').getAttribute('data-approve-url'); + window.location.href = approveUrl; + } + }); + } else if (e.target.closest('.cancel-btn')) { + e.preventDefault(); // Prevent the default link behavior + Swal.fire({ + title: "Are you sure you want to cancel this transfer?", + showCancelButton: true, + confirmButtonText: "Confirm" + }).then((result) => { + if (result.isConfirmed) { + let cancelUrl = e.target.closest('.cancel-btn').getAttribute('data-cancel-url'); + window.location.href = cancelUrl; + } + }); + } else if (e.target.closest('.reject-btn')) { + e.preventDefault(); // Prevent the default link behavior + Swal.fire({ + title: "Are you sure you want to reject this transfer?", + showCancelButton: true, + confirmButtonText: "Confirm" + }).then((result) => { + if (result.isConfirmed) { + let rejectUrl = e.target.closest('.reject-btn').getAttribute('data-reject-url'); + window.location.href = rejectUrl; + } + }); + } + }}, ], placeholder:function(){ return this.getHeaderFilters().length ? "No Matching Data" : "No Data"; //set placeholder based on if there are currently any header filters