fix probleme avec dispos
This commit is contained in:
@@ -197,7 +197,6 @@ function goToTeamMatch() {
|
||||
}
|
||||
|
||||
function goToCreateTryout() {
|
||||
// Tryout creation doesn't support pre-filling date easily, just navigate
|
||||
window.location.href = '/tryouts/create';
|
||||
}
|
||||
|
||||
@@ -208,8 +207,13 @@ function fetchTryoutOptions() {
|
||||
.then(function(data) {
|
||||
var sel = document.getElementById('createTryoutSelect');
|
||||
sel.innerHTML = '<option value="">-- Select a tryout --</option>';
|
||||
var today = new Date().toISOString().split('T')[0];
|
||||
data.forEach(function(t) {
|
||||
sel.innerHTML += '<option value="' + t.id + '">' + t.title + ' (' + t.date + ')</option>';
|
||||
// Only show tryouts that haven't ended
|
||||
var tryoutEndDate = t.end_date || t.date;
|
||||
if (tryoutEndDate >= today) {
|
||||
sel.innerHTML += '<option value="' + t.id + '">' + t.title + ' (' + t.date + ')</option>';
|
||||
}
|
||||
});
|
||||
})
|
||||
.catch(function() {});
|
||||
@@ -236,8 +240,8 @@ function showEventModal(event) {
|
||||
|
||||
var content = '<div class="detail-grid">';
|
||||
content += '<div class="detail-item"><span class="detail-label">Type</span><span class="detail-value">';
|
||||
content += '<span class="badge badge-' + (type === 'tryout' ? 'info' : (props.match_type === 'team_vs_team' || props.match_type === 'player_vs_player' ? 'success' : 'warning')) + '">';
|
||||
content += (type === 'tryout' ? 'Tryout' : (props.match_type === 'team_vs_team' ? 'Team Match' : (props.match_type === 'player_vs_player' ? 'Player Match' : 'Player Scrim'))) + '</span>';
|
||||
content += '<span class="badge badge-' + (props.match_type === 'team_vs_team' || props.match_type === 'player_vs_player' ? 'success' : 'warning') + '">';
|
||||
content += (props.match_type === 'team_vs_team' ? 'Team Match' : (props.match_type === 'player_vs_player' ? 'Player Match' : 'Player Scrim')) + '</span>';
|
||||
content += '</span></div>';
|
||||
content += '<div class="detail-item"><span class="detail-label">Title</span><span class="detail-value">' + title + '</span></div>';
|
||||
content += '<div class="detail-item"><span class="detail-label">Date</span><span class="detail-value">' + date + '</span></div>';
|
||||
@@ -250,7 +254,6 @@ function showEventModal(event) {
|
||||
if (type === 'match' && props.participants) {
|
||||
content += '<div class="detail-item full-width"><span class="detail-label">Teams</span><span class="detail-value">';
|
||||
if (props.match_type === 'team_vs_team') {
|
||||
// For team vs team, participants is "Team1 vs Team2"
|
||||
var teams = props.participants.split(' vs ');
|
||||
if (teams.length >= 2) {
|
||||
content += '<div class="match-teams">';
|
||||
@@ -262,8 +265,6 @@ function showEventModal(event) {
|
||||
content += props.participants;
|
||||
}
|
||||
} else if (props.match_type === 'player_vs_player') {
|
||||
// For player vs player, we need to parse the participants
|
||||
// The format is "player1, player2 vs player3, player4"
|
||||
var parts = props.participants.split(' vs ');
|
||||
if (parts.length >= 2) {
|
||||
content += '<div class="match-teams">';
|
||||
@@ -275,7 +276,6 @@ function showEventModal(event) {
|
||||
content += props.participants;
|
||||
}
|
||||
} else {
|
||||
// For player scrim, just show the list
|
||||
content += props.participants;
|
||||
}
|
||||
content += '</span></div>';
|
||||
@@ -286,7 +286,7 @@ function showEventModal(event) {
|
||||
}
|
||||
content += '</div>';
|
||||
|
||||
document.getElementById('modalTitle').textContent = type === 'tryout' ? 'Tryout Details' : 'Match Details';
|
||||
document.getElementById('modalTitle').textContent = 'Match Details';
|
||||
document.getElementById('modalContent').innerHTML = content;
|
||||
|
||||
// Reset buttons
|
||||
@@ -301,11 +301,11 @@ function showEventModal(event) {
|
||||
document.getElementById('editMatchBtn').onclick = function() {
|
||||
window.location.href = '/matches/' + props.match_id + '/edit';
|
||||
};
|
||||
} else if (type === 'tryout' && canScheduleMatches) {
|
||||
document.getElementById('modalActions').style.display = 'flex';
|
||||
document.getElementById('viewTryoutBtn').style.display = 'inline-flex';
|
||||
document.getElementById('viewTryoutBtn').onclick = function() {
|
||||
window.location.href = '/tryouts/' + props.tryout_id;
|
||||
document.getElementById('deleteMatchBtn').style.display = 'inline-flex';
|
||||
document.getElementById('deleteMatchBtn').onclick = function() {
|
||||
if (confirm('Are you sure you want to delete this match?')) {
|
||||
deleteCalendarMatch(props.match_id);
|
||||
}
|
||||
};
|
||||
} else {
|
||||
document.getElementById('modalActions').style.display = 'none';
|
||||
@@ -329,6 +329,27 @@ function showEventModal(event) {
|
||||
document.getElementById('eventModal').classList.remove('hidden');
|
||||
}
|
||||
|
||||
function deleteCalendarMatch(matchId) {
|
||||
fetch('/matches/' + matchId + '/delete', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'X-CSRFToken': '{{ csrf_token() }}',
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
})
|
||||
.then(function(r) { return r.json().catch(function() { return {}; }); })
|
||||
.then(function() {
|
||||
hideEventModal();
|
||||
if (window.fcCalendar) {
|
||||
window.fcCalendar.refetchEvents();
|
||||
}
|
||||
})
|
||||
.catch(function(err) {
|
||||
console.error('Error deleting match:', err);
|
||||
alert('Failed to delete match.');
|
||||
});
|
||||
}
|
||||
|
||||
function toggleCalendarPresence(matchId, participantId, btn) {
|
||||
fetch('/matches/' + matchId + '/toggle-presence/' + participantId, {
|
||||
method: 'POST',
|
||||
|
||||
Reference in New Issue
Block a user