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

Commit 6c57b2c

Browse files
author
vikasrohit
committed
Merge branch 'dev' into feature/sup-2481-intergrate-web-links-api
* dev: Update Fix search bar, styling and placement of user handle Move footer links to bottom of mobile nav, style white Fix formatting Fix import adjusted winner ribbon positioning Fix test Remove stopPropagation fixed srm calc fixed some design card display stuff Prevent the section from flickering quick fix more nav styling changes removing "only" from tests and fixing logout redirecting logout to home page, removing cookies etc SUP-2272, Profile--> Remove the mouse hover from profile image. SUP-2420, SiteMap--> Remove the 'Footer' section. Finished nav basics placeholder logo 'beta' tag css fix
2 parents 13b4020 + f3aae78 commit 6c57b2c

30 files changed

+542
-257
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ The tests folder contains mock data (tests/test-helpers/mock-data.js). It also h
5858
Spec files live alongside the code they are testing. For example, in peer-review you have review-status.controller.js and review-status.spec.js in the same review-status folder. If you want to see an example of tests, use review-status.spec.js as an example of controller tests and services/challenge.service.spec.js as an example of service tests.
5959

6060
## UI-Router and States
61-
See sample.routes.js and peer-review.routes.js as examples.
61+
See any *.routes.js file as an example.
6262

6363
## Contributing
6464

