|
|
|
|
@ -27,7 +27,7 @@ struct GroupStageSettingsView: View { |
|
|
|
|
_groupStage = Bindable(groupStage) |
|
|
|
|
_groupStageName = .init(wrappedValue: groupStage.name ?? "") |
|
|
|
|
_size = .init(wrappedValue: groupStage.size) |
|
|
|
|
_courtIndex = .init(wrappedValue: groupStage._matches().first?.courtIndex ?? 0) |
|
|
|
|
_courtIndex = .init(wrappedValue: groupStage.matches().first?.courtIndex ?? 0) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
var tournamentStore: TournamentStore? { |
|
|
|
|
@ -66,12 +66,12 @@ struct GroupStageSettingsView: View { |
|
|
|
|
Section { |
|
|
|
|
CourtPicker(title: "Terrain dédié", selection: $courtIndex, maxCourt: tournament.courtCount) |
|
|
|
|
RowButtonView("Confirmer", role: .destructive) { |
|
|
|
|
groupStage._matches().forEach { match in |
|
|
|
|
groupStage.matches().forEach { match in |
|
|
|
|
match.setCourt(courtIndex) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
do { |
|
|
|
|
try tournamentStore?.matches.addOrUpdate(contentOfs: groupStage._matches()) |
|
|
|
|
try tournamentStore?.matches.addOrUpdate(contentOfs: groupStage.matches()) |
|
|
|
|
} catch { |
|
|
|
|
Logger.error(error) |
|
|
|
|
} |
|
|
|
|
@ -91,7 +91,7 @@ struct GroupStageSettingsView: View { |
|
|
|
|
teams.forEach { team in |
|
|
|
|
team.groupStagePosition = nil |
|
|
|
|
team.groupStage = nil |
|
|
|
|
groupStage._matches().forEach({ $0.updateTeamScores() }) |
|
|
|
|
groupStage.matches().forEach({ $0.updateTeamScores() }) |
|
|
|
|
} |
|
|
|
|
do { |
|
|
|
|
try tournamentStore?.teamRegistrations.addOrUpdate(contentOfs: teams) |
|
|
|
|
@ -111,13 +111,13 @@ struct GroupStageSettingsView: View { |
|
|
|
|
|
|
|
|
|
Section { |
|
|
|
|
RowButtonView("Retirer tous les horaires", role: .destructive) { |
|
|
|
|
groupStage._matches().forEach { match in |
|
|
|
|
groupStage.matches().forEach { match in |
|
|
|
|
match.startDate = nil |
|
|
|
|
match.endDate = nil |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
do { |
|
|
|
|
try tournamentStore?.matches.addOrUpdate(contentOfs: groupStage._matches()) |
|
|
|
|
try tournamentStore?.matches.addOrUpdate(contentOfs: groupStage.matches()) |
|
|
|
|
} catch { |
|
|
|
|
Logger.error(error) |
|
|
|
|
} |
|
|
|
|
@ -130,7 +130,7 @@ struct GroupStageSettingsView: View { |
|
|
|
|
teams.forEach { team in |
|
|
|
|
team.groupStagePosition = nil |
|
|
|
|
team.groupStage = nil |
|
|
|
|
groupStage._matches().forEach({ $0.updateTeamScores() }) |
|
|
|
|
groupStage.matches().forEach({ $0.updateTeamScores() }) |
|
|
|
|
} |
|
|
|
|
do { |
|
|
|
|
try tournamentStore?.teamRegistrations.addOrUpdate(contentOfs: teams) |
|
|
|
|
|