added new tournament mode.
This commit is contained in:
@@ -137,9 +137,42 @@
|
||||
margin-bottom: 15px;
|
||||
border-bottom: 3px solid #007bff;
|
||||
padding-bottom: 5px;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
/* Compact Stats Overview */
|
||||
.section-controls {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.filter-btn {
|
||||
background: #f8f9fa;
|
||||
border: 1px solid #dee2e6;
|
||||
padding: 6px 12px;
|
||||
border-radius: 6px;
|
||||
cursor: pointer;
|
||||
font-size: 0.8rem;
|
||||
transition: all 0.2s ease;
|
||||
}
|
||||
|
||||
.filter-btn.active {
|
||||
background: #007bff;
|
||||
color: white;
|
||||
border-color: #007bff;
|
||||
}
|
||||
|
||||
.filter-btn:hover {
|
||||
background: #e9ecef;
|
||||
}
|
||||
|
||||
.filter-btn.active:hover {
|
||||
background: #0056b3;
|
||||
}
|
||||
|
||||
/* Enhanced Stats Overview */
|
||||
.stats-overview {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
|
||||
@@ -181,7 +214,20 @@
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
/* Compact Archive Grid */
|
||||
/* Target-specific stat cards */
|
||||
.stat-card.target-40 {
|
||||
border-left: 4px solid #dc3545;
|
||||
}
|
||||
|
||||
.stat-card.target-20 {
|
||||
border-left: 4px solid #ffc107;
|
||||
}
|
||||
|
||||
.stat-card.target-4 {
|
||||
border-left: 4px solid #28a745;
|
||||
}
|
||||
|
||||
/* Enhanced Archive Grid */
|
||||
.archive-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
|
||||
@@ -221,6 +267,22 @@
|
||||
background: #fff3cd;
|
||||
}
|
||||
|
||||
.archive-card.tournament-40 .archive-header {
|
||||
background: #f8d7da;
|
||||
}
|
||||
|
||||
.archive-card.tournament-20 .archive-header {
|
||||
background: #fff3cd;
|
||||
}
|
||||
|
||||
.archive-card.tournament-4 .archive-header {
|
||||
background: #d1edff;
|
||||
}
|
||||
|
||||
.archive-card.tournament-other .archive-header {
|
||||
background: #f8f9fa;
|
||||
}
|
||||
|
||||
.archive-title {
|
||||
font-size: 1.2rem;
|
||||
font-weight: bold;
|
||||
@@ -251,6 +313,21 @@
|
||||
color: #856404;
|
||||
}
|
||||
|
||||
.badge-40-targets {
|
||||
background: #dc3545;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.badge-20-targets {
|
||||
background: #ffc107;
|
||||
color: #856404;
|
||||
}
|
||||
|
||||
.badge-4-targets {
|
||||
background: #17a2b8;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.archive-content {
|
||||
padding: 15px 20px;
|
||||
}
|
||||
@@ -283,23 +360,28 @@
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
gap: 8px;
|
||||
padding-top: 12px;
|
||||
border-top: 1px solid #f0f0f0;
|
||||
}
|
||||
|
||||
.view-btn {
|
||||
background: #007bff;
|
||||
.action-btn {
|
||||
border: none;
|
||||
color: white;
|
||||
padding: 8px 16px;
|
||||
padding: 8px 12px;
|
||||
border-radius: 6px;
|
||||
cursor: pointer;
|
||||
font-size: 0.85rem;
|
||||
font-size: 0.8rem;
|
||||
font-weight: bold;
|
||||
transition: all 0.2s ease;
|
||||
text-decoration: none;
|
||||
display: inline-block;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.view-btn {
|
||||
background: #007bff;
|
||||
color: white;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.view-btn:hover {
|
||||
@@ -307,16 +389,18 @@
|
||||
transform: translateY(-1px);
|
||||
}
|
||||
|
||||
.edit-btn {
|
||||
background: #28a745;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.edit-btn:hover {
|
||||
background: #1e7e34;
|
||||
}
|
||||
|
||||
.delete-btn {
|
||||
background: #dc3545;
|
||||
border: none;
|
||||
color: white;
|
||||
padding: 6px 12px;
|
||||
border-radius: 6px;
|
||||
cursor: pointer;
|
||||
font-size: 0.75rem;
|
||||
font-weight: bold;
|
||||
transition: all 0.2s ease;
|
||||
}
|
||||
|
||||
.delete-btn:hover {
|
||||
@@ -342,7 +426,7 @@
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
/* Confirmation Modal */
|
||||
/* Modal Styles */
|
||||
.modal-overlay {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
@@ -364,18 +448,20 @@
|
||||
visibility: visible;
|
||||
}
|
||||
|
||||
.confirmation-modal {
|
||||
.modal {
|
||||
background: white;
|
||||
border-radius: 8px;
|
||||
padding: 20px;
|
||||
max-width: 400px;
|
||||
max-width: 500px;
|
||||
width: 90%;
|
||||
max-height: 80vh;
|
||||
overflow-y: auto;
|
||||
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
|
||||
transform: scale(0.9);
|
||||
transition: transform 0.2s ease;
|
||||
}
|
||||
|
||||
.modal-overlay.active .confirmation-modal {
|
||||
.modal-overlay.active .modal {
|
||||
transform: scale(1);
|
||||
}
|
||||
|
||||
@@ -383,7 +469,7 @@
|
||||
font-size: 1.1rem;
|
||||
font-weight: bold;
|
||||
color: #333;
|
||||
margin-bottom: 10px;
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
|
||||
.modal-message {
|
||||
@@ -396,6 +482,7 @@
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
justify-content: flex-end;
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
.modal-btn {
|
||||
@@ -425,6 +512,64 @@
|
||||
background: #c82333;
|
||||
}
|
||||
|
||||
.modal-btn.primary {
|
||||
background: #007bff;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.modal-btn.primary:hover {
|
||||
background: #0056b3;
|
||||
}
|
||||
|
||||
/* Edit Form Styles */
|
||||
.edit-form {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 15px;
|
||||
}
|
||||
|
||||
.form-group {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 5px;
|
||||
}
|
||||
|
||||
.form-label {
|
||||
font-weight: bold;
|
||||
color: #333;
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
|
||||
.form-input {
|
||||
padding: 8px 12px;
|
||||
border: 1px solid #ddd;
|
||||
border-radius: 4px;
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
|
||||
.form-input:focus {
|
||||
outline: none;
|
||||
border-color: #007bff;
|
||||
}
|
||||
|
||||
.form-select {
|
||||
padding: 8px 12px;
|
||||
border: 1px solid #ddd;
|
||||
border-radius: 4px;
|
||||
font-size: 0.9rem;
|
||||
background: white;
|
||||
}
|
||||
|
||||
.form-select:focus {
|
||||
outline: none;
|
||||
border-color: #007bff;
|
||||
}
|
||||
|
||||
/* Hidden class for filtering */
|
||||
.hidden {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
/* Mobile responsive */
|
||||
@media (max-width: 768px) {
|
||||
.navbar {
|
||||
@@ -468,9 +613,19 @@
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.view-btn {
|
||||
.action-btn {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.section-title {
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.section-controls {
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
@@ -485,37 +640,54 @@
|
||||
</div>
|
||||
|
||||
<div class="container">
|
||||
<!-- Stats Overview -->
|
||||
<!-- Enhanced Stats Overview -->
|
||||
<div class="stats-overview">
|
||||
<div class="stat-card">
|
||||
<span class="stat-icon">🏆</span>
|
||||
<div class="stat-value">{{ stats.total_tournaments }}</div>
|
||||
<div class="stat-label">Standalone Tournaments</div>
|
||||
</div>
|
||||
<div class="stat-card">
|
||||
<span class="stat-icon">🎖️</span>
|
||||
<div class="stat-value">{{ stats.total_leagues }}</div>
|
||||
<div class="stat-value">{{ leagues|length if leagues else 0 }}</div>
|
||||
<div class="stat-label">Completed Leagues</div>
|
||||
</div>
|
||||
<div class="stat-card">
|
||||
<span class="stat-icon">👥</span>
|
||||
<div class="stat-value">{{ stats.total_players }}</div>
|
||||
<div class="stat-label">Active Players</div>
|
||||
<span class="stat-icon">🏆</span>
|
||||
<div class="stat-value">{{ tournaments|length if tournaments else 0 }}</div>
|
||||
<div class="stat-label">Total Tournaments</div>
|
||||
</div>
|
||||
<div class="stat-card target-40">
|
||||
<span class="stat-icon">🎯</span>
|
||||
<div class="stat-value">{{ tournaments|selectattr('tournament_type', 'equalto', '40_targets')|list|length if tournaments else 0 }}</div>
|
||||
<div class="stat-label">40-Target Tournaments</div>
|
||||
</div>
|
||||
<div class="stat-card target-20">
|
||||
<span class="stat-icon">🏹</span>
|
||||
<div class="stat-value">{{ tournaments|selectattr('tournament_type', 'equalto', '20_targets')|list|length if tournaments else 0 }}</div>
|
||||
<div class="stat-label">20-Target Tournaments</div>
|
||||
</div>
|
||||
<div class="stat-card target-4">
|
||||
<span class="stat-icon">🎪</span>
|
||||
<div class="stat-value">{{ tournaments|selectattr('tournament_type', 'equalto', '4_targets')|list|length if tournaments else 0 }}</div>
|
||||
<div class="stat-label">4-Target Tournaments</div>
|
||||
</div>
|
||||
<div class="stat-card">
|
||||
<span class="stat-icon">📊</span>
|
||||
<div class="stat-value">{{ stats.total_matches }}</div>
|
||||
<div class="stat-label">Total Competitions</div>
|
||||
<span class="stat-icon">👥</span>
|
||||
<div class="stat-value">{{ stats.total_players if stats else 0 }}</div>
|
||||
<div class="stat-label">Active Players</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Leagues Section -->
|
||||
{% if leagues %}
|
||||
<div class="section">
|
||||
<h2 class="section-title">🎖️ League Championships</h2>
|
||||
<div class="archive-grid">
|
||||
<div class="section-title">
|
||||
<span>🎖️ League Championships</span>
|
||||
<div class="section-controls">
|
||||
<button class="filter-btn active" onclick="filterLeagues('all')">All</button>
|
||||
<button class="filter-btn" onclick="filterLeagues('completed')">Completed</button>
|
||||
<button class="filter-btn" onclick="filterLeagues('recent')">Recent</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="archive-grid" id="leagues-grid">
|
||||
{% for league in leagues %}
|
||||
<div class="archive-card league" onclick="viewLeague('{{ league.filename }}')">
|
||||
<div class="archive-card league" data-status="{{ 'completed' if league.completed_tournaments == league.total_tournaments else 'incomplete' }}" data-date="{{ league.archived_at }}" onclick="viewLeague('{{ league.filename }}')">
|
||||
<div class="archive-header">
|
||||
<div>
|
||||
<div class="archive-title">League Championship</div>
|
||||
@@ -543,9 +715,12 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="archive-actions">
|
||||
<a href="/archive/league/{{ league.filename }}" class="view-btn">🏆 View Results</a>
|
||||
<button class="delete-btn" onclick="event.stopPropagation(); deleteArchive('league', '{{ league.filename }}')">
|
||||
🗑️ Delete
|
||||
<a href="/archive/league/{{ league.filename }}" class="action-btn view-btn">🏆 View</a>
|
||||
<button class="action-btn edit-btn" onclick="event.stopPropagation(); editArchive('league', '{{ league.filename }}', {{ league|tojson }})">
|
||||
✏️ Edit
|
||||
</button>
|
||||
<button class="action-btn delete-btn" onclick="event.stopPropagation(); deleteArchive('league', '{{ league.filename }}')">
|
||||
🗑️
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -555,16 +730,198 @@
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<!-- Standalone Tournaments Section -->
|
||||
<!-- Tournaments Section - Organized by Target Count -->
|
||||
{% if tournaments %}
|
||||
|
||||
<!-- 40-Target Tournaments -->
|
||||
{% set tournaments_40 = tournaments|selectattr('tournament_type', 'equalto', '40_targets')|list %}
|
||||
{% if tournaments_40 %}
|
||||
<div class="section">
|
||||
<h2 class="section-title">🏆 Standalone Tournaments</h2>
|
||||
<div class="archive-grid">
|
||||
{% for tournament in tournaments %}
|
||||
<div class="archive-card tournament" onclick="viewTournament('{{ tournament.filename }}')">
|
||||
<div class="section-title">
|
||||
<span>🎯 40-Target Tournaments</span>
|
||||
<div class="section-controls">
|
||||
<button class="filter-btn active" onclick="filterTournaments('40', 'all')">All</button>
|
||||
<button class="filter-btn" onclick="filterTournaments('40', 'finished')">Finished</button>
|
||||
<button class="filter-btn" onclick="filterTournaments('40', 'recent')">Recent</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="archive-grid" id="tournaments-40-grid">
|
||||
{% for tournament in tournaments_40 %}
|
||||
<div class="archive-card tournament-40" data-status="{{ 'finished' if tournament.tournament_finished else 'incomplete' }}" data-date="{{ tournament.archived_at }}" data-targets="40" onclick="viewTournament('{{ tournament.filename }}')">
|
||||
<div class="archive-header">
|
||||
<div>
|
||||
<div class="archive-title">Single Tournament</div>
|
||||
<div class="archive-title">40-Target Tournament</div>
|
||||
<div class="archive-subtitle">{{ tournament.created_at[:10] if tournament.created_at != 'Unknown' else 'Unknown Date' }}</div>
|
||||
</div>
|
||||
<span class="archive-badge badge-40-targets">40 Targets</span>
|
||||
</div>
|
||||
<div class="archive-content">
|
||||
<div class="archive-info">
|
||||
<div class="info-item">
|
||||
<span class="info-icon">👥</span>
|
||||
<span class="info-value">{{ tournament.participants_count }} players</span>
|
||||
</div>
|
||||
<div class="info-item">
|
||||
<span class="info-icon">🎯</span>
|
||||
<span class="info-value">{{ tournament.tournament_type.replace('_', ' ')|title }}</span>
|
||||
</div>
|
||||
<div class="info-item">
|
||||
<span class="info-icon">📅</span>
|
||||
<span class="info-value">{{ tournament.archived_at[:10] if tournament.archived_at != 'Unknown' else 'Unknown Date' }}</span>
|
||||
</div>
|
||||
<div class="info-item">
|
||||
<span class="info-icon">🏁</span>
|
||||
<span class="info-value">{{ 'Finished' if tournament.tournament_finished else 'Incomplete' }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="archive-actions">
|
||||
<a href="/archive/tournament/{{ tournament.filename }}" class="action-btn view-btn">📊 View</a>
|
||||
<button class="action-btn edit-btn" onclick="event.stopPropagation(); editArchive('tournament', '{{ tournament.filename }}', {{ tournament|tojson }})">
|
||||
✏️ Edit
|
||||
</button>
|
||||
<button class="action-btn delete-btn" onclick="event.stopPropagation(); deleteArchive('tournament', '{{ tournament.filename }}')">
|
||||
🗑️
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<!-- 20-Target Tournaments -->
|
||||
{% set tournaments_20 = tournaments|selectattr('tournament_type', 'equalto', '20_targets')|list %}
|
||||
{% if tournaments_20 %}
|
||||
<div class="section">
|
||||
<div class="section-title">
|
||||
<span>🏹 20-Target Tournaments</span>
|
||||
<div class="section-controls">
|
||||
<button class="filter-btn active" onclick="filterTournaments('20', 'all')">All</button>
|
||||
<button class="filter-btn" onclick="filterTournaments('20', 'finished')">Finished</button>
|
||||
<button class="filter-btn" onclick="filterTournaments('20', 'recent')">Recent</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="archive-grid" id="tournaments-20-grid">
|
||||
{% for tournament in tournaments_20 %}
|
||||
<div class="archive-card tournament-20" data-status="{{ 'finished' if tournament.tournament_finished else 'incomplete' }}" data-date="{{ tournament.archived_at }}" data-targets="20" onclick="viewTournament('{{ tournament.filename }}')">
|
||||
<div class="archive-header">
|
||||
<div>
|
||||
<div class="archive-title">20-Target Tournament</div>
|
||||
<div class="archive-subtitle">{{ tournament.created_at[:10] if tournament.created_at != 'Unknown' else 'Unknown Date' }}</div>
|
||||
</div>
|
||||
<span class="archive-badge badge-20-targets">20 Targets</span>
|
||||
</div>
|
||||
<div class="archive-content">
|
||||
<div class="archive-info">
|
||||
<div class="info-item">
|
||||
<span class="info-icon">👥</span>
|
||||
<span class="info-value">{{ tournament.participants_count }} players</span>
|
||||
</div>
|
||||
<div class="info-item">
|
||||
<span class="info-icon">🎯</span>
|
||||
<span class="info-value">{{ tournament.tournament_type.replace('_', ' ')|title }}</span>
|
||||
</div>
|
||||
<div class="info-item">
|
||||
<span class="info-icon">📅</span>
|
||||
<span class="info-value">{{ tournament.archived_at[:10] if tournament.archived_at != 'Unknown' else 'Unknown Date' }}</span>
|
||||
</div>
|
||||
<div class="info-item">
|
||||
<span class="info-icon">🏁</span>
|
||||
<span class="info-value">{{ 'Finished' if tournament.tournament_finished else 'Incomplete' }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="archive-actions">
|
||||
<a href="/archive/tournament/{{ tournament.filename }}" class="action-btn view-btn">📊 View</a>
|
||||
<button class="action-btn edit-btn" onclick="event.stopPropagation(); editArchive('tournament', '{{ tournament.filename }}', {{ tournament|tojson }})">
|
||||
✏️ Edit
|
||||
</button>
|
||||
<button class="action-btn delete-btn" onclick="event.stopPropagation(); deleteArchive('tournament', '{{ tournament.filename }}')">
|
||||
🗑️
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<!-- 4-Target Tournaments -->
|
||||
{% set tournaments_4 = tournaments|selectattr('tournament_type', 'equalto', '4_targets')|list %}
|
||||
{% if tournaments_4 %}
|
||||
<div class="section">
|
||||
<div class="section-title">
|
||||
<span>🎪 4-Target Tournaments</span>
|
||||
<div class="section-controls">
|
||||
<button class="filter-btn active" onclick="filterTournaments('4', 'all')">All</button>
|
||||
<button class="filter-btn" onclick="filterTournaments('4', 'finished')">Finished</button>
|
||||
<button class="filter-btn" onclick="filterTournaments('4', 'recent')">Recent</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="archive-grid" id="tournaments-4-grid">
|
||||
{% for tournament in tournaments_4 %}
|
||||
<div class="archive-card tournament-4" data-status="{{ 'finished' if tournament.tournament_finished else 'incomplete' }}" data-date="{{ tournament.archived_at }}" data-targets="4" onclick="viewTournament('{{ tournament.filename }}')">
|
||||
<div class="archive-header">
|
||||
<div>
|
||||
<div class="archive-title">4-Target Tournament</div>
|
||||
<div class="archive-subtitle">{{ tournament.created_at[:10] if tournament.created_at != 'Unknown' else 'Unknown Date' }}</div>
|
||||
</div>
|
||||
<span class="archive-badge badge-4-targets">4 Targets</span>
|
||||
</div>
|
||||
<div class="archive-content">
|
||||
<div class="archive-info">
|
||||
<div class="info-item">
|
||||
<span class="info-icon">👥</span>
|
||||
<span class="info-value">{{ tournament.participants_count }} players</span>
|
||||
</div>
|
||||
<div class="info-item">
|
||||
<span class="info-icon">🎯</span>
|
||||
<span class="info-value">{{ tournament.tournament_type.replace('_', ' ')|title }}</span>
|
||||
</div>
|
||||
<div class="info-item">
|
||||
<span class="info-icon">📅</span>
|
||||
<span class="info-value">{{ tournament.archived_at[:10] if tournament.archived_at != 'Unknown' else 'Unknown Date' }}</span>
|
||||
</div>
|
||||
<div class="info-item">
|
||||
<span class="info-icon">🏁</span>
|
||||
<span class="info-value">{{ 'Finished' if tournament.tournament_finished else 'Incomplete' }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="archive-actions">
|
||||
<a href="/archive/tournament/{{ tournament.filename }}" class="action-btn view-btn">📊 View</a>
|
||||
<button class="action-btn edit-btn" onclick="event.stopPropagation(); editArchive('tournament', '{{ tournament.filename }}', {{ tournament|tojson }})">
|
||||
✏️ Edit
|
||||
</button>
|
||||
<button class="action-btn delete-btn" onclick="event.stopPropagation(); deleteArchive('tournament', '{{ tournament.filename }}')">
|
||||
🗑️
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<!-- Other/Unknown Target Count Tournaments -->
|
||||
{% set tournaments_other = tournaments|rejectattr('tournament_type', 'in', ['4_targets', '20_targets', '40_targets'])|list %}
|
||||
{% if tournaments_other %}
|
||||
<div class="section">
|
||||
<div class="section-title">
|
||||
<span>🏆 Other Tournaments</span>
|
||||
<div class="section-controls">
|
||||
<button class="filter-btn active" onclick="filterTournaments('other', 'all')">All</button>
|
||||
<button class="filter-btn" onclick="filterTournaments('other', 'finished')">Finished</button>
|
||||
<button class="filter-btn" onclick="filterTournaments('other', 'recent')">Recent</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="archive-grid" id="tournaments-other-grid">
|
||||
{% for tournament in tournaments_other %}
|
||||
<div class="archive-card tournament-other" data-status="{{ 'finished' if tournament.tournament_finished else 'incomplete' }}" data-date="{{ tournament.archived_at }}" data-targets="other" onclick="viewTournament('{{ tournament.filename }}')">
|
||||
<div class="archive-header">
|
||||
<div>
|
||||
<div class="archive-title">Tournament ({{ tournament.tournament_type or 'Unknown' }})</div>
|
||||
<div class="archive-subtitle">{{ tournament.created_at[:10] if tournament.created_at != 'Unknown' else 'Unknown Date' }}</div>
|
||||
</div>
|
||||
<span class="archive-badge badge-tournament">Tournament</span>
|
||||
@@ -589,9 +946,12 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="archive-actions">
|
||||
<a href="/archive/tournament/{{ tournament.filename }}" class="view-btn">📊 View Results</a>
|
||||
<button class="delete-btn" onclick="event.stopPropagation(); deleteArchive('tournament', '{{ tournament.filename }}')">
|
||||
🗑️ Delete
|
||||
<a href="/archive/tournament/{{ tournament.filename }}" class="action-btn view-btn">📊 View</a>
|
||||
<button class="action-btn edit-btn" onclick="event.stopPropagation(); editArchive('tournament', '{{ tournament.filename }}', {{ tournament|tojson }})">
|
||||
✏️ Edit
|
||||
</button>
|
||||
<button class="action-btn delete-btn" onclick="event.stopPropagation(); deleteArchive('tournament', '{{ tournament.filename }}')">
|
||||
🗑️
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -600,6 +960,8 @@
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% endif %}
|
||||
|
||||
<!-- Empty State -->
|
||||
{% if not leagues and not tournaments %}
|
||||
@@ -616,7 +978,7 @@
|
||||
|
||||
<!-- Confirmation Modal -->
|
||||
<div class="modal-overlay" id="confirmationModal">
|
||||
<div class="confirmation-modal">
|
||||
<div class="modal">
|
||||
<div class="modal-title" id="modalTitle">Confirm Action</div>
|
||||
<div class="modal-message" id="modalMessage">Are you sure you want to proceed?</div>
|
||||
<div class="modal-buttons">
|
||||
@@ -626,8 +988,48 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Edit Modal -->
|
||||
<div class="modal-overlay" id="editModal">
|
||||
<div class="modal">
|
||||
<div class="modal-title" id="editModalTitle">Edit Archive</div>
|
||||
<form class="edit-form" id="editForm">
|
||||
<div class="form-group">
|
||||
<label class="form-label">Archive Name</label>
|
||||
<input type="text" class="form-input" id="editName" placeholder="Enter archive name">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="form-label">Format Type</label>
|
||||
<select class="form-select" id="editType">
|
||||
<option value="single_elimination">Single Elimination</option>
|
||||
<option value="double_elimination">Double Elimination</option>
|
||||
<option value="round_robin">Round Robin</option>
|
||||
<option value="swiss">Swiss System</option>
|
||||
<option value="league">League Championship</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group" id="targetCountGroup">
|
||||
<label class="form-label">Target Format</label>
|
||||
<select class="form-select" id="editTargetCount">
|
||||
<option value="4_targets">4 Targets (5 shots each)</option>
|
||||
<option value="20_targets">20 Targets (2 shots each)</option>
|
||||
<option value="40_targets">40 Targets (2 shots each)</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="form-label">Notes</label>
|
||||
<input type="text" class="form-input" id="editNotes" placeholder="Add notes about this tournament">
|
||||
</div>
|
||||
</form>
|
||||
<div class="modal-buttons">
|
||||
<button class="modal-btn cancel" onclick="closeEditModal()">Cancel</button>
|
||||
<button class="modal-btn primary" onclick="saveEdit()">Save Changes</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
let pendingAction = null;
|
||||
let editingItem = null;
|
||||
|
||||
// Navigation functions
|
||||
function viewTournament(filename) {
|
||||
@@ -638,6 +1040,7 @@
|
||||
window.location.href = `/archive/league/${filename}`;
|
||||
}
|
||||
|
||||
// Delete function
|
||||
async function deleteArchive(type, filename) {
|
||||
showModal(
|
||||
'Delete Archive',
|
||||
@@ -664,6 +1067,114 @@
|
||||
);
|
||||
}
|
||||
|
||||
// Edit function
|
||||
function editArchive(type, filename, data) {
|
||||
editingItem = { type, filename, data };
|
||||
|
||||
document.getElementById('editModalTitle').textContent = `Edit ${type.charAt(0).toUpperCase() + type.slice(1)}`;
|
||||
document.getElementById('editName').value = data.name || `${type} - ${data.created_at?.substring(0, 10) || 'Unknown'}`;
|
||||
|
||||
// For format type, use a default since this isn't typically stored
|
||||
document.getElementById('editType').value = type === 'league' ? 'league' : 'single_elimination';
|
||||
document.getElementById('editNotes').value = data.notes || '';
|
||||
|
||||
// Show/hide target count field - both tournaments and leagues have tournament_type
|
||||
const targetCountGroup = document.getElementById('targetCountGroup');
|
||||
if (type === 'tournament' || type === 'league') {
|
||||
targetCountGroup.style.display = 'flex';
|
||||
document.getElementById('editTargetCount').value = data.tournament_type || '20_targets';
|
||||
} else {
|
||||
targetCountGroup.style.display = 'none';
|
||||
}
|
||||
|
||||
document.getElementById('editModal').classList.add('active');
|
||||
}
|
||||
|
||||
// Save edit function
|
||||
async function saveEdit() {
|
||||
if (!editingItem) return;
|
||||
|
||||
const updatedData = {
|
||||
name: document.getElementById('editName').value,
|
||||
notes: document.getElementById('editNotes').value
|
||||
};
|
||||
|
||||
// For both tournaments and leagues, save the tournament_type (target format)
|
||||
if (editingItem.type === 'tournament' || editingItem.type === 'league') {
|
||||
updatedData.tournament_type = document.getElementById('editTargetCount').value;
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await fetch(`/api/archive/update/${editingItem.type}/${editingItem.filename}`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify(updatedData)
|
||||
});
|
||||
|
||||
const result = await response.json();
|
||||
|
||||
if (result.status === 'success') {
|
||||
alert('Archive updated successfully');
|
||||
location.reload();
|
||||
} else {
|
||||
alert('Error updating archive: ' + result.message);
|
||||
}
|
||||
} catch (error) {
|
||||
alert('Error updating archive: ' + error.message);
|
||||
}
|
||||
|
||||
closeEditModal();
|
||||
}
|
||||
|
||||
// Filtering functions
|
||||
function filterLeagues(filter) {
|
||||
const cards = document.querySelectorAll('#leagues-grid .archive-card');
|
||||
const buttons = document.querySelectorAll('#leagues-grid').parentElement.querySelectorAll('.filter-btn');
|
||||
|
||||
// Update active button
|
||||
buttons.forEach(btn => btn.classList.remove('active'));
|
||||
event.target.classList.add('active');
|
||||
|
||||
// Filter cards
|
||||
cards.forEach(card => {
|
||||
const isCompleted = card.dataset.status === 'completed';
|
||||
const date = new Date(card.dataset.date);
|
||||
const isRecent = (Date.now() - date.getTime()) < (30 * 24 * 60 * 60 * 1000); // Last 30 days
|
||||
|
||||
let show = true;
|
||||
if (filter === 'completed' && !isCompleted) show = false;
|
||||
if (filter === 'recent' && !isRecent) show = false;
|
||||
|
||||
card.classList.toggle('hidden', !show);
|
||||
});
|
||||
}
|
||||
|
||||
function filterTournaments(targetCount, filter) {
|
||||
const gridId = targetCount === 'other' ? 'tournaments-other-grid' : `tournaments-${targetCount}-grid`;
|
||||
const cards = document.querySelectorAll(`#${gridId} .archive-card`);
|
||||
const section = document.querySelector(`#${gridId}`).closest('.section');
|
||||
const buttons = section.querySelectorAll('.filter-btn');
|
||||
|
||||
// Update active button
|
||||
buttons.forEach(btn => btn.classList.remove('active'));
|
||||
event.target.classList.add('active');
|
||||
|
||||
// Filter cards
|
||||
cards.forEach(card => {
|
||||
const isFinished = card.dataset.status === 'finished';
|
||||
const date = new Date(card.dataset.date);
|
||||
const isRecent = (Date.now() - date.getTime()) < (30 * 24 * 60 * 60 * 1000); // Last 30 days
|
||||
|
||||
let show = true;
|
||||
if (filter === 'finished' && !isFinished) show = false;
|
||||
if (filter === 'recent' && !isRecent) show = false;
|
||||
|
||||
card.classList.toggle('hidden', !show);
|
||||
});
|
||||
}
|
||||
|
||||
// Modal functions
|
||||
function showModal(title, message, confirmCallback) {
|
||||
document.getElementById('modalTitle').textContent = title;
|
||||
@@ -677,6 +1188,11 @@
|
||||
pendingAction = null;
|
||||
}
|
||||
|
||||
function closeEditModal() {
|
||||
document.getElementById('editModal').classList.remove('active');
|
||||
editingItem = null;
|
||||
}
|
||||
|
||||
function confirmAction() {
|
||||
if (pendingAction) {
|
||||
pendingAction();
|
||||
@@ -690,11 +1206,42 @@
|
||||
}
|
||||
});
|
||||
|
||||
document.getElementById('editModal').addEventListener('click', function(e) {
|
||||
if (e.target === this) {
|
||||
closeEditModal();
|
||||
}
|
||||
});
|
||||
|
||||
// Initialize page
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
console.log('📚 Archive loaded');
|
||||
console.log('🏆 Tournaments:', {{ tournaments|length if tournaments else 0 }});
|
||||
console.log('📚 Enhanced Archive loaded');
|
||||
console.log('🏆 Total Tournaments:', {{ tournaments|length if tournaments else 0 }});
|
||||
console.log('🎖️ Leagues:', {{ leagues|length if leagues else 0 }});
|
||||
|
||||
{% if tournaments %}
|
||||
const tournaments = {{ tournaments|tojson }};
|
||||
console.log('Tournament data sample:', tournaments[0] || 'No tournaments');
|
||||
|
||||
// Count tournaments by type
|
||||
const tournaments40 = tournaments.filter(t => t.tournament_type === '40_targets');
|
||||
const tournaments20 = tournaments.filter(t => t.tournament_type === '20_targets');
|
||||
const tournaments4 = tournaments.filter(t => t.tournament_type === '4_targets');
|
||||
const tournamentsOther = tournaments.filter(t => !['4_targets', '20_targets', '40_targets'].includes(t.tournament_type));
|
||||
|
||||
console.log('🎯 40-Target Tournaments:', tournaments40.length);
|
||||
console.log('🏹 20-Target Tournaments:', tournaments20.length);
|
||||
console.log('🎪 4-Target Tournaments:', tournaments4.length);
|
||||
console.log('🏆 Other Tournaments:', tournamentsOther.length);
|
||||
|
||||
// Log tournament types for debugging
|
||||
const tournamentTypes = [...new Set(tournaments.map(t => t.tournament_type))];
|
||||
console.log('Available tournament types:', tournamentTypes);
|
||||
{% else %}
|
||||
console.log('🎯 40-Target Tournaments: 0');
|
||||
console.log('🏹 20-Target Tournaments: 0');
|
||||
console.log('🎪 4-Target Tournaments: 0');
|
||||
console.log('🏆 Other Tournaments: 0');
|
||||
{% endif %}
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
|
||||
Reference in New Issue
Block a user