Skip to content

Commit

Permalink
Implement matching of annotation id to label name visually in search box
Browse files Browse the repository at this point in the history
  • Loading branch information
PedroDinis committed Sep 2, 2024
1 parent 5806356 commit cfea481
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/components/DocumentAnnotations/AnnotationFilters.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
icon="search"
:placeholder="$t('search')"
>
<template #tag="props">
<span>{{ labelNameForAnnotationId(props.tag) || props.tag }}</span>
</template>
</b-taginput>
</b-field>
</div>
Expand All @@ -27,7 +30,7 @@
</div>
</template>
<script>
import { mapState } from "vuex";
import { mapGetters, mapState } from "vuex";
export default {
name: "AnnotationFilters",
data() {
Expand All @@ -41,6 +44,7 @@ export default {
"annotationFilters",
"annotationSearch",
]),
...mapGetters("document", ["annotationById", "labelOfAnnotation"]),
},
watch: {
Expand All @@ -56,6 +60,18 @@ export default {
mounted() {
this.search = this.annotationSearch;
},
methods: {
labelNameForAnnotationId(annotationId) {
const annotation = this.annotationById(Number(annotationId));
if (annotation) {
const label = this.labelOfAnnotation(annotation);
if (label) {
return label.name;
}
}
return false;
},
},
};
</script>

Expand Down

0 comments on commit cfea481

Please sign in to comment.