Edit pairable round status in pairing window
This commit is contained in:
@@ -228,6 +228,11 @@
|
|||||||
background-clip: initial;
|
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) {
|
.ui.striped.table>tbody>tr:nth-child(2n),.ui.striped.table>tr:nth-child(2n) {
|
||||||
background-color: rgba(0,0,50,.1)
|
background-color: rgba(0,0,50,.1)
|
||||||
}
|
}
|
||||||
|
@@ -38,6 +38,39 @@ function editGame(game) {
|
|||||||
modal('edit-pairing');
|
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(()=>{
|
onLoad(()=>{
|
||||||
$('.listitem').on('click', e => {
|
$('.listitem').on('click', e => {
|
||||||
if (e.shiftKey && typeof(focused) !== 'undefined') {
|
if (e.shiftKey && typeof(focused) !== 'undefined') {
|
||||||
@@ -58,9 +91,11 @@ onLoad(()=>{
|
|||||||
let target = e.target.closest('.listitem');
|
let target = e.target.closest('.listitem');
|
||||||
if (e.detail === 1) {
|
if (e.detail === 1) {
|
||||||
focused = target.toggleClass('selected').attr('draggable', target.hasClass('selected'));
|
focused = target.toggleClass('selected').attr('draggable', target.hasClass('selected'));
|
||||||
} else {
|
} else if (target.closest('#paired')) {
|
||||||
focused = target.attr('draggable', target.hasClass('selected'));
|
focused = target.attr('draggable', target.hasClass('selected'));
|
||||||
editGame(focused);
|
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();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@@ -26,13 +26,13 @@
|
|||||||
<div id="pairables" class="multi-select" title="pairable players">
|
<div id="pairables" class="multi-select" title="pairable players">
|
||||||
#foreach($p in $pairables)
|
#foreach($p in $pairables)
|
||||||
#set($part = $pmap[$p])
|
#set($part = $pmap[$p])
|
||||||
<div data-id="$part.id" class="listitem pairable"><span>$part.name $part.firstname</span><span>#rank($part.rank) $part.country</span></div>
|
<div data-id="$part.id" class="listitem pairable"><span class="name">$part.name $part.firstname</span><span>#rank($part.rank) $part.country</span></div>
|
||||||
#end
|
#end
|
||||||
</div>
|
</div>
|
||||||
<div id="unpairables" class="multi-select" title="unpairable players">
|
<div id="unpairables" class="multi-select" title="unpairable players">
|
||||||
#foreach($p in $unpairables)
|
#foreach($p in $unpairables)
|
||||||
#set($part = $pmap[$p])
|
#set($part = $pmap[$p])
|
||||||
<div class="listitem unpairable" data-id="$part.id"><span>$part.name $part.firstname</span><span>#rank($part.rank) $part.country</span></div>
|
<div data-id="$part.id" class="listitem unpairable"><span class="name">$part.name $part.firstname</span><span>#rank($part.rank) $part.country</span></div>
|
||||||
#end
|
#end
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -114,3 +114,32 @@
|
|||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div id="edit-pairable" class="popup">
|
||||||
|
<div class="popup-body">
|
||||||
|
<form id="pairable-form" class="ui form edit">
|
||||||
|
<input type="hidden" name="id"/>
|
||||||
|
<div class="popup-content">
|
||||||
|
<div id="edit-pairable-disp"></div>
|
||||||
|
<div class="inline fields">
|
||||||
|
<div class="field">
|
||||||
|
<label>
|
||||||
|
Pairable for round $round?
|
||||||
|
<input type="checkbox" name="pairable"/>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="popup-footer">
|
||||||
|
<button id="cancel-edit-pairable" type="button" class="ui gray right labeled icon floating close button">
|
||||||
|
<i class="times icon"></i>
|
||||||
|
Cancel
|
||||||
|
</button>
|
||||||
|
<button id="update-pairable" type="button" class="ui green right labeled icon floating button">
|
||||||
|
<i class="check icon"></i>
|
||||||
|
Update
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@@ -38,7 +38,7 @@
|
|||||||
<td>$part.club</td>
|
<td>$part.club</td>
|
||||||
<td data-sort="$part.rank">#rank($part.rank)#if($part.mmsCorrection) ($part.mmsCorrection)#end</td>
|
<td data-sort="$part.rank">#rank($part.rank)#if($part.mmsCorrection) ($part.mmsCorrection)#end</td>
|
||||||
<td>$part.rating</td>
|
<td>$part.rating</td>
|
||||||
<td>
|
<td class="participating">
|
||||||
#foreach($round in [1..$tour.rounds])
|
#foreach($round in [1..$tour.rounds])
|
||||||
## CB TODO - upstream json parsing should not give longs here, should it?
|
## CB TODO - upstream json parsing should not give longs here, should it?
|
||||||
#if($part.skip && $part.skip.contains($round.longValue()))
|
#if($part.skip && $part.skip.contains($round.longValue()))
|
||||||
|
Reference in New Issue
Block a user