diff --git a/components/profile-window-content.vue b/components/profile-window-content.vue new file mode 100644 index 0000000..350e0f3 --- /dev/null +++ b/components/profile-window-content.vue @@ -0,0 +1,36 @@ + + + + + diff --git a/components/text-window-content.vue b/components/text-window-content.vue index d90519c..741a03d 100644 --- a/components/text-window-content.vue +++ b/components/text-window-content.vue @@ -7,7 +7,7 @@ const props = defineProps(); const { params } = toRefs(props); const { data, isPending, isPlaceholderData } = useTextById(params); -const onClick = useAnchorClickHandler(); +const openNewWindowFromAnchor = useAnchorClickHandler(); const isLoading = computed(() => { return isPending.value || isPlaceholderData.value; @@ -20,7 +20,7 @@ const isLoading = computed(() => { :class="{ 'opacity-50 grayscale': isLoading }" > -
+
diff --git a/components/window-content.vue b/components/window-content.vue index 3ea38a9..abb48b9 100644 --- a/components/window-content.vue +++ b/components/window-content.vue @@ -9,5 +9,6 @@ const props = defineProps(); diff --git a/composables/use-anchor-click-handler.ts b/composables/use-anchor-click-handler.ts index 92e8a64..d68b00f 100644 --- a/composables/use-anchor-click-handler.ts +++ b/composables/use-anchor-click-handler.ts @@ -9,7 +9,7 @@ export function useAnchorClickHandler() { /** * Intercept anchor clicks to open window instead of navigating. */ - function onClick(event: MouseEvent) { + function openNewWindowFromAnchor(event: MouseEvent) { const element = event.target; if (element instanceof HTMLAnchorElement) { @@ -31,5 +31,5 @@ export function useAnchorClickHandler() { } } - return onClick; + return openNewWindowFromAnchor; } diff --git a/composables/use-profile-by-id.ts b/composables/use-profile-by-id.ts new file mode 100644 index 0000000..67c6239 --- /dev/null +++ b/composables/use-profile-by-id.ts @@ -0,0 +1,16 @@ +import { useQuery } from "@tanstack/vue-query"; + +export function useProfileById(params: MaybeRef<{ id: string }>, options?: { enabled?: boolean }) { + const api = useApiClient(); + + return useQuery({ + enabled: options?.enabled, + queryKey: ["get-profile-by-id", params] as const, + async queryFn({ queryKey: [, params] }) { + const response = await api.vicav.getProfile(params, { + headers: { accept: "application/xml" }, + }); + return response.text(); + }, + }); +} diff --git a/stores/use-windows-store.ts b/stores/use-windows-store.ts index 0edaf8f..4c028f8 100644 --- a/stores/use-windows-store.ts +++ b/stores/use-windows-store.ts @@ -64,6 +64,13 @@ export interface TextWindowItem extends WindowItemBase { }; } +export interface ProfileWindowItem extends WindowItemBase { + kind: "profile"; + params: { + id: string; + }; +} + export type WindowItem = | BibliographyQueryWindowItem | CorpusQueryWindowItem @@ -73,6 +80,7 @@ export type WindowItem = | DictionaryEntryWindowItem | DictionaryQueryWindowItem | GeoMapWindowItem + | ProfileWindowItem | SampleTextWindowItem | TextWindowItem; diff --git a/utils/is-window-type.ts b/utils/is-window-type.ts index 1be6e99..ce673bb 100644 --- a/utils/is-window-type.ts +++ b/utils/is-window-type.ts @@ -12,6 +12,7 @@ export const windowTypeMap: Record = { SampleText: "sample-text", Text: "text", WMap: "geo-map", + Profile: "profile", }; export function isWindowType(value: string | undefined): value is WindowType {