club_update
Razmig Sarkissian 1 year ago
parent 443d06be74
commit 04499515d7
  1. 4
      PadelClub/Data/Round.swift
  2. 3
      PadelClub/Views/Round/RoundSettingsView.swift
  3. 13
      PadelClub/Views/Tournament/Screen/TournamentRankView.swift
  4. 26
      PadelClub/Views/Tournament/TournamentBuildView.swift
  5. 4
      PadelClub/Views/Tournament/TournamentRunningView.swift

@ -179,7 +179,7 @@ defer {
return previousMatch.teams().first return previousMatch.teams().first
} }
} else if let parent = upperBracketTopMatch(ofMatchIndex: match.index, previousRound: previousRound)?.losingTeamId { } else if let parent = upperBracketTopMatch(ofMatchIndex: match.index, previousRound: previousRound)?.losingTeamId {
return Store.main.findById(parent) return tournamentStore.findById(parent)
} }
case .two: case .two:
if let luckyLoser = match.teamScores.first(where: { $0.luckyLoser == match.index * 2 + 1 }) { if let luckyLoser = match.teamScores.first(where: { $0.luckyLoser == match.index * 2 + 1 }) {
@ -191,7 +191,7 @@ defer {
return previousMatch.teams().first return previousMatch.teams().first
} }
} else if let parent = upperBracketBottomMatch(ofMatchIndex: match.index, previousRound: previousRound)?.losingTeamId { } else if let parent = upperBracketBottomMatch(ofMatchIndex: match.index, previousRound: previousRound)?.losingTeamId {
return Store.main.findById(parent) return tournamentStore.findById(parent)
} }
} }

@ -100,8 +100,7 @@ struct RoundSettingsView: View {
var currentIndex = 0 var currentIndex = 0
let matches = (0..<matchCount).map { index in //0 is final match let matches = (0..<matchCount).map { index in //0 is final match
let match = Match(round: round.id, index: index + matchStartIndex, matchFormat: round.matchFormat) let match = Match(round: round.id, index: index + matchStartIndex, matchFormat: round.matchFormat)
if let nextRound, let followingMatch = self.tournament.tournamentStore.matches.first(where: { $0.round == nextRound.id && $0.index == (index - 1) / 2 }) {
if let nextRound, let followingMatch = match.getFollowingMatch(fromNextRoundId: nextRound.id) {
if followingMatch.disabled { if followingMatch.disabled {
match.disabled = true match.disabled = true
} else if index%2 == 1 && followingMatch.team(.one) != nil { } else if index%2 == 1 && followingMatch.team(.one) != nil {

@ -168,18 +168,16 @@ struct TournamentRankView: View {
VStack(spacing: 0) { VStack(spacing: 0) {
if editMode?.wrappedValue.isEditing == true { if editMode?.wrappedValue.isEditing == true {
if key > 1 { if key > 1 {
Button { FooterButtonView("monter") {
key -= 1 key -= 1
team.finalRanking = key team.finalRanking = key
team.pointsEarned = tournament.isAnimation() ? nil : tournament.tournamentLevel.points(for: key - 1, count: tournament.teamCount)
do { do {
try self.tournament.tournamentStore.teamRegistrations.addOrUpdate(instance: team) try self.tournament.tournamentStore.teamRegistrations.addOrUpdate(instance: team)
} catch { } catch {
Logger.error(error) Logger.error(error)
} }
} label: {
Label("descendre", systemImage: "chevron.compact.up").labelStyle(.iconOnly)
} }
.buttonStyle(.bordered)
} }
} }
@ -259,18 +257,17 @@ struct TournamentRankView: View {
.buttonStyle(.plain) .buttonStyle(.plain)
if editMode?.wrappedValue.isEditing == true { if editMode?.wrappedValue.isEditing == true {
Button { FooterButtonView("descendre") {
key += 1 key += 1
team.finalRanking = key team.finalRanking = key
team.pointsEarned = tournament.isAnimation() ? nil : tournament.tournamentLevel.points(for: key - 1, count: tournament.teamCount)
do { do {
try self.tournament.tournamentStore.teamRegistrations.addOrUpdate(instance: team) try self.tournament.tournamentStore.teamRegistrations.addOrUpdate(instance: team)
} catch { } catch {
Logger.error(error) Logger.error(error)
} }
} label: {
Label("descendre", systemImage: "chevron.compact.down").labelStyle(.iconOnly)
} }
.buttonStyle(.bordered)
} }
} }
.alert("Position", isPresented: $isEditingTeam) { .alert("Position", isPresented: $isEditingTeam) {

@ -91,12 +91,38 @@ struct TournamentBuildView: View {
Section { Section {
#if DEBUG #if DEBUG
NavigationLink(value: Screen.rankings) { NavigationLink(value: Screen.rankings) {
LabeledContent {
if tournament.publishRankings == false {
Image(systemName: "exclamationmark.circle.fill")
.foregroundStyle(.logoYellow)
} else {
Image(systemName: "checkmark")
.foregroundStyle(.green)
}
} label: {
Text("Classement final des équipes") Text("Classement final des équipes")
if tournament.publishRankings == false {
Text("Vérifiez le classement avant de publier").foregroundStyle(.red)
}
}
} }
#else #else
if tournament.hasEnded() { if tournament.hasEnded() {
NavigationLink(value: Screen.rankings) { NavigationLink(value: Screen.rankings) {
LabeledContent {
if tournament.publishRankings == false {
Image(systemName: "exclamationmark.circle.fill")
.foregroundStyle(.logoYellow)
} else {
Image(systemName: "checkmark")
.foregroundStyle(.green)
}
} label: {
Text("Classement final des équipes") Text("Classement final des équipes")
if tournament.publishRankings == false {
Text("Vérifiez le classement avant de publier").foregroundStyle(.red)
}
}
} }
} }
#endif #endif

@ -18,10 +18,10 @@ struct TournamentRunningView: View {
@ViewBuilder @ViewBuilder
var body: some View { var body: some View {
MatchListView(section: "en cours", matches: tournament.runningMatches(allMatches)) MatchListView(section: "en cours", matches: tournament.runningMatches(allMatches), hideWhenEmpty: tournament.hasEnded())
// MatchListView(section: "à lancer", matches: tournament.readyMatches(allMatches), isExpanded: false) // MatchListView(section: "à lancer", matches: tournament.readyMatches(allMatches), isExpanded: false)
// MatchListView(section: "disponible", matches: tournament.availableToStart(allMatches), isExpanded: false) // MatchListView(section: "disponible", matches: tournament.availableToStart(allMatches), isExpanded: false)
MatchListView(section: "terminés", matches: tournament.finishedMatches(allMatches), isExpanded: false) MatchListView(section: "terminés", matches: tournament.finishedMatches(allMatches), isExpanded: tournament.hasEnded())
} }
} }

Loading…
Cancel
Save