add name edition for team
add a quick paste button
remove all previews
multistore
Razmig Sarkissian 1 year ago
parent 395b5a80c7
commit 9a55c74465
  1. 2
      PadelClub/Data/TeamRegistration.swift
  2. 6
      PadelClub/Data/Tournament.swift
  3. 12
      PadelClub/Utils/FileImportManager.swift
  4. 2
      PadelClub/Utils/PadelRule.swift
  5. 6
      PadelClub/Views/Calling/CallSettingsView.swift
  6. 6
      PadelClub/Views/Calling/Components/MenuWarningView.swift
  7. 6
      PadelClub/Views/Calling/GroupStageCallingView.swift
  8. 6
      PadelClub/Views/Calling/SeedsCallingView.swift
  9. 6
      PadelClub/Views/Calling/SendToAllView.swift
  10. 6
      PadelClub/Views/Cashier/CashierSettingsView.swift
  11. 8
      PadelClub/Views/Cashier/Event/EventCreationView.swift
  12. 6
      PadelClub/Views/Cashier/Event/EventLinksView.swift
  13. 6
      PadelClub/Views/Club/ClubDetailView.swift
  14. 6
      PadelClub/Views/Club/ClubImportView.swift
  15. 6
      PadelClub/Views/Club/ClubRowView.swift
  16. 6
      PadelClub/Views/Club/ClubSearchView.swift
  17. 12
      PadelClub/Views/Club/ClubsView.swift
  18. 6
      PadelClub/Views/Club/CourtView.swift
  19. 8
      PadelClub/Views/Club/CreateClubView.swift
  20. 8
      PadelClub/Views/Components/FortuneWheelView.swift
  21. 6
      PadelClub/Views/Components/StepperView.swift
  22. 8
      PadelClub/Views/GroupStage/GroupStageSettingsView.swift
  23. 13
      PadelClub/Views/GroupStage/GroupStageView.swift
  24. 6
      PadelClub/Views/GroupStage/Shared/GroupStageTeamReplacementView.swift
  25. 6
      PadelClub/Views/Match/Components/MatchTeamDetailView.swift
  26. 6
      PadelClub/Views/Match/Components/PlayerBlockView.swift
  27. 6
      PadelClub/Views/Match/MatchDetailView.swift
  28. 6
      PadelClub/Views/Match/MatchRowView.swift
  29. 8
      PadelClub/Views/Match/MatchSetupView.swift
  30. 6
      PadelClub/Views/Match/MatchSummaryView.swift
  31. 87
      PadelClub/Views/Navigation/Agenda/ActivityView.swift
  32. 6
      PadelClub/Views/Navigation/Agenda/CalendarView.swift
  33. 6
      PadelClub/Views/Navigation/Agenda/EventListView.swift
  34. 6
      PadelClub/Views/Navigation/MainView.swift
  35. 6
      PadelClub/Views/Navigation/Ongoing/OngoingView.swift
  36. 6
      PadelClub/Views/Navigation/Organizer/TournamentOrganizerView.swift
  37. 6
      PadelClub/Views/Navigation/Toolbox/APICallsListView.swift
  38. 6
      PadelClub/Views/Navigation/Toolbox/DebugSettingsView.swift
  39. 6
      PadelClub/Views/Navigation/Toolbox/DurationSettingsView.swift
  40. 6
      PadelClub/Views/Navigation/Toolbox/ToolboxView.swift
  41. 6
      PadelClub/Views/Navigation/Umpire/PadelClubView.swift
  42. 6
      PadelClub/Views/Navigation/Umpire/UmpireView.swift
  43. 6
      PadelClub/Views/Planning/CourtAvailabilitySettingsView.swift
  44. 6
      PadelClub/Views/Planning/GroupStageScheduleEditorView.swift
  45. 6
      PadelClub/Views/Planning/MatchScheduleEditorView.swift
  46. 6
      PadelClub/Views/Planning/PlanningSettingsView.swift
  47. 6
      PadelClub/Views/Planning/PlanningView.swift
  48. 6
      PadelClub/Views/Planning/RoundScheduleEditorView.swift
  49. 6
      PadelClub/Views/Planning/SchedulerView.swift
  50. 10
      PadelClub/Views/Player/Components/PlayerPopoverView.swift
  51. 8
      PadelClub/Views/Player/Components/PlayerSexPickerView.swift
  52. 6
      PadelClub/Views/Player/PlayerDetailView.swift
  53. 6
      PadelClub/Views/Player/PlayerView.swift
  54. 6
      PadelClub/Views/Round/LoserRoundSettingsView.swift
  55. 10
      PadelClub/Views/Round/RoundSettingsView.swift
  56. 8
      PadelClub/Views/Round/RoundView.swift
  57. 6
      PadelClub/Views/Round/RoundsView.swift
  58. 10
      PadelClub/Views/Shared/MatchFormatPickerView.swift
  59. 6
      PadelClub/Views/Shared/TournamentFilterView.swift
  60. 6
      PadelClub/Views/Subscription/PurchaseListView.swift
  61. 6
      PadelClub/Views/Subscription/SubscriptionInfoView.swift
  62. 18
      PadelClub/Views/Subscription/SubscriptionView.swift
  63. 12
      PadelClub/Views/Team/Components/TeamHeaderView.swift
  64. 6
      PadelClub/Views/Team/Components/TeamWeightView.swift
  65. 26
      PadelClub/Views/Team/EditingTeamView.swift
  66. 6
      PadelClub/Views/Team/TeamDetailView.swift
  67. 14
      PadelClub/Views/Team/TeamPickerView.swift
  68. 9
      PadelClub/Views/Team/TeamRowView.swift
  69. 15
      PadelClub/Views/Tournament/FileImportView.swift
  70. 6
      PadelClub/Views/Tournament/Screen/BroadcastView.swift
  71. 8
      PadelClub/Views/Tournament/Screen/Components/InscriptionInfoView.swift
  72. 6
      PadelClub/Views/Tournament/Screen/Components/TournamentClubSettingsView.swift
  73. 8
      PadelClub/Views/Tournament/Screen/Components/TournamentDurationManagerView.swift
  74. 8
      PadelClub/Views/Tournament/Screen/Components/TournamentFieldsManagerView.swift
  75. 6
      PadelClub/Views/Tournament/Screen/Components/TournamentMatchFormatsSettingsView.swift
  76. 6
      PadelClub/Views/Tournament/Screen/Components/TournamentStatusView.swift
  77. 6
      PadelClub/Views/Tournament/Screen/Components/UpdateSourceRankDateView.swift
  78. 60
      PadelClub/Views/Tournament/Screen/InscriptionManagerView.swift
  79. 14
      PadelClub/Views/Tournament/Screen/TableStructureView.swift
  80. 6
      PadelClub/Views/Tournament/Screen/TournamentCallView.swift
  81. 6
      PadelClub/Views/Tournament/Screen/TournamentCashierView.swift
  82. 10
      PadelClub/Views/Tournament/Screen/TournamentRankView.swift
  83. 6
      PadelClub/Views/Tournament/Screen/TournamentScheduleView.swift
  84. 6
      PadelClub/Views/Tournament/Screen/TournamentSettingsView.swift
  85. 6
      PadelClub/Views/Tournament/Shared/DateBoxView.swift
  86. 6
      PadelClub/Views/Tournament/Shared/PadelClubButtonView.swift
  87. 6
      PadelClub/Views/Tournament/Shared/TournamentCellView.swift
  88. 6
      PadelClub/Views/Tournament/TournamentBuildView.swift
  89. 6
      PadelClub/Views/Tournament/TournamentInitView.swift
  90. 6
      PadelClub/Views/Tournament/TournamentRunningView.swift
  91. 10
      PadelClub/Views/Tournament/TournamentView.swift
  92. 10
      PadelClub/Views/User/AccountView.swift
  93. 10
      PadelClub/Views/User/ChangePasswordView.swift
  94. 18
      PadelClub/Views/User/LoginView.swift
  95. 6
      PadelClub/Views/User/UserCreationView.swift

