From 371997da6f35a01317fa912a89433ba0fe1196a8 Mon Sep 17 00:00:00 2001 From: manolobevia Date: Thu, 9 Jun 2011 21:53:15 +0000 Subject: [PATCH] NIHVIVO-2280: On main account page, If there is no account selected for deletion and the user click on the DELETE button, the page was throwing a js alert displaying, "Are you sure you want to delete this account?". I have fixed this error. --- webapp/web/js/account/accountUtils.js | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/webapp/web/js/account/accountUtils.js b/webapp/web/js/account/accountUtils.js index 2eab9026d..c95585c2c 100644 --- a/webapp/web/js/account/accountUtils.js +++ b/webapp/web/js/account/accountUtils.js @@ -10,7 +10,6 @@ $(document).ready(function(){ $('#account-display').submit(); }); - //Delete accounts //Show is javascript is enable $('input:checkbox[name=delete-all]').show(); @@ -24,17 +23,20 @@ $(document).ready(function(){ // if not checked, deselect all the checkboxes $('input:checkbox[name=deleteAccount]').removeAttr('checked'); } - }); - $('input:checkbox[name=deleteAccount]').click(function(){ - $('input:checkbox[name=delete-all]').removeAttr('checked'); - }); + $('input:checkbox[name=deleteAccount]').click(function(){ + $('input:checkbox[name=delete-all]').removeAttr('checked'); + }); - // Confirmation alert for account deletion in userAccounts-list.ftl template - $('input[name="delete-account"]').click(function(){ - var countAccount = $('input:checkbox[name=deleteAccount]:checked').length; - var answer = confirm( 'Are you sure you want to delete ' + ((countAccount > 1) ? 'these accounts' : 'this account') +'?'); - return answer; - }); + // Confirmation alert for account deletion in userAccounts-list.ftl template + $('input[name="delete-account"]').click(function(){ + var countAccount = $('input:checkbox[name=deleteAccount]:checked').length; + if (countAccount == 0){ + return false; + }else{ + var answer = confirm( 'Are you sure you want to delete ' + ((countAccount > 1) ? 'these accounts' : 'this account') +'?'); + return answer; + } + }); }); \ No newline at end of file