wip: use pinia
This commit is contained in:
@@ -13,24 +13,6 @@
|
||||
/>
|
||||
</MglMap>
|
||||
</ClientOnly>
|
||||
|
||||
<div v-if="routesRequest.data.value" id="lineSelector">
|
||||
<div
|
||||
v-for="route of routesRequest.data.value"
|
||||
:key="route.id"
|
||||
:class="{
|
||||
selected: selectedRoutes.includes(route.id),
|
||||
lineLabel: true,
|
||||
}"
|
||||
:style="{
|
||||
background: '#' + route.color,
|
||||
color: '#' + route.textColor,
|
||||
}"
|
||||
@click="selectRoute(route.id)"
|
||||
>
|
||||
{{ route.type }} : {{ route.shortName }}
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
@@ -69,28 +51,6 @@ const transport_lines = computed(() => linesRequest.data.value?.features ?? []);
|
||||
|
||||
const routesRequest = await useFetch<Route[]>("/routes.json");
|
||||
|
||||
// Selected routes with lines
|
||||
const routeWithLines = computed(() => {
|
||||
const shownLines: { route: Route; line: Feature<MultiLineString> }[] = [];
|
||||
for (const routeId of selectedRoutes.value) {
|
||||
const route = routesRequest.data.value?.find((r) => r.id == routeId);
|
||||
if (!route) {
|
||||
continue;
|
||||
}
|
||||
const line = transport_lines.value.find(
|
||||
(f) => routeId == f.properties?.id.replace("_", ":"),
|
||||
);
|
||||
if (!line) {
|
||||
continue;
|
||||
}
|
||||
shownLines.push({
|
||||
route,
|
||||
line,
|
||||
});
|
||||
}
|
||||
return shownLines;
|
||||
});
|
||||
|
||||
async function selectRoute(routeId: string) {
|
||||
if (!map.map) {
|
||||
console.error("Map is not yet initialized ! aborting");
|
||||
|
||||
Reference in New Issue
Block a user