generated from acdh-oeaw/template-app-nuxt
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
display on all the data pages in the explore view (places, themes, research-perspectives and glossary) corresponding lists of that specific data.
- Loading branch information
1 parent
6ee4772
commit 7b1f0e1
Showing
17 changed files
with
750 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
<script lang="ts" setup> | ||
import { EyeIcon } from "lucide-vue-next"; | ||
import { Drawer, DrawerContent, DrawerTrigger } from "@/components/ui/drawer"; | ||
const props = defineProps<{ | ||
source: { | ||
name?: string | undefined; | ||
alternative_name?: string | undefined; | ||
description?: string | undefined; | ||
}; | ||
sourceType: string; | ||
isMobile: boolean; | ||
}>(); | ||
</script> | ||
|
||
<template> | ||
<div v-if="props.isMobile"> | ||
<Drawer> | ||
<DrawerTrigger class="w-full"> | ||
<EyeIcon class="text-frisch-orange" :size="16" /> | ||
</DrawerTrigger> | ||
<DrawerContent> | ||
<div class="flex items-center gap-1 px-4 pt-2 text-sm"> | ||
{{ props.sourceType }} | ||
</div> | ||
<h1 class="px-4 pb-2 text-lg font-semibold">{{ props.source.name }}</h1> | ||
<h2 | ||
v-if="props.source.alternative_name" | ||
class="px-4 pb-2 font-normal text-muted-foreground" | ||
> | ||
{{ props.source.name }} | ||
</h2> | ||
<div class="px-4 py-2"> | ||
<div class="py-2 text-base font-semibold text-black">Beschreibung</div> | ||
<div class="text-black"> | ||
{{ props.source.description }} | ||
</div> | ||
</div> | ||
</DrawerContent> | ||
</Drawer> | ||
</div> | ||
<div v-else> | ||
<Sheet> | ||
<SheetTrigger as-child> | ||
<EyeIcon class="text-frisch-orange" :size="16" /> | ||
</SheetTrigger> | ||
<SheetContent> | ||
<div class="flex items-center gap-1 text-sm"> | ||
{{ props.sourceType }} | ||
</div> | ||
<SheetTitle class="pb-2"> | ||
{{ props.source.name }} | ||
<h2 | ||
v-if="props.source.alternative_name" | ||
class="px-4 pb-2 font-normal text-muted-foreground" | ||
> | ||
{{ props.source.name }} | ||
</h2></SheetTitle | ||
> | ||
<SheetDescription> | ||
<div class="py-2 text-base font-semibold text-black">Beschreibung</div> | ||
<div class="text-black"> | ||
{{ props.source.description }} | ||
</div> | ||
</SheetDescription> | ||
</SheetContent> | ||
</Sheet> | ||
</div> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { useQuery } from "@tanstack/vue-query"; | ||
|
||
import type { GlossaryEntries } from "@/types/api"; | ||
|
||
export function useGetGlossary() { | ||
const { $api } = useNuxtApp(); | ||
|
||
return useQuery({ | ||
queryKey: ["glossaryList"] as const, | ||
async queryFn() { | ||
let allResults: GlossaryEntries = []; | ||
let nextUrl: boolean; | ||
let offset = 0; | ||
const limit = 500; | ||
|
||
do { | ||
const response = await $api["apis_api_apis_ontology.glossar_list"]({ | ||
queries: { limit, offset }, | ||
}); | ||
|
||
allResults = [...allResults, ...response.results]; | ||
|
||
if (response.next) { | ||
const url = new URL(response.next); | ||
offset = Number(url.searchParams.get("offset")) || offset + limit; | ||
nextUrl = true; | ||
} else { | ||
nextUrl = false; | ||
} | ||
} while (nextUrl); | ||
|
||
return { count: allResults.length, results: allResults }; | ||
}, | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { useQuery } from "@tanstack/vue-query"; | ||
|
||
import type { Places } from "@/types/api"; | ||
|
||
export function useGetPlaces() { | ||
const { $api } = useNuxtApp(); | ||
|
||
return useQuery({ | ||
queryKey: ["placelist"] as const, | ||
async queryFn() { | ||
let allResults: Places = []; | ||
let nextUrl: boolean; | ||
let offset = 0; | ||
const limit = 500; | ||
|
||
do { | ||
const response = await $api["apis_api_apis_ontology.place_list"]({ | ||
queries: { limit, offset }, | ||
}); | ||
|
||
allResults = [...allResults, ...response.results]; | ||
|
||
if (response.next) { | ||
const url = new URL(response.next); | ||
offset = Number(url.searchParams.get("offset")) || offset + limit; | ||
nextUrl = true; | ||
} else { | ||
nextUrl = false; | ||
} | ||
} while (nextUrl); | ||
|
||
return { count: allResults.length, results: allResults }; | ||
}, | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { useQuery } from "@tanstack/vue-query"; | ||
|
||
import type { ResearchPerspectives } from "@/types/api"; | ||
|
||
export function useGetPerspectives() { | ||
const { $api } = useNuxtApp(); | ||
|
||
return useQuery({ | ||
queryKey: ["perspectivesList"] as const, | ||
async queryFn() { | ||
let allResults: ResearchPerspectives = []; | ||
let nextUrl: boolean; | ||
let offset = 0; | ||
const limit = 500; | ||
|
||
do { | ||
const response = await $api["apis_api_apis_ontology.researchperspective_list"]({ | ||
queries: { limit, offset }, | ||
}); | ||
|
||
allResults = [...allResults, ...response.results]; | ||
|
||
if (response.next) { | ||
const url = new URL(response.next); | ||
offset = Number(url.searchParams.get("offset")) || offset + limit; | ||
nextUrl = true; | ||
} else { | ||
nextUrl = false; | ||
} | ||
} while (nextUrl); | ||
|
||
return { count: allResults.length, results: allResults }; | ||
}, | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { useQuery } from "@tanstack/vue-query"; | ||
|
||
import type { Topics } from "@/types/api"; | ||
|
||
export function useGetTopics() { | ||
const { $api } = useNuxtApp(); | ||
|
||
return useQuery({ | ||
queryKey: ["topiclist"] as const, | ||
async queryFn() { | ||
let allResults: Topics = []; | ||
let nextUrl: boolean; | ||
let offset = 0; | ||
const limit = 500; | ||
|
||
do { | ||
const response = await $api["apis_api_apis_ontology.topic_list"]({ | ||
queries: { limit, offset }, | ||
}); | ||
|
||
allResults = [...allResults, ...response.results]; | ||
|
||
if (response.next) { | ||
const url = new URL(response.next); | ||
offset = Number(url.searchParams.get("offset")) || offset + limit; | ||
nextUrl = true; | ||
} else { | ||
nextUrl = false; | ||
} | ||
} while (nextUrl); | ||
|
||
return { count: allResults.length, results: allResults }; | ||
}, | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.