multistore
Razmig Sarkissian 1 year ago
parent f97531a767
commit f43abf9331
  1. 4
      PadelClub.xcodeproj/project.pbxproj
  2. 7
      PadelClub/Data/Coredata/Persistence.swift
  3. 4
      PadelClub/Data/PlayerRegistration.swift
  4. 4
      PadelClub/Utils/FileImportManager.swift
  5. 43
      PadelClub/Views/Navigation/Toolbox/ToolboxView.swift

@ -1919,7 +1919,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 17;
CURRENT_PROJECT_VERSION = 18;
DEFINES_MODULE = YES;
DEVELOPMENT_ASSET_PATHS = "\"PadelClub/Preview Content\"";
DEVELOPMENT_TEAM = BQ3Y44M3Q6;
@ -1957,7 +1957,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 17;
CURRENT_PROJECT_VERSION = 18;
DEFINES_MODULE = YES;
DEVELOPMENT_ASSET_PATHS = "\"PadelClub/Preview Content\"";
DEVELOPMENT_TEAM = BQ3Y44M3Q6;

@ -155,15 +155,16 @@ class PersistenceController: NSObject {
importedPlayer.country?.replace(characters: replacementsCharacters)
}
importedPlayer.tournamentCount = Int64(data.tournamentCount ?? 0)
importedPlayer.lastName = data.lastName
importedPlayer.lastName = data.lastName.trimmed.uppercased()
if fixApril2024 {
importedPlayer.lastName?.replace(characters: replacementsCharacters)
}
importedPlayer.firstName = data.firstName
importedPlayer.firstName = data.firstName.trimmed.capitalized
if fixApril2024 {
importedPlayer.firstName?.replace(characters: replacementsCharacters)
}
importedPlayer.fullName = data.firstName + " " + data.lastName
importedPlayer.fullName = data.firstName.trimmed.capitalized + " " + data.lastName.trimmed.uppercased()
if fixApril2024 {
importedPlayer.fullName?.replace(characters: replacementsCharacters)
}

@ -60,8 +60,8 @@ class PlayerRegistration: ModelObject, Storable {
internal init(importedPlayer: ImportedPlayer) {
self.teamRegistration = ""
self.firstName = importedPlayer.firstName ?? ""
self.lastName = importedPlayer.lastName ?? ""
self.firstName = (importedPlayer.firstName ?? "").trimmed.capitalized
self.lastName = (importedPlayer.lastName ?? "").trimmed.uppercased()
self.licenceId = importedPlayer.license ?? nil
self.rank = Int(importedPlayer.rank)
self.sex = importedPlayer.male ? .male : .female

@ -27,8 +27,8 @@ class FileImportManager {
lastName.replace(characters: replacementsCharacters)
var firstName = federalPlayer.firstName
firstName.replace(characters: replacementsCharacters)
importedPlayer.lastName = lastName
importedPlayer.firstName = firstName
importedPlayer.lastName = lastName.trimmed.uppercased()
importedPlayer.firstName = firstName.trimmed.capitalized
}
}
playersLeft.removeAll(where: { $0.lastName.isEmpty == false })

@ -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()

Loading…
Cancel
Save