lp1977877 confirmation dialogs for Remove Note, Archive Note, and Unarchive Note
authorJason Etheridge <jason@EquinoxOLI.org>
Fri, 3 Jun 2022 17:43:44 +0000 (13:43 -0400)
committerGalen Charlton <gmc@equinoxOLI.org>
Fri, 28 Oct 2022 00:18:52 +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/index.tt2
Open-ILS/web/js/ui/default/staff/circ/patron/app.js

index 89ec013..ddf92e4 100644 (file)
@@ -49,6 +49,9 @@ angular.module('egCoreMod').run(['egStrings', function(s) {
   s.RENEW_ITEMS = "[% l('Renew Items?') %]";
   s.RENEW_ALL_ITEMS = "[% l('Renew All Items?') %]";
   s.CHECK_IN_CONFIRM = "[% l('Check In Items?') %]";
+  s.CONFIRM_ARCHIVE_NOTE = "[% l('Archive selected notes? Public non-deleted notes will still be visible to patrons.') %]";
+  s.CONFIRM_UNARCHIVE_NOTE = "[% l('Unarchive selected notes? Associated blocks/penalties will be restored.') %]";
+  s.CONFIRM_REMOVE_NOTE = "[% l('Remove selected notes?') %]";
   s.REG_INVALID_FIELDS = 
     "[% l('Please enter valid values for all required fields.') %]"
   s.REG_PASSWORD_RESET_REQUEST_NO_EMAIL =
index c633cc2..fec6e90 100644 (file)
@@ -793,8 +793,8 @@ function($scope,  $q,  $routeParams,  $timeout,  $window,  $location,  egCore ,
  * Manages messages
  */
 .controller('PatronMessagesCtrl',
-       ['$scope','$q','$routeParams','egCore','$uibModal','patronSvc','egCirc','hasPermAt',
-function($scope , $q , $routeParams,  egCore , $uibModal , patronSvc , egCirc , hasPermAt ) {
+       ['$scope','$q','$routeParams','egCore','$uibModal','egConfirmDialog','patronSvc','egCirc','hasPermAt',
+function($scope , $q , $routeParams,  egCore , $uibModal , egConfirmDialog , patronSvc , egCirc , hasPermAt ) {
     $scope.initTab('messages', $routeParams.id);
     var usr_id = $routeParams.id;
     var org_ids = hasPermAt.VIEW_USER;
@@ -861,145 +861,175 @@ function($scope , $q , $routeParams,  egCore , $uibModal , patronSvc , egCirc ,
     $scope.removePenalty = 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); }
-        });
+        function doit() {
+            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) {
-                    return egCore.pcrud.remove(penalties);
-                })
-            );
-        }
-        if (aum_ids.length > 0) {
-            promises.push(
-                egCore.pcrud.search('aum',
-                    {id : aum_ids}, {},
-                    {atomic : true, authoritative : true}
-                ).then(function(messages) {
-                    return egCore.pcrud.remove(messages);
-                })
-            );
+            // 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) {
+                        return egCore.pcrud.remove(penalties);
+                    })
+                );
+            }
+            if (aum_ids.length > 0) {
+                promises.push(
+                    egCore.pcrud.search('aum',
+                        {id : aum_ids}, {},
+                        {atomic : true, authoritative : true}
+                    ).then(function(messages) {
+                        return egCore.pcrud.remove(messages);
+                    })
+                );
+            }
+            $q.all(promises).then(function() {
+                activeGrid.refresh();
+                archiveGrid.refresh();
+                // force a refresh of the user
+                patronSvc.setPrimary(patronSvc.current.id(), null, true);
+            });
         }
-        $q.all(promises).then(function() {
-            activeGrid.refresh();
-            archiveGrid.refresh();
-            // force a refresh of the user
-            patronSvc.setPrimary(patronSvc.current.id(), null, true);
-        });
+
+        egCore.audio.play('warning.circ.remove_note');
+        egConfirmDialog.open(
+            egCore.strings.CONFIRM_REMOVE_NOTE, '',
+            {   //xactIds : ''+ids,
+                ok : function() {
+                    doit();
+                }
+            }
+        );
     }
 
     $scope.archivePenalty = 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); }
-        });
+        function doit() {
+            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('now');
-                    });
-                    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('now');
-                    });
-                    return egCore.pcrud.update(messages);
-                })
-            );
+            // 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('now');
+                        });
+                        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('now');
+                        });
+                        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);
+            });
         }
-        $q.all(promises).then(function() {
-            activeGrid.refresh();
-            archiveGrid.refresh();
-            // force a refresh of the user
-            patronSvc.setPrimary(patronSvc.current.id(), null, true);
-        });
+
+        egCore.audio.play('warning.circ.archive_note');
+        egConfirmDialog.open(
+            egCore.strings.CONFIRM_ARCHIVE_NOTE, '', 
+            {   //xactIds : ''+ids,
+                ok : function() {
+                    doit();
+                }
+            }
+        );
     }
 
     $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); }
-        });
+        function doit() {
+            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);
-                })
-            );
+            // 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);
+            });
         }
-        $q.all(promises).then(function() {
-            activeGrid.refresh();
-            archiveGrid.refresh();
-            // force a refresh of the user
-            patronSvc.setPrimary(patronSvc.current.id(), null, true);
-        });
+
+        egCore.audio.play('warning.circ.unarchive_note');
+        egConfirmDialog.open(
+            egCore.strings.CONFIRM_UNARCHIVE_NOTE, '', 
+            {   //xactIds : ''+ids,
+                ok : function() {
+                    doit();
+                }
+            }
+        );
     }
 
     // leverage egEnv for caching