Bug fix
Ajout du statut remplaçant pour les joueurs Possibilité d'ajouter/enlever coach et manager des équipes les joueurs peuvent être associés à plusieurs équipes au lieu d'une seule
This commit is contained in:
@@ -100,7 +100,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% set positions = GAME_POSITIONS.get(tryout.game, []) %}
|
||||
{% set positions = game_positions.get(tryout.game, []) %}
|
||||
<div class="form-row">
|
||||
<div class="form-group col-12">
|
||||
<label for="position_recommendation">Recommended Position</label>
|
||||
|
||||
+129
-19
@@ -21,11 +21,11 @@
|
||||
<form method="POST" action="{{ url_for('teams.create_team') }}" class="form">
|
||||
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}"/>
|
||||
<div class="form-row">
|
||||
<div class="form-group col-6">
|
||||
<div class="form-group col-4">
|
||||
<label for="name">Team Name</label>
|
||||
<input type="text" id="name" name="name" placeholder="e.g., Varsity, JV, U14" required>
|
||||
</div>
|
||||
<div class="form-group col-6">
|
||||
<div class="form-group col-4">
|
||||
<label for="coach_id">Assigned Coach</label>
|
||||
<select id="coach_id" name="coach_id" class="form-select">
|
||||
<option value="">-- No coach assigned --</option>
|
||||
@@ -34,6 +34,15 @@
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group col-4">
|
||||
<label for="manager_id">Assigned Manager</label>
|
||||
<select id="manager_id" name="manager_id" class="form-select">
|
||||
<option value="">-- No manager assigned --</option>
|
||||
{% for manager in managers %}
|
||||
<option value="{{ manager.id }}">{{ manager.full_name }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-actions">
|
||||
<button type="button" class="btn btn-secondary" onclick="hideCreateForm()">Cancel</button>
|
||||
@@ -50,13 +59,36 @@
|
||||
<div class="card-header">
|
||||
<h3><i class="fas fa-users-cog"></i> {{ team.name }}</h3>
|
||||
<div class="card-actions">
|
||||
{% if team.coach %}
|
||||
<span class="text-muted">Coach: {{ team.coach.full_name }}</span>
|
||||
{% else %}
|
||||
<span class="text-muted">No coach assigned</span>
|
||||
{% endif %}
|
||||
<div class="team-staff">
|
||||
{% if team.coach %}
|
||||
<span class="text-muted">Coach: {{ team.coach.full_name }}</span>
|
||||
{% if can_manage %}
|
||||
<form method="POST" action="{{ url_for('teams.remove_coach', team_id=team.id) }}" class="inline-form" onsubmit="return confirm('Remove coach {{ team.coach.full_name }} from {{ team.name }}?')">
|
||||
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}"/>
|
||||
<button type="submit" class="btn btn-sm btn-outline-danger" title="Remove Coach">
|
||||
<i class="fas fa-user-minus"></i>
|
||||
</button>
|
||||
</form>
|
||||
{% endif %}
|
||||
{% else %}
|
||||
<span class="text-muted">No coach assigned</span>
|
||||
{% endif %}
|
||||
{% if team.manager %}
|
||||
<span class="text-muted ml-2">Manager: {{ team.manager.full_name }}</span>
|
||||
{% if can_manage %}
|
||||
<form method="POST" action="{{ url_for('teams.remove_manager', team_id=team.id) }}" class="inline-form" onsubmit="return confirm('Remove manager {{ team.manager.full_name }} from {{ team.name }}?')">
|
||||
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}"/>
|
||||
<button type="submit" class="btn btn-sm btn-outline-danger" title="Remove Manager">
|
||||
<i class="fas fa-user-minus"></i>
|
||||
</button>
|
||||
</form>
|
||||
{% endif %}
|
||||
{% else %}
|
||||
<span class="text-muted ml-2">No manager assigned</span>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% if can_manage %}
|
||||
<button class="btn btn-sm btn-outline edit-team-btn" data-team-id="{{ team.id }}" data-team-name="{{ team.name }}" data-coach-id="{{ team.coach_id or '' }}">
|
||||
<button class="btn btn-sm btn-outline edit-team-btn" data-team-id="{{ team.id }}" data-team-name="{{ team.name }}" data-coach-id="{{ team.coach_id or '' }}" data-manager-id="{{ team.manager_id or '' }}">
|
||||
<i class="fas fa-edit"></i> Edit
|
||||
</button>
|
||||
<form method="POST" action="{{ url_for('teams.delete_team', team_id=team.id) }}" class="inline-form" onsubmit="return confirm('Delete team {{ team.name }}? This will unassign it from any linked tryouts.')">
|
||||
@@ -79,6 +111,7 @@
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Player</th>
|
||||
<th>Status</th>
|
||||
<th>Position / Role</th>
|
||||
<th>Email</th>
|
||||
<th>Phone</th>
|
||||
@@ -88,20 +121,34 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for player in team.players %}
|
||||
{% for entry in team.get_players_with_status() %}
|
||||
<tr>
|
||||
<td>
|
||||
<div class="user-mini">
|
||||
<div class="avatar-sm">{{ player.full_name[:2] | upper }}</div>
|
||||
<span>{{ player.full_name }}</span>
|
||||
<div class="avatar-sm">{{ entry.player.full_name[:2] | upper }}</div>
|
||||
<span>{{ entry.player.full_name }}</span>
|
||||
</div>
|
||||
</td>
|
||||
<td>{{ player.role | capitalize }}</td>
|
||||
<td>{{ player.email }}</td>
|
||||
<td>{{ player.phone or '-' }}</td>
|
||||
<td>
|
||||
{% if can_manage_team %}
|
||||
<button class="btn btn-sm status-toggle-btn {% if entry.status == 'starter' %}btn-success{% else %}btn-warning{% endif %}"
|
||||
data-team-id="{{ team.id }}"
|
||||
data-player-id="{{ entry.player.id }}"
|
||||
onclick="toggleStatus(this)">
|
||||
{{ entry.status | capitalize }}
|
||||
</button>
|
||||
{% else %}
|
||||
<span class="badge {% if entry.status == 'starter' %}badge-success{% else %}badge-warning{% endif %}">
|
||||
{{ entry.status | capitalize }}
|
||||
</span>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>{{ entry.player.role | capitalize }}</td>
|
||||
<td>{{ entry.player.email }}</td>
|
||||
<td>{{ entry.player.phone or '-' }}</td>
|
||||
{% if can_manage_team %}
|
||||
<td>
|
||||
<form method="POST" action="{{ url_for('teams.remove_player', team_id=team.id, player_id=player.id) }}" class="inline-form" onsubmit="return confirm('Remove {{ player.full_name }} from {{ team.name }}?')">
|
||||
<form method="POST" action="{{ url_for('teams.remove_player', team_id=team.id, player_id=entry.player.id) }}" class="inline-form" onsubmit="return confirm('Remove {{ entry.player.full_name }} from {{ team.name }}?')">
|
||||
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}"/>
|
||||
<button type="submit" class="btn btn-sm btn-danger">
|
||||
<i class="fas fa-user-minus"></i> Remove
|
||||
@@ -112,7 +159,7 @@
|
||||
</tr>
|
||||
{% else %}
|
||||
<tr>
|
||||
<td colspan="{% if can_manage_team %}5{% else %}4{% endif %}" class="text-center">
|
||||
<td colspan="{% if can_manage_team %}6{% else %}5{% endif %}" class="text-center">
|
||||
<div class="empty-state">
|
||||
<i class="fas fa-users-slash"></i>
|
||||
<h4>No players assigned</h4>
|
||||
@@ -136,11 +183,15 @@
|
||||
<select name="player_id" class="form-select" required>
|
||||
<option value="">-- Select a player --</option>
|
||||
{% for p in all_players %}
|
||||
{% if p.team_id != team.id %}
|
||||
<option value="{{ p.id }}">{{ p.full_name }} {% if p.org_team %}(currently in {{ p.org_team.name }}){% endif %}</option>
|
||||
{% if p.id not in team.players | map(attribute='id') %}
|
||||
<option value="{{ p.id }}">{{ p.full_name }}</option>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</select>
|
||||
<select name="status" class="form-select ml-2">
|
||||
<option value="starter">Starter</option>
|
||||
<option value="substitute">Substitute</option>
|
||||
</select>
|
||||
<button type="submit" class="btn btn-sm btn-primary ml-2">
|
||||
<i class="fas fa-plus"></i> Add to Team
|
||||
</button>
|
||||
@@ -190,6 +241,15 @@
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="edit_manager_id">Assigned Manager</label>
|
||||
<select id="edit_manager_id" name="manager_id" class="form-select">
|
||||
<option value="">-- No manager assigned --</option>
|
||||
{% for manager in managers %}
|
||||
<option value="{{ manager.id }}">{{ manager.full_name }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-actions">
|
||||
<button type="button" class="btn btn-secondary" onclick="hideEditForm()">Cancel</button>
|
||||
<button type="submit" class="btn btn-primary">Save Changes</button>
|
||||
@@ -208,24 +268,56 @@ function hideCreateForm() {
|
||||
document.getElementById('createTeamForm').classList.add('hidden');
|
||||
}
|
||||
|
||||
function toggleStatus(btn) {
|
||||
var teamId = btn.getAttribute('data-team-id');
|
||||
var playerId = btn.getAttribute('data-player-id');
|
||||
|
||||
fetch('/teams/' + teamId + '/toggle_status/' + playerId, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'X-CSRFToken': '{{ csrf_token() }}',
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
})
|
||||
.then(function(response) { return response.json(); })
|
||||
.then(function(data) {
|
||||
if (data.success) {
|
||||
btn.textContent = data.new_status.charAt(0).toUpperCase() + data.new_status.slice(1);
|
||||
if (data.new_status === 'starter') {
|
||||
btn.classList.remove('btn-warning');
|
||||
btn.classList.add('btn-success');
|
||||
} else {
|
||||
btn.classList.remove('btn-success');
|
||||
btn.classList.add('btn-warning');
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch(function(error) {
|
||||
console.error('Error:', error);
|
||||
});
|
||||
}
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
document.querySelectorAll('.edit-team-btn').forEach(function(btn) {
|
||||
btn.addEventListener('click', function() {
|
||||
var teamId = this.getAttribute('data-team-id');
|
||||
var teamName = this.getAttribute('data-team-name');
|
||||
var coachId = this.getAttribute('data-coach-id');
|
||||
var managerId = this.getAttribute('data-manager-id');
|
||||
document.getElementById('editTeamForm').action = '/teams/' + teamId + '/edit';
|
||||
document.getElementById('edit_name').value = teamName;
|
||||
document.getElementById('edit_coach_id').value = coachId || '';
|
||||
document.getElementById('edit_manager_id').value = managerId || '';
|
||||
document.getElementById('editTeamModal').classList.remove('hidden');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
function showEditForm(teamId, teamName, coachId) {
|
||||
function showEditForm(teamId, teamName, coachId, managerId) {
|
||||
document.getElementById('editTeamForm').action = '/teams/' + teamId + '/edit';
|
||||
document.getElementById('edit_name').value = teamName;
|
||||
document.getElementById('edit_coach_id').value = coachId || '';
|
||||
document.getElementById('edit_manager_id').value = managerId || '';
|
||||
document.getElementById('editTeamModal').classList.remove('hidden');
|
||||
}
|
||||
|
||||
@@ -233,4 +325,22 @@ function hideEditForm() {
|
||||
document.getElementById('editTeamModal').classList.add('hidden');
|
||||
}
|
||||
</script>
|
||||
<style>
|
||||
.team-staff {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
.team-staff .text-muted {
|
||||
font-size: 0.85rem;
|
||||
}
|
||||
.ml-2 {
|
||||
margin-left: 8px;
|
||||
}
|
||||
.status-toggle-btn {
|
||||
cursor: pointer;
|
||||
min-width: 90px;
|
||||
}
|
||||
</style>
|
||||
{% endblock %}
|
||||
Reference in New Issue
Block a user