Compare commits
2 Commits
d9c5d242ec
...
f060c9771f
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f060c9771f | ||
|
|
0ab71166aa |
@@ -125,6 +125,7 @@ class CmsRepository @Inject constructor(
|
|||||||
spieler = values[7],
|
spieler = values[7],
|
||||||
informationenLink = values[8],
|
informationenLink = values[8],
|
||||||
letzteAktualisierung = values[9],
|
letzteAktualisierung = values[9],
|
||||||
|
spielplanMannschaftId = values.getOrElse(10) { "" },
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -381,6 +382,7 @@ data class CmsMannschaftRow(
|
|||||||
val spieler: String = "",
|
val spieler: String = "",
|
||||||
val informationenLink: String = "",
|
val informationenLink: String = "",
|
||||||
val letzteAktualisierung: String = "",
|
val letzteAktualisierung: String = "",
|
||||||
|
val spielplanMannschaftId: String = "",
|
||||||
)
|
)
|
||||||
|
|
||||||
private fun List<CmsMannschaftRow>.toMannschaftenCsv(): String {
|
private fun List<CmsMannschaftRow>.toMannschaftenCsv(): String {
|
||||||
@@ -395,6 +397,7 @@ private fun List<CmsMannschaftRow>.toMannschaftenCsv(): String {
|
|||||||
"Spieler",
|
"Spieler",
|
||||||
"Weitere Informationen Link",
|
"Weitere Informationen Link",
|
||||||
"Letzte Aktualisierung",
|
"Letzte Aktualisierung",
|
||||||
|
"Spielplan Mannschaft ID",
|
||||||
).toCsvRow()
|
).toCsvRow()
|
||||||
val rows = map { row ->
|
val rows = map { row ->
|
||||||
listOf(
|
listOf(
|
||||||
@@ -408,6 +411,7 @@ private fun List<CmsMannschaftRow>.toMannschaftenCsv(): String {
|
|||||||
row.spieler,
|
row.spieler,
|
||||||
row.informationenLink,
|
row.informationenLink,
|
||||||
row.letzteAktualisierung,
|
row.letzteAktualisierung,
|
||||||
|
row.spielplanMannschaftId,
|
||||||
).toCsvRow()
|
).toCsvRow()
|
||||||
}
|
}
|
||||||
return listOf(header).plus(rows).joinToString("\n")
|
return listOf(header).plus(rows).joinToString("\n")
|
||||||
|
|||||||
@@ -737,6 +737,7 @@ private fun MannschaftEditorCard(
|
|||||||
) {
|
) {
|
||||||
DataCard(row.mannschaft.ifBlank { "Mannschaft" }) {
|
DataCard(row.mannschaft.ifBlank { "Mannschaft" }) {
|
||||||
OutlinedTextField(value = row.mannschaft, onValueChange = { onChange(row.copy(mannschaft = it)) }, label = { Text("Mannschaft") }, modifier = Modifier.fillMaxWidth())
|
OutlinedTextField(value = row.mannschaft, onValueChange = { onChange(row.copy(mannschaft = it)) }, label = { Text("Mannschaft") }, modifier = Modifier.fillMaxWidth())
|
||||||
|
OutlinedTextField(value = row.spielplanMannschaftId, onValueChange = { onChange(row.copy(spielplanMannschaftId = it)) }, label = { Text("Spielplan-Team-ID") }, supportingText = { Text("Eindeutige myTischtennis-Team-ID") }, modifier = Modifier.fillMaxWidth())
|
||||||
OutlinedTextField(value = row.liga, onValueChange = { onChange(row.copy(liga = it)) }, label = { Text("Liga") }, modifier = Modifier.fillMaxWidth())
|
OutlinedTextField(value = row.liga, onValueChange = { onChange(row.copy(liga = it)) }, label = { Text("Liga") }, modifier = Modifier.fillMaxWidth())
|
||||||
OutlinedTextField(value = row.staffelleiter, onValueChange = { onChange(row.copy(staffelleiter = it)) }, label = { Text("Staffelleiter") }, modifier = Modifier.fillMaxWidth())
|
OutlinedTextField(value = row.staffelleiter, onValueChange = { onChange(row.copy(staffelleiter = it)) }, label = { Text("Staffelleiter") }, modifier = Modifier.fillMaxWidth())
|
||||||
OutlinedTextField(value = row.telefon, onValueChange = { onChange(row.copy(telefon = it)) }, label = { Text("Telefon") }, modifier = Modifier.fillMaxWidth())
|
OutlinedTextField(value = row.telefon, onValueChange = { onChange(row.copy(telefon = it)) }, label = { Text("Telefon") }, modifier = Modifier.fillMaxWidth())
|
||||||
|
|||||||
@@ -202,6 +202,17 @@
|
|||||||
:disabled="isSaving"
|
:disabled="isSaving"
|
||||||
>
|
>
|
||||||
</div>
|
</div>
|
||||||
|
<div>
|
||||||
|
<label class="block text-sm font-medium text-gray-700 mb-2">Spielplan-Team-ID</label>
|
||||||
|
<input
|
||||||
|
v-model="formData.spielplan_mannschaft_id"
|
||||||
|
type="text"
|
||||||
|
class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-primary-500"
|
||||||
|
placeholder="myTischtennis-Team-ID"
|
||||||
|
:disabled="isSaving"
|
||||||
|
>
|
||||||
|
<p class="mt-1 text-xs text-gray-500">Verknüpft diese Mannschaft eindeutig mit dem importierten Spielplan.</p>
|
||||||
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<label class="block text-sm font-medium text-gray-700 mb-2">Liga *</label>
|
<label class="block text-sm font-medium text-gray-700 mb-2">Liga *</label>
|
||||||
<input
|
<input
|
||||||
@@ -417,7 +428,7 @@ const showModal = ref(false)
|
|||||||
const errorMessage = ref('')
|
const errorMessage = ref('')
|
||||||
const isEditing = ref(false)
|
const isEditing = ref(false)
|
||||||
const editingIndex = ref(-1)
|
const editingIndex = ref(-1)
|
||||||
const formData = ref({ mannschaft: '', liga: '', staffelleiter: '', telefon: '', heimspieltag: '', spielsystem: '', mannschaftsfuehrer: '', spielerListe: [], weitere_informationen_link: '', letzte_aktualisierung: '' })
|
const formData = ref({ mannschaft: '', spielplan_mannschaft_id: '', liga: '', staffelleiter: '', telefon: '', heimspieltag: '', spielsystem: '', mannschaftsfuehrer: '', spielerListe: [], weitere_informationen_link: '', letzte_aktualisierung: '' })
|
||||||
const moveTargetBySpielerId = ref({})
|
const moveTargetBySpielerId = ref({})
|
||||||
const initialMoveTargetBySpielerId = ref({})
|
const initialMoveTargetBySpielerId = ref({})
|
||||||
const pendingSpielerNamesByTeamIndex = ref({})
|
const pendingSpielerNamesByTeamIndex = ref({})
|
||||||
@@ -498,7 +509,7 @@ const loadMannschaften = async () => {
|
|||||||
for (let i = 0; i < line.length; i++) { const char = line[i]; if (char === '"') { inQuotes = !inQuotes } else if (char === ',' && !inQuotes) { values.push(current.trim()); current = '' } else { current += char } }
|
for (let i = 0; i < line.length; i++) { const char = line[i]; if (char === '"') { inQuotes = !inQuotes } else if (char === ',' && !inQuotes) { values.push(current.trim()); current = '' } else { current += char } }
|
||||||
values.push(current.trim())
|
values.push(current.trim())
|
||||||
if (values.length < 10) return null
|
if (values.length < 10) return null
|
||||||
return { mannschaft: values[0]?.trim() || '', liga: values[1]?.trim() || '', staffelleiter: values[2]?.trim() || '', telefon: values[3]?.trim() || '', heimspieltag: values[4]?.trim() || '', spielsystem: values[5]?.trim() || '', mannschaftsfuehrer: values[6]?.trim() || '', spieler: values[7]?.trim() || '', weitere_informationen_link: values[8]?.trim() || '', letzte_aktualisierung: values[9]?.trim() || '' }
|
return { mannschaft: values[0]?.trim() || '', liga: values[1]?.trim() || '', staffelleiter: values[2]?.trim() || '', telefon: values[3]?.trim() || '', heimspieltag: values[4]?.trim() || '', spielsystem: values[5]?.trim() || '', mannschaftsfuehrer: values[6]?.trim() || '', spieler: values[7]?.trim() || '', weitere_informationen_link: values[8]?.trim() || '', letzte_aktualisierung: values[9]?.trim() || '', spielplan_mannschaft_id: values[10]?.trim() || '' }
|
||||||
}).filter(m => m !== null && m.mannschaft !== '')
|
}).filter(m => m !== null && m.mannschaft !== '')
|
||||||
} catch (error) { console.error('Fehler beim Laden:', error); errorMessage.value = 'Fehler beim Laden der Mannschaften'; throw error } finally { isLoading.value = false }
|
} catch (error) { console.error('Fehler beim Laden:', error); errorMessage.value = 'Fehler beim Laden der Mannschaften'; throw error } finally { isLoading.value = false }
|
||||||
}
|
}
|
||||||
@@ -508,10 +519,10 @@ const onSeasonChange = async () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const getSpielerListe = (m) => { if (!m.spieler) return []; return m.spieler.split(';').map(s => s.trim()).filter(s => s !== '') }
|
const getSpielerListe = (m) => { if (!m.spieler) return []; return m.spieler.split(';').map(s => s.trim()).filter(s => s !== '') }
|
||||||
const openAddModal = () => { formData.value = { mannschaft: '', liga: '', staffelleiter: '', telefon: '', heimspieltag: '', spielsystem: '', mannschaftsfuehrer: '', spielerListe: [], weitere_informationen_link: '', letzte_aktualisierung: nowIsoDate() }; showModal.value = true; errorMessage.value = ''; isEditing.value = false; editingIndex.value = -1; resetSpielerDraftState() }
|
const openAddModal = () => { formData.value = { mannschaft: '', spielplan_mannschaft_id: '', liga: '', staffelleiter: '', telefon: '', heimspieltag: '', spielsystem: '', mannschaftsfuehrer: '', spielerListe: [], weitere_informationen_link: '', letzte_aktualisierung: nowIsoDate() }; showModal.value = true; errorMessage.value = ''; isEditing.value = false; editingIndex.value = -1; resetSpielerDraftState() }
|
||||||
const closeModal = () => { showModal.value = false; errorMessage.value = ''; isEditing.value = false; editingIndex.value = -1; resetSpielerDraftState() }
|
const closeModal = () => { showModal.value = false; errorMessage.value = ''; isEditing.value = false; editingIndex.value = -1; resetSpielerDraftState() }
|
||||||
const openEditModal = (mannschaft, index) => {
|
const openEditModal = (mannschaft, index) => {
|
||||||
formData.value = { mannschaft: mannschaft.mannschaft || '', liga: mannschaft.liga || '', staffelleiter: mannschaft.staffelleiter || '', telefon: mannschaft.telefon || '', heimspieltag: mannschaft.heimspieltag || '', spielsystem: mannschaft.spielsystem || '', mannschaftsfuehrer: mannschaft.mannschaftsfuehrer || '', spielerListe: parseSpielerString(mannschaft.spieler || ''), weitere_informationen_link: mannschaft.weitere_informationen_link || '', letzte_aktualisierung: mannschaft.letzte_aktualisierung || nowIsoDate() }
|
formData.value = { mannschaft: mannschaft.mannschaft || '', spielplan_mannschaft_id: mannschaft.spielplan_mannschaft_id || '', liga: mannschaft.liga || '', staffelleiter: mannschaft.staffelleiter || '', telefon: mannschaft.telefon || '', heimspieltag: mannschaft.heimspieltag || '', spielsystem: mannschaft.spielsystem || '', mannschaftsfuehrer: mannschaft.mannschaftsfuehrer || '', spielerListe: parseSpielerString(mannschaft.spieler || ''), weitere_informationen_link: mannschaft.weitere_informationen_link || '', letzte_aktualisierung: mannschaft.letzte_aktualisierung || nowIsoDate() }
|
||||||
isEditing.value = true; editingIndex.value = index; showModal.value = true; errorMessage.value = ''; resetSpielerDraftState()
|
isEditing.value = true; editingIndex.value = index; showModal.value = true; errorMessage.value = ''; resetSpielerDraftState()
|
||||||
const currentTeam = (formData.value.mannschaft || '').trim()
|
const currentTeam = (formData.value.mannschaft || '').trim()
|
||||||
for (const s of formData.value.spielerListe) {
|
for (const s of formData.value.spielerListe) {
|
||||||
@@ -569,7 +580,7 @@ const saveMannschaft = async () => {
|
|||||||
try {
|
try {
|
||||||
if (!applySelectedSpielerTransfers()) return
|
if (!applySelectedSpielerTransfers()) return
|
||||||
const spielerString = serializeSpielerList(formData.value.spielerListe)
|
const spielerString = serializeSpielerList(formData.value.spielerListe)
|
||||||
const updated = { mannschaft: formData.value.mannschaft || '', liga: formData.value.liga || '', staffelleiter: formData.value.staffelleiter || '', telefon: formData.value.telefon || '', heimspieltag: formData.value.heimspieltag || '', spielsystem: formData.value.spielsystem || '', mannschaftsfuehrer: formData.value.mannschaftsfuehrer || '', spieler: spielerString, weitere_informationen_link: formData.value.weitere_informationen_link || '', letzte_aktualisierung: formData.value.letzte_aktualisierung || nowIsoDate() }
|
const updated = { mannschaft: formData.value.mannschaft || '', spielplan_mannschaft_id: formData.value.spielplan_mannschaft_id || '', liga: formData.value.liga || '', staffelleiter: formData.value.staffelleiter || '', telefon: formData.value.telefon || '', heimspieltag: formData.value.heimspieltag || '', spielsystem: formData.value.spielsystem || '', mannschaftsfuehrer: formData.value.mannschaftsfuehrer || '', spieler: spielerString, weitere_informationen_link: formData.value.weitere_informationen_link || '', letzte_aktualisierung: formData.value.letzte_aktualisierung || nowIsoDate() }
|
||||||
if (isEditing.value && editingIndex.value >= 0) { mannschaften.value[editingIndex.value] = { ...updated } } else { mannschaften.value.push({ ...updated }) }
|
if (isEditing.value && editingIndex.value >= 0) { mannschaften.value[editingIndex.value] = { ...updated } } else { mannschaften.value.push({ ...updated }) }
|
||||||
const touchedTeamIndexes = Object.keys(pendingSpielerNamesByTeamIndex.value)
|
const touchedTeamIndexes = Object.keys(pendingSpielerNamesByTeamIndex.value)
|
||||||
if (touchedTeamIndexes.length > 0) { const ts = nowIsoDate(); for (const idxStr of touchedTeamIndexes) { const idx = Number(idxStr); if (!Number.isFinite(idx)) continue; const existing = mannschaften.value[idx]; if (!existing) continue; mannschaften.value[idx] = { ...existing, spieler: serializeSpielerNames(pendingSpielerNamesByTeamIndex.value[idx]), letzte_aktualisierung: ts } } }
|
if (touchedTeamIndexes.length > 0) { const ts = nowIsoDate(); for (const idxStr of touchedTeamIndexes) { const idx = Number(idxStr); if (!Number.isFinite(idx)) continue; const existing = mannschaften.value[idx]; if (!existing) continue; mannschaften.value[idx] = { ...existing, spieler: serializeSpielerNames(pendingSpielerNamesByTeamIndex.value[idx]), letzte_aktualisierung: ts } } }
|
||||||
@@ -579,10 +590,10 @@ const saveMannschaft = async () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const saveCSV = async () => {
|
const saveCSV = async () => {
|
||||||
const header = 'Mannschaft,Liga,Staffelleiter,Telefon,Heimspieltag,Spielsystem,Mannschaftsführer,Spieler,Weitere Informationen Link,Letzte Aktualisierung'
|
const header = 'Mannschaft,Liga,Staffelleiter,Telefon,Heimspieltag,Spielsystem,Mannschaftsführer,Spieler,Weitere Informationen Link,Letzte Aktualisierung,Spielplan Mannschaft ID'
|
||||||
const rows = mannschaften.value.map(m => {
|
const rows = mannschaften.value.map(m => {
|
||||||
const esc = (v) => { if (!v) return ''; const s = String(v); if (s.includes(',') || s.includes('"') || s.includes('\n')) return `"${s.replace(/"/g, '""')}"`; return s }
|
const esc = (v) => { if (!v) return ''; const s = String(v); if (s.includes(',') || s.includes('"') || s.includes('\n')) return `"${s.replace(/"/g, '""')}"`; return s }
|
||||||
return [esc(m.mannschaft), esc(m.liga), esc(m.staffelleiter), esc(m.telefon), esc(m.heimspieltag), esc(m.spielsystem), esc(m.mannschaftsfuehrer), esc(m.spieler), esc(m.weitere_informationen_link), esc(m.letzte_aktualisierung)].join(',')
|
return [esc(m.mannschaft), esc(m.liga), esc(m.staffelleiter), esc(m.telefon), esc(m.heimspieltag), esc(m.spielsystem), esc(m.mannschaftsfuehrer), esc(m.spieler), esc(m.weitere_informationen_link), esc(m.letzte_aktualisierung), esc(m.spielplan_mannschaft_id)].join(',')
|
||||||
})
|
})
|
||||||
await $fetch('/api/cms/save-csv', {
|
await $fetch('/api/cms/save-csv', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
@@ -639,10 +650,10 @@ const createNextSeason = async () => {
|
|||||||
isCreatingSeason.value = true
|
isCreatingSeason.value = true
|
||||||
errorMessage.value = ''
|
errorMessage.value = ''
|
||||||
try {
|
try {
|
||||||
const header = 'Mannschaft,Liga,Staffelleiter,Telefon,Heimspieltag,Spielsystem,Mannschaftsführer,Spieler,Weitere Informationen Link,Letzte Aktualisierung'
|
const header = 'Mannschaft,Liga,Staffelleiter,Telefon,Heimspieltag,Spielsystem,Mannschaftsführer,Spieler,Weitere Informationen Link,Letzte Aktualisierung,Spielplan Mannschaft ID'
|
||||||
const rows = mannschaften.value.map(m => {
|
const rows = mannschaften.value.map(m => {
|
||||||
const esc = (v) => { if (!v) return ''; const s = String(v); if (s.includes(',') || s.includes('"') || s.includes('\n')) return `"${s.replace(/"/g, '""')}"`; return s }
|
const esc = (v) => { if (!v) return ''; const s = String(v); if (s.includes(',') || s.includes('"') || s.includes('\n')) return `"${s.replace(/"/g, '""')}"`; return s }
|
||||||
return [esc(m.mannschaft), esc(m.liga), esc(m.staffelleiter), esc(m.telefon), esc(m.heimspieltag), esc(m.spielsystem), esc(m.mannschaftsfuehrer), esc(m.spieler), esc(m.weitere_informationen_link), esc(m.letzte_aktualisierung || nowIsoDate())].join(',')
|
return [esc(m.mannschaft), esc(m.liga), esc(m.staffelleiter), esc(m.telefon), esc(m.heimspieltag), esc(m.spielsystem), esc(m.mannschaftsfuehrer), esc(m.spieler), esc(m.weitere_informationen_link), esc(m.letzte_aktualisierung || nowIsoDate()), esc(m.spielplan_mannschaft_id)].join(',')
|
||||||
})
|
})
|
||||||
|
|
||||||
await $fetch('/api/cms/save-csv', {
|
await $fetch('/api/cms/save-csv', {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "harheimertc-website",
|
"name": "harheimertc-website",
|
||||||
"version": "1.8.2",
|
"version": "1.8.3",
|
||||||
"description": "Moderne Webseite für den Harheimer Tischtennis Club",
|
"description": "Moderne Webseite für den Harheimer Tischtennis Club",
|
||||||
"private": true,
|
"private": true,
|
||||||
"type": "module",
|
"type": "module",
|
||||||
|
|||||||
@@ -473,6 +473,7 @@ const loadMannschaften = async () => {
|
|||||||
spieler: values[7].trim(),
|
spieler: values[7].trim(),
|
||||||
weitere_informationen_link: values[8].trim(),
|
weitere_informationen_link: values[8].trim(),
|
||||||
letzte_aktualisierung: values[9].trim(),
|
letzte_aktualisierung: values[9].trim(),
|
||||||
|
spielplan_mannschaft_id: values[10] ? values[10].trim() : '',
|
||||||
slug: values[0].trim().toLowerCase().replace(/\s+/g, '-')
|
slug: values[0].trim().toLowerCase().replace(/\s+/g, '-')
|
||||||
}
|
}
|
||||||
}).filter(mannschaft => mannschaft !== null)
|
}).filter(mannschaft => mannschaft !== null)
|
||||||
@@ -557,6 +558,12 @@ const isExactHarheimTeam = (teamName, variant) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const isSpielForMannschaft = (row, cmsMannschaft) => {
|
const isSpielForMannschaft = (row, cmsMannschaft) => {
|
||||||
|
const configuredTeamId = String(mannschaft.value?.spielplan_mannschaft_id || '').trim()
|
||||||
|
if (configuredTeamId) {
|
||||||
|
return String(row.HeimMannschaftId || '').trim() === configuredTeamId ||
|
||||||
|
String(row.GastMannschaftId || '').trim() === configuredTeamId
|
||||||
|
}
|
||||||
|
|
||||||
const variants = getTeamVariants(cmsMannschaft)
|
const variants = getTeamVariants(cmsMannschaft)
|
||||||
if (!variants.length) return false
|
if (!variants.length) return false
|
||||||
|
|
||||||
|
|||||||
@@ -360,6 +360,7 @@
|
|||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref, onMounted } from 'vue'
|
import { ref, onMounted } from 'vue'
|
||||||
|
import { filterSpielplanRows, toApiTeamParam } from '../../utils/spielplan-filter.js'
|
||||||
|
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
@@ -525,183 +526,16 @@ const filterData = () => {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
let saisonFiltered = spielplanData.value
|
filteredData.value = filterSpielplanRows(spielplanData.value, {
|
||||||
|
team: selectedFilter.value,
|
||||||
// Dann nach Wettbewerb filtern
|
wettbewerb: selectedWettbewerb.value
|
||||||
let wettbewerbFiltered = saisonFiltered
|
|
||||||
if (selectedWettbewerb.value === 'punktrunde') {
|
|
||||||
wettbewerbFiltered = saisonFiltered.filter(row => {
|
|
||||||
const runde = (row.Runde || '').toLowerCase()
|
|
||||||
const staffel = (row.Staffel || '').toLowerCase()
|
|
||||||
const liga = (row.Liga || '').toLowerCase()
|
|
||||||
const isPokal = runde.includes('pokal') || staffel.includes('pokal') || liga.includes('pokal')
|
|
||||||
|
|
||||||
return !isPokal
|
|
||||||
})
|
})
|
||||||
} else if (selectedWettbewerb.value === 'pokal') {
|
|
||||||
wettbewerbFiltered = saisonFiltered.filter(row => {
|
|
||||||
const runde = (row.Runde || '').toLowerCase()
|
|
||||||
const staffel = (row.Staffel || '').toLowerCase()
|
|
||||||
const liga = (row.Liga || '').toLowerCase()
|
|
||||||
return runde.includes('pokal') || staffel.includes('pokal') || liga.includes('pokal')
|
|
||||||
})
|
|
||||||
}
|
|
||||||
// "alle" zeigt alle Spiele ohne weitere Filterung
|
|
||||||
|
|
||||||
// Dann nach Mannschaft filtern
|
|
||||||
if (selectedFilter.value === 'all') {
|
|
||||||
filteredData.value = wettbewerbFiltered
|
|
||||||
} else if (selectedFilter.value === 'erwachsene') {
|
|
||||||
filteredData.value = wettbewerbFiltered.filter(row => {
|
|
||||||
const heimMannschaft = (row.HeimMannschaft || '').toLowerCase()
|
|
||||||
const gastMannschaft = (row.GastMannschaft || '').toLowerCase()
|
|
||||||
const heimAltersklasse = (row.HeimMannschaftAltersklasse || '').toLowerCase()
|
|
||||||
const gastAltersklasse = (row.GastMannschaftAltersklasse || '').toLowerCase()
|
|
||||||
|
|
||||||
// Prüfe ob eine der Mannschaften Harheimer TC ist
|
|
||||||
const isHarheimerHeim = heimMannschaft.includes('harheimer tc')
|
|
||||||
const isHarheimerGast = gastMannschaft.includes('harheimer tc')
|
|
||||||
|
|
||||||
if (!isHarheimerHeim && !isHarheimerGast) {
|
|
||||||
return false // Kein Harheimer TC Spiel
|
|
||||||
}
|
|
||||||
|
|
||||||
// Filtere nach Erwachsenen-Mannschaften (NICHT Jugend)
|
|
||||||
const isErwachsenenHeim = isHarheimerHeim &&
|
|
||||||
heimAltersklasse.includes('erwachsene') &&
|
|
||||||
!heimAltersklasse.includes('jugend')
|
|
||||||
const isErwachsenenGast = isHarheimerGast &&
|
|
||||||
gastAltersklasse.includes('erwachsene') &&
|
|
||||||
!gastAltersklasse.includes('jugend')
|
|
||||||
|
|
||||||
return isErwachsenenHeim || isErwachsenenGast
|
|
||||||
})
|
|
||||||
} else if (selectedFilter.value === 'nachwuchs') {
|
|
||||||
filteredData.value = wettbewerbFiltered.filter(row => {
|
|
||||||
const heimMannschaft = (row.HeimMannschaft || '').toLowerCase()
|
|
||||||
const gastMannschaft = (row.GastMannschaft || '').toLowerCase()
|
|
||||||
const heimAltersklasse = (row.HeimMannschaftAltersklasse || '').toLowerCase()
|
|
||||||
const gastAltersklasse = (row.GastMannschaftAltersklasse || '').toLowerCase()
|
|
||||||
|
|
||||||
// Prüfe ob eine der Mannschaften Harheimer TC ist
|
|
||||||
const isHarheimerHeim = heimMannschaft.includes('harheimer tc')
|
|
||||||
const isHarheimerGast = gastMannschaft.includes('harheimer tc')
|
|
||||||
|
|
||||||
if (!isHarheimerHeim && !isHarheimerGast) {
|
|
||||||
return false // Kein Harheimer TC Spiel
|
|
||||||
}
|
|
||||||
|
|
||||||
// Filtere nach Jugend-Mannschaften (NUR Jugend)
|
|
||||||
const isJugendHeim = isHarheimerHeim &&
|
|
||||||
(heimAltersklasse.includes('jugend') || heimMannschaft.includes('jugend'))
|
|
||||||
const isJugendGast = isHarheimerGast &&
|
|
||||||
(gastAltersklasse.includes('jugend') || gastMannschaft.includes('jugend'))
|
|
||||||
|
|
||||||
return isJugendHeim || isJugendGast
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
// Spezifische Mannschaft - Mapping zwischen CMS-Mannschaften und CSV-Daten
|
|
||||||
filteredData.value = wettbewerbFiltered.filter(row => {
|
|
||||||
const heimMannschaft = (row.HeimMannschaft || '').toLowerCase()
|
|
||||||
const gastMannschaft = (row.GastMannschaft || '').toLowerCase()
|
|
||||||
const heimAltersklasse = (row.HeimMannschaftAltersklasse || '').toLowerCase()
|
|
||||||
const gastAltersklasse = (row.GastMannschaftAltersklasse || '').toLowerCase()
|
|
||||||
|
|
||||||
// Prüfe ob eine der Mannschaften Harheimer TC ist
|
|
||||||
const isHarheimerHeim = heimMannschaft.includes('harheimer tc')
|
|
||||||
const isHarheimerGast = gastMannschaft.includes('harheimer tc')
|
|
||||||
|
|
||||||
if (!isHarheimerHeim && !isHarheimerGast) {
|
|
||||||
return false // Kein Harheimer TC Spiel
|
|
||||||
}
|
|
||||||
|
|
||||||
const cmsMannschaft = selectedFilter.value
|
|
||||||
|
|
||||||
// Mapping zwischen CMS-Mannschaften und CSV-Daten
|
|
||||||
const mannschaftMapping = {
|
|
||||||
'Erwachsene 1': ['harheimer tc'], // Nur ohne römische Zahl
|
|
||||||
'Erwachsene 2': ['harheimer tc ii'],
|
|
||||||
'Erwachsene 3': ['harheimer tc iii'],
|
|
||||||
'Erwachsene 4': ['harheimer tc iv'],
|
|
||||||
'Erwachsene 5': ['harheimer tc v'],
|
|
||||||
'Jugendmannschaft': ['harheimer tc'] // Jugend hat keine römische Zahl
|
|
||||||
}
|
|
||||||
|
|
||||||
const csvVariants = mannschaftMapping[cmsMannschaft] || []
|
|
||||||
|
|
||||||
// Prüfe Mannschafts-Zuordnung UND Altersklasse
|
|
||||||
const mannschaftMatch = csvVariants.some(variant => {
|
|
||||||
// Strikte Übereinstimmung: Prüfe exakte Mannschaftsnamen
|
|
||||||
if (isHarheimerHeim) {
|
|
||||||
// Für "harheimer tc" (Erwachsene 1): Nur wenn KEINE römische Zahl folgt
|
|
||||||
if (variant === 'harheimer tc') {
|
|
||||||
return heimMannschaft === 'harheimer tc' ||
|
|
||||||
heimMannschaft.startsWith('harheimer tc ') &&
|
|
||||||
!heimMannschaft.match(/harheimer tc\s+[ivx]+/i)
|
|
||||||
}
|
|
||||||
// Für andere Mannschaften: Exakte Übereinstimmung
|
|
||||||
return heimMannschaft === variant || heimMannschaft.startsWith(variant + ' ')
|
|
||||||
}
|
|
||||||
if (isHarheimerGast) {
|
|
||||||
// Für "harheimer tc" (Erwachsene 1): Nur wenn KEINE römische Zahl folgt
|
|
||||||
if (variant === 'harheimer tc') {
|
|
||||||
return gastMannschaft === 'harheimer tc' ||
|
|
||||||
gastMannschaft.startsWith('harheimer tc ') &&
|
|
||||||
!gastMannschaft.match(/harheimer tc\s+[ivx]+/i)
|
|
||||||
}
|
|
||||||
// Für andere Mannschaften: Exakte Übereinstimmung
|
|
||||||
return gastMannschaft === variant || gastMannschaft.startsWith(variant + ' ')
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
})
|
|
||||||
|
|
||||||
if (!mannschaftMatch) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
// Zusätzliche Altersklassen-Prüfung für spezifische Mannschaften
|
|
||||||
if (cmsMannschaft.startsWith('Erwachsene')) {
|
|
||||||
// Erwachsenen-Mannschaften: MUSS Erwachsene sein, DARF NICHT Jugend sein
|
|
||||||
const isErwachsenenHeim = isHarheimerHeim &&
|
|
||||||
heimAltersklasse.includes('erwachsene') &&
|
|
||||||
!heimAltersklasse.includes('jugend')
|
|
||||||
const isErwachsenenGast = isHarheimerGast &&
|
|
||||||
gastAltersklasse.includes('erwachsene') &&
|
|
||||||
!gastAltersklasse.includes('jugend')
|
|
||||||
|
|
||||||
return isErwachsenenHeim || isErwachsenenGast
|
|
||||||
} else if (cmsMannschaft === 'Jugendmannschaft') {
|
|
||||||
// Jugend-Mannschaft: MUSS Jugend sein
|
|
||||||
const isJugendHeim = isHarheimerHeim &&
|
|
||||||
(heimAltersklasse.includes('jugend') || heimMannschaft.includes('jugend'))
|
|
||||||
const isJugendGast = isHarheimerGast &&
|
|
||||||
(gastAltersklasse.includes('jugend') || gastMannschaft.includes('jugend'))
|
|
||||||
|
|
||||||
return isJugendHeim || isJugendGast
|
|
||||||
}
|
|
||||||
|
|
||||||
return true // Fallback für unbekannte Mannschaften
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const downloadPDF = () => {
|
const downloadPDF = () => {
|
||||||
if (!filteredData.value || filteredData.value.length === 0) return
|
if (!filteredData.value || filteredData.value.length === 0) return
|
||||||
|
|
||||||
// Bestimme den Team-Parameter basierend auf dem Filter
|
const teamParam = toApiTeamParam(selectedFilter.value)
|
||||||
let teamParam = ''
|
|
||||||
|
|
||||||
if (selectedFilter.value === 'all') {
|
|
||||||
teamParam = 'all'
|
|
||||||
} else if (selectedFilter.value === 'erwachsene') {
|
|
||||||
teamParam = 'erwachsene'
|
|
||||||
} else if (selectedFilter.value === 'nachwuchs') {
|
|
||||||
teamParam = 'nachwuchs'
|
|
||||||
} else {
|
|
||||||
// Für einzelne Mannschaften: Konvertiere Namen
|
|
||||||
teamParam = selectedFilter.value.replace(/\s+/g, '_').toLowerCase()
|
|
||||||
}
|
|
||||||
|
|
||||||
// Erstelle Download-URL für dynamische PDF-Generierung
|
// Erstelle Download-URL für dynamische PDF-Generierung
|
||||||
const params = new URLSearchParams({
|
const params = new URLSearchParams({
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import fs from 'fs/promises'
|
|||||||
import path from 'path'
|
import path from 'path'
|
||||||
import { readSpielplanData, validateSeasonSlug } from '../../utils/spielplan-data.js'
|
import { readSpielplanData, validateSeasonSlug } from '../../utils/spielplan-data.js'
|
||||||
import { info as loggerInfo, error as loggerError } from '../../utils/logger.js'
|
import { info as loggerInfo, error as loggerError } from '../../utils/logger.js'
|
||||||
|
import { filterSpielplanRows } from '../../../utils/spielplan-filter.js'
|
||||||
|
|
||||||
function seasonSlugToLabel(slug) {
|
function seasonSlugToLabel(slug) {
|
||||||
const match = String(slug || '').match(/^(\d{2})--(\d{2})$/)
|
const match = String(slug || '').match(/^(\d{2})--(\d{2})$/)
|
||||||
@@ -35,116 +36,8 @@ export default defineEventHandler(async (event) => {
|
|||||||
|
|
||||||
const dataRows = spielplan.data
|
const dataRows = spielplan.data
|
||||||
|
|
||||||
// Filtere Daten basierend auf Team
|
|
||||||
let filteredData = dataRows
|
|
||||||
|
|
||||||
if (team !== 'all') {
|
|
||||||
filteredData = dataRows.filter(row => {
|
|
||||||
const heimMannschaft = (row.HeimMannschaft || '').toLowerCase()
|
|
||||||
const gastMannschaft = (row.GastMannschaft || '').toLowerCase()
|
|
||||||
const heimAltersklasse = (row.HeimMannschaftAltersklasse || '').toLowerCase()
|
|
||||||
const gastAltersklasse = (row.GastMannschaftAltersklasse || '').toLowerCase()
|
|
||||||
|
|
||||||
// Prüfe ob eine der Mannschaften Harheimer TC ist
|
|
||||||
const isHarheimerHeim = heimMannschaft.includes('harheimer tc')
|
|
||||||
const isHarheimerGast = gastMannschaft.includes('harheimer tc')
|
|
||||||
|
|
||||||
if (!isHarheimerHeim && !isHarheimerGast) {
|
|
||||||
return false // Kein Harheimer TC Spiel
|
|
||||||
}
|
|
||||||
|
|
||||||
// Mapping zwischen Team-Namen und CSV-Daten
|
|
||||||
const mannschaftMapping = {
|
|
||||||
'erwachsene': ['harheimer tc'], // Alle Erwachsenen-Mannschaften
|
|
||||||
'nachwuchs': ['harheimer tc'], // Alle Jugend-Mannschaften
|
|
||||||
'erwachsene_1': ['harheimer tc'], // Nur ohne römische Zahl
|
|
||||||
'erwachsene_2': ['harheimer tc ii'],
|
|
||||||
'erwachsene_3': ['harheimer tc iii'],
|
|
||||||
'erwachsene_4': ['harheimer tc iv'],
|
|
||||||
'erwachsene_5': ['harheimer tc v'],
|
|
||||||
'jugendmannschaft': ['harheimer tc'] // Jugend hat keine römische Zahl
|
|
||||||
}
|
|
||||||
|
|
||||||
const csvVariants = mannschaftMapping[team] || []
|
|
||||||
|
|
||||||
if (csvVariants.length === 0) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
// Prüfe Mannschafts-Zuordnung UND Altersklasse
|
|
||||||
const mannschaftMatch = csvVariants.some(variant => {
|
|
||||||
// Strikte Übereinstimmung: Prüfe exakte Mannschaftsnamen
|
|
||||||
if (isHarheimerHeim) {
|
|
||||||
// Für "harheimer tc" (Erwachsene 1): Nur wenn KEINE römische Zahl folgt
|
|
||||||
if (variant === 'harheimer tc') {
|
|
||||||
return heimMannschaft === 'harheimer tc' ||
|
|
||||||
heimMannschaft.startsWith('harheimer tc ') &&
|
|
||||||
!heimMannschaft.match(/harheimer tc\s+[ivx]+/i)
|
|
||||||
}
|
|
||||||
// Für andere Mannschaften: Exakte Übereinstimmung
|
|
||||||
return heimMannschaft === variant || heimMannschaft.startsWith(variant + ' ')
|
|
||||||
}
|
|
||||||
if (isHarheimerGast) {
|
|
||||||
// Für "harheimer tc" (Erwachsene 1): Nur wenn KEINE römische Zahl folgt
|
|
||||||
if (variant === 'harheimer tc') {
|
|
||||||
return gastMannschaft === 'harheimer tc' ||
|
|
||||||
gastMannschaft.startsWith('harheimer tc ') &&
|
|
||||||
!gastMannschaft.match(/harheimer tc\s+[ivx]+/i)
|
|
||||||
}
|
|
||||||
// Für andere Mannschaften: Exakte Übereinstimmung
|
|
||||||
return gastMannschaft === variant || gastMannschaft.startsWith(variant + ' ')
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
})
|
|
||||||
|
|
||||||
if (!mannschaftMatch) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
// Zusätzliche Altersklassen-Prüfung für spezifische Mannschaften
|
|
||||||
if (team.startsWith('erwachsene')) {
|
|
||||||
// Erwachsenen-Mannschaften: MUSS Erwachsene sein, DARF NICHT Jugend sein
|
|
||||||
const isErwachsenenHeim = isHarheimerHeim &&
|
|
||||||
heimAltersklasse.includes('erwachsene') &&
|
|
||||||
!heimAltersklasse.includes('jugend')
|
|
||||||
const isErwachsenenGast = isHarheimerGast &&
|
|
||||||
gastAltersklasse.includes('erwachsene') &&
|
|
||||||
!gastAltersklasse.includes('jugend')
|
|
||||||
|
|
||||||
return isErwachsenenHeim || isErwachsenenGast
|
|
||||||
} else if (team === 'jugendmannschaft' || team === 'nachwuchs') {
|
|
||||||
// Jugend-Mannschaft: MUSS Jugend sein
|
|
||||||
const isJugendHeim = isHarheimerHeim &&
|
|
||||||
(heimAltersklasse.includes('jugend') || heimMannschaft.includes('jugend'))
|
|
||||||
const isJugendGast = isHarheimerGast &&
|
|
||||||
(gastAltersklasse.includes('jugend') || gastMannschaft.includes('jugend'))
|
|
||||||
|
|
||||||
return isJugendHeim || isJugendGast
|
|
||||||
}
|
|
||||||
|
|
||||||
return true // Fallback für unbekannte Mannschaften
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// Filtere nach Wettbewerb (Standard: Punktrunde)
|
|
||||||
// Muss zur Frontend-Logik passen: Punktrunde = alles, was kein Pokal ist.
|
|
||||||
const wettbewerb = String(query.wettbewerb || 'punktrunde').toLowerCase().trim()
|
const wettbewerb = String(query.wettbewerb || 'punktrunde').toLowerCase().trim()
|
||||||
if (wettbewerb !== 'alle') {
|
const filteredData = filterSpielplanRows(dataRows, { team, wettbewerb })
|
||||||
filteredData = filteredData.filter(row => {
|
|
||||||
const runde = (row.Runde || '').toLowerCase()
|
|
||||||
const staffel = (row.Staffel || '').toLowerCase()
|
|
||||||
const liga = (row.Liga || '').toLowerCase()
|
|
||||||
const isPokal = runde.includes('pokal') || staffel.includes('pokal') || liga.includes('pokal')
|
|
||||||
|
|
||||||
if (wettbewerb === 'punktrunde') {
|
|
||||||
return !isPokal
|
|
||||||
} else if (wettbewerb === 'pokal') {
|
|
||||||
return isPokal
|
|
||||||
}
|
|
||||||
|
|
||||||
return true
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// Sammle Halle-Informationen für die jeweilige Mannschaft
|
// Sammle Halle-Informationen für die jeweilige Mannschaft
|
||||||
const hallenMap = new Map()
|
const hallenMap = new Map()
|
||||||
|
|||||||
@@ -25,12 +25,14 @@ const SPIELPLAN_HEADERS = [
|
|||||||
'HeimVereinName',
|
'HeimVereinName',
|
||||||
'HeimMannschaftAltersklasse',
|
'HeimMannschaftAltersklasse',
|
||||||
'HeimMannschaftNr',
|
'HeimMannschaftNr',
|
||||||
|
'HeimMannschaftId',
|
||||||
'HeimMannschaft',
|
'HeimMannschaft',
|
||||||
'GastVereinVerband',
|
'GastVereinVerband',
|
||||||
'GastVereinNr',
|
'GastVereinNr',
|
||||||
'GastVereinName',
|
'GastVereinName',
|
||||||
'GastMannschaftAltersklasse',
|
'GastMannschaftAltersklasse',
|
||||||
'GastMannschaftNr',
|
'GastMannschaftNr',
|
||||||
|
'GastMannschaftId',
|
||||||
'GastMannschaft',
|
'GastMannschaft',
|
||||||
'SpieleHeim',
|
'SpieleHeim',
|
||||||
'SpieleGast'
|
'SpieleGast'
|
||||||
@@ -250,12 +252,14 @@ export function convertImportedSpielplanToJson(imported) {
|
|||||||
HeimVereinName: homeIsHarheim ? CLUB_NAME : '',
|
HeimVereinName: homeIsHarheim ? CLUB_NAME : '',
|
||||||
HeimMannschaftAltersklasse: inferAgeClass(match, match.teamHome),
|
HeimMannschaftAltersklasse: inferAgeClass(match, match.teamHome),
|
||||||
HeimMannschaftNr: inferTeamNumber(match.teamHome),
|
HeimMannschaftNr: inferTeamNumber(match.teamHome),
|
||||||
|
HeimMannschaftId: match.teamHomeId || '',
|
||||||
HeimMannschaft: match.teamHome || '',
|
HeimMannschaft: match.teamHome || '',
|
||||||
GastVereinVerband: match.leagueOrgShortName || imported.source?.association || '',
|
GastVereinVerband: match.leagueOrgShortName || imported.source?.association || '',
|
||||||
GastVereinNr: match.teamAwayClubId || '',
|
GastVereinNr: match.teamAwayClubId || '',
|
||||||
GastVereinName: awayIsHarheim ? CLUB_NAME : '',
|
GastVereinName: awayIsHarheim ? CLUB_NAME : '',
|
||||||
GastMannschaftAltersklasse: inferAgeClass(match, match.teamAway),
|
GastMannschaftAltersklasse: inferAgeClass(match, match.teamAway),
|
||||||
GastMannschaftNr: inferTeamNumber(match.teamAway),
|
GastMannschaftNr: inferTeamNumber(match.teamAway),
|
||||||
|
GastMannschaftId: match.teamAwayId || '',
|
||||||
GastMannschaft: match.teamAway || '',
|
GastMannschaft: match.teamAway || '',
|
||||||
SpieleHeim: result.home,
|
SpieleHeim: result.home,
|
||||||
SpieleGast: result.away
|
SpieleGast: result.away
|
||||||
|
|||||||
125
utils/spielplan-filter.js
Normal file
125
utils/spielplan-filter.js
Normal file
@@ -0,0 +1,125 @@
|
|||||||
|
function normalizeText(value) {
|
||||||
|
return String(value || '').trim().toLowerCase().replace(/\s+/g, ' ')
|
||||||
|
}
|
||||||
|
|
||||||
|
function normalizeTeamFilterKey(value) {
|
||||||
|
const normalized = normalizeText(value).replace(/\s+/g, '_')
|
||||||
|
|
||||||
|
if (!normalized) return ''
|
||||||
|
if (normalized === 'all' || normalized === 'erwachsene' || normalized === 'nachwuchs') return normalized
|
||||||
|
if (normalized === 'jugendmannschaft') return 'jugendmannschaft'
|
||||||
|
|
||||||
|
const erwachseneMatch = normalized.match(/^erwachsene_(\d+)$/)
|
||||||
|
if (erwachseneMatch) {
|
||||||
|
return `erwachsene_${erwachseneMatch[1]}`
|
||||||
|
}
|
||||||
|
|
||||||
|
return normalized
|
||||||
|
}
|
||||||
|
|
||||||
|
const MANNSCHAFT_MAPPING = {
|
||||||
|
erwachsene_1: ['harheimer tc'],
|
||||||
|
erwachsene_2: ['harheimer tc ii'],
|
||||||
|
erwachsene_3: ['harheimer tc iii'],
|
||||||
|
erwachsene_4: ['harheimer tc iv'],
|
||||||
|
erwachsene_5: ['harheimer tc v'],
|
||||||
|
jugendmannschaft: ['harheimer tc']
|
||||||
|
}
|
||||||
|
|
||||||
|
function matchMappedVariant(mannschaft, variant) {
|
||||||
|
if (variant === 'harheimer tc') {
|
||||||
|
return mannschaft === 'harheimer tc' ||
|
||||||
|
(mannschaft.startsWith('harheimer tc ') && !mannschaft.match(/harheimer tc\s+[ivx]+/i))
|
||||||
|
}
|
||||||
|
|
||||||
|
return mannschaft === variant || mannschaft.startsWith(`${variant} `)
|
||||||
|
}
|
||||||
|
|
||||||
|
function isErwachsenenTeam(teamKey) {
|
||||||
|
return teamKey === 'erwachsene' || teamKey.startsWith('erwachsene_')
|
||||||
|
}
|
||||||
|
|
||||||
|
export function rowMatchesWettbewerbFilter(row, rawWettbewerb) {
|
||||||
|
const wettbewerb = normalizeText(rawWettbewerb || 'punktrunde')
|
||||||
|
const runde = normalizeText(row?.Runde)
|
||||||
|
const staffel = normalizeText(row?.Staffel)
|
||||||
|
const liga = normalizeText(row?.Liga)
|
||||||
|
const isPokal = runde.includes('pokal') || staffel.includes('pokal') || liga.includes('pokal')
|
||||||
|
|
||||||
|
if (wettbewerb === 'alle') return true
|
||||||
|
if (wettbewerb === 'pokal') return isPokal
|
||||||
|
return !isPokal
|
||||||
|
}
|
||||||
|
|
||||||
|
export function rowMatchesTeamFilter(row, rawTeam) {
|
||||||
|
const teamKey = normalizeTeamFilterKey(rawTeam)
|
||||||
|
if (!teamKey || teamKey === 'all') return true
|
||||||
|
|
||||||
|
const heimMannschaft = normalizeText(row?.HeimMannschaft)
|
||||||
|
const gastMannschaft = normalizeText(row?.GastMannschaft)
|
||||||
|
const heimAltersklasse = normalizeText(row?.HeimMannschaftAltersklasse)
|
||||||
|
const gastAltersklasse = normalizeText(row?.GastMannschaftAltersklasse)
|
||||||
|
|
||||||
|
const isHarheimerHeim = heimMannschaft.includes('harheimer tc')
|
||||||
|
const isHarheimerGast = gastMannschaft.includes('harheimer tc')
|
||||||
|
|
||||||
|
if (!isHarheimerHeim && !isHarheimerGast) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
if (teamKey === 'erwachsene') {
|
||||||
|
const isErwachsenenHeim = isHarheimerHeim && heimAltersklasse.includes('erwachsene') && !heimAltersklasse.includes('jugend')
|
||||||
|
const isErwachsenenGast = isHarheimerGast && gastAltersklasse.includes('erwachsene') && !gastAltersklasse.includes('jugend')
|
||||||
|
return isErwachsenenHeim || isErwachsenenGast
|
||||||
|
}
|
||||||
|
|
||||||
|
if (teamKey === 'nachwuchs' || teamKey === 'jugendmannschaft') {
|
||||||
|
const isJugendHeim = isHarheimerHeim && (heimAltersklasse.includes('jugend') || heimMannschaft.includes('jugend'))
|
||||||
|
const isJugendGast = isHarheimerGast && (gastAltersklasse.includes('jugend') || gastMannschaft.includes('jugend'))
|
||||||
|
return isJugendHeim || isJugendGast
|
||||||
|
}
|
||||||
|
|
||||||
|
const csvVariants = MANNSCHAFT_MAPPING[teamKey] || []
|
||||||
|
if (csvVariants.length === 0) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
const mannschaftMatch = csvVariants.some((variant) => {
|
||||||
|
if (isHarheimerHeim && matchMappedVariant(heimMannschaft, variant)) return true
|
||||||
|
if (isHarheimerGast && matchMappedVariant(gastMannschaft, variant)) return true
|
||||||
|
return false
|
||||||
|
})
|
||||||
|
|
||||||
|
if (!mannschaftMatch) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isErwachsenenTeam(teamKey)) {
|
||||||
|
const isErwachsenenHeim = isHarheimerHeim && heimAltersklasse.includes('erwachsene') && !heimAltersklasse.includes('jugend')
|
||||||
|
const isErwachsenenGast = isHarheimerGast && gastAltersklasse.includes('erwachsene') && !gastAltersklasse.includes('jugend')
|
||||||
|
return isErwachsenenHeim || isErwachsenenGast
|
||||||
|
}
|
||||||
|
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
export function filterSpielplanRows(rows, options = {}) {
|
||||||
|
const sourceRows = Array.isArray(rows) ? rows : []
|
||||||
|
const team = options.team || 'all'
|
||||||
|
const wettbewerb = options.wettbewerb || 'punktrunde'
|
||||||
|
|
||||||
|
return sourceRows.filter((row) => rowMatchesTeamFilter(row, team) && rowMatchesWettbewerbFilter(row, wettbewerb))
|
||||||
|
}
|
||||||
|
|
||||||
|
export function toApiTeamParam(filterValue) {
|
||||||
|
const teamKey = normalizeTeamFilterKey(filterValue)
|
||||||
|
if (teamKey === 'all' || teamKey === 'erwachsene' || teamKey === 'nachwuchs' || teamKey === 'jugendmannschaft') {
|
||||||
|
return teamKey
|
||||||
|
}
|
||||||
|
|
||||||
|
if (teamKey.match(/^erwachsene_\d+$/)) {
|
||||||
|
return teamKey
|
||||||
|
}
|
||||||
|
|
||||||
|
return String(filterValue || '').trim().replace(/\s+/g, '_').toLowerCase()
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user