improve export data capability for teams / players

main
Razmig Sarkissian 4 weeks ago
parent 18228396bf
commit bd03321cc0
  1. 4
      PadelClub/Views/Calling/Components/PlayersWithoutContactView.swift
  2. 4
      PadelClub/Views/Calling/SendToAllView.swift
  3. 2
      PadelClub/Views/Cashier/CashierView.swift
  4. 1
      PadelClub/Views/GroupStage/GroupStageView.swift
  5. 1
      PadelClub/Views/Match/MatchSetupView.swift
  6. 2
      PadelClub/Views/Player/PlayerDetailView.swift
  7. 2
      PadelClub/Views/Shared/LearnMoreSheetView.swift
  8. 2
      PadelClub/Views/Team/EditingTeamView.swift
  9. 29
      PadelClub/Views/Tournament/Screen/InscriptionManagerView.swift

@ -14,7 +14,7 @@ struct PlayersWithoutContactView: View {
var body: some View {
Section {
let withoutEmails = players.filter({ $0.email?.isEmpty == true || $0.email == nil })
let withoutEmails = players.filter({ $0.hasMail() == false })
DisclosureGroup {
ForEach(withoutEmails) { player in
NavigationLink {
@ -32,7 +32,7 @@ struct PlayersWithoutContactView: View {
}
}
let withoutPhones = players.filter({ $0.phoneNumber?.isEmpty == true || $0.phoneNumber == nil || $0.phoneNumber?.isMobileNumber() == false })
let withoutPhones = players.filter({ $0.hasMobilePhone() == false })
DisclosureGroup {
ForEach(withoutPhones) { player in
NavigationLink {

@ -273,9 +273,9 @@ struct SendToAllView: View {
self._verifyUser {
if contactMethod == 0 {
contactType = .message(date: nil, recipients: _teams().flatMap { $0.unsortedPlayers() }.compactMap { $0.phoneNumber }, body: finalMessage(), tournamentBuild: nil)
contactType = .message(date: nil, recipients: _teams().flatMap { $0.unsortedPlayers() }.flatMap { [$0.phoneNumber, $0.contactPhoneNumber] }.compactMap({ $0 }), body: finalMessage(), tournamentBuild: nil)
} else {
contactType = .mail(date: nil, recipients: tournament.umpireMail(), bccRecipients: _teams().flatMap { $0.unsortedPlayers() }.compactMap { $0.email }, body: finalMessage(), subject: tournament.mailSubject(), tournamentBuild: nil)
contactType = .mail(date: nil, recipients: tournament.umpireMail(), bccRecipients: _teams().flatMap { $0.unsortedPlayers() }.flatMap { [$0.email, $0.contactEmail] }.compactMap({ $0 }), body: finalMessage(), subject: tournament.mailSubject(), tournamentBuild: nil)
}
}

@ -18,7 +18,7 @@ struct ShareableObject {
func sharedData() async -> Data? {
let _players = players.filter({ cashierViewModel._shouldDisplayPlayer($0) })
.map {
[$0.pasteData()]
[$0.pasteData(type: .payment)]
.compacted()
.joined(separator: "\n")
}

@ -245,7 +245,6 @@ struct GroupStageView: View {
Text("#\(index + 1)")
.font(.caption)
TeamPickerView(groupStagePosition: index, pickTypeContext: .groupStage, teamPicked: { team in
print(team.pasteData())
team.groupStage = groupStage.id
team.groupStagePosition = index
groupStage._matches().forEach({ $0.updateTeamScores() })

@ -65,7 +65,6 @@ struct MatchSetupView: View {
HStack {
let luckyLosers = walkOutSpot ? match.luckyLosers() : []
TeamPickerView(shouldConfirm: shouldConfirm, round: match.roundObject, pickTypeContext: matchTypeContext == .bracket ? .bracket : .loserBracket, luckyLosers: luckyLosers, teamPicked: { team in
print(team.pasteData())
if walkOutSpot || team.bracketPosition != nil || matchTypeContext == .loserBracket {
match.setLuckyLoser(team: team, teamPosition: teamPosition)
do {

@ -372,7 +372,7 @@ struct PlayerDetailView: View {
.toolbarBackground(.visible, for: .navigationBar)
.toolbar {
ToolbarItem(placement: .topBarTrailing) {
ShareLink(item: player.pasteData()) {
ShareLink(item: player.pasteData(type: .sharing)) {
Label("Partager", systemImage: "square.and.arrow.up")
}
}

@ -28,7 +28,7 @@ struct LearnMoreSheetView: View {
""")
} actions: {
ShareLink(item: tournament.pasteDataForImporting().createFile(tournament.tournamentTitle(.short))) {
ShareLink(item: tournament.pasteDataForImporting(type: .sharing).createFile(tournament.tournamentTitle(.short))) {
Text("Exporter les inscriptions")
}

@ -116,7 +116,7 @@ struct EditingTeamView: View {
}
} footer: {
HStack {
CopyPasteButtonView(pasteValue: team.playersPasteData())
CopyPasteButtonView(pasteValue: team.playersPasteData(type: .sharing))
Spacer()
if team.isWildCard(), team.unsortedPlayers().isEmpty {
TeamPickerView(pickTypeContext: .wildcard) { teamregistration in

@ -547,11 +547,25 @@ struct InscriptionManagerView: View {
private func _sharingTeamsMenuView() -> some View {
Menu {
ShareLink(item: teamPaste(), preview: .init("Inscriptions")) {
Text("En texte")
Menu {
ShareLink(item: teamPaste(.rawText, type: .sharing), preview: .init(ExportType.sharing.localizedString().capitalized)) {
Text("En texte")
}
ShareLink(item: teamPaste(.csv, type: .sharing), preview: .init(ExportType.sharing.localizedString().capitalized)) {
Text("En csv")
}
} label: {
Text("Pour diffusion")
}
ShareLink(item: teamPaste(.csv), preview: .init("Inscriptions")) {
Text("En csv")
Menu {
ShareLink(item: teamPaste(.rawText, type: .payment), preview: .init(ExportType.payment.localizedString().capitalized)) {
Text("En texte")
}
ShareLink(item: teamPaste(.csv, type: .payment), preview: .init(ExportType.payment.localizedString().capitalized)) {
Text("En csv")
}
} label: {
Text("Pour encaissement")
}
} label: {
Label("Exporter les paires", systemImage: "square.and.arrow.up")
@ -575,8 +589,8 @@ struct InscriptionManagerView: View {
tournament.unsortedTeamsWithoutWO()
}
func teamPaste(_ exportFormat: ExportFormat = .rawText) -> TournamentShareFile {
TournamentShareFile(tournament: tournament, exportFormat: exportFormat)
func teamPaste(_ exportFormat: ExportFormat = .rawText, type: ExportType) -> TournamentShareFile {
TournamentShareFile(tournament: tournament, exportFormat: exportFormat, type: type)
}
var unsortedPlayers: [PlayerRegistration] {
@ -1251,10 +1265,11 @@ struct TournamentGroupStageShareContent: Transferable {
struct TournamentShareFile: Transferable {
let tournament: Tournament
let exportFormat: ExportFormat
let type: ExportType
func shareFile() -> URL {
print("Generating URL...")
return tournament.pasteDataForImporting(exportFormat).createFile(self.tournament.tournamentTitle()+"-inscriptions", exportFormat)
return tournament.pasteDataForImporting(exportFormat, type: type).createFile(self.tournament.tournamentTitle()+"-"+type.localizedString(), exportFormat)
}
static var transferRepresentation: some TransferRepresentation {

Loading…
Cancel
Save