Wallet/src/js/controllers/preferencesDelete.js

45 lines
1.5 KiB
JavaScript
Raw Normal View History

2015-03-06 12:00:10 -03:00
'use strict';
angular.module('copayApp.controllers').controller('preferencesDeleteWalletController',
2016-08-23 16:53:26 -03:00
function($scope, $ionicPopup, $stateParams, lodash, profileService, $state, gettextCatalog, ongoingProcess) {
2016-08-19 12:50:52 -03:00
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;
2016-08-19 12:50:52 -03:00
var walletName = $scope.alias || $scope.walletName;
2015-03-06 12:00:10 -03:00
2016-08-19 12:50:52 -03:00
$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();
}
}
]
2015-03-06 12:00:10 -03:00
});
};
2016-08-19 12:50:52 -03:00
function deleteWallet() {
2016-06-13 15:25:40 -03:00
ongoingProcess.set('deletingWallet', true);
2016-08-19 12:50:52 -03:00
profileService.deleteWalletClient(wallet, function(err) {
2016-06-13 15:25:40 -03:00
ongoingProcess.set('deletingWallet', false);
if (err) {
$scope.error = err.message || err;
} else {
2016-08-19 13:07:18 -03:00
$state.go('tabs.home');
}
});
2015-03-06 12:00:10 -03:00
};
2015-07-29 12:37:51 -03:00
});