ajustements des calendriers, ajout de matchs jouer vs joueur
This commit is contained in:
@@ -12,10 +12,11 @@
|
||||
<form method="POST" action="{{ url_for('matches.create_match', tryout_id=tryout.id) }}" class="form">
|
||||
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}"/>
|
||||
|
||||
<div class="form-group">
|
||||
<div class="form-group">
|
||||
<label for="match_type">Match Type</label>
|
||||
<select name="match_type" id="match_type" class="form-select" onchange="toggleMatchType()" required>
|
||||
<option value="team_vs_team">Team vs Team</option>
|
||||
<option value="player_vs_player">Player vs Player</option>
|
||||
<option value="player_scrim">Player Scrim</option>
|
||||
</select>
|
||||
</div>
|
||||
@@ -79,10 +80,41 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Player vs Player Selection -->
|
||||
<div id="player-vs-player-section" class="hidden">
|
||||
<hr class="section-divider">
|
||||
<h4 class="section-title"><i class="fas fa-user-friends"></i> Select Players</h4>
|
||||
|
||||
<div class="form-row">
|
||||
<div class="form-group">
|
||||
<label>Team 1 Players</label>
|
||||
<div class="checkbox-grid">
|
||||
{% for player in all_players %}
|
||||
<label class="checkbox-label">
|
||||
<input type="checkbox" name="team1_player_ids" value="{{ player.id }}" onchange="handleTeamSelection(this, 1)">
|
||||
{{ player.full_name }}
|
||||
</label>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Team 2 Players</label>
|
||||
<div class="checkbox-grid">
|
||||
{% for player in all_players %}
|
||||
<label class="checkbox-label">
|
||||
<input type="checkbox" name="team2_player_ids" value="{{ player.id }}" onchange="handleTeamSelection(this, 2)">
|
||||
{{ player.full_name }}
|
||||
</label>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Player Scrim Selection -->
|
||||
<div id="player-scrim-section" class="hidden">
|
||||
<hr class="section-divider">
|
||||
<h4 class="section-title"><i class="fas fa-user-friends"></i> Select Players</h4>
|
||||
<h4 class="section-title"><i class="fas fa-users"></i> Select Players</h4>
|
||||
|
||||
<div class="form-group">
|
||||
<label>Players</label>
|
||||
@@ -115,20 +147,41 @@
|
||||
function toggleMatchType() {
|
||||
var matchType = document.getElementById('match_type').value;
|
||||
var teamSection = document.getElementById('team-vs-team-section');
|
||||
var playerSection = document.getElementById('player-scrim-section');
|
||||
var playerVsPlayerSection = document.getElementById('player-vs-player-section');
|
||||
var scrimSection = document.getElementById('player-scrim-section');
|
||||
|
||||
// Hide all sections first
|
||||
teamSection.classList.add('hidden');
|
||||
playerVsPlayerSection.classList.add('hidden');
|
||||
scrimSection.classList.add('hidden');
|
||||
|
||||
// Show relevant section
|
||||
if (matchType === 'team_vs_team') {
|
||||
teamSection.classList.remove('hidden');
|
||||
playerSection.classList.add('hidden');
|
||||
} else {
|
||||
teamSection.classList.add('hidden');
|
||||
playerSection.classList.remove('hidden');
|
||||
} else if (matchType === 'player_vs_player') {
|
||||
playerVsPlayerSection.classList.remove('hidden');
|
||||
} else if (matchType === 'player_scrim') {
|
||||
scrimSection.classList.remove('hidden');
|
||||
}
|
||||
}
|
||||
|
||||
function handleTeamSelection(checkbox, teamSide) {
|
||||
// When selecting from one team, deselect from the other team
|
||||
var otherSide = teamSide === 1 ? 2 : 1;
|
||||
var otherCheckboxes = document.querySelectorAll('input[name="team' + otherSide + '_player_ids"]');
|
||||
var playerId = checkbox.value;
|
||||
|
||||
// Find the corresponding checkbox in the other team and uncheck it
|
||||
otherCheckboxes.forEach(function(other) {
|
||||
if (other.value === playerId) {
|
||||
other.checked = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Initialize on page load
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
toggleMatchType();
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
||||
{% endblock %}
|
||||
|
||||
@@ -53,6 +53,7 @@
|
||||
<textarea name="description" id="description" class="form-textarea" placeholder="Optional notes about this match">{{ match.description or '' }}</textarea>
|
||||
</div>
|
||||
|
||||
<!-- Team vs Team Selection -->
|
||||
{% if match.match_type == 'team_vs_team' %}
|
||||
<hr class="section-divider">
|
||||
<h4 class="section-title"><i class="fas fa-users"></i> Teams</h4>
|
||||
@@ -77,9 +78,69 @@
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Show team rosters -->
|
||||
<div class="team-rosters mt-3">
|
||||
{% if match.team1 %}
|
||||
<div class="team-roster">
|
||||
<h5>{{ match.team1.name }} Players</h5>
|
||||
<ul class="team-members-list">
|
||||
{% for member in match.team1.members %}
|
||||
<li>{{ member.player.full_name }}{% if member.position %} <span class="position-tag">{{ member.position }}</span>{% endif %}</li>
|
||||
{% else %}
|
||||
<li class="text-muted">No players assigned</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if match.team2 %}
|
||||
<div class="team-roster">
|
||||
<h5>{{ match.team2.name }} Players</h5>
|
||||
<ul class="team-members-list">
|
||||
{% for member in match.team2.members %}
|
||||
<li>{{ member.player.full_name }}{% if member.position %} <span class="position-tag">{{ member.position }}</span>{% endif %}</li>
|
||||
{% else %}
|
||||
<li class="text-muted">No players assigned</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<!-- Player vs Player Selection -->
|
||||
{% elif match.match_type == 'player_vs_player' %}
|
||||
<hr class="section-divider">
|
||||
<h4 class="section-title"><i class="fas fa-user-friends"></i> Select Players</h4>
|
||||
|
||||
<div class="form-row">
|
||||
<div class="form-group">
|
||||
<label>Team 1 Players</label>
|
||||
<div class="checkbox-grid">
|
||||
{% for player in all_players %}
|
||||
<label class="checkbox-label">
|
||||
<input type="checkbox" name="team1_player_ids" value="{{ player.id }}" {% if player.id in team1_player_ids %}checked{% endif %} onchange="handleTeamSelection(this, 1)">
|
||||
{{ player.full_name }}
|
||||
</label>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Team 2 Players</label>
|
||||
<div class="checkbox-grid">
|
||||
{% for player in all_players %}
|
||||
<label class="checkbox-label">
|
||||
<input type="checkbox" name="team2_player_ids" value="{{ player.id }}" {% if player.id in team2_player_ids %}checked{% endif %} onchange="handleTeamSelection(this, 2)">
|
||||
{{ player.full_name }}
|
||||
</label>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Player Scrim Selection -->
|
||||
{% else %}
|
||||
<hr class="section-divider">
|
||||
<h4 class="section-title"><i class="fas fa-user-friends"></i> Players</h4>
|
||||
<h4 class="section-title"><i class="fas fa-users"></i> Select Players</h4>
|
||||
|
||||
<div class="form-group">
|
||||
<label>Players</label>
|
||||
@@ -105,4 +166,22 @@
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
{% endblock %}
|
||||
|
||||
{% block scripts %}
|
||||
<script>
|
||||
function handleTeamSelection(checkbox, teamSide) {
|
||||
// When selecting from one team, deselect from the other team
|
||||
var otherSide = teamSide === 1 ? 2 : 1;
|
||||
var otherCheckboxes = document.querySelectorAll('input[name="team' + otherSide + '_player_ids"]');
|
||||
var playerId = checkbox.value;
|
||||
|
||||
// Find the corresponding checkbox in the other team and uncheck it
|
||||
otherCheckboxes.forEach(function(other) {
|
||||
if (other.value === playerId) {
|
||||
other.checked = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
||||
@@ -231,10 +231,10 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% if matches %}
|
||||
{% if can_view_calendar %}
|
||||
<div class="card mt-4">
|
||||
<div class="card-header">
|
||||
<h3><i class="fas fa-futbol"></i> Scheduled Matches</h3>
|
||||
<h3><i class="fas fa-futbol"></i> Schedule</h3>
|
||||
{% if can_edit %}
|
||||
<a href="{{ url_for('matches.create_match', tryout_id=tryout.id) }}" class="btn btn-sm btn-success">
|
||||
<i class="fas fa-plus"></i> Schedule Match
|
||||
@@ -242,9 +242,18 @@
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="card-body">
|
||||
{% if matches %}
|
||||
<!-- Mini Calendar -->
|
||||
<div id="mini-calendar" style="min-height: 300px;"></div>
|
||||
{% else %}
|
||||
<!-- No matches yet - show message -->
|
||||
<div class="text-center py-4">
|
||||
<i class="fas fa-calendar-alt fa-3x text-muted mb-3"></i>
|
||||
<p class="text-muted">No matches scheduled yet. Check back later!</p>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if matches %}
|
||||
<!-- Matches Table -->
|
||||
<div class="table-container mt-3">
|
||||
<table class="table">
|
||||
@@ -264,19 +273,42 @@
|
||||
<tbody>
|
||||
{% for item in match_data %}
|
||||
{% set m = item.match %}
|
||||
{% set participants = item.participants %}
|
||||
<tr>
|
||||
<td class="cell-title">{{ m.title }}</td>
|
||||
<td>
|
||||
<span class="badge badge-{{ 'success' if m.match_type == 'team_vs_team' else 'warning' }}">
|
||||
{{ 'Team vs Team' if m.match_type == 'team_vs_team' else 'Player Scrim' }}
|
||||
<span class="badge badge-{{ 'success' if m.match_type in ['team_vs_team', 'player_vs_player'] else 'warning' }}">
|
||||
{% if m.match_type == 'team_vs_team' %}
|
||||
Team vs Team
|
||||
{% elif m.match_type == 'player_vs_player' %}
|
||||
Player vs Player
|
||||
{% else %}
|
||||
Player Scrim
|
||||
{% endif %}
|
||||
</span>
|
||||
</td>
|
||||
<td>{{ m.date.strftime('%m/%d/%Y') }}</td>
|
||||
<td>
|
||||
{% if m.match_type == 'team_vs_team' %}
|
||||
{{ item.participants.team1 }} vs {{ item.participants.team2 }}
|
||||
{{ participants.team1 }} vs {{ participants.team2 }}
|
||||
{% if participants.team1_players or participants.team2_players %}
|
||||
<div class="team-roster-display mt-1">
|
||||
{% if participants.team1_players %}
|
||||
<small><strong>{{ m.team1.name if m.team1 else 'Team 1' }}:</strong>
|
||||
{% for pl in participants.team1_players %}{{ pl.name }}{% if not loop.last %}, {% endif %}{% endfor %}
|
||||
</small><br>
|
||||
{% endif %}
|
||||
{% if participants.team2_players %}
|
||||
<small><strong>{{ m.team2.name if m.team2 else 'Team 2' }}:</strong>
|
||||
{% for pl in participants.team2_players %}{{ pl.name }}{% if not loop.last %}, {% endif %}{% endfor %}
|
||||
</small>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endif %}
|
||||
{% elif m.match_type == 'player_vs_player' %}
|
||||
{{ participants.team1 }} vs {{ participants.team2 }}
|
||||
{% else %}
|
||||
{{ item.participants | join(', ') }}
|
||||
{{ participants | join(', ') }}
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>
|
||||
@@ -301,6 +333,7 @@
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
Reference in New Issue
Block a user