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

Commit 35837c5

Browse files
author
Parth Shah
committed
Merge branch 'dev' of github.com:appirio-tech/topcoder-app into dev
2 parents 5929557 + 0fb2c56 commit 35837c5

File tree

5 files changed

+44
-21
lines changed

5 files changed

+44
-21
lines changed

app/settings/account-info/account-info.controller.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,13 @@
1515
accountInfoForm: false,
1616
newPasswordForm: false
1717
};
18+
var originalUserData = userData;
1819

1920
activate();
2021

2122
function activate() {
22-
processData();
23-
vm.userData = userData;
23+
vm.userData = userData.clone();
24+
processData(vm.userData);
2425
UserService.getUserProfile({fields: 'credential'})
2526
.then(function(res) {
2627
vm.isSocialRegistrant = !res.credential.hasPassword;
@@ -31,7 +32,7 @@
3132
});
3233

3334
vm.countries = ISO3166.getAllCountryObjects();
34-
vm.countryObj = ISO3166.getCountryObjFromAlpha3(userData.homeCountryCode);
35+
vm.countryObj = ISO3166.getCountryObjFromAlpha3(vm.userData.homeCountryCode);
3536

3637
// Timeout needed since newPasswordForm.currentPassword doesn't exist until later
3738
$timeout(function(){
@@ -53,7 +54,7 @@
5354
var isValidCountry = _.isUndefined(countryCode) ? false : true;
5455
vm.accountInfoForm.country.$setValidity('required', isValidCountry);
5556
if (isValidCountry) {
56-
userData.homeCountryCode = countryCode;
57+
vm.userData.homeCountryCode = countryCode;
5758
}
5859
}
5960

@@ -69,19 +70,20 @@
6970

7071
function saveAccountInfo() {
7172
vm.formProcessing.accountInfoForm = true;
72-
userData.addresses = getAddr();
73-
ProfileService.updateUserProfile(userData)
73+
vm.userData.addresses = getAddr();
74+
ProfileService.updateUserProfile(vm.userData)
7475
.then(function(data) {
7576
vm.formProcessing.accountInfoForm = false;
7677
toaster.pop('success', "Success!", "Your account information was updated.");
78+
for (var k in vm.userData) userData[k] = vm.userData[k];
7779
})
7880
.catch(function() {
7981
vm.formProcessing.accountInfoForm = false;
8082
toaster.pop('error', "Whoops!", "Something went wrong. Please try again later.");
8183
})
8284
}
8385

84-
function processData() {
86+
function processData(userData) {
8587
vm.homeAddress = _.find(userData.addresses, {type: 'HOME'}) || {};
8688
}
8789

app/settings/account-info/account-info.jade

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,13 @@
9595
placeholder="123 Topcoder Ave.",
9696
value="{{vm.homeAddress.streetAddr1}}",
9797
ng-model="vm.homeAddress.streetAddr1",
98-
ng-class="{'form-field-focused': hasFocus==true}"
98+
ng-class="{'form-field-focused': hasFocus==true}",
99+
ng-required="vm.addressDirty = vm.accountInfoForm.address.$dirty || vm.accountInfoForm.city.$dirty || vm.accountInfoForm.state.$dirty || vm.accountInfoForm.zipcode.$dirty || vm.accountInfoForm.country.$dirty"
99100
)
100101

102+
.account-info-error(ng-show="vm.addressDirty && vm.accountInfoForm.address.$invalid")
103+
p(ng-show="vm.accountInfoForm.address.$error.required") Please enter an address
104+
101105
.form-label Address 2
102106
span(style="text-transform: none;")  (opt., suite, etc.)
103107
input.form-field(
@@ -115,27 +119,39 @@
115119
value="{{vm.homeAddress.city}}",
116120
placeholder="Best City in the World",
117121
ng-model="vm.homeAddress.city",
118-
ng-class="{'form-field-focused': hasFocus==true}"
122+
ng-class="{'form-field-focused': hasFocus==true}",
123+
ng-required="vm.addressDirty"
119124
)
120125

126+
.account-info-error(ng-show="vm.addressDirty && vm.accountInfoForm.city.$invalid")
127+
p(ng-show="vm.accountInfoForm.city.$error.required") Please enter a city
128+
121129
.form-label State/Province
122130
input.form-field(
123131
name="state", type="text",
124132
value="{{vm.homeAddress.stateCode}}",
125133
placeholder="California",
126134
ng-model="vm.homeAddress.stateCode",
127-
ng-class="{'form-field-focused': hasFocus==true}"
135+
ng-class="{'form-field-focused': hasFocus==true}",
136+
ng-required="vm.addressDirty"
128137
)
129138

139+
.account-info-error(ng-show="vm.addressDirty && vm.accountInfoForm.state.$invalid")
140+
p(ng-show="vm.accountInfoForm.state.$error.required") Please enter a state or province
141+
130142
.form-label Zip
131143
input.form-field(
132144
name="zipcode", type="text",
133145
placeholder="Zip"
134146
value="{{vm.homeAddress.zip}}",
135147
ng-model="vm.homeAddress.zip",
136-
ng-class="{'form-field-focused': hasFocus==true}"
148+
ng-class="{'form-field-focused': hasFocus==true}",
149+
ng-required="vm.addressDirty"
137150
)
138151

152+
.account-info-error(ng-show="vm.addressDirty && vm.accountInfoForm.zipcode.$invalid")
153+
p(ng-show="vm.accountInfoForm.zipcode.$error.required") Please enter a zip
154+
139155
.form-label Country
140156
angucomplete-alt(
141157
input-name="country",
@@ -148,9 +164,10 @@
148164
title-field="name",
149165
match-class="angucomplete-highlight",
150166
minlength="1",
151-
ng-class="{'form-field-focused': hasFocus==true}"
167+
ng-class="{'form-field-focused': hasFocus==true}",
168+
field-required="vm.addressDirty"
152169
)
153-
.account-info-error(ng-show="vm.accountInfoForm.country.$invalid")
170+
.account-info-error(ng-show="vm.addressDirty && vm.accountInfoForm.country.$error.required")
154171
p(ng-show="vm.accountInfoForm.country.$error.required") Please choose a country from the list.
155172

156173

app/settings/edit-profile/edit-profile.controller.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
activate();
1919

2020
function activate() {
21+
vm.userData = userData.clone();
2122
vm.linkedExternalAccounts = [];
2223
vm.linkedExternalAccountsData = {};
2324
vm.skills = false;
@@ -26,12 +27,11 @@
2627
vm.tracks = {};
2728

2829
vm.countries = ISO3166.getAllCountryObjects();
29-
vm.countryObj = ISO3166.getCountryObjFromAlpha3(userData.competitionCountryCode);
30+
vm.countryObj = ISO3166.getCountryObjFromAlpha3(vm.userData.competitionCountryCode);
3031

31-
processData(userData);
32-
vm.userData = userData;
32+
processData(vm.userData);
3333

34-
ExternalAccountService.getLinkedExternalAccounts(userData.userId).then(function(data) {
34+
ExternalAccountService.getLinkedExternalAccounts(vm.userData.userId).then(function(data) {
3535
vm.linkedExternalAccounts = data;
3636
});
3737

@@ -114,6 +114,7 @@
114114
vm.profileFormProcessing = false;
115115
$log.info('Saved successfully');
116116
toaster.pop('success', "Success!", "Your account information was updated.");
117+
for (var k in vm.userData) userData[k] = vm.userData[k];
117118
})
118119
.catch(function(err) {
119120
vm.profileFormProcessing = false;
@@ -128,9 +129,9 @@
128129

129130
function processData(userInfo) {
130131
vm.tracks = {
131-
DESIGN: _.contains(userData.tracks, 'DESIGN'),
132-
DEVELOP: _.contains(userData.tracks, 'DEVELOP'),
133-
DATA_SCIENCE: _.contains(userData.tracks, 'DATA_SCIENCE'),
132+
DESIGN: _.contains(userInfo.tracks, 'DESIGN'),
133+
DEVELOP: _.contains(userInfo.tracks, 'DEVELOP'),
134+
DATA_SCIENCE: _.contains(userInfo.tracks, 'DATA_SCIENCE'),
134135
};
135136
}
136137
}

assets/css/settings/account-info.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
.account-info-container {
55
padding-bottom: 75px;
66

7+
.account-info-error {
8+
color: #ef3a3a;
9+
}
10+
711
.section-fields {
812
margin-top: 20px;
913
}

assets/css/settings/settings.scss

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,6 @@
215215
.skills {
216216
.section-fields {
217217
margin-top: 20px;
218-
width: 100%;
219218
display: flex;
220219
flex-direction: column;
221220

0 commit comments

Comments
 (0)