From aaf4a1357e27357b89eb4dc38d8ab7c565b11a32 Mon Sep 17 00:00:00 2001 From: Claude Brisson Date: Fri, 26 Jan 2024 10:43:40 +0100 Subject: [PATCH] Edit pairable round status in pairing window --- view-webapp/src/main/sass/main.scss | 5 ++ .../src/main/webapp/js/tour-pairing.inc.js | 46 ++++++++++++++++++- .../src/main/webapp/tour-pairing.inc.html | 33 ++++++++++++- .../main/webapp/tour-registration.inc.html | 2 +- 4 files changed, 82 insertions(+), 4 deletions(-) diff --git a/view-webapp/src/main/sass/main.scss b/view-webapp/src/main/sass/main.scss index 9c5881a..4919ec1 100644 --- a/view-webapp/src/main/sass/main.scss +++ b/view-webapp/src/main/sass/main.scss @@ -228,6 +228,11 @@ background-clip: initial; } + .ui.form label input[type="checkbox"] { + margin-left: 1em; + vertical-align: baseline; + } + .ui.striped.table>tbody>tr:nth-child(2n),.ui.striped.table>tr:nth-child(2n) { background-color: rgba(0,0,50,.1) } diff --git a/view-webapp/src/main/webapp/js/tour-pairing.inc.js b/view-webapp/src/main/webapp/js/tour-pairing.inc.js index 75de4d3..6e9eaf3 100644 --- a/view-webapp/src/main/webapp/js/tour-pairing.inc.js +++ b/view-webapp/src/main/webapp/js/tour-pairing.inc.js @@ -38,6 +38,39 @@ function editGame(game) { modal('edit-pairing'); } +function editPairable(pairable) { + let id = pairable.data('id'); + let form = $('#pairable-form')[0]; + form.val('id', id); + let name = pairable.find('.name')[0].textContent; + $('#edit-pairable-disp')[0].textContent = name; + let box = pairable.closest('.multi-select'); + let state = box.attr('id') === 'pairables'; + form.val('pairable', state); + modal('edit-pairable'); +} + +function updatePairable() { + let form = $('#pairable-form')[0]; + let id = form.val('id'); + let status = form.val('pairable'); + let origSkip = $(`#players tr[data-id="${id}"] td.participating label`) + .map(disk => disk.hasClass('red')); + let skip = status ? [] : [ activeRound ]; + for (let i = 0; i < origSkip.length; ++i) { + let round = i + 1; + if (round !== activeRound && origSkip[i]) skip.push(round); + } + api.putJson(`tour/${tour_id}/part/${id}`, { + id: id, + skip: skip + }).then(player => { + if (player !== 'error') { + window.location.reload(); + } + }); +} + onLoad(()=>{ $('.listitem').on('click', e => { if (e.shiftKey && typeof(focused) !== 'undefined') { @@ -58,9 +91,11 @@ onLoad(()=>{ let target = e.target.closest('.listitem'); if (e.detail === 1) { focused = target.toggleClass('selected').attr('draggable', target.hasClass('selected')); - } else { + } else if (target.closest('#paired')) { focused = target.attr('draggable', target.hasClass('selected')); editGame(focused); + } else { + editPairable(focused); } } }); @@ -115,4 +150,13 @@ onLoad(()=>{ } }); }); + $('.multi-select').on('dblclick', e => { + let box = e.target.closest('.multi-select'); + if (!e.target.closest('.listitem')) { + box.find('.listitem').removeClass('selected'); + } + }); + $('#update-pairable').on('click', e => { + updatePairable(); + }); }); diff --git a/view-webapp/src/main/webapp/tour-pairing.inc.html b/view-webapp/src/main/webapp/tour-pairing.inc.html index 13bd19d..c1d8df4 100644 --- a/view-webapp/src/main/webapp/tour-pairing.inc.html +++ b/view-webapp/src/main/webapp/tour-pairing.inc.html @@ -26,13 +26,13 @@
#foreach($p in $pairables) #set($part = $pmap[$p]) -
$part.name $part.firstname#rank($part.rank) $part.country
+
$part.name $part.firstname#rank($part.rank) $part.country
#end
#foreach($p in $unpairables) #set($part = $pmap[$p]) -
$part.name $part.firstname#rank($part.rank) $part.country
+
$part.name $part.firstname#rank($part.rank) $part.country
#end
@@ -114,3 +114,32 @@ + + diff --git a/view-webapp/src/main/webapp/tour-registration.inc.html b/view-webapp/src/main/webapp/tour-registration.inc.html index e2185fd..4345639 100644 --- a/view-webapp/src/main/webapp/tour-registration.inc.html +++ b/view-webapp/src/main/webapp/tour-registration.inc.html @@ -38,7 +38,7 @@ $part.club #rank($part.rank)#if($part.mmsCorrection) ($part.mmsCorrection)#end $part.rating - + #foreach($round in [1..$tour.rounds]) ## CB TODO - upstream json parsing should not give longs here, should it? #if($part.skip && $part.skip.contains($round.longValue()))