Manager ne pouvait pas voir les tryouts.
probleme avec discord bot
This commit is contained in:
cedrick2711
2026-08-06 14:46:51 -04:00
parent 68e3da6601
commit fcf10bcdff
13 changed files with 279 additions and 117 deletions
+93 -31
View File
@@ -280,6 +280,22 @@ for (let h = 8; h <= 22; h++) {
const COACH_DAYS = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'];
let coachSelectedSlots = {};
// Drag state for coach grid
let coachDragMode = false;
let coachDragAction = null;
function applyCoachSlotAction(dayOfWeek, timeStr, element) {
if (!coachSelectedSlots[dayOfWeek]) coachSelectedSlots[dayOfWeek] = [];
const index = coachSelectedSlots[dayOfWeek].indexOf(timeStr);
if (coachDragAction === 'select' && index === -1) {
coachSelectedSlots[dayOfWeek].push(timeStr);
element.classList.add('selected');
} else if (coachDragAction === 'deselect' && index > -1) {
coachSelectedSlots[dayOfWeek].splice(index, 1);
element.classList.remove('selected');
}
}
function loadCoachAvailability() {
{% for av in existing_availability %}
if (!coachSelectedSlots[{{ av.day_of_week }}]) coachSelectedSlots[{{ av.day_of_week }}] = [];
@@ -296,25 +312,40 @@ function renderCoachGrid() {
COACH_TIME_SLOTS.forEach(slot => {
const isSelected = coachSelectedSlots[dayIndex] && coachSelectedSlots[dayIndex].includes(slot.time);
const cssClass = isSelected ? 'time-slot selected' : 'time-slot';
html += '<div class="' + cssClass + '" data-day="' + dayIndex + '" data-time="' + slot.time + '" onclick="toggleCoachSlot(' + dayIndex + ', \'' + slot.time + '\', this)">' + slot.display + '</div>';
html += '<div class="' + cssClass + '" data-day="' + dayIndex + '" data-time="' + slot.time + '">' + slot.display + '</div>';
});
html += '</div>';
});
grid.innerHTML = html;
}
function toggleCoachSlot(dayOfWeek, timeStr, element) {
if (!coachSelectedSlots[dayOfWeek]) coachSelectedSlots[dayOfWeek] = [];
const index = coachSelectedSlots[dayOfWeek].indexOf(timeStr);
if (index === -1) {
coachSelectedSlots[dayOfWeek].push(timeStr);
element.classList.add('selected');
} else {
coachSelectedSlots[dayOfWeek].splice(index, 1);
element.classList.remove('selected');
}
clearTimeout(window._coachSaveTimeout);
window._coachSaveTimeout = setTimeout(saveCoachAvailability, 1000);
// Drag event listeners
grid.addEventListener('mousedown', function(e) {
const slot = e.target.closest('.time-slot');
if (!slot) return;
e.preventDefault();
coachDragMode = true;
const day = parseInt(slot.dataset.day);
const time = slot.dataset.time;
if (!coachSelectedSlots[day]) coachSelectedSlots[day] = [];
const isSelected = coachSelectedSlots[day].indexOf(time) > -1;
coachDragAction = isSelected ? 'deselect' : 'select';
applyCoachSlotAction(day, time, slot);
});
grid.addEventListener('mousemove', function(e) {
if (!coachDragMode) return;
const slot = e.target.closest('.time-slot');
if (!slot) return;
applyCoachSlotAction(parseInt(slot.dataset.day), slot.dataset.time, slot);
});
document.addEventListener('mouseup', function() {
if (coachDragMode) {
coachDragMode = false;
coachDragAction = null;
saveCoachAvailability();
}
});
}
function saveCoachAvailability() {
@@ -400,9 +431,27 @@ var DAYS = [
// Store selected slots: {day: [time, time, ...]}
var selectedSlots = {};
// Drag state
var dispDragMode = false;
var dispDragAction = null; // 'select' or 'deselect'
function applySlotAction(block, action) {
var day = parseInt(block.dataset.day);
var time = block.dataset.time;
if (!selectedSlots[day]) selectedSlots[day] = [];
var index = selectedSlots[day].indexOf(time);
if (action === 'select' && index === -1) {
selectedSlots[day].push(time);
block.classList.add('selected');
} else if (action === 'deselect' && index > -1) {
selectedSlots[day].splice(index, 1);
block.classList.remove('selected');
}
}
function renderDisponibilityGrid() {
var grid = document.getElementById('disponibilities-grid');
grid.innerHTML = '<div style="margin-bottom: 10px;"><strong>Click time blocks to select your available hours</strong></div>';
grid.innerHTML = '<div style="margin-bottom: 10px;"><strong>Click or click-and-drag to select your available hours</strong></div>';
var container = document.createElement('div');
container.className = 'disponibility-grid';
@@ -425,9 +474,6 @@ function renderDisponibilityGrid() {
block.dataset.day = day.value;
block.dataset.time = slot.time;
block.textContent = slot.display;
block.onclick = function() {
toggleSlot(day.value, slot.time, block);
};
timeBlocks.appendChild(block);
});
@@ -435,23 +481,39 @@ function renderDisponibilityGrid() {
container.appendChild(dayRow);
});
// Drag event listeners on the container
container.addEventListener('mousedown', function(e) {
var block = e.target.closest('.disponibility-time-block');
if (!block) return;
e.preventDefault();
dispDragMode = true;
var day = parseInt(block.dataset.day);
var time = block.dataset.time;
if (!selectedSlots[day]) selectedSlots[day] = [];
var isSelected = selectedSlots[day].indexOf(time) > -1;
dispDragAction = isSelected ? 'deselect' : 'select';
applySlotAction(block, dispDragAction);
});
container.addEventListener('mousemove', function(e) {
if (!dispDragMode) return;
var block = e.target.closest('.disponibility-time-block');
if (!block) return;
applySlotAction(block, dispDragAction);
});
document.addEventListener('mouseup', function() {
if (dispDragMode) {
dispDragMode = false;
dispDragAction = null;
saveDisponibilities();
}
});
grid.appendChild(container);
loadMyDisponibilities();
}
function toggleSlot(day, time, element) {
if (!selectedSlots[day]) selectedSlots[day] = [];
var index = selectedSlots[day].indexOf(time);
if (index > -1) {
selectedSlots[day].splice(index, 1);
element.classList.remove('selected');
} else {
selectedSlots[day].push(time);
element.classList.add('selected');
}
}
function loadMyDisponibilities() {
fetch('{{ url_for("users.get_my_disponibilities") }}')
.then(function(response) { return response.json(); })
+15 -7
View File
@@ -80,15 +80,23 @@
</div>
<div class="form-row">
<div class="form-group col-12">
<label for="coach_id">Assigned Coach</label>
<select id="coach_id" name="coach_id" class="form-select">
<option value="">-- No coach assigned --</option>
<label>Assigned Coaches</label>
<div class="checkbox-grid">
{% for coach in coaches %}
<option value="{{ coach.id }}" {% if tryout and tryout.coach_id == coach.id %}selected{% endif %}>
{{ coach.username }}
</option>
{% set is_checked = false %}
{% if tryout %}
{% for c in tryout.coaches %}
{% if c.id == coach.id %}{% set is_checked = true %}{% endif %}
{% endfor %}
{% if tryout.coach_id == coach.id %}{% set is_checked = true %}{% endif %}
{% endif %}
<label class="checkbox-label">
<input type="checkbox" name="coach_ids" value="{{ coach.id }}" {% if is_checked %}checked{% endif %}>
<span>{{ coach.username }}</span>
</label>
{% endfor %}
</select>
</div>
<small class="text-muted">Select one or more coaches for this tryout.</small>
</div>
</div>
<div class="form-group">
+1 -1
View File
@@ -31,7 +31,7 @@
<td>
<div class="user-mini">
<div class="avatar-sm">{{ u.username[:2] | upper }}</div>
<span>{{ u.username }}</span>
<a href="{{ url_for('users.view_user', user_id=u.id) }}">{{ u.username }}</a>
</div>
</td>
<td>{{ u.username }}</td>
+10 -2
View File
@@ -74,8 +74,16 @@
<span class="detail-value">{{ tryout.manager.username if tryout.manager else 'Not assigned' }}</span>
</div>
<div class="detail-item">
<span class="detail-label">Coach</span>
<span class="detail-value">{{ tryout.coach.username if tryout.coach else 'Not assigned' }}</span>
<span class="detail-label">Coaches</span>
<span class="detail-value">
{% if tryout.coaches %}
{{ tryout.coaches | map(attribute='username') | join(', ') }}
{% elif tryout.coach %}
{{ tryout.coach.username }}
{% else %}
Not assigned
{% endif %}
</span>
</div>
<div class="detail-item">
<span class="detail-label">Registered Players</span>
+10
View File
@@ -34,6 +34,16 @@
<span class="detail-value">{{ profile_user.discord_username }}</span>
</div>
{% endif %}
{% if profile_user.league_os_profile %}
<div class="detail-item">
<span class="detail-label"><i class="fas fa-link"></i> League OS</span>
<span class="detail-value">
<a href="{{ profile_user.league_os_profile }}" target="_blank" rel="noopener noreferrer" class="trn-link">
<i class="fas fa-external-link-alt"></i> {{ profile_user.league_os_profile }}
</a>
</span>
</div>
{% endif %}
</div>
{% set gamertags = profile_user.gamertags %}