diff --git a/docker/ploughshares/templates/pending_approval.html b/docker/ploughshares/templates/pending_approval.html index 62d8bf9..c902152 100644 --- a/docker/ploughshares/templates/pending_approval.html +++ b/docker/ploughshares/templates/pending_approval.html @@ -36,8 +36,12 @@

0 items selected

- - + + + +

reject records? this will delete them from the database permanently.

+ +
{% if transactions %}
@@ -171,6 +175,45 @@ counter.textContent = checkedTransactions.length; } + const approveButton = document.querySelector(".items-selected button.approve"); + const rejectButton = document.querySelector(".items-selected button.reject"); + const rejectDialog = document.querySelector(".items-selected dialog.reject"); + const rejectDialogButton = document.querySelector(".items-selected dialog.reject button"); + + approveButton.addEventListener("click", async () => { + const promises = checkedTransactions.map(async id=>{ + await fetch( + `/api/transaction/${id}/approve`, + { + method: "POST", + } + ) + }); + + await Promise.all(promises); + location.reload(); + }); + + rejectButton.addEventListener("click", () => rejectDialog.showModal()); + + rejectDialog.addEventListener("click", e => { + if (e.target === rejectDialog) rejectDialog.close(); + }); + + rejectDialogButton.addEventListener("click", async () => { + const promises = checkedTransactions.map(async id=>{ + await fetch( + `/api/transaction/${id}`, + { + method: "DELETE", + } + ) + }); + + await Promise.all(promises); + location.reload(); + }); + document.addEventListener('DOMContentLoaded', function() { // Refresh button functionality const refreshBtn = document.getElementById('refreshBtn');