Skip to content

Commit

Permalink
Appease typescript linter
Browse files Browse the repository at this point in the history
  • Loading branch information
chiatt committed Nov 26, 2024
1 parent 582f202 commit ca1fb42
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ const {
drawnFeaturesBuffer,
} = props;
let resultsSelected = inject("resultsSelected");
let resultsSelected = inject("resultsSelected") as Ref<string[]>;
const emits = defineEmits([
"mapInitialized",
Expand Down Expand Up @@ -129,7 +129,9 @@ watch(
watch(
() => resultsSelected,
(selected) => {
updateFeatureSelection(selected);
if (selected) {
updateFeatureSelection(selected as Ref<string[]>);
}
}, {deep: true}
);
Expand Down Expand Up @@ -204,7 +206,7 @@ function updateFeatureSelection(selected: Ref<string[]>) {
const features = map.value!.queryRenderedFeatures({layers:layers});
features.forEach(feature => {
const featureSelected = selected.value.includes(feature.properties?.resourceinstanceid);
map.value.setFeatureState(
map.value!.setFeatureState(
{
source: "referencecollections",
sourceLayer: "referencecollections",
Expand Down
18 changes: 12 additions & 6 deletions afrc/src/afrc/Search/components/SearchResultItem.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<script setup lang="ts">
import Button from "primevue/button";
import { inject } from "vue";
import type { Ref } from "vue";
let resultsSelected = inject("resultsSelected");
const resultsSelected = inject("resultsSelected") as Ref<string[]>;
const props = defineProps({
searchResult: {
Expand All @@ -11,20 +12,25 @@ const props = defineProps({
},
});
function selectResult(resourceid) {
function selectResult(resourceid: string) {
resultsSelected.value = [resourceid];
}
function clearResult(e) {
function clearResult() {
resultsSelected.value = [];
}
</script>

<template>
<section class="result" :class="{ hovered: resultsSelected.includes(searchResult._source.resourceinstanceid)}"
@mouseenter="selectResult(searchResult._source.resourceinstanceid)"
@mouseleave="clearResult">
<section
class="result"
:class="{
hovered: resultsSelected.includes(searchResult._source.resourceinstanceid)
}"
@mouseenter="selectResult(searchResult._source.resourceinstanceid)"
@mouseleave="clearResult"
>
<div class="image-placeholder">
<img src="https://picsum.photos/160" />
</div>
Expand Down

0 comments on commit ca1fb42

Please sign in to comment.