|
|
|
|
@ -18,18 +18,20 @@ struct PlanningSettingsView: View { |
|
|
|
|
@State private var schedulingDone: Bool = false |
|
|
|
|
@State private var showOptions: Bool = false |
|
|
|
|
@State private var issueFound: Bool = false |
|
|
|
|
@State private var parallelType: Bool = false |
|
|
|
|
|
|
|
|
|
init(tournament: Tournament) { |
|
|
|
|
self.tournament = tournament |
|
|
|
|
if let matchScheduler = tournament.matchScheduler() { |
|
|
|
|
if matchScheduler.groupStageChunkCount == nil { |
|
|
|
|
matchScheduler.groupStageChunkCount = tournament.getGroupStageChunkValue() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
self.matchScheduler = matchScheduler |
|
|
|
|
self._groupStageChunkCount = State(wrappedValue: matchScheduler.groupStageChunkCount ?? tournament.getGroupStageChunkValue()) |
|
|
|
|
if matchScheduler.groupStageChunkCount != nil { |
|
|
|
|
_parallelType = .init(wrappedValue: true) |
|
|
|
|
_groupStageChunkCount = State(wrappedValue: matchScheduler.groupStageChunkCount!) |
|
|
|
|
} else { |
|
|
|
|
_groupStageChunkCount = State(wrappedValue: tournament.getGroupStageChunkValue()) |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
self.matchScheduler = MatchScheduler(tournament: tournament.id, groupStageChunkCount: tournament.getGroupStageChunkValue()) |
|
|
|
|
self.matchScheduler = MatchScheduler(tournament: tournament.id) |
|
|
|
|
self._groupStageChunkCount = State(wrappedValue: tournament.getGroupStageChunkValue()) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
@ -93,28 +95,11 @@ struct PlanningSettingsView: View { |
|
|
|
|
.foregroundStyle(.logoRed) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if tournament.groupStageCount > 0 { |
|
|
|
|
Section { |
|
|
|
|
TournamentFieldsManagerView(localizedStringKey: "Poule en parallèle", count: $groupStageChunkCount, max: tournament.groupStageCount) |
|
|
|
|
.onChange(of: groupStageChunkCount) { |
|
|
|
|
matchScheduler.groupStageChunkCount = groupStageChunkCount |
|
|
|
|
} |
|
|
|
|
} footer: { |
|
|
|
|
NavigationLink { |
|
|
|
|
_optionsView() |
|
|
|
|
} label: { |
|
|
|
|
Text("Voir les options avancées") |
|
|
|
|
.underline() |
|
|
|
|
.foregroundStyle(.master) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
Section { |
|
|
|
|
NavigationLink { |
|
|
|
|
_optionsView() |
|
|
|
|
} label: { |
|
|
|
|
Text("Voir les options avancées") |
|
|
|
|
} |
|
|
|
|
Section { |
|
|
|
|
NavigationLink { |
|
|
|
|
_optionsView() |
|
|
|
|
} label: { |
|
|
|
|
Text("Voir les options avancées") |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -219,6 +204,37 @@ struct PlanningSettingsView: View { |
|
|
|
|
@ViewBuilder |
|
|
|
|
private func _optionsView() -> some View { |
|
|
|
|
List { |
|
|
|
|
if tournament.groupStageCount > 0 { |
|
|
|
|
Section { |
|
|
|
|
Picker(selection: $parallelType) { |
|
|
|
|
Text("Auto.").tag(false) |
|
|
|
|
Text("Manuel").tag(true) |
|
|
|
|
} label: { |
|
|
|
|
Text("Poules en parallèle") |
|
|
|
|
let value = tournament.getGroupStageChunkValue() |
|
|
|
|
if parallelType == false, value > 1 { |
|
|
|
|
Text("\(value.formatted()) poules commenceront en parallèle") |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
.onChange(of: parallelType) { |
|
|
|
|
if parallelType { |
|
|
|
|
groupStageChunkCount = tournament.getGroupStageChunkValue() |
|
|
|
|
} else { |
|
|
|
|
matchScheduler.groupStageChunkCount = nil |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if parallelType { |
|
|
|
|
TournamentFieldsManagerView(localizedStringKey: "Poule en parallèle", count: $groupStageChunkCount, max: tournament.groupStageCount) |
|
|
|
|
.onChange(of: groupStageChunkCount) { |
|
|
|
|
matchScheduler.groupStageChunkCount = groupStageChunkCount |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} footer: { |
|
|
|
|
Text("Vous pouvez indiquer le nombre de poule démarrant en même temps.") |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Section { |
|
|
|
|
Toggle(isOn: $matchScheduler.overrideCourtsUnavailability) { |
|
|
|
|
Text("Ne pas tenir compte des autres épreuves") |
|
|
|
|
|