@ -249,7 +249,7 @@ class TeamRegistration: ModelObject, Storable {
} }
func pasteData() -> String { func pasteData() -> String {
[name, playersPasteData(), formattedInscriptionDate()].compactMap({ $0 }).joined(separator: "\n") [playersPasteData(), formattedInscriptionDate(), name].compactMap({ $0 }).joined(separator: "\n")
} }
var computedRegistrationDate: Date { var computedRegistrationDate: Date {

@ -929,7 +929,7 @@ class Tournament : ModelObject, Storable {
}), let previousTeamRegistrationDate = previousPlayer.team()?.registrationDate { }), let previousTeamRegistrationDate = previousPlayer.team()?.registrationDate {
registrationDate = previousTeamRegistrationDate registrationDate = previousTeamRegistrationDate
} }
let newTeam = addTeam(team.players, registrationDate: registrationDate) let newTeam = addTeam(team.players, registrationDate: registrationDate, name: team.name)
teamsToImport.append(newTeam) teamsToImport.append(newTeam)
} }
} }
@ -1528,8 +1528,8 @@ class Tournament : ModelObject, Storable {
} }
} }
func addTeam(_ players: Set<PlayerRegistration>, registrationDate: Date? = nil) -> TeamRegistration { func addTeam(_ players: Set<PlayerRegistration>, registrationDate: Date? = nil, name: String? = nil) -> TeamRegistration {
let team = TeamRegistration(tournament: id, registrationDate: registrationDate ?? Date()) let team = TeamRegistration(tournament: id, registrationDate: registrationDate ?? Date(), name: name)
team.setWeight(from: Array(players), inTournamentCategory: tournamentCategory) team.setWeight(from: Array(players), inTournamentCategory: tournamentCategory)
players.forEach { player in players.forEach { player in
player.teamRegistration = team.id player.teamRegistration = team.id

@ -103,10 +103,12 @@ class FileImportManager {
let tournamentCategory: TournamentCategory let tournamentCategory: TournamentCategory
let previousTeam: TeamRegistration? let previousTeam: TeamRegistration?
var registrationDate: Date? = nil var registrationDate: Date? = nil
var name: String? = nil
init(players: [PlayerRegistration], tournamentCategory: TournamentCategory, previousTeam: TeamRegistration?, registrationDate: Date? = nil, tournament: Tournament) { init(players: [PlayerRegistration], tournamentCategory: TournamentCategory, previousTeam: TeamRegistration?, registrationDate: Date? = nil, name: String? = nil, tournament: Tournament) {
self.players = Set(players) self.players = Set(players)
self.tournamentCategory = tournamentCategory self.tournamentCategory = tournamentCategory
self.name = name
self.previousTeam = previousTeam self.previousTeam = previousTeam
if players.count < 2 { if players.count < 2 {
let s = players.compactMap { $0.sex?.rawValue } let s = players.compactMap { $0.sex?.rawValue }
@ -354,6 +356,14 @@ class FileImportManager {
} }
return nil return nil
} }
var name: String? {
if let name = data[safe:3] {
return name
}
return nil
}
let team = TeamHolder(players: registeredPlayers, tournamentCategory: tournament.tournamentCategory, previousTeam: tournament.findTeam(registeredPlayers), registrationDate: registrationDate, tournament: tournament) let team = TeamHolder(players: registeredPlayers, tournamentCategory: tournament.tournamentCategory, previousTeam: tournament.findTeam(registeredPlayers), registrationDate: registrationDate, tournament: tournament)
results.append(team) results.append(team)
} }

@ -787,7 +787,7 @@ enum TournamentCategory: Int, Hashable, Codable, CaseIterable, Identifiable {
var playerFilterOption: PlayerFilterOption { var playerFilterOption: PlayerFilterOption {
switch self { switch self {
case .men: case .men:
return .male return .all
case .women: case .women:
return .female return .female
case .mix: case .mix:

@ -92,6 +92,6 @@ struct CallSettingsView: View {
} }
} }
#Preview { //#Preview {
CallSettingsView() // CallSettingsView()
} //}

@ -105,6 +105,6 @@ struct MenuWarningView: View {
} }
} }
#Preview { //#Preview {
MenuWarningView(teams: [], contactType: .constant(nil)) // MenuWarningView(teams: [], contactType: .constant(nil))
} //}

@ -103,6 +103,6 @@ struct GroupStageCallingView: View {
} }
} }
#Preview { //#Preview {
GroupStageCallingView() // GroupStageCallingView()
} //}

@ -113,6 +113,6 @@ struct SeedsCallingView: View {
} }
} }
#Preview { //#Preview {
SeedsCallingView() // SeedsCallingView()
} //}

