* Normalize OSM POIs and always use and store the OSM type and tags * Pass place objects to place route, do not load from API if passed * Construct place URLs with osm prefix including the type * Load specific type from API when given
83 lines
2.2 KiB
Plaintext
83 lines
2.2 KiB
Plaintext
import Component from '@glimmer/component';
|
|
import { pageTitle } from 'ember-page-title';
|
|
import Map from '#components/map';
|
|
import PlacesSidebar from '#components/places-sidebar';
|
|
import { service } from '@ember/service';
|
|
import { tracked } from '@glimmer/tracking';
|
|
import { action } from '@ember/object';
|
|
import { eq } from 'ember-truth-helpers';
|
|
import { and } from 'ember-truth-helpers';
|
|
|
|
export default class ApplicationComponent extends Component {
|
|
@service storage;
|
|
@service router;
|
|
|
|
@tracked nearbyPlaces = null;
|
|
// @tracked bookmarksVersion = 0; // Moved to storage service
|
|
|
|
get isSidebarOpen() {
|
|
return !!this.nearbyPlaces || this.router.currentRouteName === 'place';
|
|
}
|
|
|
|
constructor() {
|
|
super(...arguments);
|
|
console.log('Application component constructed');
|
|
// Access the service to ensure it is instantiated
|
|
this.storage;
|
|
}
|
|
|
|
@action
|
|
showPlaces(places, selectedPlace = null) {
|
|
// If we have a specific place, transition to the route
|
|
if (selectedPlace) {
|
|
// Pass the FULL object model to avoid re-fetching!
|
|
// The Route's serialize() hook handles URL generation.
|
|
this.router.transitionTo('place', selectedPlace);
|
|
this.nearbyPlaces = null; // Clear list when selecting specific
|
|
} else if (places && places.length > 0) {
|
|
// Show list case
|
|
this.nearbyPlaces = places;
|
|
this.router.transitionTo('index');
|
|
}
|
|
}
|
|
|
|
@action
|
|
selectFromList(place) {
|
|
if (place) {
|
|
// Optimize: Pass full object to avoid fetch
|
|
this.router.transitionTo('place', place);
|
|
}
|
|
}
|
|
|
|
@action
|
|
closeSidebar() {
|
|
this.nearbyPlaces = null;
|
|
this.router.transitionTo('index');
|
|
}
|
|
|
|
@action
|
|
refreshBookmarks() {
|
|
this.storage.notifyChange();
|
|
}
|
|
|
|
<template>
|
|
{{pageTitle "M/\RCO"}}
|
|
|
|
<Map
|
|
@onPlacesFound={{this.showPlaces}}
|
|
@isSidebarOpen={{this.isSidebarOpen}}
|
|
@onOutsideClick={{this.closeSidebar}}
|
|
/>
|
|
|
|
{{#if (and (eq this.router.currentRouteName "index") this.nearbyPlaces)}}
|
|
<PlacesSidebar
|
|
@places={{this.nearbyPlaces}}
|
|
@onSelect={{this.selectFromList}}
|
|
@onClose={{this.closeSidebar}}
|
|
/>
|
|
{{/if}}
|
|
|
|
{{outlet}}
|
|
</template>
|
|
}
|