From 93326db2d97bdea10efe59114d0a7067f365d814 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Sun, 23 Feb 2025 13:11:43 +0100 Subject: [PATCH] fix: call filterpanel from searchbar --- src/components/common/VnSection.vue | 26 ++++++++++++--- src/components/ui/VnFilterPanel.vue | 49 +++++++++++++++++---------- src/components/ui/VnSearchbar.vue | 51 ++++++++++++++++++++++------- src/composables/useArrayData.js | 15 +++++++-- src/pages/Ticket/TicketFilter.vue | 29 ++++++++++++---- src/pages/Ticket/TicketList.vue | 23 ++++++------- 6 files changed, 138 insertions(+), 55 deletions(-) diff --git a/src/components/common/VnSection.vue b/src/components/common/VnSection.vue index 6677fa312..1b1c18d7d 100644 --- a/src/components/common/VnSection.vue +++ b/src/components/common/VnSection.vue @@ -2,7 +2,7 @@ import RightAdvancedMenu from './RightAdvancedMenu.vue'; import VnSearchbar from 'components/ui/VnSearchbar.vue'; import VnTableFilter from '../VnTable/VnTableFilter.vue'; -import { onBeforeMount, onMounted, onUnmounted, computed, ref, provide } from 'vue'; +import { onBeforeMount, onMounted, onUnmounted, computed, ref, inject, watch } from 'vue'; import { useArrayData } from 'src/composables/useArrayData'; import { useRoute, useRouter } from 'vue-router'; import { useHasContent } from 'src/composables/useHasContent'; @@ -36,6 +36,10 @@ const $props = defineProps({ type: Object, default: null, }, + filterPanelRef: { + type: Object, + default: null, + }, redirect: { type: Boolean, default: true, @@ -52,12 +56,13 @@ const router = useRouter(); let arrayData; const sectionValue = computed(() => $props.section ?? $props.dataKey); const isMainSection = ref(false); -const searchbarRef = ref(null); const searchbarId = 'section-searchbar'; const advancedMenuSlot = 'advanced-menu'; const hasContent = useHasContent(`#${searchbarId}`); -provide('searchbar', () => searchbarRef.value?.search()); +// const filterPanel = ref(inject('filterPanel', null)); + +// filterPanel.value = inject('filterPanel', null); onBeforeMount(() => { if ($props.dataKey) @@ -69,14 +74,26 @@ onBeforeMount(() => { }); checkIsMain(); }); +// const filterPanel = ref(inject('filterPanel', null)); onMounted(() => { const unsubscribe = router.afterEach(() => { checkIsMain(); }); + // filterPanel.value = inject('filterPanel', null); onUnmounted(unsubscribe); }); +watch( + () => inject('filterPanel'), + (newValue) => { + if (newValue) { + debugger; + // hacer algo cuando el valor esté disponible + } + }, + { immediate: true }, +); onUnmounted(() => { if (arrayData) arrayData.destroy(); }); @@ -90,9 +107,10 @@ function checkIsMain() { }