Refactor category sorting logic in Vereinsmeisterschaften component
Some checks failed
Code Analysis (JS/Vue) / analyze (push) Failing after 51s
Some checks failed
Code Analysis (JS/Vue) / analyze (push) Failing after 51s
This commit introduces a new function, getSortedKategorien, to sort competition categories based on a predefined order. The rendering of categories in the Vereinsmeisterschaften component is updated to utilize this new sorting function, improving the organization and display of results. This change enhances the user experience by ensuring categories are presented in a consistent and logical order.
This commit is contained in:
@@ -72,7 +72,7 @@
|
||||
class="space-y-6"
|
||||
>
|
||||
<div
|
||||
v-for="(kategorieData, kategorie) in sortedGroupedResults[jahr].kategorien"
|
||||
v-for="kategorie in getSortedKategorien(sortedGroupedResults[jahr].kategorien)"
|
||||
:key="kategorie"
|
||||
class="border-l-4 border-primary-600 pl-4"
|
||||
>
|
||||
@@ -82,7 +82,7 @@
|
||||
|
||||
<div class="grid gap-3">
|
||||
<div
|
||||
v-for="(ergebnis, index) in kategorieData"
|
||||
v-for="(ergebnis, index) in sortedGroupedResults[jahr].kategorien[kategorie]"
|
||||
:key="index"
|
||||
:class="[
|
||||
'flex items-center justify-between p-3 rounded-lg',
|
||||
@@ -395,6 +395,31 @@ const totalDoubles = computed(() => {
|
||||
return results.value.filter(r => r.kategorie === 'Doppel' && r.platz === '1').length
|
||||
})
|
||||
|
||||
// Sortierreihenfolge für Kategorien
|
||||
const kategorieReihenfolge = ['Einzel', 'Doppel', 'Mixed', 'Senioren', 'Jugend']
|
||||
|
||||
function getSortedKategorien(kategorien) {
|
||||
if (!kategorien) return []
|
||||
|
||||
// Sortiere Kategorien nach vordefinierter Reihenfolge
|
||||
const sorted = Object.keys(kategorien).sort((a, b) => {
|
||||
const indexA = kategorieReihenfolge.indexOf(a)
|
||||
const indexB = kategorieReihenfolge.indexOf(b)
|
||||
|
||||
// Wenn beide in der Liste sind, sortiere nach Index
|
||||
if (indexA !== -1 && indexB !== -1) {
|
||||
return indexA - indexB
|
||||
}
|
||||
// Wenn nur eine in der Liste ist, kommt sie zuerst
|
||||
if (indexA !== -1) return -1
|
||||
if (indexB !== -1) return 1
|
||||
// Wenn keine in der Liste ist, alphabetisch sortieren
|
||||
return a.localeCompare(b)
|
||||
})
|
||||
|
||||
return sorted
|
||||
}
|
||||
|
||||
function openLightbox(filename, name) {
|
||||
lightboxImage.value = { filename, name }
|
||||
document.body.style.overflow = 'hidden'
|
||||
|
||||
Reference in New Issue
Block a user