diff --git a/arches_lingo/src/arches_lingo/components/generic/LabelEditor.vue b/arches_lingo/src/arches_lingo/components/generic/LabelEditor.vue index 65d8ac70..ba6f6061 100644 --- a/arches_lingo/src/arches_lingo/components/generic/LabelEditor.vue +++ b/arches_lingo/src/arches_lingo/components/generic/LabelEditor.vue @@ -39,7 +39,15 @@ const props = withDefaults( value: () => ({}) as AppellativeStatus, }, ); -const appellative_status = ref(props.value); +const value = ref(props.value); + +const languageOptions = ref([]); +const typeOptions = ref([]); +const statusOptions = ref([]); +const metatypeOptions = ref([]); +const eventTypeOptions = ref([]); +const groupAndPersonOptions = ref(); +const textualWorkOptions = ref(); function onUpdate(newValue: string) { console.log(newValue); @@ -75,14 +83,6 @@ async function getResourceInstanceOptions( return results; } -const languageOptions = ref([]); -const typeOptions = ref([]); -const statusOptions = ref([]); -const metatypeOptions = ref([]); -const eventTypeOptions = ref([]); -const groupAndPersonOptions = ref(); -const textualWorkOptions = ref(); - onMounted(async () => { const [languageOpts, typeOpts, statusOpts, metatypeOpts, eventTypeOpts] = await Promise.all([ @@ -115,16 +115,14 @@ onMounted(async () => { { { { { { { +import { EDIT, VIEW } from "@/arches_lingo/constants.ts"; +import ReferenceDatatypeViewer from "@/arches_lingo/components/generic/reference-datatype/ReferenceDatatypeViewer.vue"; +import ReferenceDatatypeEditor from "@/arches_lingo/components/generic/reference-datatype/ReferenceDatatypeEditor.vue"; + import type { ControlledListItem, DataComponentMode, } from "@/arches_lingo/types"; -import ReferenceDatatypeViewer from "@/arches_lingo/components/generic/reference-datatype/ReferenceDatatypeViewer.vue"; -import ReferenceDatatypeEditor from "@/arches_lingo/components/generic/reference-datatype/ReferenceDatatypeEditor.vue"; -import { EDIT, VIEW } from "@/arches_lingo/constants.ts"; defineProps<{ mode?: DataComponentMode; diff --git a/arches_lingo/src/arches_lingo/components/generic/reference-datatype/ReferenceDatatypeEditor.vue b/arches_lingo/src/arches_lingo/components/generic/reference-datatype/ReferenceDatatypeEditor.vue index c2e9738f..dce2a87a 100644 --- a/arches_lingo/src/arches_lingo/components/generic/reference-datatype/ReferenceDatatypeEditor.vue +++ b/arches_lingo/src/arches_lingo/components/generic/reference-datatype/ReferenceDatatypeEditor.vue @@ -10,6 +10,7 @@ import type { ControlledListItem } from "@/arches_lingo/types"; import type { Language } from "@/arches_vue_utils/types.ts"; const systemLanguage = inject(systemLanguageKey) as Language; +const emit = defineEmits(["update"]); const props = withDefaults( defineProps<{ value?: ControlledListItem[]; @@ -22,12 +23,7 @@ const props = withDefaults( }, ); -const emit = defineEmits(["update"]); -const uriRef = ref( - props?.value && !props.multiValue - ? props?.value[0].uri - : props?.value?.map((item) => item.uri) || [], -); +const uriRef = ref(extractURI(props.value)); const val = computed({ get() { return uriRef.value; @@ -46,24 +42,35 @@ const val = computed({ }, }); -const optionLabels = (item: ControlledListItem): string => { - const preferredLabel = - item.labels.find( - (label) => - label.language_id === systemLanguage?.code && - label.valuetype_id === PREF_LABEL, - ) || item.labels.find((label) => label.valuetype_id === PREF_LABEL); - return preferredLabel?.value ?? ""; -}; +function extractURI(item: ControlledListItem[]): string | string[] { + if (item && !props.multiValue) { + return item[0].uri; + } else if (item && props.multiValue) { + return item.map((item) => item.uri); + } else { + return []; + } +} + +function getOptionLabels(item: ControlledListItem): string { + const prefLabels = item.labels.filter( + (label) => label.valuetype_id === PREF_LABEL, + ); + const optionLabel = + prefLabels.find( + (label) => label.language_id === systemLanguage?.code, + ) || prefLabels[0]; + return optionLabel?.value ?? ""; +}