fix stuff in file import

sync2
Raz 1 year ago
parent 09c4012990
commit 393069ec45
  1. 2
      PadelClub.xcodeproj/project.pbxproj
  2. 4
      PadelClub/Data/PlayerRegistration.swift
  3. 2
      PadelClub/Views/Components/Labels.swift
  4. 10
      PadelClub/Views/Player/Components/PlayerPopoverView.swift
  5. 2
      PadelClub/Views/Player/PlayerDetailView.swift
  6. 2
      PadelClub/Views/Team/EditingTeamView.swift
  7. 16
      PadelClub/Views/Tournament/FileImportView.swift
  8. 9
      PadelClub/Views/Tournament/Screen/AddTeamView.swift
  9. 2
      PadelClub/Views/Tournament/Screen/TournamentSettingsView.swift
  10. 4
      PadelClub/Views/Tournament/TournamentInitView.swift

@ -3156,6 +3156,7 @@
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator"; SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";
SUPPORTS_MACCATALYST = NO; SUPPORTS_MACCATALYST = NO;
SUPPORTS_XR_DESIGNED_FOR_IPHONE_IPAD = NO; SUPPORTS_XR_DESIGNED_FOR_IPHONE_IPAD = NO;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 5.0; SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2"; TARGETED_DEVICE_FAMILY = "1,2";
}; };
@ -3198,6 +3199,7 @@
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator"; SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";
SUPPORTS_MACCATALYST = NO; SUPPORTS_MACCATALYST = NO;
SUPPORTS_XR_DESIGNED_FOR_IPHONE_IPAD = NO; SUPPORTS_XR_DESIGNED_FOR_IPHONE_IPAD = NO;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 5.0; SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2"; TARGETED_DEVICE_FAMILY = "1,2";
}; };

