|
|
|
|
@ -30,23 +30,34 @@ struct SchedulerView: View { |
|
|
|
|
List { |
|
|
|
|
switch destination { |
|
|
|
|
case .scheduleGroupStage: |
|
|
|
|
MatchFormatPickingView(matchFormat: $tournament.groupStageMatchFormat) { |
|
|
|
|
Task { |
|
|
|
|
tournament.matchScheduler()?.updateSchedule(tournament: tournament) |
|
|
|
|
Section { |
|
|
|
|
MatchFormatPickingView(matchFormat: $tournament.groupStageMatchFormat) { |
|
|
|
|
Task { |
|
|
|
|
tournament.matchScheduler()?.updateSchedule(tournament: tournament) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
.onChange(of: tournament.groupStageMatchFormat) { |
|
|
|
|
let groupStages = tournament.groupStages() |
|
|
|
|
groupStages.forEach { groupStage in |
|
|
|
|
groupStage.updateMatchFormat(tournament.groupStageMatchFormat) |
|
|
|
|
.onChange(of: tournament.groupStageMatchFormat) { |
|
|
|
|
let groupStages = tournament.groupStages() |
|
|
|
|
groupStages.forEach { groupStage in |
|
|
|
|
groupStage.updateMatchFormat(tournament.groupStageMatchFormat) |
|
|
|
|
} |
|
|
|
|
do { |
|
|
|
|
try dataStore.tournaments.addOrUpdate(instance: tournament) |
|
|
|
|
try dataStore.groupStages.addOrUpdate(contentOfs: groupStages) |
|
|
|
|
} catch { |
|
|
|
|
Logger.error(error) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
do { |
|
|
|
|
try dataStore.tournaments.addOrUpdate(instance: tournament) |
|
|
|
|
try dataStore.groupStages.addOrUpdate(contentOfs: groupStages) |
|
|
|
|
} catch { |
|
|
|
|
Logger.error(error) |
|
|
|
|
} footer: { |
|
|
|
|
if tournament.groupStageMatchFormat.weight > tournament.groupStageSmartMatchFormat().weight { |
|
|
|
|
Button { |
|
|
|
|
tournament.groupStageMatchFormat = tournament.groupStageSmartMatchFormat() |
|
|
|
|
} label: { |
|
|
|
|
Text("devrait être joué au moins en " + tournament.groupStageSmartMatchFormat().format + ", ") + Text("modifier ?").underline().foregroundStyle(.master) |
|
|
|
|
} |
|
|
|
|
.buttonStyle(.plain) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
ForEach(tournament.groupStages()) { |
|
|
|
|
@ -63,6 +74,19 @@ struct SchedulerView: View { |
|
|
|
|
} |
|
|
|
|
.headerProminence(.increased) |
|
|
|
|
.monospacedDigit() |
|
|
|
|
.onChange(of: tournament.groupStageMatchFormat) { |
|
|
|
|
let groupStages = tournament.groupStages() |
|
|
|
|
tournament.groupStages().forEach { groupStage in |
|
|
|
|
groupStage.updateMatchFormat(tournament.groupStageMatchFormat) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
do { |
|
|
|
|
try dataStore.tournaments.addOrUpdate(instance: tournament) |
|
|
|
|
try dataStore.groupStages.addOrUpdate(contentOfs: groupStages) |
|
|
|
|
} catch { |
|
|
|
|
Logger.error(error) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ViewBuilder |
|
|
|
|
@ -92,33 +116,67 @@ struct SchedulerView: View { |
|
|
|
|
} |
|
|
|
|
} header: { |
|
|
|
|
Text(round.titleLabel()) |
|
|
|
|
} footer: { |
|
|
|
|
let federalFormat = tournament.roundSmartMatchFormat(round.index) |
|
|
|
|
if round.matchFormat.weight > federalFormat.weight { |
|
|
|
|
Button { |
|
|
|
|
round.updateMatchFormatAndAllMatches(federalFormat) |
|
|
|
|
do { |
|
|
|
|
try dataStore.rounds.addOrUpdate(instance: round) |
|
|
|
|
} catch { |
|
|
|
|
Logger.error(error) |
|
|
|
|
} |
|
|
|
|
} label: { |
|
|
|
|
Text("devrait être joué au moins en " + federalFormat.format + ", ") + Text("modifier ?").underline().foregroundStyle(.master) |
|
|
|
|
} |
|
|
|
|
.buttonStyle(.plain) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Section { |
|
|
|
|
NavigationLink { |
|
|
|
|
LoserRoundScheduleEditorView(upperRound: round, tournament: tournament) |
|
|
|
|
.environment(tournament) |
|
|
|
|
} label: { |
|
|
|
|
LabeledContent { |
|
|
|
|
let count = round.loserRounds().filter({ $0.isDisabled() == false }).count |
|
|
|
|
Text(count.formatted() + " tour" + count.pluralSuffix) |
|
|
|
|
if round.index != 0 { |
|
|
|
|
Section { |
|
|
|
|
NavigationLink { |
|
|
|
|
LoserRoundScheduleEditorView(upperRound: round, tournament: tournament) |
|
|
|
|
.environment(tournament) |
|
|
|
|
} label: { |
|
|
|
|
if let startDate = round.getLoserRoundStartDate() { |
|
|
|
|
HStack { |
|
|
|
|
Text(startDate.formattedAsHourMinute()).font(.title3) |
|
|
|
|
if let estimatedEndDate = round.estimatedLoserRoundEndDate(tournament.additionalEstimationDuration) { |
|
|
|
|
Image(systemName: "arrowshape.forward.fill") |
|
|
|
|
Text(estimatedEndDate.formattedAsHourMinute()).font(.title3) |
|
|
|
|
LabeledContent { |
|
|
|
|
let count = round.loserRounds().filter({ $0.isDisabled() == false }).count |
|
|
|
|
Text(count.formatted() + " tour" + count.pluralSuffix) |
|
|
|
|
} label: { |
|
|
|
|
if let startDate = round.getLoserRoundStartDate() { |
|
|
|
|
HStack { |
|
|
|
|
Text(startDate.formattedAsHourMinute()).font(.title3) |
|
|
|
|
if let estimatedEndDate = round.estimatedLoserRoundEndDate(tournament.additionalEstimationDuration) { |
|
|
|
|
Image(systemName: "arrowshape.forward.fill") |
|
|
|
|
Text(estimatedEndDate.formattedAsHourMinute()).font(.title3) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
Text(startDate.formattedAsDate()) |
|
|
|
|
} else { |
|
|
|
|
Text("Aucun horaire") |
|
|
|
|
} |
|
|
|
|
Text(startDate.formattedAsDate()) |
|
|
|
|
} else { |
|
|
|
|
Text("Aucun horaire") |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} header: { |
|
|
|
|
Text("Match de classement \(round.roundTitle(.short))") |
|
|
|
|
} footer: { |
|
|
|
|
if round.index == 1, let semi = round.loserRounds().first { |
|
|
|
|
let federalFormat = tournament.loserBracketSmartMatchFormat(1) |
|
|
|
|
if semi.matchFormat.weight > federalFormat.weight { |
|
|
|
|
Button { |
|
|
|
|
round.updateMatchFormatAndAllMatches(federalFormat) |
|
|
|
|
do { |
|
|
|
|
try dataStore.rounds.addOrUpdate(instance: round) |
|
|
|
|
} catch { |
|
|
|
|
Logger.error(error) |
|
|
|
|
} |
|
|
|
|
} label: { |
|
|
|
|
Text("devrait être joué au moins en " + federalFormat.format + ", ") + Text("modifier ?").underline().foregroundStyle(.master) |
|
|
|
|
} |
|
|
|
|
.buttonStyle(.plain) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} header: { |
|
|
|
|
Text("Match de classement \(round.roundTitle(.short))") |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|