From aba65a82bd20bbef40c2522435a6d5f933ef7f3c Mon Sep 17 00:00:00 2001 From: Brian Smith Date: Tue, 3 Mar 2015 21:29:10 -0500 Subject: [PATCH] let caller decide what to display if no genres are found --- web/app/assets/javascripts/profile.js | 19 ++++++++++++------- web/app/assets/javascripts/profile_utils.js | 2 +- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/web/app/assets/javascripts/profile.js b/web/app/assets/javascripts/profile.js index 07a6c7d3a..111fa0c88 100644 --- a/web/app/assets/javascripts/profile.js +++ b/web/app/assets/javascripts/profile.js @@ -408,7 +408,6 @@ function hideElements(elements) { $.each(elements, function(index, val) { - console.log('hiding ' + val.id); val.hide(); }); } @@ -520,7 +519,7 @@ // genres $genres.empty(); var profileGenres = profileUtils.profileGenreList(user.genres); - $genres.append(profileGenres); + $genres.append(profileGenres.length > 0 ? profileGenres : NOT_SPECIFIED_TEXT); // concert gigs var concertGigCount = user.concert_count; @@ -680,7 +679,8 @@ if (user.paid_sessions) { $paidGigSection.show(); - $paidGigDetails.find("ul li:nth-child(1)").append(profileUtils.paidSessionGenreList(user.genres)); + var genreList = profileUtils.paidSessionGenreList(user.genres); + $paidGigDetails.find("ul li:nth-child(1)").append(genreList.length > 0 ? genreList : NOT_SPECIFIED_TEXT); var hourlyRate = user.paid_sessions_hourly_rate; $paidGigDetails.find("ul li:nth-child(2)").append(hourlyRate ? hourlyRate : NOT_SPECIFIED_TEXT); @@ -695,7 +695,9 @@ // free sessions if (user.free_sessions) { $freeGigSection.show(); - $freeGigDetails.find("ul li:nth-child(1)").append(profileUtils.freeSessionGenreList(user.genres)); + + var genreList = profileUtils.freeSessionGenreList(user.genres); + $freeGigDetails.find("ul li:nth-child(1)").append(genreList.length > 0 ? genreList : NOT_SPECIFIED_TEXT); } else { $freeGigSection.hide(); @@ -705,7 +707,8 @@ if (user.cowriting) { $cowritingSection.show(); - $cowritingDetails.find("ul li:nth-child(1)").append(profileUtils.cowritingGenreList(user.genres)); + var genreList = profileUtils.cowritingGenreList(user.genres); + $cowritingDetails.find("ul li:nth-child(1)").append(genreList.length > 0 ? genreList : NOT_SPECIFIED_TEXT); var purpose = user.cowriting_purpose; $cowritingDetails.find("ul li:nth-child(2)").append(purpose ? profileUtils.cowritingPurposeMap[purpose] : NOT_SPECIFIED_TEXT); @@ -718,7 +721,8 @@ if (user.traditional_band) { $traditionalBandSection.show(); - $traditionalBandDetails.find("ul li:nth-child(1)").append(profileUtils.traditionalBandGenreList(user.genres)); + var genreList = profileUtils.traditionalBandGenreList(user.genres); + $traditionalBandDetails.find("ul li:nth-child(1)").append(genreList.length > 0 ? genreList : NOT_SPECIFIED_TEXT); var commitment = user.traditional_band_commitment; $traditionalBandDetails.find("ul li:nth-child(2)").append(commitment ? profileUtils.bandCommitmentMap[commitment] : NOT_SPECIFIED_TEXT); @@ -735,7 +739,8 @@ if (user.virtual_band) { $virtualBandSection.show(); - $virtualBandDetails.find("ul li:nth-child(1)").append(profileUtils.virtualBandGenreList(user.genres)); + var genreList = profileUtils.virtualBandGenreList(user.genres); + $virtualBandDetails.find("ul li:nth-child(1)").append(genreList.length > 0 ? genreList : NOT_SPECIFIED_TEXT); var commitment = user.virtual_band_commitment; $virtualBandDetails.find("ul li:nth-child(2)").append(commitment ? profileUtils.bandCommitmentMap[commitment] : NOT_SPECIFIED_TEXT); diff --git a/web/app/assets/javascripts/profile_utils.js b/web/app/assets/javascripts/profile_utils.js index 57b51448f..6ee38beb0 100644 --- a/web/app/assets/javascripts/profile_utils.js +++ b/web/app/assets/javascripts/profile_utils.js @@ -71,7 +71,7 @@ } } - return list.length > 0 ? list : 'None specified'; + return list.length > 0; } // profile genres