@ -224,6 +224,6 @@ struct SendToAllView: View {
} }
#Preview { //#Preview {
SendToAllView(addLink: true) // SendToAllView(addLink: true)
} //}

@ -60,6 +60,6 @@ struct CashierSettingsView: View {
} }
} }
#Preview { //#Preview {
CashierSettingsView(tournaments: []) // CashierSettingsView(tournaments: [])
} //}

@ -208,7 +208,7 @@ struct EventCreationView: View {
} }
#Preview { //#Preview {
EventCreationView() // EventCreationView()
.environmentObject(DataStore.shared) // .environmentObject(DataStore.shared)
} //}

@ -55,6 +55,6 @@ struct EventLinksView: View {
} }
} }
#Preview { //#Preview {
EventLinksView(event: Event.mock()) // EventLinksView(event: Event.mock())
} //}

@ -260,6 +260,6 @@ struct ClubDetailView: View {
} }
} }
#Preview { //#Preview {
ClubDetailView(club: Club.mock(), displayContext: .edition) // ClubDetailView(club: Club.mock(), displayContext: .edition)
} //}

File diff suppressed because one or more lines are too long

@ -25,6 +25,6 @@ struct ClubRowView: View {
} }
} }
#Preview { //#Preview {
ClubRowView(club: Club.mock()) // ClubRowView(club: Club.mock())
} //}

@ -423,6 +423,6 @@ fileprivate extension CLPlacemark {
} }
#Preview { //#Preview {
ClubSearchView() // ClubSearchView()
} //}

@ -153,9 +153,9 @@ struct ClubsView: View {
} }
} }
#Preview { //#Preview {
NavigationStack { // NavigationStack {
ClubsView() // ClubsView()
.environmentObject(DataStore.shared) // .environmentObject(DataStore.shared)
} // }
} //}

@ -77,6 +77,6 @@ struct CourtView: View {
} }
} }
#Preview { //#Preview {
CourtView(court: Court.mock()) // CourtView(court: Court.mock())
} //}

@ -71,7 +71,7 @@ struct CreateClubView: View {
} }
} }
#Preview { //#Preview {
CreateClubView(club: Club.mock()) // CreateClubView(club: Club.mock())
.environmentObject(DataStore.shared) // .environmentObject(DataStore.shared)
} //}

@ -345,7 +345,7 @@ struct Triangle: Shape {
} }
} }
#Preview { //#Preview {
SpinDrawView(drawees: ["3", "4"], segments: ["1", "2"]) { draws in // SpinDrawView(drawees: ["3", "4"], segments: ["1", "2"]) { draws in
} // }
} //}

@ -88,6 +88,6 @@ struct StepperView: View {
} }
#Preview { //#Preview {
StepperView(title: "poule", count: .constant(1)) // StepperView(title: "poule", count: .constant(1))
} //}

@ -130,7 +130,7 @@ struct GroupStageSettingsView: View {
} }
} }
#Preview { //#Preview {
GroupStageSettingsView() // GroupStageSettingsView()
.environment(Tournament.mock()) // .environment(Tournament.mock())
} //}

@ -126,13 +126,12 @@ struct GroupStageView: View {
} }
.font(.footnote) .font(.footnote)
HStack { HStack {
if let teamName = team.name { VStack(alignment: .leading) {
Text(teamName).font(.title) if let teamName = team.name {
} else { Text(teamName).foregroundStyle(.secondary)
VStack(alignment: .leading) { }
ForEach(team.players()) { player in ForEach(team.players()) { player in
Text(player.playerLabel()).lineLimit(1) Text(player.playerLabel()).lineLimit(1)
}
} }
} }
Spacer() Spacer()

@ -156,6 +156,6 @@ struct GroupStageTeamReplacementView: View {
} }
} }
#Preview { //#Preview {
GroupStageTeamReplacementView(team: TeamRegistration.mock()) // GroupStageTeamReplacementView(team: TeamRegistration.mock())
} //}

@ -40,6 +40,6 @@ struct MatchTeamDetailView: View {
} }
#Preview { //#Preview {
MatchTeamDetailView(match: Match.mock()) // MatchTeamDetailView(match: Match.mock())
} //}

@ -57,12 +57,18 @@ struct PlayerBlockView: View {
Text("Repêchée").italic().font(.caption) Text("Repêchée").italic().font(.caption)
} }
if let name = team?.name {
Text(name).foregroundStyle(.secondary)
}
ForEach(names, id: \.self) { name in ForEach(names, id: \.self) { name in
Text(name).lineLimit(1) Text(name).lineLimit(1)
} }
} else { } else {
ZStack(alignment: .leading) { ZStack(alignment: .leading) {
VStack { VStack {
if let name = team?.name {
Text(name).foregroundStyle(.secondary)
}
Text("longLabelPlayerOne").lineLimit(1) Text("longLabelPlayerOne").lineLimit(1)
Text("longLabelPlayerTwo").lineLimit(1) Text("longLabelPlayerTwo").lineLimit(1)
} }

@ -451,6 +451,6 @@ struct MatchDetailView: View {
} }
} }
#Preview { //#Preview {
MatchDetailView(match: Match.mock(), matchViewStyle: .standardStyle) // MatchDetailView(match: Match.mock(), matchViewStyle: .standardStyle)
} //}

@ -64,6 +64,6 @@ struct MatchRowView: View {
} }
#Preview { //#Preview {
MatchRowView(match: Match.mock(), matchViewStyle: .standardStyle) // MatchRowView(match: Match.mock(), matchViewStyle: .standardStyle)
} //}

@ -171,7 +171,7 @@ struct MatchSetupView: View {
} }
} }
#Preview { //#Preview {
MatchSetupView(match: Match.mock()) // MatchSetupView(match: Match.mock())
.environmentObject(DataStore.shared) // .environmentObject(DataStore.shared)
} //}

@ -99,6 +99,6 @@ struct MatchSummaryView: View {
} }
} }
#Preview { //#Preview {
MatchSummaryView(match: Match.mock(), matchViewStyle: .standardStyle) // MatchSummaryView(match: Match.mock(), matchViewStyle: .standardStyle)
} //}

