Mac Mahon groups edition

This commit is contained in:
Claude Brisson
2024-01-25 06:43:38 +01:00
parent 6fff3893f2
commit a4b18e0ef1
10 changed files with 150 additions and 11 deletions

View File

@@ -162,6 +162,7 @@ function close_modal() {
$('body').removeClass('dimmed');
$(`.popup`).removeClass('shown');
store('addingPlayers', false);
store('macmahonGroups', false);
}
function downloadFile(blob, filename) {
@@ -177,11 +178,14 @@ function downloadFile(blob, filename) {
onLoad(() => {
$('button.close').on('click', e => {
close_modal();
/* no need to be specific...
let modal = e.target.closest('.popup');
if (modal) {
modal.removeClass('shown');
$('body').removeClass('dimmed');
}
*/
});
/* commented for now - do we want this?
@@ -267,4 +271,3 @@ onLoad(() => {
}
});

View File

@@ -65,18 +65,18 @@ onLoad(()=>{
}
});
$('#pair').on('click', e => {
let parts = $('#pairables')[0].childNodes.filter('.selected.listitem').map(item => parseInt(item.data("id")));
let parts = $('#pairables .selected.listitem').map(item => parseInt(item.data("id")));
if (parts.length == 0) {
$('#pairables .listitem').addClass('selected');
parts = $('#pairables')[0].childNodes.filter('.selected.listitem').map(item => parseInt(item.data("id")));
parts = $('#pairables .selected.listitem').map(item => parseInt(item.data("id")));
}
pair(parts);
});
$('#unpair').on('click', e => {
let games = $('#paired')[0].childNodes.filter('.selected.listitem').map(item => parseInt(item.data("id")));
let games = $('#paired .selected.listitem').map(item => parseInt(item.data("id")));
if (games.length == 0) {
$('#paired .listitem').addClass('selected');
games = $('#paired')[0].childNodes.filter('.selected.listitem').map(item => parseInt(item.data("id")));
games = $('#paired .selected.listitem').map(item => parseInt(item.data("id")));
}
unpair(games);
});

View File

@@ -104,6 +104,11 @@ function addPlayers() {
store('addingPlayers', true);
}
function bulkUpdate(players) {
Promise.all(players.map(p => api.putJson(`tour/${tour_id}/part/${p.id}`, p)))
.then((values) => window.location.reload());
}
let tableSort;
onLoad(() => {
@@ -314,7 +319,56 @@ onLoad(() => {
$('#filter')[0].value = '';
$('tbody > tr').removeClass('hidden');
});
$('#edit-macmahon-groups').on('click', e => {
modal('macmahon-groups');
store('macmahonGroups', true);
});
if (store('addingPlayers')) {
addPlayers();
}
if (store('macmahonGroups')) {
modal('macmahon-groups');
}
// mac mahon groups...
$('#under-to-top').on('click', e => {
let players = $('#under-group .selected').map(item => (
{
id: parseInt(item.data("id")),
mmsCorrection: parseInt(item.data("correction")) + 1
}));
bulkUpdate(players);
});
$('#top-to-under').on('click', e => {
let players = $('#top-group .selected').map(item => (
{
id: parseInt(item.data("id")),
mmsCorrection: parseInt(item.data("correction")) - 1
}));
bulkUpdate(players);
});
$('#top-to-super').on('click', e => {
let players = $('#top-group .selected').map(item => (
{
id: parseInt(item.data("id")),
mmsCorrection: parseInt(item.data("correction")) + 1
}));
bulkUpdate(players);
});
$('#super-to-top').on('click', e => {
let players = $('#super-group .selected').map(item => (
{
id: parseInt(item.data("id")),
mmsCorrection: parseInt(item.data("correction")) - 1
}));
bulkUpdate(players);
});
$('#reset-macmahon-groups').on('click', e => {
let players = $('#macmahon-groups .listitem').map(item => (
{
id: parseInt(item.data("id")),
mmsCorrection: 0
}));
bulkUpdate(players);
});
});