From 493e51833955b79906b46ca552c7074e0af419c6 Mon Sep 17 00:00:00 2001 From: Jon Date: Tue, 29 Oct 2024 12:15:40 +0100 Subject: [PATCH] feat: refs #6999 added search when user tabs on a filter with value --- src/pages/Entry/EntryLatestBuys.vue | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/pages/Entry/EntryLatestBuys.vue b/src/pages/Entry/EntryLatestBuys.vue index 119808176..50a4ccc7f 100644 --- a/src/pages/Entry/EntryLatestBuys.vue +++ b/src/pages/Entry/EntryLatestBuys.vue @@ -4,6 +4,7 @@ import { useI18n } from 'vue-i18n'; import { useStateStore } from 'stores/useStateStore'; import { toDate } from 'src/filters'; +import { useArrayData } from 'composables/useArrayData'; import VnSubToolbar from 'src/components/ui/VnSubToolbar.vue'; import RightMenu from 'src/components/common/RightMenu.vue'; import EntryLatestBuysFilter from './EntryLatestBuysFilter.vue'; @@ -12,6 +13,9 @@ import VnImg from 'src/components/ui/VnImg.vue'; const stateStore = useStateStore(); const { t } = useI18n(); +const tableRef = ref(); +const arrayData = useArrayData('LatestBuys', { searchUrl: 'Buys/latestBuysFilter' }); +const lastParams = {}; const columns = [ { align: 'center', @@ -234,13 +238,26 @@ const columns = [ format: (row, dashIfEmpty) => dashIfEmpty(toDate(row.landing)), }, ]; -const tableRef = ref(); onMounted(async () => { stateStore.rightDrawer = true; }); onUnmounted(() => (stateStore.rightDrawer = false)); + +const onTabPressed = async () => { + let params = tableRef.value.params; + + if ( + Object.keys(params).length > 0 && + JSON.stringify(params) !== JSON.stringify(lastParams) + ) { + Object.assign(lastParams, params); + + await arrayData.addFilter({ filter: { where: params } }); + } + params = {}; +};