Bugfixing a refaktoring

This commit is contained in:
Michal Kváček
2023-10-13 23:25:06 +02:00
parent bf8df8bb34
commit 5b47c56c6f
10 changed files with 151 additions and 116 deletions
+16 -1
View File
@@ -1,6 +1,7 @@
<template>
<q-item
clickable
:active="isButtonActive"
tag="router-link"
:to="to"
>
@@ -19,6 +20,8 @@
</template>
<script setup>
import {computed} from "vue";
import {useRoute, useRouter} from "vue-router";
const props = defineProps({
title: {
@@ -40,5 +43,17 @@ const props = defineProps({
type: String,
default: ''
}
})
});
const $route = useRoute();
const $router = useRouter();
const isButtonActive = computed(() => {
const btnResolvedPath = $router.resolve(props.to).path;
if (props.to.name === 'myFlights') {
return $route.name.toLowerCase().includes("flight");
} else {
return $route.fullPath === btnResolvedPath || $route.fullPath.startsWith(btnResolvedPath);
}
});
</script>