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

Commit 1ad77a8

Browse files
authored
Merge pull request #931 from appirio-tech/dev
Community fixes 1 and initial listings page
2 parents a6c1a43 + c5c65d2 commit 1ad77a8

18 files changed

+298
-262
lines changed

app/directives/challenge-links/challenge-links.jade

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
.challenge-links(ng-class="view + '-view'")
2-
a.registrants(ng-href="{{challenge|challengeLinks:'registrants'}}", ng-switch="challenge.subTrack")
2+
a.registrants(ng-href="{{challenge|challengeLinks:'registrants'}}", ng-switch="challenge.subTrack", target="_self")
33
.icon.registrants-icon
44
p(ng-switch-when="MARATHON_MATCH") {{challenge.numRegistrants[0]}}
55
p(ng-switch-default) {{challenge.numRegistrants}}
66

7-
a.submissions(ng-hide="challenge.track === 'DATA_SCIENCE'", ng-href="{{challenge|challengeLinks:'submissions'}}")
7+
a.submissions(ng-hide="challenge.track === 'DATA_SCIENCE'", ng-href="{{challenge|challengeLinks:'submissions'}}", target="_self")
88
.icon.submissions-icon
99
p {{challenge.numSubmissions}}
1010

app/index.js

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ require('angucomplete-alt')
2222
require('angularjs-toaster')
2323
require('ng-dialog')
2424
require('xml2js')
25+
require('ngreact')
2526

2627
require('appirio-tech-ng-ui-components')
2728
require('appirio-tech-ng-iso-constants')

app/listings/listings.controller.js

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import angular from 'angular'
2+
3+
(function () {
4+
'use strict'
5+
6+
angular.module('tc.listings').controller('ListingsCtrl', ListingsCtrl)
7+
8+
ListingsCtrl.$inject = ['CONSTANTS', 'logger', '$q',
9+
'TcAuthService', 'UserService', 'UserStatsService', 'ProfileService', 'ChallengeService', 'ExternalAccountService',
10+
'ngDialog', '$anchorScroll'
11+
]
12+
13+
function ListingsCtrl(CONSTANTS, logger, $q, TcAuthService, UserService, UserStatsService, ProfileService, ChallengeService, ExternalAccountService, ngDialog, $anchorScroll) {
14+
15+
activate()
16+
17+
function activate() {
18+
logger.debug('Calling ListingsController activate()')
19+
20+
}
21+
}
22+
23+
})()

app/listings/listings.jade

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
react-component(name="ChallengeFiltersExample")

app/listings/listings.module.js

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import angular from 'angular'
2+
import { ChallengeFiltersExample } from 'appirio-tech-react-components'
3+
4+
(function() {
5+
'use strict'
6+
7+
var dependencies = [
8+
'angular-jwt',
9+
'ui.router',
10+
'ngCookies',
11+
'tc.services',
12+
'tcUIComponents',
13+
'angularSlideables',
14+
'ngDialog',
15+
'react'
16+
]
17+
18+
angular.module('tc.listings', dependencies)
19+
.value('ChallengeFiltersExample', ChallengeFiltersExample.default)
20+
21+
})()

app/listings/listings.routes.js

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import angular from 'angular'
2+
3+
(function() {
4+
'use strict'
5+
6+
angular.module('tc.listings').config([
7+
'$stateProvider',
8+
routes
9+
]).run(['$rootScope', '$state', function($rootScope, $state) {
10+
$rootScope.$on('$stateChangeError', function(event, toState, toParams, fromState, fromParams, error) {
11+
// if (toState.name.indexOf('sloog') > -1 && 400 <= error.status <= 500 ) {
12+
//
13+
// // unable to find a member with that username
14+
// $state.go('404')
15+
// }
16+
})
17+
}])
18+
19+
function routes($stateProvider) {
20+
var states = {
21+
'listings': {
22+
parent: 'root',
23+
url: '/listings/',
24+
template: require('./listings')(),
25+
controller: 'ListingsCtrl as vm',
26+
resolve: {
27+
userHandle: ['$stateParams', function($stateParams) {
28+
return $stateParams.userHandle
29+
}]
30+
},
31+
data: {
32+
authRequired: false,
33+
title: 'Listings'
34+
}
35+
}
36+
}
37+
38+
for (var name in states) {
39+
var state = states[name]
40+
$stateProvider.state(name, state)
41+
}
42+
}
43+
})()

app/my-challenges/my-challenges.controller.js

+8
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,14 @@ import _ from 'lodash'
146146
vm.getChallenges(currentOffset, false)
147147
}
148148

