|
|
|
|
@ -9,12 +9,22 @@ import SwiftUI |
|
|
|
|
import TipKit |
|
|
|
|
import LeStorage |
|
|
|
|
|
|
|
|
|
let slideToDeleteTip = SlideToDeleteTip() |
|
|
|
|
let inscriptionManagerWomanRankTip = InscriptionManagerWomanRankTip() |
|
|
|
|
let fileTip = InscriptionManagerFileInputTip() |
|
|
|
|
let pasteTip = InscriptionManagerPasteInputTip() |
|
|
|
|
let searchTip = InscriptionManagerSearchInputTip() |
|
|
|
|
let createTip = InscriptionManagerCreateInputTip() |
|
|
|
|
let rankUpdateTip = InscriptionManagerRankUpdateTip() |
|
|
|
|
let padelBeachExportTip = PadelBeachExportTip() |
|
|
|
|
let padelBeachImportTip = PadelBeachImportTip() |
|
|
|
|
|
|
|
|
|
struct InscriptionManagerView: View { |
|
|
|
|
@EnvironmentObject var dataStore: DataStore |
|
|
|
|
@EnvironmentObject var networkMonitor: NetworkMonitor |
|
|
|
|
|
|
|
|
|
@FetchRequest( |
|
|
|
|
sortDescriptors: [NSSortDescriptor(keyPath: \ImportedPlayer.rank, ascending: true)], |
|
|
|
|
sortDescriptors: [], |
|
|
|
|
animation: .default) |
|
|
|
|
private var fetchPlayers: FetchedResults<ImportedPlayer> |
|
|
|
|
|
|
|
|
|
@ -41,6 +51,13 @@ struct InscriptionManagerView: View { |
|
|
|
|
@State private var contactType: ContactType? = nil |
|
|
|
|
@State private var sentError: ContactManagerError? = nil |
|
|
|
|
@State private var showSubscriptionView: Bool = false |
|
|
|
|
@State private var registrationIssues: Int? = nil |
|
|
|
|
@State private var sortedTeams: [TeamRegistration] = [] |
|
|
|
|
@State private var unfilteredTeams: [TeamRegistration] = [] |
|
|
|
|
@State private var walkoutTeams: [TeamRegistration] = [] |
|
|
|
|
@State private var unsortedTeamsWithoutWO: [TeamRegistration] = [] |
|
|
|
|
@State private var unsortedPlayers: [PlayerRegistration] = [] |
|
|
|
|
@State private var teamPaste: URL? |
|
|
|
|
|
|
|
|
|
var messageSentFailed: Binding<Bool> { |
|
|
|
|
Binding { |
|
|
|
|
@ -83,19 +100,8 @@ struct InscriptionManagerView: View { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
let slideToDeleteTip = SlideToDeleteTip() |
|
|
|
|
let inscriptionManagerWomanRankTip = InscriptionManagerWomanRankTip() |
|
|
|
|
let fileTip = InscriptionManagerFileInputTip() |
|
|
|
|
let pasteTip = InscriptionManagerPasteInputTip() |
|
|
|
|
let searchTip = InscriptionManagerSearchInputTip() |
|
|
|
|
let createTip = InscriptionManagerCreateInputTip() |
|
|
|
|
let rankUpdateTip = InscriptionManagerRankUpdateTip() |
|
|
|
|
let padelBeachExportTip = PadelBeachExportTip() |
|
|
|
|
let padelBeachImportTip = PadelBeachImportTip() |
|
|
|
|
|
|
|
|
|
let categoryOption: PlayerFilterOption |
|
|
|
|
let filterable: Bool |
|
|
|
|
let dates = Set(SourceFileManager.shared.allFilesSortedByDate(true).map({ $0.dateFromPath })).sorted().reversed() |
|
|
|
|
|
|
|
|
|
init(tournament: Tournament) { |
|
|
|
|
self.tournament = tournament |
|
|
|
|
@ -110,6 +116,16 @@ struct InscriptionManagerView: View { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private func _clearScreen() { |
|
|
|
|
teamPaste = nil |
|
|
|
|
unsortedPlayers.removeAll() |
|
|
|
|
unfilteredTeams.removeAll() |
|
|
|
|
walkoutTeams.removeAll() |
|
|
|
|
unsortedTeamsWithoutWO.removeAll() |
|
|
|
|
sortedTeams.removeAll() |
|
|
|
|
registrationIssues = nil |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Function to create a simple hash from a list of IDs |
|
|
|
|
private func _simpleHash(ids: [String]) -> Int { |
|
|
|
|
// Combine the hash values of each string |
|
|
|
|
@ -121,7 +137,43 @@ struct InscriptionManagerView: View { |
|
|
|
|
return _simpleHash(ids: ids1) != _simpleHash(ids: ids2) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private func _setHash() async { |
|
|
|
|
let start = Date() |
|
|
|
|
defer { |
|
|
|
|
let duration = Duration.milliseconds(Date().timeIntervalSince(start) * 1_000) |
|
|
|
|
print("func _setHash", duration.formatted(.units(allowed: [.seconds, .milliseconds]))) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
let selectedSortedTeams = tournament.selectedSortedTeams() |
|
|
|
|
if self.teamsHash == nil, selectedSortedTeams.isEmpty == false { |
|
|
|
|
self.teamsHash = _simpleHash(ids: selectedSortedTeams.map { $0.id }) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private func _handleHashDiff() async { |
|
|
|
|
let newHash = _simpleHash(ids: tournament.selectedSortedTeams().map { $0.id }) |
|
|
|
|
if let teamsHash, newHash != teamsHash { |
|
|
|
|
self.teamsHash = newHash |
|
|
|
|
if self.tournament.shouldVerifyBracket == false || self.tournament.shouldVerifyGroupStage == false { |
|
|
|
|
self.tournament.shouldVerifyBracket = true |
|
|
|
|
self.tournament.shouldVerifyGroupStage = true |
|
|
|
|
|
|
|
|
|
let waitingList = self.tournament.waitingListTeams(in: self.tournament.selectedSortedTeams()) |
|
|
|
|
waitingList.forEach { team in |
|
|
|
|
if team.bracketPosition != nil || team.groupStagePosition != nil { |
|
|
|
|
team.resetPositions() |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
do { |
|
|
|
|
try dataStore.teamRegistrations.addOrUpdate(contentOfs: waitingList) |
|
|
|
|
try dataStore.tournaments.addOrUpdate(instance: tournament) |
|
|
|
|
} catch { |
|
|
|
|
Logger.error(error) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
var body: some View { |
|
|
|
|
VStack(spacing: 0) { |
|
|
|
|
@ -130,38 +182,16 @@ struct InscriptionManagerView: View { |
|
|
|
|
_buildingTeamView() |
|
|
|
|
} else if tournament.unsortedTeams().isEmpty { |
|
|
|
|
_inscriptionTipsView() |
|
|
|
|
} else { |
|
|
|
|
_teamRegisteredView() |
|
|
|
|
} |
|
|
|
|
_teamRegisteredView() |
|
|
|
|
} |
|
|
|
|
.onAppear { |
|
|
|
|
let selectedSortedTeams = tournament.selectedSortedTeams() |
|
|
|
|
if self.teamsHash == nil, selectedSortedTeams.isEmpty == false { |
|
|
|
|
self.teamsHash = _simpleHash(ids: selectedSortedTeams.map { $0.id }) |
|
|
|
|
} |
|
|
|
|
_getTeams() |
|
|
|
|
} |
|
|
|
|
.onDisappear { |
|
|
|
|
let newHash = _simpleHash(ids: tournament.selectedSortedTeams().map { $0.id }) |
|
|
|
|
if let teamsHash, newHash != teamsHash { |
|
|
|
|
self.teamsHash = newHash |
|
|
|
|
if self.tournament.shouldVerifyBracket == false || self.tournament.shouldVerifyGroupStage == false { |
|
|
|
|
self.tournament.shouldVerifyBracket = true |
|
|
|
|
self.tournament.shouldVerifyGroupStage = true |
|
|
|
|
|
|
|
|
|
let waitingList = self.tournament.waitingListTeams(in: self.tournament.selectedSortedTeams()) |
|
|
|
|
waitingList.forEach { team in |
|
|
|
|
if team.bracketPosition != nil || team.groupStagePosition != nil { |
|
|
|
|
team.resetPositions() |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
Task { |
|
|
|
|
await _handleHashDiff() |
|
|
|
|
|
|
|
|
|
do { |
|
|
|
|
try dataStore.teamRegistrations.addOrUpdate(contentOfs: waitingList) |
|
|
|
|
try dataStore.tournaments.addOrUpdate(instance: tournament) |
|
|
|
|
} catch { |
|
|
|
|
Logger.error(error) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
.alert("Un problème est survenu", isPresented: messageSentFailed) { |
|
|
|
|
@ -258,10 +288,14 @@ struct InscriptionManagerView: View { |
|
|
|
|
.tint(.master) |
|
|
|
|
} |
|
|
|
|
.onChange(of: tournament.prioritizeClubMembers) { |
|
|
|
|
_clearScreen() |
|
|
|
|
_save() |
|
|
|
|
_getTeams() |
|
|
|
|
} |
|
|
|
|
.onChange(of: tournament.teamSorting) { |
|
|
|
|
_clearScreen() |
|
|
|
|
_save() |
|
|
|
|
_getTeams() |
|
|
|
|
} |
|
|
|
|
.onChange(of: currentRankSourceDate) { |
|
|
|
|
if let currentRankSourceDate, tournament.rankSourceDate != currentRankSourceDate { |
|
|
|
|
@ -334,8 +368,10 @@ struct InscriptionManagerView: View { |
|
|
|
|
Label("Clôturer", systemImage: "lock") |
|
|
|
|
} |
|
|
|
|
Divider() |
|
|
|
|
ShareLink(item: tournament.pasteDataForImporting().createTxtFile(self.tournament.tournamentTitle(.short))) { |
|
|
|
|
Label("Exporter les paires", systemImage: "square.and.arrow.up") |
|
|
|
|
if let teamPaste { |
|
|
|
|
ShareLink(item: teamPaste) { |
|
|
|
|
Label("Exporter les paires", systemImage: "square.and.arrow.up") |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
Button { |
|
|
|
|
presentImportView = true |
|
|
|
|
@ -373,7 +409,28 @@ struct InscriptionManagerView: View { |
|
|
|
|
createdPlayerIds.isEmpty == false || editedTeam != nil || pasteString != nil |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private func _getTeams(from sortedTeams: [TeamRegistration]) -> [TeamRegistration] { |
|
|
|
|
private func _prepareStats() async { |
|
|
|
|
let start = Date() |
|
|
|
|
defer { |
|
|
|
|
let duration = Duration.milliseconds(Date().timeIntervalSince(start) * 1_000) |
|
|
|
|
print("func _prepareStats", duration.formatted(.units(allowed: [.seconds, .milliseconds]))) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
unsortedPlayers = tournament.unsortedPlayers() |
|
|
|
|
walkoutTeams = tournament.walkoutTeams() |
|
|
|
|
unsortedTeamsWithoutWO = tournament.unsortedTeamsWithoutWO() |
|
|
|
|
teamPaste = tournament.pasteDataForImporting().createTxtFile(self.tournament.tournamentTitle(.short)) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private func _prepareTeams() { |
|
|
|
|
let start = Date() |
|
|
|
|
defer { |
|
|
|
|
let duration = Duration.milliseconds(Date().timeIntervalSince(start) * 1_000) |
|
|
|
|
print("func _prepareTeams", duration.formatted(.units(allowed: [.seconds, .milliseconds]))) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
sortedTeams = tournament.sortedTeams() |
|
|
|
|
|
|
|
|
|
var teams = sortedTeams |
|
|
|
|
if filterMode == .walkOut { |
|
|
|
|
teams = teams.filter({ $0.walkOut }) |
|
|
|
|
@ -384,17 +441,32 @@ struct InscriptionManagerView: View { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if byDecreasingOrdering { |
|
|
|
|
return teams.reversed() |
|
|
|
|
self.unfilteredTeams = teams.reversed() |
|
|
|
|
} else { |
|
|
|
|
return teams |
|
|
|
|
self.unfilteredTeams = teams |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private func _getIssues() async { |
|
|
|
|
let start = Date() |
|
|
|
|
defer { |
|
|
|
|
let duration = Duration.milliseconds(Date().timeIntervalSince(start) * 1_000) |
|
|
|
|
print("func _getIssues", duration.formatted(.units(allowed: [.seconds, .milliseconds]))) |
|
|
|
|
} |
|
|
|
|
await registrationIssues = tournament.registrationIssues() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private func _getTeams() { |
|
|
|
|
_prepareTeams() |
|
|
|
|
Task { |
|
|
|
|
await _prepareStats() |
|
|
|
|
await _getIssues() |
|
|
|
|
await _setHash() |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private func _teamRegisteredView() -> some View { |
|
|
|
|
List { |
|
|
|
|
let sortedTeams = tournament.sortedTeams() |
|
|
|
|
let unfilteredTeams = _getTeams(from: sortedTeams) |
|
|
|
|
|
|
|
|
|
if presentSearch == false { |
|
|
|
|
_rankHandlerView() |
|
|
|
|
_relatedTips() |
|
|
|
|
@ -418,6 +490,7 @@ struct InscriptionManagerView: View { |
|
|
|
|
Task { |
|
|
|
|
await MainActor.run() { |
|
|
|
|
fetchPlayers.nsPredicate = _pastePredicate(pasteField: searchField, mostRecentDate: SourceFileManager.shared.mostRecentDateAvailable) |
|
|
|
|
fetchPlayers.nsSortDescriptors = [NSSortDescriptor(keyPath: \ImportedPlayer.rank, ascending: true)] |
|
|
|
|
pasteString = searchField |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
@ -474,6 +547,7 @@ struct InscriptionManagerView: View { |
|
|
|
|
Task { |
|
|
|
|
await MainActor.run { |
|
|
|
|
fetchPlayers.nsPredicate = _pastePredicate(pasteField: first, mostRecentDate: SourceFileManager.shared.mostRecentDateAvailable) |
|
|
|
|
fetchPlayers.nsSortDescriptors = [NSSortDescriptor(keyPath: \ImportedPlayer.rank, ascending: true)] |
|
|
|
|
pasteString = first |
|
|
|
|
autoSelect = true |
|
|
|
|
} |
|
|
|
|
@ -504,6 +578,8 @@ struct InscriptionManagerView: View { |
|
|
|
|
@ViewBuilder |
|
|
|
|
func rankingDateSourcePickerView(showDateInLabel: Bool) -> some View { |
|
|
|
|
Section { |
|
|
|
|
let dates = Set(SourceFileManager.shared.allFilesSortedByDate(true).map({ $0.dateFromPath })).sorted().reversed() |
|
|
|
|
|
|
|
|
|
Picker(selection: $currentRankSourceDate) { |
|
|
|
|
if currentRankSourceDate == nil { |
|
|
|
|
Text("inconnu").tag(nil as Date?) |
|
|
|
|
@ -571,6 +647,7 @@ struct InscriptionManagerView: View { |
|
|
|
|
Task { |
|
|
|
|
await MainActor.run { |
|
|
|
|
fetchPlayers.nsPredicate = _pastePredicate(pasteField: paste, mostRecentDate: SourceFileManager.shared.mostRecentDateAvailable) |
|
|
|
|
fetchPlayers.nsSortDescriptors = [NSSortDescriptor(keyPath: \ImportedPlayer.rank, ascending: true)] |
|
|
|
|
pasteString = paste |
|
|
|
|
autoSelect = true |
|
|
|
|
} |
|
|
|
|
@ -621,9 +698,6 @@ struct InscriptionManagerView: View { |
|
|
|
|
|
|
|
|
|
private func _informationView(count: Int) -> some View { |
|
|
|
|
Section { |
|
|
|
|
let walkoutTeams = tournament.walkoutTeams() |
|
|
|
|
let unsortedTeamsWithoutWO = tournament.unsortedTeamsWithoutWO() |
|
|
|
|
|
|
|
|
|
LabeledContent { |
|
|
|
|
Text(unsortedTeamsWithoutWO.count.formatted() + "/" + tournament.teamCount.formatted()).font(.largeTitle) |
|
|
|
|
} label: { |
|
|
|
|
@ -647,7 +721,11 @@ struct InscriptionManagerView: View { |
|
|
|
|
.environment(tournament) |
|
|
|
|
} label: { |
|
|
|
|
LabeledContent { |
|
|
|
|
Text(tournament.registrationIssues().formatted()).font(.largeTitle) |
|
|
|
|
if let registrationIssues { |
|
|
|
|
Text(registrationIssues.formatted()).font(.largeTitle) |
|
|
|
|
} else { |
|
|
|
|
ProgressView() |
|
|
|
|
} |
|
|
|
|
} label: { |
|
|
|
|
Text("Problèmes détéctés") |
|
|
|
|
if let closedRegistrationDate = tournament.closedRegistrationDate { |
|
|
|
|
@ -660,43 +738,43 @@ struct InscriptionManagerView: View { |
|
|
|
|
|
|
|
|
|
@ViewBuilder |
|
|
|
|
private func _relatedTips() -> some View { |
|
|
|
|
if pasteString == nil |
|
|
|
|
&& createdPlayerIds.isEmpty |
|
|
|
|
&& tournament.unsortedTeams().count >= tournament.teamCount |
|
|
|
|
&& tournament.unsortedPlayers().filter({ $0.source == .beachPadel }).isEmpty { |
|
|
|
|
Section { |
|
|
|
|
TipView(padelBeachExportTip) { action in |
|
|
|
|
if action.id == "more-info-export" { |
|
|
|
|
isLearningMore = true |
|
|
|
|
} |
|
|
|
|
if action.id == "padel-beach" { |
|
|
|
|
UIApplication.shared.open(URLs.beachPadel.url) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
.tipStyle(tint: nil) |
|
|
|
|
} |
|
|
|
|
Section { |
|
|
|
|
TipView(padelBeachImportTip) { action in |
|
|
|
|
if action.id == "more-info-import" { |
|
|
|
|
presentImportView = true |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
.tipStyle(tint: nil) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// if pasteString == nil |
|
|
|
|
// && createdPlayerIds.isEmpty |
|
|
|
|
// && tournament.unsortedTeams().count >= tournament.teamCount |
|
|
|
|
// && tournament.unsortedPlayers().filter({ $0.source == .beachPadel }).isEmpty { |
|
|
|
|
// Section { |
|
|
|
|
// TipView(padelBeachExportTip) { action in |
|
|
|
|
// if action.id == "more-info-export" { |
|
|
|
|
// isLearningMore = true |
|
|
|
|
// } |
|
|
|
|
// if action.id == "padel-beach" { |
|
|
|
|
// UIApplication.shared.open(URLs.beachPadel.url) |
|
|
|
|
// } |
|
|
|
|
// } |
|
|
|
|
// .tipStyle(tint: nil) |
|
|
|
|
// } |
|
|
|
|
// Section { |
|
|
|
|
// TipView(padelBeachImportTip) { action in |
|
|
|
|
// if action.id == "more-info-import" { |
|
|
|
|
// presentImportView = true |
|
|
|
|
// } |
|
|
|
|
// } |
|
|
|
|
// .tipStyle(tint: nil) |
|
|
|
|
// } |
|
|
|
|
// } |
|
|
|
|
// |
|
|
|
|
|
|
|
|
|
if tournament.tournamentCategory == .men && tournament.femalePlayers().isEmpty == false { |
|
|
|
|
if tournament.tournamentCategory == .men && unsortedPlayers.filter({ $0.isMalePlayer() == false }).isEmpty == false { |
|
|
|
|
Section { |
|
|
|
|
TipView(inscriptionManagerWomanRankTip) |
|
|
|
|
.tipStyle(tint: nil) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Section { |
|
|
|
|
TipView(slideToDeleteTip) |
|
|
|
|
.tipStyle(tint: nil) |
|
|
|
|
} |
|
|
|
|
// |
|
|
|
|
// Section { |
|
|
|
|
// TipView(slideToDeleteTip) |
|
|
|
|
// .tipStyle(tint: nil) |
|
|
|
|
// } |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private func _searchSource() -> String? { |
|
|
|
|
@ -777,6 +855,9 @@ struct InscriptionManagerView: View { |
|
|
|
|
createdPlayers.removeAll() |
|
|
|
|
createdPlayerIds.removeAll() |
|
|
|
|
pasteString = nil |
|
|
|
|
|
|
|
|
|
_clearScreen() |
|
|
|
|
_getTeams() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private func _updateTeam() { |
|
|
|
|
@ -797,6 +878,8 @@ struct InscriptionManagerView: View { |
|
|
|
|
createdPlayerIds.removeAll() |
|
|
|
|
pasteString = nil |
|
|
|
|
self.editedTeam = nil |
|
|
|
|
_clearScreen() |
|
|
|
|
_getTeams() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private func _buildingTeamView() -> some View { |
|
|
|
|
@ -999,14 +1082,19 @@ struct InscriptionManagerView: View { |
|
|
|
|
Toggle(isOn: .init(get: { |
|
|
|
|
return team.wildCardBracket |
|
|
|
|
}, set: { value in |
|
|
|
|
team.resetPositions() |
|
|
|
|
team.wildCardGroupStage = false |
|
|
|
|
team.walkOut = false |
|
|
|
|
team.wildCardBracket = value |
|
|
|
|
do { |
|
|
|
|
try dataStore.teamRegistrations.addOrUpdate(instance: team) |
|
|
|
|
} catch { |
|
|
|
|
Logger.error(error) |
|
|
|
|
_clearScreen() |
|
|
|
|
|
|
|
|
|
Task { |
|
|
|
|
team.resetPositions() |
|
|
|
|
team.wildCardGroupStage = false |
|
|
|
|
team.walkOut = false |
|
|
|
|
team.wildCardBracket = value |
|
|
|
|
do { |
|
|
|
|
try dataStore.teamRegistrations.addOrUpdate(instance: team) |
|
|
|
|
} catch { |
|
|
|
|
Logger.error(error) |
|
|
|
|
} |
|
|
|
|
_getTeams() |
|
|
|
|
} |
|
|
|
|
})) { |
|
|
|
|
Label("Wildcard Tableau", systemImage: team.wildCardBracket ? "circle.inset.filled" : "circle") |
|
|
|
|
@ -1015,14 +1103,19 @@ struct InscriptionManagerView: View { |
|
|
|
|
Toggle(isOn: .init(get: { |
|
|
|
|
return team.wildCardGroupStage |
|
|
|
|
}, set: { value in |
|
|
|
|
team.resetPositions() |
|
|
|
|
team.wildCardBracket = false |
|
|
|
|
team.walkOut = false |
|
|
|
|
team.wildCardGroupStage = value |
|
|
|
|
do { |
|
|
|
|
try dataStore.teamRegistrations.addOrUpdate(instance: team) |
|
|
|
|
} catch { |
|
|
|
|
Logger.error(error) |
|
|
|
|
_clearScreen() |
|
|
|
|
|
|
|
|
|
Task { |
|
|
|
|
team.resetPositions() |
|
|
|
|
team.wildCardBracket = false |
|
|
|
|
team.walkOut = false |
|
|
|
|
team.wildCardGroupStage = value |
|
|
|
|
do { |
|
|
|
|
try dataStore.teamRegistrations.addOrUpdate(instance: team) |
|
|
|
|
} catch { |
|
|
|
|
Logger.error(error) |
|
|
|
|
} |
|
|
|
|
_getTeams() |
|
|
|
|
} |
|
|
|
|
})) { |
|
|
|
|
Label("Wildcard Poule", systemImage: team.wildCardGroupStage ? "circle.inset.filled" : "circle") |
|
|
|
|
@ -1032,24 +1125,32 @@ struct InscriptionManagerView: View { |
|
|
|
|
Toggle(isOn: .init(get: { |
|
|
|
|
return team.walkOut |
|
|
|
|
}, set: { value in |
|
|
|
|
team.resetPositions() |
|
|
|
|
team.wildCardBracket = false |
|
|
|
|
team.wildCardGroupStage = false |
|
|
|
|
team.walkOut = value |
|
|
|
|
do { |
|
|
|
|
try dataStore.teamRegistrations.addOrUpdate(instance: team) |
|
|
|
|
} catch { |
|
|
|
|
Logger.error(error) |
|
|
|
|
_clearScreen() |
|
|
|
|
Task { |
|
|
|
|
team.resetPositions() |
|
|
|
|
team.wildCardBracket = false |
|
|
|
|
team.wildCardGroupStage = false |
|
|
|
|
team.walkOut = value |
|
|
|
|
do { |
|
|
|
|
try dataStore.teamRegistrations.addOrUpdate(instance: team) |
|
|
|
|
} catch { |
|
|
|
|
Logger.error(error) |
|
|
|
|
} |
|
|
|
|
_getTeams() |
|
|
|
|
} |
|
|
|
|
})) { |
|
|
|
|
Label("WO", systemImage: team.walkOut ? "circle.inset.filled" : "circle") |
|
|
|
|
} |
|
|
|
|
Divider() |
|
|
|
|
Button(role: .destructive) { |
|
|
|
|
do { |
|
|
|
|
try dataStore.teamRegistrations.delete(instance: team) |
|
|
|
|
} catch { |
|
|
|
|
Logger.error(error) |
|
|
|
|
_clearScreen() |
|
|
|
|
Task { |
|
|
|
|
do { |
|
|
|
|
try dataStore.teamRegistrations.delete(instance: team) |
|
|
|
|
} catch { |
|
|
|
|
Logger.error(error) |
|
|
|
|
} |
|
|
|
|
_getTeams() |
|
|
|
|
} |
|
|
|
|
} label: { |
|
|
|
|
LabelDelete() |
|
|
|
|
|