From a4c16a94a595bb99a08e57e5c4f442ec9adf2fa3 Mon Sep 17 00:00:00 2001 From: Gustavo Cortez Date: Tue, 6 May 2014 14:39:16 -0300 Subject: [PATCH] Signin page: * Swap places for "join" and "create/open" (#285). * Prevent the user not set the password and required fields (#280). --- css/main.css | 3 --- index.html | 42 +++++++++++++++++++++++----------------- js/controllers/signin.js | 36 ++++++++++++++++++++++------------ 3 files changed, 48 insertions(+), 33 deletions(-) diff --git a/css/main.css b/css/main.css index 6108e8a29..779713c4f 100644 --- a/css/main.css +++ b/css/main.css @@ -267,9 +267,6 @@ hr { margin: 2.25rem 0;} .lh {line-height: 0;} .oh {overflow:hidden;} .lh {line-height: 0;} -.signin input.ng-dirty.ng-invalid { - border: 2px red solid; -} .video-small { width: 80px; diff --git a/index.html b/index.html index 9994794a6..8d308e0d6 100644 --- a/index.html +++ b/index.html @@ -143,38 +143,44 @@
-
- -
-
+
+
+ +
diff --git a/js/controllers/signin.js b/js/controllers/signin.js index 04eedc1c7..6eee392b0 100644 --- a/js/controllers/signin.js +++ b/js/controllers/signin.js @@ -7,25 +7,37 @@ angular.module('copay.signin').controller('SigninController', $scope.selectedWalletId = $scope.wallets.length ? $scope.wallets[0].id : null; $scope.openPassword = ''; - $scope.create = function() { - $scope.loading = true; + $scope.create = function(form) { + if (form) { + if (form.$invalid) { + $rootScope.flashMessage = { message: 'Please, enter required fields', type: 'error'}; + return; + } - $rootScope.walletName = $scope.walletName; - $rootScope.walletPassword = $scope.createPassword; + $rootScope.walletName = form.walletName.$modelValue; + $rootScope.walletPassword = form.createPassword.$modelValue; + } $location.path('setup'); }; - $scope.open = function() { - if ($scope.openPassword != '') { - $scope.loading = true; - - var passphrase = Passphrase.getBase64($scope.openPassword); - var w = walletFactory.open($scope.selectedWalletId, { passphrase: passphrase}); - controllerUtils.startNetwork(w); + $scope.open = function(form) { + if (form.$invalid) { + $rootScope.flashMessage = { message: 'Please, enter required fields', type: 'error'}; + return; } + $scope.loading = true; + var password = form.openPassword.$modelValue; + + var passphrase = Passphrase.getBase64(password); + var w = walletFactory.open($scope.selectedWalletId, { passphrase: passphrase}); + controllerUtils.startNetwork(w); }; - $scope.join = function() { + $scope.join = function(form) { + if (form.$invalid) { + $rootScope.flashMessage = { message: 'Please, enter required fields', type: 'error'}; + return; + } $scope.loading = true; walletFactory.network.on('badSecret', function() {