Ask confirmation if a table number change would trigger a tables renumbering

This commit is contained in:
Claude Brisson
2024-08-01 22:54:32 +02:00
parent cb24ec1794
commit 2cf97d1ecf
2 changed files with 10 additions and 1 deletions

View File

@@ -54,6 +54,7 @@ function renumberTables() {
}
function editGame(game) {
// CB TODO - those should be data attributes of the parent game tag
let t = game.find('.table');
let w = game.find('.white');
let b = game.find('.black');
@@ -61,6 +62,7 @@ function editGame(game) {
let form = $('#pairing-form')[0];
form.val('id', game.data('id'));
form.val('prev-table', t.data('value'));
form.val('t', t.data('value'));
form.val('w', w.data('id'));
$('#edit-pairing-white').text(w.text());
@@ -188,6 +190,12 @@ onLoad(()=>{
b: form.val('b'),
h: form.val('h')
}
let prevTable = form.val('prev-table');
if (prevTable !== game.t && $(`.t[data-table="${game.t}"]`).length > 0) {
if (!confirm(`This change will trigger a tables renumbering because the destination table #${game.t} is not empty. Proceed?`)) {
return;
}
}
api.putJson(`tour/${tour_id}/pair/${activeRound}`, game)
.then(game => {
if (game !== 'error') {

View File

@@ -95,7 +95,7 @@
#set($white = $pmap[$game.w])
#set($black = $pmap[$game.b])
<tr>
<td>${game.t}</td>
<td class="t" data-table="${game.t}">${game.t}</td>
<td class="left">#if($white)${white.name} ${white.firstname} (#rank($white.rank), $white.country $white.club)#{else}BIP#end</td>
<td class="left">#if($black)${black.name} ${black.firstname} (#rank($black.rank), $black.country $black.club)#{else}BIP#end</td>
<td>${game.h}</td>
@@ -111,6 +111,7 @@
<div class="popup-body">
<form id="pairing-form" class="ui form edit">
<input type="hidden" name="id"/>
<input type="hidden" name="prev-table"/>
<div class="popup-content">
<div class="inline fields">
<div class="field">