Wallet/src/js/controllers/preferencesAlias.js

33 lines
1.1 KiB
JavaScript
Raw Normal View History

2015-05-14 10:39:22 -03:00
'use strict';
angular.module('copayApp.controllers').controller('preferencesAliasController',
function($scope, $timeout, $stateParams, $ionicHistory, gettextCatalog, configService, profileService, walletService) {
2016-08-17 15:53:17 -03:00
var wallet = profileService.getWallet($stateParams.walletId);
var walletId = wallet.credentials.walletId;
2015-05-14 10:39:22 -03:00
var config = configService.getSync();
2016-08-17 15:53:17 -03:00
$scope.walletName = wallet.credentials.walletName;
2016-09-23 13:30:58 -03:00
$scope.alias = {
value: (config.aliasFor && config.aliasFor[walletId]) || wallet.credentials.walletName
};
2015-05-14 10:39:22 -03:00
$scope.save = function() {
2015-05-14 10:39:22 -03:00
var opts = {
aliasFor: {}
};
2016-09-23 13:30:58 -03:00
opts.aliasFor[walletId] = $scope.alias.value;
2015-05-14 10:39:22 -03:00
configService.set(opts, function(err) {
2016-08-17 15:53:17 -03:00
if (err) $log.warn(err);
2016-08-29 16:48:15 -03:00
$ionicHistory.goBack();
2015-05-14 10:39:22 -03:00
});
};
$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();
});
2015-05-14 10:39:22 -03:00
});