Tweak scores view page

main
sudoer777 2021-11-21 22:07:25 -07:00
parent 4f2b496cf2
commit 8674781ba9
2 changed files with 36 additions and 27 deletions

View File

@ -7,6 +7,7 @@ const divisionDropdown = document.getElementById('division-dropdown');
const teamDropdown = document.getElementById('team-dropdown');
const gamesTable = document.getElementById('games-table');
const gamesTableHeader = document.getElementById('games-table-header');
const noScoresMessage = document.getElementById('no-scores-message');
@ -101,15 +102,18 @@ async function listTeams() {
async function listGames() {
gamesTable.innerHTML = "";
gamesTableHeader.textContent = "";
noScoresMessage.textContent = "";
const selectedTeamID = teamDropdown.value;
const selectedDivisionID = divisionDropdown.value;
const selectedSeasonID = seasonDropdown.value;
if(selectedTeamID && selectedDivisionID) {
await setupGamesTable();
gamesTableHeader.textContent = `Scores for ${teamDropdown.options[teamDropdown.selectedIndex].text}`;
const gamesList = await Data.getGames(selectedTeamID, selectedDivisionID, selectedSeasonID);
if(gamesList.length > 0) {
await setupGamesTableHeaders();
gamesList.forEach((game) => {
const row = document.createElement('tr');
@ -135,9 +139,12 @@ async function listGames() {
gamesTable.appendChild(row);
});
}
else {
noScoresMessage.textContent = "No scores available";
}
}
}
async function setupGamesTable() {
gamesTableHeader.textContent = `Scores for ${teamDropdown.options[teamDropdown.selectedIndex].text}`;
async function setupGamesTableHeaders() {
const row = document.createElement('tr');
@ -166,3 +173,4 @@ sportDropdown.onchange = (() => {
});
genderDropdown.onchange = listDivisions;
teamDropdown.onchange = listGames;
seasonDropdown.onchange = listGames;

View File

@ -25,6 +25,7 @@ block content
span(class='form-section')
div
h2#games-table-header
span#no-scores-message
table
colgroup
col#score-column(span="1")