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

Commit 14d393e

Browse files
committed
Merge branch 'dev' into tom-history-graph
Conflicts: app/services/profile.service.js
2 parents 6010bb3 + f053b7c commit 14d393e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+787
-238
lines changed

app/account/login/login.controller.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@
101101
TcAuthService.socialLogin(backend, callbackUrl);
102102
};
103103

104+
vm.$stateParams = $stateParams;
104105
}
105106

106107
})();

app/account/login/login.jade

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@
3232
a.forgot-password(ui-sref="resetPassword") Forgot Password?
3333

3434
p.redirect Don't have an account?
35-
a(ui-sref="register") Join Now.
35+
a(ui-sref="register(vm.$stateParams)") Join Now.
3636

app/account/register/register.controller.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@
8787
userId: vm.socialUserId,
8888
name: vm.firstname + " " + vm.lastname,
8989
email: vm.socialProfile.email,
90-
emailVerified: vm.socialProfile.emailVerified,
90+
emailVerified: vm.socialProfile.email_verified,
9191
providerType: vm.socialProvider
9292
}
9393
}
@@ -120,5 +120,7 @@
120120
callbackURL: callbackUrl
121121
});
122122
}
123+
124+
vm.$stateParams = $stateParams;
123125
}
124126
})();

app/account/register/register.jade

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
p.form-error(ng-show="vm.registerForm.email.$dirty && vm.registerForm.email.$invalid") Please enter a valid email address.
6868

6969
.validation-bar(ng-class="{ 'success-bar': (vm.registerForm.password.$valid) }")
70-
toggle-password
70+
toggle-password(ng-if="!vm.isSocialRegistration")
7171

7272
.tips.password-tips(ng-show="vm.passwordFocus")
7373
h3 Password Tips:
@@ -96,4 +96,4 @@
9696
i.fa.fa-google-plus-square(ng-click="vm.socialRegister('google-oauth2')")
9797

9898
p.redirect Already have an account?
99-
a(ui-sref="login") Login.
99+
a(ui-sref="login(vm.$stateParams)") Login.

app/directives/account/toggle-password/toggle-password.directive.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@
2020
passwordInput.focus();
2121
});
2222

23+
element.bind('keyup', function(event) {
24+
if (event.keyCode === 13) {
25+
passwordInput.blur();
26+
}
27+
});
28+
2329
vm.onFocus = function(event) {
2430
vm.passwordFocus = true;
2531
vm.placeholder = '';

app/directives/challenge-tiles/challenge-tile.spec.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,16 @@
22
describe('Challenge Tile Directive', function() {
33
var scope;
44
var element;
5+
var domain;
56
var challenge = mockData.getMockChallengeWithUserDetails();
67
var spotlightChallenge = mockData.getMockSpotlightChallenges()[0];
78

89
beforeEach(function() {
910
bard.appModule('topcoder');
10-
bard.inject(this, '$compile', '$rootScope');
11+
bard.inject(this, '$compile', '$rootScope', 'CONSTANTS');
12+
1113
scope = $rootScope.$new();
14+
domain = CONSTANTS.domain;
1215
});
1316

1417
bard.verifyNoOutstandingHttpRequests();
@@ -34,7 +37,7 @@ describe('Challenge Tile Directive', function() {
3437
});
3538

3639
it('should have domain added to the scope', function() {
37-
expect(element.isolateScope().DOMAIN).to.equal('topcoder-dev.com');
40+
expect(element.isolateScope().DOMAIN).to.equal(domain);
3841
});
3942
});
4043

app/directives/profile-widget/profile-widget.directive.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,14 @@
1111
profile: '=profile',
1212
editProfileLink: '=editProfileLink'
1313
},
14-
link: function($scope, elem, attrs, ctrl) {
15-
$scope.DOMAIN = CONSTANTS.domain;
14+
link: function(scope, elem, attrs) {
15+
scope.DOMAIN = CONSTANTS.domain;
1616

17-
if (_.isUndefined($scope.editProfileLink)) {
18-
$scope.editProfileLink = false;
19-
}
17+
scope.$watch('editProfileLink', function(newValue, oldValue, scope) {
18+
if (newValue) {
19+
scope.editProfileLink = newValue;
20+
}
21+
});
2022
}
2123
};
2224
}

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
.profile-widget-directive
2-
a(ui-sref="profile.about({userHandle: profile.handle})")
3-
img.profile-circle(fallback-src="/images/avatarPlaceholder.png", ng-src="{{profile.photo.photoUrl}}")
2+
a(ui-sref="profile.about({userHandle: profile.handle})")
3+
img.profile-circle(fallback-img="/images/avatarPlaceholder.png", loading-src="/images/avatarPlaceholder.png", ng-src="{{profile.photoURL}}")
44