@ -21,6 +21,18 @@ struct ActivityView: View {
@State private var error: Error? @State private var error: Error?
@State private var uuid: UUID = UUID() @State private var uuid: UUID = UUID()
@State private var presentClubSearchView: Bool = false @State private var presentClubSearchView: Bool = false
@State private var quickAccessScreen: QuickAccessScreen? = nil
enum QuickAccessScreen : Identifiable, Hashable {
case inscription(pasteString: String)
var id: String {
switch self {
case .inscription:
return "inscription"
}
}
}
var runningTournaments: [FederalTournamentHolder] { var runningTournaments: [FederalTournamentHolder] {
dataStore.tournaments.filter({ $0.endDate == nil }) dataStore.tournaments.filter({ $0.endDate == nil })
@ -60,27 +72,15 @@ struct ActivityView: View {
@ViewBuilder @ViewBuilder
private func _pasteView() -> some View { private func _pasteView() -> some View {
if UIPasteboard.general.hasStrings { PasteButton(payloadType: String.self) { strings in
// Enable string-related control... guard let first = strings.first else { return }
if let string = UIPasteboard.general.string { quickAccessScreen = .inscription(pasteString: first)
// use the string here
Section {
Menu("Utiliser le contenu du presse-papier") {
Section {
ForEach(getRunningTournaments()) { tournament in
Button(tournament.tournamentTitle()) {
navigation.path.append(tournament)
tournament.navigationPath = [Screen.inscription]
}
}
} header: {
Text("coller dans")
}
}
}
}
} }
.foregroundStyle(.master)
.labelStyle(.iconOnly)
.buttonBorderShape(.capsule)
} }
var body: some View { var body: some View {
@Bindable var navigation = navigation @Bindable var navigation = navigation
NavigationStack(path: $navigation.path) { NavigationStack(path: $navigation.path) {
@ -90,7 +90,6 @@ struct ActivityView: View {
List { List {
switch navigation.agendaDestination! { switch navigation.agendaDestination! {
case .activity: case .activity:
_pasteView()
EventListView(tournaments: runningTournaments, viewStyle: viewStyle, sortAscending: true) EventListView(tournaments: runningTournaments, viewStyle: viewStyle, sortAscending: true)
case .history: case .history:
EventListView(tournaments: endedTournaments, viewStyle: viewStyle, sortAscending: false) EventListView(tournaments: endedTournaments, viewStyle: viewStyle, sortAscending: false)
@ -196,6 +195,8 @@ struct ActivityView: View {
.frame(minHeight: 28) .frame(minHeight: 28)
} }
.symbolVariant(federalDataViewModel.areFiltersEnabled() ? .fill : .none) .symbolVariant(federalDataViewModel.areFiltersEnabled() ? .fill : .none)
_pasteView()
} }
ToolbarItem(placement: .topBarTrailing) { ToolbarItem(placement: .topBarTrailing) {
@ -231,6 +232,46 @@ struct ActivityView: View {
} }
} }
} }
.sheet(item: $quickAccessScreen) { screen in
switch screen {
case .inscription(let pasteString):
NavigationStack {
List {
Section {
Text(pasteString)
} header: {
Text("Contenu du presse-papier")
}
Section {
ForEach(getRunningTournaments()) { tournament in
NavigationLink {
InscriptionManagerView(tournament: tournament, pasteString: pasteString)
.environment(tournament)
} label: {
VStack(alignment: .leading) {
Text(tournament.tournamentTitle())
Text(tournament.formattedDate()).foregroundStyle(.secondary)
}
}
}
} header: {
Text("À coller dans la liste d'inscription")
}
}
.toolbar {
ToolbarItem(placement: .topBarLeading) {
Button("Fermer") {
self.quickAccessScreen = nil
}
}
}
.navigationTitle("Choix du tournoi")
.navigationBarTitleDisplayMode(.inline)
.toolbarBackground(.visible, for: .navigationBar)
}
}
}
} }
private func _gatherFederalTournaments() { private func _gatherFederalTournaments() {
@ -323,6 +364,6 @@ struct ActivityView: View {
} }
#Preview { //#Preview {
ActivityView() // ActivityView()
} //}

@ -176,6 +176,6 @@ struct CalendarView: View {
} }
#Preview { //#Preview {
CalendarView(date: .now, tournaments: []) // CalendarView(date: .now, tournaments: [])
} //}

@ -118,6 +118,6 @@ struct EventListView: View {
} }
#Preview { //#Preview {
EventListView(tournaments: [], viewStyle: .calendar, sortAscending: true) // EventListView(tournaments: [], viewStyle: .calendar, sortAscending: true)
} //}

@ -165,6 +165,6 @@ struct MainView: View {
} }
} }
#Preview { //#Preview {
MainView() // MainView()
} //}

@ -103,6 +103,6 @@ struct OngoingView: View {
} }
} }
#Preview { //#Preview {
OngoingView() // OngoingView()
} //}

@ -50,6 +50,6 @@ struct TournamentOrganizerView: View {
} }
} }
#Preview { //#Preview {
TournamentOrganizerView() // TournamentOrganizerView()
} //}

@ -38,6 +38,6 @@ struct APICallsView: View {
} }
} }
#Preview { //#Preview {
APICallsListView() // APICallsListView()
} //}

@ -45,6 +45,6 @@ struct DebugSettingsView: View {
} }
} }
#Preview { //#Preview {
DebugSettingsView() // DebugSettingsView()
} //}

@ -20,6 +20,6 @@ struct DurationSettingsView: View {
} }
} }
#Preview { //#Preview {
DurationSettingsView() // DurationSettingsView()
} //}

@ -123,6 +123,6 @@ struct ToolboxView: View {
} }
} }
#Preview { //#Preview {
ToolboxView() // ToolboxView()
} //}

@ -239,6 +239,6 @@ struct PadelClubView: View {
} }
} }
#Preview { //#Preview {
PadelClubView() // PadelClubView()
} //}

@ -240,6 +240,6 @@ struct AccountRowView: View {
} }
} }
#Preview { //#Preview {
UmpireView() // UmpireView()
} //}

@ -198,6 +198,6 @@ struct CourtPicker: View {
} }
} }
#Preview { //#Preview {
CourtAvailabilitySettingsView(event: Event.mock()) // CourtAvailabilitySettingsView(event: Event.mock())
} //}

