diff --git a/app/directives/challenge-tile/challenge-tile.directive.jade b/app/directives/challenge-tile/challenge-tile.directive.jade index c5e96b19a..e9b737bd5 100644 --- a/app/directives/challenge-tile/challenge-tile.directive.jade +++ b/app/directives/challenge-tile/challenge-tile.directive.jade @@ -75,23 +75,10 @@ p BLAH .challenge-details(ng-switch-when="DEVELOP") - p.place(ng-class="{ 'first-place': challenge.wonFirst }") {{challenge.highestPlacement}}#[span {{challenge.highestPlacement | ordinal:true}}] Place - - .challenge-score - p.score {{challenge.userDetails.submissionReviewScore/100 | percentage}} - - p Review Score + dev-challenge-user-place(challenge="challenge", view="view") .challenge-details(ng-switch-when="DESIGN") - p.place(ng-class="{ 'first-place': challenge.wonFirst }") {{challenge.highestPlacement}}#[span {{challenge.highestPlacement | ordinal:true}}] Place - - .thumbnail(ng-click="openLightbox()") - img(ng-src="http://studio.{{DOMAIN}}/studio.jpg?module=DownloadSubmission&sbmid={{challenge.thumbnailId}}&sbt=full", fallback-src="/images/ico-picture.svg") - - .thumbnail-gallery(ng-click="challenge.showLightbox()") - .gallery-icon - - .num-images 1 image + design-challenge-user-place(challenge="challenge", view="view") .challenge.list-view(ng-show="view=='list'", ng-class="challenge.track") .active-challenge(ng-show="challenge.status === 'ACTIVE'") @@ -163,28 +150,7 @@ p Total Points .challenge-details(ng-switch-when="DEVELOP") - .place-date - p.place(ng-class="{ 'first-place': challenge.wonFirst }") {{challenge.highestPlacement}}#[span {{challenge.highestPlacement | ordinal:true}}] Place - p.date-completed {{challenge.submissionEndDate | date : 'MMMM yyyy'}} - - .winner-ribbon(ng-show="challenge.wonFirst") - - .challenge-score - p.score {{challenge.userDetails.submissionReviewScore/100 | percentage}} - - p Review Score + dev-challenge-user-place(challenge="challenge", view="view") .challenge-details(ng-switch-when="DESIGN") - .place-date - p.place(ng-class="{ 'first-place': challenge.wonFirst }") {{challenge.highestPlacement}}#[span {{challenge.highestPlacement | ordinal:true}}] Place - p.date-completed {{challenge.submissionEndDate | date : 'MMMM yyyy'}} - - .winner-ribbon(ng-show="challenge.wonFirst") - - .thumbnail(ng-click="openLightbox()") - img(ng-src="http://studio.{{DOMAIN}}/studio.jpg?module=DownloadSubmission&sbmid={{challenge.thumbnailId}}&sbt=full", fallback-src="/images/ico-picture.svg") - - .thumbnail-gallery(ng-click="challenge.showLightbox()") - .gallery-icon - - .num-images 1 image + design-challenge-user-place(challenge="challenge", view="view") diff --git a/app/directives/challenge-tile/challenge-tile.directive.js b/app/directives/challenge-tile/challenge-tile.directive.js index 38b20b870..60077621c 100644 --- a/app/directives/challenge-tile/challenge-tile.directive.js +++ b/app/directives/challenge-tile/challenge-tile.directive.js @@ -23,15 +23,6 @@ $scope.challenge.subTrack === 'MARATHON_MATCH') { ChallengeService.processPastMarathonMatch($scope.challenge); } - if ($scope.challenge.track == 'DESIGN' && $scope.challenge.userDetails.submissions && $scope.challenge.userDetails.submissions.length > 0) { - $scope.challenge.thumbnailId = $scope.challenge.userDetails.submissions[0].id; - - $scope.challenge.highestPlacement = _.max($scope.challenge.userDetails.submissions, 'placement').placement; - - if ($scope.challenge.highestPlacement == 1) { - $scope.challenge.wonFirst = true; - } - } } function openLightbox() { diff --git a/app/directives/challenge-user-place/challenge-user-place.directive.js b/app/directives/challenge-user-place/challenge-user-place.directive.js new file mode 100644 index 000000000..4cf4d3592 --- /dev/null +++ b/app/directives/challenge-user-place/challenge-user-place.directive.js @@ -0,0 +1,56 @@ +(function() { + 'use strict'; + + angular.module('tcUIComponents') + .directive('devChallengeUserPlace', devChallengeUserPlace) + .directive('designChallengeUserPlace', designChallengeUserPlace); + + function devChallengeUserPlace() { + return { + restrict: 'E', + templateUrl: 'directives/challenge-user-place/dev-challenge-user-place.directive.html', + scope: { + challenge: '=', + view: '=' + }, + controller: ['$scope', 'CONSTANTS', '$attrs', 'ChallengeService', + function($scope, CONSTANTS, $attrs, ChallengeService) { + $scope.DOMAIN = CONSTANTS.domain; + + activate(); + + function activate() { + } + }] + }; + } + + function designChallengeUserPlace() { + return { + restrict: 'E', + templateUrl: 'directives/challenge-user-place/design-challenge-user-place.directive.html', + scope: { + challenge: '=', + view: '=' + }, + controller: ['$scope', 'CONSTANTS', '$attrs', 'ChallengeService', + function($scope, CONSTANTS, $attrs, ChallengeService) { + $scope.DOMAIN = CONSTANTS.domain; + + activate(); + + function activate() { + if ($scope.challenge.userDetails.submissions && $scope.challenge.userDetails.submissions.length > 0) { + $scope.challenge.thumbnailId = $scope.challenge.userDetails.submissions[0].id; + + $scope.challenge.highestPlacement = _.max($scope.challenge.userDetails.submissions, 'placement').placement; + + if ($scope.challenge.highestPlacement == 1) { + $scope.challenge.wonFirst = true; + } + } + } + }] + }; + } +})(); diff --git a/app/directives/challenge-user-place/design-challenge-user-place.directive.jade b/app/directives/challenge-user-place/design-challenge-user-place.directive.jade new file mode 100644 index 000000000..91b40956a --- /dev/null +++ b/app/directives/challenge-user-place/design-challenge-user-place.directive.jade @@ -0,0 +1,29 @@ +.tile-view(ng-show="view === 'tile'") + p.place(ng-class="{ 'first-place': challenge.wonFirst }", ng-show="challenge.highestPlacement") {{challenge.highestPlacement}}#[span {{challenge.highestPlacement | ordinal:true}}] Place + p.place(ng-show="challenge.userStatus === 'NOT_FINISHED'") Didn't Finish + p.place(ng-show="challenge.userStatus === 'PASSED_SCREENING'") Passed Screening + + .thumbnail(ng-click="openLightbox()", ng-class="{hidden: challenge.userStatus !== 'PASSED_REVIEW'}") + img(ng-src="http://studio.{{DOMAIN}}/studio.jpg?module=DownloadSubmission&sbmid={{challenge.thumbnailId}}&sbt=full", fallback-src="/images/ico-picture.svg") + + .thumbnail-gallery(ng-click="challenge.showLightbox()") + .gallery-icon + + .num-images 1 image + +.list-view(ng-show="view === 'list'") + .place-date + p.place(ng-class="{ 'first-place': challenge.wonFirst }", ng-show="challenge.highestPlacement") {{challenge.highestPlacement}}#[span {{challenge.highestPlacement | ordinal:true}}] Place + p.place(ng-show="challenge.userStatus === 'NOT_FINISHED'") Didn't Finish + p.place(ng-show="challenge.userStatus === 'PASSED_SCREENING'") Passed Screening + p.date-completed {{challenge.submissionEndDate | date : 'MMMM yyyy'}} + + .winner-ribbon(ng-show="challenge.wonFirst") + + .thumbnail(ng-click="openLightbox()", ng-class="{hidden: challenge.userStatus !== 'PASSED_REVIEW'}") + img(ng-src="http://studio.{{DOMAIN}}/studio.jpg?module=DownloadSubmission&sbmid={{challenge.thumbnailId}}&sbt=full", fallback-src="/images/ico-picture.svg") + + .thumbnail-gallery(ng-click="challenge.showLightbox()") + .gallery-icon + + .num-images 1 image \ No newline at end of file diff --git a/app/directives/challenge-user-place/dev-challenge-user-place.directive.jade b/app/directives/challenge-user-place/dev-challenge-user-place.directive.jade new file mode 100644 index 000000000..5e3e921ea --- /dev/null +++ b/app/directives/challenge-user-place/dev-challenge-user-place.directive.jade @@ -0,0 +1,23 @@ +.tile-view(ng-show="view === 'tile'") + p.place(ng-class="{ 'first-place': challenge.wonFirst }", ng-show="challenge.highestPlacement") {{challenge.highestPlacement}}#[span {{challenge.highestPlacement | ordinal:true}}] Place + p.place(ng-show="challenge.userStatus === 'NOT_FINISHED'") Didn't Finish + p.place(ng-show="challenge.userStatus === 'PASSED_SCREENING'") Passed Screening + + .challenge-score(ng-class="{hidden: challenge.userStatus !== 'PASSED_REVIEW'}") + p.score {{challenge.userDetails.submissionReviewScore/100 | percentage}} + + p Review Score + +.list-view(ng-show="view === 'list'") + .place-date + p.place(ng-class="{ 'first-place': challenge.wonFirst }", ng-show="challenge.highestPlacement") {{challenge.highestPlacement}}#[span {{challenge.highestPlacement | ordinal:true}}] Place + p.place(ng-show="challenge.userStatus === 'NOT_FINISHED'") Didn't Finish + p.place(ng-show="challenge.userStatus === 'PASSED_SCREENING'") Passed Screening + p.date-completed {{challenge.submissionEndDate | date : 'MMMM yyyy'}} + + .winner-ribbon(ng-show="challenge.wonFirst") + + .challenge-score(ng-class="{hidden: challenge.userStatus !== 'PASSED_REVIEW'}") + p.score {{challenge.userDetails.submissionReviewScore/100 | percentage}} + + p Review Score \ No newline at end of file diff --git a/app/index.jade b/app/index.jade index 2cd6d8e45..605334d58 100644 --- a/app/index.jade +++ b/app/index.jade @@ -69,7 +69,9 @@ html link(rel="stylesheet", href="assets/css/directives/external-link-data.css") link(rel="stylesheet", href="assets/css/directives/external-account.css") link(rel="stylesheet", href="assets/css/directives/distribution-graph.css") + link(rel="stylesheet", href="assets/css/directives/dev-challenge-user-place.css") link(rel="stylesheet", href="assets/css/directives/design-lightbox.css") + link(rel="stylesheet", href="assets/css/directives/design-challenge-user-place.css") link(rel="stylesheet", href="assets/css/directives/challenge-tile.css") link(rel="stylesheet", href="assets/css/directives/badge-tooltip.css") link(rel="stylesheet", href="assets/css/account/reset-password.css") @@ -155,6 +157,7 @@ html script(src="directives/badges/badge-tooltip.directive.js") script(src="directives/busy-button/busy-button.directive.js") script(src="directives/challenge-tile/challenge-tile.directive.js") + script(src="directives/challenge-user-place/challenge-user-place.directive.js") script(src="directives/distribution-graph/distribution-graph.directive.js") script(src="directives/external-account/external-account.directive.js") script(src="directives/focus-on.directive.js") diff --git a/app/my-challenges/my-challenges.controller.js b/app/my-challenges/my-challenges.controller.js index 461d4f6a1..95a1ee0aa 100644 --- a/app/my-challenges/my-challenges.controller.js +++ b/app/my-challenges/my-challenges.controller.js @@ -81,7 +81,11 @@ return ChallengeService.getUserChallenges(handle, params) .then(function(challenges){ - ChallengeService.processActiveDevDesignChallenges(challenges); + if (vm.statusFilter == 'active') { + ChallengeService.processActiveDevDesignChallenges(challenges); + } else { + ChallengeService.processPastChallenges(challenges); + } if (challenges.length > 0) { vm.myChallenges = challenges; vm.userHasChallenges = true; diff --git a/app/services/challenge.service.js b/app/services/challenge.service.js index 400775275..febcf54d0 100644 --- a/app/services/challenge.service.js +++ b/app/services/challenge.service.js @@ -171,9 +171,36 @@ function processPastChallenges(challenges) { angular.forEach(challenges, function(challenge) { - if (challenge.userDetails && Array.isArray(challenge.userDetails.winningPlacements)) { - challenge.highestPlacement = _.max(challenge.userDetails.winningPlacements); - challenge.wonFirst = challenge.highestPlacement == 1; + if (challenge.userDetails) { + // TODO placement logic for challenges can be moved to their corresponding user place directive + // process placement for challenges having winningPlacements array in response + if (Array.isArray(challenge.userDetails.winningPlacements)) { + challenge.highestPlacement = _.max(challenge.userDetails.winningPlacements); + challenge.wonFirst = challenge.highestPlacement == 1; + if (challenge.highestPlacement === 0) { + challenge.highestPlacement = null; + } + } + // process placement for design challenges + if (challenge.track == 'DESIGN' && challenge.userDetails.submissions && challenge.userDetails.submissions.length > 0) { + challenge.thumbnailId = challenge.userDetails.submissions[0].id; + + challenge.highestPlacement = _.max(challenge.userDetails.submissions, 'placement').placement; + + if (challenge.highestPlacement == 1) { + challenge.wonFirst = true; + } + } + + if (challenge.userDetails.hasUserSubmittedForReview) { + if (!challenge.highestPlacement) { + challenge.userStatus = "PASSED_SCREENING"; + } else { + challenge.userStatus = "PASSED_REVIEW"; + } + } else { + challenge.userStatus = "NOT_FINISHED"; + } } }); } diff --git a/assets/css/directives/challenge-tile.scss b/assets/css/directives/challenge-tile.scss index 6c1c41116..8732eb383 100644 --- a/assets/css/directives/challenge-tile.scss +++ b/assets/css/directives/challenge-tile.scss @@ -270,50 +270,7 @@ challenge-tile .challenge.tile-view { &.DATA_SCIENCE { flex: 2; justify-content: center; - } - - .place { - margin-bottom: 30px; - @include sofia-pro-regular; - font-size: 20px; - color: $gray-darkest; - text-transform: uppercase; - - &.first-place { - font-weight: bold; - color: $black; - } - - span { - @include superscript; - text-transform: lowercase; - } - } - - .challenge-score { - width: 84px; - height: 84px; - display: flex; - flex-direction: column; - margin-bottom: 70px; - text-align: center; - background-color: #F6F6F6; - - .score { - margin-top: 28px; - margin-bottom: 5px; - @include sofia-pro-bold; - font-size: 18px; - color: $gray-darkest; - } - - p:last-child { - @include sofia-pro-medium; - font-size: 9px; - color: #A3A3AE; - text-transform: uppercase; - } - } + } .marathon-score { margin-bottom: 70px; @@ -336,46 +293,6 @@ challenge-tile .challenge.tile-view { text-transform: uppercase; } } - - .thumbnail { - position: relative; - width: 268px; - height: 200px; - overflow: hidden; - - img { - width: 100%; - height: auto; - overflow: hidden; - } - - .thumbnail-gallery { - position: absolute; - display: flex; - flex-direction: row; - align-items: center; - width: 270px; - height: 32px; - bottom: 0; - left: 0; - background-color: rgba(0, 0, 0, 0.4); - cursor: pointer; - - .gallery-icon { - margin-left: 10px; - @include background-image-size(21px, 17px); - background: url(/images/ico-gallery.svg); - } - - .num-images { - margin-left: 8px; - @include sofia-pro-regular; - font-size: 10px; - color: $gray-lighter; - text-transform: uppercase; - } - } - } } } @@ -506,67 +423,6 @@ challenge-tile .challenge.list-view { } } - .place-date { - display: flex; - flex-direction: column; - - .place { - @include sofia-pro-regular; - font-size: 20px; - color: $gray-darkest; - text-transform: uppercase; - - &.first-place { - font-weight: bold; - color: $black; - } - - span { - @include superscript; - text-transform: lowercase; - } - } - - .date-completed { - @include sofia-pro-regular; - font-size: 14px; - line-height: 18px; - text-transform: uppercase; - color: #A3A3AE; - margin-top: 9px; - } - } - - .winner-ribbon { - @include background-image-size(73px, 26px); - background: url(/images/ico-winner-ribbon.svg); - align-self: flex-start; - } - - .challenge-score { - width: 84px; - height: 84px; - display: flex; - flex-direction: column; - text-align: center; - background-color: #F6F6F6; - - .score { - margin-top: 28px; - margin-bottom: 5px; - @include sofia-pro-bold; - font-size: 18px; - color: $gray-darkest; - } - - p:last-child { - @include sofia-pro-medium; - font-size: 9px; - color: #A3A3AE; - text-transform: uppercase; - } - } - .marathon-score { text-align: center; @@ -587,46 +443,6 @@ challenge-tile .challenge.list-view { } } - .thumbnail { - position: relative; - width: 84px; - height: 84px; - overflow: hidden; - - img { - width: 100%; - height: auto; - overflow: hidden; - } - - .thumbnail-gallery { - position: absolute; - display: flex; - flex-direction: row; - align-items: center; - width: 84px; - height: 32px; - bottom: 0; - left: 0; - background-color: rgba(0, 0, 0, 0.4); - cursor: pointer; - - .gallery-icon { - margin-left: 10px; - @include background-image-size(21px, 17px); - background: url(/images/ico-gallery.svg); - } - - .num-images { - margin-left: 8px; - @include sofia-pro-regular; - font-size: 10px; - color: $gray-lighter; - text-transform: uppercase; - } - } - } - .phase-action { .submit { display: inline-block; diff --git a/assets/css/directives/design-challenge-user-place.scss b/assets/css/directives/design-challenge-user-place.scss new file mode 100644 index 000000000..283a02d15 --- /dev/null +++ b/assets/css/directives/design-challenge-user-place.scss @@ -0,0 +1,161 @@ +@import 'topcoder-includes'; +@import '../partials/combined'; + +// styling for tile view +design-challenge-user-place { + + .tile-view { + display: flex; + flex-direction: column; + align-items: center; + + .place { + margin-bottom: 30px; + @include sofia-pro-regular; + font-size: 20px; + color: $gray-darkest; + text-transform: uppercase; + + &.first-place { + font-weight: bold; + color: $black; + } + + span { + @include superscript; + text-transform: lowercase; + } + } + + .thumbnail { + position: relative; + width: 268px; + height: 200px; + overflow: hidden; + + img { + width: 100%; + height: auto; + overflow: hidden; + } + + .thumbnail-gallery { + position: absolute; + display: flex; + flex-direction: row; + align-items: center; + width: 270px; + height: 32px; + bottom: 0; + left: 0; + background-color: rgba(0, 0, 0, 0.4); + cursor: pointer; + + .gallery-icon { + margin-left: 10px; + @include background-image-size(21px, 17px); + background: url(/images/ico-gallery.svg); + } + + .num-images { + margin-left: 8px; + @include sofia-pro-regular; + font-size: 10px; + color: $gray-lighter; + text-transform: uppercase; + } + } + } + } + +} + +// styling for list view +design-challenge-user-place { + width: 100%; + + .list-view { + display: flex; + flex-direction: row; + justify-content: space-between; + align-items: center; + + .place-date { + display: flex; + flex-direction: column; + + .place { + @include sofia-pro-light; + font-size: 18px; + line-height: 23px; + color: $gray-darkest; + text-transform: uppercase; + + &.first-place { + font-weight: bold; + color: $black; + } + + span { + @include superscript; + text-transform: lowercase; + } + } + + .date-completed { + @include sofia-pro-regular; + font-size: 14px; + line-height: 18px; + text-transform: uppercase; + color: #A3A3AE; + margin-top: 9px; + } + } + + .winner-ribbon { + @include background-image-size(73px, 26px); + background: url(/images/ico-winner-ribbon.svg); + align-self: flex-start; + } + + .thumbnail { + position: relative; + width: 84px; + height: 84px; + overflow: hidden; + + img { + width: 100%; + height: auto; + overflow: hidden; + } + + .thumbnail-gallery { + position: absolute; + display: flex; + flex-direction: row; + align-items: center; + width: 84px; + height: 32px; + bottom: 0; + left: 0; + background-color: rgba(0, 0, 0, 0.4); + cursor: pointer; + + .gallery-icon { + margin-left: 10px; + @include background-image-size(21px, 17px); + background: url(/images/ico-gallery.svg); + } + + .num-images { + margin-left: 8px; + @include sofia-pro-regular; + font-size: 10px; + color: $gray-lighter; + text-transform: uppercase; + } + } + } + } +} \ No newline at end of file diff --git a/assets/css/directives/dev-challenge-user-place.scss b/assets/css/directives/dev-challenge-user-place.scss new file mode 100644 index 000000000..7fe3531ba --- /dev/null +++ b/assets/css/directives/dev-challenge-user-place.scss @@ -0,0 +1,126 @@ +@import 'topcoder-includes'; +@import '../partials/combined'; + +// styling for tile view +dev-challenge-user-place { + + .tile-view { + .place { + margin-bottom: 30px; + @include sofia-pro-regular; + font-size: 20px; + color: $gray-darkest; + text-transform: uppercase; + + &.first-place { + font-weight: bold; + color: $black; + } + + span { + @include superscript; + text-transform: lowercase; + } + } + + .challenge-score { + width: 84px; + height: 84px; + display: flex; + flex-direction: column; + margin-bottom: 70px; + text-align: center; + background-color: #F6F6F6; + + .score { + margin-top: 28px; + margin-bottom: 5px; + @include sofia-pro-bold; + font-size: 18px; + color: $gray-darkest; + } + + p:last-child { + @include sofia-pro-medium; + font-size: 9px; + color: #A3A3AE; + text-transform: uppercase; + } + } + } + +} + +// styling for list view +dev-challenge-user-place { + width: 100%; + + .list-view { + display: flex; + flex-direction: row; + justify-content: space-between; + align-items: center; + + .place-date { + display: flex; + flex-direction: column; + + .place { + @include sofia-pro-light; + font-size: 18px; + line-height: 23px; + color: $gray-darkest; + text-transform: uppercase; + + &.first-place { + font-weight: bold; + color: $black; + } + + span { + @include superscript; + text-transform: lowercase; + } + } + + .date-completed { + @include sofia-pro-regular; + font-size: 14px; + line-height: 18px; + text-transform: uppercase; + color: #A3A3AE; + margin-top: 9px; + } + } + + .winner-ribbon { + @include background-image-size(73px, 26px); + background: url(/images/ico-winner-ribbon.svg); + align-self: flex-start; + } + + .challenge-score { + width: 84px; + height: 84px; + display: flex; + flex-direction: column; + text-align: center; + background-color: #F6F6F6; + + .score { + margin-top: 28px; + margin-bottom: 5px; + @include sofia-pro-bold; + font-size: 18px; + color: $gray-darkest; + } + + p:last-child { + @include sofia-pro-medium; + font-size: 9px; + color: #A3A3AE; + text-transform: uppercase; + } + } + } +} \ No newline at end of file diff --git a/assets/css/topcoder.scss b/assets/css/topcoder.scss index d7e24194a..14101408c 100644 --- a/assets/css/topcoder.scss +++ b/assets/css/topcoder.scss @@ -11,6 +11,15 @@ body { } } +// TODO move hidden and visible classes to ui kit +.hidden { + visibility: hidden; +} + +.visible { + visibility: visible; +} + .fold-wrapper { min-height: 100%; @media only screen and (min-width : 992px) {