Skip to content

Commit 7b597e2

Browse files
committed
💄 Trip map: grey out unused places, 💄 minor tweaks
1 parent ec1f5db commit 7b597e2

File tree

6 files changed

+47
-16
lines changed

6 files changed

+47
-16
lines changed

src/src/app/components/trip/trip.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ <h2 class="text-xl md:text-3xl font-semibold mb-0 truncate max-w-96 md:mx-auto">
183183
@if (selectedItem.comment) {
184184
<div class="md:col-span-2 rounded-md shadow p-4">
185185
<p class="font-bold mb-1">Comment</p>
186-
<p class="text-sm text-gray-500">{{ selectedItem.comment }}</p>
186+
<p class="text-sm text-gray-500 whitespace-pre-line">{{ selectedItem.comment }}</p>
187187
</div>
188188
}
189189

src/src/app/components/trip/trip.component.ts

Lines changed: 36 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ export class TripComponent implements AfterViewInit {
284284

285285
this.markerClusterGroup?.clearLayers();
286286
this.places.forEach((p) => {
287-
const marker = placeToMarker(p, false);
287+
const marker = placeToMarker(p, false, !this.placesUsedInTable.has(p.id));
288288
this.markerClusterGroup?.addLayer(marker);
289289
});
290290
}
@@ -375,9 +375,19 @@ export class TripComponent implements AfterViewInit {
375375
.flatMap((day) => day.items.sort((a, b) => a.time.localeCompare(b.time)))
376376
.map((item) => {
377377
if (item.lat && item.lng)
378-
return { text: item.text, lat: item.lat, lng: item.lng };
378+
return {
379+
text: item.text,
380+
lat: item.lat,
381+
lng: item.lng,
382+
isPlace: !!item.place,
383+
};
379384
if (item.place && item.place)
380-
return { text: item.text, lat: item.place.lat, lng: item.place.lng };
385+
return {
386+
text: item.text,
387+
lat: item.place.lat,
388+
lng: item.place.lng,
389+
isPlace: true,
390+
};
381391
return undefined;
382392
})
383393
.filter((n) => n !== undefined);
@@ -413,7 +423,7 @@ export class TripComponent implements AfterViewInit {
413423
const layGroup = L.layerGroup();
414424
layGroup.addLayer(path);
415425
items.forEach((item) => {
416-
layGroup.addLayer(tripDayMarker(item));
426+
if (!item.isPlace) layGroup.addLayer(tripDayMarker(item));
417427
});
418428

419429
if (this.tripMapAntLayer) {
@@ -448,9 +458,19 @@ export class TripComponent implements AfterViewInit {
448458
const items = data
449459
.map((item) => {
450460
if (item.lat && item.lng)
451-
return { text: item.text, lat: item.lat, lng: item.lng };
461+
return {
462+
text: item.text,
463+
lat: item.lat,
464+
lng: item.lng,
465+
isPlace: !!item.place,
466+
};
452467
if (item.place && item.place)
453-
return { text: item.text, lat: item.place.lat, lng: item.place.lng };
468+
return {
469+
text: item.text,
470+
lat: item.place.lat,
471+
lng: item.place.lng,
472+
isPlace: true,
473+
};
454474
return undefined;
455475
})
456476
.filter((n) => n !== undefined);
@@ -486,7 +506,7 @@ export class TripComponent implements AfterViewInit {
486506
const layGroup = L.layerGroup();
487507
layGroup.addLayer(path);
488508
items.forEach((item) => {
489-
layGroup.addLayer(tripDayMarker(item));
509+
if (!item.isPlace) layGroup.addLayer(tripDayMarker(item));
490510
});
491511

492512
if (this.tripMapAntLayer) {
@@ -765,7 +785,10 @@ export class TripComponent implements AfterViewInit {
765785
);
766786
}
767787
if (item.price) this.updateTotalPrice(item.price);
768-
if (item.place?.id) this.placesUsedInTable.add(item.place.id);
788+
if (item.place?.id) {
789+
this.placesUsedInTable.add(item.place.id);
790+
this.setPlacesAndMarkers();
791+
}
769792
},
770793
});
771794
},
@@ -832,6 +855,8 @@ export class TripComponent implements AfterViewInit {
832855

833856
if (this.tripMapAntLayerDayID == item.day_id)
834857
this.toggleTripDayHighlightPathDay(item.day_id);
858+
859+
if (item.place?.id || it.place?.id) this.setPlacesAndMarkers();
835860
},
836861
});
837862
},
@@ -869,8 +894,10 @@ export class TripComponent implements AfterViewInit {
869894
this.flattenedTripItems = this.flattenTripDayItems(
870895
this.trip?.days!,
871896
);
872-
if (item.place?.id)
897+
if (item.place?.id) {
873898
this.placesUsedInTable.delete(item.place.id);
899+
this.setPlacesAndMarkers();
900+
}
874901
this.dayStatsCache.delete(item.day_id);
875902
this.selectedItem = undefined;
876903
this.resetPlaceHighlightMarker();

src/src/app/components/trips/trips.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
</div>
1010
</div>
1111

12-
<div class="mt-10 grid gap-4 grid-cols-1 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4">
12+
<div class="mt-10 grid gap-4 grid-cols-2 md:grid-cols-3 lg:grid-cols-4">
1313
@defer {
1414
@for (trip of trips; track trip.id) {
1515
<div class="group relative rounded-lg overflow-hidden shadow-lg cursor-pointer" [class.grayscale]="trip.archived"

src/src/app/modals/place-create-modal/place-create-modal.component.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,8 @@ export class PlaceCreateModalComponent {
121121
const latControl = this.placeForm.get("lat");
122122
const lngControl = this.placeForm.get("lng");
123123

124-
latControl?.setValue(formatLatLng(lat), { emitEvent: false });
125-
lngControl?.setValue(formatLatLng(lng), { emitEvent: false });
124+
latControl?.setValue(formatLatLng(lat).trim(), { emitEvent: false });
125+
lngControl?.setValue(formatLatLng(lng).trim(), { emitEvent: false });
126126

127127
lngControl?.markAsDirty();
128128
lngControl?.updateValueAndValidity();

src/src/app/modals/trip-create-day-item-modal/trip-create-day-item-modal.component.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,8 @@ export class TripCreateDayItemModalComponent {
121121
const latControl = this.itemForm.get("lat");
122122
const lngControl = this.itemForm.get("lng");
123123

124-
latControl?.setValue(formatLatLng(lat), { emitEvent: false });
125-
lngControl?.setValue(formatLatLng(lng), { emitEvent: false });
124+
latControl?.setValue(formatLatLng(lat).trim(), { emitEvent: false });
125+
lngControl?.setValue(formatLatLng(lng).trim(), { emitEvent: false });
126126

127127
lngControl?.markAsDirty();
128128
lngControl?.updateValueAndValidity();

src/src/app/shared/map.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ export function tripDayMarker(item: {
9999
export function placeToMarker(
100100
place: Place,
101101
isLowNet: boolean = true,
102+
grayscale: boolean = false,
102103
): L.Marker {
103104
let marker: L.Marker;
104105
let options: any = {
@@ -114,14 +115,17 @@ export function placeToMarker(
114115
? place.category.image
115116
: (place.image ?? place.category.image);
116117

118+
let markerClasses = place.visited ? "image-marker visited" : "image-marker";
119+
if (grayscale) markerClasses += " grayscale";
120+
117121
marker.options.icon = L.icon({
118122
iconUrl: markerImage,
119123
iconSize: [56, 56],
120124
iconAnchor: [28, 28],
121125
shadowSize: [0, 0],
122126
shadowAnchor: [0, 0],
123127
popupAnchor: [0, -12],
124-
className: place.visited ? "image-marker visited" : "image-marker",
128+
className: markerClasses,
125129
});
126130

127131
let touchDevice = "ontouchstart" in window;

0 commit comments

Comments
 (0)