@ -36,6 +36,6 @@ struct GroupStageScheduleEditorView: View {
} }
} }
#Preview { //#Preview {
GroupStageScheduleEditorView(groupStage: GroupStage.mock(), tournament: Tournament.mock()) // GroupStageScheduleEditorView(groupStage: GroupStage.mock(), tournament: Tournament.mock())
} //}

@ -37,6 +37,6 @@ struct MatchScheduleEditorView: View {
} }
} }
#Preview { //#Preview {
MatchScheduleEditorView(match: Match.mock(), tournament: Tournament.mock()) // MatchScheduleEditorView(match: Match.mock(), tournament: Tournament.mock())
} //}

@ -252,6 +252,6 @@ struct PlanningSettingsView: View {
} }
} }
#Preview { //#Preview {
PlanningSettingsView(tournament: Tournament.mock()) // PlanningSettingsView(tournament: Tournament.mock())
} //}

@ -98,6 +98,6 @@ struct PlanningView: View {
} }
} }
#Preview { //#Preview {
PlanningView(matches: [], selectedScheduleDestination: .constant(nil)) // PlanningView(matches: [], selectedScheduleDestination: .constant(nil))
} //}

@ -69,6 +69,6 @@ struct RoundScheduleEditorView: View {
} }
} }
#Preview { //#Preview {
RoundScheduleEditorView(round: Round.mock(), tournament: Tournament.mock()) // RoundScheduleEditorView(round: Round.mock(), tournament: Tournament.mock())
} //}

@ -181,6 +181,6 @@ struct SchedulerView: View {
} }
} }
#Preview { //#Preview {
SchedulerView(tournament: Tournament.mock(), destination: .scheduleBracket) // SchedulerView(tournament: Tournament.mock(), destination: .scheduleBracket)
} //}

@ -257,8 +257,8 @@ struct PlayerPopoverView: View {
} }
#Preview { //#Preview {
PlayerPopoverView(source: "Razmig Sarkissian", sex: 1) { player in // PlayerPopoverView(source: "Razmig Sarkissian", sex: 1) { player in
//
} // }
} //}

@ -49,7 +49,7 @@ struct PlayerSexPickerView: View {
} }
#Preview { //#Preview {
PlayerSexPickerView(player: PlayerRegistration.mock()) // PlayerSexPickerView(player: PlayerRegistration.mock())
.environment(Tournament.mock()) // .environment(Tournament.mock())
} //}

@ -122,6 +122,6 @@ struct PlayerDetailView: View {
} }
} }
#Preview { //#Preview {
PlayerDetailView(player: PlayerRegistration.mock()) // PlayerDetailView(player: PlayerRegistration.mock())
} //}

@ -28,6 +28,6 @@ struct PlayerView: View {
} }
} }
#Preview { //#Preview {
PlayerView(player: PlayerRegistration.mock()) // PlayerView(player: PlayerRegistration.mock())
} //}

@ -26,6 +26,6 @@ struct LoserRoundSettingsView: View {
} }
} }
#Preview { //#Preview {
LoserRoundSettingsView() // LoserRoundSettingsView()
} //}

@ -132,8 +132,8 @@ struct RoundSettingsView: View {
} }
} }
#Preview { //#Preview {
RoundSettingsView() // RoundSettingsView()
.environment(Tournament.mock()) // .environment(Tournament.mock())
.environmentObject(DataStore.shared) // .environmentObject(DataStore.shared)
} //}

@ -328,7 +328,7 @@ struct RoundView: View {
} }
} }
#Preview { //#Preview {
RoundView(round: Round.mock()) // RoundView(round: Round.mock())
.environment(Tournament.mock()) // .environment(Tournament.mock())
} //}

@ -43,6 +43,6 @@ struct RoundsView: View {
} }
} }
#Preview { //#Preview {
RoundsView(tournament: Tournament.mock()) // RoundsView(tournament: Tournament.mock())
} //}

@ -50,8 +50,8 @@ struct MatchFormatPickerView: View {
} }
#Preview { //#Preview {
List { // List {
MatchFormatPickerView(headerLabel: "Test", matchFormat: .constant(MatchFormat.superTie)) // MatchFormatPickerView(headerLabel: "Test", matchFormat: .constant(MatchFormat.superTie))
} // }
} //}

@ -145,6 +145,6 @@ struct TournamentFilterView: View {
} }
} }
#Preview { //#Preview {
TournamentFilterView(federalDataViewModel: FederalDataViewModel()) // TournamentFilterView(federalDataViewModel: FederalDataViewModel())
} //}

@ -116,6 +116,6 @@ struct PurchaseView: View {
} }
} }
#Preview { //#Preview {
PurchaseListView() // PurchaseListView()
} //}

@ -52,6 +52,6 @@ struct NoPaymentTip: Tip {
} }
} }
#Preview { //#Preview {
SubscriptionInfoView(payment: .free) // SubscriptionInfoView(payment: .free)
} //}

@ -398,12 +398,12 @@ fileprivate struct SubscriptionDetailView: View {
} }
#Preview { //#Preview {
SubscriptionDetailView() // SubscriptionDetailView()
} //}
#Preview { //#Preview {
NavigationStack { // NavigationStack {
SubscriptionView(isPresented: .constant(true), showLackOfPlanMessage: false) // SubscriptionView(isPresented: .constant(true), showLackOfPlanMessage: false)
} // }
} //}

@ -26,6 +26,12 @@ struct TeamHeaderView: View {
Text("Poids").font(.caption) Text("Poids").font(.caption)
Text(team.weight.formatted()) Text(team.weight.formatted())
} }
if let name = team.name {
VStack(alignment: .leading, spacing: 0) {
Text("Nom de l'équipe").font(.caption)
Text(name)
}
}
} }
Spacer() Spacer()
VStack(alignment: .trailing, spacing: 0) { VStack(alignment: .trailing, spacing: 0) {
@ -45,6 +51,6 @@ struct TeamHeaderView: View {
} }
} }
#Preview { //#Preview {
TeamHeaderView(team: TeamRegistration.mock(), teamIndex: 1, tournament: nil) // TeamHeaderView(team: TeamRegistration.mock(), teamIndex: 1, tournament: nil)
} //}

@ -39,6 +39,6 @@ struct TeamWeightView: View {
} }
} }
#Preview { //#Preview {
TeamWeightView(team: TeamRegistration.mock(), teamPosition: .one) // TeamWeightView(team: TeamRegistration.mock(), teamPosition: .one)
} //}

