Skip to content
This repository was archived by the owner on Mar 4, 2025. It is now read-only.

Commit 29b8342

Browse files
author
Nick Litwin
committed
Merge branch 'dev' into feature/tc-ui-kit-integration
2 parents 0dd8584 + 5091765 commit 29b8342

File tree

7 files changed

+55
-33
lines changed

7 files changed

+55
-33
lines changed

app/account/register/register.jade

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@
3434
minlength="1"
3535
)
3636

37-
.form-errors
38-
p.form-error(ng-show="vm.registerForm.country.$error.required") Please choose a country from the list
37+
.form-input-error(ng-show="vm.registerForm.country.$dirty && vm.registerForm.country.$invalid", ng-messages="vm.registerForm.country.$error")
38+
p.form-error(ng-message="required") Please choose a country from the list
3939

4040
.section-break
4141
hr
@@ -53,10 +53,13 @@
5353

5454
p It can contain letters, numbers, and these characters: -_.{}[]
5555

56-
.form-errors
57-
p.form-error(ng-show="vm.registerForm.username.$dirty && vm.registerForm.username.$error.usernameIsFree", ng-bind="vm.usernameErrorMessage")
56+
.form-input-error(ng-if="vm.registerForm.username.$dirty && vm.registerForm.username.$invalid", ng-messages="vm.registerForm.username.$error")
57+
p.form-error(ng-message="required") Please enter a username.
58+
p.form-error(ng-message="usernameIsFree") {{vm.usernameErrorMessage}}
5859

59-
p.form-error(ng-show="vm.registerForm.username.$dirty && (vm.registerForm.username.$error.minlength || vm.registerForm.username.$error.maxlength)") That username is not the correct length or format.
60+
p.form-error(ng-message="minlength") That username is not the correct length or format.
61+
62+
p.form-error(ng-message="maxlength") That username is not the correct length or format.
6063

6164
.validation-bar(ng-class="{ 'error-bar': (vm.registerForm.email.$dirty && vm.registerForm.email.$invalid), 'success-bar': (vm.registerForm.email.$valid) }")
6265
input-sticky-placeholder(sticky-placeholder="Email", ng-model="vm.email")
@@ -69,10 +72,12 @@
6972

7073
p We'll occasionally send you emails related to your activities or interests.
7174

72-
.form-errors
73-
p.form-error(ng-show="vm.registerForm.email.$dirty && (vm.registerForm.email.$error.emailIsAvailable || vm.registerForm.email.$error.validEmail)", ng-bind="vm.emailErrorMessage")
75+
.form-input-error(ng-show="vm.registerForm.email.$dirty && vm.registerForm.email.$invalid", ng-messages="vm.registerForm.email.$error")
76+
p.form-error(ng-message="emailIsAvailable") {{vm.emailErrorMessage}}
77+
78+
p.form-error(ng-message="validEmail") {{vm.emailErrorMessage}}
7479

75-
p.form-error(ng-show="vm.registerForm.email.$dirty && vm.registerForm.email.$error.required") Please enter an email address.
80+
p.form-error(ng-message="required") Please enter an email address.
7681

7782
.validation-bar(ng-class="{ 'success-bar': (vm.registerForm.password.$valid) }")
7883
toggle-password-with-tips(ng-if="!vm.isSocialRegistration")

app/index.jade

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ html
107107
script(src='../bower_components/intro.js/intro.js')
108108
script(src='../bower_components/angular-intro.js/src/angular-intro.js')
109109
script(src='../bower_components/angular-jwt/dist/angular-jwt.js')
110+
script(src='../bower_components/angular-messages/angular-messages.js')
110111
script(src='../bower_components/angular-sanitize/angular-sanitize.js')
111112
script(src='../bower_components/angular-ui-router/release/angular-ui-router.js')
112113
script(src='../bower_components/x2js/xml2json.min.js')

app/profile/about/about.controller.js

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33

44
angular.module('tc.profile').controller('ProfileAboutController', ProfileAboutController);
55

6-
ProfileAboutController.$inject = ['$log', '$scope', 'ProfileService', 'ExternalAccountService'];
6+
ProfileAboutController.$inject = ['$log', '$scope', 'ProfileService', 'ExternalAccountService', 'UserService', 'CONSTANTS'];
77

