Pairing still in progress
This commit is contained in:
@@ -20,7 +20,7 @@ object PairingHandler: PairgothApiHandler {
|
|||||||
val playing = tournament.games(round).values.flatMap {
|
val playing = tournament.games(round).values.flatMap {
|
||||||
listOf(it.black, it.white)
|
listOf(it.black, it.white)
|
||||||
}.toSet()
|
}.toSet()
|
||||||
return tournament.pairables.values.filter { !it.skip.contains(round) && !playing.contains(it.id) }.map { it.id }.toJsonArray()
|
return tournament.pairables.values.filter { !it.skip.contains(round) && !playing.contains(it.id) }.sortedByDescending { it.rating }.map { it.id }.toJsonArray()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun post(request: HttpServletRequest): Json {
|
override fun post(request: HttpServletRequest): Json {
|
||||||
|
@@ -68,7 +68,7 @@ NodeList.prototype.offset = function() {
|
|||||||
}
|
}
|
||||||
Element.prototype.attr = function (key, value) {
|
Element.prototype.attr = function (key, value) {
|
||||||
if (typeof(value) === 'undefined') {
|
if (typeof(value) === 'undefined') {
|
||||||
return this.attributes[key].value;
|
return this.attributes[key]?.value;
|
||||||
} else {
|
} else {
|
||||||
this.setAttribute(key, value);
|
this.setAttribute(key, value);
|
||||||
return this;
|
return this;
|
||||||
@@ -86,7 +86,7 @@ NodeList.prototype.attr = function(key, value) {
|
|||||||
}
|
}
|
||||||
Element.prototype.data = function (key, value) {
|
Element.prototype.data = function (key, value) {
|
||||||
if (typeof(value) === 'undefined') {
|
if (typeof(value) === 'undefined') {
|
||||||
return this.attributes[`data-${key}`].value
|
return this.attributes[`data-${key}`]?.value
|
||||||
} else {
|
} else {
|
||||||
this.setAttribute(`data-${key}`, value);
|
this.setAttribute(`data-${key}`, value);
|
||||||
return this;
|
return this;
|
||||||
|
@@ -1,5 +1,14 @@
|
|||||||
let focused = undefined;
|
let focused = undefined;
|
||||||
|
|
||||||
|
function pair(parts) {
|
||||||
|
api.postJson(`tour/${tour_id}/pair/${activeRound}`, parts)
|
||||||
|
.then(rst => {
|
||||||
|
if (rst !== 'error') {
|
||||||
|
document.location.reload();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
onLoad(()=>{
|
onLoad(()=>{
|
||||||
$('.listitem').on('click', e => {
|
$('.listitem').on('click', e => {
|
||||||
if (e.shiftKey && typeof(focused) !== 'undefined') {
|
if (e.shiftKey && typeof(focused) !== 'undefined') {
|
||||||
@@ -17,7 +26,12 @@ onLoad(()=>{
|
|||||||
children.item(j).attr('draggable', true);
|
children.item(j).attr('draggable', true);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
focused = e.target.closest('.listitem').toggleClass('selected').attr('draggable', true);
|
let target = e.target.closest('.listitem');
|
||||||
|
focused = target.toggleClass('selected').attr('draggable', target.hasClass('selected'));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
$('#pair').on('click', e => {
|
||||||
|
let parts = $('#pairables')[0].childNodes.filter('.selected.listitem').map(item => parseInt(item.data("id")));
|
||||||
|
pair(parts);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@@ -135,7 +135,6 @@ onLoad(() => {
|
|||||||
skip: form.find('input.participation').map((input,i) => [i+1, input.checked]).filter(arr => !arr[1]).map(arr => arr[0])
|
skip: form.find('input.participation').map((input,i) => [i+1, input.checked]).filter(arr => !arr[1]).map(arr => arr[0])
|
||||||
}
|
}
|
||||||
if (form.hasClass('add')) {
|
if (form.hasClass('add')) {
|
||||||
("ADDING")
|
|
||||||
api.postJson(`tour/${tour_id}/part`, player)
|
api.postJson(`tour/${tour_id}/part`, player)
|
||||||
.then(player => {
|
.then(player => {
|
||||||
if (player !== 'error') {
|
if (player !== 'error') {
|
||||||
|
@@ -18,7 +18,7 @@
|
|||||||
#else
|
#else
|
||||||
#foreach($p in $pairables)
|
#foreach($p in $pairables)
|
||||||
#set($part = $pmap[$p])
|
#set($part = $pmap[$p])
|
||||||
<div class="listitem pairable"><span>$part.name $part.firstname</span><span>$part.country #rank($part.rank)</span></div>
|
<div data-id="$part.id" class="listitem pairable"><span>$part.name $part.firstname</span><span>$part.country #rank($part.rank)</span></div>
|
||||||
#end
|
#end
|
||||||
#end
|
#end
|
||||||
</div>
|
</div>
|
||||||
|
Reference in New Issue
Block a user