Merge pull request #177 from gabrielbazan7/fix/preferencesAlias

fix alias
This commit is contained in:
Gustavo Maximiliano Cortez 2016-09-23 13:38:22 -03:00 committed by GitHub
commit aac4fa885b
2 changed files with 6 additions and 4 deletions

View File

@ -11,7 +11,7 @@
<div class="card list"> <div class="card list">
<label class="item item-input item-stacked-label"> <label class="item item-input item-stacked-label">
<span class="input-label" transalate>Alias for {{walletName}}</span> <span class="input-label" transalate>Alias for {{walletName}}</span>
<input type="text" id="alias" name="alias" ng-model="alias" placeholder="John" required> <input type="text" id="alias" name="alias" ng-model="alias.value" placeholder="John" required>
</label> </label>
</div> </div>
<button type="submit" <button type="submit"

View File

@ -3,18 +3,20 @@
angular.module('copayApp.controllers').controller('preferencesAliasController', angular.module('copayApp.controllers').controller('preferencesAliasController',
function($scope, $timeout, $stateParams, $ionicHistory, gettextCatalog, configService, profileService, walletService) { function($scope, $timeout, $stateParams, $ionicHistory, gettextCatalog, configService, profileService, walletService) {
var wallet = profileService.getWallet($stateParams.walletId); var wallet = profileService.getWallet($stateParams.walletId);
$scope.wallet = wallet;
var walletId = wallet.credentials.walletId; var walletId = wallet.credentials.walletId;
var config = configService.getSync(); var config = configService.getSync();
$scope.walletName = wallet.credentials.walletName; $scope.walletName = wallet.credentials.walletName;
$scope.alias = (config.aliasFor && config.aliasFor[walletId]) || wallet.walletName; $scope.alias = {
value: (config.aliasFor && config.aliasFor[walletId]) || wallet.credentials.walletName
};
$scope.save = function() { $scope.save = function() {
var opts = { var opts = {
aliasFor: {} aliasFor: {}
}; };
opts.aliasFor[walletId] = $scope.alias;
opts.aliasFor[walletId] = $scope.alias.value;
configService.set(opts, function(err) { configService.set(opts, function(err) {
if (err) $log.warn(err); if (err) $log.warn(err);