Merge pull request #206 from JDonadio/bug/delete-wallet

Fix delete wallet - wallet alias
This commit is contained in:
Matias Alejo Garcia 2016-08-19 13:06:28 -03:00 committed by GitHub
commit 5b14c8aca3
2 changed files with 30 additions and 46 deletions

View File

@ -10,9 +10,9 @@
<ion-content class="has-header" ng-controller="preferencesDeleteWalletController" cache-view="false">
<div translate>Warning!</div>
<div translate>Permanently delete this wallet. THIS ACTION CANNOT BE REVERSED</div>
<div class="right" ng-style="{'color':index.backgroundColor}" ng-show="!isDeletingWallet">
{{index.walletName}}<span ng-show="index.alias">({{index.alias}})</span>
<div class="right" ng-style="{'color':backgroundColor}" ng-show="!isDeletingWallet">
<span ng-show="alias">{{alias}}</span>{{walletName}}
</div>
<button class="button button-block button-stable" ng-click="deleteWallet()"translate>Delete wallet</button>
<button class="button button-block button-stable" ng-click="showDeletePopup()"translate>Delete wallet</button>
</ion-content>
</ion-view>

View File

@ -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: '<span>' + gettextCatalog.getString('Are you sure you want to delete this wallet?') + '</span>',
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();
}
};
});