diff --git a/src/assets/scripts/profile/profile.controller.js b/src/assets/scripts/profile/profile.controller.js index 09eec0a..2c0ddc9 100644 --- a/src/assets/scripts/profile/profile.controller.js +++ b/src/assets/scripts/profile/profile.controller.js @@ -1,6 +1,6 @@ import visas from './visa.type'; /** @ngInject */ -const ProfileController = ($scope, ProfileService, UserService) => { +const ProfileController = ($scope, $timeout, ProfileService, UserService) => { // Load visas in the scope $scope.visas = visas; @@ -24,12 +24,32 @@ const ProfileController = ($scope, ProfileService, UserService) => { * * v1.0 non selective update */ - $scope.updateProfile = () => { + $scope.updateProfile = (ProfileForm) => { + // Trigger validation flag. + $scope.submitted = true; + + // If form is invalid, return and show validation errors. + if (ProfileForm.$invalid) { + return; + } + + ProfileService.updateUserProfile($scope.user.id, $scope.userUpdated) .then((result)=>{ console.log(result); + $scope.messages = 'Your profile has been updated!'; + }) + .catch((err)=> { + console.log(err); + $scope.messages = 'Oops, we received your request, but there was an error processing it.'; }) - .catch((err)=> {console.log(err)}) + .finally(() => { + // Hide status messages after three seconds. + $timeout(() => { + $scope.messages = null; + }, 3000); + }); + } }); diff --git a/src/assets/scripts/profile/profile.html b/src/assets/scripts/profile/profile.html index db2caf4..f1e34d4 100644 --- a/src/assets/scripts/profile/profile.html +++ b/src/assets/scripts/profile/profile.html @@ -29,12 +29,14 @@
+
Your Profile
-
+
First Name - Required! +
@@ -43,7 +45,8 @@
Last Name - Required! +
@@ -51,16 +54,20 @@
Email Address - + Required! + Invalid email! +
Phone Number - Required! +
State of residence in Australia - @@ -74,7 +81,8 @@
Nationality - @@ -273,16 +281,17 @@
Visa Type - -
Language (Select one or more) - @@ -362,19 +371,21 @@
Education - + Required! +
-
-
Main Classification:
- +
Main Classification
+ Required! +
-
Skills:
- +
Skills
+ Required! +
@@ -383,7 +394,6 @@
Illustration
-
@@ -407,8 +417,8 @@
- - + +