Evaluer un joueur retourne à la page précédente au lieu de la page des evaluations
231 lines
10 KiB
HTML
231 lines
10 KiB
HTML
{% extends "layouts/base.html" %}
|
|
{% block title %}Teams - TryoutPro{% endblock %}
|
|
{% block page_title %}Teams{% endblock %}
|
|
{% block breadcrumb %}<span class="breadcrumb">Home / Teams</span>{% endblock %}
|
|
|
|
{% block header_actions %}
|
|
{% if can_manage %}
|
|
<button class="btn btn-primary" onclick="showCreateForm()">
|
|
<i class="fas fa-plus"></i> New Team
|
|
</button>
|
|
{% endif %}
|
|
{% endblock %}
|
|
|
|
{% block content %}
|
|
{% if can_manage %}
|
|
<div id="createTeamForm" class="card mb-4 {% if not form_visible %}hidden{% endif %}">
|
|
<div class="card-header">
|
|
<h3>Create New Team</h3>
|
|
</div>
|
|
<div class="card-body">
|
|
<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">
|
|
<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">
|
|
<label for="coach_id">Assigned Coach</label>
|
|
<select id="coach_id" name="coach_id" class="form-select">
|
|
<option value="">-- No coach assigned --</option>
|
|
{% for coach in coaches %}
|
|
<option value="{{ coach.id }}">{{ coach.full_name }}</option>
|
|
{% endfor %}
|
|
</select>
|
|
</div>
|
|
</div>
|
|
<div class="form-actions">
|
|
<button type="button" class="btn btn-secondary" onclick="hideCreateForm()">Cancel</button>
|
|
<button type="submit" class="btn btn-primary">Create Team</button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
{% endif %}
|
|
|
|
{% for team in teams %}
|
|
{% set can_manage_team = can_manage or (current_user.role == 'coach' and team.coach_id == current_user.id) %}
|
|
<div class="card mb-4">
|
|
<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 %}
|
|
{% 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 '' }}">
|
|
<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.')">
|
|
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}"/>
|
|
<button type="submit" class="btn btn-sm btn-danger">
|
|
<i class="fas fa-trash"></i> Delete
|
|
</button>
|
|
</form>
|
|
{% endif %}
|
|
</div>
|
|
</div>
|
|
<div class="card-body">
|
|
<div class="table-container">
|
|
<table class="table">
|
|
<thead>
|
|
<tr>
|
|
<th>Player</th>
|
|
<th>Position / Role</th>
|
|
<th>Email</th>
|
|
<th>Phone</th>
|
|
{% if can_manage_team %}
|
|
<th>Actions</th>
|
|
{% endif %}
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
{% for player in team.players %}
|
|
<tr>
|
|
<td>
|
|
<div class="user-mini">
|
|
<div class="avatar-sm">{{ player.full_name[:2] | upper }}</div>
|
|
<span>{{ player.full_name }}</span>
|
|
</div>
|
|
</td>
|
|
<td>{{ player.role | capitalize }}</td>
|
|
<td>{{ player.email }}</td>
|
|
<td>{{ 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 }}?')">
|
|
<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
|
|
</button>
|
|
</form>
|
|
</td>
|
|
{% endif %}
|
|
</tr>
|
|
{% else %}
|
|
<tr>
|
|
<td colspan="{% if can_manage_team %}5{% else %}4{% endif %}" class="text-center">
|
|
<div class="empty-state">
|
|
<i class="fas fa-users-slash"></i>
|
|
<h4>No players assigned</h4>
|
|
{% if can_manage_team %}
|
|
<p>Add players to this team using the form below.</p>
|
|
{% endif %}
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
{% endfor %}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
|
|
{% if can_manage_team %}
|
|
<hr class="my-3">
|
|
<div class="add-player-section">
|
|
<h5 class="mb-2"><i class="fas fa-user-plus"></i> Add Player to {{ team.name }}</h5>
|
|
<form method="POST" action="{{ url_for('teams.add_player', team_id=team.id) }}" class="form-inline">
|
|
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}"/>
|
|
<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>
|
|
{% endif %}
|
|
{% endfor %}
|
|
</select>
|
|
<button type="submit" class="btn btn-sm btn-primary ml-2">
|
|
<i class="fas fa-plus"></i> Add to Team
|
|
</button>
|
|
</form>
|
|
</div>
|
|
{% endif %}
|
|
</div>
|
|
</div>
|
|
{% else %}
|
|
<div class="card">
|
|
<div class="card-body text-center">
|
|
<div class="empty-state">
|
|
<i class="fas fa-users-cog"></i>
|
|
<h3>No teams yet</h3>
|
|
{% if can_manage %}
|
|
<p>Create organization teams and assign coaches to manage tryouts.</p>
|
|
<button class="btn btn-primary" onclick="showCreateForm()">Create Team</button>
|
|
{% else %}
|
|
<p>There are no teams to display.</p>
|
|
{% endif %}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
{% endfor %}
|
|
|
|
<!-- Edit Team Modal -->
|
|
<div id="editTeamModal" class="modal hidden">
|
|
<div class="modal-backdrop" onclick="hideEditForm()"></div>
|
|
<div class="modal-content">
|
|
<div class="modal-header">
|
|
<h3>Edit Team</h3>
|
|
<button class="modal-close" onclick="hideEditForm()">×</button>
|
|
</div>
|
|
<div class="modal-body">
|
|
<form id="editTeamForm" method="POST" action="" class="form">
|
|
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}"/>
|
|
<div class="form-group">
|
|
<label for="edit_name">Team Name</label>
|
|
<input type="text" id="edit_name" name="name" required>
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="edit_coach_id">Assigned Coach</label>
|
|
<select id="edit_coach_id" name="coach_id" class="form-select">
|
|
<option value="">-- No coach assigned --</option>
|
|
{% for coach in coaches %}
|
|
<option value="{{ coach.id }}">{{ coach.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>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
function showCreateForm() {
|
|
document.getElementById('createTeamForm').classList.remove('hidden');
|
|
}
|
|
|
|
function hideCreateForm() {
|
|
document.getElementById('createTeamForm').classList.add('hidden');
|
|
}
|
|
|
|
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');
|
|
document.getElementById('editTeamForm').action = '/teams/' + teamId + '/edit';
|
|
document.getElementById('edit_name').value = teamName;
|
|
document.getElementById('edit_coach_id').value = coachId || '';
|
|
document.getElementById('editTeamModal').classList.remove('hidden');
|
|
});
|
|
});
|
|
});
|
|
|
|
function showEditForm(teamId, teamName, coachId) {
|
|
document.getElementById('editTeamForm').action = '/teams/' + teamId + '/edit';
|
|
document.getElementById('edit_name').value = teamName;
|
|
document.getElementById('edit_coach_id').value = coachId || '';
|
|
document.getElementById('editTeamModal').classList.remove('hidden');
|
|
}
|
|
|
|
function hideEditForm() {
|
|
document.getElementById('editTeamModal').classList.add('hidden');
|
|
}
|
|
</script>
|
|
{% endblock %} |