fix(VnSection): refs #8197 check route #1263

Merged
alexm merged 4 commits from 8197-better_check_route into dev 2025-01-21 14:11:35 +00:00
1 changed files with 22 additions and 10 deletions
Showing only changes of commit 7bca8a4194 - Show all commits

View File

@ -2,9 +2,9 @@
import RightMenu from './RightMenu.vue';
import VnSearchbar from 'components/ui/VnSearchbar.vue';
import VnTableFilter from '../VnTable/VnTableFilter.vue';
import { onBeforeMount, computed, ref } from 'vue';
import { onBeforeMount, onMounted, onUnmounted, computed, ref } from 'vue';
import { useArrayData } from 'src/composables/useArrayData';
import { useRoute } from 'vue-router';
import { useRoute, useRouter } from 'vue-router';
import { useHasContent } from 'src/composables/useHasContent';
const $props = defineProps({
@ -47,16 +47,12 @@ const $props = defineProps({
});
const route = useRoute();
const router = useRouter();
let arrayData;
const sectionValue = computed(() => $props.section ?? $props.dataKey);
const isMainSection = computed(() => {
const isSame = sectionValue.value == route.name;
if (!isSame && arrayData) {
arrayData.reset(['userParams', 'filter']);
arrayData.setCurrentFilter();
}
return isSame;
});
const isMainSection = ref();
alexm marked this conversation as resolved Outdated

valor por defecto a false? Asumo que por el nombre es un booleano

valor por defecto a false? Asumo que por el nombre es un booleano
Outdated
Review

null me vale jajaj pero si le pongo false

null me vale jajaj pero si le pongo false
const searchbarId = 'section-searchbar';
const hasContent = useHasContent(`#${searchbarId}`);
@ -68,7 +64,23 @@ onBeforeMount(() => {
...$props.arrayDataProps,
navigate: $props.redirect,
});
checkIsMain();
});
onMounted(() => {
const unsubscribe = router.afterEach(() => {
checkIsMain();
});
onUnmounted(() => unsubscribe());
alexm marked this conversation as resolved Outdated

Bien, y así también serviria onUnmounted(unsubscribe); no?

Bien, y así también serviria ` onUnmounted(unsubscribe);` no?
});
function checkIsMain() {
isMainSection.value = sectionValue.value == route.name;
if (!isMainSection.value && arrayData) {
arrayData.reset(['userParams', 'filter']);
arrayData.setCurrentFilter();
}
}
</script>
<template>
<slot name="searchbar">