Skip to content

Commit

Permalink
refactor(feature-info): rename content to featureInfoPanelContent
Browse files Browse the repository at this point in the history
  • Loading branch information
tkohr committed Nov 22, 2024
1 parent c0b5a47 commit 89607ea
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 13 deletions.
5 changes: 3 additions & 2 deletions src/components/info/feature-info.composable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ const INFO_SERVICE_URL = import.meta.env.VITE_GET_INFO_SERVICE_URL

export default function useFeatureInfo() {
const map = useMap().getOlMap()
const { setContent, setLoading, setInfoPanelHidden } = useFeatureInfoStore()
const { setFeatureInfoPanelContent, setLoading, setInfoPanelHidden } =
useFeatureInfoStore()
const { fid } = storeToRefs(useFeatureInfoStore())
const { toggleInfoOpen } = useAppStore()
const { findById } = useThemes()
Expand Down Expand Up @@ -274,7 +275,7 @@ export default function useFeatureInfo() {
}
featureInfoService.highlightFeatures(lastHighlightedFeatures.value, fit)

setContent(content)
setFeatureInfoPanelContent(content)
}

function reset(openPanel = false) {
Expand Down
10 changes: 6 additions & 4 deletions src/components/info/info-panel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ import FeatureInfo from '@/components/info/feature-info.vue'
const { t } = useTranslation()
const appStore = useAppStore()
const { content, isLoading } = storeToRefs(useFeatureInfoStore())
const { featureInfoPanelContent, isLoading } = storeToRefs(
useFeatureInfoStore()
)
</script>

<template>
Expand All @@ -23,7 +25,7 @@ const { content, isLoading } = storeToRefs(useFeatureInfoStore())
</template>

<template v-slot:content>
<div v-if="!content" class="text-white">
<div v-if="!featureInfoPanelContent" class="text-white">
<ul class="list-disc pl-10">
<li>
{{ t(`A right click (tap and hold on mobile)...`, { ns: 'app' }) }}
Expand All @@ -33,8 +35,8 @@ const { content, isLoading } = storeToRefs(useFeatureInfoStore())
</li>
</ul>
</div>
<div v-if="content && !isLoading">
<feature-info :content="content" />
<div v-if="featureInfoPanelContent && !isLoading">
<feature-info :content="featureInfoPanelContent" />
</div>
</template>
</side-panel-layout>
Expand Down
15 changes: 8 additions & 7 deletions src/stores/feature-info.store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,23 @@ import { shallowRef, ShallowRef } from 'vue'
export const useFeatureInfoStore = defineStore(
'featureInfo',
() => {
const content: ShallowRef<FeatureInfoJSON[] | undefined> = shallowRef()
const featureInfoPanelContent: ShallowRef<FeatureInfoJSON[] | undefined> =
shallowRef()
const fid: ShallowRef<string | undefined> = shallowRef()
const isLoading: ShallowRef<boolean> = shallowRef(false)
const infoPanelHidden: ShallowRef<boolean> = shallowRef(false)

function setContent(value: FeatureInfoJSON[]) {
function setFeatureInfoPanelContent(value: FeatureInfoJSON[]) {
if (!value || value.length === 0) {
content.value = undefined
featureInfoPanelContent.value = undefined
} else {
content.value = [...value]
featureInfoPanelContent.value = [...value]
isLoading.value = false
}
}

function clearContent() {
content.value = undefined
featureInfoPanelContent.value = undefined
isLoading.value = false
}

Expand All @@ -37,11 +38,11 @@ export const useFeatureInfoStore = defineStore(
}

return {
content,
featureInfoPanelContent,
fid,
isLoading,
infoPanelHidden,
setContent,
setFeatureInfoPanelContent,
clearContent,
setFid,
setLoading,
Expand Down

0 comments on commit 89607ea

Please sign in to comment.