Select all in lists for pair/unpair; allow results changes in previous rounds

This commit is contained in:
Claude Brisson
2023-12-27 11:51:51 +01:00
parent b8c411773d
commit 797ac17b74
3 changed files with 8 additions and 1 deletions

View File

@@ -35,6 +35,7 @@ object PairingHandler: PairgothApiHandler {
val round = getSubSelector(request)?.toIntOrNull() ?: badRequest("invalid round number")
if (round > tournament.lastRound() + 1) badRequest("invalid round: previous round has not been played")
val payload = getArrayPayload(request)
if (payload.isEmpty()) badRequest("nobody to pair")
val allPlayers = payload.size == 1 && payload[0] == "all"
//if (!allPlayers && tournament.pairing.type == PairingType.SWISS) badRequest("Swiss pairing requires all pairable players")
val playing = (tournament.games(round).values).flatMap {

View File

@@ -21,7 +21,6 @@ object ResultsHandler: PairgothApiHandler {
override fun put(request: HttpServletRequest): Json {
val tournament = getTournament(request)
val round = getSubSelector(request)?.toIntOrNull() ?: badRequest("invalid round number")
if (round != tournament.lastRound()) badRequest("cannot enter results in other rounds but the last")
val payload = getObjectPayload(request)
val game = tournament.games(round)[payload.getInt("id")] ?: badRequest("invalid game id")
game.result = Game.Result.fromSymbol(payload.getChar("result") ?: badRequest("missing result"))

View File

@@ -42,10 +42,17 @@ onLoad(()=>{
});
$('#pair').on('click', e => {
let parts = $('#pairables')[0].childNodes.filter('.selected.listitem').map(item => parseInt(item.data("id")));
if (parts.length == 0) {
$('#pairables .listitem').addClass('selected');
parts = $('#pairables')[0].childNodes.filter('.selected.listitem').map(item => parseInt(item.data("id")));
}
pair(parts);
});
$('#unpair').on('click', e => {
let games = $('#paired')[0].childNodes.filter('.selected.listitem').map(item => parseInt(item.data("id")));
if (games.length == 0) {
games = $('#paired')[0].childNodes.filter('.selected.listitem').map(item => parseInt(item.data("id")));
}
unpair(games);
});
});