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

Feat/disable map visualization #25

Merged
merged 19 commits into from
Aug 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
f6fabc8
chore: remove padding and center buttons in visualizations
oliviareichl Jun 28, 2024
3482368
style: place tooltip above element
oliviareichl Jul 15, 2024
b57bccb
Merge branch 'develop' into feat/disable-map-visualization
oliviareichl Jul 18, 2024
b8a9d7b
chore: refactor the layout and usage of query params so the sidebar w…
oliviareichl Jul 19, 2024
111a204
WIP: make the visualizations navigatable per query params
oliviareichl Jul 22, 2024
686bd44
fix: search in both visualizations, network mode with query params
oliviareichl Jul 23, 2024
06143b3
chore: disable mode switch when the entity is not a place
oliviareichl Jul 23, 2024
c619fb3
fix: labels are shown when a detailview is selected
oliviareichl Jul 24, 2024
c03d9fd
fix: call mode-switcher only when an id is provided
oliviareichl Jul 24, 2024
97f30e0
fix: highlight searchnodes in network after disposing a detailnode
oliviareichl Jul 25, 2024
c17ed18
chore: implement the detailview functionality in the data table
oliviareichl Jul 29, 2024
27f6b5a
refactor: delete unused data page
oliviareichl Jul 29, 2024
73dfc03
chore: modify mode-switcher so the datalist view is also switchable
oliviareichl Jul 30, 2024
be07f71
fix: mode switcher movement when a detailview in the data view is sel…
oliviareichl Jul 30, 2024
de1ca21
fix: data and map view when map is the start page
oliviareichl Jul 31, 2024
483ee9c
fix: update landing page links
stefanprobst Aug 5, 2024
cdd4ac9
fix: add missing icon for event system class
stefanprobst Aug 5, 2024
1e3640f
fix: adapt navlinks in the detail view to new route
oliviareichl Aug 7, 2024
c54e080
fix: missing route
oliviareichl Aug 7, 2024
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
22 changes: 16 additions & 6 deletions components/app-header.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,26 @@ const defaultLinks = computed<
if (!project.map.startPage) {
return {
home: { href: { path: "/" }, label: t("AppHeader.links.home") },
data: { href: { path: "/data" }, label: t("AppHeader.links.data") },
map: { href: { path: "/map" }, label: t("AppHeader.links.map") },
network: { href: { path: "/network" }, label: t("AppHeader.links.network") },
data: {
href: { path: "/visualization", query: { mode: "table" } },
label: t("AppHeader.links.data"),
},
map: {
href: { path: "/visualization", query: { mode: "map" } },
label: t("AppHeader.links.map"),
},
network: {
href: { path: "/visualization", query: { mode: "network" } },
label: t("AppHeader.links.network"),
},
team: { href: { path: "/team" }, label: t("AppHeader.links.team") },
};
}
return {
home: { href: { path: "/" }, label: t("AppHeader.links.home") },
data: { href: { path: "/data" }, label: t("AppHeader.links.data") },
network: { href: { path: "/network" }, label: t("AppHeader.links.network") },
home: {
href: { path: "/", query: { mode: "map" } },
label: t("AppHeader.links.home"),
},
team: { href: { path: "/team" }, label: t("AppHeader.links.team") },
};
});
Expand Down
22 changes: 20 additions & 2 deletions components/custom-primary-details-feature.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const t = useTranslations();
const { getUnprefixedId } = useIdPrefix();

const props = defineProps<{ entity: EntityFeature }>();
const route = useRoute();