@ -160,8 +160,8 @@ final class PlayerRegistration: ModelObject, Storable {
} }
func isSameAs(_ player: PlayerRegistration) -> Bool { func isSameAs(_ player: PlayerRegistration) -> Bool {
firstName.localizedCaseInsensitiveCompare(player.firstName) == .orderedSame && firstName.trimmedMultiline.localizedCaseInsensitiveCompare(player.firstName.trimmedMultiline) == .orderedSame &&
lastName.localizedCaseInsensitiveCompare(player.lastName) == .orderedSame lastName.trimmedMultiline.localizedCaseInsensitiveCompare(player.lastName.trimmedMultiline) == .orderedSame
} }
func tournament() -> Tournament? { func tournament() -> Tournament? {

@ -21,7 +21,7 @@ struct LabelStructure: View {
struct LabelSettings: View { struct LabelSettings: View {
var body: some View { var body: some View {
Label("Réglages", systemImage: "slider.horizontal.3").labelStyle(.titleOnly) Label("Réglages du tournoi", systemImage: "slider.horizontal.3").labelStyle(.titleOnly)
} }
} }

@ -99,7 +99,7 @@ struct PlayerPopoverView: View {
.textInputAutocapitalization(.words) .textInputAutocapitalization(.words)
.focused($firstNameIsFocused) .focused($firstNameIsFocused)
.onSubmit { .onSubmit {
firstName = firstName.trimmed firstName = firstName.trimmedMultiline
lastNameIsFocused = true lastNameIsFocused = true
} }
.fixedSize() .fixedSize()
@ -114,7 +114,7 @@ struct PlayerPopoverView: View {
.keyboardType(.alphabet) .keyboardType(.alphabet)
.focused($lastNameIsFocused) .focused($lastNameIsFocused)
.onSubmit { .onSubmit {
lastName = lastName.trimmed lastName = lastName.trimmedMultiline
licenseIsFocused = true licenseIsFocused = true
} }
.fixedSize() .fixedSize()
@ -128,7 +128,7 @@ struct PlayerPopoverView: View {
.keyboardType(.numberPad) .keyboardType(.numberPad)
.submitLabel(.next) .submitLabel(.next)
.onSubmit { .onSubmit {
license = license.trimmed license = license.trimmedMultiline
if requiredField.contains(.license) { if requiredField.contains(.license) {
if license.isLicenseNumber { if license.isLicenseNumber {
amountIsFocused = true amountIsFocused = true
@ -206,7 +206,7 @@ struct PlayerPopoverView: View {
Spacer() Spacer()
Button("Confirmer") { Button("Confirmer") {
if licenseIsFocused { if licenseIsFocused {
license = license.trimmed license = license.trimmedMultiline
if requiredField.contains(.license) { if requiredField.contains(.license) {
if license.isLicenseNumber { if license.isLicenseNumber {
amountIsFocused = true amountIsFocused = true
@ -251,7 +251,7 @@ struct PlayerPopoverView: View {
} }
func createManualPlayer() { func createManualPlayer() {
let playerRegistration = PlayerRegistration(firstName: firstName, lastName: lastName, licenceId: license.trimmed.isEmpty ? nil : license, rank: rank, sex: PlayerRegistration.PlayerSexType(rawValue: sex)) let playerRegistration = PlayerRegistration(firstName: firstName.trimmedMultiline, lastName: lastName.trimmedMultiline, licenceId: license.trimmedMultiline.isEmpty ? nil : license, rank: rank, sex: PlayerRegistration.PlayerSexType(rawValue: sex))
self.creationCompletionHandler(playerRegistration) self.creationCompletionHandler(playerRegistration)
} }

@ -41,6 +41,7 @@ struct PlayerDetailView: View {
.multilineTextAlignment(.trailing) .multilineTextAlignment(.trailing)
.frame(maxWidth: .infinity) .frame(maxWidth: .infinity)
.onSubmit(of: .text) { .onSubmit(of: .text) {
player.lastName = player.lastName.trimmedMultiline
_save() _save()
} }
} label: { } label: {
@ -53,6 +54,7 @@ struct PlayerDetailView: View {
.multilineTextAlignment(.trailing) .multilineTextAlignment(.trailing)
.frame(maxWidth: .infinity) .frame(maxWidth: .infinity)
.onSubmit(of: .text) { .onSubmit(of: .text) {
player.firstName = player.firstName.trimmedMultiline
_save() _save()
} }
} label: { } label: {

@ -147,7 +147,7 @@ struct EditingTeamView: View {
.frame(maxWidth: .infinity) .frame(maxWidth: .infinity)
.submitLabel(.done) .submitLabel(.done)
.onSubmit(of: .text) { .onSubmit(of: .text) {
let trimmed = name.trimmed let trimmed = name.trimmedMultiline
if trimmed.isEmpty { if trimmed.isEmpty {
team.name = nil team.name = nil
} else { } else {

@ -311,6 +311,11 @@ struct FileImportView: View {
} label: { } label: {
Text("Équipe\(_filteredTeams.count.pluralSuffix) \(tournament.tournamentCategory.importingRawValue) \(tournament.federalTournamentAge.importingRawValue) détectée\(_filteredTeams.count.pluralSuffix)") Text("Équipe\(_filteredTeams.count.pluralSuffix) \(tournament.tournamentCategory.importingRawValue) \(tournament.federalTournamentAge.importingRawValue) détectée\(_filteredTeams.count.pluralSuffix)")
} }
LabeledContent {
Text(_filteredTeams.count.formatted())
} label: {
Text("Équipe\(_filteredTeams.count.pluralSuffix) \(tournament.tournamentCategory.importingRawValue) \(tournament.federalTournamentAge.importingRawValue) détectée\(_filteredTeams.count.pluralSuffix)")
}
} footer: { } footer: {
if previousTeams.isEmpty == false { if previousTeams.isEmpty == false {
Text("La liste ci-dessous n'est qu'une indication d'évolution par rapport au seul poids d'équipe. Cela ne tient pas compte des dates d'inscriptions, WCs et autres éléments.").foregroundStyle(.logoRed) Text("La liste ci-dessous n'est qu'une indication d'évolution par rapport au seul poids d'équipe. Cela ne tient pas compte des dates d'inscriptions, WCs et autres éléments.").foregroundStyle(.logoRed)
@ -442,11 +447,16 @@ struct FileImportView: View {
.disabled(validationInProgress) .disabled(validationInProgress)
} }
private func _getUnfound(tournament: Tournament, fromTeams filteredTeams: [FileImportManager.TeamHolder]) -> Set<TeamRegistration> {
let previousTeams = filteredTeams.compactMap({ $0.previousTeam })
let unfound = Set(tournament.unsortedTeams()).subtracting(Set(previousTeams))
return unfound
}
private func _validate(tournament: Tournament) async { private func _validate(tournament: Tournament) async {
let filteredTeams = filteredTeams(tournament: tournament) let filteredTeams = filteredTeams(tournament: tournament)
let previousTeams = filteredTeams.compactMap({ $0.previousTeam })
let unfound = Set(tournament.unsortedTeams()).subtracting(Set(previousTeams)) let unfound = _getUnfound(tournament: tournament, fromTeams: filteredTeams)
unfound.forEach { team in unfound.forEach { team in
team.resetPositions() team.resetPositions()
team.wildCardBracket = false team.wildCardBracket = false
@ -455,7 +465,7 @@ struct FileImportView: View {
} }
do { do {
try self.tournamentStore.teamRegistrations.addOrUpdate(contentOfs: unfound) try tournament.tournamentStore.teamRegistrations.addOrUpdate(contentOfs: unfound)
} catch { } catch {
Logger.error(error) Logger.error(error)
} }

@ -164,7 +164,7 @@ struct AddTeamView: View {
} }
} }
} }
.navigationBarBackButtonHidden(_isEditingTeam()) .navigationBarBackButtonHidden(true)
.toolbarBackground(.visible, for: .navigationBar) .toolbarBackground(.visible, for: .navigationBar)
.toolbarBackground(.visible, for: .bottomBar) .toolbarBackground(.visible, for: .bottomBar)
.navigationBarTitleDisplayMode(.inline) .navigationBarTitleDisplayMode(.inline)
@ -336,6 +336,7 @@ struct AddTeamView: View {
if let pasteString { if let pasteString {
Section { Section {
TextEditor(text: $editableTextField) TextEditor(text: $editableTextField)
.frame(minHeight: 120, maxHeight: .infinity)
.focused($focusedField, equals: .pasteField) .focused($focusedField, equals: .pasteField)
.toolbar { .toolbar {
ToolbarItemGroup(placement: .keyboard) { ToolbarItemGroup(placement: .keyboard) {
@ -355,15 +356,17 @@ struct AddTeamView: View {
Text("Contenu du presse-papier") Text("Contenu du presse-papier")
} footer: { } footer: {
HStack { HStack {
FooterButtonView("éditer") {
self.focusedField = .pasteField
}
Spacer() Spacer()
Button("effacer", role: .destructive) { FooterButtonView("effacer", role: .destructive) {
self.focusedField = nil self.focusedField = nil
self.editableTextField = "" self.editableTextField = ""
self.pasteString = nil self.pasteString = nil
self.createdPlayers.removeAll() self.createdPlayers.removeAll()
self.createdPlayerIds.removeAll() self.createdPlayerIds.removeAll()
} }
.buttonStyle(.borderless)
} }
} }
} }

@ -74,7 +74,7 @@ struct TournamentSettingsView: View {
} }
.navigationBarTitleDisplayMode(.inline) .navigationBarTitleDisplayMode(.inline)
.toolbarBackground(.visible, for: .navigationBar) .toolbarBackground(.visible, for: .navigationBar)
.navigationTitle("Réglages") .navigationTitle("Réglages du tournoi")
} }
} }

@ -40,7 +40,7 @@ struct TournamentInitView: View {
Image(systemName: "checkmark").foregroundStyle(.green) Image(systemName: "checkmark").foregroundStyle(.green)
} }
} label: { } label: {
LabelStructure() Text("Structure")
Text(tournament.structureDescriptionLocalizedLabel()) Text(tournament.structureDescriptionLocalizedLabel())
} }
} }
@ -49,7 +49,7 @@ struct TournamentInitView: View {
LabeledContent { LabeledContent {
Text(tournament.localizedTournamentType()) Text(tournament.localizedTournamentType())
} label: { } label: {
LabelSettings() Text("Réglages du tournoi")
Text("Formats, terrains, prix et plus") Text("Formats, terrains, prix et plus")
} }
} }

Loading…
Cancel
Save