Tweak scores view page
parent
4f2b496cf2
commit
8674781ba9
|
@ -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;
|
|
@ -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")
|
||||
|
|
Reference in New Issue