diff --git a/api-webapp/src/main/kotlin/org/jeudego/pairgoth/api/StandingsHandler.kt b/api-webapp/src/main/kotlin/org/jeudego/pairgoth/api/StandingsHandler.kt index e4413c7..1d1da46 100644 --- a/api-webapp/src/main/kotlin/org/jeudego/pairgoth/api/StandingsHandler.kt +++ b/api-webapp/src/main/kotlin/org/jeudego/pairgoth/api/StandingsHandler.kt @@ -32,7 +32,7 @@ object StandingsHandler: PairgothApiHandler { fun mmBase(pairable: Pairable): Double { if (tournament.pairing !is MacMahon) throw Error("invalid call: tournament is not Mac Mahon") - return min(max(pairable.rank, tournament.pairing.mmFloor), tournament.pairing.mmBar) + MacMahonSolver.mmsZero + return min(max(pairable.rank, tournament.pairing.mmFloor), tournament.pairing.mmBar) + MacMahonSolver.mmsZero + pairable.mmsCorrection } // CB avoid code redundancy with solvers diff --git a/view-webapp/src/main/kotlin/org/jeudego/pairgoth/view/PairgothTool.kt b/view-webapp/src/main/kotlin/org/jeudego/pairgoth/view/PairgothTool.kt index 3fece49..577b6d3 100644 --- a/view-webapp/src/main/kotlin/org/jeudego/pairgoth/view/PairgothTool.kt +++ b/view-webapp/src/main/kotlin/org/jeudego/pairgoth/view/PairgothTool.kt @@ -58,4 +58,12 @@ class PairgothTool { } return Json.Object("total" to total, "known" to known) } + + fun getMmsMap(pairables: Collection) = + pairables.groupBy { pairable -> pairable.getDouble("MMS")?.toLong() } + .mapValues { entry -> + entry.value.sortedByDescending { pairable -> + pairable.getInt("rank") + } + } } \ No newline at end of file diff --git a/view-webapp/src/main/sass/main.scss b/view-webapp/src/main/sass/main.scss index 551ce50..9c5881a 100644 --- a/view-webapp/src/main/sass/main.scss +++ b/view-webapp/src/main/sass/main.scss @@ -39,7 +39,7 @@ white-space: nowrap; } - .red { + .darkred { color: darkred; } diff --git a/view-webapp/src/main/sass/tour.scss b/view-webapp/src/main/sass/tour.scss index cef5f77..d704081 100644 --- a/view-webapp/src/main/sass/tour.scss +++ b/view-webapp/src/main/sass/tour.scss @@ -181,6 +181,17 @@ } } + #macmahon-groups { + left: 0; + right: 0; + transform: initial; + max-width: max(90vw, 1200px); + .popup-content { + display: flex; + flex-flow: row wrap; + } + } + /* pairing section */ #pairing-content { @@ -260,7 +271,7 @@ } } - #pairing-buttons { + .pairing-buttons { display: flex; flex-flow: column nowrap; justify-content: start; diff --git a/view-webapp/src/main/webapp/WEB-INF/translations/fr b/view-webapp/src/main/webapp/WEB-INF/translations/fr index 2c0c8b5..26c84bd 100644 --- a/view-webapp/src/main/webapp/WEB-INF/translations/fr +++ b/view-webapp/src/main/webapp/WEB-INF/translations/fr @@ -58,6 +58,7 @@ Log in Se connecter Luc Vannier Luc Vannier MM bar Barre MM Mac Mahon Mac Mahon +Mac Mahon groups Groupes Mac Mahon MacMahon MacMahon Main time Temps principal Max time Temps max diff --git a/view-webapp/src/main/webapp/js/main.js b/view-webapp/src/main/webapp/js/main.js index d0881b7..07bb21b 100644 --- a/view-webapp/src/main/webapp/js/main.js +++ b/view-webapp/src/main/webapp/js/main.js @@ -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(() => { } }); - 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 6e0ebba..75de4d3 100644 --- a/view-webapp/src/main/webapp/js/tour-pairing.inc.js +++ b/view-webapp/src/main/webapp/js/tour-pairing.inc.js @@ -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); }); diff --git a/view-webapp/src/main/webapp/js/tour-registration.inc.js b/view-webapp/src/main/webapp/js/tour-registration.inc.js index 64394fd..9961ee6 100644 --- a/view-webapp/src/main/webapp/js/tour-registration.inc.js +++ b/view-webapp/src/main/webapp/js/tour-registration.inc.js @@ -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); + }); }); diff --git a/view-webapp/src/main/webapp/tour-pairing.inc.html b/view-webapp/src/main/webapp/tour-pairing.inc.html index 5549aa0..13bd19d 100644 --- a/view-webapp/src/main/webapp/tour-pairing.inc.html +++ b/view-webapp/src/main/webapp/tour-pairing.inc.html @@ -37,7 +37,7 @@
-
+
+#if($tour.pairing.type == 'MAC_MAHON') + +#end
@@ -193,10 +199,66 @@ +#if($tour.pairing.type == 'MAC_MAHON') + #set($mmbase = $api.get("tour/${params.id}/standings/0")) + #if($mmbase.isObject() && ($mmbase.error || $mmbase.message)) + #if($mmbase.error) + #set($error = $mmbase.error) + #else + #set($error = $mmbase.message) + #end + + #set($mmbase = []) + #end + #set($mmsMap = $utils.getMmsMap($mmbase)) + +#end #[[