|
|
|
|
@ -22,9 +22,15 @@ struct PlanningView: View { |
|
|
|
|
let updatePlannedDatesTip = UpdatePlannedDatesTip() |
|
|
|
|
let allMatches: [Match] |
|
|
|
|
let timeSlotMoveOptionTip = TimeSlotMoveOptionTip() |
|
|
|
|
let event: Event? |
|
|
|
|
|
|
|
|
|
init(matches: [Match], selectedScheduleDestination: Binding<ScheduleDestination?>) { |
|
|
|
|
self.allMatches = matches |
|
|
|
|
init(matches: [Match], selectedScheduleDestination: Binding<ScheduleDestination?>, event: Event? = nil) { |
|
|
|
|
self.event = event |
|
|
|
|
if let event { |
|
|
|
|
self.allMatches = event.confirmedTournaments().flatMap { $0.allMatches() } |
|
|
|
|
} else { |
|
|
|
|
self.allMatches = matches |
|
|
|
|
} |
|
|
|
|
_selectedScheduleDestination = selectedScheduleDestination |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -132,6 +138,24 @@ struct PlanningView: View { |
|
|
|
|
} else { |
|
|
|
|
ToolbarItemGroup(placement: .topBarTrailing) { |
|
|
|
|
Menu { |
|
|
|
|
if let event { |
|
|
|
|
Menu { |
|
|
|
|
Button { |
|
|
|
|
event.confirmedTournaments().forEach { tournament in |
|
|
|
|
tournament.removeAllDates() |
|
|
|
|
} |
|
|
|
|
} label: { |
|
|
|
|
Text("Effacer tous les horaires") |
|
|
|
|
} |
|
|
|
|
Button { |
|
|
|
|
_planEvent(event: event) |
|
|
|
|
} label: { |
|
|
|
|
Text("Planifier") |
|
|
|
|
} |
|
|
|
|
} label: { |
|
|
|
|
Text("Planifier l'événement") |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if notSlots == false { |
|
|
|
|
CourtOptionsView(timeSlots: timeSlots, underlined: false) |
|
|
|
|
Toggle(isOn: $enableMove) { |
|
|
|
|
@ -226,11 +250,26 @@ struct PlanningView: View { |
|
|
|
|
RowButtonView("Horaire intelligent") { |
|
|
|
|
selectedScheduleDestination = nil |
|
|
|
|
} |
|
|
|
|
} else if let event { |
|
|
|
|
RowButtonView("Planifier automatiquement") { |
|
|
|
|
_planEvent(event: event) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private func _planEvent(event: Event) { |
|
|
|
|
event.confirmedTournaments().forEach { tournament in |
|
|
|
|
if let matchScheduler = tournament.matchScheduler() { |
|
|
|
|
_ = matchScheduler.updateSchedule(tournament: tournament) |
|
|
|
|
} else { |
|
|
|
|
let matchScheduler = MatchScheduler(tournament: tournament.id, courtsAvailable: Set(tournament.courtsAvailable())) |
|
|
|
|
_ = matchScheduler.updateSchedule(tournament: tournament) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
struct BySlotView: View { |
|
|
|
|
@Environment(\.filterOption) private var filterOption |
|
|
|
|
|