From d719697c3037c10850f1bd606998240930898d72 Mon Sep 17 00:00:00 2001 From: Matias Alejo Garcia Date: Thu, 4 Dec 2014 23:32:02 -0300 Subject: [PATCH] fix form binding --- js/controllers/createProfile.js | 50 +++++++-- views/createProfile.html | 180 +++++++++++++++++++------------- 2 files changed, 148 insertions(+), 82 deletions(-) diff --git a/js/controllers/createProfile.js b/js/controllers/createProfile.js index 92c3569f8..87ae5ba1a 100644 --- a/js/controllers/createProfile.js +++ b/js/controllers/createProfile.js @@ -8,6 +8,9 @@ angular.module('copayApp.controllers').controller('CreateProfileController', fun identityService.goWalletHome(); $scope.isMobile = isMobile.any(); + $scope.createStep = 'storage'; + $scope.useLocalstorage = false; + pinService.makePinInput($scope, 'newpin', function(newValue) { _firstpin = newValue; $scope.askForPin = 2; @@ -47,10 +50,37 @@ angular.module('copayApp.controllers').controller('CreateProfileController', fun }); }; + + $scope.setStorage = function(useLocalstorage) { + console.log('[createProfile.js.53:useLocalstorage:]', useLocalstorage); //TODO + console.log('[createProfile.js.53:useLocalstorage:]', $scope.useLocalstorage); //TODO + //settingsService.save({...}) + $scope.createStep = 'email'; + $scope.useEmail = !useLocalstorage; + $scope.useLocalstorage = useLocalstorage; + $timeout(function() { + $scope.$digest(); + }, 1); + }; + + $scope.setEmailOrUsername = function(form) { + console.log('[createProfile.js.53:useLocalstorage:]', $scope.useLocalstorage); //TODO + + $scope.userOrEmail = $scope.useLocalstorage ? form.username.$modelValue : form.email.$modelValue; + preconditions.checkState($scope.userOrEmail); + + $scope.createStep = 'pass'; + $timeout(function() { + $scope.$digest(); + }, 1); + }; + + + $scope.createDefaultWallet = function() { $rootScope.hideNavigation = false; identityService.createDefaultWallet(function(err) { - $scope.askForPin =0 ; + $scope.askForPin = 0; $scope.loading = false; if (err) { @@ -67,7 +97,7 @@ angular.module('copayApp.controllers').controller('CreateProfileController', fun return; } $scope.loading = true; - identityService.create(form.email.$modelValue, form.password.$modelValue, function(err) { + identityService.create( $scope.userOrEmail, form.password.$modelValue, function(err) { $scope.loading = false; if (err) { @@ -76,15 +106,13 @@ angular.module('copayApp.controllers').controller('CreateProfileController', fun msg = 'This profile already exists' } $timeout(function() { - form.email.$setViewValue(''); - form.email.$render(); - form.password.$setViewValue(''); - form.password.$render(); - form.repeatpassword.$setViewValue(''); - form.repeatpassword.$render(); - form.$setPristine(); - $scope.error = msg; - },1); + form.password.$setViewValue(''); + form.password.$render(); + form.repeatpassword.$setViewValue(''); + form.repeatpassword.$render(); + form.$setPristine(); + $scope.error = msg; + }, 1); $scope.error = msg; } else { $scope.error = null; diff --git a/views/createProfile.html b/views/createProfile.html index 24bd03951..a22211557 100644 --- a/views/createProfile.html +++ b/views/createProfile.html @@ -36,109 +36,148 @@ -
- - + + + +
-
+
+
Access your wallets anywhere
-
+
+
Backups managed by the server
-
+
+
Email address confirmation needed
- - +
+ +
+ +
-
- Access your wallets anywhere +
+
+ Todo1
-
- Backups managed by the server +
+
+ Todo2
-
- Email address confirmation needed +
+
+ Todo3
- - - +
+ +
+
+ + -
+
-
- - - Not valid - - -
- -
- - -
+ + +
[x] Creating in this device
+
[x] Creating in the cloud
+ +
+ + + Not valid + + +
+ +
+ + +
+
+ + +
- -
+ -
- - +> + + + +
+ +
[x] Creating in this device
+
[x] Creating in the cloud
+
-> {{userOrEmail}}
+ + +
+ + +
+
- + {{'Passwords must match'|translate}} - +
-
+
- + + - - @@ -173,15 +212,14 @@
-
- +