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

Commit 1708a07

Browse files
author
Parth Shah
committed
Merge branch 'dev' of github.com:appirio-tech/topcoder-app into dev
2 parents 1717a22 + 0e0125d commit 1708a07

38 files changed

+320
-194
lines changed

app/account/register/register.controller.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636

3737
var isValidCountry = _.isUndefined(countryCode) ? false : true;
3838
vm.registerForm.country.$setValidity('required', isValidCountry);
39+
vm.isValidCountry = isValidCountry;
3940
if (isValidCountry) {
4041
vm.country = angucompleteCountryObj.originalObject;
4142
}
@@ -103,8 +104,20 @@
103104
var socialData = resp.data;
104105
vm.socialUserId = socialData.socialUserId;
105106
vm.username = socialData.username;
107+
if (socialData.username) {
108+
vm.registerForm.username.$setDirty();
109+
}
106110
vm.firstname = socialData.firstname;
111+
if (socialData.firstname) {
112+
vm.registerForm.firstname.$setDirty();
113+
}
107114
vm.lastname = socialData.lastname;
115+
if (socialData.lastname) {
116+
vm.registerForm.lastname.$setDirty();
117+
}
118+
if (socialData.email) {
119+
vm.registerForm.email.$setDirty();
120+
}
108121
vm.email = socialData.email;
109122
vm.socialProfile = socialData.socialProfile;
110123
vm.socialProvider = socialData.socialProvider;

app/account/register/register.jade

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@
3535
minlength="1"
3636
)
3737

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

4141
.section-break
4242
hr
@@ -97,7 +97,8 @@
9797
section.terms
9898
p By clicking "Join" you agree to Topcoder's #[a(href="http://www.topcoder.com/community/how-it-works/terms/", target="_blank") Terms] and #[a(href="http://www.topcoder.com/community/how-it-works/privacy-policy/", target="_blank") Privacy Policy]
9999

100-
button.tc-btn.tc-btn-large(type="submit", tc-busy-button, tc-busy-when="vm.registering", ng-disabled="vm.registerForm.$invalid") Join
100+
button.tc-btn.tc-btn-large(type="submit", tc-busy-button, tc-busy-when="vm.registering", ng-disabled="vm.registerForm.$invalid", ng-show="vm.isValidCountry") Join
101+
button.tc-btn.tc-btn-large.disabled(type="submit", ng-show="!vm.isValidCountry", disabled="disabled") Join
101102

102103
section.login-options
103104
p.tc-separator

app/directives/busy-button/busy-button.directive.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33

44
angular.module('tcUIComponents').directive('tcBusyButton', tcBusyButton);
55

6-
function tcBusyButton() {
6+
tcBusyButton.$inject = ['$parse'];
7+
8+
function tcBusyButton($parse) {
79
return {
810
restrict: "A",
911
scope: {
@@ -21,7 +23,11 @@
2123
scope);
2224
element.attr('disabled', true).html('').append(busyMessageHtml);
2325
} else {
24-
element.removeAttr('disabled').html(scope.originalContent);
26+
// remove the disabled attribute only if either element does not have ng-disabled set
27+
// or it evaluates to false
28+
if (!attr.ngDisabled || !$parse(attr.ngDisabled)) {
29+
element.removeAttr('disabled').html(scope.originalContent);
30+
}
2531
}
2632
});
2733
}

app/directives/challenge-tile/challenge-tile.directive.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,6 @@
2424
ChallengeService.processPastMarathonMatch($scope.challenge);
2525
}
2626

27-
if ($scope.challenge.status.trim().toUpperCase() === 'COMPLETED' && $scope.challenge.track === 'DESIGN') {
28-
ChallengeService.formatPastDesignChallenge($scope.challenge);
29-
console.log($scope.challenge.plain());
30-
}
3127
}
3228

