-
Notifications
You must be signed in to change notification settings - Fork 4
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
Feat/disable map visualization #25
Changes from all commits
f6fabc8
3482368
b57bccb
b8a9d7b
111a204
686bd44
06143b3
c619fb3
c03d9fd
97f30e0
c17ed18
27f6b5a
73dfc03
be07f71
de1ca21
483ee9c
cdd4ac9
1e3640f
c54e080
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,26 +15,38 @@ const router = useRouter(); | |
const route = useRoute(); | ||
const t = useTranslations(); | ||
|
||
const currentView = useGetCurrentView(); | ||
const { getUnprefixedId } = useIdPrefix(); | ||
|
||
const searchFiltersSchema = v.object({ | ||
category: v.fallback(v.picklist(categories), "entityName"), | ||
search: v.fallback(v.string(), ""), | ||
}); | ||
|
||
const detailEntityId = computed(() => { | ||
return route.params.id as string; | ||
const entitySelectionSchema = v.object({ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is this actually used somewhere? |
||
selection: v.fallback(v.array(v.string()), []), | ||
}); | ||
|
||
const searchFilters = computed(() => { | ||
return v.parse(searchFiltersSchema, route.query); | ||
}); | ||
|
||
type EntitySelection = v.InferOutput<typeof entitySelectionSchema>; | ||
|
||
type SearchFilters = v.InferOutput<typeof searchFiltersSchema>; | ||
|
||
function setEntitySelection(query: Partial<EntitySelection>) { | ||
void router.push({ query: { mode: route.query.mode, ...query } }); | ||
} | ||
|
||
function onChangeEntitySelection(values: EntityFeature) { | ||
const temp: EntitySelection = { | ||
selection: [getUnprefixedId(values["@id"])], | ||
}; | ||
setEntitySelection(temp); | ||
} | ||
|
||
function setSearchFilters(query: Partial<SearchFilters>) { | ||
void router.push({ query }); | ||
void router.push({ query: { mode: route.query.mode, ...query } }); | ||
} | ||
|
||
function onChangeSearchFilters(values: SearchFormData) { | ||
|
@@ -83,6 +95,13 @@ function togglePolygons() { | |
show.value = !show.value; | ||
} | ||
|
||
const selection = computed(() => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we should validate this |
||
return route.query.selection; | ||
}); | ||
|
||
const mode = computed(() => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we should validate this |
||
return route.query.mode; | ||
}); | ||
/** | ||
* Reduce size of geojson payload, which has an impact on performance, | ||
* because `maplibre-gl` will serialize geojson features when sending them to the webworker. | ||
|
@@ -148,30 +167,32 @@ watch(data, () => { | |
}); | ||
|
||
watchEffect(() => { | ||
const entity = entities.value.find((feature) => { | ||
const id = getUnprefixedId(feature["@id"]); | ||
return id === detailEntityId.value; | ||
}); | ||
|
||
if (entity) { | ||
let coordinates = null; | ||
|
||
if (entity.geometry.type === "GeometryCollection") { | ||
coordinates = entity.geometry.geometries.find((g) => { | ||
return g.type === "Point"; | ||
})?.coordinates as [number, number] | undefined; | ||
} | ||
|
||
if (entity.geometry.type === "Point") { | ||
coordinates = entity.geometry.coordinates as unknown as [number, number]; | ||
if (mode.value && selection.value) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do we need to close the popover when selection is empty? |
||
const entity = entities.value.find((feature) => { | ||
const id = getUnprefixedId(feature["@id"]); | ||
return id === selection.value; | ||
}); | ||
|
||
if (entity) { | ||
let coordinates = null; | ||
|
||
if (entity.geometry.type === "GeometryCollection") { | ||
coordinates = entity.geometry.geometries.find((g) => { | ||
return g.type === "Point"; | ||
})?.coordinates as [number, number] | undefined; | ||
} | ||
|
||
if (entity.geometry.type === "Point") { | ||
coordinates = entity.geometry.coordinates as unknown as [number, number]; | ||
} | ||
|
||
popover.value = { | ||
coordinates: | ||
coordinates ?? | ||
(turf.center(createFeatureCollection([entity])).geometry.coordinates as [number, number]), | ||
entities: [entity], | ||
}; | ||
} | ||
|
||
popover.value = { | ||
coordinates: | ||
coordinates ?? | ||
(turf.center(createFeatureCollection([entity])).geometry.coordinates as [number, number]), | ||
entities: [entity], | ||
}; | ||
} | ||
}); | ||
</script> | ||
|
@@ -248,8 +269,9 @@ watchEffect(() => { | |
> | ||
<strong class="font-medium"> | ||
<NavLink | ||
class="flex items-center gap-1 underline decoration-dotted hover:no-underline" | ||
:href="{ path: `/entities/${entity.properties._id}/${currentView}` }" | ||
href="#" | ||
class="flex cursor-pointer items-center gap-1 underline decoration-dotted hover:no-underline" | ||
@click="onChangeEntitySelection(entity)" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this should be a regular link. instead of |
||
> | ||
<Component :is="getEntityIcon(entity.systemClass)" class="size-3.5 shrink-0" /> | ||
{{ entity.properties.title }} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should validate this