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. 7
      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. 16
      PadelClub/Views/User/LoginView.swift
  95. 6
      PadelClub/Views/User/UserCreationView.swift

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

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

@ -103,10 +103,12 @@ class FileImportManager {
let tournamentCategory: TournamentCategory
let previousTeam: TeamRegistration?
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.tournamentCategory = tournamentCategory
self.name = name
self.previousTeam = previousTeam
if players.count < 2 {
let s = players.compactMap { $0.sex?.rawValue }
@ -354,6 +356,14 @@ class FileImportManager {
}
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)
results.append(team)
}

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

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

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

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

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

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

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

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

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

@ -260,6 +260,6 @@ struct ClubDetailView: View {
}
}
#Preview {
ClubDetailView(club: Club.mock(), displayContext: .edition)
}
//#Preview {
// 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 {
ClubRowView(club: Club.mock())
}
//#Preview {
// ClubRowView(club: Club.mock())
//}

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

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

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

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

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

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

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

@ -126,15 +126,14 @@ struct GroupStageView: View {
}
.font(.footnote)
HStack {
if let teamName = team.name {
Text(teamName).font(.title)
} else {
VStack(alignment: .leading) {
if let teamName = team.name {
Text(teamName).foregroundStyle(.secondary)
}
ForEach(team.players()) { player in
Text(player.playerLabel()).lineLimit(1)
}
}
}
Spacer()
if let score = groupStage.scoreLabel(forGroupStagePosition: groupStagePosition, score: scores?.first(where: { $0.team.groupStagePosition == groupStagePosition })) {
VStack(alignment: .trailing) {

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

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

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

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

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

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

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

@ -21,6 +21,18 @@ struct ActivityView: View {
@State private var error: Error?
@State private var uuid: UUID = UUID()
@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] {
dataStore.tournaments.filter({ $0.endDate == nil })
@ -60,27 +72,15 @@ struct ActivityView: View {
@ViewBuilder
private func _pasteView() -> some View {
if UIPasteboard.general.hasStrings {
// Enable string-related control...
if let string = UIPasteboard.general.string {
// 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")
}
}
}
}
PasteButton(payloadType: String.self) { strings in
guard let first = strings.first else { return }
quickAccessScreen = .inscription(pasteString: first)
}
.foregroundStyle(.master)
.labelStyle(.iconOnly)
.buttonBorderShape(.capsule)
}
var body: some View {
@Bindable var navigation = navigation
NavigationStack(path: $navigation.path) {
@ -90,7 +90,6 @@ struct ActivityView: View {
List {
switch navigation.agendaDestination! {
case .activity:
_pasteView()
EventListView(tournaments: runningTournaments, viewStyle: viewStyle, sortAscending: true)
case .history:
EventListView(tournaments: endedTournaments, viewStyle: viewStyle, sortAscending: false)
@ -196,6 +195,8 @@ struct ActivityView: View {
.frame(minHeight: 28)
}
.symbolVariant(federalDataViewModel.areFiltersEnabled() ? .fill : .none)
_pasteView()
}
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() {
@ -323,6 +364,6 @@ struct ActivityView: View {
}
#Preview {
ActivityView()
}
//#Preview {
// ActivityView()
//}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

@ -12,14 +12,34 @@ struct EditingTeamView: View {
@EnvironmentObject var dataStore: DataStore
var team: TeamRegistration
@State private var registrationDate : Date
@State private var name: String
init(team: TeamRegistration) {
self.team = team
_name = .init(wrappedValue: team.name ?? "")
_registrationDate = State(wrappedValue: team.registrationDate ?? Date())
}
var body: some View {
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 {
DatePicker(registrationDate.formatted(.dateTime.weekday()), selection: $registrationDate)
} header: {
@ -61,6 +81,6 @@ struct EditingTeamView: View {
}
}
#Preview {
EditingTeamView(team: TeamRegistration.mock())
}
//#Preview {
// EditingTeamView(team: TeamRegistration.mock())
//}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Loading…
Cancel
Save