multistore
Razmig Sarkissian 1 year ago
parent ceeb479ac6
commit 5be8ef5d19
  1. 8
      PadelClub/Utils/FileImportManager.swift
  2. 4
      PadelClub/Views/Cashier/Event/EventLinksView.swift
  3. 2
      PadelClub/Views/GroupStage/GroupStageSettingsView.swift
  4. 39
      PadelClub/Views/Planning/PlanningSettingsView.swift
  5. 87
      PadelClub/Views/Tournament/FileImportView.swift
  6. 4
      PadelClub/Views/Tournament/Screen/TableStructureView.swift

@ -82,7 +82,7 @@ class FileImportManager {
case frenchFederation case frenchFederation
case padelClub case padelClub
case unknown case custom
var localizedLabel: String { var localizedLabel: String {
switch self { switch self {
@ -90,8 +90,8 @@ class FileImportManager {
return "Padel Club" return "Padel Club"
case .frenchFederation: case .frenchFederation:
return "FFT" return "FFT"
case .unknown: case .custom:
return "Inconnu" return "Personnalisé"
} }
} }
} }
@ -158,7 +158,7 @@ class FileImportManager {
return try await _getFederalTeams(from: fileContent, tournament: tournament) return try await _getFederalTeams(from: fileContent, tournament: tournament)
case .padelClub: case .padelClub:
return await _getPadelClubTeams(from: fileContent, tournament: tournament) return await _getPadelClubTeams(from: fileContent, tournament: tournament)
case .unknown: case .custom:
return await _getPadelBusinessLeagueTeams(from: fileContent, tournament: tournament) return await _getPadelBusinessLeagueTeams(from: fileContent, tournament: tournament)
} }
} }

@ -34,7 +34,7 @@ struct EventLinksView: View {
let links : [PageLink] = [.teams, .summons, .groupStages, .matches, .rankings] let links : [PageLink] = [.teams, .summons, .groupStages, .matches, .rankings]
Picker(selection: $pageLink) { Picker(selection: $pageLink) {
ForEach(links) { pageLink in ForEach(links) { pageLink in
Text(pageLink.localizedLabel()) Text(pageLink.localizedLabel()).tag(pageLink)
} }
} label: { } label: {
Text("Choisir une page du tournoi en particulier") Text("Choisir une page du tournoi en particulier")
@ -49,7 +49,7 @@ struct EventLinksView: View {
.multilineTextAlignment(.leading) .multilineTextAlignment(.leading)
ShareLink("Partagez ce message", item: eventLinksPasteData) ShareLink("Partagez ce lien", item: eventLinksPasteData)
} }
} }
} }

@ -43,7 +43,7 @@ struct GroupStageSettingsView: View {
Section { Section {
menuBuildAllGroupStages menuBuildAllGroupStages
} footer: { } footer: {
Text("efface et recréé les poules, les horaires et les résultats existants seront perdus") Text("Efface et recréé les poules, les horaires et les résultats existants seront perdus")
} }
} }

