Skip to content

Commit

Permalink
Merge pull request #38359 from code-dot-org/volunteer-map-hide-empty-…
Browse files Browse the repository at this point in the history
…values

Volunteer map: hide empty values
  • Loading branch information
breville committed Jan 4, 2021
2 parents f13caa2 + d8a298e commit c47eb84
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions pegasus/sites.v3/code.org/public/js/volunteer-local.js
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,10 @@ function createMapEntryDetail(elements) {
return div;
}

function hasContent(value) {
return value && value !== "null";
}

function compileHTML(index, location) {
let html = createHTMLElement("div");

Expand All @@ -497,13 +501,13 @@ function compileHTML(index, location) {
])
);

if (location.company_s) {
if (hasContent(location.company_s)) {
html.appendChild(
createMapEntryDetail([document.createTextNode(location.company_s)])
);
}

if (location.experience_s) {
if (hasContent(location.experience_s)) {
html.appendChild(
createMapEntryDetail([
createHTMLElement("strong", null, "Experience:"),
Expand All @@ -512,7 +516,7 @@ function compileHTML(index, location) {
);
}

if (location.location_flexibility_ss) {
if (hasContent(location.location_flexibility_ss)) {
location.location_flexibility_ss.forEach(function(field, index) {
location.location_flexibility_ss[index] = i18n("location_" + field);
});
Expand All @@ -527,7 +531,7 @@ function compileHTML(index, location) {
);
}

if (location.description_s) {
if (hasContent(location.description_s)) {
html.appendChild(
createMapEntryDetail([
createHTMLElement("strong", null, "About me:"),
Expand All @@ -536,7 +540,7 @@ function compileHTML(index, location) {
);
}

if (location.linkedin_s) {
if (hasContent(location.linkedin_s)) {
if (!location.linkedin_s.match(/^https?:\/\//i)) {
location.linkedin_s = "http://" + location.linkedin_s;
}
Expand All @@ -549,7 +553,7 @@ function compileHTML(index, location) {
);
}

if (location.facebook_s) {
if (hasContent(location.facebook_s)) {
if (!location.facebook_s.match(/^https?:\/\//i)) {
location.facebook_s = "http://" + location.facebook_s;
}
Expand Down

0 comments on commit c47eb84

Please sign in to comment.