Skip to content

Commit

Permalink
Update uri ref for select component reactivity #147
Browse files Browse the repository at this point in the history
  • Loading branch information
johnatawnclementawn committed Dec 31, 2024
1 parent b194a4c commit e093cd3
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import ConfirmDialog from "primevue/confirmdialog";
import { useConfirm } from "primevue/useconfirm";
import ReferenceDatatypeViewer from "@/arches_lingo/components/generic/reference-datatype/ReferenceDatatypeViewer.vue";
import ResourceInstanceRelationshipsViewer from "@/arches_lingo/components/generic/resource-instance-relationships/ResourceInstanceRelationshipsViewer.vue";
import ResourceInstanceRelationships from "@/arches_lingo/components/generic/resource-instance-relationships/ResourceInstanceRelationshipsViewer.vue";
import type { AppellativeStatus } from "@/arches_lingo/types";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ defineProps<{
options?: ControlledListItem[];
}>();
const emits = defineEmits(["update"]);
const onUpdate = (val: ControlledListItem) => {
const onUpdate = (val: ControlledListItem[]) => {
emits("update", val);
};
</script>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script setup lang="ts">
import { computed, inject, toRef } from "vue";
import { computed, inject, ref } from "vue";
import Select from "primevue/select";
import { systemLanguageKey } from "@/arches_lingo/constants.ts";
Expand All @@ -21,16 +21,15 @@ const props = withDefaults(
);
const emit = defineEmits(["update"]);
const valRef = toRef(props?.value?.[0]?.uri); // use uri as value
const uriRef = ref(props?.value?.[0]?.uri); // unwrap array n=1 && use uri as value
const val = computed({
get() {
return valRef.value; // unwrap array n=1
return uriRef.value;
},
set(value) {
// const item = props.options?.find((item) => item.uri === value);
console.log(value);
// emit("update", [item]); // rewrap array n=1
emit("update", value);
set(newVal) {
uriRef.value = newVal; // update uri
const item = props.options?.find((item) => item.uri === newVal);
emit("update", item ? [item] : []); // emit the updated value as a list item
},
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { onMounted, ref } from "vue";
import { useRoute } from "vue-router";
import { useToast } from "primevue/usetoast";
import { VIEW, EDIT, OPEN_EDITOR } from "@/arches_lingo/constants.ts";
import { VIEW, EDIT, OPEN_EDITOR, ERROR } from "@/arches_lingo/constants.ts";
import { deleteSchemeLabelTile, fetchSchemeLabel } from "@/arches_lingo/api.ts";
import LabelViewer from "@/arches_lingo/components/generic/LabelViewer.vue";
import LabelEditor from "@/arches_lingo/components/generic/LabelEditor.vue";
Expand Down

0 comments on commit e093cd3

Please sign in to comment.