From 3ac6e07349d15daecbbd385ada660dfa5c4045f0 Mon Sep 17 00:00:00 2001 From: vikasrohit Date: Fri, 30 Oct 2015 14:14:44 -0700 Subject: [PATCH] SUP-2392, Extra spacing on profile if section is missing -- Fixed --- app/profile/about/about.controller.js | 2 +- app/profile/about/about.jade | 6 +++--- app/profile/profile.controller.js | 16 ++++++++++++++-- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/app/profile/about/about.controller.js b/app/profile/about/about.controller.js index 82beac1e8..564986821 100644 --- a/app/profile/about/about.controller.js +++ b/app/profile/about/about.controller.js @@ -61,7 +61,7 @@ vm.categories = profileVm.categories; vm.marathonRating = profileVm.categories['MARATHON_MATCH'] && profileVm.categories['MARATHON_MATCH'].rating; vm.SRMRating = profileVm.categories['SRM'] && profileVm.categories['SRM'].rating; - vm.displaySection.stats = profileVm.showEditProfileLink || _.get(vm, 'categories.DESIGN', []).length || _.get(vm, 'categories.DEVELOP', []).length || _.get(vm, 'categories.DATA_SCIENCE', []).length || _.get(vm, 'categories.COPILOT', []).length; + vm.displaySection.stats = profileVm.showEditProfileLink; }); profileVm.skillsPromise.then(function() { diff --git a/app/profile/about/about.jade b/app/profile/about/about.jade index a3e459ffc..d86802bf8 100644 --- a/app/profile/about/about.jade +++ b/app/profile/about/about.jade @@ -12,7 +12,7 @@ .empty-profile .empty-state - empty-state-placeholder(state-name="profile-empty", show="profileVm.status.skills === 'ready' && profileVm.status.stats === 'ready' && profileVm.status.externalLinks === 'ready' && !profileVm.showEditProfileLink && !profileVm.numProjects && (!profileVm.skills || (profileVm.skills && profileVm.skills.length == 0)) && !vm.hasLinks") + empty-state-placeholder(state-name="profile-empty", show="profileVm.status.skills === 'ready' && profileVm.status.stats === 'ready' && profileVm.status.externalLinks === 'ready' && !profileVm.showEditProfileLink && !profileVm.showTCActivity && (!profileVm.skills || (profileVm.skills && profileVm.skills.length == 0)) && !vm.hasLinks") .sample-image img(ng-src="/images/robot.svg") @@ -39,12 +39,12 @@ #tcActivity - tc-section(ng-show="vm.displaySection.stats", state="profileVm.status.stats") + tc-section(ng-show="vm.displaySection.stats || profileVm.showTCActivity", state="profileVm.status.stats") .categories .empty-state - empty-state-placeholder(state-name="profile-topcoder-activity", show="!profileVm.numProjects", theme="offwhite") + empty-state-placeholder(state-name="profile-topcoder-activity", show="!profileVm.showTCActivity", theme="offwhite") .track( ng-repeat="track in profileVm.profile.tracks", diff --git a/app/profile/profile.controller.js b/app/profile/profile.controller.js index 4eddf8e0b..30f6a1084 100644 --- a/app/profile/profile.controller.js +++ b/app/profile/profile.controller.js @@ -42,26 +42,38 @@ if (stats.COPILOT && stats.COPILOT.contests && vm.profile.tracks.indexOf('COPILOT') == -1) { vm.profile.tracks.push('COPILOT'); } - vm.numProjects = vm.stats.challenges; + // flag to indicate if the member has acitivity on topcoder to be shown + // it is set to true, if we get at least one track with showTrack == true + vm.showTCActivity = false; vm.numWins = vm.stats.wins; vm.categories = ProfileService.getRanks(vm.stats); for(var trackName in vm.categories) { // trackStats is an array of subtrack rankings along with track stats properties (e.g showTrack) var trackStats = vm.categories[trackName]; + // flag to indicate if the member has activity for this track + // it is set to true, if we get at least one subtrack which can be shown for topcoder activity trackStats.showTrack = false; + // if track has subtracks with stats if (trackStats && trackStats.length > 0) { + // iterate over each subtrack stat and determine if we need to show as stat trackStats.forEach(function(subTrackRank) { + // process subtack stat UserStatsService.processStatRank(subTrackRank); + // if any of the subtrack has stat to show, enable the showTrack flag for the track if (subTrackRank.showStats) { trackStats.showTrack = true; } }); } + // if any of the track has stat to show, enable the showTCActivity flag to true + if (trackStats.showTrack) { + vm.showTCActivity = true; + } } } else { vm.stats = false; // vm.profile.tracks = []; - vm.numProjects = 0; + vm.showTCActivity = 0; vm.numWins = 0; vm.categories = {}; }