ajout de match régulier pour les équipes et de pratiques
Ajout d'un profil public cliquable pour les utilisateurs déplacement du profil
This commit is contained in:
@@ -29,6 +29,61 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Create Event Modal (for clicking empty days) -->
|
||||
<div id="createEventModal" class="modal hidden">
|
||||
<div class="modal-backdrop" onclick="hideCreateEventModal()"></div>
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h3><i class="fas fa-plus-circle"></i> Create New Event</h3>
|
||||
<button class="modal-close" onclick="hideCreateEventModal()">×</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<p class="mb-3"><strong>Date:</strong> <span id="createEventDate"></span></p>
|
||||
<input type="hidden" id="createEventDateInput"/>
|
||||
|
||||
<div class="card mb-3">
|
||||
<div class="card-body">
|
||||
<h5><i class="fas fa-futbol"></i> Schedule Tryout Match</h5>
|
||||
<p class="text-muted small">Add a scrim/match inside an existing tryout</p>
|
||||
<div class="form-inline">
|
||||
<select id="createTryoutSelect" class="form-select" style="flex:1;">
|
||||
<option value="">-- Select a tryout --</option>
|
||||
</select>
|
||||
<button class="btn btn-sm btn-primary ml-2" onclick="goToTryoutMatch()">
|
||||
<i class="fas fa-arrow-right"></i> Go
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card mb-3">
|
||||
<div class="card-body">
|
||||
<h5><i class="fas fa-users"></i> Schedule Team Match</h5>
|
||||
<p class="text-muted small">Regular season match for an org team</p>
|
||||
<div class="form-inline">
|
||||
<select id="createTeamSelect" class="form-select" style="flex:1;">
|
||||
<option value="">-- Select a team --</option>
|
||||
</select>
|
||||
<button class="btn btn-sm btn-success ml-2" onclick="goToTeamMatch()">
|
||||
<i class="fas fa-arrow-right"></i> Go
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<h5><i class="fas fa-calendar-plus"></i> Create New Tryout</h5>
|
||||
<p class="text-muted small">Create a brand new tryout event</p>
|
||||
<button class="btn btn-sm btn-info" onclick="goToCreateTryout()">
|
||||
<i class="fas fa-plus"></i> Create Tryout
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Event Details Modal -->
|
||||
<div id="eventModal" class="modal hidden">
|
||||
<div class="modal-backdrop" onclick="hideEventModal()"></div>
|
||||
@@ -39,6 +94,9 @@
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div id="modalContent"></div>
|
||||
<div id="modalPresenceToggle" class="form-actions mt-3" style="display: none; justify-content: center;">
|
||||
<button class="btn btn-sm btn-outline" id="calPresenceBtn">Confirm</button>
|
||||
</div>
|
||||
<div id="modalActions" class="form-actions mt-3" style="display: none;">
|
||||
<button class="btn btn-sm btn-danger" id="deleteMatchBtn" style="display: none;">
|
||||
<i class="fas fa-trash"></i> Delete Match
|
||||
@@ -74,13 +132,32 @@ document.addEventListener('DOMContentLoaded', function() {
|
||||
eventClick: function(info) {
|
||||
showEventModal(info.event);
|
||||
},
|
||||
dateClick: function(info) {
|
||||
if (canScheduleMatches) {
|
||||
var dateStr = info.dateStr;
|
||||
showCreateEventModal(dateStr);
|
||||
}
|
||||
},
|
||||
selectable: true,
|
||||
select: function(info) {
|
||||
if (canScheduleMatches) {
|
||||
var dateStr = info.startStr;
|
||||
showCreateEventModal(dateStr);
|
||||
calendar.unselect();
|
||||
}
|
||||
},
|
||||
slotMinTime: '12:00:00',
|
||||
slotMaxTime: '24:00:00'
|
||||
});
|
||||
calendar.render();
|
||||
|
||||
// Store calendar in window for access
|
||||
window.fcCalendar = calendar;
|
||||
|
||||
// Pre-load tryout and team options for the create modal
|
||||
if (canScheduleMatches) {
|
||||
fetchTryoutOptions();
|
||||
fetchTeamOptions();
|
||||
}
|
||||
});
|
||||
|
||||
function changeView(viewName) {
|
||||
@@ -89,6 +166,68 @@ function changeView(viewName) {
|
||||
}
|
||||
}
|
||||
|
||||
// --- Create Event Modal ---
|
||||
function showCreateEventModal(dateStr) {
|
||||
document.getElementById('createEventDate').textContent = dateStr;
|
||||
document.getElementById('createEventDateInput').value = dateStr;
|
||||
|
||||
// Reset dropdowns
|
||||
document.getElementById('createTryoutSelect').value = '';
|
||||
document.getElementById('createTeamSelect').value = '';
|
||||
|
||||
document.getElementById('createEventModal').classList.remove('hidden');
|
||||
}
|
||||
|
||||
function hideCreateEventModal() {
|
||||
document.getElementById('createEventModal').classList.add('hidden');
|
||||
}
|
||||
|
||||
function goToTryoutMatch() {
|
||||
var tryoutId = document.getElementById('createTryoutSelect').value;
|
||||
if (!tryoutId) { alert('Please select a tryout.'); return; }
|
||||
var date = document.getElementById('createEventDateInput').value;
|
||||
window.location.href = '/matches/create/' + tryoutId + '?date=' + date;
|
||||
}
|
||||
|
||||
function goToTeamMatch() {
|
||||
var teamId = document.getElementById('createTeamSelect').value;
|
||||
if (!teamId) { alert('Please select a team.'); return; }
|
||||
var date = document.getElementById('createEventDateInput').value;
|
||||
window.location.href = '/team-matches/' + teamId + '/create?date=' + date;
|
||||
}
|
||||
|
||||
function goToCreateTryout() {
|
||||
// Tryout creation doesn't support pre-filling date easily, just navigate
|
||||
window.location.href = '/tryouts/create';
|
||||
}
|
||||
|
||||
// Pre-fetch data for dropdowns
|
||||
function fetchTryoutOptions() {
|
||||
fetch('/matches/api/manageable-tryouts')
|
||||
.then(function(r) { return r.json(); })
|
||||
.then(function(data) {
|
||||
var sel = document.getElementById('createTryoutSelect');
|
||||
sel.innerHTML = '<option value="">-- Select a tryout --</option>';
|
||||
data.forEach(function(t) {
|
||||
sel.innerHTML += '<option value="' + t.id + '">' + t.title + ' (' + t.date + ')</option>';
|
||||
});
|
||||
})
|
||||
.catch(function() {});
|
||||
}
|
||||
|
||||
function fetchTeamOptions() {
|
||||
fetch('/team-matches/api/manageable-teams')
|
||||
.then(function(r) { return r.json(); })
|
||||
.then(function(data) {
|
||||
var sel = document.getElementById('createTeamSelect');
|
||||
sel.innerHTML = '<option value="">-- Select a team --</option>';
|
||||
data.forEach(function(t) {
|
||||
sel.innerHTML += '<option value="' + t.id + '">' + t.name + '</option>';
|
||||
});
|
||||
})
|
||||
.catch(function() {});
|
||||
}
|
||||
|
||||
function showEventModal(event) {
|
||||
var props = event.extendedProps;
|
||||
var title = event.title;
|
||||
@@ -172,9 +311,49 @@ function showEventModal(event) {
|
||||
document.getElementById('modalActions').style.display = 'none';
|
||||
}
|
||||
|
||||
// Show presence toggle for matches where user is a participant
|
||||
var presenceDiv = document.getElementById('modalPresenceToggle');
|
||||
if (type === 'match' && props.user_participant_id) {
|
||||
presenceDiv.style.display = 'flex';
|
||||
var confirmed = props.user_attendance_confirmed || false;
|
||||
var toggleBtn = document.getElementById('calPresenceBtn');
|
||||
toggleBtn.textContent = confirmed ? '✅ Confirmed' : 'Confirm';
|
||||
toggleBtn.className = 'btn btn-sm ' + (confirmed ? 'btn-success' : 'btn-outline');
|
||||
toggleBtn.onclick = function() {
|
||||
toggleCalendarPresence(props.match_id, props.user_participant_id, toggleBtn);
|
||||
};
|
||||
} else {
|
||||
presenceDiv.style.display = 'none';
|
||||
}
|
||||
|
||||
document.getElementById('eventModal').classList.remove('hidden');
|
||||
}
|
||||
|
||||
function toggleCalendarPresence(matchId, participantId, btn) {
|
||||
fetch('/matches/' + matchId + '/toggle-presence/' + participantId, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'X-CSRFToken': '{{ csrf_token() }}',
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
})
|
||||
.then(function(r) { return r.json(); })
|
||||
.then(function(data) {
|
||||
if (data.attendance_confirmed) {
|
||||
btn.classList.add('btn-success');
|
||||
btn.classList.remove('btn-outline');
|
||||
btn.textContent = '✅ Confirmed';
|
||||
} else {
|
||||
btn.classList.remove('btn-success');
|
||||
btn.classList.add('btn-outline');
|
||||
btn.textContent = 'Confirm';
|
||||
}
|
||||
})
|
||||
.catch(function(err) {
|
||||
console.error('Error toggling presence:', err);
|
||||
});
|
||||
}
|
||||
|
||||
function hideEventModal() {
|
||||
document.getElementById('eventModal').classList.add('hidden');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user