3329
function openLightbox() {

app/directives/challenge-user-place/challenge-user-place.directive.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
if (!$scope.challenge.isPrivate && $scope.challenge.userDetails.submissions && $scope.challenge.userDetails.submissions.length > 0) {
4747
$scope.selectedIndex = 0;
4848
$scope.challenge.thumbnailId = $scope.challenge.userDetails.submissions[0].id;
49-
$scope.imageURL = $scope.challenge.userDetails.submissions[0].fullImage;
49+
$scope.imageURL = $scope.challenge.userDetails.submissions[0].submissionImage;
5050
$scope.selectedImage = $scope.imageURL;
5151

5252
$scope.challenge.highestPlacement = _.max($scope.challenge.userDetails.submissions, 'placement').placement;

app/directives/challenge-user-place/design-lightbox/design-lightbox.jade

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
.selections
1616
img.selection(
1717
ng-repeat="submission in challenge.userDetails.submissions",
18-
ng-src="{{submission.fullImage}}",
19-
ng-click="updateSelected(submission.fullImage, $index)",
20-
ng-class="{'current': submission.fullImage == selectedImage}"
18+
ng-src="{{submission.submissionImage}}",
19+
ng-click="updateSelected(submission.submissionImage, $index)",
20+
ng-class="{'current': submission.submissionImage == selectedImage}"
2121
)
2222

2323
.right-nav

app/directives/distribution-graph/distribution-graph.directive.jade

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@
1111
.num {{rating}}
1212
.label RATING
1313
button.tc-btn.tc-btn-s.compare(ng-click="graphState.show = 'history'")
14-
| BACK TO YOUR RATING
14+
| View Rating History
1515

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
.ext-tile(ng-repeat="account in accountList | orderBy:'order'", ng-click="!account.disabled && !readOnly && handleClick(account.provider, account.status)", ng-class="{'connected': account.status === 'linked', 'connecting': account.status === 'pending', 'disabled': account.disabled, 'enabled': !account.disabled, 'read-only': readOnly, 'connect': account.status === 'unlinked' && !account.disabled}")
1+
.ext-tile(ng-repeat="account in accountList | orderBy:'order'", ng-click="!account.disabled && !readOnly && handleClick(account.provider, account.status)", ng-class="{'connected': !readOnly && account.status === 'linked', 'connecting': !readOnly && account.status === 'pending', 'disabled': account.disabled, 'enabled': !readOnly && !account.disabled, 'read-only': readOnly, 'connect': !readOnly && account.status === 'unlinked' && !account.disabled}", ng-if="!readOnly || account.featured === true")
22
.external-account-box(ng-class="account.colorClass")
33
i.fa(ng-class="account.className")
44

55
.provider {{account.displayName}}
66

7-
.status.already-connected(ng-if="account.status === 'linked'") Connected
7+
.status.already-connected(ng-if="!readOnly && account.status === 'linked'") Connected
88

9-
.status.already-connected(ng-if="account.status === 'pending'") Connecting
9+
.status.already-connected(ng-if="!readOnly && account.status === 'pending'") Connecting
1010

1111
.status.disconnect Disconnect
1212

13-
.status(ng-if="account.status === 'unlinked' && !account.disabled") Connect
13+
.status(ng-if="!readOnly && account.status === 'unlinked' && !account.disabled") Connect
1414

15-
.status(ng-if="account.disabled") Coming Soon
15+
.status(ng-if="!readOnly && account.disabled") Coming Soon

app/directives/external-account/external-account.directive.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
(function() {
22
'use strict';
33
var _supportedAccounts = [
4-
{ provider: "dribbble", className: "fa-dribbble", displayName: "Dribbble", disabled: false, order: 6, colorClass: 'el-dribble'},
5-
{ provider: "linkedin", className: "fa-linkedin", displayName: "LinkedIn", disabled: true, order: 5, colorClass: 'el-linkedin'},
4+
{ provider: "dribbble", className: "fa-dribbble", displayName: "Dribbble", disabled: false, order: 6, colorClass: 'el-dribble', featured: true},
5+
{ provider: "linkedin", className: "fa-linkedin", displayName: "LinkedIn", disabled: true, order: 5, colorClass: 'el-linkedin', featured: true},
66
{ provider: "stackoverflow", className: "fa-stack-overflow", displayName: "Stack Overflow", disabled: false, order: 3, colorClass: 'el-stackoverflow'},
77
{ provider: "behance", className: "fa-behance", displayName: "Behance", disabled: true, order: 2, colorClass: 'el-behance'},
88
// { provider: "google-oauth2", className: "fa-google-plus", displayName: "Google+", disabled: true, order: }, colorClass: 'el-dribble',
9-
{ provider: "github", className: "fa-github", displayName: "Github", disabled: false, order: 1, colorClass: 'el-github'},
9+
{ provider: "github", className: "fa-github", displayName: "Github", disabled: false, order: 1, colorClass: 'el-github', featured: true},
1010
{ provider: "bitbucket", className: "fa-bitbucket", displayName: "Bitbucket", disabled: false, order: 7, colorClass: 'el-bitbucket'},
1111
{ provider: "twitter", className: "fa-twitter", displayName: "Twitter", disabled: true, order: 4, colorClass: 'el-twitter'},
1212
{ provider: "weblinks", className: "fa-globe", displayName: "Web Links", disabled: true, order: 8, colorClass: 'el-weblinks'}

app/directives/focus-on.directive.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,11 @@
1010
var model = $parse(attr.focusOn);
1111
scope.$watch(model, function(newValue) {
1212
$timeout(function() {
13-
if (newValue !== undefined) {
13+
14+
if (newValue !== undefined && newValue) {
1415
element[0].focus();
16+
} else {
17+
element[0].blur();
1518
}
1619
}, 0);
1720
});

app/directives/history-graph/history-graph.directive.jade

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@
1010
.history-info
1111
.challenge(ng-if="historyRating") {{historyChallenge}}
1212
.date(ng-if="historyRating") {{historyDate | date}}
13-
button.tc-btn.tc-btn-s.compare(ng-click="graphState.show = 'distribution'") COMMUNITY RATINGS
13+
button.tc-btn.tc-btn-s.compare(ng-click="graphState.show = 'distribution'") View Rating Distribution

app/directives/srm-tile/srm-tile.directive.jade

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,9 @@
1515
span.time-zone {{srm.codingStartAt | localTime:"z" }}
1616

1717
.phase-status
18-
.registered(ng-show="vm.registered")
19-
i.fa.fa-check-circle-o
20-
p You are registered!
21-
.unregistered(ng-hide="vm.registered")
22-
button.tc-btn.tc-btn-s.tc-btn-wide.srm-action Register
18+
.registered(ng-show="srm.userStatus === CONSTANTS.REGISTERED") Registered
19+
.unregistered(ng-hide="srm.currentPhase !== CONSTANTS.REGISTRATION || srm.userStatus === CONSTANTS.REGISTERED")
20+
a.tc-btn.tc-btn-s.tc-btn-wide(href="https://community.{{DOMAIN}}/tc?module=MatchDetails&rd={{srm.rounds[0].id}}") Register
2321

2422
.past-srm(ng-show="srm.status === 'PAST'")
2523
.challenge-track
@@ -48,13 +46,11 @@
4846

4947
.srm-details
5048
p.starts-in Starts in #[span {{srm.codingStartAt | timeDiff:"quantity"}} {{srm.codingStartAt | timeDiff:'unit'}}]
51-
49+
5250
.phase-status
53-
.registered(ng-show="vm.registered")
54-
i.fa.fa-check-circle-o
55-
p You are registered!
56-
.unregistered(ng-hide="vm.registered")
57-
button.tc-btn.tc-btn-s.tc-btn-wide.srm-action Register
51+
.registered(ng-show="srm.userStatus === CONSTANTS.REGISTERED") Registered
52+
.unregistered(ng-hide="srm.currentPhase !== CONSTANTS.REGISTRATION || srm.userStatus === CONSTANTS.REGISTERED")
53+
a.tc-btn.tc-btn-s.tc-btn-wide(href="https://community.{{DOMAIN}}/tc?module=MatchDetails&rd={{srm.rounds[0].id}}") Register
5854

5955
.past-srm(ng-show="srm.status === 'PAST'")
6056
.challenge-track

app/directives/srm-tile/srm-tile.directive.js

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,12 @@
1010
showResults: '=',
1111
showFooter: '='
1212
},
13-
controller: ['$scope', 'CONSTANTS', function($scope, CONSTANTS) {
13+
controller: ['$scope', '$filter', 'CONSTANTS', 'SRMService',
14+
function($scope, $filter, CONSTANTS, SRMService) {
1415
$scope.DOMAIN = CONSTANTS.domain;
15-
// TODO removed hard coded value
16-
$scope.registered = false;
17-
if (Array.isArray($scope.srm.rounds) && $scope.srm.rounds.length) {
18-
if ($scope.srm.rounds[0].userSRMDetails && $scope.srm.rounds[0].userSRMDetails.rated) {
19-
$scope.srm.result = $scope.srm.rounds[0].userSRMDetails;
20-
}
21-
if ($scope.srm.rounds[0].codingStartAt) {
22-
$scope.srm.codingStartAt = $scope.srm.rounds[0].codingStartAt;
23-
}
24-
if ($scope.srm.rounds[0].codingEndAt) {
25-
$scope.srm.codingEndAt = $scope.srm.rounds[0].codingEndAt;
26-
}
27-
}
16+
$scope.CONSTANTS = CONSTANTS;
17+
$scope.srm.userStatus = _.get($scope.srm, 'userStatus', null);
18+
SRMService.processSRM($scope.srm);
2819
}]
2920
};
3021
});

app/layout/header/header.jade

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@
1818
span(ng-switch-when="false" class="tc-btn tc-btn-s") JOIN
1919

2020
ul.main-menu
21-
li.menu-item.search-wrapper
21+
li.menu-item.search-wrapper(ng-mouseenter="vm.focusSearch = true", ng-mouseleave="vm.focusSearch = false")
2222
.menu-item-header.show-large #[button.btn-expand-search.search-icon(type="button")]
2323

2424
.submenu
25-
input(type="text" placeholder="find people" ng-model="vm.searchTerm" ng-keyup="vm.checkSubmit($event)")
25+
input(type="text" placeholder="find members" ng-model="vm.searchTerm" ng-keyup="vm.checkSubmit($event)", focus-on="vm.focusSearch")
2626
// Suggestion list container
2727
// ul.suggestion-list(ng-if="main.searchTerm.length > 0")
2828
// li(ng-repeat="suggestion in main.suggestions | filter:main.searchTerm | limitTo:5")

app/my-dashboard/srms/srms.controller.js

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@
33

44
angular.module('tc.myDashboard').controller('SRMWidgetController', SRMWidgetController);
55

6-
SRMWidgetController.$inject = ['UserService','SRMService', '$log'];
6+
SRMWidgetController.$inject = ['CONSTANTS', 'UserService','SRMService', '$q', '$log'];
77

8-
function SRMWidgetController(UserService, SRMService, $log) {
8+
function SRMWidgetController(CONSTANTS, UserService, SRMService, $q, $log) {
99
var vm = this;
1010
vm.srms = [];
11-
vm.loading = true;
11+
vm.state = CONSTANTS.STATE_LOADING;
1212

1313
var userId = UserService.getUserIdentity().userId;
14+
var handle = UserService.getUserIdentity().handle;
1415

1516
activate();
1617

@@ -24,14 +25,32 @@
2425
limit: 3
2526
};
2627

27-
SRMService.getSRMs(params)
28-
.then(function(data){
29-
vm.srms = data;
30-
vm.loading = false;
31-
}, function(resp) {
28+
$q.all([
29+
SRMService.getSRMs(params),
30+
// passing same params for user srms too, because it is highly unlikely that a member is registered
31+
// for more than 3 SRMs at a time as we don't have more than 3 active SRMs at the same time.
32+
SRMService.getUserSRMs(handle, params)
33+
]).then(function(data) {
34+
var srms = data[0];
35+
var userSrms = data[1];
36+
var userSrmsMap = {};
37+
var userSrms = userSrms.forEach(function (srm) {
38+
var id = srm.id;
39+
userSrmsMap[id] = srm;
40+
});
41+
// populates a map of user's future SRMs
42+
srms.forEach(function(srm) {
43+
if (userSrmsMap[srm.id]) {
44+
srm.userStatus = CONSTANTS.REGISTERED;
45+
}
46+
});
47+
48+
vm.srms = srms;
49+
vm.state = CONSTANTS.STATE_READY;
50+
}).catch(function(error) {
3251
// TODO - handle error
3352
$log.error(resp);
34-
vm.loading = false;
53+
vm.state = CONSTANTS.STATE_ERROR;
3554
});
3655
}
3756
}

app/my-dashboard/srms/srms.jade

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ header
44

55
.section-loading(ng-show="vm.loading")
66

7-
section(ng-hide="vm.loading")
7+
tc-section(state="vm.state")
88
.srm-tiles
99
srm-tile(ng-repeat="srm in vm.srms", srm="srm", view="'tile'", ng-class="'tile-view'")
1010

app/my-dashboard/srms/srms.spec.js

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ describe('SRMs Widget Controller', function() {
3131
});
3232

3333
// mock srms api
34-
sinon.stub(srmService, 'getSRMs', function(data) {
34+
sinon.stub(srmService, 'getSRMs', function(params) {
3535
var deferred = $q.defer();
3636
var resp = null;
37-
if (data.filter.indexOf('listType=past') != -1) {
37+
if (params.filter.indexOf('listType=past') != -1) {
3838
resp = JSON.parse(JSON.stringify(srms));
3939
} else {
4040
resp = JSON.parse(JSON.stringify(srms.slice(1)));
@@ -47,6 +47,20 @@ describe('SRMs Widget Controller', function() {
4747
deferred.resolve(resp);
4848
return deferred.promise;
4949
});
50+
51+
// mock srms api
52+
sinon.stub(srmService, 'getUserSRMs', function(handle, params) {
53+
var deferred = $q.defer();
54+
// TODO remove add more tests case for scenario when user has some registered SRMs
55+
var resp = [];
56+
resp.pagination = {
57+
total: resp.length,
58+
pageIndex: 1,
59+
pageSize: 10
60+
};
61+
deferred.resolve(resp);
62+
return deferred.promise;
63+
});
5064
});
5165

5266
bard.verifyNoOutstandingHttpRequests();

app/my-srms/my-srms.controller.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,8 @@
7676
filter: 'status=' + vm.statusFilter
7777
};
7878

79-
if (vm.statusFilter === 'past') {
80-
return SRMService.getPastSRMs(userHandle, params)
81-
.then(handleSRMsLoad, handleSRMsFailure);
82-
} else {
83-
return SRMService.getSRMs(params)
79+
return SRMService.getUserSRMs(userHandle, params)
8480
.then(handleSRMsLoad, handleSRMsFailure);
85-
}
8681
}
8782

8883
function handleSRMsLoad(data) {

app/my-srms/my-srms.jade

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,8 @@
1616
button.list(ng-click="vm.changeView('list')", ng-class="{ disabled: vm.view === 'list' }") List
1717

1818
.no-srms(ng-if="!vm.srms.length && vm.loading === 'ready'")
19-
empty-state-placeholder(title="Past SRMs", description="You have not participated in any SRMs yet.", show="vm.statusFilter === 'past'")
20-
.info-links
21-
a.find-srms.tc-btn.tc-btn-s.tc-btn-ghost(ng-href="https://www.{{DOMAIN}}/challenges/data?pageIndex=1") Find SRMs
22-
a.learn-more(href="https://www.{{DOMAIN}}/member-onboarding/competing-in-an-algorithm-match-srm/ ") Learn More
23-
empty-state-placeholder(title="Upcoming SRMs", description="There are no upcoming SRMs.", show="vm.statusFilter === 'future'")
19+
empty-state-placeholder(state-name="my-srms-past", show="vm.statusFilter === 'past'", theme="offwhite")
20+
empty-state-placeholder(state-name="my-srms-upcoming", show="vm.statusFilter === 'future'", theme="offwhite")
2421

2522
.has-srms(ng-show="vm.srms.length")
2623
.data(ng-class="vm.view + '-view'")

0 commit comments

Comments
 (0)