Commit 231577f2 authored by Rolf Aas's avatar Rolf Aas
Browse files

Simplified display of diets

parent 1147b2e9
......@@ -70,33 +70,37 @@ window.addEventListener("DOMContentLoaded", async () => {
let diet = diets[j];
let dietAnchor = dietAnchors[j];
switch (event.currentTarget.id) {
case "list-my-diets-list":
if (diet.owner == currentUser.url) {
dietAnchor.classList.remove('hide');
} else {
dietAnchor.classList.add('hide');
}
break;
case "list-athlete-diets-list":
if (currentUser.athletes && currentUser.athletes.includes(diet.owner)) {
dietAnchor.classList.remove('hide');
} else {
dietAnchor.classList.add('hide');
}
break;
case "list-public-diets-list":
if (diet.visibility == "PU") {
dietAnchor.classList.remove('hide');
} else {
dietAnchor.classList.add('hide');
}
break;
default:
dietAnchor.classList.remove('hide');
break;
}
add_or_remove_diet_anchor(event.currentTarget, currentUser, dietAnchor, diet);
}
});
}
});
\ No newline at end of file
});
function add_or_remove_diet_anchor(currentTarget, currentUser, dietAnchor, diet) {
switch (currentTarget.id) {
case "list-my-diets-list":
if (diet.owner == currentUser.url) {
dietAnchor.classList.remove('hide');
} else {
dietAnchor.classList.add('hide');
}
break;
case "list-athlete-diets-list":
if (currentUser.athletes && currentUser.athletes.includes(diet.owner)) {
dietAnchor.classList.remove('hide');
} else {
dietAnchor.classList.add('hide');
}
break;
case "list-public-diets-list":
if (diet.visibility == "PU") {
dietAnchor.classList.remove('hide');
} else {
dietAnchor.classList.add('hide');
}
break;
default:
dietAnchor.classList.remove('hide');
break;
}
}
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment