From 3e8a3976eb9fcd28cc94833079a801d8750db1cd Mon Sep 17 00:00:00 2001 From: Gustavo Maximiliano Cortez Date: Mon, 5 Oct 2015 15:04:07 -0300 Subject: [PATCH] Fix modals and choose focused wallet in sell page --- public/views/modals/glidera-wallets.html | 40 ++++++++++++++++++++++++ public/views/sellGlidera.html | 6 ++-- src/js/controllers/buyGlidera.js | 3 +- src/js/controllers/sellGlidera.js | 25 +++++++++++++-- 4 files changed, 68 insertions(+), 6 deletions(-) create mode 100644 public/views/modals/glidera-wallets.html diff --git a/public/views/modals/glidera-wallets.html b/public/views/modals/glidera-wallets.html new file mode 100644 index 000000000..1e1a00bb1 --- /dev/null +++ b/public/views/modals/glidera-wallets.html @@ -0,0 +1,40 @@ + + + diff --git a/public/views/sellGlidera.html b/public/views/sellGlidera.html index 2242a76a5..95c4acc02 100644 --- a/public/views/sellGlidera.html +++ b/public/views/sellGlidera.html @@ -51,12 +51,12 @@ ng-submit="sell.get2faCode(index.glideraToken)" novalidate>
+ ng-init="sell.init(index.glideraTestnet)" + ng-click="openWalletsModal(sell.otherWallets)">
diff --git a/src/js/controllers/buyGlidera.js b/src/js/controllers/buyGlidera.js index da8469454..9e823a5a1 100644 --- a/src/js/controllers/buyGlidera.js +++ b/src/js/controllers/buyGlidera.js @@ -22,6 +22,7 @@ angular.module('copayApp.controllers').controller('buyGlideraController', self.selectedWalletName = null; self.selectedWalletAddr = null; var ModalInstanceCtrl = function($scope, $modalInstance) { + $scope.type = 'BUY'; $scope.wallets = wallets; $scope.cancel = function() { $modalInstance.dismiss('cancel'); @@ -49,7 +50,7 @@ angular.module('copayApp.controllers').controller('buyGlideraController', }; var modalInstance = $modal.open({ - templateUrl: 'views/modals/wallets.html', + templateUrl: 'views/modals/glidera-wallets.html', windowClass: animationService.modalAnimated.slideUp, controller: ModalInstanceCtrl, }); diff --git a/src/js/controllers/sellGlidera.js b/src/js/controllers/sellGlidera.js index a417b457d..a2859db05 100644 --- a/src/js/controllers/sellGlidera.js +++ b/src/js/controllers/sellGlidera.js @@ -14,18 +14,39 @@ angular.module('copayApp.controllers').controller('sellGlideraController', this.currentFeeLevel = config.wallet.settings.feeLevel || 'normal'; var fc; - this.otherWallets = function(testnet) { + var otherWallets = function(testnet) { var network = testnet ? 'testnet' : 'livenet'; return lodash.filter(profileService.getWallets(network), function(w) { return w.network == network && w.m == 1; }); }; + this.init = function(testnet) { + self.otherWallets = otherWallets(testnet); + // Choose focused wallet + try { + var currentWalletId = profileService.focusedClient.credentials.walletId; + lodash.find(self.otherWallets, function(w) { + if (w.id == currentWalletId) { + $timeout(function() { + self.selectedWalletId = w.id; + self.selectedWalletName = w.name; + fc = profileService.getClient(w.id); + $scope.$apply(); + }, 100); + } + }); + } catch(e) { + $log.debug(e); + }; + }; + $scope.openWalletsModal = function(wallets) { self.error = null; self.selectedWalletId = null; self.selectedWalletName = null; var ModalInstanceCtrl = function($scope, $modalInstance) { + $scope.type = 'SELL'; $scope.wallets = wallets; $scope.cancel = function() { $modalInstance.dismiss('cancel'); @@ -45,7 +66,7 @@ angular.module('copayApp.controllers').controller('sellGlideraController', }; var modalInstance = $modal.open({ - templateUrl: 'views/modals/wallets.html', + templateUrl: 'views/modals/glidera-wallets.html', windowClass: animationService.modalAnimated.slideUp, controller: ModalInstanceCtrl, });