Correction des présences et correction de plusieurs erreurs mineur de déplacement/parcours de l'utilisateur, harmonisation des processus
This commit is contained in:
+70
-47
@@ -124,36 +124,10 @@
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% if can_manage %}
|
||||
<div class="staff-add-forms">
|
||||
<form method="POST" action="{{ url_for('teams.add_coach', team_id=team.id) }}" class="inline-form">
|
||||
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}"/>
|
||||
<select name="coach_id" class="form-select form-select-sm" onchange="if(this.value) this.form.submit()">
|
||||
<option value="">+ Add Coach</option>
|
||||
{% for c in coaches %}
|
||||
{% if c.id not in (team_coaches | map(attribute='id') | list) %}
|
||||
<option value="{{ c.id }}">{{ c.username }}</option>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</select>
|
||||
</form>
|
||||
<form method="POST" action="{{ url_for('teams.add_manager', team_id=team.id) }}" class="inline-form">
|
||||
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}"/>
|
||||
<select name="manager_id" class="form-select form-select-sm" onchange="if(this.value) this.form.submit()">
|
||||
<option value="">+ Add Manager</option>
|
||||
{% for m in managers %}
|
||||
{% if m.id not in (team_managers | map(attribute='id') | list) %}
|
||||
<option value="{{ m.id }}">{{ m.username }}</option>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</select>
|
||||
</form>
|
||||
</div>
|
||||
{% endif %}
|
||||
<a href="{{ url_for('team_matches.list_matches') }}?team_id={{ team.id }}" class="btn btn-sm btn-outline" title="View Team Matches">
|
||||
<i class="fas fa-futbol"></i> Matches
|
||||
</a>
|
||||
{% if current_user.can_schedule_matches() and (current_user.role in ['president', 'manager'] or (current_user.role == 'coach' and team.coaches.filter_by(id=current_user.id).first()) or (current_user.role == 'coach' and team.coach_id == current_user.id)) %}
|
||||
{% if current_user.can_schedule_matches() and (current_user.role in ['admin', 'manager'] or (current_user.role == 'coach' and team.coaches.filter_by(id=current_user.id).first()) or (current_user.role == 'coach' and team.coach_id == current_user.id)) %}
|
||||
<a href="{{ url_for('team_matches.create_match', team_id=team.id) }}" class="btn btn-sm btn-success" title="Schedule Team Match">
|
||||
<i class="fas fa-plus"></i> Match
|
||||
</a>
|
||||
@@ -286,28 +260,37 @@
|
||||
<div class="modal-body">
|
||||
<form id="editTeamForm" method="POST" action="" class="form">
|
||||
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}"/>
|
||||
<input type="hidden" name="sync_staff" value="1"/>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="edit_name">Team Name</label>
|
||||
<input type="text" id="edit_name" name="name" required>
|
||||
</div>
|
||||
|
||||
<hr class="section-divider">
|
||||
|
||||
<!-- Manage Coaches -->
|
||||
<h5 class="mb-2"><i class="fas fa-chalkboard-teacher"></i> Coaches</h5>
|
||||
<div class="form-group">
|
||||
<label for="edit_coach_id">Assigned Coach</label>
|
||||
<select id="edit_coach_id" name="coach_id" class="form-select">
|
||||
<option value="">-- No coach assigned --</option>
|
||||
<select name="coach_ids" id="edit-coach-select" class="form-select" multiple style="min-height: 100px; width: 100%;">
|
||||
{% for coach in coaches %}
|
||||
<option value="{{ coach.id }}">{{ coach.username }}</option>
|
||||
<option value="{{ coach.id }}" class="coach-option">{{ coach.username }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
<small class="form-text">Hold Ctrl/Cmd to select multiple. Only unassigned coaches shown.</small>
|
||||
</div>
|
||||
|
||||
<!-- Manage Managers -->
|
||||
<h5 class="mb-2"><i class="fas fa-user-tie"></i> Managers</h5>
|
||||
<div class="form-group">
|
||||
<label for="edit_manager_id">Assigned Manager</label>
|
||||
<select id="edit_manager_id" name="manager_id" class="form-select">
|
||||
<option value="">-- No manager assigned --</option>
|
||||
<select name="manager_ids" id="edit-manager-select" class="form-select" multiple style="min-height: 100px; width: 100%;">
|
||||
{% for manager in managers %}
|
||||
<option value="{{ manager.id }}">{{ manager.username }}</option>
|
||||
<option value="{{ manager.id }}" class="manager-option">{{ manager.username }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
<small class="form-text">Hold Ctrl/Cmd to select multiple. Only unassigned managers shown.</small>
|
||||
</div>
|
||||
|
||||
<div class="form-actions">
|
||||
<button type="button" class="btn btn-secondary" onclick="hideEditForm()">Cancel</button>
|
||||
<button type="submit" class="btn btn-primary">Save Changes</button>
|
||||
@@ -355,28 +338,68 @@ function toggleStatus(btn) {
|
||||
});
|
||||
}
|
||||
|
||||
var currentEditTeamId = null;
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
document.querySelectorAll('.edit-team-btn').forEach(function(btn) {
|
||||
btn.addEventListener('click', function() {
|
||||
var teamId = this.getAttribute('data-team-id');
|
||||
currentEditTeamId = this.getAttribute('data-team-id');
|
||||
var teamName = this.getAttribute('data-team-name');
|
||||
var coachId = this.getAttribute('data-coach-id');
|
||||
var managerId = this.getAttribute('data-manager-id');
|
||||
document.getElementById('editTeamForm').action = '/teams/' + teamId + '/edit';
|
||||
document.getElementById('editTeamForm').action = '/teams/' + currentEditTeamId + '/edit';
|
||||
document.getElementById('edit_name').value = teamName;
|
||||
document.getElementById('edit_coach_id').value = coachId || '';
|
||||
document.getElementById('edit_manager_id').value = managerId || '';
|
||||
document.getElementById('editTeamModal').classList.remove('hidden');
|
||||
populateEditSelects(currentEditTeamId);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
function showEditForm(teamId, teamName, coachId, managerId) {
|
||||
document.getElementById('editTeamForm').action = '/teams/' + teamId + '/edit';
|
||||
document.getElementById('edit_name').value = teamName;
|
||||
document.getElementById('edit_coach_id').value = coachId || '';
|
||||
document.getElementById('edit_manager_id').value = managerId || '';
|
||||
document.getElementById('editTeamModal').classList.remove('hidden');
|
||||
function getCurrentStaffIds(teamId, type) {
|
||||
// Get currently assigned coach/manager IDs from the staff bar pills
|
||||
var ids = [];
|
||||
var teamCard = document.querySelector('[data-team-id="' + teamId + '"]');
|
||||
if (!teamCard) return ids;
|
||||
|
||||
var staffBar = teamCard.closest('.card').querySelector('.team-staff-bar');
|
||||
if (!staffBar) return ids;
|
||||
|
||||
var groupIndex = type === 'coach' ? 0 : 1;
|
||||
var group = staffBar.querySelectorAll('.staff-group')[groupIndex];
|
||||
if (!group) return ids;
|
||||
|
||||
group.querySelectorAll('.staff-tag form input[name="coach_id"], .staff-tag form input[name="manager_id"]').forEach(function(input) {
|
||||
ids.push(input.value);
|
||||
});
|
||||
|
||||
return ids;
|
||||
}
|
||||
|
||||
function populateEditSelects(teamId) {
|
||||
var coachSelect = document.getElementById('edit-coach-select');
|
||||
var managerSelect = document.getElementById('edit-manager-select');
|
||||
|
||||
var currentCoachIds = getCurrentStaffIds(teamId, 'coach');
|
||||
var currentManagerIds = getCurrentStaffIds(teamId, 'manager');
|
||||
|
||||
// Show all coaches, but pre-select current ones and hide non-assigned
|
||||
// Actually: show only currently-assigned options (pre-selected)
|
||||
coachSelect.querySelectorAll('.coach-option').forEach(function(opt) {
|
||||
var isAssigned = currentCoachIds.includes(opt.value);
|
||||
opt.selected = isAssigned;
|
||||
// Always show all options so user can add/remove
|
||||
opt.style.display = '';
|
||||
});
|
||||
|
||||
managerSelect.querySelectorAll('.manager-option').forEach(function(opt) {
|
||||
var isAssigned = currentManagerIds.includes(opt.value);
|
||||
opt.selected = isAssigned;
|
||||
opt.style.display = '';
|
||||
});
|
||||
|
||||
// Also update text to reflect current count
|
||||
document.querySelector('#edit-coach-select + .form-text').textContent =
|
||||
'Currently assigned: ' + currentCoachIds.length + '. Hold Ctrl/Cmd to select multiple.';
|
||||
document.querySelector('#edit-manager-select + .form-text').textContent =
|
||||
'Currently assigned: ' + currentManagerIds.length + '. Hold Ctrl/Cmd to select multiple.';
|
||||
}
|
||||
|
||||
function hideEditForm() {
|
||||
|
||||
Reference in New Issue
Block a user