From 725b2cc16e9cbe810df69913e14beb9d4911a35b Mon Sep 17 00:00:00 2001 From: itskovacs Date: Sat, 25 Oct 2025 14:09:06 +0200 Subject: [PATCH] :lipstick: refresh days order on interactions --- src/src/app/components/trip/trip.component.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/src/app/components/trip/trip.component.ts b/src/src/app/components/trip/trip.component.ts index ad688da..a21c9d0 100644 --- a/src/src/app/components/trip/trip.component.ts +++ b/src/src/app/components/trip/trip.component.ts @@ -910,6 +910,18 @@ export class TripComponent implements AfterViewInit { }); } + sortDays() { + this.trip?.days?.sort((a, b) => { + const hasDateA = !!a.dt; + const hasDateB = !!b.dt; + + if (hasDateA && !hasDateB) return -1; + if (!hasDateA && hasDateB) return 1; + + return (a.dt || '').localeCompare(b.dt || '') || (a.label || '').localeCompare(b.label || ''); + }); + } + addDay() { if (!this.trip) return; @@ -936,6 +948,7 @@ export class TripComponent implements AfterViewInit { .subscribe({ next: (day) => { this.trip!.days.push(day); + this.sortDays(); this.flattenTripDayItems(); }, }); @@ -1013,6 +1026,7 @@ export class TripComponent implements AfterViewInit { const idx = this.trip!.days.findIndex((d) => d.id == day.id); if (idx != -1) { this.trip?.days.splice(idx, 1, day); + this.sortDays(); this.flattenTripDayItems(); } },