Wallet/src/js/controllers/preferencesAlias.js

33 lines
1.1 KiB
JavaScript

'use strict';
angular.module('copayApp.controllers').controller('preferencesAliasController',
function($scope, $timeout, $stateParams, $ionicHistory, gettextCatalog, configService, profileService, walletService) {
var wallet = profileService.getWallet($stateParams.walletId);
var walletId = wallet.credentials.walletId;
var config = configService.getSync();
$scope.walletName = wallet.credentials.walletName;
$scope.alias = {
value: (config.aliasFor && config.aliasFor[walletId]) || wallet.credentials.walletName
};
$scope.save = function() {
var opts = {
aliasFor: {}
};
opts.aliasFor[walletId] = $scope.alias.value;
configService.set(opts, function(err) {
if (err) $log.warn(err);
$ionicHistory.goBack();
});
};
$scope.valueCheck = function() {
if ($scope.alias.value == wallet.credentials.walletName || $scope.alias.value == '') $scope.disableSave = true;
else $scope.disableSave = false;
};
$scope.$watch('alias.value', function(newvalue, oldvalue) {
$scope.valueCheck();
});
});