fix match dispatcher

multistore
Razmig Sarkissian 2 years ago
parent 3a2d242e13
commit 69dcc5a16d
  1. 41
      PadelClub/ViewModel/MatchScheduler.swift
  2. 2
      PadelClub/Views/Calling/CallView.swift
  3. 4
      PadelClub/Views/Planning/Components/DateUpdateManagerView.swift
  4. 5
      PadelClub/Views/Planning/GroupStageScheduleEditorView.swift
  5. 4
      PadelClub/Views/Planning/LoserRoundScheduleEditorView.swift
  6. 2
      PadelClub/Views/Planning/LoserRoundStepScheduleEditorView.swift
  7. 1
      PadelClub/Views/Planning/RoundScheduleEditorView.swift
  8. 1
      PadelClub/Views/Planning/SchedulerView.swift

@ -494,22 +494,41 @@ class MatchScheduler {
}
})
if let roundId {
if let round : Round = Store.main.findById(roundId) {
let matches = round._matches()
round.resetFromRoundAllMatchesStartDate()
flattenedMatches = matches + flattenedMatches
// if let roundId {
// if let round : Round = Store.main.findById(roundId) {
// let matches = round._matches().filter({ $0.disabled == false }).sorted(by: \.index)
// round.resetFromRoundAllMatchesStartDate()
// flattenedMatches = matches + flattenedMatches
// }
//
// } else if let matchId {
// if let match : Match = Store.main.findById(matchId) {
// if let round = match.roundObject {
// round.resetFromRoundAllMatchesStartDate(from: match)
// }
// flattenedMatches = [match] + flattenedMatches
// }
// }
if let roundId, let matchId {
//todo
if let index = flattenedMatches.firstIndex(where: { $0.round == roundId && $0.id == matchId }) {
flattenedMatches[index...].forEach {
$0.startDate = nil
$0.removeCourt()
}
}
} else if let matchId {
if let match : Match = Store.main.findById(matchId) {
if let round = match.roundObject {
round.resetFromRoundAllMatchesStartDate(from: match)
} else if let roundId {
//todo
if let index = flattenedMatches.firstIndex(where: { $0.round == roundId }) {
flattenedMatches[index...].forEach {
$0.startDate = nil
$0.removeCourt()
}
flattenedMatches = [match] + flattenedMatches
}
}
let usedCourts = getAvailableCourts(from: allMatches.filter({ $0.startDate?.isEarlierThan(startDate) == true && $0.startDate?.dayInt == startDate.dayInt }))
let initialCourts = usedCourts.filter { (court, availableDate) in
availableDate <= startDate

@ -84,7 +84,7 @@ struct CallView: View {
var body: some View {
let callWord = teams.allSatisfy({ $0.called() }) ? "Reconvoquer" : "Convoquer"
HStack(spacing: 0.0) {
HStack {
if teams.count == 1 {
if let previousCallDate = teams.first?.callDate, Calendar.current.compare(previousCallDate, to: callDate, toGranularity: .minute) != .orderedSame {
Text("Reconvoquer " + callDate.localizedDate() + " par")

@ -47,12 +47,12 @@ struct DateUpdateManagerView: View {
Spacer()
if dateUpdated {
FooterButtonView("valider la modification") {
FooterButtonView("valider l'horaire") {
validateAction()
dateUpdated = false
}
} else if currentDate != nil {
FooterButtonView("horaire automatique") {
FooterButtonView("retirer l'horaire") {
currentDate = nil
}
}

@ -12,7 +12,8 @@ struct GroupStageScheduleEditorView: View {
@Bindable var groupStage: GroupStage
var tournament: Tournament
@State private var startDate: Date
@State private var uuid: UUID = UUID()
init(groupStage: GroupStage, tournament: Tournament) {
self.groupStage = groupStage
self.tournament = tournament
@ -31,8 +32,10 @@ struct GroupStageScheduleEditorView: View {
DateUpdateManagerView(startDate: $startDate, currentDate: $groupStage.startDate, duration: groupStage.matchFormat.getEstimatedDuration(tournament.additionalEstimationDuration)) {
groupStage.startDate = startDate
_save()
uuid = UUID()
}
}
.id(uuid)
}

@ -43,11 +43,13 @@ struct LoserRoundScheduleEditorView: View {
ForEach(enabledLoserRounds.indices, id: \.self) { index in
let loserRound = enabledLoserRounds[index]
LoserRoundStepScheduleEditorView(stepIndex: index, round: loserRound, upperRound: upperRound)
.id(UUID())
}
}
.onChange(of: matchFormat) {
loserRounds.forEach { round in
round.updateIfRequiredMatchFormat(matchFormat, andLoserBracket: true)
round.updateMatchFormatAndAllMatches(matchFormat)
//round.updateIfRequiredMatchFormat(matchFormat, andLoserBracket: true)
}
_save()
}

@ -61,7 +61,7 @@ struct LoserRoundStepScheduleEditorView: View {
}
.headerProminence(.increased)
.onChange(of: matchFormat) {
round.updateIfRequiredMatchFormat(matchFormat, andLoserBracket: true)
round.updateMatchFormatAndAllMatches(matchFormat)
_save()
}
.onChange(of: round.startDate) {

@ -35,6 +35,7 @@ struct RoundScheduleEditorView: View {
ForEach(round.playedMatches()) { match in
MatchScheduleEditorView(match: match)
.id(UUID())
}
}
.navigationBarTitleDisplayMode(.inline)

@ -48,6 +48,7 @@ struct SchedulerView: View {
}
ForEach(tournament.groupStages()) {
GroupStageScheduleEditorView(groupStage: $0, tournament: tournament)
.id(UUID())
}
case .scheduleBracket:
ForEach(tournament.rounds()) { round in

Loading…
Cancel
Save