diff --git a/components/range-slider.vue b/components/range-slider.vue index 72c299c..4f16f04 100644 --- a/components/range-slider.vue +++ b/components/range-slider.vue @@ -1,38 +1,33 @@ diff --git a/lib/facets.ts b/lib/facets.ts index d573b7e..52fec0c 100644 --- a/lib/facets.ts +++ b/lib/facets.ts @@ -40,7 +40,7 @@ export const typesenseQueryToFacetObject = ( } else { const [key, value] = facetString.split(":"); if (key !== undefined && value !== undefined) { - retObject[key] = value.replace(/\[(\d*)\.\.(\d*),\d*\]/, "$1;$2").split(";"); // converts format [yyyy..yyyy,y] to classic [yyyy,yyyy] + retObject[key] = value.replace(/\[(\d+)\.\.(\d+),?\d*\]/, "$1;$2").split(";"); // converts formats [yyyy..yyyy,y] and [yyyy..yyyy] to classic [yyyy,yyyy] } } }); diff --git a/locales/de.json b/locales/de.json index 321e192..e5efeb8 100644 --- a/locales/de.json +++ b/locales/de.json @@ -255,7 +255,8 @@ "additional": "Weitere Informationen", "courtrelated": "Bezüge zum Wiener Hof", "relations": "Bezüge", - "coords": "Koordinaten" + "coords": "Koordinaten", + "related_places": "Bezüge zu Orten" }, "ui": { "showing-results": "Zeige {first} - {last} von {all} Ergebnissen", diff --git a/locales/en.json b/locales/en.json index 4ba85c0..d63b284 100644 --- a/locales/en.json +++ b/locales/en.json @@ -254,7 +254,8 @@ "additional": "Additional Information", "courtrelated": "Court Relations", "relations": "Relations", - "coords": "Coordinates" + "coords": "Coordinates", + "related_places": "Place Relations" }, "ui": { "showing-results": "Showing {first} - {last} out of {all}", diff --git a/pages/detail/persons/[id].vue b/pages/detail/persons/[id].vue index 0387e79..9e203e6 100644 --- a/pages/detail/persons/[id].vue +++ b/pages/detail/persons/[id].vue @@ -348,6 +348,14 @@ definePageMeta({ grid-class="grid-cols-3" :collection-name="collection" /> +

{{ t("detail-page.additional") }}

import { isEmpty } from "lodash-es"; -import { ArrowLeftRight, CalendarRange, MapPin, School2, User, Users } from "lucide-vue-next"; +import { + ArrowLeftRight, + CalendarRange, + CalendarSearch, + MapPin, + School2, + User, + Users, +} from "lucide-vue-next"; import GenericDisclosure from "@/components/generic-disclosure.vue"; import RangeSlider from "@/components/range-slider.vue"; @@ -9,6 +17,9 @@ import type { NavLink } from "@/types/misc.d.ts"; const t = useTranslations(); const localePath = useLocalePath(); + +const route = useRoute(); + const links = computed(() => { return { people: { @@ -44,8 +55,16 @@ const links = computed(() => { } satisfies Record; }); +const updateFacets = async () => { + const { query } = route; + + if (query.facets?.start_date_int) { + await addToFacets(typesenseQueryToFacetObject(String(query.facets)).start_date_int); + } else await addToFacets([1600, 1900]); +}; + const addToFacets = async (range: [number, number]) => { - const { query } = useRoute(); + const { query } = route; const router = useRouter(); const facetObject = typesenseQueryToFacetObject(String(query.facets)); @@ -62,7 +81,7 @@ const addToFacets = async (range: [number, number]) => { await router.push({ query: { ...query, - facets: facetObjectToTypesenseQuery(facetObject), + facets: facetObjectToTypesenseQuery(facetObject, false, includeDateless.value), }, }); } @@ -70,24 +89,41 @@ const addToFacets = async (range: [number, number]) => { await router.push({ query: { ...query, - facets: facetObjectToTypesenseQuery({ - ...facetObject, - start_date_int: range, - end_date_int: range, - }), + facets: facetObjectToTypesenseQuery( + { + ...facetObject, + start_date_int: range, + end_date_int: range, + }, + false, + includeDateless.value, + ), }, }); } }; const queryRange = computed(() => { - const { query } = useRoute(); + const { query } = route; const facetObject = typesenseQueryToFacetObject(String(query.facets)); - return facetObject.start_date_int as [number, number] | undefined; + return (facetObject.start_date_int ?? [1600, 1900]) as [number, number]; }); +const includeDateless = ref(true); + +if (route.query.facets && /\[\d+..\d+\]/.test(String(route.query.facets))) { + includeDateless.value = false; +} + +const slider: Ref<[number, number]> = ref(queryRange.value.map(Number) as [number, number]); + +watch( + () => route.name, + () => (slider.value = [1600, 1900]), +); + definePageMeta({ title: "pages.search.title", }); @@ -118,14 +154,43 @@ definePageMeta({
-
- -
- note: also includes entities without date information +
+ +
+
+ + +
+
+ + + Apply time filters + +
diff --git a/types/schema.d.ts b/types/schema.d.ts index c853757..bbf87cb 100644 --- a/types/schema.d.ts +++ b/types/schema.d.ts @@ -138,6 +138,7 @@ export interface PersonDetail { marriages_and_family_relations: Array; relations_to_church_and_orders: Array; non_court_functions: Array; + related_places: Array; } export interface GenericRelation {