From b38a88b9461cc05b7b2a5218004e4a6991eec3db Mon Sep 17 00:00:00 2001 From: Javier Date: Fri, 19 Aug 2016 12:50:52 -0300 Subject: [PATCH] fix delete wallet - wallet alias --- public/views/preferencesDeleteWallet.html | 6 +- src/js/controllers/preferencesDelete.js | 70 +++++++++-------------- 2 files changed, 30 insertions(+), 46 deletions(-) diff --git a/public/views/preferencesDeleteWallet.html b/public/views/preferencesDeleteWallet.html index ff96de011..20063efd8 100644 --- a/public/views/preferencesDeleteWallet.html +++ b/public/views/preferencesDeleteWallet.html @@ -10,9 +10,9 @@
Warning!
Permanently delete this wallet. THIS ACTION CANNOT BE REVERSED
-
- {{index.walletName}}({{index.alias}}) +
+ {{alias}}{{walletName}}
- + diff --git a/src/js/controllers/preferencesDelete.js b/src/js/controllers/preferencesDelete.js index 133789e76..9e0e6a6b0 100644 --- a/src/js/controllers/preferencesDelete.js +++ b/src/js/controllers/preferencesDelete.js @@ -1,39 +1,39 @@ 'use strict'; angular.module('copayApp.controllers').controller('preferencesDeleteWalletController', - function($scope, $rootScope, $filter, $timeout, $log, $ionicModal, storageService, notification, profileService, platformInfo, go, gettext, gettextCatalog, applicationService, ongoingProcess) { - var isCordova = platformInfo.isCordova; - $scope.isCordova = isCordova; + function($scope, $ionicPopup, $stateParams, lodash, notification, profileService, go, gettextCatalog, ongoingProcess) { + var wallet = profileService.getWallet($stateParams.walletId); + $scope.alias = lodash.isEqual(wallet.name, wallet.credentials.walletName) ? null : wallet.name + ' '; + $scope.walletName = '[' + wallet.credentials.walletName + ']'; $scope.error = null; + var walletName = $scope.alias || $scope.walletName; - var delete_msg = gettextCatalog.getString('Are you sure you want to delete this wallet?'); - var accept_msg = gettextCatalog.getString('Accept'); - var cancel_msg = gettextCatalog.getString('Cancel'); - var confirm_msg = gettextCatalog.getString('Confirm'); - - var _modalDeleteWallet = function() { - $scope.title = delete_msg; - $scope.accept_msg = accept_msg; - $scope.cancel_msg = cancel_msg; - $scope.confirm_msg = confirm_msg; - $scope.okAction = doDeleteWallet; - $scope.loading = false; - - $ionicModal.fromTemplateUrl('views/modals/confirmation.html', { - scope: $scope - }).then(function(modal) { - $scope.confirmationModal = modal; - $scope.confirmationModal.show(); + $scope.showDeletePopup = function() { + var popup = $ionicPopup.show({ + template: '' + gettextCatalog.getString('Are you sure you want to delete this wallet?') + '', + title: gettextCatalog.getString('Confirm'), + buttons: [ + { + text: gettextCatalog.getString('Cancel'), + onTap: function(e) { + popup.close(); + } + }, + { + text: gettextCatalog.getString('Accept'), + type: 'button-positive', + onTap: function(e) { + deleteWallet(); + popup.close(); + } + } + ] }); }; - var doDeleteWallet = function() { + function deleteWallet() { ongoingProcess.set('deletingWallet', true); - var fc = profileService.focusedClient; - var name = fc.credentials.walletName; - var walletName = (fc.alias || '') + ' [' + name + ']'; - - profileService.deleteWalletClient(fc, function(err) { + profileService.deleteWalletClient(wallet, function(err) { ongoingProcess.set('deletingWallet', false); if (err) { $scope.error = err.message || err; @@ -45,20 +45,4 @@ angular.module('copayApp.controllers').controller('preferencesDeleteWalletContro } }); }; - - $scope.deleteWallet = function() { - if (isCordova) { - navigator.notification.confirm( - delete_msg, - function(buttonIndex) { - if (buttonIndex == 1) { - doDeleteWallet(); - } - }, - confirm_msg, [accept_msg, cancel_msg] - ); - } else { - _modalDeleteWallet(); - } - }; });