Fix Addressbook

This commit is contained in:
Gustavo Maximiliano Cortez 2015-02-18 16:38:43 -03:00
commit 17a70c1d50
2 changed files with 24 additions and 9 deletions

View file

@ -534,7 +534,8 @@ angular.module('copayApp.controllers').controller('SendController',
};
$scope.cancel = function(form) {
$scope.error = $scope.success = null;
$scope.error = $scope.success = $scope.newaddress = $scope.newlabel = null;
clearForm(form);
$scope.toggleForm();
};
@ -542,11 +543,23 @@ angular.module('copayApp.controllers').controller('SendController',
$scope.showForm = !$scope.showForm;
};
var clearForm = function(form) {
form.newaddress.$pristine = true;
form.newaddress.$setViewValue('');
form.newaddress.$render();
form.newlabel.$pristine = true;
form.newlabel.$setViewValue('');
form.newlabel.$render();
form.$setPristine();
};
// TODO change to modal
$scope.submitAddressBook = function(form) {
if (form.$invalid) {
return;
}
$scope.loading = true;
$timeout(function() {
var errorMsg;
var entry = {
@ -563,11 +576,13 @@ angular.module('copayApp.controllers').controller('SendController',
if (errorMsg) {
$scope.error = errorMsg;
} else {
clearForm(form);
$scope.toggleForm();
notification.success('Entry created', 'New addressbook entry created')
}
$scope.loading = false;
$rootScope.$digest();
}, 1);
}, 100);
return;
};