const { data } = useGetBySystemClass(
computed(() => {
Expand Down Expand Up @@ -80,13 +81,27 @@ const handledRelations: Array<RelationType> = [
onMounted(() => {
emit("handledRelations", handledRelations);
});

function getPath() {
if (route.path.includes("visualization")) {
return "visualization";
}
return "";
}

const currentMode = computed(() => {
return route.query.mode;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should validate this

});
</script>

<template>
<div class="flex justify-between">
<NavLink
v-if="previousFeature"
:href="{ path: `/entities/${getUnprefixedId(previousFeature['@id'])}` }"
:href="{
path: `/${getPath()}`,
query: { mode: currentMode, selection: getUnprefixedId(previousFeature['@id']) },
}"
class="flex items-center underline decoration-dotted transition hover:no-underline focus-visible:no-underline"
>
<ChevronLeftIcon class="size-4" />
Expand All @@ -95,7 +110,10 @@ onMounted(() => {
</NavLink>
<NavLink
v-if="nextFeature"
:href="{ path: `/entities/${getUnprefixedId(nextFeature['@id'])}` }"
:href="{
path: `/${getPath()}`,
query: { mode: currentMode, selection: getUnprefixedId(nextFeature['@id']) },
}"
class="flex items-center underline decoration-dotted transition hover:no-underline focus-visible:no-underline"
>
<span>{{ nextFeature.properties.title }}</span>
Expand Down
80 changes: 51 additions & 29 deletions components/data-map-view.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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({

Choose a reason for hiding this comment

The 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) {
Expand Down Expand Up @@ -83,6 +95,13 @@ function togglePolygons() {
show.value = !show.value;
}

const selection = computed(() => {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should validate this

return route.query.selection;
});

const mode = computed(() => {

Choose a reason for hiding this comment

The 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.
Expand Down Expand Up @@ -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) {

Choose a reason for hiding this comment

The 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>
Expand Down Expand Up @@ -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)"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be a regular link. instead of onChangeEntitySelection we should add a helper which returns the correct href

>
<Component :is="getEntityIcon(entity.systemClass)" class="size-3.5 shrink-0" />
{{ entity.properties.title }}
Expand Down
22 changes: 5 additions & 17 deletions components/data-network-view.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const router = useRouter();
const route = useRoute();

const detailEntityId = computed(() => {
return route.params.id as string;
return route.query.selection as string;
});

const searchFiltersSchema = z.object({
Expand All @@ -22,7 +22,7 @@ const searchFilters = computed(() => {
});

function onChangeSearchFilters(values: SearchFormData) {
const query = { ...searchFilters.value, ...values };
const query = { mode: route.query.mode, ...searchFilters.value, ...values };

if (values.search === "") {
// @ts-expect-error Fix me later please
Expand All @@ -33,27 +33,15 @@ function onChangeSearchFilters(values: SearchFormData) {
}

function onChangeCategory(values: CategoryFormData) {
void router.push({ query: { ...searchFilters.value, ...values } });
void router.push({ query: { mode: route.query.mode, ...searchFilters.value, ...values } });
}

const { data, isPending, isPlaceholderData } = useGetNetworkData(
// @ts-expect-error Includes custom, per-instance system classes.
computed(() => {
return {
exclude_system_classes: [
// TO-DO: Currently there is an issue: filtering by case study and system_class type will return no results
"type",
"object_location",
"reference_system",
"file",
"source_translation",
"source",
"bibliography",
"external_reference",
"administrative_unit",
"edition",
"type_tools",
],
// TO-DO: Currently there is an issue: filtering by case study and system_class type will return no results
exclude_system_classes: project.network.exclude,
};
}),
);
Expand Down
6 changes: 4 additions & 2 deletions components/data-view.vue
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ const sortingState = computed(() => {
type SearchFilters = v.InferOutput<typeof searchFiltersSchema>;

function setSearchFilters(query: Partial<SearchFilters>) {
void router.push({ query });
void router.push({
query: { mode: route.query.mode, selection: route.query.selection, ...query },
});
document.body.scrollTo(0, 0);
}

Expand Down Expand Up @@ -106,7 +108,7 @@ const entities = computed(() => {
</script>

<template>
<div class="relative grid grid-rows-[auto_1fr] gap-4">
<div class="container relative grid grid-rows-[auto_1fr] gap-4 p-8">
<SearchForm
:filter="searchFilters.category"
:search="searchFilters.search"
Expand Down
28 changes: 26 additions & 2 deletions components/entity-details.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
const { getUnprefixedId } = useIdPrefix();

const t = useTranslations();
const route = useRoute();

const props = defineProps<{
relations: EntityFeature["relations"];
Expand Down Expand Up @@ -33,6 +34,17 @@
},
);
});

function getPath() {
if (route.path.includes("visualization")) {
return "visualization";
}
return "";
}

const currentMode = computed(() => {
return route.query.mode;
});
</script>

<template>
Expand All @@ -44,7 +56,7 @@
<dl
class="grid gap-x-8 gap-y-4 sm:grid-cols-[repeat(auto-fill,minmax(20rem,1fr))] sm:justify-start"
>
<div v-for="[relationType, relations] of relationsByType" :key="relationType">

Check warning on line 59 in components/entity-details.vue

View workflow job for this annotation

GitHub Actions / Validate (20.x, ubuntu-latest)

Variable 'relations' is already declared in the upper scope
<dt class="text-xs font-medium uppercase tracking-wider text-muted-foreground">
{{ t(`SystemClassNames.${relationType}`) }}
</dt>
Expand All @@ -54,7 +66,13 @@
<NavLink
v-if="relation.relationTo"
class="underline decoration-dotted hover:no-underline"
:href="{ path: `/entities/${getUnprefixedId(relation.relationTo)}` }"
:href="{
path: `/${getPath()}`,
query: {
mode: currentMode,
selection: getUnprefixedId(relation.relationTo),
},
}"
>
{{ relation.label }}
</NavLink>
Expand All @@ -68,7 +86,13 @@
<NavLink
v-if="relation.relationTo"
class="underline decoration-dotted hover:no-underline"
:href="{ path: `/entities/${getUnprefixedId(relation.relationTo)}` }"
:href="{
path: `/${getPath()}`,
query: {
mode: currentMode,
selection: getUnprefixedId(relation.relationTo),
},
}"
>
{{ relation.label }}
</NavLink>
Expand Down
17 changes: 16 additions & 1 deletion components/entity-preview-link.vue
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<script setup lang="ts">
const route = useRoute();
const props = defineProps<{ id: number; entity?: EntityFeature; label?: string }>();

const previewEntity = computed(() => {
Expand All @@ -21,14 +22,28 @@ const { data, isPending, isPlaceholderData } = props.entity
const isLoading = computed(() => {
return isPending || isPlaceholderData;
});

function getPath() {
if (route.path.includes("visualization")) {
return "visualization";
}
return "";
}

const currentMode = computed(() => {
return route.query.mode;
});
</script>

<template v-if="entity || id">
<HoverCard :close-delay="150" :open-delay="150">
<HoverCardTrigger as-child>
<NavLink
class="underline decoration-dotted transition hover:no-underline focus-visible:no-underline"
:href="{ path: `/entities/${id}` }"
:href="{
path: `/${getPath()}`,
query: { mode: currentMode, selection: id },
}"
>
<template v-if="label">
{{ label }}
Expand Down
Loading
Loading