This commit is contained in:
@@ -127,7 +127,7 @@
|
||||
<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 ['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)) %}
|
||||
{% if current_user.can_manage_team_matches(team) %}
|
||||
<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>
|
||||
@@ -159,6 +159,9 @@
|
||||
<div class="user-mini">
|
||||
<div class="avatar-sm">{{ entry.player.username[:2] | upper }}</div>
|
||||
<a href="{{ url_for('users.view_user', user_id=entry.player.id) }}">{{ entry.player.username }}</a>
|
||||
{% if entry.is_team_representative %}
|
||||
<span class="badge badge-info" title="{{ _('Team representative') }}">{{ _('Representative') }}</span>
|
||||
{% endif %}
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
@@ -180,6 +183,16 @@
|
||||
<td>{{ entry.player.phone or '-' }}</td>
|
||||
{% if can_manage_team %}
|
||||
<td>
|
||||
{% if current_user.can_designate_team_representative() %}
|
||||
<button type="button"
|
||||
class="btn btn-sm representative-toggle-btn {% if entry.is_team_representative %}btn-warning{% else %}btn-outline{% endif %}"
|
||||
data-team-id="{{ team.id }}"
|
||||
data-player-id="{{ entry.player.id }}"
|
||||
data-action="toggle-representative"
|
||||
title="{{ _('Name as team representative') }}">
|
||||
<i class="fas fa-star"></i>
|
||||
</button>
|
||||
{% endif %}
|
||||
<form method="POST" data-ajax action="{{ url_for('teams.remove_player', team_id=team.id, player_id=entry.player.id) }}" class="inline-form" data-confirm="{{ _('Remove %(player)s from %(team)s?', player=entry.player.username, team=team.name) }}">
|
||||
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}"/>
|
||||
<button type="submit" class="btn btn-sm btn-danger">
|
||||
@@ -341,6 +354,35 @@ function toggleStatus(btn) {
|
||||
});
|
||||
}
|
||||
|
||||
function toggleRepresentative(btn) {
|
||||
var teamId = btn.getAttribute('data-team-id');
|
||||
var playerId = btn.getAttribute('data-player-id');
|
||||
|
||||
fetch('/teams/' + teamId + '/toggle_representative/' + playerId, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'X-CSRFToken': '{{ csrf_token() }}',
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
})
|
||||
.then(function(response) { return response.json(); })
|
||||
.then(function(data) {
|
||||
if (data.success) {
|
||||
if (data.is_team_representative) {
|
||||
btn.classList.remove('btn-outline');
|
||||
btn.classList.add('btn-warning');
|
||||
} else {
|
||||
btn.classList.remove('btn-warning');
|
||||
btn.classList.add('btn-outline');
|
||||
}
|
||||
window.TT.refreshPage(window.location.pathname);
|
||||
}
|
||||
})
|
||||
.catch(function(error) {
|
||||
console.error('Error:', error);
|
||||
});
|
||||
}
|
||||
|
||||
var currentEditTeamId = null;
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
@@ -416,6 +458,7 @@ registerActions({
|
||||
'hide-create-form': hideCreateForm,
|
||||
'hide-edit-form': hideEditForm,
|
||||
'toggle-status': toggleStatus,
|
||||
'toggle-representative': toggleRepresentative,
|
||||
});
|
||||
</script>
|
||||
<style>
|
||||
|
||||
Reference in New Issue
Block a user