Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added the feature for hiding the bus route on back to button #33

Merged
merged 3 commits into from
Aug 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions src/components/map/GoogleMap.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@
import StopMarker from './StopMarker.svelte';
import RouteMap from './RouteMap.svelte';

export let selectedTrip;
export let selectedTrip = null;
export let selectedRoute = null;
export let showRoute = false;
export let showRouteMap = false;
export let showAllStops = true;

const dispatch = createEventDispatcher();

Expand Down Expand Up @@ -83,6 +85,11 @@
markers = [];
}

$: if (showAllStops) {
clearAllMarkers();
allStops.forEach((s) => addMarker(s));
}

$: if (selectedRoute && showRoute) {
clearAllMarkers();
const stopsToShow = allStops.filter((s) => s.routeIds.includes(selectedRoute.id));
Expand Down Expand Up @@ -194,7 +201,7 @@

<div id="map"></div>

{#if selectedTrip}
{#if selectedTrip && showRouteMap}
<RouteMap {map} tripId={selectedTrip.tripId} />
{/if}

Expand Down
12 changes: 12 additions & 0 deletions src/components/oba/StopPane.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

export let stop;
export let arrivalsAndDeparturesResponse = null;
export let showAllStops = true;

let arrivalsAndDepartures;
let loading = false;
let error;
Expand All @@ -29,6 +31,11 @@
loading = false;
}

$: if (showAllStops) {
showTripDetails = false;
selectedTripDetails = null;
}

$: (async (s, arrDep) => {
// if the arrivalsAndDeparturesResponse is passed in, use that
// instead of loading fresh data.
Expand Down Expand Up @@ -66,9 +73,14 @@
};
showTripDetails = true;
dispatch('tripSelected', selectedTripDetails);
dispatch('updateRouteMap', { show: true });
}

function handleCloseTripDetailModal() {
showTripDetails = false;
dispatch('tripSelected', null);
dispatch('updateRouteMap', { show: false });
dispatch('showAllStops');
}
</script>

Expand Down
46 changes: 38 additions & 8 deletions src/routes/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
let selectedTrip = null;
let showRoute = false;
let selectedRoute = null;
let showRouteMap = false;
let showAllStops = false;

function stopSelected(event) {
stop = event.detail.stop;
Expand All @@ -20,19 +22,47 @@
}

function tripSelected(event) {
selectedTrip = event.detail;
showRoute = true;
selectedRoute = {
id: event.detail.routeId,
shortName: event.detail.routeShortName
};
if (event.detail) {
selectedTrip = event.detail;
showRoute = true;
selectedRoute = {
id: event.detail.routeId,
shortName: event.detail.routeShortName
};
} else {
selectedTrip = null;
showRoute = false;
selectedRoute = null;
}
}

function handleUpdateRouteMap(event) {
showRouteMap = event.detail.show;
showAllStops = !event.detail.show;
}

function handleShowAllStops() {
showAllStops = true;
showRouteMap = false;
}
</script>

{#if stop}
<ModalPane on:close={closePane}>
<StopPane {stop} on:tripSelected={tripSelected} />
<StopPane
{showAllStops}
{stop}
on:tripSelected={tripSelected}
on:updateRouteMap={handleUpdateRouteMap}
on:showAllStops={handleShowAllStops}
/>
</ModalPane>
{/if}

<GoogleMap {selectedTrip} {selectedRoute} on:stopSelected={stopSelected} {showRoute} />
<GoogleMap
{selectedTrip}
{selectedRoute}
on:stopSelected={stopSelected}
{showRoute}
{showRouteMap}
/>
Loading