149+
window.onscroll = function() {
150+
if ((window.innerHeight + window.scrollY) >= document.body.offsetHeight) {
151+
if (vm.totalCount > vm.myChallenges.length) {
152+
vm.loadMore()
153+
}
154+
}
155+
}
156+
149157
function _checkForParticipation() {
150158
return ChallengeService.checkChallengeParticipation(vm.handle, function(participated) {
151159
vm.neverParticipated = !participated

app/my-challenges/my-challenges.jade

+3-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
.my-challenges-container
22
.my-challenges
3-
3+
44
.page-header
55
page-state-header(handle="{{vm.handle}}", page-title="My Challenges", hide-money="true", show-back-link="true", default-state="dashboard")
66

@@ -26,10 +26,7 @@
2626

2727
.hasChallenges(ng-show="vm.myChallenges.length", state="vm.loading")
2828

29-
.data(ng-class="vm.view + '-view'")
29+
.data(ng-class="vm.view + '-view'")
3030
challenge-tile(
31-
ng-repeat="challenge in vm.myChallenges | orderBy:vm.orderBy:true",
31+
ng-repeat="challenge in vm.myChallenges | orderBy:vm.orderBy:true",
3232
challenge="challenge", view="vm.view", ng-class="vm.view + '-view'")
33-
34-
tc-section.load-more-section(state="vm.loading")
35-
button.tc-btn(ng-show="vm.totalCount > vm.myChallenges.length", ng-click="vm.loadMore()") Load More

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

+3-81
Original file line numberDiff line numberDiff line change
@@ -3,56 +3,15 @@ const mockData = require('../../../tests/test-helpers/mock-data')
33

44
/* jshint -W117, -W030 */
55
describe('Header Dashboard Controller', function() {
6-
var userService, profileService, identity
76
var profile = mockData.getMockProfile()
8-
var stats = mockData.getMockStats()
9-
var financials = mockData.getMockUserFinancials()
107

118
beforeEach(function() {
129
bard.appModule('topcoder')
1310
bard.inject(this,
1411
'$controller',
1512
'$rootScope',
1613
'$q',
17-
'UserService',
18-
'ProfileService',
1914
'Helpers')
20-
21-
userService = UserService
22-
profileService = ProfileService
23-
24-
identity = function() {
25-
return {
26-
handle: 'albertwang',
27-
userId: 123456
28-
}
29-
}
30-
31-
// mock user api
32-
sinon.stub(userService, 'getUserIdentity', function() {
33-
return {
34-
userId: 1234567,
35-
handle: 'ut',
36-
37-
}
38-
})
39-
40-
// mock profile api
41-
sinon.stub(profileService, 'getUserProfile', function(handle) {
42-
var deferred = $q.defer()
43-
deferred.resolve(profile)
44-
return deferred.promise
45-
})
46-
sinon.stub(profileService, 'getUserStats', function(handle) {
47-
var deferred = $q.defer()
48-
deferred.resolve(stats)
49-
return deferred.promise
50-
})
51-
sinon.stub(profileService, 'getUserFinancials', function(handle) {
52-
var deferred = $q.defer()
53-
deferred.resolve(financials)
54-
return deferred.promise
55-
})
5615
})
5716

5817
bard.verifyNoOutstandingHttpRequests()
@@ -61,33 +20,6 @@ describe('Header Dashboard Controller', function() {
6120
var controller = null
6221
beforeEach( function(){
6322
controller = $controller('HeaderDashboardController', {
64-
UserService : userService,
65-
ProfileService: profileService,
66-
userIdentity: identity,
67-
profile: profile
68-
})
69-
$rootScope.$apply()
70-
})
71-
72-
it('variables should be initialized to correct value', function() {
73-
expect(controller.profile).to.exist
74-
expect(controller.profile.handle).to.equal('albertwang')
75-
})
76-
})
77-
78-
describe('inialization with profile api stats endpoint error', function() {
79-
var controller = null
80-
beforeEach( function(){
81-
profileService.getUserStats.restore()
82-
sinon.stub(profileService, 'getUserStats', function(handle) {
83-
var deferred = $q.defer()
84-
deferred.reject('failed')
85-
return deferred.promise
86-
})
87-
controller = $controller('HeaderDashboardController', {
88-
UserService : userService,
89-
ProfileService: profileService,
90-
userIdentity: identity,
9123
profile: profile
9224
})
9325
$rootScope.$apply()
@@ -99,27 +31,17 @@ describe('Header Dashboard Controller', function() {
9931
})
10032
})
10133

102-
describe('inialization with profile api profile endpoint error', function() {
34+
describe('inialization with null profile', function() {
10335
var controller = null
10436
beforeEach( function(){
105-
profileService.getUserProfile.restore()
106-
sinon.stub(profileService, 'getUserProfile', function(handle) {
107-
var deferred = $q.defer()
108-
deferred.reject('failed')
109-
return deferred.promise
110-
})
11137
controller = $controller('HeaderDashboardController', {
112-
UserService : userService,
113-
ProfileService: profileService,
114-
userIdentity: identity,
115-
profile: profileService.getUserProfile()
38+
profile: null
11639
})
11740
$rootScope.$apply()
11841
})
11942

12043
it('variables should be initialized to correct value', function() {
121-
expect(controller.profile.$$state.status).to.equal(2)
122-
expect(controller.profile.$$state.value).to.equal('failed')
44+
expect(controller.profile).to.be.null
12345
})
12446
})
12547

app/profile/badges/badges.jade

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
header.head
2+
.ngdialog-close
23
.breadcrumbs
34
.handle
45
img.profile-circle(fallback-src=require("../../../assets/images/avatarPlaceholder.png"), ng-src="{{vm.profile.photoURL}}")

app/services/externalAccounts.service.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ import _ from 'lodash'
194194
} else {
195195
logger.error('Unsupported social login backend', provider)
196196

197-
$q.reject({
197+
reject({
198198
status: 'failed',
199199
'error': 'Unsupported social login backend \'' + provider + '\''
200200
})

0 commit comments

Comments
 (0)