|
|
|
@ -21,7 +21,9 @@ struct PlanningSettingsView: View { |
|
|
|
@State private var showOptions: Bool = false |
|
|
|
@State private var showOptions: Bool = false |
|
|
|
@State private var issueFound: Bool = false |
|
|
|
@State private var issueFound: Bool = false |
|
|
|
@State private var parallelType: Bool = false |
|
|
|
@State private var parallelType: Bool = false |
|
|
|
|
|
|
|
@State private var deletingDateMatchesDone: Bool = false |
|
|
|
|
|
|
|
@State private var deletingDone: Bool = false |
|
|
|
|
|
|
|
|
|
|
|
var tournamentStore: TournamentStore { |
|
|
|
var tournamentStore: TournamentStore { |
|
|
|
return self.tournament.tournamentStore |
|
|
|
return self.tournament.tournamentStore |
|
|
|
} |
|
|
|
} |
|
|
|
@ -121,11 +123,13 @@ struct PlanningSettingsView: View { |
|
|
|
Section { |
|
|
|
Section { |
|
|
|
RowButtonView("Supprimer les horaires des matches", role: .destructive) { |
|
|
|
RowButtonView("Supprimer les horaires des matches", role: .destructive) { |
|
|
|
do { |
|
|
|
do { |
|
|
|
|
|
|
|
deletingDateMatchesDone = false |
|
|
|
allMatches.forEach({ |
|
|
|
allMatches.forEach({ |
|
|
|
$0.startDate = nil |
|
|
|
$0.startDate = nil |
|
|
|
$0.confirmed = false |
|
|
|
$0.confirmed = false |
|
|
|
}) |
|
|
|
}) |
|
|
|
try self.tournamentStore.matches.addOrUpdate(contentOfs: allMatches) |
|
|
|
try self.tournamentStore.matches.addOrUpdate(contentOfs: allMatches) |
|
|
|
|
|
|
|
deletingDateMatchesDone = true |
|
|
|
} catch { |
|
|
|
} catch { |
|
|
|
Logger.error(error) |
|
|
|
Logger.error(error) |
|
|
|
} |
|
|
|
} |
|
|
|
@ -137,7 +141,8 @@ struct PlanningSettingsView: View { |
|
|
|
Section { |
|
|
|
Section { |
|
|
|
RowButtonView("Supprimer tous les horaires", role: .destructive) { |
|
|
|
RowButtonView("Supprimer tous les horaires", role: .destructive) { |
|
|
|
do { |
|
|
|
do { |
|
|
|
allMatches.forEach({ |
|
|
|
deletingDone = false |
|
|
|
|
|
|
|
allMatches.forEach({ |
|
|
|
$0.startDate = nil |
|
|
|
$0.startDate = nil |
|
|
|
$0.confirmed = false |
|
|
|
$0.confirmed = false |
|
|
|
}) |
|
|
|
}) |
|
|
|
@ -148,6 +153,7 @@ struct PlanningSettingsView: View { |
|
|
|
|
|
|
|
|
|
|
|
allRounds.forEach({ $0.startDate = nil }) |
|
|
|
allRounds.forEach({ $0.startDate = nil }) |
|
|
|
try self.tournamentStore.rounds.addOrUpdate(contentOfs: allRounds) |
|
|
|
try self.tournamentStore.rounds.addOrUpdate(contentOfs: allRounds) |
|
|
|
|
|
|
|
deletingDone = true |
|
|
|
} catch { |
|
|
|
} catch { |
|
|
|
Logger.error(error) |
|
|
|
Logger.error(error) |
|
|
|
} |
|
|
|
} |
|
|
|
@ -196,6 +202,14 @@ struct PlanningSettingsView: View { |
|
|
|
.toastFormatted() |
|
|
|
.toastFormatted() |
|
|
|
.deferredRendering(for: .seconds(2)) |
|
|
|
.deferredRendering(for: .seconds(2)) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} else if deletingDone { |
|
|
|
|
|
|
|
Label("Tous les horaires ont été supprimés", systemImage: "clock.badge.xmark.fill") |
|
|
|
|
|
|
|
.toastFormatted() |
|
|
|
|
|
|
|
.deferredRendering(for: .seconds(2)) |
|
|
|
|
|
|
|
} else if deletingDateMatchesDone { |
|
|
|
|
|
|
|
Label("Horaires des matchs supprimés", systemImage: "clock.badge.xmark.fill") |
|
|
|
|
|
|
|
.toastFormatted() |
|
|
|
|
|
|
|
.deferredRendering(for: .seconds(2)) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
.onChange(of: tournament.startDate) { |
|
|
|
.onChange(of: tournament.startDate) { |
|
|
|
|