Skip to content

Commit 298d80e

Browse files
authored
Merge pull request topcoder-archive#1015 from appirio-tech/dev
Latest Listings
2 parents aecc440 + d6679a1 commit 298d80e

File tree

3 files changed

+73
-5
lines changed

3 files changed

+73
-5
lines changed

app/listings/listings.controller.js

Lines changed: 71 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import _ from 'lodash'
12
import angular from 'angular'
23
import { loadUser } from '../services/userv3.service.js'
34

@@ -13,24 +14,91 @@ import { loadUser } from '../services/userv3.service.js'
1314

1415
function ListingsCtrl(CONSTANTS, logger, $q, TcAuthService, UserService, UserStatsService, ProfileService,
1516
ChallengeService, ExternalAccountService, ngDialog, $anchorScroll, $scope) {
17+
var vm = this
18+
var handle
19+
vm.neverParticipated = false
20+
vm.loading = true
21+
vm.userHasChallenges = true
22+
vm.challengeView = 'tile'
1623

1724
activate()
1825

1926
function activate() {
2027
$scope.myChallenges = []
21-
$scope.userProps = { isAuth: false }
28+
$scope.userProps = { isAuth: false, myChallenges: [] }
2229
logger.debug('Calling ListingsController activate()')
23-
30+
vm.myChallenges = []
2431
loadUser().then(function(token) {
32+
handle = UserService.getUserIdentity().handle
33+
// mock current user have this challenges
34+
vm.myChallenges.push({'id':30056409})
35+
vm.myChallenges.push({'id':30056067})
36+
vm.myChallenges.push({'id':16870})
37+
2538
// update auth flag
2639
if(TcAuthService.isAuthenticated()) {
27-
$scope.userProps = { isAuth: true }
40+
getChallenges(handle)
41+
$scope.userProps = { isAuth: true, myChallenges: vm.myChallenges }
2842
}
2943
}, function(error) {
3044
// do nothing, just show non logged in state of navigation bar
3145
})
3246
}
3347

48+
function getChallenges(handle) {
49+
var marathonMatchParams = {
50+
limit: 8,
51+
filter: 'status=active'
52+
}
53+
54+
var challengeParams = {
55+
limit: 8,
56+
orderBy: 'submissionEndDate',
57+
filter: 'status=active'
58+
}
59+
60+
$q.all([
61+
ChallengeService.getUserMarathonMatches(handle, marathonMatchParams),
62+
ChallengeService.getUserChallenges(handle, challengeParams)
63+
]).then(function(challenges){
64+
var marathonMatches = challenges[0]
65+
var devDesignChallenges = challenges[1]
66+
67+
if (!marathonMatches.length && !devDesignChallenges.length) {
68+
vm.userHasChallenges = false
69+
_checkForParticipation().then(function() {
70+
vm.loading = false
71+
})
72+
} else {
73+
ChallengeService.processActiveDevDesignChallenges(devDesignChallenges)
74+
ChallengeService.processActiveMarathonMatches(marathonMatches)
75+
var userChallenges = marathonMatches.concat(devDesignChallenges)
76+
77+
userChallenges = _.sortBy(userChallenges, function(n) {
78+
return n.registrationEndDate
79+
})
80+
vm.myChallenges = userChallenges.reverse().slice(0, 8)
81+
82+
// update myChallenges
83+
$scope.userProps = { isAuth: true, myChallenges: vm.myChallenges }
84+
85+
vm.userHasChallenges = true
86+
vm.loading = false
87+
}
88+
})
89+
.catch(function(err) {
90+
logger.error('Error getting challenges and marathon matches', err)
91+
92+
vm.userHasChallenges = true
93+
vm.loading = false
94+
})
95+
}
96+
97+
function _checkForParticipation() {
98+
return ChallengeService.checkChallengeParticipation(handle, function(participated) {
99+
vm.neverParticipated = !participated
100+
})
101+
}
34102
}
35103

36104
})()

assets/css/directives/badge-tooltip.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@
438438
background-position: 0px -672px;
439439
}
440440
.Predix-Community {
441-
background-position: -50px -672px;
441+
background-position: -47px -672px;
442442
}
443443
.iOS-Community {
444444
background-position: -95px -672px;

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
"appirio-styles": "0.x.x",
5757
"appirio-tech-ng-iso-constants": "^1.0.6",
5858
"appirio-tech-ng-ui-components": "^2.1.2",
59-
"appirio-tech-react-components": "nomo-kazza/react-components.git#challenge-listings",
59+
"appirio-tech-react-components": "appirio-tech/react-components.git#cl-misc-fixes-2",
6060
"auth0-angular": "^4.1.0",
6161
"auth0-js": "^6.8.0",
6262
"d3": "^3.5.14",

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy