From c9b88ca4efc929f703d3625d3f6c226e55099e32 Mon Sep 17 00:00:00 2001 From: itskovacs Date: Mon, 11 Aug 2025 18:43:58 +0200 Subject: [PATCH] :lipstick: Google Maps Trip navigation, :lipstick: Trip: table menu on mobile --- .../app/components/trip/trip.component.html | 28 +++++---- src/src/app/components/trip/trip.component.ts | 60 ++++++++++++++++++- 2 files changed, 76 insertions(+), 12 deletions(-) diff --git a/src/src/app/components/trip/trip.component.html b/src/src/app/components/trip/trip.component.html index 98863de..708a125 100644 --- a/src/src/app/components/trip/trip.component.html +++ b/src/src/app/components/trip/trip.component.html @@ -54,15 +54,23 @@
- -
- - -
- + + +
+ + +
@@ -105,9 +113,9 @@ {{ tripitem.time }}
- {{ tripitem.text }} @if (tripitem.status) {
} + {{ tripitem.text }}
diff --git a/src/src/app/components/trip/trip.component.ts b/src/src/app/components/trip/trip.component.ts index 7f8a4e7..d6067bf 100644 --- a/src/src/app/components/trip/trip.component.ts +++ b/src/src/app/components/trip/trip.component.ts @@ -118,6 +118,41 @@ export class TripComponent implements AfterViewInit { ], }, ]; + readonly menuTripTableActionsItems: MenuItem[] = [ + { + label: "Actions", + items: [ + { + label: "Directions", + icon: "pi pi-directions", + command: () => { + this.toggleTripDaysHighlight(); + }, + }, + { + label: "Navigation", + icon: "pi pi-car", + command: () => { + this.tripToNavigation(); + }, + }, + { + label: "Expand / Group", + icon: "pi pi-arrow-down-left-and-arrow-up-right-to-center", + command: () => { + this.tableExpandableMode = !this.tableExpandableMode; + }, + }, + { + label: "Print", + icon: "pi pi-print", + command: () => { + this.printTable(); + }, + }, + ], + }, + ]; readonly menuTripDayActionsItems: MenuItem[] = [ { label: "Actions", @@ -223,7 +258,7 @@ export class TripComponent implements AfterViewInit { this.selectedItem = undefined; setTimeout(() => { window.print(); - }, 30); + }, 100); } sortTripDays() { @@ -311,7 +346,16 @@ export class TripComponent implements AfterViewInit { } resetMapBounds() { - if (!this.places.length) return; + if (!this.places.length) { + this.map?.fitBounds( + this.flattenedTripItems + .filter((i) => i.lat != null && i.lng != null) + .map((i) => [i.lat!, i.lng!]), + { padding: [30, 30] }, + ); + return; + } + this.map?.fitBounds( this.places.map((p) => [p.lat, p.lng]), { padding: [30, 30] }, @@ -752,6 +796,18 @@ export class TripComponent implements AfterViewInit { window.open(url, "_blank"); } + tripToNavigation() { + // TODO: More services + const items = this.flattenedTripItems.filter( + (item) => item.lat && item.lng, + ); + if (!items.length) return; + + const waypoints = items.map((item) => `${item.lat},${item.lng}`).join("/"); + const url = `https://www.google.com/maps/dir/${waypoints}`; + window.open(url, "_blank"); + } + editDay(day: TripDay) { if (!this.trip) return;