search box for currency
This commit is contained in:
parent
11f063b85d
commit
39a2c80133
2 changed files with 32 additions and 11 deletions
|
|
@ -12,23 +12,36 @@ angular.module('copayApp.controllers').controller('preferencesAltCurrencyControl
|
||||||
isoCode: 'BTC'
|
isoCode: 'BTC'
|
||||||
}];
|
}];
|
||||||
|
|
||||||
var config = configService.getSync();
|
function init() {
|
||||||
$scope.currentCurrency = config.wallet.settings.alternativeIsoCode;
|
var config = configService.getSync();
|
||||||
|
$scope.currentCurrency = config.wallet.settings.alternativeIsoCode;
|
||||||
|
|
||||||
rateService.whenAvailable(function() {
|
rateService.whenAvailable(function() {
|
||||||
storageService.getLastCurrencyUsed(function(err, lastUsedAltCurrency) {
|
storageService.getLastCurrencyUsed(function(err, lastUsedAltCurrency) {
|
||||||
|
|
||||||
$scope.lastUsedAltCurrencyList = JSON.parse(lastUsedAltCurrency) || [];
|
$scope.lastUsedAltCurrencyList = JSON.parse(lastUsedAltCurrency) || [];
|
||||||
|
|
||||||
var idx = lodash.indexBy(unusedCurrencyList, 'isoCode');
|
var idx = lodash.indexBy(unusedCurrencyList, 'isoCode');
|
||||||
var idx2 = lodash.indexBy($scope.lastUsedAltCurrencyList, 'isoCode');
|
var idx2 = lodash.indexBy($scope.lastUsedAltCurrencyList, 'isoCode');
|
||||||
|
|
||||||
completeAlternativeList = lodash.reject(rateService.listAlternatives(), function(c) {
|
$scope.completeAlternativeList = lodash.reject(rateService.listAlternatives(), function(c) {
|
||||||
return idx[c.isoCode] || idx2[c.isoCode];
|
return idx[c.isoCode] || idx2[c.isoCode];
|
||||||
|
});
|
||||||
|
$scope.altCurrencyList = $scope.completeAlternativeList;
|
||||||
});
|
});
|
||||||
$scope.altCurrencyList = completeAlternativeList;
|
|
||||||
});
|
});
|
||||||
});
|
}
|
||||||
|
|
||||||
|
$scope.findCurrency = function(search) {
|
||||||
|
if (!search) init();
|
||||||
|
$scope.altCurrencyList = lodash.filter($scope.completeAlternativeList, function(item) {
|
||||||
|
var val = item.name;
|
||||||
|
return lodash.includes(val.toLowerCase(), search.toLowerCase());
|
||||||
|
});
|
||||||
|
$timeout(function() {
|
||||||
|
$scope.$apply();
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
$scope.save = function(newAltCurrency) {
|
$scope.save = function(newAltCurrency) {
|
||||||
var opts = {
|
var opts = {
|
||||||
|
|
@ -58,4 +71,5 @@ angular.module('copayApp.controllers').controller('preferencesAltCurrencyControl
|
||||||
storageService.setLastCurrencyUsed(JSON.stringify($scope.lastUsedAltCurrencyList), function() {});
|
storageService.setLastCurrencyUsed(JSON.stringify($scope.lastUsedAltCurrencyList), function() {});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
init();
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,13 @@
|
||||||
</ion-nav-back-button>
|
</ion-nav-back-button>
|
||||||
</ion-nav-bar>
|
</ion-nav-bar>
|
||||||
<ion-content>
|
<ion-content>
|
||||||
|
<div class="bar bar-header item-input-inset">
|
||||||
|
<label class="item-input-wrapper">
|
||||||
|
<i class="icon ion-ios-search placeholder-icon"></i>
|
||||||
|
<input type="search" ng-init="searchedAltCurrency = ''" ng-model="searchedAltCurrency" ng-change="findCurrency(searchedAltCurrency)"
|
||||||
|
placeholder="{{'Search your currency' | translate}}">
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
<div class="list" ng-if="lastUsedAltCurrencyList[0]">
|
<div class="list" ng-if="lastUsedAltCurrencyList[0]">
|
||||||
<ion-radio ng-repeat="lastUsedAltCurrency in lastUsedAltCurrencyList" ng-value="lastUsedAltCurrency.isoCode" ng-model="currentCurrency"
|
<ion-radio ng-repeat="lastUsedAltCurrency in lastUsedAltCurrencyList" ng-value="lastUsedAltCurrency.isoCode" ng-model="currentCurrency"
|
||||||
ng-click="save(lastUsedAltCurrency)">{{lastUsedAltCurrency.name}}
|
ng-click="save(lastUsedAltCurrency)">{{lastUsedAltCurrency.name}}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue