|
183 | 183 | ChallengeService.getChallengeTerms(challengeId).then(function (termsList) {
|
184 | 184 | vm.termsList = termsList;
|
185 | 185 | });
|
186 |
| - ChallengeService |
187 |
| - .getUserChallenges(vm.handle, vm.challengeApiParams) |
188 |
| - .then(function (challenge) { |
189 |
| - if (challenge[0] && challenge[0].result.content.length) { |
190 |
| - challenge = challenge[0].result.content[0]; |
191 |
| - vm.userRole = challenge.userDetails ? challenge.userDetails.roles : []; |
192 |
| - } else { |
193 |
| - vm.userRole = []; |
194 |
| - } |
195 |
| - //Set to test value if defined |
196 |
| - vm.userRole = vm.mockUserRole ? vm.mockUserRole : vm.userRole; |
197 |
| - }); |
| 186 | + getUserRole(); |
198 | 187 | ChallengeService
|
199 | 188 | .getChallenge(challengeId)
|
200 | 189 | .then(function (challenge) {
|
|
213 | 202 | .then(function (challenge) {
|
214 | 203 | processChallenge(challenge, vm.handle, vm, ChallengeService);
|
215 | 204 | });
|
| 205 | + getUserRole(); |
| 206 | + } |
| 207 | + |
| 208 | + /** |
| 209 | + * |
| 210 | + * Updates User Role for the challenge |
| 211 | + * @param ChallengeService |
| 212 | + */ |
| 213 | + function getUserRole() { |
| 214 | + ChallengeService |
| 215 | + .getUserChallenges(vm.handle, vm.challengeApiParams) |
| 216 | + .then(function (challenge) { |
| 217 | + if (challenge[0] && challenge[0].result.content.length) { |
| 218 | + challenge = challenge[0].result.content[0]; |
| 219 | + vm.userRole = challenge.userDetails ? challenge.userDetails.roles : []; |
| 220 | + } else { |
| 221 | + vm.userRole = []; |
| 222 | + } |
| 223 | + //Set to test value if defined |
| 224 | + vm.userRole = vm.mockUserRole ? vm.mockUserRole : vm.userRole; |
| 225 | + }); |
216 | 226 | }
|
217 | 227 |
|
218 | 228 | /**
|
|
396 | 406 | }
|
397 | 407 |
|
398 | 408 | // If is not submited, then enable submission
|
399 |
| - if (((moment(challenge.submissionEndDate)) > moment()) && regList.indexOf(handle) > -1) { |
| 409 | + var challengeSubmissionPhase = _.find(vm.challenge.phases, function(phase) { return phase.type === 'Submission'; }) |
| 410 | + if ((challengeSubmissionPhase && challengeSubmissionPhase.status === 'Open') && regList.indexOf(handle) > -1) { |
400 | 411 | vm.challenge.submissionDisabled = false;
|
401 | 412 | }
|
402 | 413 |
|
|
562 | 573 |
|
563 | 574 | function initButtons(vm) {
|
564 | 575 | vm.buttons = [];
|
565 |
| - if (vm.challenge.currentPhaseName === 'Appeals' && vm.hasSubmitted) { |
566 |
| - vm.buttons.push(newButton({ |
567 |
| - text: 'View Scorecard', |
568 |
| - href: '//' + vm.reviewAppURL + '/actions/ViewProjectDetails?pid=' + vm.challenge.challengeId, |
569 |
| - })); |
570 |
| - vm.buttons.push(newButton({ |
571 |
| - text: 'Complete Appeals', |
572 |
| - href: '//' + vm.reviewAppURL + '/actions/EarlyAppeals?pid=' + vm.challenge.challengeId, |
573 |
| - classes: 'unregister' |
574 |
| - })); |
575 |
| - } else { |
| 576 | + if (vm.isDesign) { |
576 | 577 | if (vm.challenge.allowToUnregister) {
|
577 | 578 | vm.buttons.push(newButton({
|
578 | 579 | classes: 'challengeRegisterBtn unregister',
|
|
591 | 592 | classes: (vm.challenge.submissionDisabled ? 'disabled ' : 'disabledNOT'),
|
592 | 593 | text: 'Submit Your Entries'
|
593 | 594 | }));
|
| 595 | + vm.buttons.push(newButton({ |
| 596 | + href: '//studio.' + vm.domain + '/?module=ViewSubmission&ct=' + vm.challenge.challengeId, |
| 597 | + text: 'View Your Submission', |
| 598 | + classes: (vm.challenge.submissionDisabled ? 'disabled ' : 'disabledNOT'), |
| 599 | + })) |
| 600 | + } else { |
| 601 | + if (vm.challenge.currentPhaseName === 'Appeals') { |
| 602 | + vm.buttons.push(newButton({ |
| 603 | + text: 'View Scorecard', |
| 604 | + href: '//' + vm.reviewAppURL + '/actions/ViewProjectDetails?pid=' + vm.challenge.challengeId, |
| 605 | + })); |
| 606 | + if (vm.hasSubmitted) { |
| 607 | + vm.buttons.push(newButton({ |
| 608 | + text: 'Complete Appeals', |
| 609 | + href: '//' + vm.reviewAppURL + '/actions/EarlyAppeals?pid=' + vm.challenge.challengeId, |
| 610 | + classes: 'unregister' |
| 611 | + })); |
| 612 | + } |
| 613 | + } else { |
| 614 | + if (vm.challenge.allowToUnregister) { |
| 615 | + vm.buttons.push(newButton({ |
| 616 | + classes: 'challengeRegisterBtn unregister', |
| 617 | + onClick: vm.unregisterFromChallenge, |
| 618 | + text: 'Unregister From This Challenge' |
| 619 | + })); |
| 620 | + } else { |
| 621 | + vm.buttons.push(newButton({ |
| 622 | + classes: 'challengeRegisterBtn ' + (vm.challenge.registrationDisabled ? 'disabled ' : 'disabledNOT'), |
| 623 | + onClick: vm.registerToChallenge, |
| 624 | + text: 'Register For This Challenge' |
| 625 | + })); |
| 626 | + } |
| 627 | + vm.buttons.push(newButton({ |
| 628 | + href: '/challenge-details/' + vm.challenge.challengeId + '/submit/?type=develop', |
| 629 | + classes: (vm.challenge.submissionDisabled ? 'disabled ' : 'disabledNOT'), |
| 630 | + text: 'Submit Your Entries' |
| 631 | + })); |
| 632 | + if (!vm.challenge.peerReviewDisabled) { |
| 633 | + vm.buttons.push(newButton({ |
| 634 | + href: '/challenges/' + vm.challenge.challengeId + '/reviews/', |
| 635 | + classes: (vm.challenge.peerReviewDisabled ? 'disabled ' : 'disabledNOT'), |
| 636 | + text: 'Review This Challenge' |
| 637 | + })); |
| 638 | + } |
| 639 | + } |
594 | 640 | }
|
595 | 641 | }
|
596 | 642 |
|
|
0 commit comments