@ -12,14 +12,34 @@ struct EditingTeamView: View {
@EnvironmentObject var dataStore: DataStore @EnvironmentObject var dataStore: DataStore
var team: TeamRegistration var team: TeamRegistration
@State private var registrationDate : Date @State private var registrationDate : Date
@State private var name: String
init(team: TeamRegistration) { init(team: TeamRegistration) {
self.team = team self.team = team
_name = .init(wrappedValue: team.name ?? "")
_registrationDate = State(wrappedValue: team.registrationDate ?? Date()) _registrationDate = State(wrappedValue: team.registrationDate ?? Date())
} }
var body: some View { var body: some View {
List { List {
Section {
TextField("Nom de l'équipe", text: $name)
.autocorrectionDisabled()
.keyboardType(.alphabet)
.frame(maxWidth: .infinity)
.submitLabel(.done)
.onSubmit(of: .text) {
let trimmed = name.trimmed
if trimmed.isEmpty {
team.name = nil
} else {
team.name = trimmed
}
_save()
}
}
Section { Section {
DatePicker(registrationDate.formatted(.dateTime.weekday()), selection: $registrationDate) DatePicker(registrationDate.formatted(.dateTime.weekday()), selection: $registrationDate)
} header: { } header: {
@ -61,6 +81,6 @@ struct EditingTeamView: View {
} }
} }
#Preview { //#Preview {
EditingTeamView(team: TeamRegistration.mock()) // EditingTeamView(team: TeamRegistration.mock())
} //}

@ -28,6 +28,6 @@ struct TeamDetailView: View {
} }
} }
#Preview { //#Preview {
TeamDetailView(team: TeamRegistration.mock()) // TeamDetailView(team: TeamRegistration.mock())
} //}

@ -89,10 +89,10 @@ struct TeamPickerView: View {
} }
} }
#Preview { //#Preview {
TeamPickerView(teamPicked: { team in // TeamPickerView(teamPicked: { team in
}) // })
.environment(Tournament.mock()) // .environment(Tournament.mock())
.environmentObject(DataStore.shared) // .environmentObject(DataStore.shared)
//
} //}

@ -17,6 +17,9 @@ struct TeamRowView: View {
TeamWeightView(team: team, teamPosition: teamPosition) TeamWeightView(team: team, teamPosition: teamPosition)
} label: { } label: {
VStack(alignment: .leading) { VStack(alignment: .leading) {
if let name = team.name {
Text(name).foregroundStyle(.secondary)
}
ForEach(team.players()) { player in ForEach(team.players()) { player in
Text(player.playerLabel()) Text(player.playerLabel())
} }
@ -31,6 +34,6 @@ struct TeamRowView: View {
} }
} }
#Preview { //#Preview {
TeamRowView(team: TeamRegistration.mock()) // TeamRowView(team: TeamRegistration.mock())
} //}

@ -215,6 +215,13 @@ struct FileImportView: View {
.navigationTitle("Importation") .navigationTitle("Importation")
.navigationBarTitleDisplayMode(.large) .navigationBarTitleDisplayMode(.large)
.toolbar { .toolbar {
ToolbarItem(placement: .bottomBar) {
PasteButton(payloadType: String.self) { strings in
guard let string = strings.first else { return }
fileContent = string
fileProvider = .padelClub
}
}
ToolbarItem(placement: .cancellationAction) { ToolbarItem(placement: .cancellationAction) {
Button("Annuler", role: .cancel) { Button("Annuler", role: .cancel) {
dismiss() dismiss()
@ -315,10 +322,10 @@ struct FileImportView: View {
} }
} }
#Preview { //#Preview {
FileImportView() // FileImportView()
.environment(Tournament.mock()) // .environment(Tournament.mock())
} //}
enum TeamImportStrategy: CaseIterable { enum TeamImportStrategy: CaseIterable {
case notFoundAreWalkOut case notFoundAreWalkOut

@ -373,6 +373,6 @@ struct BroadcastView: View {
} }
#Preview { //#Preview {
BroadcastView() // BroadcastView()
} //}

@ -216,7 +216,7 @@ struct InscriptionInfoView: View {
} }
} }
#Preview { //#Preview {
InscriptionInfoView() // InscriptionInfoView()
.environment(Tournament.mock()) // .environment(Tournament.mock())
} //}

@ -120,6 +120,6 @@ struct TournamentClubSettingsView: View {
} }
} }
#Preview { //#Preview {
TournamentClubSettingsView() // TournamentClubSettingsView()
} //}

@ -21,7 +21,7 @@ struct TournamentDurationManagerView: View {
} }
} }
#Preview { //#Preview {
TournamentDurationManagerView() // TournamentDurationManagerView()
.environment(Tournament.mock()) // .environment(Tournament.mock())
} //}

@ -22,7 +22,7 @@ struct TournamentFieldsManagerView: View {
} }
} }
#Preview { //#Preview {
TournamentFieldsManagerView(localizedStringKey: "test", count: .constant(2), max: 10) // TournamentFieldsManagerView(localizedStringKey: "test", count: .constant(2), max: 10)
.environment(Tournament.mock()) // .environment(Tournament.mock())
} //}

@ -116,6 +116,6 @@ struct TournamentMatchFormatsSettingsView: View {
} }
} }
#Preview { //#Preview {
TournamentMatchFormatsSettingsView() // TournamentMatchFormatsSettingsView()
} //}

@ -114,6 +114,6 @@ struct TournamentStatusView: View {
} }
} }
#Preview { //#Preview {
TournamentStatusView() // TournamentStatusView()
} //}

@ -96,6 +96,6 @@ struct UpdateSourceRankDateView: View {
} }
} }
#Preview { //#Preview {
UpdateSourceRankDateView(currentRankSourceDate: .constant(Date()), confirmUpdateRank: .constant(true), tournament: Tournament.mock()) // UpdateSourceRankDateView(currentRankSourceDate: .constant(Date()), confirmUpdateRank: .constant(true), tournament: Tournament.mock())
} //}

