|
|
|
|
@ -6,14 +6,57 @@ |
|
|
|
|
// |
|
|
|
|
|
|
|
|
|
import SwiftUI |
|
|
|
|
import LeStorage |
|
|
|
|
|
|
|
|
|
struct ToolboxView: View { |
|
|
|
|
@EnvironmentObject var dataStore: DataStore |
|
|
|
|
@Environment(NavigationViewModel.self) private var navigation: NavigationViewModel |
|
|
|
|
|
|
|
|
|
var body: some View { |
|
|
|
|
@Bindable var navigation = navigation |
|
|
|
|
NavigationStack(path: $navigation.toolboxPath) { |
|
|
|
|
List { |
|
|
|
|
#if DEBUG |
|
|
|
|
Section { |
|
|
|
|
RowButtonView("Fix Names") { |
|
|
|
|
let playerRegistrations = dataStore.playerRegistrations |
|
|
|
|
playerRegistrations.forEach { player in |
|
|
|
|
player.firstName = player.firstName.trimmed.capitalized |
|
|
|
|
player.lastName = player.lastName.trimmed.uppercased() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
do { |
|
|
|
|
try dataStore.playerRegistrations.addOrUpdate(contentOfs: playerRegistrations) |
|
|
|
|
} catch { |
|
|
|
|
Logger.error(error) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Section { |
|
|
|
|
RowButtonView("Delete teams") { |
|
|
|
|
let teamRegistrations = dataStore.teamRegistrations.filter({ $0.tournamentObject() == nil }) |
|
|
|
|
do { |
|
|
|
|
try dataStore.teamRegistrations.delete(contentOfs: teamRegistrations) |
|
|
|
|
} catch { |
|
|
|
|
Logger.error(error) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Section { |
|
|
|
|
RowButtonView("Delete players") { |
|
|
|
|
let playersRegistrations = dataStore.playerRegistrations.filter({ $0.team() == nil }) |
|
|
|
|
do { |
|
|
|
|
try dataStore.playerRegistrations.delete(contentOfs: playersRegistrations) |
|
|
|
|
} catch { |
|
|
|
|
Logger.error(error) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
Section { |
|
|
|
|
NavigationLink { |
|
|
|
|
SelectablePlayerListView() |
|
|
|
|
|