diff --git a/components/feature-window-content.vue b/components/feature-window-content.vue new file mode 100644 index 0000000..0e2904d --- /dev/null +++ b/components/feature-window-content.vue @@ -0,0 +1,77 @@ + + + + + diff --git a/components/profile-window-content.vue b/components/profile-window-content.vue new file mode 100644 index 0000000..5b7925f --- /dev/null +++ b/components/profile-window-content.vue @@ -0,0 +1,105 @@ + + + + + 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 3cc2763..bd1826f 100644 --- a/components/window-content.vue +++ b/components/window-content.vue @@ -9,5 +9,7 @@ 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-feature-by-id.ts b/composables/use-feature-by-id.ts new file mode 100644 index 0000000..7ed9fb5 --- /dev/null +++ b/composables/use-feature-by-id.ts @@ -0,0 +1,16 @@ +import { useQuery } from "@tanstack/vue-query"; + +export function useFeatureById(params: MaybeRef<{ id: string }>, options?: { enabled?: boolean }) { + const api = useApiClient(); + + return useQuery({ + enabled: options?.enabled, + queryKey: ["get-feature-by-id", params] as const, + async queryFn({ queryKey: [, params] }) { + const response = await api.vicav.getLingFeature(params, { + headers: { accept: "application/xml" }, + }); + return response.text(); + }, + }); +} 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 af946a0..e81baa0 100644 --- a/stores/use-windows-store.ts +++ b/stores/use-windows-store.ts @@ -66,6 +66,20 @@ export interface TextWindowItem extends WindowItemBase { }; } +export interface ProfileWindowItem extends WindowItemBase { + kind: "profile"; + params: { + id: string; + }; +} + +export interface FeatureWindowItem extends WindowItemBase { + kind: "feature"; + params: { + id: string; + }; +} + export type WindowItem = | BibliographyQueryWindowItem | CorpusQueryWindowItem @@ -74,7 +88,9 @@ export type WindowItem = | DataListWindowItem | DictionaryEntryWindowItem | DictionaryQueryWindowItem + | FeatureWindowItem | GeoMapWindowItem + | ProfileWindowItem | SampleTextWindowItem | TextWindowItem; diff --git a/utils/is-window-type.ts b/utils/is-window-type.ts index 1be6e99..b426793 100644 --- a/utils/is-window-type.ts +++ b/utils/is-window-type.ts @@ -12,6 +12,8 @@ export const windowTypeMap: Record = { SampleText: "sample-text", Text: "text", WMap: "geo-map", + Profile: "profile", + Feature: "feature", }; export function isWindowType(value: string | undefined): value is WindowType {