ajout de présence des joueurs sur un matchs
This commit is contained in:
@@ -141,7 +141,19 @@
|
||||
<h5>{{ match.team1.name }}</h5>
|
||||
<ul class="team-members-list">
|
||||
{% for member in match.team1.members %}
|
||||
<li>{{ member.player.username if member.player else 'Unknown Player' }}{% if member.position %} <span class="position-tag">{{ member.position }}</span>{% endif %}</li>
|
||||
<li>
|
||||
{{ member.player.username if member.player else 'Unknown Player' }}{% if member.position %} <span class="position-tag">{{ member.position }}</span>{% endif %}
|
||||
{% set pdata = participants_map.get(member.player_id) %}
|
||||
{% if pdata %}
|
||||
<span class="presence-badge {{ 'presence-confirmed' if pdata.attendance_confirmed else 'presence-pending' }}"
|
||||
data-participant-id="{{ pdata.participant_id }}"
|
||||
data-match-id="{{ match.id }}"
|
||||
onclick="togglePresence({{ match.id }}, {{ pdata.participant_id }}, this)"
|
||||
title="Click to toggle presence">
|
||||
{{ '✅ Confirmed' if pdata.attendance_confirmed else '⏳ Pending' }}
|
||||
</span>
|
||||
{% endif %}
|
||||
</li>
|
||||
{% else %}
|
||||
<li class="text-muted">No players assigned</li>
|
||||
{% endfor %}
|
||||
@@ -155,7 +167,19 @@
|
||||
<h5>{{ match.team2.name }}</h5>
|
||||
<ul class="team-members-list">
|
||||
{% for member in match.team2.members %}
|
||||
<li>{{ member.player.username if member.player else 'Unknown Player' }}{% if member.position %} <span class="position-tag">{{ member.position }}</span>{% endif %}</li>
|
||||
<li>
|
||||
{{ member.player.username if member.player else 'Unknown Player' }}{% if member.position %} <span class="position-tag">{{ member.position }}</span>{% endif %}
|
||||
{% set pdata = participants_map.get(member.player_id) %}
|
||||
{% if pdata %}
|
||||
<span class="presence-badge {{ 'presence-confirmed' if pdata.attendance_confirmed else 'presence-pending' }}"
|
||||
data-participant-id="{{ pdata.participant_id }}"
|
||||
data-match-id="{{ match.id }}"
|
||||
onclick="togglePresence({{ match.id }}, {{ pdata.participant_id }}, this)"
|
||||
title="Click to toggle presence">
|
||||
{{ '✅ Confirmed' if pdata.attendance_confirmed else '⏳ Pending' }}
|
||||
</span>
|
||||
{% endif %}
|
||||
</li>
|
||||
{% else %}
|
||||
<li class="text-muted">No players assigned</li>
|
||||
{% endfor %}
|
||||
@@ -382,6 +406,38 @@
|
||||
.randomize-btn:hover {
|
||||
background: var(--primary-dark);
|
||||
}
|
||||
|
||||
/* Presence badge styles */
|
||||
.presence-badge {
|
||||
display: inline-block;
|
||||
padding: 2px 8px;
|
||||
border-radius: 12px;
|
||||
font-size: 12px;
|
||||
cursor: pointer;
|
||||
margin-left: 8px;
|
||||
transition: all 0.2s ease;
|
||||
user-select: none;
|
||||
}
|
||||
.presence-badge:hover {
|
||||
transform: scale(1.05);
|
||||
box-shadow: 0 1px 3px rgba(0,0,0,0.2);
|
||||
}
|
||||
.presence-confirmed {
|
||||
background: #d4edda;
|
||||
color: #155724;
|
||||
border: 1px solid #c3e6cb;
|
||||
}
|
||||
.presence-pending {
|
||||
background: #fff3cd;
|
||||
color: #856404;
|
||||
border: 1px solid #ffeeba;
|
||||
}
|
||||
.team-members-list li {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
gap: 4px;
|
||||
}
|
||||
</style>
|
||||
<script>
|
||||
// Player data as simple JS object (id -> full_name)
|
||||
@@ -491,7 +547,6 @@ document.addEventListener('DOMContentLoaded', function() {
|
||||
|
||||
// Initialize team assignments for player_vs_player matches
|
||||
// Populate Team 1
|
||||
{% if match %}
|
||||
initialTeam1Ids.forEach(function(pid) {
|
||||
var teamDiv = document.getElementById('team1-selection');
|
||||
var playerName = playerDataById.player_data[pid];
|
||||
@@ -1007,5 +1062,35 @@ function randomizeTeams() {
|
||||
updateHiddenInputs();
|
||||
updateRandomizePreview();
|
||||
}
|
||||
|
||||
// Presence toggle function
|
||||
function togglePresence(matchId, participantId, badgeEl) {
|
||||
fetch('/matches/' + matchId + '/toggle-presence/' + participantId, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'X-CSRFToken': document.querySelector('[name="csrf_token"]').value
|
||||
}
|
||||
})
|
||||
.then(function(response) { return response.json(); })
|
||||
.then(function(data) {
|
||||
if (data.error) {
|
||||
alert('Error: ' + data.error);
|
||||
return;
|
||||
}
|
||||
if (data.attendance_confirmed) {
|
||||
badgeEl.classList.remove('presence-pending');
|
||||
badgeEl.classList.add('presence-confirmed');
|
||||
badgeEl.textContent = '✅ Confirmed';
|
||||
} else {
|
||||
badgeEl.classList.remove('presence-confirmed');
|
||||
badgeEl.classList.add('presence-pending');
|
||||
badgeEl.textContent = '⏳ Pending';
|
||||
}
|
||||
})
|
||||
.catch(function(error) {
|
||||
console.error('Error toggling presence:', error);
|
||||
});
|
||||
}
|
||||
</script>
|
||||
{% endblock %}
|
||||
{% endblock %}
|
||||
|
||||
@@ -278,11 +278,12 @@
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Match</th>
|
||||
<th>Match</th>
|
||||
<th>Type</th>
|
||||
<th>Date</th>
|
||||
<th>Participants</th>
|
||||
<th>Time</th>
|
||||
<th>Presence</th>
|
||||
<th>Status</th>
|
||||
{% if can_edit %}
|
||||
<th>Actions</th>
|
||||
@@ -307,6 +308,28 @@
|
||||
</span>
|
||||
</td>
|
||||
<td>{{ m.date.strftime('%m/%d/%Y') }}</td>
|
||||
<td>
|
||||
{% if m.start_time and m.end_time %}
|
||||
{{ m.start_time.strftime('%H:%M') }} - {{ m.end_time.strftime('%H:%M') }}
|
||||
{% else %}
|
||||
TBD
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>
|
||||
{% if item.total_count > 0 %}
|
||||
<span class="presence-summary" title="{{ item.confirmed_count }} of {{ item.total_count }} confirmed">
|
||||
{% if item.confirmed_count == item.total_count and item.total_count > 0 %}
|
||||
<span class="badge badge-success">✅ {{ item.confirmed_count }}/{{ item.total_count }}</span>
|
||||
{% elif item.confirmed_count > 0 %}
|
||||
<span class="badge badge-warning">✅ {{ item.confirmed_count }}/{{ item.total_count }}</span>
|
||||
{% else %}
|
||||
<span class="badge badge-secondary">⏳ 0/{{ item.total_count }}</span>
|
||||
{% endif %}
|
||||
</span>
|
||||
{% else %}
|
||||
<span class="text-muted">—</span>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>
|
||||
{% if m.match_type == 'team_vs_team' %}
|
||||
<div class="match-teams">
|
||||
@@ -360,13 +383,6 @@
|
||||
{{ participants | join(', ') }}
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>
|
||||
{% if m.start_time and m.end_time %}
|
||||
{{ m.start_time.strftime('%H:%M') }} - {{ m.end_time.strftime('%H:%M') }}
|
||||
{% else %}
|
||||
TBD
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>
|
||||
<span class="badge badge-{{ m.status }}">{{ m.status }}</span>
|
||||
</td>
|
||||
|
||||
Reference in New Issue
Block a user