@ -22,6 +22,7 @@ let padelBeachImportTip = PadelBeachImportTip()
struct InscriptionManagerView: View { struct InscriptionManagerView: View {
@EnvironmentObject var dataStore: DataStore @EnvironmentObject var dataStore: DataStore
@EnvironmentObject var networkMonitor: NetworkMonitor @EnvironmentObject var networkMonitor: NetworkMonitor
@Environment(\.dismiss) var dismiss
@FetchRequest( @FetchRequest(
sortDescriptors: [], sortDescriptors: [],
@ -29,6 +30,8 @@ struct InscriptionManagerView: View {
private var fetchPlayers: FetchedResults<ImportedPlayer> private var fetchPlayers: FetchedResults<ImportedPlayer>
var tournament: Tournament var tournament: Tournament
var cancelShouldDismiss: Bool = false
@State private var searchField: String = "" @State private var searchField: String = ""
@State private var presentSearch: Bool = false @State private var presentSearch: Bool = false
@State private var presentPlayerSearch: Bool = false @State private var presentPlayerSearch: Bool = false
@ -101,20 +104,15 @@ struct InscriptionManagerView: View {
} }
} }
let categoryOption: PlayerFilterOption init(tournament: Tournament, pasteString: String? = nil) {
let filterable: Bool
init(tournament: Tournament) {
self.tournament = tournament self.tournament = tournament
_currentRankSourceDate = State(wrappedValue: tournament.rankSourceDate) if let pasteString {
switch tournament.tournamentCategory { _pasteString = .init(wrappedValue: pasteString)
case .women: _fetchPlayers = FetchRequest<ImportedPlayer>(sortDescriptors: [NSSortDescriptor(keyPath: \ImportedPlayer.rank, ascending: true)], predicate: Self._pastePredicate(pasteField: pasteString, mostRecentDate: tournament.rankSourceDate, filterOption: tournament.tournamentCategory.playerFilterOption))
categoryOption = .female _autoSelect = .init(wrappedValue: true)
filterable = false cancelShouldDismiss = true
default:
categoryOption = .all
filterable = true
} }
_currentRankSourceDate = State(wrappedValue: tournament.rankSourceDate)
} }
private func _clearScreen() { private func _clearScreen() {
@ -337,6 +335,9 @@ struct InscriptionManagerView: View {
editedTeam = nil editedTeam = nil
createdPlayers.removeAll() createdPlayers.removeAll()
createdPlayerIds.removeAll() createdPlayerIds.removeAll()
if cancelShouldDismiss {
dismiss()
}
} }
} }
} else { } else {
@ -515,7 +516,7 @@ struct InscriptionManagerView: View {
RowButtonView("Créer une équipe") { RowButtonView("Créer une équipe") {
Task { Task {
await MainActor.run() { await MainActor.run() {
fetchPlayers.nsPredicate = _pastePredicate(pasteField: searchField, mostRecentDate: SourceFileManager.shared.mostRecentDateAvailable) fetchPlayers.nsPredicate = Self._pastePredicate(pasteField: searchField, mostRecentDate: SourceFileManager.shared.mostRecentDateAvailable, filterOption: _filterOption())
fetchPlayers.nsSortDescriptors = [NSSortDescriptor(keyPath: \ImportedPlayer.rank, ascending: true)] fetchPlayers.nsSortDescriptors = [NSSortDescriptor(keyPath: \ImportedPlayer.rank, ascending: true)]
pasteString = searchField pasteString = searchField
} }
@ -572,7 +573,7 @@ struct InscriptionManagerView: View {
guard let first = strings.first else { return } guard let first = strings.first else { return }
Task { Task {
await MainActor.run { await MainActor.run {
fetchPlayers.nsPredicate = _pastePredicate(pasteField: first, mostRecentDate: SourceFileManager.shared.mostRecentDateAvailable) fetchPlayers.nsPredicate = Self._pastePredicate(pasteField: first, mostRecentDate: SourceFileManager.shared.mostRecentDateAvailable, filterOption: _filterOption())
fetchPlayers.nsSortDescriptors = [NSSortDescriptor(keyPath: \ImportedPlayer.rank, ascending: true)] fetchPlayers.nsSortDescriptors = [NSSortDescriptor(keyPath: \ImportedPlayer.rank, ascending: true)]
pasteString = first pasteString = first
autoSelect = true autoSelect = true
@ -641,14 +642,7 @@ struct InscriptionManagerView: View {
} }
private func _filterOption() -> PlayerFilterOption { private func _filterOption() -> PlayerFilterOption {
switch tournament.tournamentCategory { return tournament.tournamentCategory.playerFilterOption
case .men:
return .male
case .women:
return .female
case .mix:
return .all
}
} }
@ViewBuilder @ViewBuilder
@ -672,7 +666,7 @@ struct InscriptionManagerView: View {
if let paste = UIPasteboard.general.string { if let paste = UIPasteboard.general.string {
Task { Task {
await MainActor.run { await MainActor.run {
fetchPlayers.nsPredicate = _pastePredicate(pasteField: paste, mostRecentDate: SourceFileManager.shared.mostRecentDateAvailable) fetchPlayers.nsPredicate = Self._pastePredicate(pasteField: paste, mostRecentDate: SourceFileManager.shared.mostRecentDateAvailable, filterOption: _filterOption())
fetchPlayers.nsSortDescriptors = [NSSortDescriptor(keyPath: \ImportedPlayer.rank, ascending: true)] fetchPlayers.nsSortDescriptors = [NSSortDescriptor(keyPath: \ImportedPlayer.rank, ascending: true)]
pasteString = paste pasteString = paste
autoSelect = true autoSelect = true
@ -739,7 +733,7 @@ struct InscriptionManagerView: View {
LabeledContent { LabeledContent {
Text(max(0, unsortedTeamsWithoutWO.count - tournament.teamCount).formatted()).font(.largeTitle) Text(max(0, unsortedTeamsWithoutWO.count - tournament.teamCount).formatted()).font(.largeTitle)
} label: { } label: {
Text("Liste d'attente") Text("Attente")
} }
NavigationLink { NavigationLink {
@ -807,7 +801,7 @@ struct InscriptionManagerView: View {
selectionSearchField ?? pasteString selectionSearchField ?? pasteString
} }
private func _pastePredicate(pasteField: String, mostRecentDate: Date?) -> NSPredicate? { static private func _pastePredicate(pasteField: String, mostRecentDate: Date?, filterOption: PlayerFilterOption) -> NSPredicate? {
let text = pasteField.canonicalVersion let text = pasteField.canonicalVersion
let nameComponents = text.components(separatedBy: .whitespacesAndNewlines).compactMap { $0.isEmpty ? nil : $0 }.filter({ $0 != "de" && $0 != "la" && $0 != "le" && $0.count > 1 }) let nameComponents = text.components(separatedBy: .whitespacesAndNewlines).compactMap { $0.isEmpty ? nil : $0 }.filter({ $0 != "de" && $0 != "la" && $0 != "le" && $0.count > 1 })
@ -816,9 +810,9 @@ struct InscriptionManagerView: View {
//self.wordsCount = nameComponents.count //self.wordsCount = nameComponents.count
if _filterOption() == .male { if filterOption == .male {
andPredicates.append(NSPredicate(format: "male == YES")) andPredicates.append(NSPredicate(format: "male == YES"))
} else if _filterOption() == .female { } else if filterOption == .female {
andPredicates.append(NSPredicate(format: "male == NO")) andPredicates.append(NSPredicate(format: "male == NO"))
} }
@ -1244,9 +1238,9 @@ struct InscriptionManagerView: View {
} }
} }
#Preview { //#Preview {
NavigationStack { // NavigationStack {
InscriptionManagerView(tournament: Tournament.mock()) // InscriptionManagerView(tournament: Tournament.mock())
.environment(Tournament.mock()) // .environment(Tournament.mock())
} // }
} //}

@ -347,10 +347,10 @@ extension TableStructureView {
} }
#Preview { //#Preview {
NavigationStack { // NavigationStack {
TableStructureView() // TableStructureView()
.environment(Tournament.mock()) // .environment(Tournament.mock())
.environmentObject(DataStore.shared) // .environmentObject(DataStore.shared)
} // }
} //}

@ -109,6 +109,6 @@ struct TournamentCallView: View {
} }
#Preview { //#Preview {
TournamentCallView(tournament: Tournament.mock()) // TournamentCallView(tournament: Tournament.mock())
} //}

@ -158,9 +158,9 @@ struct TournamentCashierView: View {
} }
} }
#Preview { //#Preview {
TournamentCashierView(tournament: Tournament.mock()) // TournamentCashierView(tournament: Tournament.mock())
} //}
//class DebouncedObject: ObservableObject { //class DebouncedObject: ObservableObject {
// @Published var searchText: String = "" { // @Published var searchText: String = "" {

@ -101,6 +101,10 @@ struct TournamentRankView: View {
Divider() Divider()
VStack(alignment: .leading) { VStack(alignment: .leading) {
if let name = team.name {
Text(name).foregroundStyle(.secondary)
}
ForEach(team.players()) { player in ForEach(team.players()) { player in
VStack(alignment: .leading, spacing: -4.0) { VStack(alignment: .leading, spacing: -4.0) {
Text(player.playerLabel()).bold() Text(player.playerLabel()).bold()
@ -149,6 +153,6 @@ struct TournamentRankView: View {
} }
} }
#Preview { //#Preview {
TournamentRankView() // TournamentRankView()
} //}

@ -96,6 +96,6 @@ struct TournamentScheduleView: View {
} }
} }
#Preview { //#Preview {
TournamentScheduleView(tournament: Tournament.mock()) // TournamentScheduleView(tournament: Tournament.mock())
} //}

@ -83,6 +83,6 @@ struct TournamentSettingsView: View {
} }
#Preview { //#Preview {
TournamentSettingsView() // TournamentSettingsView()
} //}

@ -60,6 +60,6 @@ struct MonthYearView: View {
// } // }
//} //}
#Preview { //#Preview {
DateVerticalView(date: Date()) // DateVerticalView(date: Date())
} //}

@ -30,6 +30,6 @@ struct PadelClubButtonView: View {
} }
#Preview { //#Preview {
PadelClubButtonView(isImported: true) // PadelClubButtonView(isImported: true)
} //}

@ -151,6 +151,6 @@ struct TournamentCellView: View {
} }
} }
#Preview { //#Preview {
TournamentCellView(tournament: Tournament.fake()) // TournamentCellView(tournament: Tournament.fake())
} //}

@ -151,6 +151,6 @@ struct TournamentBuildView: View {
} }
} }
#Preview { //#Preview {
TournamentBuildView(tournament: Tournament.mock()) // TournamentBuildView(tournament: Tournament.mock())
} //}

