From 17a70c1d5084218a4c6289d11a623c8d0f8f50a0 Mon Sep 17 00:00:00 2001 From: Gustavo Maximiliano Cortez Date: Wed, 18 Feb 2015 16:38:43 -0300 Subject: [PATCH] Fix Addressbook --- js/controllers/send.js | 19 +++++++++++++++++-- views/modals/address-book.html | 14 +++++++------- 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/js/controllers/send.js b/js/controllers/send.js index ad3e861b5..37282e913 100644 --- a/js/controllers/send.js +++ b/js/controllers/send.js @@ -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; }; diff --git a/views/modals/address-book.html b/views/modals/address-book.html index bb733ddb5..3c2f6bfe4 100644 --- a/views/modals/address-book.html +++ b/views/modals/address-book.html @@ -42,9 +42,9 @@ - -
-
+
@@ -75,14 +75,14 @@ placeholder="{{'Label'|translate}}" ng-model="newlabel" required>
- Cancel + Cancel -
-