Ask for confirmation before dropping changes or unregistering a player

This commit is contained in:
Claude Brisson
2024-04-10 09:13:23 +02:00
parent 7cef2e06fd
commit 6e5ea7168e
3 changed files with 78 additions and 59 deletions

View File

@@ -35,6 +35,7 @@ Delete Supprimer
Director Directeur
Download Télécharger
Download the standalone web interface module which suits your need, then follow Télécharger le module dinterface web qui correspond à vos besoins, puis suivez
Drop changes? Abandonner les changements ?
Edit Éditer
Encoding Encodage
Enter the magic word Entrer le mot magique
@@ -127,6 +128,7 @@ Tournament name Nom du tournoi
Tournament type Type de tournoi
Unpair Désapparier
Unregister Désinscrire
Unregister this player? Désinscrire ce joueur ?
Update Mettre à jour
We offer you the flexibility to use Nous vous offrons la flexibilité dutiliser
Welcome to Bienvenue sur

View File

@@ -157,6 +157,12 @@ onLoad(() => {
});
$('#cancel-register').on('click', e => {
e.preventDefault();
if ($('#player-form').hasClass('edit') && !$('#register').hasClass('disabled')) {
let confirmMessage = $('#drop-changes').text();
if (!confirm(confirmMessage)) {
return false;
}
}
close_modal();
searchHighlight = undefined;
return false;
@@ -246,6 +252,7 @@ onLoad(() => {
}
form.removeClass('add');
$('#player').removeClass('create').addClass('edit');
$('#register').addClass('disabled');
modal('player');
}
});
@@ -310,12 +317,15 @@ onLoad(() => {
$('#unregister').on('click', e => {
let form = $('#player-form')[0];
let id = form.val('id');
api.deleteJson(`tour/${tour_id}/part/${id}`)
.then(ret => {
if (ret !== 'error') {
window.location.reload();
}
});
let confirmMessage = $('#unregister-player').text();
if (confirm(confirmMessage)) {
api.deleteJson(`tour/${tour_id}/part/${id}`)
.then(ret => {
if (ret !== 'error') {
window.location.reload();
}
});
}
});
$('#reg-status').on('click', e => {
let current = $('#final-reg').hasClass('final');
@@ -429,4 +439,7 @@ onLoad(() => {
$('#browse-players').on('click', e => {
search('*');
});
$('.player-fields').on('change input', e => {
$('#register').removeClass('disabled');
});
});

View File

@@ -146,71 +146,73 @@
</div>
<div id="search-result"></div>
</div>
<div class="two stackable fields">
<div class="eight wide field">
<label>Family name</label>
<span class="info"></span>
<input type="text" name="name" placeholder="last name"/>
<div class="player-fields">
<div class="two stackable fields">
<div class="eight wide field">
<label>Family name</label>
<span class="info"></span>
<input type="text" name="name" placeholder="last name"/>
</div>
<div class="eight wide field">
<label>Given name</label>
<span class="info"></span>
<input type="text" name="firstname" placeholder="first name"/>
</div>
</div>
<div class="eight wide field">
<label>Given name</label>
<span class="info"></span>
<input type="text" name="firstname" placeholder="first name"/>
</div>
</div>
<div class="two stackable fields">
<div class="eight wide field">
<label>Country</label>
<span class="info"></span>
<select name="country">
<option></option>
<div class="two stackable fields">
<div class="eight wide field">
<label>Country</label>
<span class="info"></span>
<select name="country">
<option></option>
#set($defaultCountry = $translate.defaultCountry[$request.lang])
#foreach($country in $countries.countries)
<option value="$country.key">$country.value</option>
<option value="$country.key">$country.value</option>
#end
</select>
</select>
</div>
<div class="eight wide field">
<label>Club</label>
<span class="info"></span>
<input type="text" name="club" placeholder="club"/>
</div>
</div>
<div class="eight wide field">
<label>Club</label>
<span class="info"></span>
<input type="text" name="club" placeholder="club"/>
</div>
</div>
<div class="two stackable fields">
<div class="eight wide field">
<label>Rank</label>
<span class="info"></span>
<select name="rank">
<option></option>
<div class="two stackable fields">
<div class="eight wide field">
<label>Rank</label>
<span class="info"></span>
<select name="rank">
<option></option>
#levels()
</select>
</select>
</div>
<div class="eight wide field">
<label>Rating</label>
<span class="info"></span>
<input name="rating" type="text" class="numeric"/>
</div>
</div>
<div class="eight wide field">
<label>Rating</label>
<span class="info"></span>
<input name="rating" type="text" class="numeric"/>
</div>
</div>
<div class="inline fields">
<label>Final ?</label>
<div id="final-reg" class="field">
<input name="final" type="hidden"/>
<button id="reg-status" type="button" class="ui icon roundedremove mini button">
<span class="final"><i class="fa fa-check"></i></span>
<span class="preliminary"><i class="fa fa-question"></i></span>
</button>
</div>
<label>Participation</label>
<div class="inline fields">
<label>Final ?</label>
<div id="final-reg" class="field">
<input name="final" type="hidden"/>
<button id="reg-status" type="button" class="ui icon roundedremove mini button">
<span class="final"><i class="fa fa-check"></i></span>
<span class="preliminary"><i class="fa fa-question"></i></span>
</button>
</div>
<label>Participation</label>
#foreach($r in [1..$tour.rounds])
<div class="centered field">
<label>R${r}</label>
<input name="r${r}" type="checkbox" checked="checked" class="participation"/>
</div>
<div class="centered field">
<label>R${r}</label>
<input name="r${r}" type="checkbox" checked="checked" class="participation"/>
</div>
#end
</div>
</div>
</div>
<div class="popup-footer">
<button id="cancel-register" type="button" class="ui gray right labeled icon floating close button">
<button id="cancel-register" type="button" class="ui gray right labeled icon floating button">
<i class="times icon"></i>
<span class="edition">Close</span>
<span class="creation">Close</span>
@@ -288,6 +290,8 @@
</div>
</div>
#end
<div id="drop-changes" class="hidden">Drop changes?</div>
<div id="unregister-player" class="hidden">Unregister this player?</div>
#[[
<script id="result" type="text/template">
{{for #data}}