From 16390a0dfebd0253db1125b637054b0c32e1d227 Mon Sep 17 00:00:00 2001 From: Jason Etheridge Date: Fri, 3 Jun 2022 13:43:44 -0400 Subject: [PATCH] lp1977877 confirmation dialogs for Remove Note, Archive Note, and Unarchive Note Signed-off-by: Jason Etheridge Signed-off-by: Terran McCanna Signed-off-by: Galen Charlton --- Open-ILS/src/templates/staff/circ/patron/index.tt2 | 3 + .../web/js/ui/default/staff/circ/patron/app.js | 280 ++++++++++++--------- 2 files changed, 158 insertions(+), 125 deletions(-) diff --git a/Open-ILS/src/templates/staff/circ/patron/index.tt2 b/Open-ILS/src/templates/staff/circ/patron/index.tt2 index 89ec013d78..ddf92e43a5 100644 --- a/Open-ILS/src/templates/staff/circ/patron/index.tt2 +++ b/Open-ILS/src/templates/staff/circ/patron/index.tt2 @@ -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 = 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 c633cc2407..fec6e90aef 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 @@ -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 -- 2.11.0