@ -93,16 +93,30 @@ struct PlanningSettingsView: View {
.foregroundStyle(.logoRed) .foregroundStyle(.logoRed)
} }
if tournament.groupStageCount > 0 {
Section {
TournamentFieldsManagerView(localizedStringKey: "Poule en parallèle", count: $groupStageChunkCount, max: tournament.groupStageCount)
.onChange(of: groupStageChunkCount) {
matchScheduler.groupStageChunkCount = groupStageChunkCount
}
} footer: {
NavigationLink { NavigationLink {
List {
_optionsView() _optionsView()
} label: {
Text("Voir les options avancées")
.underline()
.foregroundStyle(.master)
} }
.navigationTitle("Options avancées") }
.navigationBarTitleDisplayMode(.inline) } else {
.toolbarBackground(.visible, for: .navigationBar) Section {
NavigationLink {
_optionsView()
} label: { } label: {
Text("Voir les options avancées") Text("Voir les options avancées")
} }
}
}
let allMatches = tournament.allMatches() let allMatches = tournament.allMatches()
let allGroupStages = tournament.groupStages() let allGroupStages = tournament.groupStages()
@ -204,17 +218,7 @@ struct PlanningSettingsView: View {
@ViewBuilder @ViewBuilder
private func _optionsView() -> some View { private func _optionsView() -> some View {
if tournament.groupStageCount > 0 { List {
Section {
TournamentFieldsManagerView(localizedStringKey: "Poule en parallèle", count: $groupStageChunkCount, max: tournament.groupStageCount)
.onChange(of: groupStageChunkCount) {
matchScheduler.groupStageChunkCount = groupStageChunkCount
}
} footer: {
Text("Vous pouvez indiquer le nombre de poule démarrant en même temps.")
}
}
Section { Section {
Toggle(isOn: $matchScheduler.overrideCourtsUnavailability) { Toggle(isOn: $matchScheduler.overrideCourtsUnavailability) {
Text("Ne pas tenir compte des autres épreuves") Text("Ne pas tenir compte des autres épreuves")
@ -273,6 +277,11 @@ struct PlanningSettingsView: View {
Text("Si libre plus de \(matchScheduler.timeDifferenceLimit) minutes") Text("Si libre plus de \(matchScheduler.timeDifferenceLimit) minutes")
} }
} }
}
.navigationTitle("Options avancées")
.navigationBarTitleDisplayMode(.inline)
.toolbarBackground(.visible, for: .navigationBar)
} }
private func _setupSchedule() async -> Bool { private func _setupSchedule() async -> Bool {

@ -9,6 +9,51 @@ import SwiftUI
import TipKit import TipKit
import LeStorage import LeStorage
enum FileImportCustomField: Int, Identifiable, CaseIterable {
var id: Int { self.rawValue }
case sexType
case teamName
case lastName
case firstName
case rank
case licenceId
case clubName
func columnLabel() -> String {
let columnIndex: Int = self.rawValue + 1
return columnIndex.formatted()
}
func descriptionLabel() -> String? {
switch self {
case .sexType:
return "f ou m"
default:
return nil
}
}
func localizedLabel() -> String {
switch self {
case .sexType:
return "Sexe"
case .teamName:
return "Nom de l'équipe"
case .lastName:
return "Nom"
case .firstName:
return "Prénom"
case .rank:
return "Rang"
case .licenceId:
return "Licence"
case .clubName:
return "Nom du club"
}
}
}
struct FileImportView: View { struct FileImportView: View {
@EnvironmentObject var dataStore: DataStore @EnvironmentObject var dataStore: DataStore
@Environment(Tournament.self) var tournament: Tournament @Environment(Tournament.self) var tournament: Tournament
@ -29,6 +74,7 @@ struct FileImportView: View {
@State private var fileProvider: FileImportManager.FileProvider = .frenchFederation @State private var fileProvider: FileImportManager.FileProvider = .frenchFederation
@State private var validationInProgress: Bool = false @State private var validationInProgress: Bool = false
@State private var multiImport: Bool = false @State private var multiImport: Bool = false
@State private var presentFormatHelperView: Bool = false
private func filteredTeams(tournament: Tournament) -> [FileImportManager.TeamHolder] { private func filteredTeams(tournament: Tournament) -> [FileImportManager.TeamHolder] {
return teams.filter { $0.tournamentCategory == tournament.tournamentCategory }.sorted(by: \.weight) return teams.filter { $0.tournamentCategory == tournament.tournamentCategory }.sorted(by: \.weight)
@ -83,6 +129,10 @@ struct FileImportView: View {
if fileProvider == .frenchFederation { if fileProvider == .frenchFederation {
let footerString = "Fichier provenant de [beach-padel.app.fft.fr](\(URLs.beachPadel.rawValue))" let footerString = "Fichier provenant de [beach-padel.app.fft.fr](\(URLs.beachPadel.rawValue))"
Text(.init(footerString)) Text(.init(footerString))
} else if fileProvider == .custom {
FooterButtonView("Voir le format du fichier") {
presentFormatHelperView = true
}
} }
} }
@ -228,6 +278,43 @@ struct FileImportView: View {
} }
} }
} }
.navigationBarTitleDisplayMode(.inline)
.toolbarBackground(.visible, for: .navigationBar)
.sheet(isPresented: $presentFormatHelperView) {
NavigationStack {
List {
Section {
Text("Créer un fichier xls, xlsx ou csv qui contient les colonnes suivantes.")
Text("Chaque ligne correspond à un joueur, et chaque groupe de deux lignes correspond à une équipe.")
Text("Aucune valeur n'est obligatoire.")
}
Section {
ForEach(FileImportCustomField.allCases) { fileImportCustomField in
LabeledContent {
Text(fileImportCustomField.localizedLabel())
} label: {
Text("Colonne \(fileImportCustomField.columnLabel())")
if let descriptionLabel = fileImportCustomField.descriptionLabel() {
Text(descriptionLabel)
}
}
}
}
}
.navigationTitle("Description du format")
.navigationBarTitleDisplayMode(.inline)
.toolbarBackground(.visible, for: .navigationBar)
.toolbar {
ToolbarItem(placement: .topBarLeading) {
Button("Fermer") {
presentFormatHelperView = false
}
}
}
}
.tint(.master)
}
.fileImporter(isPresented: $isShowing, allowedContentTypes: [.spreadsheet, .commaSeparatedText, .text], allowsMultipleSelection: false, onCompletion: { results in .fileImporter(isPresented: $isShowing, allowedContentTypes: [.spreadsheet, .commaSeparatedText, .text], allowsMultipleSelection: false, onCompletion: { results in
switch results { switch results {

@ -142,7 +142,7 @@ struct TableStructureView: View {
} }
Section { Section {
RowButtonView("Recontruire les poules", role:.destructive) { RowButtonView("Reconstruire les poules", role:.destructive) {
_save(rebuildEverything: false) _save(rebuildEverything: false)
} }
} }
@ -227,7 +227,7 @@ struct TableStructureView: View {
_saveWithoutRebuild() _saveWithoutRebuild()
} }
Button("Recontruire les poules") { Button("Reconstruire les poules") {
_save(rebuildEverything: false) _save(rebuildEverything: false)
} }

Loading…
Cancel
Save