Bugfix: click on final/preliminary was resetting skpped rounds

This commit is contained in:
Claude Brisson
2024-04-10 13:30:05 +02:00
parent a285914213
commit 974dba59ea
5 changed files with 47 additions and 16 deletions

View File

@@ -116,12 +116,11 @@ fun Player.Companion.fromJson(json: Json.Object, default: Player? = null) = Play
final = json.getBoolean("final") ?: default?.final ?: true, final = json.getBoolean("final") ?: default?.final ?: true,
mmsCorrection = json.getInt("mmsCorrection") ?: default?.mmsCorrection ?: 0 mmsCorrection = json.getInt("mmsCorrection") ?: default?.mmsCorrection ?: 0
).also { player -> ).also { player ->
player.skip.clear() (json.getArray("skip") ?: default?.skip)?.let {
json.getArray("skip")?.let {
if (it.isNotEmpty()) player.skip.addAll(it.map { id -> (id as Number).toInt() }) if (it.isNotEmpty()) player.skip.addAll(it.map { id -> (id as Number).toInt() })
} }
DatabaseId.values().forEach { dbid -> DatabaseId.values().forEach { dbid ->
json.getString(dbid.key)?.let { id -> (json.getString(dbid.key) ?: default?.externalIds?.get(dbid))?.let { id ->
player.externalIds[dbid] = id player.externalIds[dbid] = id
} }
} }

View File

@@ -63,8 +63,13 @@
#players-list { #players-list {
max-width: 95vw; max-width: 95vw;
#players tr.filtered { #players {
display: none; tr.filtered {
display: none;
}
tr.highlighted {
background-color: #D0FFD0;
}
} }
} }
@@ -96,6 +101,9 @@
opacity: 0; opacity: 0;
} }
} }
.active > * {
cursor: pointer;
}
} }
#player-form { #player-form {

View File

@@ -160,6 +160,23 @@ function modal(id) {
} }
function close_modal() { function close_modal() {
// check if modal requires confirmation
let shownPopup = $('.shown.popup');
if (shownPopup.length == 1) {
let id = shownPopup.attr('id');
switch (id) {
case 'player': {
if (!$('#player-form').hasClass('add') && !$('#register').hasClass('disabled')) {
let confirmMessage = $('#drop-changes').text();
if (!confirm(confirmMessage)) {
return false;
}
}
break;
}
}
}
// close modal
$('body').removeClass('dimmed'); $('body').removeClass('dimmed');
$(`.popup`).removeClass('shown'); $(`.popup`).removeClass('shown');
store('addingPlayers', false); store('addingPlayers', false);

View File

@@ -157,12 +157,6 @@ onLoad(() => {
}); });
$('#cancel-register').on('click', e => { $('#cancel-register').on('click', e => {
e.preventDefault(); e.preventDefault();
if (!$('#player-form').hasClass('add') && !$('#register').hasClass('disabled')) {
let confirmMessage = $('#drop-changes').text();
if (!confirm(confirmMessage)) {
return false;
}
}
close_modal(); close_modal();
searchHighlight = undefined; searchHighlight = undefined;
return false; return false;
@@ -211,9 +205,9 @@ onLoad(() => {
if (form.hasClass('add')) { if (form.hasClass('add')) {
api.postJson(`tour/${tour_id}/part`, player) api.postJson(`tour/${tour_id}/part`, player)
.then(player => { .then(player => {
console.log(player)
if (player !== 'error') { if (player !== 'error') {
store('registrationSuccess', true); store('registrationSuccess', true);
store('scrollIntoView', player.id)
window.location.reload(); window.location.reload();
} }
}); });
@@ -224,6 +218,7 @@ onLoad(() => {
.then(player => { .then(player => {
if (player !== 'error') { if (player !== 'error') {
store('registrationSuccess', true); store('registrationSuccess', true);
store('scrollIntoView', id)
window.location.reload(); window.location.reload();
} }
}); });
@@ -390,8 +385,20 @@ onLoad(() => {
$('#player').addClass('successful'); $('#player').addClass('successful');
setTimeout(() => $('#player .success-feedback').addClass('done'), 0); setTimeout(() => $('#player .success-feedback').addClass('done'), 0);
} }
store.remove('registrationSuccess');
} }
store.remove('registrationSuccess');
let scrollIntoView = store('scrollIntoView');
if (scrollIntoView) {
let row = $(`tr[data-id="${scrollIntoView}"`);
if (row.length) {
row.addClass('highlighted');
store.remove('scroll');
setTimeout(()=>{
row[0].scrollIntoView({ behavior: "smooth", block: "center" });
}, 100);
}
}
store.remove('scrollIntoView');
if (store('macmahonGroups')) { if (store('macmahonGroups')) {
modal('macmahon-groups'); modal('macmahon-groups');
} }

View File

@@ -203,9 +203,9 @@
</div> </div>
<label>Participation</label> <label>Participation</label>
#foreach($r in [1..$tour.rounds]) #foreach($r in [1..$tour.rounds])
<div class="centered field"> <div class="active centered field">
<label>R${r}</label> <label for="participation_r${r}">R${r}</label>
<input name="r${r}" type="checkbox" checked="checked" class="participation"/> <input id="participation_r${r}" name="r${r}" type="checkbox" checked="checked" class="participation"/>
</div> </div>
#end #end
</div> </div>