Merge pull request #4345 from JDonadio/bug/select-currency
Fix currency selection
This commit is contained in:
commit
c5eb9a60fd
2 changed files with 19 additions and 44 deletions
|
|
@ -1,20 +1,12 @@
|
|||
<div
|
||||
class="topbar-container"
|
||||
ng-include="'views/includes/topbar.html'"
|
||||
<div class="topbar-container" ng-include="'views/includes/topbar.html'"
|
||||
ng-init="titleSection='Alternative Currency'; goBackToState = 'preferencesGlobal'; noColor = true">
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div class="content preferences" ng-controller="preferencesAltCurrencyController as prefAltCurrency">
|
||||
|
||||
<div class="content preferences" ng-controller="preferencesAltCurrencyController">
|
||||
<h4></h4>
|
||||
<ul class="no-bullet m0 ">
|
||||
<li ng-repeat="altCurrency in prefAltCurrency.alternativeOpts" ng-click="prefAltCurrency.save(altCurrency)">
|
||||
<span>{{altCurrency.name}}</span>
|
||||
<i class="fi-check size-16 right" ng-show="altCurrency.name == prefAltCurrency.selectedAlternative.name"></i>
|
||||
</li>
|
||||
<ul>
|
||||
</div>
|
||||
<div class="extra-margin-bottom"></div>
|
||||
|
||||
<ion-radio class="line-b size-12" ng-repeat="altCurrency in altCurrencyList" ng-value="altCurrency" ng-model="currentCurrency"
|
||||
ng-click="save(altCurrency)">{{altCurrency.name}}
|
||||
</ion-radio>
|
||||
</div>
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue