From 9bb74a84df0ad8c8ef05a26eea041d393ea21cc7 Mon Sep 17 00:00:00 2001 From: jChenvan <188939308+jChenvan@users.noreply.github.com> Date: Fri, 18 Jul 2025 19:26:45 -0400 Subject: [PATCH] Add batch approval/rejection --- .../templates/pending_approval.html | 47 ++++++++++++++++++- 1 file changed, 45 insertions(+), 2 deletions(-) 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');