From 18f840183fad1627fe59c2d1b621505c3b27c93a Mon Sep 17 00:00:00 2001 From: sudoer777 <78781902+sudoer777@users.noreply.github.com> Date: Mon, 22 Nov 2021 15:32:44 -0700 Subject: [PATCH] Add functionality to list divisions in management page --- public/scripts/manage.js | 53 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 50 insertions(+), 3 deletions(-) diff --git a/public/scripts/manage.js b/public/scripts/manage.js index 19b700a..8958f1c 100644 --- a/public/scripts/manage.js +++ b/public/scripts/manage.js @@ -56,9 +56,9 @@ CATEGORIES.push(new Category( async function listSportHeaders() { const headerRow = document.createElement('tr'); - const yearsHeader = document.createElement('th'); - yearsHeader.textContent = "Name"; - headerRow.appendChild(yearsHeader); + const nameHeader = document.createElement('th'); + nameHeader.textContent = "Name"; + headerRow.appendChild(nameHeader); itemsListTable.appendChild(headerRow); }, @@ -67,6 +67,53 @@ CATEGORIES.push(new Category( nameCell.textContent = sport.name; row.appendChild(nameCell); }, + async function addSport() { + // + }, + async function submitSport() { + // + }, + async function editSport() { + + } +)); + +CATEGORIES.push(new Category( + "divisions", + async function getDivisions() { + return await Data.getDivisions(); + }, + async function listDivisionHeaders() { + const headerRow = document.createElement('tr'); + + const nameHeader = document.createElement('th'); + nameHeader.textContent = "Name"; + headerRow.appendChild(nameHeader); + + const genderHeader = document.createElement('th'); + headerRow.appendChild(genderHeader); + + const sportHeader = document.createElement('th'); + sportHeader.textContent = "Sport"; + headerRow.appendChild(sportHeader); + + itemsListTable.appendChild(headerRow); + }, + function listDivision(division, row) { + const nameCell = document.createElement('td'); + nameCell.textContent = division.name; + row.appendChild(nameCell); + + const genderCell = document.createElement('td'); + const gender = division.gender.name == "female" ? "F" : "M"; + genderCell.textContent = gender; + row.appendChild(genderCell); + + const sportCell = document.createElement('td'); + Data.getSportName(division.sportID) + .then(data => sportCell.textContent = data); + row.appendChild(sportCell); + }, async function addSeason() { // },