diff --git a/public/views/modals/destination-address.html b/public/views/modals/destination-address.html index b59856bb4..8a663d4bb 100644 --- a/public/views/modals/destination-address.html +++ b/public/views/modals/destination-address.html @@ -1,13 +1,13 @@
@@ -81,12 +84,13 @@
  • - Add a new entry + Add a new entry + ({{newAddress}})
  • -
    +

    Add a new entry

    {{error|translate}}
    @@ -107,7 +111,7 @@
    @@ -116,7 +120,7 @@ value="{{'Save'|translate}}" ng-disabled="!addressbookForm.$valid" ng-style="{'background-color':color}" - ng-click="add(addressbook)"> + ng-click="newAddress = ''; add(addressbook)">
    diff --git a/public/views/walletHome.html b/public/views/walletHome.html index d35be98e0..faf16d9ef 100644 --- a/public/views/walletHome.html +++ b/public/views/walletHome.html @@ -322,7 +322,8 @@ diff --git a/src/js/controllers/walletHome.js b/src/js/controllers/walletHome.js index 800e31c5d..5721f7f48 100644 --- a/src/js/controllers/walletHome.js +++ b/src/js/controllers/walletHome.js @@ -136,7 +136,7 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi }); }; - $scope.openDestinationAddressModal = function(wallets, address, label) { + $scope.openDestinationAddressModal = function(wallets, address) { $rootScope.modalOpened = true; var fc = profileService.focusedClient; self.resetForm(); @@ -146,9 +146,29 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi $scope.editAddressbook = false; $scope.addAddressbookEntry = false; $scope.selectedAddressbook = {}; - $scope.addressbook = { 'address' : address, 'label' : label}; + $scope.newAddress = address; + $scope.addressbook = { 'address' : ($scope.newAddress || '') , 'label' : ''}; $scope.color = fc.backgroundColor; + $scope.beforeQrCodeScann = function() { + $scope.error = null; + $scope.addAddressbookEntry = true; + $scope.editAddressbook = false; + }; + + $scope.onQrCodeScanned = function(data, addressbookForm) { + $timeout(function() { + var form = addressbookForm; + if (data && form) { + data = data.replace('bitcoin:', ''); + form.address.$setViewValue(data); + form.address.$isValid = true; + form.address.$render(); + } + $scope.$digest(); + }, 100); + }; + $scope.selectAddressbook = function(addr) { $modalInstance.close(addr); }; @@ -164,6 +184,8 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi }; $scope.toggleAddAddressbookEntry = function() { + $scope.error = null; + $scope.addressbook = { 'address' : ($scope.newAddress || '') , 'label' : ''}; $scope.addAddressbookEntry = !$scope.addAddressbookEntry; };