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 @@