Aktualisiert die Logik zum Löschen eines Datums in DiaryView.vue. Die Schaltfläche zum Löschen wird nun nur angezeigt, wenn keine Inhalte (Trainingplan, Teilnehmer, Aktivitäten, Unfälle oder Notizen) vorhanden sind. Fügt eine neue Methode canDeleteCurrentDate hinzu, die diese Überprüfung durchführt, um die Benutzerfreundlichkeit zu verbessern und versehentliche Löschungen zu verhindern.
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
<option v-for="entry in dates" :key="entry.id" :value="entry">{{ getFormattedDate(entry.date) }}
|
||||
</option>
|
||||
</select>
|
||||
<button v-if="date && date !== 'new' && trainingPlan.length === 0" class="btn-secondary" @click="deleteCurrentDate">Datum löschen</button>
|
||||
<button v-if="date && date !== 'new' && canDeleteCurrentDate" class="btn-secondary" @click="deleteCurrentDate">Datum löschen</button>
|
||||
</label>
|
||||
</div>
|
||||
<div v-if="showForm && date === 'new'">
|
||||
@@ -534,6 +534,20 @@ export default {
|
||||
return this.newMember.firstName.trim() !== '' &&
|
||||
(this.newMember.gender === 'male' || this.newMember.gender === 'female' || this.newMember.gender === 'diverse');
|
||||
},
|
||||
|
||||
canDeleteCurrentDate() {
|
||||
if (!this.date || this.date === 'new') return false;
|
||||
|
||||
// Prüfe ob keine Inhalte vorhanden sind
|
||||
const hasTrainingPlan = this.trainingPlan && this.trainingPlan.length > 0;
|
||||
const hasParticipants = this.participants && this.participants.length > 0;
|
||||
const hasActivities = this.activities && this.activities.length > 0;
|
||||
const hasAccidents = this.accidents && this.accidents.length > 0;
|
||||
const hasNotes = this.notes && this.notes.length > 0;
|
||||
|
||||
// Kann gelöscht werden wenn alle Listen leer sind
|
||||
return !hasTrainingPlan && !hasParticipants && !hasActivities && !hasAccidents && !hasNotes;
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
drawingDataFor(pa) {
|
||||
@@ -1044,9 +1058,8 @@ export default {
|
||||
},
|
||||
|
||||
async deleteCurrentDate() {
|
||||
if (!this.date || this.date === 'new') return;
|
||||
if (this.trainingPlan.length > 0) {
|
||||
alert('Datum kann nicht gelöscht werden: Es sind bereits Aktivitäten vorhanden.');
|
||||
if (!this.canDeleteCurrentDate) {
|
||||
alert('Datum kann nicht gelöscht werden: Es sind noch Inhalte vorhanden (Trainingplan, Teilnehmer, Aktivitäten, Unfälle oder Notizen).');
|
||||
return;
|
||||
}
|
||||
if (!confirm('Dieses Datum wirklich löschen?')) return;
|
||||
|
||||
Reference in New Issue
Block a user