|
|
|
@ -34,6 +34,39 @@ struct InscriptionManagerView: View { |
|
|
|
@State private var autoSelect: Bool = false |
|
|
|
@State private var autoSelect: Bool = false |
|
|
|
@State private var teamsHash: Int? |
|
|
|
@State private var teamsHash: Int? |
|
|
|
@State private var presentationCount: Int = 0 |
|
|
|
@State private var presentationCount: Int = 0 |
|
|
|
|
|
|
|
@State private var filterMode: FilterMode = .all |
|
|
|
|
|
|
|
@State private var sortingMode: SortingMode = .teamWeight |
|
|
|
|
|
|
|
@State private var byDecreasingOrdering: Bool = false |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
enum SortingMode: Int, Identifiable, CaseIterable { |
|
|
|
|
|
|
|
var id: Int { self.rawValue } |
|
|
|
|
|
|
|
case registrationDate |
|
|
|
|
|
|
|
case teamWeight |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func localizedLabel() -> String { |
|
|
|
|
|
|
|
switch self { |
|
|
|
|
|
|
|
case .registrationDate: |
|
|
|
|
|
|
|
return "Date d'inscription" |
|
|
|
|
|
|
|
case .teamWeight: |
|
|
|
|
|
|
|
return "Poids d'équipe" |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
enum FilterMode: Int, Identifiable, CaseIterable { |
|
|
|
|
|
|
|
var id: Int { self.rawValue } |
|
|
|
|
|
|
|
case all |
|
|
|
|
|
|
|
case walkOut |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func localizedLabel() -> String { |
|
|
|
|
|
|
|
switch self { |
|
|
|
|
|
|
|
case .all: |
|
|
|
|
|
|
|
return "Toutes les équipes" |
|
|
|
|
|
|
|
case .walkOut: |
|
|
|
|
|
|
|
return "Voir les WOs" |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
let slideToDeleteTip = SlideToDeleteTip() |
|
|
|
let slideToDeleteTip = SlideToDeleteTip() |
|
|
|
let inscriptionManagerWomanRankTip = InscriptionManagerWomanRankTip() |
|
|
|
let inscriptionManagerWomanRankTip = InscriptionManagerWomanRankTip() |
|
|
|
@ -167,7 +200,29 @@ struct InscriptionManagerView: View { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
ToolbarItem(placement: .navigationBarTrailing) { |
|
|
|
ToolbarItemGroup(placement: .navigationBarTrailing) { |
|
|
|
|
|
|
|
Menu { |
|
|
|
|
|
|
|
Picker(selection: $filterMode) { |
|
|
|
|
|
|
|
ForEach(FilterMode.allCases) { |
|
|
|
|
|
|
|
Text($0.localizedLabel()).tag($0) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} label: { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
Picker(selection: $sortingMode) { |
|
|
|
|
|
|
|
ForEach(SortingMode.allCases) { |
|
|
|
|
|
|
|
Text($0.localizedLabel()).tag($0) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} label: { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Picker(selection: $byDecreasingOrdering) { |
|
|
|
|
|
|
|
Text("Croissant").tag(false) |
|
|
|
|
|
|
|
Text("Décroissant").tag(true) |
|
|
|
|
|
|
|
} label: { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} label: { |
|
|
|
|
|
|
|
LabelFilter() |
|
|
|
|
|
|
|
} |
|
|
|
Menu { |
|
|
|
Menu { |
|
|
|
if tournament.inscriptionClosed() == false { |
|
|
|
if tournament.inscriptionClosed() == false { |
|
|
|
Menu { |
|
|
|
Menu { |
|
|
|
@ -233,9 +288,27 @@ struct InscriptionManagerView: View { |
|
|
|
createdPlayerIds.isEmpty == false || editedTeam != nil || pasteString != nil |
|
|
|
createdPlayerIds.isEmpty == false || editedTeam != nil || pasteString != nil |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private func _getTeams(from sortedTeams: [TeamRegistration]) -> [TeamRegistration] { |
|
|
|
|
|
|
|
var teams = sortedTeams |
|
|
|
|
|
|
|
if filterMode == .walkOut { |
|
|
|
|
|
|
|
teams = teams.filter({ $0.walkOut }) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if sortingMode == .registrationDate { |
|
|
|
|
|
|
|
teams = teams.sorted(by: \.computedRegistrationDate) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if byDecreasingOrdering { |
|
|
|
|
|
|
|
return teams.reversed() |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
return teams |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private func _teamRegisteredView() -> some View { |
|
|
|
private func _teamRegisteredView() -> some View { |
|
|
|
List { |
|
|
|
List { |
|
|
|
let unfilteredTeams = tournament.sortedTeams() |
|
|
|
let sortedTeams = tournament.sortedTeams() |
|
|
|
|
|
|
|
let unfilteredTeams = _getTeams(from: sortedTeams) |
|
|
|
|
|
|
|
|
|
|
|
if presentSearch == false { |
|
|
|
if presentSearch == false { |
|
|
|
_rankHandlerView() |
|
|
|
_rankHandlerView() |
|
|
|
@ -273,7 +346,7 @@ struct InscriptionManagerView: View { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
ForEach(teams) { team in |
|
|
|
ForEach(teams) { team in |
|
|
|
let teamIndex = team.index(in: unfilteredTeams) |
|
|
|
let teamIndex = team.index(in: sortedTeams) |
|
|
|
Section { |
|
|
|
Section { |
|
|
|
TeamDetailView(team: team) |
|
|
|
TeamDetailView(team: team) |
|
|
|
} header: { |
|
|
|
} header: { |
|
|
|
|