diff --git a/api-webapp/src/main/kotlin/org/jeudego/pairgoth/model/Pairable.kt b/api-webapp/src/main/kotlin/org/jeudego/pairgoth/model/Pairable.kt index 0fbaa15..1c27c7b 100644 --- a/api-webapp/src/main/kotlin/org/jeudego/pairgoth/model/Pairable.kt +++ b/api-webapp/src/main/kotlin/org/jeudego/pairgoth/model/Pairable.kt @@ -116,12 +116,11 @@ fun Player.Companion.fromJson(json: Json.Object, default: Player? = null) = Play final = json.getBoolean("final") ?: default?.final ?: true, mmsCorrection = json.getInt("mmsCorrection") ?: default?.mmsCorrection ?: 0 ).also { player -> - player.skip.clear() - json.getArray("skip")?.let { + (json.getArray("skip") ?: default?.skip)?.let { if (it.isNotEmpty()) player.skip.addAll(it.map { id -> (id as Number).toInt() }) } DatabaseId.values().forEach { dbid -> - json.getString(dbid.key)?.let { id -> + (json.getString(dbid.key) ?: default?.externalIds?.get(dbid))?.let { id -> player.externalIds[dbid] = id } } diff --git a/view-webapp/src/main/sass/tour.scss b/view-webapp/src/main/sass/tour.scss index e8bc5ef..3e58d79 100644 --- a/view-webapp/src/main/sass/tour.scss +++ b/view-webapp/src/main/sass/tour.scss @@ -63,8 +63,13 @@ #players-list { max-width: 95vw; - #players tr.filtered { - display: none; + #players { + tr.filtered { + display: none; + } + tr.highlighted { + background-color: #D0FFD0; + } } } @@ -96,6 +101,9 @@ opacity: 0; } } + .active > * { + cursor: pointer; + } } #player-form { diff --git a/view-webapp/src/main/webapp/js/main.js b/view-webapp/src/main/webapp/js/main.js index 0f8e610..9c9decc 100644 --- a/view-webapp/src/main/webapp/js/main.js +++ b/view-webapp/src/main/webapp/js/main.js @@ -160,6 +160,23 @@ function modal(id) { } 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'); $(`.popup`).removeClass('shown'); store('addingPlayers', false); 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 b085def..263d65e 100644 --- a/view-webapp/src/main/webapp/js/tour-registration.inc.js +++ b/view-webapp/src/main/webapp/js/tour-registration.inc.js @@ -157,12 +157,6 @@ onLoad(() => { }); $('#cancel-register').on('click', e => { e.preventDefault(); - if (!$('#player-form').hasClass('add') && !$('#register').hasClass('disabled')) { - let confirmMessage = $('#drop-changes').text(); - if (!confirm(confirmMessage)) { - return false; - } - } close_modal(); searchHighlight = undefined; return false; @@ -211,9 +205,9 @@ onLoad(() => { if (form.hasClass('add')) { api.postJson(`tour/${tour_id}/part`, player) .then(player => { - console.log(player) if (player !== 'error') { store('registrationSuccess', true); + store('scrollIntoView', player.id) window.location.reload(); } }); @@ -224,6 +218,7 @@ onLoad(() => { .then(player => { if (player !== 'error') { store('registrationSuccess', true); + store('scrollIntoView', id) window.location.reload(); } }); @@ -390,8 +385,20 @@ onLoad(() => { $('#player').addClass('successful'); 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')) { modal('macmahon-groups'); } diff --git a/view-webapp/src/main/webapp/tour-registration.inc.html b/view-webapp/src/main/webapp/tour-registration.inc.html index 7188830..5af4ca9 100644 --- a/view-webapp/src/main/webapp/tour-registration.inc.html +++ b/view-webapp/src/main/webapp/tour-registration.inc.html @@ -203,9 +203,9 @@ #foreach($r in [1..$tour.rounds]) -