8-
function ProfileAboutController($log, $scope, ProfileService, ExternalAccountService, UserService) {
8+
function ProfileAboutController($log, $scope, ProfileService, ExternalAccountService, UserService, CONSTANTS) {
99
var vm = this;
1010
$log = $log.getInstance("ProfileAboutController");
1111
var profileVm = $scope.$parent.profileVm;
@@ -24,11 +24,35 @@
2424

2525
profileVm.externalLinksPromise.then(function() {
2626
vm.linkedExternalAccountsData = profileVm.linkedExternalAccountsData;
27-
vm.linkedExternalAccounts = profileVm.linkedExternalAccounts;
27+
2828
// show section if user is viewing his/her own profile OR if we have data
29-
vm.hasLinks = vm.linkedExternalAccounts.length;
30-
//vm.hasLinks = _.any(_.valuesIn(_.omit(vm.linkedExternalAccountsData, ['userId', 'updatedAt','createdAt','createdBy','updatedBy','handle'])));
29+
//vm.hasLinks = profileVm.linkedExternalAccounts.length;
30+
vm.hasLinks = _.any(_.valuesIn(_.omit(vm.linkedExternalAccountsData, ['userId', 'updatedAt','createdAt','createdBy','updatedBy','handle'])));
3131
vm.displaySection.externalLinks = profileVm.showEditProfileLink || vm.hasLinks;
32+
33+
// if user is authenticated, call for profiles end point
34+
if (profileVm.isUser) {
35+
var userId = UserService.getUserIdentity().userId;
36+
ExternalAccountService.getLinkedExternalAccounts(userId).then(function(data) {
37+
vm.linkedExternalAccounts = data;
38+
profileVm.status.externalLinks = CONSTANTS.STATE_READY;
39+
}).catch(function(err) {
40+
profileVm.status.externalLinks = CONSTANTS.STATE_ERROR;
41+
});
42+
} else {
43+
vm.linkedExternalAccounts = [];
44+
// remove all keys except the provider keys
45+
var accounts = _.omit(vm.linkedExternalAccountsData, ['userId', 'updatedAt','createdAt','createdBy','updatedBy','handle']);
46+
// populate the externalLinks for external-account-data directive with info from ext accounts data
47+
for(var provider in accounts) {
48+
if (accounts[provider]) {
49+
vm.linkedExternalAccounts.push({
50+
providerType: provider
51+
});
52+
}
53+
}
54+
profileVm.status.externalLinks = CONSTANTS.STATE_READY;
55+
}
3256
});
3357

3458
profileVm.statsPromise.then(function() {

app/profile/profile.controller.js

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33

44
angular.module('tc.profile').controller('ProfileCtrl', ProfileCtrl);
55

6-
ProfileCtrl.$inject = ['CONSTANTS', '$log',
6+
ProfileCtrl.$inject = ['CONSTANTS', '$log', '$q',
77
'TcAuthService', 'UserService', 'ProfileService', 'ChallengeService', 'ExternalAccountService',
88
'userHandle', 'profile', 'ngDialog'
99
];
1010

11-
function ProfileCtrl(CONSTANTS, $log, TcAuthService, UserService, ProfileService, ChallengeService, ExternalAccountService, userHandle, profile, ngDialog) {
11+
function ProfileCtrl(CONSTANTS, $log, $q, TcAuthService, UserService, ProfileService, ChallengeService, ExternalAccountService, userHandle, profile, ngDialog) {
1212
var vm = this;
1313
// set profile to the object that was resolved
1414
vm.profile = profile;
@@ -58,17 +58,12 @@
5858
});
5959

6060

61-
vm.externalLinksPromise = ExternalAccountService.getLinkedExternalAccounts(profile.userId).then(function(data) {
62-
vm.linkedExternalAccounts = data;
63-
vm.status.externalLinks = CONSTANTS.STATE_READY;
61+
vm.externalLinksPromise = ExternalAccountService.getLinkedExternalLinksData(vm.userHandle).then(function(data) {
62+
vm.linkedExternalAccountsData = data.plain();
6463
}).catch(function(err) {
6564
vm.status.externalLinks = CONSTANTS.STATE_ERROR;
6665
});
6766

68-
ExternalAccountService.getLinkedExternalLinksData(vm.userHandle).then(function(data) {
69-
vm.linkedExternalAccountsData = data.plain();
70-
});
71-
7267
function activate() {
7368
$log.debug('Calling ProfileController activate()');
7469
// show edit profile link if user is authenticated and is viewing their own profile

app/topcoder.module.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@
2828
'CONSTANTS',
2929
'dcbImgFallback',
3030
'toaster',
31-
'angular-intro'
31+
'angular-intro',
32+
'ngMessages'
3233
];
3334

3435
angular.module('topcoder', dependencies).run(appRun);

assets/css/account/register.scss

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,12 @@
9292
}
9393
}
9494
}
95-
9695
.section-break {
97-
display: none;
96+
97+
hr {
98+
max-width: 180px;
99+
margin: 10px auto 20px auto;
100+
}
98101
}
99102
}
100103

@@ -129,14 +132,6 @@
129132
flex-direction: column;
130133
width: 100%;
131134
}
132-
.section-break {
133-
display: block;
134-
135-
hr {
136-
max-width: 180px;
137-
margin: 10px auto 20px auto;
138-
}
139-
}
140135
}
141136

142137
section.social {

bower.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
"angular-img-fallback": "~0.1.3",
3333
"angular-intro.js": "~1.3.0",
3434
"angular-jwt": "~0.0.9",
35+
"angular-messages": "~1.4.7",
3536
"angular-sanitize": "1.4.x",
3637
"angular-ui-router": "~0.2.15",
3738
"angular-xml": "~2.1.1",

0 commit comments

Comments
 (0)