Add page to add divisions
parent
f95015095d
commit
1a3b013a0f
|
@ -135,10 +135,10 @@ CATEGORIES.push(new Category(
|
|||
.then(data => sportCell.textContent = data);
|
||||
row.appendChild(sportCell);
|
||||
},
|
||||
async function addSeason() {
|
||||
//
|
||||
async function addDivision() {
|
||||
window.location.href = "manage/adddivision";
|
||||
},
|
||||
async function editSeason() {
|
||||
async function editDivision() {
|
||||
|
||||
}
|
||||
));
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
import * as Data from "../data.js";
|
||||
|
||||
|
||||
const sportDropdown = document.getElementById('sport-dropdown');
|
||||
|
||||
async function listSports() {
|
||||
sportDropdown.innerHTML = "";
|
||||
|
||||
const sportsList = await Data.getSports();
|
||||
|
||||
sportsList.forEach(sport => {
|
||||
const option = document.createElement('option');
|
||||
option.text = sport.name;
|
||||
option.value = sport.id;
|
||||
sportDropdown.appendChild(option);
|
||||
});
|
||||
}
|
||||
listSports();
|
|
@ -4,6 +4,8 @@ var genders = require('../database/scores/genders');
|
|||
var games = require('../database/scores/games');
|
||||
var seasons = require('../database/scores/seasons');
|
||||
var sports = require('../database/scores/sports');
|
||||
var divisions = require('../database/scores/divisions');
|
||||
var genders = require('../database/scores/genders');
|
||||
|
||||
|
||||
router.get('/', function(req, res, next) {
|
||||
|
@ -51,4 +53,25 @@ router.post('/submitsport', function(req, res, next) {
|
|||
.then(res.send("SUCCESS"));
|
||||
});
|
||||
|
||||
router.get('/adddivision', function(req, res, next) {
|
||||
res.render('manage/adddivision', { title: 'Add division' });
|
||||
});
|
||||
|
||||
router.post('/submitdivision', function(req, res, next) {
|
||||
const name = req.body['name'];
|
||||
const sport = req.body['sport'];
|
||||
const genderName = req.body['gender'];
|
||||
|
||||
if(genderName == "both") {
|
||||
divisions.add(name, genders.FEMALE, sport)
|
||||
.then(divisions.add(name, genders.MALE, sport)
|
||||
.then(res.send("SUCCESS")));
|
||||
}
|
||||
else {
|
||||
const gender = (genderName == "female") ? genders.FEMALE : genders.MALE;
|
||||
divisions.add(name, gender, sport)
|
||||
.then(res.send("SUCCESS"));
|
||||
}
|
||||
});
|
||||
|
||||
module.exports = router;
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
extends layout
|
||||
|
||||
block stylesheets
|
||||
link(rel='stylesheet', href='/stylesheets/submit.css')
|
||||
link(rel='stylesheet', href='/stylesheets/form.css')
|
||||
|
||||
block content
|
||||
div#mobile-view
|
||||
h1 Add Division
|
||||
form(action='./submitdivision', method='POST')
|
||||
span(class='form-section')
|
||||
label Sport
|
||||
span(class='form-section-input')
|
||||
select#sport-dropdown(name="sport" class="form-main-dropdown")
|
||||
span(class='form-section')
|
||||
label Gender
|
||||
span(class='form-section-input')
|
||||
select#gender-dropdown(name="gender" class="form-main-dropdown")
|
||||
option(value="both") Both
|
||||
option(value="female") Female
|
||||
option(value="male") Male
|
||||
span(class='form-section')
|
||||
label Division name
|
||||
span(class='form-section-input')
|
||||
input(type="text", name="name")
|
||||
span(class='form-section')
|
||||
button#submit-button(type="submit") Submit
|
||||
|
||||
block scripts
|
||||
script(src='/scripts/manage/division.js' type="module")
|
Reference in New Issue