From 3ca17f257c2fec0e363edc463baaf609dc5aa746 Mon Sep 17 00:00:00 2001 From: Jason Etheridge Date: Fri, 3 Jun 2022 13:24:20 -0400 Subject: [PATCH] lp1977877 action for unarchiving Notes in the staff UI Signed-off-by: Jason Etheridge Signed-off-by: Terran McCanna Signed-off-by: Galen Charlton --- .../src/templates/staff/circ/patron/t_messages.tt2 | 4 +- .../web/js/ui/default/staff/circ/patron/app.js | 50 ++++++++++++++++++++++ 2 files changed, 53 insertions(+), 1 deletion(-) diff --git a/Open-ILS/src/templates/staff/circ/patron/t_messages.tt2 b/Open-ILS/src/templates/staff/circ/patron/t_messages.tt2 index 017cbf4004..5bc5246e33 100644 --- a/Open-ILS/src/templates/staff/circ/patron/t_messages.tt2 +++ b/Open-ILS/src/templates/staff/circ/patron/t_messages.tt2 @@ -55,9 +55,11 @@ idl-class="aump" grid-controls="archiveGridControls" dateformat="{{$root.egDateAndTimeFormat}}" - features="-multiselect" persist-key="circ.patron.archived_messages"> + + diff --git a/Open-ILS/web/js/ui/default/staff/circ/patron/app.js b/Open-ILS/web/js/ui/default/staff/circ/patron/app.js index 7914bca35c..c633cc2407 100644 --- a/Open-ILS/web/js/ui/default/staff/circ/patron/app.js +++ b/Open-ILS/web/js/ui/default/staff/circ/patron/app.js @@ -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) -- 2.11.0