@@ -87,7 +87,7 @@ Jade Files
8787
```
8888

8989
SCSS Files
90-
- Use SCSS syntax (nesting)
90+
- Use SCSS syntax, but do not overly nest
9191
- Use variables and mixins as much as possible
9292
- Store new variables and mixins in the appropriate file in `assets/css/partials`
9393
- Since a class with the current state name is added to the ui-view (see the Creating New Views/Pages section), wrap your .scss file with this class, in order to write specific SCSS in its own file for that page.

app/account/account.routes.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,13 @@
108108
},
109109
logout: {
110110
url: '/logout/',
111-
controller: ['TcAuthService', function(TcAuthService) {
112-
TcAuthService.logout();
113-
}],
111+
views: {
112+
'header@': {},
113+
'container@': {
114+
controller: 'LogoutController'
115+
},
116+
'footer@': {}
117+
},
114118
data: {
115119
authRequired: false
116120
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
(function() {
2+
'use strict';
3+
4+
angular.module('tc.account').controller('LogoutController', LogoutController);
5+
6+
LogoutController.$inject = ['$log', 'TcAuthService', '$window', 'CONSTANTS'];
7+
8+
function LogoutController($log, TcAuthService, $window, CONSTANTS) {
9+
$log = $log.getInstance('LogoutController');
10+
11+
TcAuthService.logout()
12+
.then(function() {
13+
$log.debug("successfully logged out.");
14+
// redirect to home
15+
$window.location.href = CONSTANTS.MAIN_URL;
16+
});
17+
18+
}
19+
})();
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/* jshint -W117, -W030 */
2+
describe('Logout Controller', function() {
3+
var controller;
4+
var fakeWindow = {
5+
location: {
6+
href: ''
7+
}
8+
};
9+
10+
11+
beforeEach(function() {
12+
bard.appModule('topcoder');
13+
bard.appModule('tc.account');
14+
module('tc.account', function($provide) {
15+
$provide.value('$window', fakeWindow);
16+
});
17+
18+
bard.inject(this, '$controller', 'TcAuthService', '$window', '$q', 'CONSTANTS');
19+
20+
bard.mockService(TcAuthService, {
21+
logout: $q.when({}),
22+
_default: $q.when({})
23+
});
24+
25+
controller = $controller('LogoutController');
26+
});
27+
28+
bard.verifyNoOutstandingHttpRequests();
29+
30+
it('should be defined', function() {
31+
expect(controller).to.be.defined;
32+
});
33+
34+
it('should be successfully logged out', function() {
35+
expect(TcAuthService.logout).to.have.been.calledOnce;
36+
expect($window.location.href).to.equal(CONSTANTS.MAIN_URL);
37+
});
38+
39+
});

app/directives/header/header-menu-item.directive.jade

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ li.submenu-item(ng-if="item.sref && !item.srefParams")
66

77
// external links
88
li.submenu-item(ng-if="item.href && !item.srefParams")
9-
a.menu-link(ng-click="$event.stopPropagation();" ng-href="{{item.href}}" ng-class="{ 'active': isActive() }" target="{{ item.target ? item.target : '_self'}}")
9+
a.menu-link(ng-href="{{item.href}}" ng-class="{ 'active': isActive() }" target="{{ item.target ? item.target : '_self'}}")
1010
img.menu-icon(ng-src="{{item.icon}}")
1111
.menu-text {{item.text}}
1212

app/directives/header/header-menu-item.directive.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@
1313
var href = $scope.item.href;
1414

1515
// I believe I have to hack this because of https://github.com/angular-ui/ui-router/issues/395, I tried ui-state
16-
if ($scope.item.srefParams)
16+
if ($scope.item.srefParams) {
1717
$scope.wtfhref = $state.href($scope.item.sref, $scope.item.srefParams);
18+
}
1819

1920
$scope.isActive = function() {
2021
if (window.location.pathname == href || $state.is(sref)) {
@@ -23,6 +24,7 @@
2324

2425
return true;
2526
}
27+
2628
return false;
2729
}
2830
}]

app/directives/profile-widget/profile-widget.jade

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
.profile-widget-directive
2-
a(ui-sref="profile.about({userHandle: profile.handle})")
2+
.pic
33
img.profile-circle(ng-if="profile.photoURL", ng-src="{{profile.photoURL}}")
44
img.profile-circle(ng-if="!profile.photoURL", src="/images/ico-user-default.svg")
55

app/index.jade

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ html
3737
link(rel="stylesheet", href="assets/css/settings/edit-profile.css")
3838
link(rel="stylesheet", href="assets/css/settings/account-info.css")
3939
link(rel="stylesheet", href="assets/css/profile/subtrack.css")
40+
link(rel="stylesheet", href="assets/css/profile/nav.css")
4041
link(rel="stylesheet", href="assets/css/profile/icons.css")
4142
link(rel="stylesheet", href="assets/css/profile/header.css")
4243
link(rel="stylesheet", href="assets/css/profile/badges.css")
@@ -166,6 +167,7 @@ html
166167
script(src="account/account.module.js")
167168
script(src="account/account.routes.js")
168169
script(src="account/login/login.controller.js")
170+
script(src="account/logout/logout.controller.js")
169171
script(src="account/register/register.controller.js")
170172
script(src="account/reset-password/reset-password.controller.js")
171173
script(src="blocks/exception/exception.module.js")

app/layout/footer/footer.jade

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,25 @@ footer.bottom-footer
22
// Footer links
33
nav.menu-item
44
.menu-item-header.show-small OTHERS
5+
56
ul.submenu
6-
li.submenu-item #[a.menu-link(ng-click="$event.stopPropagation();" href="/sitemap") SITEMAP]
7-
li.submenu-item #[a.menu-link(ng-click="$event.stopPropagation();" href="/about") ABOUT US]
8-
li.submenu-item #[a.menu-link(ng-click="$event.stopPropagation();" href="/contact-us") CONTACT US]
9-
li.submenu-item #[a.menu-link(ng-click="$event.stopPropagation();" href="https://help.{{domain}}" target="_blank") HELP CENTER]
10-
li.submenu-item #[a.menu-link(ng-click="$event.stopPropagation();" href="https://www.{{domain}}/community/how-it-works/privacy-policy/") PRIVACY POLICY]
11-
li.submenu-item #[a.menu-link(ng-click="$event.stopPropagation();" href="https://www.{{domain}}/community/how-it-works/terms/") TERMS]
7+
li.submenu-item #[a.menu-link(ng-href="https://www.{{domain}}/sitemap") SITE MAP]
8+
li.submenu-item #[a.menu-link(ng-href="https://www.{{domain}}/about") ABOUT US]
9+
li.submenu-item #[a.menu-link(ng-href="https://www.{{domain}}/contact-us") CONTACT US]
10+
li.submenu-item #[a.menu-link(ng-href="https://help.{{domain}}" target="_blank") HELP CENTER]
11+
li.submenu-item #[a.menu-link(ng-href="https://www.{{domain}}/community/how-it-works/privacy-policy/") PRIVACY POLICY]
12+
li.submenu-item #[a.menu-link(ng-href="https://www.{{domain}}/community/how-it-works/terms/") TERMS]
1213

1314
// Social links
1415
.social-links
1516
p Topcoder is also on
17+
1618
a.fb-link(href="https://www.facebook.com/topcoder" target="fbwindow")
19+
1720
a.twitter-link(href="http://www.twitter.com/topcoder" target="twwindow")
21+
1822
a.linkedin-link(href="https://www.linkedin.com/company/topcoder" target="liwindow")
23+
1924
a.google-link(href="https://plus.google.com/u/0/b/104268008777050019973/104268008777050019973/posts" target="gpwindow")
2025

2126
p.copyright-notice © 2015 Topcoder. All Rights Reserved

app/layout/header/header.controller.js

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
vm.constants = CONSTANTS;
1212
vm.domain = CONSTANTS.domain;
1313
vm.login = TcAuthService.login;
14-
vm.logout = logout;
1514
vm.checkSubmit = checkSubmit;
1615
vm.searchTerm = '';
1716
vm.selectedGroup = selectedGroup;
@@ -65,13 +64,6 @@
6564
}
6665
}
6766

68-
function logout() {
69-
TcAuthService.logout()
70-
.then(function() {
71-
$state.go('home');
72-
});
73-
}
74-
7567
function selectedGroup() {
7668
return _.get(NavService, 'selectedTopLevelItem', null);
7769
}

app/layout/header/header.jade

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
.header-wrapper(ng-class="{'autocomplete': main.searchTerm.length > 0}")
22
header.top-header
33
a.logo-link(href="/")
4+
45
// Header content visible on small screens
56
.show-small.mobile-heading
67
span.tc-text-logo(ng-if="main.menuVisible") [ topcoder ]
@@ -11,8 +12,8 @@
1112

1213
// User link (profile or join)
1314
a(ui-sref="profile.about({userHandle: vm.userHandle})", ng-switch="vm.isAuth" class="user-link" data-ng-if="!main.menuVisible")
14-
//- img(ng-switch-when="true", class="user-avatar", ng-src="{{vm.profile.photoURL}}")
1515
img(ng-switch-when="true", ng-if="vm.profile.photoURL && vm.profile.photoURL.length", class="user-avatar", ng-src="{{vm.profile.photoURL}}")
16+
1617
img(ng-switch-when="true", ng-if="!vm.profile.photoURL || !vm.profile.photoURL.length", class="user-avatar", ng-src="/images/ico-user-default.svg")
1718

1819
span(ng-switch-when="false" class="tc-btn tc-btn-s") JOIN
@@ -29,7 +30,7 @@
2930
// a(href="javascript:;" class="menu-link") {{suggestion}}
3031
3132
li.menu-item.link-group.user-menu(ng-switch="vm.isAuth", ng-class="{'anonymous-menu': !vm.isAuth}")
32-
// links for logged in user
33+
// Links for logged in user
3334
div(ng-switch-when="true")
3435
.menu-item-header(
3536
ng-class="{'hide': vm.selectedGroup() == 'user'}"
@@ -49,22 +50,19 @@
4950
header-menu-item(ng-repeat="item in vm.userMenu" item="item")
5051

5152
li.submenu-item
52-
a.menu-link(ng-click="vm.logout(); main.menuVisible = vm.isAuth = false")
53+
//- a.menu-link(ng-click="vm.logout(); main.menuVisible = vm.isAuth = false")
54+
a.menu-link(ui-sref="logout")
5355
img.menu-icon(ng-src="/images/nav/exit.svg")
56+
5457
.menu-text LOG OUT
5558

56-
// links for anonymous user
59+
// Links for anonymous user
5760
.menu-item-header(ng-switch-when="false")
5861
a.tc-btn.tc-btn-s.btn-link(ui-sref="register") JOIN
5962

6063
a.tc-btn.tc-btn-s.tc-btn-ghost.btn-link(ui-sref="login") LOG IN
6164

62-
//- a(ng-click="launchIntro();", ng-show="!!vm.introOptions") Intro
63-
64-
li.menu-item.link-group(
65-
ng-repeat="(menu, items) in vm.menuLinks",
66-
ng-class="{'selected': vm.selectedGroup() == menu}"
67-
)
65+
li.menu-item.link-group(ng-repeat="(menu, items) in vm.menuLinks", ng-class="{'selected': vm.selectedGroup() == menu}")
6866
.menu-item-header {{menu}}
6967

7068
ul.submenu

app/profile/profile.controller.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
// set profile to the object that was resolved
1414
vm.profile = profile;
1515
vm.userHandle = userHandle;
16+
vm.handleColor = ProfileService.getUserHandleColor(profile);
1617
vm.showBadges = showBadges;
1718
vm.closeDialog = closeDialog;
1819
vm.scrollTo = scrollTo;

app/profile/profile.controller.spec.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ describe('Profile Controller', function() {
2424
getUserSkills: function() {
2525
return $q.when({result: {content: mockSkills}});
2626
},
27+
getUserHandleColor: function() {
28+
return 'something';
29+
},
2730
getRanks: ProfileService.getRanks
2831
};
2932
// mock user api

app/profile/subtrack/nav.jade

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
.nav-top
2+
.user
3+
.avatar
4+
img(ng-src="{{vm.profile.photoURL}}")
5+
6+
.handle(style="color: {{vm.handleColor}}") {{vm.profile.handle}}
7+
8+
.exit(ng-click="vm.closeDialog()")
9+
img(src="/images/x-mark-gray.svg")
10+
11+
hr
112
.categoryNav
213
.track(
314
ng-repeat="track in vm.profile.tracks",

app/profile/subtrack/subtrack.controller.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@
227227
template: 'profile/subtrack/nav.html',
228228
controller: 'ProfileCtrl',
229229
controllerAs: 'vm',
230-
className: 'ngdialog-theme-default',
230+
className: 'ngdialog-nav-theme',
231231
resolve: {
232232
userHandle: function() {
233233
return vm.userHandle;

app/services/authToken.service.spec.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ describe('TcAuthToken Service', function() {
5858
it('should remove tokens from store & cookie"', function() {
5959
service.removeTokens();
6060
expect($cookies.remove).to.have.been.calledWith('tcjwt');
61+
expect($cookies.remove).to.have.been.calledWith('tcsso');
6162
expect(store.remove).to.be.have.been.calledWith('appiriojwt');
6263
});
6364

app/services/nav.service.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,8 @@
88
function NavService(CONSTANTS, $state, UserService, TcAuthService) {
99

1010
var service = {
11-
1211
selectedTopLevelItem: null,
1312
getParent: getParent
14-
1513
};
1614

1715
service.menuLinks = {
@@ -47,6 +45,7 @@
4745
];
4846

4947
service.hrefs = {};
48+
5049
service.menuLinks.compete.forEach(function(link) {
5150
link.parent = 'compete';
5251
service.hrefs[link.href] = link;
@@ -68,8 +67,9 @@
6867
});
6968

7069
function getParent(ref) {
71-
if (ref.indexOf('.') >= 0)
70+
if (ref.indexOf('.') >= 0) {
7271
ref = ref.slice(0, ref.indexOf('.'));
72+
}
7373

7474
if (ref.match(/profile/)) {
7575
if (TcAuthService.isAuthenticated() && $state.params && $state.params.userHandle == UserService.getUserIdentity().handle) {
@@ -82,9 +82,6 @@
8282
}
8383
}
8484

85-
8685
return service;
87-
8886
}
89-
9087
})();

app/services/profile.service.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@
273273
array.forEach(function(level) {
274274
level.problemsFailed = level.problemsFailed || level.failedChallenges || 0;
275275
level.problemsSubmitted = level.problemsSubmitted || level.challenges || 0;
276-
level.problemsSuccessful = (level.problemsSubmitted - level.problemsFailed) || 0;
276+
level.problemsSuccessful = (level.problemsSubmitted - level.problemsFailed - (level.problemsSysByTest || 0)) || 0;
277277
level.percentSuccessful = (level.problemsSuccessful / (level.problemsSubmitted || 1)) || 0;
278278
ans.total.problemsSuccessful += level.problemsSuccessful || (level.challenges - level.failedChallenges) || 0;
279279
ans.total.problemsFailed += level.problemsFailed || level.failedChallenges || 0;

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
function activate() {
1818
vm.isSocialRegistrant = false;
19+
vm.loading = true;
1920

2021
vm.formProcessing = {
2122
accountInfoForm: false,
@@ -28,10 +29,12 @@
2829
UserService.getUserProfile({fields: 'credential'})
2930
.then(function(res) {
3031
vm.isSocialRegistrant = !res.credential.hasPassword;
32+
vm.loading = false;
3133
})
3234
.catch(function(err) {
3335
$log.error("Error fetching user profile. Redirecting to edit profile.");
3436
$state.go('settings.profile');
37+
vm.loading = false;
3538
});
3639

3740
vm.countries = ISO3166.getAllCountryObjects();

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
.form-label Email
1212
input.form-field.grey(name="email", value="{{vm.userData.email}}", disabled=true)
1313

14-
div(ng-hide="vm.isSocialRegistrant")
14+
div(ng-if="!vm.isSocialRegistrant && !vm.loading")
1515
form(name="vm.newPasswordForm", role="form", ng-submit="vm.newPasswordForm.$valid && vm.submitNewPassword()", novalidate)
1616
.form-label Current password
1717

@@ -45,7 +45,7 @@
4545
button.tc-btn.save(type="submit", tc-busy-button, tc-busy-when="vm.formProcessing.newPasswordForm", ng-disabled="vm.newPasswordForm.$invalid || vm.newPasswordForm.$pristine", ng-class="{'disabled': vm.newPasswordForm.$invalid || vm.newPasswordForm.$pristine}") Change Password
4646

4747

48-
div(ng-show="vm.isSocialRegistrant")
48+
div(ng-if="vm.isSocialRegistrant && !vm.loading")
4949
p You joined Topcoder by using an external account, so we don't have a password for you.
5050

5151
form(name="vm.accountInfoForm", role="form", novalidate, autocomplete="off")

0 commit comments

Comments
 (0)