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 { var body: some View {
Section { Section {
let withoutEmails = players.filter({ $0.email?.isEmpty == true || $0.email == nil }) let withoutEmails = players.filter({ $0.hasMail() == false })
DisclosureGroup { DisclosureGroup {
ForEach(withoutEmails) { player in ForEach(withoutEmails) { player in
NavigationLink { 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 { DisclosureGroup {
ForEach(withoutPhones) { player in ForEach(withoutPhones) { player in
NavigationLink { NavigationLink {

@ -273,9 +273,9 @@ struct SendToAllView: View {
self._verifyUser { self._verifyUser {
if contactMethod == 0 { 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 { } 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? { func sharedData() async -> Data? {
let _players = players.filter({ cashierViewModel._shouldDisplayPlayer($0) }) let _players = players.filter({ cashierViewModel._shouldDisplayPlayer($0) })
.map { .map {
[$0.pasteData()] [$0.pasteData(type: .payment)]
.compacted() .compacted()
.joined(separator: "\n") .joined(separator: "\n")
} }

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

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

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

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

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

@ -547,11 +547,25 @@ struct InscriptionManagerView: View {
private func _sharingTeamsMenuView() -> some View { private func _sharingTeamsMenuView() -> some View {
Menu { Menu {
ShareLink(item: teamPaste(), preview: .init("Inscriptions")) { Menu {
Text("En texte") 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")) { Menu {
Text("En csv") 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: {
Label("Exporter les paires", systemImage: "square.and.arrow.up") Label("Exporter les paires", systemImage: "square.and.arrow.up")
@ -575,8 +589,8 @@ struct InscriptionManagerView: View {
tournament.unsortedTeamsWithoutWO() tournament.unsortedTeamsWithoutWO()
} }
func teamPaste(_ exportFormat: ExportFormat = .rawText) -> TournamentShareFile { func teamPaste(_ exportFormat: ExportFormat = .rawText, type: ExportType) -> TournamentShareFile {
TournamentShareFile(tournament: tournament, exportFormat: exportFormat) TournamentShareFile(tournament: tournament, exportFormat: exportFormat, type: type)
} }
var unsortedPlayers: [PlayerRegistration] { var unsortedPlayers: [PlayerRegistration] {
@ -1251,10 +1265,11 @@ struct TournamentGroupStageShareContent: Transferable {
struct TournamentShareFile: Transferable { struct TournamentShareFile: Transferable {
let tournament: Tournament let tournament: Tournament
let exportFormat: ExportFormat let exportFormat: ExportFormat
let type: ExportType
func shareFile() -> URL { func shareFile() -> URL {
print("Generating 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 { static var transferRepresentation: some TransferRepresentation {

Loading…
Cancel
Save