From abfa9f5ed418a9322a4a7706243682b3225998a8 Mon Sep 17 00:00:00 2001 From: Javier Date: Fri, 10 Jun 2016 09:27:14 -0300 Subject: [PATCH] Fix currency selection --- public/views/preferencesAltCurrency.html | 22 ++++------ src/js/controllers/preferencesAltCurrency.js | 43 ++++++-------------- 2 files changed, 20 insertions(+), 45 deletions(-) diff --git a/public/views/preferencesAltCurrency.html b/public/views/preferencesAltCurrency.html index faab726c8..63b7ce908 100644 --- a/public/views/preferencesAltCurrency.html +++ b/public/views/preferencesAltCurrency.html @@ -1,20 +1,12 @@ -
- - -
- +

-
    -
  • - {{altCurrency.name}} - -
  • -
      -
-
+ + {{altCurrency.name}} + +
diff --git a/src/js/controllers/preferencesAltCurrency.js b/src/js/controllers/preferencesAltCurrency.js index 5f6a9c2cf..d14b80007 100644 --- a/src/js/controllers/preferencesAltCurrency.js +++ b/src/js/controllers/preferencesAltCurrency.js @@ -1,39 +1,31 @@ 'use strict'; angular.module('copayApp.controllers').controller('preferencesAltCurrencyController', - function($scope, $timeout, $log, configService, rateService, lodash, go, profileService, walletService) { - this.hideAdv = true; - this.hidePriv = true; - this.hideSecret = true; - this.error = null; - this.success = null; + function($scope, $log, configService, rateService, lodash, go, profileService, walletService) { var config = configService.getSync(); - this.selectedAlternative = { + $scope.currentCurrency = { name: config.wallet.settings.alternativeName, isoCode: config.wallet.settings.alternativeIsoCode }; - this.alternativeOpts = [this.selectedAlternative]; //default value - - var self = this; rateService.whenAvailable(function() { - self.alternativeOpts = rateService.listAlternatives(); - lodash.remove(self.alternativeOpts, function(n) { - return n.isoCode == 'BTC'; + $scope.altCurrencyList = rateService.listAlternatives(); + + lodash.remove($scope.altCurrencyList, function(c) { + return c.isoCode == 'BTC'; + }); + + lodash.each($scope.altCurrencyList, function(altCurrency) { + if (config.wallet.settings.alternativeIsoCode === altCurrency.isoCode) + $scope.currentCurrency = altCurrency; }); - for (var ii in self.alternativeOpts) { - if (config.wallet.settings.alternativeIsoCode === self.alternativeOpts[ii].isoCode) { - self.selectedAlternative = self.alternativeOpts[ii]; - } - } $scope.$digest(); }); - - this.save = function(newAltCurrency) { + $scope.save = function(newAltCurrency) { var opts = { wallet: { settings: { @@ -42,23 +34,14 @@ angular.module('copayApp.controllers').controller('preferencesAltCurrencyControl } } }; - this.selectedAlternative = { - name: newAltCurrency.name, - isoCode: newAltCurrency.isoCode, - }; configService.set(opts, function(err) { if (err) $log.warn(err); go.preferencesGlobal(); $scope.$emit('Local/UnitSettingUpdated'); - walletService.updateRemotePreferences(profileService.walletClients, {}, function() { + walletService.updateRemotePreferences(profileService.getClients(), {}, function() { $log.debug('Remote preferences saved'); }); - $timeout(function() { - $scope.$apply(); - }, 100); }); }; - - });