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
|
<div class="topbar-container" ng-include="'views/includes/topbar.html'"
|
||||||
class="topbar-container"
|
|
||||||
ng-include="'views/includes/topbar.html'"
|
|
||||||
ng-init="titleSection='Alternative Currency'; goBackToState = 'preferencesGlobal'; noColor = true">
|
ng-init="titleSection='Alternative Currency'; goBackToState = 'preferencesGlobal'; noColor = true">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="content preferences" ng-controller="preferencesAltCurrencyController">
|
||||||
|
|
||||||
<div class="content preferences" ng-controller="preferencesAltCurrencyController as prefAltCurrency">
|
|
||||||
|
|
||||||
<h4></h4>
|
<h4></h4>
|
||||||
<ul class="no-bullet m0 ">
|
|
||||||
<li ng-repeat="altCurrency in prefAltCurrency.alternativeOpts" ng-click="prefAltCurrency.save(altCurrency)">
|
<ion-radio class="line-b size-12" ng-repeat="altCurrency in altCurrencyList" ng-value="altCurrency" ng-model="currentCurrency"
|
||||||
<span>{{altCurrency.name}}</span>
|
ng-click="save(altCurrency)">{{altCurrency.name}}
|
||||||
<i class="fi-check size-16 right" ng-show="altCurrency.name == prefAltCurrency.selectedAlternative.name"></i>
|
</ion-radio>
|
||||||
</li>
|
</div>
|
||||||
<ul>
|
|
||||||
</div>
|
|
||||||
<div class="extra-margin-bottom"></div>
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,39 +1,31 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
angular.module('copayApp.controllers').controller('preferencesAltCurrencyController',
|
angular.module('copayApp.controllers').controller('preferencesAltCurrencyController',
|
||||||
function($scope, $timeout, $log, configService, rateService, lodash, go, profileService, walletService) {
|
function($scope, $log, configService, rateService, lodash, go, profileService, walletService) {
|
||||||
this.hideAdv = true;
|
|
||||||
this.hidePriv = true;
|
|
||||||
this.hideSecret = true;
|
|
||||||
this.error = null;
|
|
||||||
this.success = null;
|
|
||||||
|
|
||||||
var config = configService.getSync();
|
var config = configService.getSync();
|
||||||
|
|
||||||
this.selectedAlternative = {
|
$scope.currentCurrency = {
|
||||||
name: config.wallet.settings.alternativeName,
|
name: config.wallet.settings.alternativeName,
|
||||||
isoCode: config.wallet.settings.alternativeIsoCode
|
isoCode: config.wallet.settings.alternativeIsoCode
|
||||||
};
|
};
|
||||||
|
|
||||||
this.alternativeOpts = [this.selectedAlternative]; //default value
|
|
||||||
|
|
||||||
var self = this;
|
|
||||||
rateService.whenAvailable(function() {
|
rateService.whenAvailable(function() {
|
||||||
self.alternativeOpts = rateService.listAlternatives();
|
$scope.altCurrencyList = rateService.listAlternatives();
|
||||||
lodash.remove(self.alternativeOpts, function(n) {
|
|
||||||
return n.isoCode == 'BTC';
|
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();
|
$scope.$digest();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$scope.save = function(newAltCurrency) {
|
||||||
this.save = function(newAltCurrency) {
|
|
||||||
var opts = {
|
var opts = {
|
||||||
wallet: {
|
wallet: {
|
||||||
settings: {
|
settings: {
|
||||||
|
|
@ -42,23 +34,14 @@ angular.module('copayApp.controllers').controller('preferencesAltCurrencyControl
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
this.selectedAlternative = {
|
|
||||||
name: newAltCurrency.name,
|
|
||||||
isoCode: newAltCurrency.isoCode,
|
|
||||||
};
|
|
||||||
|
|
||||||
configService.set(opts, function(err) {
|
configService.set(opts, function(err) {
|
||||||
if (err) $log.warn(err);
|
if (err) $log.warn(err);
|
||||||
go.preferencesGlobal();
|
go.preferencesGlobal();
|
||||||
$scope.$emit('Local/UnitSettingUpdated');
|
$scope.$emit('Local/UnitSettingUpdated');
|
||||||
walletService.updateRemotePreferences(profileService.walletClients, {}, function() {
|
walletService.updateRemotePreferences(profileService.getClients(), {}, function() {
|
||||||
$log.debug('Remote preferences saved');
|
$log.debug('Remote preferences saved');
|
||||||
});
|
});
|
||||||
$timeout(function() {
|
|
||||||
$scope.$apply();
|
|
||||||
}, 100);
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue