@ -28,6 +28,7 @@ struct RoundView: View {
List {
List {
let loserRounds = round . loserRounds ( )
let loserRounds = round . loserRounds ( )
let availableSeeds = tournament . availableSeeds ( )
let availableQualifiedTeams = tournament . availableQualifiedTeams ( )
let availableQualifiedTeams = tournament . availableQualifiedTeams ( )
let displayableMatches = round . displayableMatches ( ) . sorted ( by : \ . index )
let displayableMatches = round . displayableMatches ( ) . sorted ( by : \ . index )
let spaceLeft = displayableMatches . filter ( { $0 . hasSpaceLeft ( ) } )
let spaceLeft = displayableMatches . filter ( { $0 . hasSpaceLeft ( ) } )
@ -76,46 +77,80 @@ struct RoundView: View {
if availableQualifiedTeams . isEmpty = = false && spaceLeft . isEmpty = = false {
if availableQualifiedTeams . isEmpty = = false && spaceLeft . isEmpty = = false {
Section {
Section {
ForEach ( availableQualifiedTeams ) { team in
DisclosureGroup {
NavigationLink {
ForEach ( availableQualifiedTeams ) { team in
SpinDrawView ( drawees : [ team ] , segments : spaceLeft ) { results in
NavigationLink {
Task {
SpinDrawView ( drawees : [ team ] , segments : spaceLeft ) { results in
results . forEach { drawResult in
Task {
team . setSeedPosition ( inSpot : spaceLeft [ drawResult . drawIndex ] , slot : nil , opposingSeeding : true )
results . forEach { drawResult in
}
team . setSeedPosition ( inSpot : spaceLeft [ drawResult . drawIndex ] , slot : nil , opposingSeeding : true )
_save ( )
}
if tournament . availableSeeds ( ) . isEmpty && tournament . availableQualifiedTeams ( ) . isEmpty {
_save ( )
self . isEditingTournamentSeed . wrappedValue = false
if tournament . availableSeeds ( ) . isEmpty && tournament . availableQualifiedTeams ( ) . isEmpty {
self . isEditingTournamentSeed . wrappedValue = false
}
}
}
}
}
} label : {
TeamRowView ( team : team , displayCallDate : false )
}
}
} label : {
TeamRowView ( team : team , displayCallDate : false )
}
}
} label : {
Text ( " Qualifié \( availableQualifiedTeams . count . pluralSuffix ) à placer " ) . badge ( availableQualifiedTeams . count )
}
}
} header : {
} header : {
Text ( " Tirage au sort visuel d'un qualifié " ) . font ( . subheadline )
Text ( " Tirage au sort visuel d'un qualifié " ) . font ( . subheadline )
}
}
}
}
if tournament . availableSeeds ( ) . isEmpty = = false && seedSpaceLeft . isEmpty = = false {
if availableSeeds . isEmpty = = false && seedSpaceLeft . isEmpty = = false {
Section {
Section {
ForEach ( tournament . availableSeeds ( ) ) { team in
DisclosureGroup {
NavigationLink {
ForEach ( availableSeeds ) { team in
SpinDrawView ( drawees : [ team ] , segments : seedSpaceLeft ) { results in
NavigationLink {
Task {
SpinDrawView ( drawees : [ team ] , segments : seedSpaceLeft ) { results in
results . forEach { drawResult in
Task {
team . setSeedPosition ( inSpot : seedSpaceLeft [ drawResult . drawIndex ] , slot : nil , opposingSeeding : false )
results . forEach { drawResult in
team . setSeedPosition ( inSpot : seedSpaceLeft [ drawResult . drawIndex ] , slot : nil , opposingSeeding : false )
}
_save ( )
if availableSeeds . isEmpty && tournament . availableQualifiedTeams ( ) . isEmpty {
self . isEditingTournamentSeed . wrappedValue = false
}
}
}
_save ( )
}
if tournament . availableSeeds ( ) . isEmpty && tournament . availableQualifiedTeams ( ) . isEmpty {
} label : {
self . isEditingTournamentSeed . wrappedValue = false
TeamRowView ( team : team , displayCallDate : false )
}
}
} label : {
Text ( " Tête \( availableSeeds . count . pluralSuffix ) de série à placer " ) . badge ( availableSeeds . count )
}
} header : {
Text ( " Tirage au sort visuel d'une tête de série " ) . font ( . subheadline )
}
} else if availableSeeds . isEmpty = = false && spaceLeft . isEmpty = = false {
Section {
DisclosureGroup {
ForEach ( availableSeeds ) { team in
NavigationLink {
SpinDrawView ( drawees : [ team ] , segments : spaceLeft ) { results in
Task {
results . forEach { drawResult in
team . setSeedPosition ( inSpot : spaceLeft [ drawResult . drawIndex ] , slot : nil , opposingSeeding : false )
}
_save ( )
if availableSeeds . isEmpty && tournament . availableQualifiedTeams ( ) . isEmpty {
self . isEditingTournamentSeed . wrappedValue = false
}
}
}
}
}
} label : {
TeamRowView ( team : team , displayCallDate : false )
}
}
} label : {
TeamRowView ( team : team , displayCallDate : false )
}
}
} label : {
Text ( " Tête \( availableSeeds . count . pluralSuffix ) de série à placer " ) . badge ( availableSeeds . count )
}
}
} header : {
} header : {
Text ( " Tirage au sort visuel d'une tête de série " ) . font ( . subheadline )
Text ( " Tirage au sort visuel d'une tête de série " ) . font ( . subheadline )