feat(App): enhance club selection and routing logic
- Updated the club selection dropdown to trigger a method on change, improving user interaction. - Removed the load club button, streamlining the selection process. - Introduced a computed property for view reloading based on the current club and route. - Refactored club selection handling to ensure proper routing when selecting a new club or creating one.
This commit is contained in:
@@ -62,14 +62,11 @@
|
||||
<div class="club-selector card">
|
||||
<h3 class="card-title">{{ $t('club.select') }}</h3>
|
||||
<div class="select-group">
|
||||
<select v-model="selectedClub" class="club-select">
|
||||
<select v-model="selectedClub" class="club-select" @change="handleClubSelectionChange">
|
||||
<option value="">{{ $t('club.selectPlaceholder') }}</option>
|
||||
<option value="new">{{ $t('club.new') }}</option>
|
||||
<option v-for="club in clubs" :key="club.id" :value="club.id">{{ club.name }}</option>
|
||||
</select>
|
||||
<button @click="loadClub" class="btn-primary" :disabled="!selectedClub">
|
||||
<span>{{ $t('club.load') }}</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -140,7 +137,7 @@
|
||||
<main class="main-content">
|
||||
<router-view v-slot="{ Component }">
|
||||
<div class="content fade-in">
|
||||
<component :is="Component" />
|
||||
<component :is="Component" :key="viewReloadKey" />
|
||||
</div>
|
||||
</router-view>
|
||||
</main>
|
||||
@@ -240,11 +237,11 @@ export default {
|
||||
// Owner oder Admin können Berechtigungen verwalten
|
||||
return this.isClubOwner || this.userRole === 'admin' || this.hasPermission('permissions', 'read');
|
||||
},
|
||||
viewReloadKey() {
|
||||
return `${this.$route.fullPath}|${this.currentClub || 'no-club'}`;
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
selectedClub(newVal) {
|
||||
this.setCurrentClub(newVal);
|
||||
},
|
||||
currentClub(newVal) {
|
||||
if (newVal === 'new') {
|
||||
this.$router.push('/createclub');
|
||||
@@ -315,6 +312,18 @@ export default {
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
async handleClubSelectionChange() {
|
||||
if (!this.selectedClub) {
|
||||
await this.setCurrentClub(null);
|
||||
return;
|
||||
}
|
||||
|
||||
await this.setCurrentClub(this.selectedClub);
|
||||
if (this.selectedClub === 'new') {
|
||||
this.$router.push('/createclub');
|
||||
}
|
||||
},
|
||||
|
||||
async loadUserData() {
|
||||
try {
|
||||
@@ -332,20 +341,6 @@ export default {
|
||||
}
|
||||
},
|
||||
|
||||
async loadClub() {
|
||||
await this.setCurrentClub(this.selectedClub);
|
||||
if (this.selectedClub === 'new') {
|
||||
this.$router.push('/createclub');
|
||||
return;
|
||||
}
|
||||
// Wenn keine Berechtigung, auf Club-Ansicht mit Anfrage-Button
|
||||
if (!this.hasPermission('statistics', 'read')) {
|
||||
this.$router.push(`/showclub/${this.selectedClub}`);
|
||||
return;
|
||||
}
|
||||
this.$router.push('/training-stats');
|
||||
},
|
||||
|
||||
async checkSession() {
|
||||
try {
|
||||
const response = await apiClient.get('/session/status');
|
||||
|
||||
Reference in New Issue
Block a user