55
.info
6-
h1 {{profile.handle}}
6+
h1 {{profile.handle}}
77

8-
a(href="http://forums.{{DOMAIN}}/?module=History&userID={{vm.profile.userId}}")
8+
a(href="http://forums.{{DOMAIN}}/?module=History&userID={{profile.userId}}")
99
i.fa.fa-comment-o
1010

1111
h3.tracks {{profile.tracks || [] | track | join: ', '}}

app/directives/tc-pager/tc-pager.jade

Lines changed: 0 additions & 10 deletions
This file was deleted.

app/directives/tc-pager/tc-pager.directive.js renamed to app/directives/tc-paginator/tc-paginator.directive.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
(function() {
22
'use strict';
3-
angular.module('tcUIComponents').directive('tcPager', function() {
3+
angular.module('tcUIComponents').directive('tcPaginator', function() {
44
return {
55
restrict: 'E',
66
transclude: true,
77
replace: true,
8-
templateUrl: 'directives/tc-pager/tc-pager.html',
8+
templateUrl: 'directives/tc-paginator/tc-paginator.html',
99
scope: {
1010
pageParams: '=',
1111
data: '='
1212
},
1313
controller: ['$log', '$scope', '$element', function($log, $scope, $element) {
14-
$element.addClass('tc-pager');
14+
$element.addClass('tc-paginator');
1515
var vm = this;
1616

1717
// pageParams.offset 0 based index of the first challenge to be shown
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
p.pager
2+
a.prev(ng-click="vm.prevPage()", ng-class="{disabled: !vm.prevPageAvailable}") Prev
3+
span   |  
4+
span.first(ng-bind="vm.pageParams.offset + 1")
5+
span -
6+
span.last(ng-bind="vm.pageParams.offset + vm.pageParams.count")
7+
span   of  
8+
span.total(ng-bind="vm.pageParams.totalCount")
9+
span   |  
10+
a.next(ng-click="vm.nextPage()", ng-class="{disabled: !vm.nextPageAvailable}") Next
Lines changed: 196 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,196 @@
1+
/* jshint -W117, -W030 */
2+
describe('TC Paginator Directive', function() {
3+
var scope;
4+
var element;
5+
var controller;
6+
var data = [{
7+
id: 1
8+
}, {
9+
id: 2
10+
}, {
11+
id: 3
12+
}, {
13+
id: 4
14+
}, {
15+
id: 5
16+
}];
17+
var pageParams = {
18+
offset: 0,
19+
limit: 2,
20+
count: 0,
21+
totalCount: 0,
22+
updated: 0
23+
};
24+
25+
beforeEach(function() {
26+
bard.appModule('topcoder');
27+
bard.inject(this, '$compile', '$rootScope');
28+
scope = $rootScope.$new();
29+
});
30+
31+
bard.verifyNoOutstandingHttpRequests();
32+
33+
describe('TC Paginator', function() {
34+
var pager;
35+
36+
beforeEach(function() {
37+
scope.data = data.slice(0, 2);
38+
scope.data.metadata = {totalCount : 5};
39+
pageParams = {
40+
offset: 0,
41+
limit: 2,
42+
count: 0,
43+
totalCount: 0,
44+
updated: 0
45+
};
46+
scope.pageParams = pageParams;
47+
element = angular.element('<tc-paginator data="data" page-params="pageParams"></tc-paginator>)');
48+
pager = $compile(element)(scope);
49+
scope.$digest();
50+
controller = element.controller('tcPaginator')
51+
});
52+
53+
it('should have pager related html', function() {
54+
var prev = pager.find('.prev');
55+
expect(prev).not.to.null;
56+
// with offset 0, prev link should be disabled
57+
expect(prev.hasClass('disabled')).to.equal(true);
58+
var first = pager.find('.first');
59+
expect(first).not.to.null;
60+
expect(first.text()).to.equal("1");
61+
var last = pager.find('.last');
62+
expect(last).not.to.null;
63+
expect(last.text()).to.equal("2");
64+
var total = pager.find('.total');
65+
expect(total).not.to.null;
66+
expect(total.text()).to.equal("5");
67+
var next = pager.find('.next');
68+
expect(next).not.to.null;
69+
// with offset 0, page size 2 and 5 total records, next link should be enabled
70+
expect(next.hasClass('disabled')).to.equal(false);
71+
});
72+
73+
it('change in scope data should trigger paginator update', function() {
74+
// change the data
75+
scope.data = data.slice(3, 4);
76+
scope.data.metadata = {totalCount: 7};
77+
scope.$apply();
78+
79+
var total = pager.find('.total');
80+
expect(total).not.to.null;
81+
// correct totalCount should be reflected in the HTML
82+
expect(total.text()).to.equal("7");
83+
// pageParams should also reflect the correct totalCount
84+
expect(pageParams.totalCount).to.equal(7);
85+
// count should 1 because the length of the scope.data is 1
86+
expect(pageParams.count).to.equal(1);
87+
});
88+
89+
it('controller.nextPage() should update the pageParams', function() {
90+
// calls nextPage method on controller
91+
controller.nextPage();
92+
expect(pageParams.offset).to.equal(2);
93+
expect(pageParams.limit).to.equal(2);
94+
expect(pageParams.updated).to.equal(1);
95+
});
96+
97+
it('clicking on next link should update the pageParams', function() {
98+
// clicks on the next page link
99+
var next = pager.find('.next');
100+
expect(next).not.to.null;
101+
next.click();
102+
103+
expect(pageParams.offset).to.equal(2);
104+
expect(pageParams.limit).to.equal(2);
105+
expect(pageParams.updated).to.equal(1);
106+
});
107+
108+
it('controller.nextPage() should not update pageParams on last page', function() {
109+
// on first page nextPageAvailable should be true
110+
expect(controller.nextPageAvailable).to.equal(true);
111+
// calls nextPage method on controller: page 2
112+
controller.nextPage();
113+
expect(pageParams.offset).to.equal(2);
114+
expect(pageParams.limit).to.equal(2);
115+
expect(pageParams.updated).to.equal(1);
116+
// update the data to trigger paginator state update
117+
scope.data = data.slice(2, 4);
118+
scope.$apply();
119+
// on second page nextPageAvailable should be true
120+
expect(controller.nextPageAvailable).to.equal(true);
121+
122+
// calls nextPage method on controller: page 3
123+
controller.nextPage();
124+
expect(pageParams.offset).to.equal(4);
125+
expect(pageParams.limit).to.equal(2);
126+
expect(pageParams.updated).to.equal(2);
127+
// update the data to trigger paginator state update
128+
scope.data = data.slice(2, 4);
129+
scope.$apply();
130+
// on thrid/last page nextPageAvailable should be false
131+
expect(controller.nextPageAvailable).to.equal(false);
132+
133+
// calls nextPage
134+
controller.nextPage();
135+
// should not have any effect on page Params
136+
expect(pageParams.offset).to.equal(4);
137+
expect(pageParams.limit).to.equal(2);
138+
expect(pageParams.updated).to.equal(2);
139+
140+
});
141+
142+
it('controller.prevPage() should not update the pageParams on first page', function() {
143+
// prev page link should not be available
144+
expect(controller.prevPageAvailable).to.equal(false);
145+
146+
// calls prevPage to move one page backward
147+
controller.prevPage();
148+
// verifies prevPage call does not have any effect
149+
expect(pageParams.offset).to.equal(0);
150+
expect(pageParams.limit).to.equal(2);
151+
expect(pageParams.updated).to.equal(0);
152+
});
153+
154+
it('controller.prevPage() should update the pageParams', function() {
155+
// calls nextPage to move one page forward
156+
controller.nextPage();
157+
// verifies next page is successful
158+
expect(pageParams.offset).to.equal(2);
159+
expect(pageParams.limit).to.equal(2);
160+
expect(pageParams.updated).to.equal(1);
161+
// update the data to trigger paginator state update
162+
scope.data = data.slice(2, 4);
163+
scope.$apply();
164+
expect(controller.prevPageAvailable).to.equal(true);
165+
166+
// calls prevPage to move one page backward
167+
controller.prevPage();
168+
// verifies prev page is successful
169+
expect(pageParams.offset).to.equal(0);
170+
expect(pageParams.limit).to.equal(2);
171+
expect(pageParams.updated).to.equal(2);
172+
});
173+
174+
it('clicking on prev link should update the pageParams', function() {
175+
// calls nextPage to move one page forward
176+
controller.nextPage();
177+
// verifies next page is successful
178+
expect(pageParams.offset).to.equal(2);
179+
expect(pageParams.limit).to.equal(2);
180+
expect(pageParams.updated).to.equal(1);
181+
// update the data to trigger paginator state update
182+
scope.data = data.slice(2, 4);
183+
scope.$apply();
184+
expect(controller.prevPageAvailable).to.equal(true);
185+
186+
// clicks on the prve page link
187+
var prev = pager.find('.prev');
188+
expect(prev).not.to.null;
189+
prev.click();
190+
// verifies prev page call is successful
191+
expect(pageParams.offset).to.equal(0);
192+
expect(pageParams.limit).to.equal(2);
193+
expect(pageParams.updated).to.equal(2);
194+
});
195+
});
196+
});

0 commit comments

Comments
 (0)