From 5d520733a083733426bed4e8664de8e78cb79ea6 Mon Sep 17 00:00:00 2001
From: Cesar Velez <cesar.velez@equinoxinitiative.org>
Date: Wed, 12 Dec 2018 17:43:35 -0500
Subject: [PATCH] LP#1737800 - add delete action to pending patrons

This adds a way to remove a pending/staged user from
the pending users grid.

Signed-off-by: Cesar Velez <cesar.velez@equinoxinitiative.org>
Signed-off-by: Terran McCanna <tmccanna@georgialibraries.org>
Signed-off-by: Bill Erickson <berickxx@gmail.com>
---
 .../templates/staff/circ/patron/t_pending_list.tt2 |  3 +++
 .../web/js/ui/default/staff/circ/patron/pending.js | 23 +++++++++++++++++++++-
 2 files changed, 25 insertions(+), 1 deletion(-)

diff --git a/Open-ILS/src/templates/staff/circ/patron/t_pending_list.tt2 b/Open-ILS/src/templates/staff/circ/patron/t_pending_list.tt2
index 7384211ef5..c8ecf9f05c 100644
--- a/Open-ILS/src/templates/staff/circ/patron/t_pending_list.tt2
+++ b/Open-ILS/src/templates/staff/circ/patron/t_pending_list.tt2
@@ -22,6 +22,9 @@
   <eg-grid-menu-item handler="load_patron" 
     label="[% l('Load Patron') %]"></eg-grid-menu-item>
 
+  <eg-grid-menu-item handler="deletePatron"
+    label="[% l('Delete Pending Patron(s)') %]"></eg-grid-menu-item>
+
   <eg-grid-field path='user.row_date' label="[% l('Create Date') %]"></eg-grid-field>
   <eg-grid-field path='user.first_given_name' label="[% l('First Name') %]"></eg-grid-field>
   <eg-grid-field path='user.second_given_name' label="[% l('Middle Name') %]"></eg-grid-field>
diff --git a/Open-ILS/web/js/ui/default/staff/circ/patron/pending.js b/Open-ILS/web/js/ui/default/staff/circ/patron/pending.js
index 0912eb84c2..59b1556f02 100644
--- a/Open-ILS/web/js/ui/default/staff/circ/patron/pending.js
+++ b/Open-ILS/web/js/ui/default/staff/circ/patron/pending.js
@@ -37,12 +37,33 @@ function($scope , $q , $routeParams , $window , $location , egCore , egGridDataP
         ).focus();
     }
 
+    function delete_patron(sel_pending_users) {
+        if (angular.isArray(sel_pending_users)){
+           var promises = [];
+            angular.forEach(sel_pending_users, function(stgu){
+                promises.push(egCore.net.request(
+                    'open-ils.actor',
+                    'open-ils.actor.user.stage.delete',
+                    egCore.auth.token(),
+                    stgu.user.row_id()
+                ));
+            });
+
+            $q.all(promises).then(refresh_page);
+        }
+    }
+
     $scope.load_patron = function(action, data, items) {
         load_patron(items);
     }
 
+    $scope.deletePatron = function(action, data, items) {
+        delete_patron(items);
+    }
+
     $scope.grid_controls = {
-        activateItem : load_patron
+        activateItem : load_patron,
+        deleteItem : delete_patron
     }
 
     function refresh_page() {
-- 
2.11.0