|
|
|
@ -30,7 +30,8 @@ struct InscriptionManagerView: View { |
|
|
|
@State private var currentRankSourceDate: Date? |
|
|
|
@State private var currentRankSourceDate: Date? |
|
|
|
@State private var confirmUpdateRank = false |
|
|
|
@State private var confirmUpdateRank = false |
|
|
|
@State private var selectionSearchField: String? |
|
|
|
@State private var selectionSearchField: String? |
|
|
|
|
|
|
|
@State private var autoSelect: Bool = false |
|
|
|
|
|
|
|
|
|
|
|
let slideToDeleteTip = SlideToDeleteTip() |
|
|
|
let slideToDeleteTip = SlideToDeleteTip() |
|
|
|
let inscriptionManagerWomanRankTip = InscriptionManagerWomanRankTip() |
|
|
|
let inscriptionManagerWomanRankTip = InscriptionManagerWomanRankTip() |
|
|
|
let fileTip = InscriptionManagerFileInputTip() |
|
|
|
let fileTip = InscriptionManagerFileInputTip() |
|
|
|
@ -279,6 +280,7 @@ struct InscriptionManagerView: View { |
|
|
|
await MainActor.run { |
|
|
|
await MainActor.run { |
|
|
|
fetchPlayers.nsPredicate = _pastePredicate(pasteField: first, mostRecentDate: SourceFileManager.shared.mostRecentDateAvailable) |
|
|
|
fetchPlayers.nsPredicate = _pastePredicate(pasteField: first, mostRecentDate: SourceFileManager.shared.mostRecentDateAvailable) |
|
|
|
pasteString = first |
|
|
|
pasteString = first |
|
|
|
|
|
|
|
autoSelect = true |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
@ -563,6 +565,24 @@ struct InscriptionManagerView: View { |
|
|
|
|
|
|
|
|
|
|
|
private func _buildingTeamView() -> some View { |
|
|
|
private func _buildingTeamView() -> some View { |
|
|
|
List(selection: $createdPlayerIds) { |
|
|
|
List(selection: $createdPlayerIds) { |
|
|
|
|
|
|
|
if let pasteString { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Section { |
|
|
|
|
|
|
|
Text(pasteString) |
|
|
|
|
|
|
|
} footer: { |
|
|
|
|
|
|
|
HStack { |
|
|
|
|
|
|
|
Text("contenu du presse-papier") |
|
|
|
|
|
|
|
Spacer() |
|
|
|
|
|
|
|
Button("effacer", role: .destructive) { |
|
|
|
|
|
|
|
self.pasteString = nil |
|
|
|
|
|
|
|
self.createdPlayers.removeAll() |
|
|
|
|
|
|
|
self.createdPlayerIds.removeAll() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
.buttonStyle(.borderless) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Section { |
|
|
|
Section { |
|
|
|
ForEach(createdPlayerIds.sorted(), id: \.self) { id in |
|
|
|
ForEach(createdPlayerIds.sorted(), id: \.self) { id in |
|
|
|
if let p = createdPlayers.first(where: { $0.id == id }) { |
|
|
|
if let p = createdPlayers.first(where: { $0.id == id }) { |
|
|
|
@ -591,22 +611,6 @@ struct InscriptionManagerView: View { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if let pasteString { |
|
|
|
if let pasteString { |
|
|
|
|
|
|
|
|
|
|
|
Section { |
|
|
|
|
|
|
|
Text(pasteString) |
|
|
|
|
|
|
|
} footer: { |
|
|
|
|
|
|
|
HStack { |
|
|
|
|
|
|
|
Text("contenu du presse-papier") |
|
|
|
|
|
|
|
Spacer() |
|
|
|
|
|
|
|
Button("effacer", role: .destructive) { |
|
|
|
|
|
|
|
self.pasteString = nil |
|
|
|
|
|
|
|
self.createdPlayers.removeAll() |
|
|
|
|
|
|
|
self.createdPlayerIds.removeAll() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
.buttonStyle(.borderless) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if fetchPlayers.isEmpty { |
|
|
|
if fetchPlayers.isEmpty { |
|
|
|
ContentUnavailableView { |
|
|
|
ContentUnavailableView { |
|
|
|
Label("Aucun résultat", systemImage: "person.2.slash") |
|
|
|
Label("Aucun résultat", systemImage: "person.2.slash") |
|
|
|
@ -634,13 +638,13 @@ struct InscriptionManagerView: View { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
.onReceive(fetchPlayers.publisher.count()) { _ in // <-- here |
|
|
|
.onReceive(fetchPlayers.publisher.count()) { _ in // <-- here |
|
|
|
if let pasteString, count == 2 { |
|
|
|
if let pasteString, count == 2, autoSelect == true { |
|
|
|
fetchPlayers.filter { $0.hitForSearch(pasteString) >= hitTarget }.sorted(by: { $0.hitForSearch(pasteString) > $1.hitForSearch(pasteString) }).forEach { player in |
|
|
|
fetchPlayers.filter { $0.hitForSearch(pasteString) >= hitTarget }.sorted(by: { $0.hitForSearch(pasteString) > $1.hitForSearch(pasteString) }).forEach { player in |
|
|
|
createdPlayerIds.insert(player.license!) |
|
|
|
createdPlayerIds.insert(player.license!) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
autoSelect = false |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
.environment(\.editMode, Binding.constant(EditMode.active)) |
|
|
|
.environment(\.editMode, Binding.constant(EditMode.active)) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|