From 6a8b0e35d7d8d429bd8b68b79e1efba1c8738404 Mon Sep 17 00:00:00 2001 From: "Torsten Schulz (local)" Date: Fri, 22 Aug 2025 16:06:56 +0200 Subject: [PATCH] =?UTF-8?q?F=C3=BCgt=20Sortierfunktionalit=C3=A4t=20f?= =?UTF-8?q?=C3=BCr=20die=20Mitgliederstatistik=20hinzu.=20Die=20Tabellen?= =?UTF-8?q?=C3=BCberschriften=20sind=20jetzt=20klickbar=20und=20erm=C3=B6g?= =?UTF-8?q?lichen=20eine=20Sortierung=20nach=20Name=20und=20Teilnahmezahle?= =?UTF-8?q?n.=20Zudem=20wurde=20die=20Sortierreihenfolge=20implementiert?= =?UTF-8?q?=20und=20visuell=20durch=20Icons=20angezeigt.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/views/TrainingStatsView.vue | 101 +++++++++++++++++++++-- 1 file changed, 95 insertions(+), 6 deletions(-) diff --git a/frontend/src/views/TrainingStatsView.vue b/frontend/src/views/TrainingStatsView.vue index 75609db..23966a6 100644 --- a/frontend/src/views/TrainingStatsView.vue +++ b/frontend/src/views/TrainingStatsView.vue @@ -23,16 +23,36 @@ - + - - - + + + - + @@ -108,6 +128,32 @@ export default { if (this.activeMembers.length === 0) return 0; const total = this.activeMembers.reduce((sum, member) => sum + member.participation3Months, 0); return total / this.activeMembers.length; + }, + + sortedMembers() { + if (!this.activeMembers.length) return []; + + return [...this.activeMembers].sort((a, b) => { + let aValue, bValue; + + if (this.sortField === 'name') { + // Case-insensitive Namens-Sortierung mit localeCompare + // Sortiere nach firstName lastName (wie in der Anzeige) + const aName = `${a.firstName} ${a.lastName}`; + const bName = `${b.firstName} ${b.lastName}`; + return aName.localeCompare(bName, 'de', { sensitivity: 'base' }) * (this.sortDirection === 'asc' ? 1 : -1); + } else { + // Numerische Sortierung + aValue = a[this.sortField] || 0; + bValue = b[this.sortField] || 0; + + if (this.sortDirection === 'asc') { + return aValue > bValue ? 1 : -1; + } else { + return aValue < bValue ? 1 : -1; + } + } + }); } }, @@ -116,7 +162,9 @@ export default { activeMembers: [], showDetailsModal: false, selectedMember: {}, - loading: false + loading: false, + sortField: 'name', + sortDirection: 'asc' }; }, @@ -177,6 +225,24 @@ export default { formatDate(dateString) { const date = new Date(dateString); return `${String(date.getDate()).padStart(2, '0')}.${String(date.getMonth() + 1).padStart(2, '0')}.${date.getFullYear()}`; + }, + + sortBy(field) { + if (this.sortField === field) { + // Wenn bereits nach diesem Feld sortiert wird, Richtung umkehren + this.sortDirection = this.sortDirection === 'asc' ? 'desc' : 'asc'; + } else { + // Neues Feld, Standardrichtung setzen + this.sortField = field; + this.sortDirection = 'desc'; + } + }, + + getSortIcon(field) { + if (this.sortField !== field) { + return '↕️'; // Neutral + } + return this.sortDirection === 'asc' ? '↑' : '↓'; } } }; @@ -245,6 +311,29 @@ export default { border-bottom: 1px solid var(--border-color); } +.sortable-header { + cursor: pointer; + user-select: none; + transition: background-color 0.2s ease; +} + +.sortable-header:hover { + background: var(--primary-color) !important; + color: white !important; +} + +.header-content { + display: flex; + align-items: center; + justify-content: space-between; + gap: 0.5rem; +} + +.sort-icon { + font-size: 0.875rem; + opacity: 0.7; +} + .members-table td { padding: 1rem; border-bottom: 1px solid var(--border-color);
Name +
+ Name + {{ getSortIcon('name') }} +
+
GeburtsdatumTeilnahmen (12 Monate)Teilnahmen (3 Monate)Teilnahmen (Gesamt) +
+ Teilnahmen (12 Monate) + {{ getSortIcon('participation12Months') }} +
+
+
+ Teilnahmen (3 Monate) + {{ getSortIcon('participation3Months') }} +
+
+
+ Teilnahmen (Gesamt) + {{ getSortIcon('participationTotal') }} +
+
Aktionen
{{ member.firstName }} {{ member.lastName }} {{ formatBirthdate(member.birthDate) }} {{ member.participation12Months }}