💄 On attachment delete: update plans

This commit is contained in:
itskovacs 2025-11-11 19:31:19 +01:00
parent f166ccc795
commit d364052b4d

View File

@ -2027,13 +2027,16 @@ export class TripComponent implements AfterViewInit {
next: () => { next: () => {
this.trip!.attachments = this.trip?.attachments?.filter((att) => att.id != attachmentId); this.trip!.attachments = this.trip?.attachments?.filter((att) => att.id != attachmentId);
let modifiedItem = false; let modifiedItem = false;
this.trip?.days.forEach(d => d.items.forEach(i => { this.trip?.days.forEach((d) =>
if (i.attachments?.length) { d.items.forEach((i) => {
i.attachments = i.attachments.filter(attachment => attachment.id != attachmentId); if (i.attachments?.length) {
modifiedItem = true; i.attachments = i.attachments.filter((attachment) => attachment.id != attachmentId);
} modifiedItem = true;
})) }
if (this.selectedItem?.attachments?.length) this.selectedItem.attachments = this.selectedItem.attachments.filter((a) => a.id != attachmentId); }),
);
if (this.selectedItem?.attachments?.length)
this.selectedItem.attachments = this.selectedItem.attachments.filter((a) => a.id != attachmentId);
if (modifiedItem) this.flattenTripDayItems(); if (modifiedItem) this.flattenTripDayItems();
}, },
}); });