diff --git a/frontend/src/components/AccidentFormDialog.vue b/frontend/src/components/AccidentFormDialog.vue index baec230..4154a9c 100644 --- a/frontend/src/components/AccidentFormDialog.vue +++ b/frontend/src/components/AccidentFormDialog.vue @@ -86,7 +86,14 @@ export default { }, computed: { availableMembers() { - return this.members.filter(m => this.participants.indexOf(m.id) >= 0); + // participants ist ein Array von IDs, nicht von Objekten + const participantIds = Array.isArray(this.participants) + ? (this.participants.length > 0 && typeof this.participants[0] === 'object' + ? this.participants.map(p => p.id || p) + : this.participants) + : []; + const participantSet = new Set(participantIds); + return this.members.filter(m => participantSet.has(m.id)); }, isValid() { return this.localAccident.memberId && this.localAccident.accident && this.localAccident.accident.trim() !== ''; @@ -95,15 +102,20 @@ export default { watch: { accident: { handler(newVal) { - this.localAccident = { ...newVal }; + // Nur aktualisieren, wenn sich wirklich etwas geändert hat (verhindert Endlosschleife) + if (newVal && (newVal.memberId !== this.localAccident.memberId || newVal.accident !== this.localAccident.accident)) { + this.localAccident = { ...newVal }; + } }, - deep: true + immediate: true }, - localAccident: { - handler(newVal) { - this.$emit('update:accident', newVal); - }, - deep: true + 'localAccident.memberId'() { + // Emit nur bei Änderung der memberId, nicht bei jeder tiefen Änderung + this.$emit('update:accident', { ...this.localAccident }); + }, + 'localAccident.accident'() { + // Emit nur bei Änderung des accident-Textes + this.$emit('update:accident', { ...this.localAccident }); } }, methods: {