Skip to content

Commit 21355ef

Browse files
committed
PB-1613 : sending ready event in print legend view
1 parent 95bf187 commit 21355ef

File tree

2 files changed

+27
-4
lines changed

2 files changed

+27
-4
lines changed

packages/mapviewer/src/modules/menu/components/LayerDescription.vue

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<script setup>
2-
import { computed, onMounted, ref, watch } from 'vue'
2+
import { computed, nextTick, onMounted, ref, watch } from 'vue'
33
import { useI18n } from 'vue-i18n'
44
import { useStore } from 'vuex'
55
@@ -22,6 +22,8 @@ const { layer, layerId, transformUrlIntoQrcode } = defineProps({
2222
},
2323
})
2424
25+
const emits = defineEmits(['loaded'])
26+
2527
const htmlContent = ref('')
2628
2729
const { t } = useI18n()
@@ -51,7 +53,11 @@ watch(
5153
}
5254
}
5355
)
54-
watch(htmlContent, transformATagIntoQRCodes)
56+
watch(htmlContent, () => {
57+
nextTick(() => {
58+
transformATagIntoQRCodes()
59+
})
60+
})
5561
5662
onMounted(async () => {
5763
if (!isExternal.value && layer) {
@@ -67,6 +73,7 @@ function transformATagIntoQRCodes() {
6773
a.innerHTML = `<img width="90" src="${getGenerateQRCodeUrl(a.href)}" alt="">`
6874
})
6975
}
76+
emits('loaded')
7077
}
7178
</script>
7279

packages/mapviewer/src/views/PrintLegendView.vue

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,29 @@
11
<script setup>
2-
import { computed } from 'vue'
2+
import log from '@geoadmin/log'
3+
import { computed, ref, watch } from 'vue'
34
import { useStore } from 'vuex'
45
6+
import { sendMapReadyEventToParent } from '@/api/iframePostMessageEvent.api'
57
import LayerDescription from '@/modules/menu/components/LayerDescription.vue'
68
import usePrintViewCommons from '@/views/usePrintViewCommons.composable'
79
810
const { printLayout, printContainerStyle } = usePrintViewCommons()
911
12+
const loadedLayerDescriptions = ref(0)
13+
1014
const store = useStore()
1115
const visibleLayers = computed(() => store.getters.visibleLayers)
16+
const visibleLayersCount = computed(() => visibleLayers.value.length)
17+
18+
watch(visibleLayersCount, () => {
19+
loadedLayerDescriptions.value = 0
20+
})
21+
watch(loadedLayerDescriptions, () => {
22+
if (loadedLayerDescriptions.value === visibleLayersCount.value) {
23+
log.debug('All layer descriptions loaded. Sending map ready event to parent window.')
24+
sendMapReadyEventToParent()
25+
}
26+
})
1227
</script>
1328

1429
<template>
@@ -23,6 +38,7 @@ const visibleLayers = computed(() => store.getters.visibleLayers)
2338
:layer="layer"
2439
:layer-id="layer.id"
2540
transform-url-into-qrcode
41+
@loaded="loadedLayerDescriptions++"
2642
/>
2743
</div>
2844
</template>
@@ -31,7 +47,7 @@ const visibleLayers = computed(() => store.getters.visibleLayers)
3147
.print-legend-view {
3248
display: grid;
3349
gap: 20px;
34-
grid-template-columns: repeat(3, 1fr);
50+
grid-template-columns: repeat(2, 1fr);
3551
}
3652
3753
@media print {

0 commit comments

Comments
 (0)