fix(TeamManagement): correct member eligibility logic and add eligibility check for planning teams
All checks were successful
Deploy tt-tagebuch / deploy (push) Successful in 37s
All checks were successful
Deploy tt-tagebuch / deploy (push) Successful in 37s
- Updated the eligibility comparison logic to ensure correct member and team index validation. - Introduced a new function to check if a member is eligible for a planning team based on age group and gender. - Enhanced the team drop functionality to include eligibility validation, providing user feedback for ineligible members.
This commit is contained in:
@@ -979,7 +979,7 @@ export default {
|
||||
if (memberIndex < 0 || teamIndex < 0) {
|
||||
return false;
|
||||
}
|
||||
return memberIndex <= teamIndex;
|
||||
return memberIndex >= teamIndex;
|
||||
};
|
||||
|
||||
const getMemberEligibilityLabel = (member, teamAgeGroup) => {
|
||||
@@ -1218,6 +1218,16 @@ export default {
|
||||
planningDraggingMemberId.value = Number(member?.id);
|
||||
};
|
||||
|
||||
const isEligibleForPlanningTeam = (memberId, teamId) => {
|
||||
const team = planningLocalTeams.value.find((entry) => Number(entry.id) === Number(teamId));
|
||||
if (!team) return false;
|
||||
const member = planningMemberById.value.get(planningMemberKey(memberId));
|
||||
if (!member) return false;
|
||||
const teamAgeGroup = team.teamAgeGroup || 'adult';
|
||||
const teamGender = team.teamGender || 'open';
|
||||
return isEligibleForTeam(member, teamAgeGroup, teamGender);
|
||||
};
|
||||
|
||||
const setPlanningTeamStatus = (teamId, state) => {
|
||||
const key = String(teamId);
|
||||
planningTeamSaveStatus.value = {
|
||||
@@ -1305,10 +1315,20 @@ export default {
|
||||
planningAutosaveTimers.set(key, timer);
|
||||
};
|
||||
|
||||
const onPlanningDropToTeam = (teamId) => {
|
||||
const onPlanningDropToTeam = async (teamId) => {
|
||||
const memberId = Number(planningDraggingMemberId.value);
|
||||
const targetTeamId = Number(teamId);
|
||||
if (!memberId || !targetTeamId) return;
|
||||
if (!isEligibleForPlanningTeam(memberId, targetTeamId)) {
|
||||
await showInfo(
|
||||
t('messages.warning'),
|
||||
'Dieses Mitglied ist für die gewählte Mannschaft nicht spielberechtigt (Geschlecht/Altersklasse).',
|
||||
'',
|
||||
'warning'
|
||||
);
|
||||
planningDraggingMemberId.value = null;
|
||||
return;
|
||||
}
|
||||
const previousEntry = planningAssignments.value.find((entry) => Number(entry.memberId) === memberId);
|
||||
const sourceTeamId = previousEntry ? Number(previousEntry.teamId) : null;
|
||||
const withoutMember = planningAssignments.value.filter((entry) => Number(entry.memberId) !== memberId);
|
||||
|
||||
Reference in New Issue
Block a user