fix some stuff

sync2
Raz 1 year ago
parent 32d81a01e8
commit 62e2b59875
  1. 16
      PadelClub/Data/Tournament.swift
  2. 2
      PadelClub/Utils/FileImportManager.swift
  3. 8
      PadelClub/Views/Tournament/Screen/AddTeamView.swift

@ -1067,6 +1067,11 @@ defer {
registrationDate = previousTeamRegistrationDate
}
let newTeam = addTeam(team.players, registrationDate: registrationDate, name: team.name)
if isAnimation() {
if newTeam.weight == 0 {
newTeam.weight = team.index(in: teams) ?? 0
}
}
teamsToImport.append(newTeam)
}
}
@ -1795,6 +1800,11 @@ defer {
players.forEach { player in
player.teamRegistration = team.id
}
if isAnimation() {
if team.weight == 0 {
team.weight = unsortedTeams().count
}
}
return team
}
@ -1910,9 +1920,9 @@ defer {
private func _defaultSorting() -> [MySortDescriptor<TeamRegistration>] {
switch teamSorting {
case .rank:
[.keyPath(\TeamRegistration.initialWeight), .keyPath(\TeamRegistration.registrationDate!)]
[.keyPath(\TeamRegistration.initialWeight), .keyPath(\TeamRegistration.registrationDate!), .keyPath(\TeamRegistration.id)]
case .inscriptionDate:
[.keyPath(\TeamRegistration.registrationDate!), .keyPath(\TeamRegistration.initialWeight)]
[.keyPath(\TeamRegistration.registrationDate!), .keyPath(\TeamRegistration.initialWeight), .keyPath(\TeamRegistration.id)]
}
}
@ -1922,7 +1932,7 @@ defer {
&& federalTournamentAge == build.age
}
private let _currentSelectionSorting : [MySortDescriptor<TeamRegistration>] = [.keyPath(\.weight), .keyPath(\.registrationDate!)]
private let _currentSelectionSorting : [MySortDescriptor<TeamRegistration>] = [.keyPath(\.weight), .keyPath(\.registrationDate!), .keyPath(\.id)]
private func _matchSchedulers() -> [MatchScheduler] {
return self.tournamentStore.matchSchedulers.filter { $0.tournament == self.id }

@ -462,6 +462,8 @@ class FileImportManager {
let player = PlayerRegistration(firstName: firstName, lastName: lastName, licenceId: licenceId, rank: rank, sex: sex, clubName: club, phoneNumber: phoneNumber, email: email)
if rank == nil, autoSearch {
player.setComputedRank(in: tournament)
} else {
player.computedRank = rank ?? 0
}
return player
}

@ -149,7 +149,7 @@ struct AddTeamView: View {
}
.toolbar {
ToolbarItem(placement: .cancellationAction) {
Button("Terminer", role: .cancel) {
Button("Annuler", role: .cancel) {
dismiss()
}
}
@ -392,8 +392,8 @@ struct AddTeamView: View {
ForEach(createdPlayerIds.sorted(), id: \.self) { id in
if let p = createdPlayers.first(where: { $0.id == id }) {
VStack(alignment: .leading, spacing: 0) {
if let player = unsortedPlayers.first(where: { ($0.licenceId == p.licenceId && $0.licenceId != nil) }), editedTeam?.includes(player: player) == true {
Text("Déjà inscrit !").foregroundStyle(.logoRed).bold()
if let player = unsortedPlayers.first(where: { ($0.licenceId == p.licenceId && $0.licenceId != nil) }), editedTeam?.includes(player: player) == false {
Text("Déjà inscrit !!").foregroundStyle(.logoRed).bold()
}
PlayerView(player: p).tag(p.id)
.environment(tournament)
@ -421,7 +421,7 @@ struct AddTeamView: View {
} else {
RowButtonView("Confirmer") {
_updateTeam(checkDuplicates: false)
editedTeam = nil
dismiss()
}
}
} header: {

Loading…
Cancel
Save