Select all in lists for pair/unpair; allow results changes in previous rounds
This commit is contained in:
@@ -35,6 +35,7 @@ object PairingHandler: PairgothApiHandler {
|
|||||||
val round = getSubSelector(request)?.toIntOrNull() ?: badRequest("invalid round number")
|
val round = getSubSelector(request)?.toIntOrNull() ?: badRequest("invalid round number")
|
||||||
if (round > tournament.lastRound() + 1) badRequest("invalid round: previous round has not been played")
|
if (round > tournament.lastRound() + 1) badRequest("invalid round: previous round has not been played")
|
||||||
val payload = getArrayPayload(request)
|
val payload = getArrayPayload(request)
|
||||||
|
if (payload.isEmpty()) badRequest("nobody to pair")
|
||||||
val allPlayers = payload.size == 1 && payload[0] == "all"
|
val allPlayers = payload.size == 1 && payload[0] == "all"
|
||||||
//if (!allPlayers && tournament.pairing.type == PairingType.SWISS) badRequest("Swiss pairing requires all pairable players")
|
//if (!allPlayers && tournament.pairing.type == PairingType.SWISS) badRequest("Swiss pairing requires all pairable players")
|
||||||
val playing = (tournament.games(round).values).flatMap {
|
val playing = (tournament.games(round).values).flatMap {
|
||||||
|
@@ -21,7 +21,6 @@ object ResultsHandler: PairgothApiHandler {
|
|||||||
override fun put(request: HttpServletRequest): Json {
|
override fun put(request: HttpServletRequest): Json {
|
||||||
val tournament = getTournament(request)
|
val tournament = getTournament(request)
|
||||||
val round = getSubSelector(request)?.toIntOrNull() ?: badRequest("invalid round number")
|
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 payload = getObjectPayload(request)
|
||||||
val game = tournament.games(round)[payload.getInt("id")] ?: badRequest("invalid game id")
|
val game = tournament.games(round)[payload.getInt("id")] ?: badRequest("invalid game id")
|
||||||
game.result = Game.Result.fromSymbol(payload.getChar("result") ?: badRequest("missing result"))
|
game.result = Game.Result.fromSymbol(payload.getChar("result") ?: badRequest("missing result"))
|
||||||
|
@@ -42,10 +42,17 @@ onLoad(()=>{
|
|||||||
});
|
});
|
||||||
$('#pair').on('click', e => {
|
$('#pair').on('click', e => {
|
||||||
let parts = $('#pairables')[0].childNodes.filter('.selected.listitem').map(item => parseInt(item.data("id")));
|
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);
|
pair(parts);
|
||||||
});
|
});
|
||||||
$('#unpair').on('click', e => {
|
$('#unpair').on('click', e => {
|
||||||
let games = $('#paired')[0].childNodes.filter('.selected.listitem').map(item => parseInt(item.data("id")));
|
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);
|
unpair(games);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user