From c9b723db4d0b48425ba199a92ee496cc63a8576a Mon Sep 17 00:00:00 2001 From: Luc Claustres Date: Fri, 21 Jun 2024 11:49:29 +0200 Subject: [PATCH] fix: Sublegends of a remote planet project are not retrieved (closes #886) --- map/client/components/legend/KLegend.vue | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/map/client/components/legend/KLegend.vue b/map/client/components/legend/KLegend.vue index 1697125bf..4d38e9acc 100644 --- a/map/client/components/legend/KLegend.vue +++ b/map/client/components/legend/KLegend.vue @@ -51,7 +51,7 @@ import _ from 'lodash' import logger from 'loglevel' import sift from 'sift' import { ref, computed, watch } from 'vue' -import { i18n, Store } from '../../../../core/client' +import { api, i18n, Store } from '../../../../core/client' import { useCurrentActivity, useCatalog } from '../../composables' import KLayerLegend from './KLayerLegend.vue' @@ -86,6 +86,13 @@ const props = defineProps({ } }) +// Get current project for activity if any +const { getActivityProject } = useCurrentActivity({ selection: false, probe: false }) +const project = getActivityProject() +// We expect the project object to expose the underlying API +const planetApi = project && typeof project.getPlanetApi === 'function' ? project.getPlanetApi() : api +// Use target catalog according to project +const { getSublegends: getProjectSublegends } = useCatalog({ project, planetApi }) // Use global catalog const { getSublegends } = useCatalog() // Use local catalog if any @@ -152,6 +159,9 @@ watch([() => props.sublegends, () => props.sublegendsFromCatalog], async () => { // Retrieve the legends from catalog if required if (props.sublegendsFromCatalog) { sublegends.value = await getSublegends() + if (project) { + sublegends.value = sublegends.value.concat(await getProjectSublegends()) + } if (Store.get('context')) { sublegends.value = sublegends.value.concat(await getContextSublegends()) }