Table numbers exclusion: handle saving

This commit is contained in:
Claude Brisson
2024-07-27 15:53:41 +02:00
parent 02e1fb8319
commit 6e97c91b2f
5 changed files with 77 additions and 26 deletions

View File

@@ -405,6 +405,10 @@
margin-top: 0.2em;
}
.tables-exclusion {
margin-top: 0.2em;
}
/* results section */
#results-filter {

View File

@@ -1,12 +1,31 @@
let focused = undefined;
function pair(parts) {
api.postJson(`tour/${tour_id}/pair/${activeRound}`, parts)
.then(rst => {
if (rst !== 'error') {
document.location.reload();
}
});
let doWork = () => {
api.postJson(`tour/${tour_id}/pair/${activeRound}`, parts)
.then(rst => {
if (rst !== 'error') {
document.location.reload();
}
});
}
let tablesExclusionControl = $('#exclude-tables');
let value = tablesExclusionControl[0].value;
let origValue = tablesExclusionControl.data('orig');
if (value === origValue) {
// tables exclusion value did not change
doWork();
} else {
// tables exclusion value has change, we must save it first
api.putJson(`tour/${tour_id}`, { round: activeRound, excludeTables: value })
.then(rst => {
if (rst !== 'error') {
doWork();
}
});
}
}
function unpair(games) {

View File

@@ -22,6 +22,14 @@
<button class="ui floating choose-round next-round button">&raquo;</button>
</div>
<div class="pairing-stats nobreak">( $pairables.size() pairable, $games.size() games )</div>
<div class="tables-exclusion">
#if($tour.tablesExclusion && $round <= $tour.tablesExclusion.size())
#set($tablesExclusion = $!tour.tablesExclusion[$round - 1])
#else
#set($tablesExclusion = '')
#end
Exclude table numbers: <input type="text" id="exclude-tables" name="exclude-tables" placeholder="ex: 1-34, 38, 45-77" data-orig="$tablesExclusion" value="$tablesExclusion"/>
</div>
<div id="pairing-lists">
<div id="pairing-left">
<div id="pairables" class="multi-select" title="pairable players">