Skip to content

Commit

Permalink
Fix duplicated static/animated layer state
Browse files Browse the repository at this point in the history
  • Loading branch information
ceesvoesenek authored and wkramer committed Dec 20, 2024
1 parent 17672ee commit b89ff9c
Showing 1 changed file with 14 additions and 16 deletions.
30 changes: 14 additions & 16 deletions src/components/wms/InformationPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@
<template v-slot:append>
<v-switch
density="compact"
v-model="animate"
v-model="doAnimateStreamlines"
hide-details
></v-switch>
</template>
Expand All @@ -118,11 +118,11 @@
</v-menu>
<v-btn
v-if="showLayer && canUseStreamlines"
@click="switchLayerType"
@click="toggleLayerType"
icon
density="compact"
variant="plain"
:color="animate ? 'primary' : undefined"
:color="doAnimateStreamlines ? 'primary' : undefined"
>
<v-progress-circular v-if="isLoading" size="20" indeterminate />
<v-icon v-else>mdi-animation-play</v-icon>
Expand Down Expand Up @@ -158,9 +158,18 @@ const props = withDefaults(defineProps<Props>(), {
layerTitle: '',
completelyMissing: false,
})
const showLayer = defineModel<boolean>('showLayer')
const layerKind = defineModel<LayerKind>('layerKind')
const emit = defineEmits(['update:layerKind', 'update:current-colour-scale'])
const doAnimateStreamlines = computed<boolean>({
get: () => layerKind.value === LayerKind.Streamline,
set: (doAnimate) => {
layerKind.value = doAnimate ? LayerKind.Streamline : LayerKind.Static
},
})
const currentColourScaleIndex = ref(0)
watch(
() => props.currentColourScaleIds,
Expand Down Expand Up @@ -207,9 +216,6 @@ const changeCurrentColourScaleRange = () => {
currentScale.value.range = mutableColorScaleRange.value
}
const showLayer = defineModel<boolean>('showLayer')
const animate = defineModel<boolean>('animate', { default: false })
const rules = {
required: (v: number) =>
(v !== null && v !== undefined && String(v) !== '') || 'Field is required',
Expand Down Expand Up @@ -244,17 +250,9 @@ const formattedTimeRange = computed(() => {
)} → ${DateTime.fromJSDate(props.lastValueTime).toFormat(format)}`
})
const switchLayerType = () => {
animate.value = !animate.value
function toggleLayerType(): void {
doAnimateStreamlines.value = !doAnimateStreamlines.value
}
watch(
() => animate.value,
() => {
const value = animate.value ? LayerKind.Streamline : LayerKind.Static
emit('update:layerKind', value)
},
)
</script>

<style scoped>
Expand Down

0 comments on commit b89ff9c

Please sign in to comment.