100
).toFixed(1)
+ // Hide progress bar if percentage is NaN
+ const showTasksBar = Number.isFinite(Number(tasksPercentComplete))
+ const showFormsBar = Number.isFinite(Number(formsPercentComplete))
+ const showNoTasksNote = !showTasksBar
+ const showNoFormsNote = !showFormsBar
+
// Create the card container
const card = document.createElement("div")
card.className = "small-card clickable"
@@ -1051,28 +1093,57 @@
${name} Details
title.textContent = member.name
card.appendChild(title)
- // Create a container for the donut chart
- const containerId = `member-role-chart-${member.projectMemberId}`
- const chartDiv = document.createElement("div")
- chartDiv.id = containerId
- card.appendChild(chartDiv)
+ // Create a container for the donut chart or an empty note
+ const hasRoles = member.roles.length > 0
+
+ let chartDiv = null
+ if (hasRoles) {
+ chartDiv = document.createElement("div")
+ chartDiv.id = `member-role-chart-${member.projectMemberId}`
+ card.appendChild(chartDiv)
+ } else {
+ const note = document.createElement("p")
+ note.className = "empty-note"
+ note.textContent = "No roles"
+ card.appendChild(note)
+ }
// Add progress bars for tasks and forms
const progressBars = `
-
-
-
-
-
-
- `
+ ${
+ showTasksBar
+ ? `
+
+
+
`
+ : `
No tasks
`
+ }
+ ${
+ showFormsBar
+ ? `
+
+
+
`
+ : `
No forms
`
+ }
+`
card.innerHTML += progressBars // Append progress bars to the card
- // Append the card to the members section and render the chart
+ // Append the card to the members section and render the chart if appropriate
const memberRoleChartContainer = document.getElementById("members-section")
if (memberRoleChartContainer) {
memberRoleChartContainer.appendChild(card)
- createDonutChart(data, containerId, `${member.name}`)
+ if (hasRoles) {
+ createDonutChart(
+ data,
+ `member-role-chart-${member.projectMemberId}`,
+ `${member.name}`
+ )
+ }
} else {
console.error("Main container for member charts not found!")
}
@@ -1157,32 +1228,57 @@
${name} Details
title.textContent = team.teamName
card.appendChild(title)
- // Create a container for the donut chart
- const containerId = `team-role-chart-${team.teamId}`
- const chartDiv = document.createElement("div")
- chartDiv.id = containerId
- card.appendChild(chartDiv)
+ // Create a container for the donut chart or an empty note
+ const hasRoles = team.roles.length > 0
+
+ let chartDiv = null
+ if (hasRoles) {
+ chartDiv = document.createElement("div")
+ chartDiv.id = `team-role-chart-${team.teamId}`
+ card.appendChild(chartDiv)
+ } else {
+ const note = document.createElement("p")
+ note.className = "empty-note"
+ note.textContent = "No roles"
+ card.appendChild(note)
+ }
+
+ // NaN guards for progress bars
+ const showTeamTasksBar = Number.isFinite(Number(team.tasksPercentComplete))
+ const showTeamFormsBar = Number.isFinite(Number(team.formsPercentComplete))
// Add progress bars for tasks and forms
const progressBars = `
-
-
-
-
-
-
- `
+ ${
+ showTeamTasksBar
+ ? `
+
+
+
`
+ : `
No tasks
`
+ }
+ ${
+ showTeamFormsBar
+ ? `
+
+
+
`
+ : `
No forms
`
+ }
+`
card.innerHTML += progressBars // Append progress bars to the card
- // Append the card to the teams section and render the chart
+ // Append the card to the teams section and render the chart if appropriate
const teamRoleChartContainer = document.getElementById("teams-section")
if (teamRoleChartContainer) {
teamRoleChartContainer.appendChild(card)
- createDonutChart(data, containerId, `${team.teamName}`)
+ if (hasRoles) {
+ createDonutChart(data, `team-role-chart-${team.teamId}`, `${team.teamName}`)
+ }
} else {
console.error("Main container for team charts not found!")
}
@@ -1625,7 +1721,7 @@
Forms Submitted
-
Select a card to view details about the contributor or team.
+
Select a card to view details about the contributor.
@@ -1643,7 +1739,7 @@
Forms Submitted
-
Select a card to view details about the contributor or team.