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/amount.js b/src/js/controllers/amount.js index d70b6bf23..ce6f34008 100644 --- a/src/js/controllers/amount.js +++ b/src/js/controllers/amount.js @@ -1,6 +1,6 @@ 'use strict'; -angular.module('copayApp.controllers').controller('amountController', function($rootScope, $scope, $filter, $timeout, $ionicScrollDelegate, platformInfo, lodash, configService, go, rateService, $stateParams, $window, $state, $log, txFormatService) { +angular.module('copayApp.controllers').controller('amountController', function($rootScope, $scope, $filter, $timeout, $ionicScrollDelegate, platformInfo, lodash, configService, rateService, $stateParams, $window, $state, $log, txFormatService) { var unitToSatoshi; diff --git a/src/js/controllers/coinbaseUri.js b/src/js/controllers/coinbaseUri.js index f402bce93..b92c1b355 100644 --- a/src/js/controllers/coinbaseUri.js +++ b/src/js/controllers/coinbaseUri.js @@ -1,6 +1,6 @@ 'use strict'; angular.module('copayApp.controllers').controller('coinbaseUriController', - function($scope, $stateParams, $timeout, profileService, configService, coinbaseService, storageService, go, ongoingProcess) { + function($scope, $stateParams, $timeout, profileService, configService, coinbaseService, storageService, $state, ongoingProcess) { this.submitOauthCode = function(code) { var self = this; @@ -21,7 +21,7 @@ angular.module('copayApp.controllers').controller('coinbaseUriController', storageService.setCoinbaseRefreshToken(network, data.refresh_token, function() { $scope.$emit('Local/CoinbaseUpdated', data.access_token); $timeout(function() { - go.path('coinbase'); + $state.go('coinbase'); $scope.$apply(); }, 100); }); diff --git a/src/js/controllers/confirm.js b/src/js/controllers/confirm.js index 9bba24d6e..e793c2709 100644 --- a/src/js/controllers/confirm.js +++ b/src/js/controllers/confirm.js @@ -1,6 +1,6 @@ 'use strict'; -angular.module('copayApp.controllers').controller('confirmController', function($rootScope, $scope, $filter, $timeout, $ionicScrollDelegate, walletService, platformInfo, lodash, configService, go, rateService, $stateParams, $window, $state, $log, profileService, bitcore, $ionicPopup, txStatus, gettext, txFormatService) { +angular.module('copayApp.controllers').controller('confirmController', function($rootScope, $scope, $filter, $timeout, $ionicScrollDelegate, walletService, platformInfo, lodash, configService, rateService, $stateParams, $window, $state, $log, profileService, bitcore, $ionicPopup, txStatus, gettext, txFormatService) { var cachedTxp = {}; diff --git a/src/js/controllers/copayers.js b/src/js/controllers/copayers.js index 2e7c871d8..51efe46af 100644 --- a/src/js/controllers/copayers.js +++ b/src/js/controllers/copayers.js @@ -1,7 +1,7 @@ 'use strict'; angular.module('copayApp.controllers').controller('copayersController', - function($scope, $rootScope, $timeout, $log, $ionicModal, profileService, $state, notification, platformInfo, gettext, gettextCatalog, $stateParams, $state) { + function($scope, $rootScope, $timeout, $log, $ionicModal, profileService, notification, platformInfo, gettext, gettextCatalog, $stateParams, $state) { var self = this; $scope.isCordova = platformInfo.isCordova; var isWP = platformInfo.isWP; diff --git a/src/js/controllers/glideraUri.js b/src/js/controllers/glideraUri.js index 2c1995373..b7dfde22b 100644 --- a/src/js/controllers/glideraUri.js +++ b/src/js/controllers/glideraUri.js @@ -1,6 +1,6 @@ 'use strict'; angular.module('copayApp.controllers').controller('glideraUriController', - function($scope, $log, $stateParams, $timeout, profileService, configService, glideraService, storageService, go, ongoingProcess) { + function($scope, $log, $stateParams, $timeout, profileService, configService, glideraService, storageService, $state, ongoingProcess) { this.submitOauthCode = function(code) { $log.debug('Glidera Oauth Code:' + code); @@ -21,7 +21,7 @@ angular.module('copayApp.controllers').controller('glideraUriController', storageService.setGlideraToken(network, data.access_token, function() { $scope.$emit('Local/GlideraUpdated', data.access_token); $timeout(function() { - go.path('glidera'); + $state.go('glidera'); $scope.$apply(); }, 100); }); diff --git a/src/js/controllers/preferencesAltCurrency.js b/src/js/controllers/preferencesAltCurrency.js index 5f0581f18..20bdb53c9 100644 --- a/src/js/controllers/preferencesAltCurrency.js +++ b/src/js/controllers/preferencesAltCurrency.js @@ -1,7 +1,7 @@ 'use strict'; angular.module('copayApp.controllers').controller('preferencesAltCurrencyController', - function($scope, $log, $timeout, configService, rateService, lodash, go, profileService, walletService) { + function($scope, $log, $timeout, configService, rateService, lodash, profileService, walletService, $state) { var next = 10; var completeAlternativeList; @@ -42,7 +42,7 @@ angular.module('copayApp.controllers').controller('preferencesAltCurrencyControl configService.set(opts, function(err) { if (err) $log.warn(err); - go.preferencesGlobal(); + $state.go('preferencesGlobal'); $scope.$emit('Local/UnitSettingUpdated'); walletService.updateRemotePreferences(profileService.getClients(), {}, function() { $log.debug('Remote preferences saved'); diff --git a/src/js/controllers/preferencesDelete.js b/src/js/controllers/preferencesDelete.js index 9ac144c57..9963f6f92 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, $state, gettext, gettextCatalog, applicationService, ongoingProcess) { - var isCordova = platformInfo.isCordova; - $scope.isCordova = isCordova; + function($scope, $ionicPopup, $stateParams, lodash, notification, profileService, $state, 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(); - } - }; }); diff --git a/src/js/controllers/preferencesUnit.js b/src/js/controllers/preferencesUnit.js index abdee5625..b23f831cc 100644 --- a/src/js/controllers/preferencesUnit.js +++ b/src/js/controllers/preferencesUnit.js @@ -1,6 +1,6 @@ 'use strict'; -angular.module('copayApp.controllers').controller('preferencesUnitController', function($scope, $log, configService, go, walletService, profileService) { +angular.module('copayApp.controllers').controller('preferencesUnitController', function($scope, $log, configService, $state, walletService, profileService) { $scope.init = function() { var config = configService.getSync(); @@ -36,7 +36,7 @@ angular.module('copayApp.controllers').controller('preferencesUnitController', f configService.set(opts, function(err) { if (err) $log.warn(err); - go.preferencesGlobal(); + $state.go('preferencesGlobal'); $scope.$emit('Local/UnitSettingUpdated'); walletService.updateRemotePreferences(profileService.getClients(), {}, function() { diff --git a/src/js/controllers/sidebar.js b/src/js/controllers/sidebar.js deleted file mode 100644 index abe29d043..000000000 --- a/src/js/controllers/sidebar.js +++ /dev/null @@ -1,67 +0,0 @@ -'use strict'; - -angular.module('copayApp.controllers').controller('sidebarController', - function($rootScope, $timeout, $ionicScrollDelegate, lodash, profileService, configService, go, platformInfo, $window) { - var self = this; - self.isWindowsPhoneApp = platformInfo.isWP && platformInfo.isCordova; - self.walletSelection = false; - - self.bitpayCardEnabled = $window.appConfig && $window.appConfig._enabledExtensions.debitcard; - - - // wallet list change - $rootScope.$on('Local/WalletListUpdated', function(event) { - self.walletSelection = false; - self.setWallets(); - }); - - $rootScope.$on('Local/ColorUpdated', function(event) { - self.setWallets(); - }); - - $rootScope.$on('Local/AliasUpdated', function(event) { - self.setWallets(); - }); - - self.signout = function() { - profileService.signout(); - }; - - self.switchWallet = function(selectedWalletId, currentWalletId) { - var client = profileService.focusedClient; - if (selectedWalletId == currentWalletId && client.isComplete()) return; - self.walletSelection = false; - profileService.setAndStoreFocus(selectedWalletId, function() {}); - $ionicScrollDelegate.scrollTop(); - }; - - self.toggleWalletSelection = function() { - self.walletSelection = !self.walletSelection; - if (!self.walletSelection) return; - self.setWallets(); - }; - - self.setWallets = function() { - if (!profileService.profile) return; - - var config = configService.getSync(); - config.colorFor = config.colorFor || {}; - config.aliasFor = config.aliasFor || {}; - - // Sanitize empty wallets (fixed in BWC 1.8.1, and auto fixed when wallets completes) - var credentials = lodash.filter(profileService.profile.credentials, 'walletName'); - var ret = lodash.map(credentials, function(c) { - return { - m: c.m, - n: c.n, - name: config.aliasFor[c.walletId] || c.walletName, - id: c.walletId, - color: config.colorFor[c.walletId] || '#4A90E2', - }; - }); - - self.wallets = lodash.sortBy(ret, 'name'); - }; - - self.setWallets(); - }); diff --git a/src/js/controllers/tab-scan.js b/src/js/controllers/tab-scan.js index 704b643e7..3615b9778 100644 --- a/src/js/controllers/tab-scan.js +++ b/src/js/controllers/tab-scan.js @@ -1,6 +1,6 @@ 'use strict'; -angular.module('copayApp.controllers').controller('tabScanController', function($scope, $timeout, $ionicModal, $log, $ionicPopup, configService, gettextCatalog, platformInfo, go, bitcore, lodash) { +angular.module('copayApp.controllers').controller('tabScanController', function($scope, $timeout, $ionicModal, $log, $ionicPopup, configService, gettextCatalog, platformInfo, bitcore, lodash, $state) { var isCordova = platformInfo.isCordova; var isWP = platformInfo.isWP; @@ -36,7 +36,7 @@ angular.module('copayApp.controllers').controller('tabScanController', function( return; } - go.confirm(parsedData); + $state.go('confirm', parsedData); }; var _parseFromUri = function(uri) { @@ -95,7 +95,7 @@ angular.module('copayApp.controllers').controller('tabScanController', function( $timeout(function() { var data = isIOS ? result : result.text; // Check if the current page is tabs.scan - if (go.is('tabs.scan')) { + if ($state.is('tabs.scan')) { _dataScanned(data); return; } @@ -190,7 +190,7 @@ angular.module('copayApp.controllers').controller('tabScanController', function( } // Check if the current page is tabs.scan _scanStop(); - if (go.is('tabs.scan')) { + if ($state.is('tabs.scan')) { _dataScanned(data); return; } diff --git a/src/js/controllers/walletDetails.js b/src/js/controllers/walletDetails.js index 0111c3e87..9a5ee09d0 100644 --- a/src/js/controllers/walletDetails.js +++ b/src/js/controllers/walletDetails.js @@ -1,6 +1,6 @@ 'use strict'; -angular.module('copayApp.controllers').controller('walletDetailsController', function($scope, $rootScope, $interval, $timeout, $filter, $log, $ionicModal, $ionicPopover, $state, $stateParams, bwcError, profileService, lodash, configService, gettext, gettextCatalog, platformInfo, go, walletService) { +angular.module('copayApp.controllers').controller('walletDetailsController', function($scope, $rootScope, $interval, $timeout, $filter, $log, $ionicModal, $ionicPopover, $state, $stateParams, bwcError, profileService, lodash, configService, gettext, gettextCatalog, platformInfo, walletService) { var isCordova = platformInfo.isCordova; var isWP = platformInfo.isWP;