|
|
|
@ -28,7 +28,7 @@ struct RoundView: View { |
|
|
|
return self.tournament.tournamentStore |
|
|
|
return self.tournament.tournamentStore |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private func _getAvailableSeedGroup() async { |
|
|
|
private func _getAvailableSeedGroup() { |
|
|
|
#if DEBUG_TIME //DEBUGING TIME |
|
|
|
#if DEBUG_TIME //DEBUGING TIME |
|
|
|
let start = Date() |
|
|
|
let start = Date() |
|
|
|
defer { |
|
|
|
defer { |
|
|
|
@ -40,7 +40,7 @@ struct RoundView: View { |
|
|
|
availableSeedGroup = tournament.seedGroupAvailable(atRoundIndex: upperRound.round.index) |
|
|
|
availableSeedGroup = tournament.seedGroupAvailable(atRoundIndex: upperRound.round.index) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private func _getSpaceLeft() async { |
|
|
|
private func _getSpaceLeft() { |
|
|
|
#if DEBUG_TIME //DEBUGING TIME |
|
|
|
#if DEBUG_TIME //DEBUGING TIME |
|
|
|
let start = Date() |
|
|
|
let start = Date() |
|
|
|
defer { |
|
|
|
defer { |
|
|
|
@ -130,12 +130,11 @@ struct RoundView: View { |
|
|
|
Section { |
|
|
|
Section { |
|
|
|
RowButtonView("Placer \(availableSeedGroup.localizedLabel())" + ((availableSeedGroup.isFixed() == false) ? " au hasard" : "")) { |
|
|
|
RowButtonView("Placer \(availableSeedGroup.localizedLabel())" + ((availableSeedGroup.isFixed() == false) ? " au hasard" : "")) { |
|
|
|
tournament.setSeeds(inRoundIndex: upperRound.round.index, inSeedGroup: availableSeedGroup) |
|
|
|
tournament.setSeeds(inRoundIndex: upperRound.round.index, inSeedGroup: availableSeedGroup) |
|
|
|
await _save() |
|
|
|
_save() |
|
|
|
if tournament.availableSeeds().isEmpty && tournament.availableQualifiedTeams().isEmpty { |
|
|
|
if tournament.availableSeeds().isEmpty && tournament.availableQualifiedTeams().isEmpty { |
|
|
|
self.isEditingTournamentSeed.wrappedValue = false |
|
|
|
self.isEditingTournamentSeed.wrappedValue = false |
|
|
|
} |
|
|
|
} |
|
|
|
await _getSpaceLeft() |
|
|
|
_prepareRound() |
|
|
|
await _getAvailableSeedGroup() |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} footer: { |
|
|
|
} footer: { |
|
|
|
if availableSeedGroup.isFixed() == false { |
|
|
|
if availableSeedGroup.isFixed() == false { |
|
|
|
@ -161,17 +160,14 @@ struct RoundView: View { |
|
|
|
ForEach(availableQualifiedTeams) { team in |
|
|
|
ForEach(availableQualifiedTeams) { team in |
|
|
|
NavigationLink { |
|
|
|
NavigationLink { |
|
|
|
SpinDrawView(drawees: [team], segments: spaceLeft) { results in |
|
|
|
SpinDrawView(drawees: [team], segments: spaceLeft) { results in |
|
|
|
Task { |
|
|
|
results.forEach { drawResult in |
|
|
|
results.forEach { drawResult in |
|
|
|
team.setSeedPosition(inSpot: spaceLeft[drawResult.drawIndex], slot: nil, opposingSeeding: true) |
|
|
|
team.setSeedPosition(inSpot: spaceLeft[drawResult.drawIndex], slot: nil, opposingSeeding: true) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
await _save() |
|
|
|
|
|
|
|
if tournament.availableSeeds().isEmpty && tournament.availableQualifiedTeams().isEmpty { |
|
|
|
|
|
|
|
self.isEditingTournamentSeed.wrappedValue = false |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
await _getSpaceLeft() |
|
|
|
|
|
|
|
await _getAvailableSeedGroup() |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
_save() |
|
|
|
|
|
|
|
if tournament.availableSeeds().isEmpty && tournament.availableQualifiedTeams().isEmpty { |
|
|
|
|
|
|
|
self.isEditingTournamentSeed.wrappedValue = false |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
_prepareRound() |
|
|
|
} |
|
|
|
} |
|
|
|
} label: { |
|
|
|
} label: { |
|
|
|
TeamRowView(team: team, displayCallDate: false) |
|
|
|
TeamRowView(team: team, displayCallDate: false) |
|
|
|
@ -193,17 +189,14 @@ struct RoundView: View { |
|
|
|
ForEach(availableSeeds) { team in |
|
|
|
ForEach(availableSeeds) { team in |
|
|
|
NavigationLink { |
|
|
|
NavigationLink { |
|
|
|
SpinDrawView(drawees: [team], segments: seedSpaceLeft) { results in |
|
|
|
SpinDrawView(drawees: [team], segments: seedSpaceLeft) { results in |
|
|
|
Task { |
|
|
|
results.forEach { drawResult in |
|
|
|
results.forEach { drawResult in |
|
|
|
team.setSeedPosition(inSpot: seedSpaceLeft[drawResult.drawIndex], slot: nil, opposingSeeding: false) |
|
|
|
team.setSeedPosition(inSpot: seedSpaceLeft[drawResult.drawIndex], slot: nil, opposingSeeding: false) |
|
|
|
} |
|
|
|
} |
|
|
|
_save() |
|
|
|
await _save() |
|
|
|
if tournament.availableSeeds().isEmpty && tournament.availableQualifiedTeams().isEmpty { |
|
|
|
if tournament.availableSeeds().isEmpty && tournament.availableQualifiedTeams().isEmpty { |
|
|
|
self.isEditingTournamentSeed.wrappedValue = false |
|
|
|
self.isEditingTournamentSeed.wrappedValue = false |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
await _getSpaceLeft() |
|
|
|
|
|
|
|
await _getAvailableSeedGroup() |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
_prepareRound() |
|
|
|
} |
|
|
|
} |
|
|
|
} label: { |
|
|
|
} label: { |
|
|
|
TeamRowView(team: team, displayCallDate: false) |
|
|
|
TeamRowView(team: team, displayCallDate: false) |
|
|
|
@ -221,17 +214,14 @@ struct RoundView: View { |
|
|
|
ForEach(availableSeeds) { team in |
|
|
|
ForEach(availableSeeds) { team in |
|
|
|
NavigationLink { |
|
|
|
NavigationLink { |
|
|
|
SpinDrawView(drawees: [team], segments: spaceLeft) { results in |
|
|
|
SpinDrawView(drawees: [team], segments: spaceLeft) { results in |
|
|
|
Task { |
|
|
|
results.forEach { drawResult in |
|
|
|
results.forEach { drawResult in |
|
|
|
team.setSeedPosition(inSpot: spaceLeft[drawResult.drawIndex], slot: nil, opposingSeeding: true) |
|
|
|
team.setSeedPosition(inSpot: spaceLeft[drawResult.drawIndex], slot: nil, opposingSeeding: true) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
await _save() |
|
|
|
|
|
|
|
if tournament.availableSeeds().isEmpty && tournament.availableQualifiedTeams().isEmpty { |
|
|
|
|
|
|
|
self.isEditingTournamentSeed.wrappedValue = false |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
await _getSpaceLeft() |
|
|
|
|
|
|
|
await _getAvailableSeedGroup() |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
_save() |
|
|
|
|
|
|
|
if tournament.availableSeeds().isEmpty && tournament.availableQualifiedTeams().isEmpty { |
|
|
|
|
|
|
|
self.isEditingTournamentSeed.wrappedValue = false |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
_prepareRound() |
|
|
|
} |
|
|
|
} |
|
|
|
} label: { |
|
|
|
} label: { |
|
|
|
TeamRowView(team: team, displayCallDate: false) |
|
|
|
TeamRowView(team: team, displayCallDate: false) |
|
|
|
@ -283,9 +273,7 @@ struct RoundView: View { |
|
|
|
PrintSettingsView(tournament: tournament) |
|
|
|
PrintSettingsView(tournament: tournament) |
|
|
|
} |
|
|
|
} |
|
|
|
.onAppear { |
|
|
|
.onAppear { |
|
|
|
Task { |
|
|
|
_prepareRound() |
|
|
|
await _prepareRound() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
let seeds = upperRound.round.seeds() |
|
|
|
let seeds = upperRound.round.seeds() |
|
|
|
SlideToDeleteSeedTip.seeds = seeds.count |
|
|
|
SlideToDeleteSeedTip.seeds = seeds.count |
|
|
|
PrintTip.seeds = seeds.count |
|
|
|
PrintTip.seeds = seeds.count |
|
|
|
@ -294,17 +282,19 @@ struct RoundView: View { |
|
|
|
.fullScreenCover(isPresented: showVisualDrawView) { |
|
|
|
.fullScreenCover(isPresented: showVisualDrawView) { |
|
|
|
if let availableSeedGroup = selectedSeedGroup { |
|
|
|
if let availableSeedGroup = selectedSeedGroup { |
|
|
|
let seeds = tournament.seeds(inSeedGroup: availableSeedGroup) |
|
|
|
let seeds = tournament.seeds(inSeedGroup: availableSeedGroup) |
|
|
|
let availableSeedSpot = tournament.availableSeedSpot(inRoundIndex: upperRound.round.index) |
|
|
|
let opposingSeeding = seedSpaceLeft.isEmpty ? true : false |
|
|
|
|
|
|
|
let availableSeedSpot = opposingSeeding ? spaceLeft : seedSpaceLeft |
|
|
|
NavigationStack { |
|
|
|
NavigationStack { |
|
|
|
SpinDrawView(drawees: seeds, segments: availableSeedSpot, autoMode: true) { draws in |
|
|
|
SpinDrawView(drawees: seeds, segments: availableSeedSpot, autoMode: true) { draws in |
|
|
|
Task { |
|
|
|
draws.forEach { drawResult in |
|
|
|
draws.forEach { drawResult in |
|
|
|
seeds[drawResult.drawee].setSeedPosition(inSpot: availableSeedSpot[drawResult.drawIndex], slot: nil, opposingSeeding: opposingSeeding) |
|
|
|
seeds[drawResult.drawee].setSeedPosition(inSpot: availableSeedSpot[drawResult.drawIndex], slot: nil, opposingSeeding: false) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
await _save() |
|
|
|
_save() |
|
|
|
if tournament.availableSeeds().isEmpty && tournament.availableQualifiedTeams().isEmpty { |
|
|
|
_prepareRound() |
|
|
|
self.isEditingTournamentSeed.wrappedValue = false |
|
|
|
|
|
|
|
} |
|
|
|
if tournament.availableSeeds().isEmpty && tournament.availableQualifiedTeams().isEmpty { |
|
|
|
|
|
|
|
self.isEditingTournamentSeed.wrappedValue = false |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
@ -315,9 +305,7 @@ struct RoundView: View { |
|
|
|
ToolbarItem(placement: .topBarTrailing) { |
|
|
|
ToolbarItem(placement: .topBarTrailing) { |
|
|
|
Button(isEditingTournamentSeed.wrappedValue == true ? "Valider" : "Modifier") { |
|
|
|
Button(isEditingTournamentSeed.wrappedValue == true ? "Valider" : "Modifier") { |
|
|
|
if isEditingTournamentSeed.wrappedValue == true { |
|
|
|
if isEditingTournamentSeed.wrappedValue == true { |
|
|
|
Task { |
|
|
|
_save() |
|
|
|
await _save() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
isEditingTournamentSeed.wrappedValue.toggle() |
|
|
|
isEditingTournamentSeed.wrappedValue.toggle() |
|
|
|
} |
|
|
|
} |
|
|
|
@ -325,7 +313,7 @@ struct RoundView: View { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private func _save() async { |
|
|
|
private func _save() { |
|
|
|
do { |
|
|
|
do { |
|
|
|
try self.tournamentStore.teamRegistrations.addOrUpdate(contentOfs: tournament.unsortedTeams()) |
|
|
|
try self.tournamentStore.teamRegistrations.addOrUpdate(contentOfs: tournament.unsortedTeams()) |
|
|
|
} catch { |
|
|
|
} catch { |
|
|
|
@ -348,13 +336,9 @@ struct RoundView: View { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private func _prepareRound() async { |
|
|
|
private func _prepareRound() { |
|
|
|
Task { |
|
|
|
_getSpaceLeft() |
|
|
|
await _getSpaceLeft() |
|
|
|
_getAvailableSeedGroup() |
|
|
|
} |
|
|
|
|
|
|
|
Task { |
|
|
|
|
|
|
|
await _getAvailableSeedGroup() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|