lp1977877 action for unarchiving Notes in the staff UI
authorJason Etheridge <jason@EquinoxOLI.org>
Fri, 3 Jun 2022 17:24:20 +0000 (13:24 -0400)
committerGalen Charlton <gmc@equinoxOLI.org>
Fri, 28 Oct 2022 00:18:51 +0000 (20:18 -0400)
Signed-off-by: Jason Etheridge <jason@EquinoxOLI.org>
Signed-off-by: Terran McCanna <tmccanna@georgialibraries.org>
Signed-off-by: Galen Charlton <gmc@equinoxOLI.org>
Open-ILS/src/templates/staff/circ/patron/t_messages.tt2
Open-ILS/web/js/ui/default/staff/circ/patron/app.js

index 017cbf4..5bc5246 100644 (file)
   idl-class="aump"
   grid-controls="archiveGridControls"
   dateformat="{{$root.egDateAndTimeFormat}}"
-  features="-multiselect"
   persist-key="circ.patron.archived_messages">
 
+  <eg-grid-action label="[% l('Unarchive Note') %]"
+    handler="unarchivePenalty"></eg-grid-action>
+
   <eg-grid-field path="read_date"></eg-grid-field>
   <eg-grid-field path="deleted" required hidden></eg-grid-field>
   <eg-grid-field path="usr.usrname" label="[% l('User') %]" required hidden></eg-grid-field>
index 7914bca..c633cc2 100644 (file)
@@ -952,6 +952,56 @@ function($scope , $q , $routeParams,  egCore , $uibModal , patronSvc , egCirc ,
         });
     }
 
+    $scope.unarchivePenalty = function(selected) {
+        if (selected.length == 0) return;
+
+        // TODO: need confirmation dialog
+
+        var promises = [];
+        // figure out the view components
+        var aum_ids = [];
+        var ausp_ids = [];
+        angular.forEach(selected, function(s) {
+            if (s.aum_id) { aum_ids.push(s.aum_id); }
+            if (s.ausp_id) { ausp_ids.push(s.ausp_id); }
+        });
+
+        // fetch all of them since trying to pull them
+        // off of patronSvc.current isn't reliable
+        if (ausp_ids.length > 0) {
+            promises.push(
+                egCore.pcrud.search('ausp',
+                    {id : ausp_ids}, {},
+                    {atomic : true, authoritative : true}
+                ).then(function(penalties) {
+                    angular.forEach(penalties, function(p) {
+                        p.stop_date(null);
+                    });
+                    return egCore.pcrud.update(penalties);
+                })
+            );
+        }
+        if (aum_ids.length > 0) {
+            promises.push(
+                egCore.pcrud.search('aum',
+                    {id : aum_ids}, {},
+                    {atomic : true, authoritative : true}
+                ).then(function(messages) {
+                    angular.forEach(messages, function(m) {
+                        m.stop_date(null);
+                    });
+                    return egCore.pcrud.update(messages);
+                })
+            );
+        }
+        $q.all(promises).then(function() {
+            activeGrid.refresh();
+            archiveGrid.refresh();
+            // force a refresh of the user
+            patronSvc.setPrimary(patronSvc.current.id(), null, true);
+        });
+    }
+
     // leverage egEnv for caching
     function fetchPenaltyTypes() {
         if (egCore.env.csp)