Files
team-tryouts/templates/pages/edit_match.html
T

188 lines
8.9 KiB
HTML

{% extends "layouts/base.html" %}
{% block title %}Edit Match - TryoutPro{% endblock %}
{% block page_title %}Edit Match{% endblock %}
{% block breadcrumb %}<span class="breadcrumb">Home / <a href="{{ url_for('tryouts.list_tryouts') }}">Tryouts</a> / <a href="{{ url_for('tryouts.view_tryout', tryout_id=tryout.id) }}">{{ tryout.title }}</a> / Edit Match</span>{% endblock %}
{% block content %}
<div class="card">
<div class="card-header">
<h3><i class="fas fa-futbol"></i> Edit Match</h3>
</div>
<div class="card-body">
<form method="POST" action="{{ url_for('matches.edit_match', match_id=match.id) }}" class="form">
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}"/>
<div class="form-group">
<label for="title">Match Title</label>
<input type="text" name="title" id="title" class="form-input" value="{{ match.title }}" required>
</div>
<div class="form-row">
<div class="form-group">
<label for="date">Date</label>
<input type="date" name="date" id="date" class="form-input" value="{{ match.date.strftime('%Y-%m-%d') }}" required>
</div>
<div class="form-group">
<label for="status">Status</label>
<select name="status" id="status" class="form-select">
<option value="scheduled" {% if match.status == 'scheduled' %}selected{% endif %}>Scheduled</option>
<option value="completed" {% if match.status == 'completed' %}selected{% endif %}>Completed</option>
<option value="cancelled" {% if match.status == 'cancelled' %}selected{% endif %}>Cancelled</option>
</select>
</div>
</div>
<div class="form-row">
<div class="form-group">
<label for="start_time">Start Time</label>
<input type="time" name="start_time" id="start_time" class="form-input" value="{{ match.start_time.strftime('%H:%M') if match.start_time else '' }}">
</div>
<div class="form-group">
<label for="end_time">End Time</label>
<input type="time" name="end_time" id="end_time" class="form-input" value="{{ match.end_time.strftime('%H:%M') if match.end_time else '' }}">
</div>
</div>
<div class="form-group">
<label for="location">Location</label>
<input type="text" name="location" id="location" class="form-input" value="{{ match.location or '' }}" placeholder="Match location">
</div>
<div class="form-group">
<label for="description">Description</label>
<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>
<div class="form-row">
<div class="form-group">
<label for="team1_id">Team 1</label>
<select name="team1_id" id="team1_id" class="form-select">
<option value="">-- Select Team 1 --</option>
{% for team in teams %}
<option value="{{ team.id }}" {% if match.team1_id == team.id %}selected{% endif %}>{{ team.name }}</option>
{% endfor %}
</select>
</div>
<div class="form-group">
<label for="team2_id">Team 2</label>
<select name="team2_id" id="team2_id" class="form-select">
<option value="">-- Select Team 2 --</option>
{% for team in teams %}
<option value="{{ team.id }}" {% if match.team2_id == team.id %}selected{% endif %}>{{ team.name }}</option>
{% endfor %}
</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-users"></i> Select Players</h4>
<div class="form-group">
<label>Players</label>
<div class="checkbox-grid">
{% for player in all_players %}
<label class="checkbox-label">
<input type="checkbox" name="player_ids" value="{{ player.id }}" {% if player.id in current_player_ids %}checked{% endif %}>
{{ player.full_name }}
</label>
{% endfor %}
</div>
</div>
{% endif %}
<div class="form-actions">
<button type="submit" class="btn btn-primary">
<i class="fas fa-save"></i> Save Changes
</button>
<a href="{{ url_for('tryouts.view_tryout', tryout_id=tryout.id) }}" class="btn btn-secondary">
<i class="fas fa-times"></i> Cancel
</a>
</div>
</form>
</div>
</div>
{% 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 %}