@ -51,6 +51,6 @@ struct TournamentInitView: View {
} }
} }
#Preview { //#Preview {
TournamentInitView(tournament: Tournament.mock()) // TournamentInitView(tournament: Tournament.mock())
} //}

@ -25,6 +25,6 @@ struct TournamentRunningView: View {
} }
} }
#Preview { //#Preview {
TournamentRunningView(tournament: Tournament.mock()) // TournamentRunningView(tournament: Tournament.mock())
} //}

@ -200,8 +200,8 @@ struct TournamentView: View {
} }
} }
#Preview { //#Preview {
NavigationStack { // NavigationStack {
TournamentView(tournament: Tournament.mock(), presentationContext: .agenda) // TournamentView(tournament: Tournament.mock(), presentationContext: .agenda)
} // }
} //}

@ -26,8 +26,8 @@ struct AccountView: View {
} }
} }
#Preview { //#Preview {
AccountView(user: User(username: "coco", email: ",mail", firstName: "first", lastName: "last", phone: "44444", country: "US")) { // AccountView(user: User(username: "coco", email: ",mail", firstName: "first", lastName: "last", phone: "44444", country: "US")) {
//
} // }
} //}

@ -61,8 +61,8 @@ struct ChangePasswordView: View {
} }
#Preview { //#Preview {
NavigationStack { // NavigationStack {
ChangePasswordView() // ChangePasswordView()
} // }
} //}

@ -167,12 +167,12 @@ struct EmailConfirmationView: View {
} }
#Preview { //#Preview {
NavigationStack { // NavigationStack {
LoginView(handler: { _ in }) // LoginView(handler: { _ in })
} // }
} //}
#Preview { //#Preview {
EmailConfirmationView() // EmailConfirmationView()
} //}

@ -179,6 +179,6 @@ struct UserCreationFormView: View {
} }
#Preview { //#Preview {
UserCreationFormView(isPresented: .constant(true), showEmailValidationMessage: .constant(true)) // UserCreationFormView(isPresented: .constant(true), showEmailValidationMessage: .constant(true))
} //}

Loading…
Cancel
Save